Skip to content

Commit

Permalink
fix: restore ConfirmSectorProofsValid
Browse files Browse the repository at this point in the history
removed in #1540
but still needed to activate preseals
  • Loading branch information
rvagg committed Jun 19, 2024
1 parent fa72bbd commit c1306b2
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 3 deletions.
67 changes: 66 additions & 1 deletion actors/miner/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ pub enum Method {
ApplyRewards = 14,
ReportConsensusFault = 15,
WithdrawBalance = 16,
//ConfirmSectorProofsValid = 17, // Deprecated
ConfirmSectorProofsValid = 17,
ChangeMultiaddrs = 18,
CompactPartitions = 19,
CompactSectorNumbers = 20,
Expand Down Expand Up @@ -2167,6 +2167,70 @@ impl Actor {
Ok(ProveCommitSectorsNIReturn { activation_results: result })
}

fn confirm_sector_proofs_valid(
rt: &impl Runtime,
params: ConfirmSectorProofsParams,
) -> Result<(), ActorError> {
rt.validate_immediate_caller_is(std::iter::once(&STORAGE_POWER_ACTOR_ADDR))?;

/* validate params */
// This should be enforced by the power actor. We log here just in case
// something goes wrong.
if params.sectors.len() > ext::power::MAX_MINER_PROVE_COMMITS_PER_EPOCH {
warn!(
"confirmed more prove commits in an epoch than permitted: {} > {}",
params.sectors.len(),
ext::power::MAX_MINER_PROVE_COMMITS_PER_EPOCH
);
}
let st: State = rt.state()?;
let store = rt.store();
// This skips missing pre-commits.
let precommited_sectors =
st.find_precommitted_sectors(store, &params.sectors).map_err(|e| {
e.downcast_default(
ExitCode::USR_ILLEGAL_STATE,
"failed to load pre-committed sectors",
)
})?;

let data_activations: Vec<DealsActivationInput> =
precommited_sectors.iter().map(|x| x.clone().into()).collect();
let info = get_miner_info(rt.store(), &st)?;

/*
For all sectors
- CommD was specified at precommit
- If deal IDs were specified at precommit the CommD was checked against them
Therefore CommD on precommit has already been provided and checked so no further processing needed
*/
let compute_commd = false;
let (batch_return, data_activations) =
activate_sectors_deals(rt, &data_activations, compute_commd)?;
let successful_activations = batch_return.successes(&precommited_sectors);

let pledge_inputs = NetworkPledgeInputs {
network_qap: params.quality_adj_power_smoothed,
network_baseline: params.reward_baseline_power,
circulating_supply: rt.total_fil_circ_supply(),
epoch_reward: params.reward_smoothed,
};
activate_new_sector_infos(
rt,
successful_activations.clone(),
data_activations.clone(),
&pledge_inputs,
&info,
)?;

for (pc, data) in successful_activations.iter().zip(data_activations.iter()) {
let unsealed_cid = pc.info.unsealed_cid.0;
emit::sector_activated(rt, pc.info.sector_number, unsealed_cid, &data.pieces)?;
}

Ok(())
}

fn check_sector_proven(
rt: &impl Runtime,
params: CheckSectorProvenParams,
Expand Down Expand Up @@ -5946,6 +6010,7 @@ impl ActorCode for Actor {
ApplyRewards => apply_rewards,
ReportConsensusFault => report_consensus_fault,
WithdrawBalance|WithdrawBalanceExported => withdraw_balance,
ConfirmSectorProofsValid => confirm_sector_proofs_valid,
ChangeMultiaddrs|ChangeMultiaddrsExported => change_multiaddresses,
CompactPartitions => compact_partitions,
CompactSectorNumbers => compact_sector_numbers,
Expand Down
11 changes: 10 additions & 1 deletion actors/miner/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use fvm_shared::piece::PaddedPieceSize;
use fvm_shared::randomness::Randomness;
use fvm_shared::sector::{
PoStProof, RegisteredAggregateProof, RegisteredPoStProof, RegisteredSealProof,
RegisteredUpdateProof, SectorNumber, SectorSize,
RegisteredUpdateProof, SectorNumber, SectorSize, StoragePower,
};
use fvm_shared::ActorID;
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -88,6 +88,15 @@ pub struct ChangeMultiaddrsParams {
pub new_multi_addrs: Vec<BytesDe>,
}

#[derive(Serialize_tuple, Deserialize_tuple)]
pub struct ConfirmSectorProofsParams {
pub sectors: Vec<SectorNumber>,
pub reward_smoothed: FilterEstimate,
#[serde(with = "bigint_ser")]
pub reward_baseline_power: StoragePower,
pub quality_adj_power_smoothed: FilterEstimate,
}

#[derive(Serialize_tuple, Deserialize_tuple)]
pub struct DeferredCronEventParams {
#[serde(with = "strict_bytes")]
Expand Down
13 changes: 12 additions & 1 deletion actors/power/src/ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ use fvm_ipld_encoding::tuple::*;
use fvm_ipld_encoding::{strict_bytes, BytesDe};

use fvm_shared::address::Address;
use fvm_shared::sector::RegisteredPoStProof;
use fvm_shared::bigint::bigint_ser;
use fvm_shared::sector::{RegisteredPoStProof, SectorNumber, StoragePower};
use fvm_shared::METHOD_CONSTRUCTOR;
use num_derive::FromPrimitive;

Expand Down Expand Up @@ -35,8 +36,18 @@ pub mod init {
pub mod miner {
use super::*;

pub const CONFIRM_SECTOR_PROOFS_VALID_METHOD: u64 = 17;
pub const ON_DEFERRED_CRON_EVENT_METHOD: u64 = 12;

#[derive(Serialize_tuple, Deserialize_tuple)]
pub struct ConfirmSectorProofsParams {
pub sectors: Vec<SectorNumber>,
pub reward_smoothed: FilterEstimate,
#[serde(with = "bigint_ser")]
pub reward_baseline_power: StoragePower,
pub quality_adj_power_smoothed: FilterEstimate,
}

#[derive(Serialize_tuple, Deserialize_tuple)]
pub struct MinerConstructorParams {
pub owner: Address,
Expand Down

0 comments on commit c1306b2

Please sign in to comment.