Skip to content

Commit

Permalink
feat: limit PoSted partitions to 3
Browse files Browse the repository at this point in the history
  • Loading branch information
arajasek committed Oct 11, 2023
1 parent 82dd420 commit 7e4cd0e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
15 changes: 10 additions & 5 deletions actors/miner/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
use std::cmp::max;
use std::collections::btree_map::Entry;
use std::collections::{BTreeMap, BTreeSet};
use std::iter;
use std::ops::Neg;
use std::{cmp, iter};

use anyhow::{anyhow, Error};
use byteorder::{BigEndian, ByteOrder, WriteBytesExt};
Expand Down Expand Up @@ -561,8 +561,11 @@ impl Actor {
}

// Validate that the miner didn't try to prove too many partitions at once.
let submission_partition_limit =
load_partitions_sectors_max(rt.policy(), info.window_post_partition_sectors);
let submission_partition_limit = cmp::min(
load_partitions_sectors_max(rt.policy(), info.window_post_partition_sectors),
rt.policy().posted_partitions_max,
);

if params.partitions.len() as u64 > submission_partition_limit {
return Err(actor_error!(
illegal_argument,
Expand Down Expand Up @@ -4401,8 +4404,10 @@ struct SectorSealProofInput {
pub sector_number: SectorNumber,
pub randomness: SealRandomness,
pub interactive_randomness: InteractiveSealRandomness,
pub sealed_cid: Cid, // Commr
pub unsealed_cid: Cid, // Commd
// Commr
pub sealed_cid: Cid,
// Commd
pub unsealed_cid: Cid,
}

impl SectorSealProofInput {
Expand Down
6 changes: 6 additions & 0 deletions runtime/src/runtime/policy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ pub struct Policy {
/// The maximum number of sector infos that may be required to be loaded in a single invocation.
pub addressed_sectors_max: u64,

/// The maximum number of partitions that can be proven in a single PoSt message.
pub posted_partitions_max: u64,

pub max_pre_commit_randomness_lookback: ChainEpoch,

/// Number of epochs between publishing the precommit and when the challenge for interactive PoRep is drawn
Expand Down Expand Up @@ -173,6 +176,7 @@ impl Default for Policy {
addressed_partitions_max: policy_constants::ADDRESSED_PARTITIONS_MAX,
declarations_max: policy_constants::DECLARATIONS_MAX,
addressed_sectors_max: policy_constants::ADDRESSED_SECTORS_MAX,
posted_partitions_max: policy_constants::POSTED_PARTITIONS_MAX,
max_pre_commit_randomness_lookback:
policy_constants::MAX_PRE_COMMIT_RANDOMNESS_LOOKBACK,
pre_commit_challenge_delay: policy_constants::PRE_COMMIT_CHALLENGE_DELAY,
Expand Down Expand Up @@ -271,6 +275,8 @@ pub mod policy_constants {

pub const ADDRESSED_SECTORS_MAX: u64 = 25_000;

pub const POSTED_PARTITIONS_MAX: u64 = 3;

pub const MAX_PRE_COMMIT_RANDOMNESS_LOOKBACK: ChainEpoch = EPOCHS_IN_DAY + CHAIN_FINALITY;

#[cfg(not(feature = "short-precommit"))]
Expand Down

0 comments on commit 7e4cd0e

Please sign in to comment.