Skip to content

Commit 7626397

Browse files
committedMar 5, 2025
fip-0100: remove batch balancer ("aggregate fee")
Closes: #1611
1 parent e11b5cd commit 7626397

13 files changed

+27
-564
lines changed
 

‎actors/miner/src/lib.rs

+2-55
Original file line numberDiff line numberDiff line change
@@ -847,8 +847,6 @@ impl Actor {
847847
emit::sector_activated(rt, pc.info.sector_number, unsealed_cid, &data.pieces)?;
848848
}
849849

850-
// The aggregate fee is paid on the sectors successfully proven.
851-
pay_aggregate_seal_proof_fee(rt, valid_precommits.len())?;
852850
Ok(())
853851
}
854852

@@ -1586,22 +1584,8 @@ impl Actor {
15861584
let mut fee_to_burn = TokenAmount::zero();
15871585
let mut needs_cron = false;
15881586
rt.transaction(|state: &mut State, rt| {
1589-
// Aggregate fee applies only when batching.
1590-
if sectors.len() > 1 {
1591-
let aggregate_fee = aggregate_pre_commit_network_fee(sectors.len(), &rt.base_fee());
1592-
// AggregateFee applied to fee debt to consolidate burn with outstanding debts
1593-
state.apply_penalty(&aggregate_fee)
1594-
.map_err(|e| {
1595-
actor_error!(
1596-
illegal_state,
1597-
"failed to apply penalty: {}",
1598-
e
1599-
)
1600-
})?;
1601-
}
1602-
// available balance already accounts for fee debt so it is correct to call
1603-
// this before RepayDebts. We would have to
1604-
// subtract fee debt explicitly if we called this after.
1587+
// Available balance already accounts for fee debt so it is correct to call this before
1588+
// repay_debts. We would have to subtract fee debt explicitly if we called this after.
16051589
let available_balance = state
16061590
.get_available_balance(&rt.current_balance())
16071591
.map_err(|e| {
@@ -1921,13 +1905,6 @@ impl Actor {
19211905
&info,
19221906
)?;
19231907

1924-
if !params.aggregate_proof.is_empty() {
1925-
// Aggregate fee is paid on the sectors successfully proven,
1926-
// but without regard to data activation which may have subsequently failed
1927-
// and prevented sector activation.
1928-
pay_aggregate_seal_proof_fee(rt, proven_activation_inputs.len())?;
1929-
}
1930-
19311908
// Notify data consumers.
19321909
let mut notifications: Vec<ActivationNotifications> = vec![];
19331910
for (activations, sector) in &successful_sector_activations {
@@ -2207,13 +2184,6 @@ impl Actor {
22072184

22082185
burn_funds(rt, fee_to_burn)?;
22092186

2210-
let len_for_aggregate_fee = if sectors_len <= NI_AGGREGATE_FEE_BASE_SECTOR_COUNT {
2211-
0
2212-
} else {
2213-
sectors_len - NI_AGGREGATE_FEE_BASE_SECTOR_COUNT
2214-
};
2215-
pay_aggregate_seal_proof_fee(rt, len_for_aggregate_fee)?;
2216-
22172187
notify_pledge_changed(rt, &total_pledge)?;
22182188

22192189
let state: State = rt.state()?;
@@ -5181,29 +5151,6 @@ fn verify_aggregate_seal(
51815151
.context_code(ExitCode::USR_ILLEGAL_ARGUMENT, "aggregate seal verify failed")
51825152
}
51835153

5184-
// Compute and burn the aggregate network fee.
5185-
fn pay_aggregate_seal_proof_fee(
5186-
rt: &impl Runtime,
5187-
aggregate_size: usize,
5188-
) -> Result<(), ActorError> {
5189-
// State is loaded afresh as earlier operations for sector/data activation can change it.
5190-
let state: State = rt.state()?;
5191-
let aggregate_fee = aggregate_prove_commit_network_fee(aggregate_size, &rt.base_fee());
5192-
let unlocked_balance = state
5193-
.get_unlocked_balance(&rt.current_balance())
5194-
.map_err(|_e| actor_error!(illegal_state, "failed to determine unlocked balance"))?;
5195-
if unlocked_balance < aggregate_fee {
5196-
return Err(actor_error!(
5197-
insufficient_funds,
5198-
"remaining unlocked funds after prove-commit {} are insufficient to pay aggregation fee of {}",
5199-
unlocked_balance,
5200-
aggregate_fee
5201-
));
5202-
}
5203-
burn_funds(rt, aggregate_fee)?;
5204-
state.check_balance_invariants(&rt.current_balance()).map_err(balance_invariants_broken)
5205-
}
5206-
52075154
fn verify_deals(
52085155
rt: &impl Runtime,
52095156
sectors: &[ext::market::SectorDeals],

‎actors/miner/src/monies.rs

+2-38
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
// Copyright 2019-2022 ChainSafe Systems
22
// SPDX-License-Identifier: Apache-2.0, MIT
33

4-
use std::cmp::{self, max};
4+
use std::cmp;
55

66
use fil_actors_runtime::network::EPOCHS_IN_DAY;
77
use fil_actors_runtime::reward::math::PRECISION;
88
use fil_actors_runtime::reward::{smooth, FilterEstimate};
99
use fil_actors_runtime::EXPECTED_LEADERS_PER_EPOCH;
10-
use fvm_shared::bigint::{BigInt, Integer};
10+
use fvm_shared::bigint::Integer;
1111
use fvm_shared::clock::ChainEpoch;
1212
use fvm_shared::econ::TokenAmount;
1313
use fvm_shared::sector::StoragePower;
@@ -107,10 +107,6 @@ pub fn expected_reward_for_power(
107107
pub mod detail {
108108
use super::*;
109109

110-
lazy_static! {
111-
pub static ref BATCH_BALANCER: TokenAmount = TokenAmount::from_nano(5);
112-
}
113-
114110
// BR but zero values are clamped at 1 attofil
115111
// Some uses of BR (PCD, IP) require a strictly positive value for BR derived values so
116112
// accounting variables can be used as succinct indicators of miner activity.
@@ -322,35 +318,3 @@ pub fn locked_reward_from_reward(reward: TokenAmount) -> (TokenAmount, &'static
322318
let lock_amount = (reward * LOCKED_REWARD_FACTOR_NUM).div_floor(LOCKED_REWARD_FACTOR_DENOM);
323319
(lock_amount, &REWARD_VESTING_SPEC)
324320
}
325-
326-
const BATCH_DISCOUNT_NUM: u32 = 1;
327-
const BATCH_DISCOUNT_DENOM: u32 = 20;
328-
329-
lazy_static! {
330-
static ref ESTIMATED_SINGLE_PROVE_COMMIT_GAS_USAGE: BigInt = BigInt::from(49299973);
331-
static ref ESTIMATED_SINGLE_PRE_COMMIT_GAS_USAGE: BigInt = BigInt::from(16433324);
332-
}
333-
334-
pub fn aggregate_prove_commit_network_fee(
335-
aggregate_size: usize,
336-
base_fee: &TokenAmount,
337-
) -> TokenAmount {
338-
aggregate_network_fee(aggregate_size, &ESTIMATED_SINGLE_PROVE_COMMIT_GAS_USAGE, base_fee)
339-
}
340-
341-
pub fn aggregate_pre_commit_network_fee(
342-
aggregate_size: usize,
343-
base_fee: &TokenAmount,
344-
) -> TokenAmount {
345-
aggregate_network_fee(aggregate_size, &ESTIMATED_SINGLE_PRE_COMMIT_GAS_USAGE, base_fee)
346-
}
347-
348-
pub fn aggregate_network_fee(
349-
aggregate_size: usize,
350-
gas_usage: &BigInt,
351-
base_fee: &TokenAmount,
352-
) -> TokenAmount {
353-
let effective_gas_fee = max(base_fee, &*BATCH_BALANCER);
354-
let network_fee_num = effective_gas_fee * gas_usage * aggregate_size * BATCH_DISCOUNT_NUM;
355-
network_fee_num.div_floor(BATCH_DISCOUNT_DENOM)
356-
}

‎actors/miner/src/policy.rs

-3
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@ use super::{PowerPair, BASE_REWARD_FOR_DISPUTED_WINDOW_POST};
2020
/// Precision used for making QA power calculations
2121
pub const SECTOR_QUALITY_PRECISION: i64 = 20;
2222

23-
/// Base number of sectors before imposing the additional aggregate fee in ProveCommitSectorsNI
24-
pub const NI_AGGREGATE_FEE_BASE_SECTOR_COUNT: usize = 5;
25-
2623
lazy_static! {
2724
/// Quality multiplier for committed capacity (no deals) in a sector
2825
pub static ref QUALITY_BASE_MULTIPLIER: BigInt = BigInt::from(10);

‎actors/miner/tests/aggregate_network_fee_test.rs

-89
This file was deleted.

‎actors/miner/tests/aggregate_prove_commit.rs

-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ use fvm_shared::{bigint::BigInt, clock::ChainEpoch, econ::TokenAmount};
1010

1111
mod util;
1212
use fil_actors_runtime::test_utils::make_piece_cid;
13-
use num_traits::Zero;
1413
use util::*;
1514

1615
// an expiration ~10 days greater than effective min expiration taking into account 30 days max
@@ -69,7 +68,6 @@ fn valid_precommits_then_aggregate_provecommit() {
6968
pcc,
7069
precommits,
7170
make_prove_commit_aggregate(&sector_nos_bf),
72-
&TokenAmount::zero(),
7371
)
7472
.unwrap();
7573

0 commit comments

Comments
 (0)