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

fip-0100: initial pass at daily_fee accounting #1622

Merged
merged 15 commits into from
Feb 19, 2025
Merged
Show file tree
Hide file tree
Changes from 2 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
17 changes: 15 additions & 2 deletions 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 All @@ -433,6 +439,8 @@ impl Deadline {
return Ok(total_power);
}

let mut total_daily_fee = TokenAmount::zero();

// First update partitions, consuming the sectors
let mut partition_deadline_updates = Vec::<(ChainEpoch, u64)>::with_capacity(sectors.len());
self.live_sectors += sectors.len() as u64;
Expand Down Expand Up @@ -466,9 +474,10 @@ impl Deadline {
sectors = &sectors[size..];

// Add sectors to partition.
let partition_power =
let (partition_power, partition_daily_fee) =
partition.add_sectors(store, proven, partition_new_sectors, sector_size, quant)?;
total_power += &partition_power;
total_daily_fee += &partition_daily_fee;

// Save partition back.
partitions.set(partition_idx, partition)?;
Expand All @@ -493,6 +502,7 @@ impl Deadline {
.add_many_to_queue_values(partition_deadline_updates.iter().copied())
.map_err(|e| e.downcast_wrap("failed to add expirations for new deadlines"))?;
self.expirations_epochs = deadline_expirations.amt.flush()?;
self.daily_fee += &total_daily_fee;

Ok(total_power)
}
Expand Down Expand Up @@ -630,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
Loading
Loading