From 6a83b82321cd289334a1cd95932880b254379bc2 Mon Sep 17 00:00:00 2001 From: Rod Vagg Date: Tue, 25 Jun 2024 15:01:21 +1000 Subject: [PATCH] chore(miner): extract NI_AGGREGATE_FEE_BASE_SECTOR_COUNT constant --- actors/miner/src/lib.rs | 6 +++++- actors/miner/src/policy.rs | 3 +++ actors/miner/tests/prove_commit_niporep.rs | 8 +++++--- actors/miner/tests/util.rs | 7 ++++--- 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/actors/miner/src/lib.rs b/actors/miner/src/lib.rs index e3d461ea0..cf1718b6d 100644 --- a/actors/miner/src/lib.rs +++ b/actors/miner/src/lib.rs @@ -2197,7 +2197,11 @@ impl Actor { burn_funds(rt, fee_to_burn)?; - let len_for_aggregate_fee = if sectors_len <= 5 { 0 } else { sectors_len - 5 }; + let len_for_aggregate_fee = if sectors_len <= *NI_AGGREGATE_FEE_BASE_SECTOR_COUNT { + 0 + } else { + sectors_len - *NI_AGGREGATE_FEE_BASE_SECTOR_COUNT + }; pay_aggregate_seal_proof_fee(rt, len_for_aggregate_fee)?; notify_pledge_changed(rt, &total_pledge)?; diff --git a/actors/miner/src/policy.rs b/actors/miner/src/policy.rs index aae212195..4f7de338b 100644 --- a/actors/miner/src/policy.rs +++ b/actors/miner/src/policy.rs @@ -29,6 +29,9 @@ lazy_static! { /// Quality multiplier for verified deals in a sector pub static ref VERIFIED_DEAL_WEIGHT_MULTIPLIER: BigInt = BigInt::from(100); + + /// Base number of sectors before imposing the additional aggregate fee in ProveCommitSectorsNI + pub static ref NI_AGGREGATE_FEE_BASE_SECTOR_COUNT: usize = 5; } /// The maximum number of partitions that may be required to be loaded in a single invocation, diff --git a/actors/miner/tests/prove_commit_niporep.rs b/actors/miner/tests/prove_commit_niporep.rs index cd0a9aa7d..4bdbde313 100644 --- a/actors/miner/tests/prove_commit_niporep.rs +++ b/actors/miner/tests/prove_commit_niporep.rs @@ -4,6 +4,7 @@ use fvm_shared::{bigint::BigInt, clock::ChainEpoch, error::ExitCode}; use fil_actor_miner::{ Actor, Method, SectorNIActivationInfo, SectorOnChainInfo, SectorOnChainInfoFlags, + NI_AGGREGATE_FEE_BASE_SECTOR_COUNT, }; use num_traits::Zero; use util::*; @@ -184,9 +185,10 @@ fn ni_prove_partialy_valid_sectors_not_required_activation() { rt.set_epoch(activation_epoch); - let sector_nums = (0..7).collect::>(); - let num_fails = 5; - let num_success = sector_nums.len() - num_fails; + let num_success: usize = 2; + let sector_nums = + (0..((*NI_AGGREGATE_FEE_BASE_SECTOR_COUNT + num_success) as u64)).collect::>(); + let num_fails = *NI_AGGREGATE_FEE_BASE_SECTOR_COUNT; let mut params = h.make_prove_commit_ni_params( miner, §or_nums, diff --git a/actors/miner/tests/util.rs b/actors/miner/tests/util.rs index 80ab66ce8..62f08b075 100644 --- a/actors/miner/tests/util.rs +++ b/actors/miner/tests/util.rs @@ -79,7 +79,8 @@ use fil_actor_miner::{ SectorReturn, SectorUpdateManifest, Sectors, State, SubmitWindowedPoStParams, TerminateSectorsParams, TerminationDeclaration, VerifiedAllocationKey, VestingFunds, WindowedPoSt, WithdrawBalanceParams, WithdrawBalanceReturn, CRON_EVENT_PROVING_DEADLINE, - NO_QUANTIZATION, REWARD_VESTING_SPEC, SECTORS_AMT_BITWIDTH, SECTOR_CONTENT_CHANGED, + NI_AGGREGATE_FEE_BASE_SECTOR_COUNT, NO_QUANTIZATION, REWARD_VESTING_SPEC, SECTORS_AMT_BITWIDTH, + SECTOR_CONTENT_CHANGED, }; use fil_actor_miner::{ raw_power_for_sector, ProveCommitSectorsNIParams, ProveCommitSectorsNIReturn, @@ -909,9 +910,9 @@ impl ActorHarness { self.expect_query_network_info(rt); - if params.sectors.len() - fail_count > 5 { + if params.sectors.len() - fail_count > *NI_AGGREGATE_FEE_BASE_SECTOR_COUNT { let aggregate_fee = aggregate_prove_commit_network_fee( - params.sectors.len() - fail_count - 5, + params.sectors.len() - fail_count - *NI_AGGREGATE_FEE_BASE_SECTOR_COUNT, &rt.base_fee.borrow(), ); rt.expect_send_simple(