Skip to content

Commit

Permalink
chore(miner): extract NI_AGGREGATE_FEE_BASE_SECTOR_COUNT constant
Browse files Browse the repository at this point in the history
  • Loading branch information
rvagg committed Jun 25, 2024
1 parent d29c6c6 commit 5d61fe1
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 7 deletions.
6 changes: 5 additions & 1 deletion actors/miner/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)?;
Expand Down
3 changes: 3 additions & 0 deletions actors/miner/src/policy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 5 additions & 3 deletions actors/miner/tests/prove_commit_niporep.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*;
Expand Down Expand Up @@ -184,9 +185,10 @@ fn ni_prove_partialy_valid_sectors_not_required_activation() {

rt.set_epoch(activation_epoch);

let sector_nums = (0..7).collect::<Vec<_>>();
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::<Vec<_>>();
let num_fails = *NI_AGGREGATE_FEE_BASE_SECTOR_COUNT;
let mut params = h.make_prove_commit_ni_params(
miner,
&sector_nums,
Expand Down
7 changes: 4 additions & 3 deletions actors/miner/tests/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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.clone() {
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.clone(),
&rt.base_fee.borrow(),
);
rt.expect_send_simple(
Expand Down

0 comments on commit 5d61fe1

Please sign in to comment.