Skip to content

Commit

Permalink
fip-0100: handle sector termination and expiration
Browse files Browse the repository at this point in the history
  • Loading branch information
Stebalien committed Feb 14, 2025
1 parent ad9059e commit 9fe997b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
11 changes: 10 additions & 1 deletion actors/miner/src/deadline_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,7 @@ impl Deadline {
let mut all_on_time_pledge = TokenAmount::zero();
let mut all_active_power = PowerPair::zero();
let mut all_faulty_power = PowerPair::zero();
let mut all_fee_deductions = TokenAmount::zero();
let mut partitions_with_early_terminations = Vec::<u64>::new();

// For each partition with an expiry, remove and collect expirations from the partition queue.
Expand Down Expand Up @@ -384,6 +385,7 @@ impl Deadline {
all_active_power += &partition_expiration.active_power;
all_faulty_power += &partition_expiration.faulty_power;
all_on_time_pledge += &partition_expiration.on_time_pledge;
all_fee_deductions += &partition_expiration.fee_deduction;

partitions.set(partition_idx, partition)?;
}
Expand All @@ -404,14 +406,18 @@ impl Deadline {
self.live_sectors -= on_time_count + early_count;

self.faulty_power -= &all_faulty_power;
self.total_power -= &all_faulty_power;
self.total_power -= &all_active_power;

self.daily_fee -= &all_fee_deductions;

Ok(ExpirationSet {
on_time_sectors: all_on_time_sectors,
early_sectors: all_early_sectors,
on_time_pledge: all_on_time_pledge,
active_power: all_active_power,
faulty_power: all_faulty_power,
fee_deduction: TokenAmount::zero(),
fee_deduction: all_fee_deductions,
})
}

Expand Down Expand Up @@ -634,6 +640,9 @@ impl Deadline {
} // note: we should _always_ have early terminations, unless the early termination bitfield is empty.

self.faulty_power -= &removed.faulty_power;
self.total_power -= &removed.active_power;
self.total_power -= &removed.faulty_power;
self.daily_fee -= &removed.fee_deduction;

// Aggregate power lost from active sectors
power_lost += &removed.active_power;
Expand Down
4 changes: 3 additions & 1 deletion actors/miner/src/expiration_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,7 @@ impl<'db, BS: Blockstore> ExpirationQueue<'db, BS> {
let mut active_power = PowerPair::zero();
let mut faulty_power = PowerPair::zero();
let mut on_time_pledge = TokenAmount::zero();
let mut fee_deduction = TokenAmount::zero();
let mut popped_keys = Vec::<u64>::new();

self.amt.for_each_while(|i, this_value| {
Expand All @@ -634,6 +635,7 @@ impl<'db, BS: Blockstore> ExpirationQueue<'db, BS> {
active_power += &this_value.active_power;
faulty_power += &this_value.faulty_power;
on_time_pledge += &this_value.on_time_pledge;
fee_deduction += &this_value.fee_deduction;

Ok(true)
})?;
Expand All @@ -646,7 +648,7 @@ impl<'db, BS: Blockstore> ExpirationQueue<'db, BS> {
on_time_pledge,
active_power,
faulty_power,
fee_deduction: TokenAmount::zero(),
fee_deduction,
})
}

Expand Down

0 comments on commit 9fe997b

Please sign in to comment.