Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: restore ConfirmSectorProofsValid #1553

Merged
merged 3 commits into from
Jun 24, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
rvagg marked this conversation as resolved.
Show resolved Hide resolved
ChangeMultiaddrs = 18,
CompactPartitions = 19,
CompactSectorNumbers = 20,
Expand Down Expand Up @@ -1950,6 +1950,70 @@ impl Actor {
Ok(ProveCommitSectors3Return { 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))?;
rvagg marked this conversation as resolved.
Show resolved Hide resolved

/* 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 {
rvagg marked this conversation as resolved.
Show resolved Hide resolved
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 @@ -5610,6 +5674,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 {
rvagg marked this conversation as resolved.
Show resolved Hide resolved
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;
rvagg marked this conversation as resolved.
Show resolved Hide resolved
pub const ON_DEFERRED_CRON_EVENT_METHOD: u64 = 12;

#[derive(Serialize_tuple, Deserialize_tuple)]
rvagg marked this conversation as resolved.
Show resolved Hide resolved
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
Loading