Skip to content

Commit

Permalink
Fix bugs in terminate sectors logic (#950)
Browse files Browse the repository at this point in the history
  • Loading branch information
austinabell authored Jan 22, 2021
1 parent ccd4fbd commit 721bc46
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
8 changes: 5 additions & 3 deletions vm/actor/src/builtin/miner/expiration_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -490,14 +490,16 @@ impl<'db, BS: BlockStore> ExpirationQueue<'db, BS> {

// Split into faulty and non-faulty. We process non-faulty sectors first
// because they always expire on-time so we know where to find them.
let mut non_faulty_sectors = Vec::<&SectorOnChainInfo>::new();
// TODO since cloning info, should be RC or find a way for data to be references.
// This might get optimized by the compiler, so not a priority
let mut non_faulty_sectors = Vec::<SectorOnChainInfo>::new();
let mut faulty_sectors = Vec::<&SectorOnChainInfo>::new();

for sector in sectors {
if faults_map.contains(&sector.sector_number) {
faulty_sectors.push(sector);
} else {
non_faulty_sectors.push(sector);
non_faulty_sectors.push(sector.clone());

// remove them from "remaining", we're going to process them below.
remaining.remove(&sector.sector_number);
Expand All @@ -506,7 +508,7 @@ impl<'db, BS: BlockStore> ExpirationQueue<'db, BS> {

// Remove non-faulty sectors.
let (removed_sector_numbers, removed_power, removed_pledge) = self
.remove_active_sectors(sectors, sector_size)
.remove_active_sectors(&non_faulty_sectors, sector_size)
.map_err(|e| e.downcast_wrap("failed to remove on-time recoveries"))?;
removed.on_time_sectors = removed_sector_numbers;
removed.active_power = removed_power;
Expand Down
4 changes: 2 additions & 2 deletions vm/actor/src/builtin/miner/partition_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -485,8 +485,8 @@ impl Partition {
)
})?;

if live_sectors.contains_all(sector_numbers) {
return Err(actor_error!(ErrIllegalArgument; "can only terminate live sectors").into());
if !live_sectors.contains_all(sector_numbers) {
return Err(actor_error!(ErrIllegalArgument, "can only terminate live sectors").into());
}

let sector_infos = sectors.load_sector(sector_numbers)?;
Expand Down

0 comments on commit 721bc46

Please sign in to comment.