Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bugs in terminate sectors logic #950

Merged
merged 1 commit into from
Jan 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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