Skip to content

Commit 7f014d8

Browse files
committed
fix: restore ConfirmSectorProofsValid
removed in #1540 but still needed to activate preseals
1 parent fc66b0d commit 7f014d8

File tree

3 files changed

+88
-3
lines changed

3 files changed

+88
-3
lines changed

actors/miner/src/lib.rs

+66-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ pub enum Method {
119119
ApplyRewards = 14,
120120
ReportConsensusFault = 15,
121121
WithdrawBalance = 16,
122-
//ConfirmSectorProofsValid = 17, // Deprecated
122+
ConfirmSectorProofsValid = 17,
123123
ChangeMultiaddrs = 18,
124124
CompactPartitions = 19,
125125
CompactSectorNumbers = 20,
@@ -2173,6 +2173,70 @@ impl Actor {
21732173
Ok(ProveCommitSectorsNIReturn { activation_results: validation_batch })
21742174
}
21752175

2176+
fn confirm_sector_proofs_valid(
2177+
rt: &impl Runtime,
2178+
params: ConfirmSectorProofsParams,
2179+
) -> Result<(), ActorError> {
2180+
rt.validate_immediate_caller_is(std::iter::once(&STORAGE_POWER_ACTOR_ADDR))?;
2181+
2182+
/* validate params */
2183+
// This should be enforced by the power actor. We log here just in case
2184+
// something goes wrong.
2185+
if params.sectors.len() > ext::power::MAX_MINER_PROVE_COMMITS_PER_EPOCH {
2186+
warn!(
2187+
"confirmed more prove commits in an epoch than permitted: {} > {}",
2188+
params.sectors.len(),
2189+
ext::power::MAX_MINER_PROVE_COMMITS_PER_EPOCH
2190+
);
2191+
}
2192+
let st: State = rt.state()?;
2193+
let store = rt.store();
2194+
// This skips missing pre-commits.
2195+
let precommited_sectors =
2196+
st.find_precommitted_sectors(store, &params.sectors).map_err(|e| {
2197+
e.downcast_default(
2198+
ExitCode::USR_ILLEGAL_STATE,
2199+
"failed to load pre-committed sectors",
2200+
)
2201+
})?;
2202+
2203+
let data_activations: Vec<DealsActivationInput> =
2204+
precommited_sectors.iter().map(|x| x.clone().into()).collect();
2205+
let info = get_miner_info(rt.store(), &st)?;
2206+
2207+
/*
2208+
For all sectors
2209+
- CommD was specified at precommit
2210+
- If deal IDs were specified at precommit the CommD was checked against them
2211+
Therefore CommD on precommit has already been provided and checked so no further processing needed
2212+
*/
2213+
let compute_commd = false;
2214+
let (batch_return, data_activations) =
2215+
activate_sectors_deals(rt, &data_activations, compute_commd)?;
2216+
let successful_activations = batch_return.successes(&precommited_sectors);
2217+
2218+
let pledge_inputs = NetworkPledgeInputs {
2219+
network_qap: params.quality_adj_power_smoothed,
2220+
network_baseline: params.reward_baseline_power,
2221+
circulating_supply: rt.total_fil_circ_supply(),
2222+
epoch_reward: params.reward_smoothed,
2223+
};
2224+
activate_new_sector_infos(
2225+
rt,
2226+
successful_activations.clone(),
2227+
data_activations.clone(),
2228+
&pledge_inputs,
2229+
&info,
2230+
)?;
2231+
2232+
for (pc, data) in successful_activations.iter().zip(data_activations.iter()) {
2233+
let unsealed_cid = pc.info.unsealed_cid.0;
2234+
emit::sector_activated(rt, pc.info.sector_number, unsealed_cid, &data.pieces)?;
2235+
}
2236+
2237+
Ok(())
2238+
}
2239+
21762240
fn check_sector_proven(
21772241
rt: &impl Runtime,
21782242
params: CheckSectorProvenParams,
@@ -5955,6 +6019,7 @@ impl ActorCode for Actor {
59556019
ApplyRewards => apply_rewards,
59566020
ReportConsensusFault => report_consensus_fault,
59576021
WithdrawBalance|WithdrawBalanceExported => withdraw_balance,
6022+
ConfirmSectorProofsValid => confirm_sector_proofs_valid,
59586023
ChangeMultiaddrs|ChangeMultiaddrsExported => change_multiaddresses,
59596024
CompactPartitions => compact_partitions,
59606025
CompactSectorNumbers => compact_sector_numbers,

actors/miner/src/types.rs

+10-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use fvm_shared::piece::PaddedPieceSize;
1414
use fvm_shared::randomness::Randomness;
1515
use fvm_shared::sector::{
1616
PoStProof, RegisteredAggregateProof, RegisteredPoStProof, RegisteredSealProof,
17-
RegisteredUpdateProof, SectorNumber, SectorSize,
17+
RegisteredUpdateProof, SectorNumber, SectorSize, StoragePower,
1818
};
1919
use fvm_shared::ActorID;
2020
use serde::{Deserialize, Serialize};
@@ -88,6 +88,15 @@ pub struct ChangeMultiaddrsParams {
8888
pub new_multi_addrs: Vec<BytesDe>,
8989
}
9090

91+
#[derive(Serialize_tuple, Deserialize_tuple)]
92+
pub struct ConfirmSectorProofsParams {
93+
pub sectors: Vec<SectorNumber>,
94+
pub reward_smoothed: FilterEstimate,
95+
#[serde(with = "bigint_ser")]
96+
pub reward_baseline_power: StoragePower,
97+
pub quality_adj_power_smoothed: FilterEstimate,
98+
}
99+
91100
#[derive(Serialize_tuple, Deserialize_tuple)]
92101
pub struct DeferredCronEventParams {
93102
#[serde(with = "strict_bytes")]

actors/power/src/ext.rs

+12-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ use fvm_ipld_encoding::tuple::*;
33
use fvm_ipld_encoding::{strict_bytes, BytesDe};
44

55
use fvm_shared::address::Address;
6-
use fvm_shared::sector::RegisteredPoStProof;
6+
use fvm_shared::bigint::bigint_ser;
7+
use fvm_shared::sector::{RegisteredPoStProof, SectorNumber, StoragePower};
78
use fvm_shared::METHOD_CONSTRUCTOR;
89
use num_derive::FromPrimitive;
910

@@ -35,8 +36,18 @@ pub mod init {
3536
pub mod miner {
3637
use super::*;
3738

39+
pub const CONFIRM_SECTOR_PROOFS_VALID_METHOD: u64 = 17;
3840
pub const ON_DEFERRED_CRON_EVENT_METHOD: u64 = 12;
3941

42+
#[derive(Serialize_tuple, Deserialize_tuple)]
43+
pub struct ConfirmSectorProofsParams {
44+
pub sectors: Vec<SectorNumber>,
45+
pub reward_smoothed: FilterEstimate,
46+
#[serde(with = "bigint_ser")]
47+
pub reward_baseline_power: StoragePower,
48+
pub quality_adj_power_smoothed: FilterEstimate,
49+
}
50+
4051
#[derive(Serialize_tuple, Deserialize_tuple)]
4152
pub struct MinerConstructorParams {
4253
pub owner: Address,

0 commit comments

Comments
 (0)