Skip to content

Commit

Permalink
fix: restore ConfirmSectorProofsValid (#1553)
Browse files Browse the repository at this point in the history
* fix: restore ConfirmSectorProofsValid

removed in #1540
but still needed to activate preseals

* changes as per review

* make rustfmt

---------

Co-authored-by: aarshkshah1992 <[email protected]>
  • Loading branch information
rvagg and aarshkshah1992 authored Jun 24, 2024
1 parent 1d8f082 commit 75fd61e
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 2 deletions.
56 changes: 55 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
InternalSectorSetupForPreseal = 17,
ChangeMultiaddrs = 18,
CompactPartitions = 19,
CompactSectorNumbers = 20,
Expand Down Expand Up @@ -1950,6 +1950,59 @@ impl Actor {
Ok(ProveCommitSectors3Return { activation_results: result })
}

fn internal_sector_setup_preseal(
rt: &impl Runtime,
params: InternalSectorSetupForPresealParams,
) -> Result<(), ActorError> {
rt.validate_immediate_caller_is(std::iter::once(&SYSTEM_ACTOR_ADDR))?;
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 +5663,7 @@ impl ActorCode for Actor {
ApplyRewards => apply_rewards,
ReportConsensusFault => report_consensus_fault,
WithdrawBalance|WithdrawBalanceExported => withdraw_balance,
InternalSectorSetupForPreseal => internal_sector_setup_preseal,
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 InternalSectorSetupForPresealParams {
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

0 comments on commit 75fd61e

Please sign in to comment.