Skip to content

Commit

Permalink
FIP-0084: Remove ProveCommit and dependencies (#1540)
Browse files Browse the repository at this point in the history
* Remove ProveCommit and dependencies

* Remove gas param

* Fixup power tests

* Remove deprecated harness methods and redirect to prove commit3

* Use new harness names

* Remove tests exercising deprecated behavior of prove commit

* fmt

* Get tests running locally

* Cleanup

* Fix many miner tests

* Fix the fix

* More linter and fmt fixes

* fmt

* clippy

* Fix power tests

* Fix itests and miner power dependent tests

* fmt

* Remove and cleanup prove_commit tests

* All tests passing

* Clippy

* Review Response

* Finish review response

* Remove low value test method

* Update prefactor tests to correct names

---------

Co-authored-by: zenground0 <[email protected]>
  • Loading branch information
ZenGround0 and ZenGround0 authored May 29, 2024
1 parent 84d40fc commit ea7c454
Show file tree
Hide file tree
Showing 26 changed files with 462 additions and 1,805 deletions.
116 changes: 2 additions & 114 deletions actors/miner/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ pub enum Method {
ChangePeerID = 4,
SubmitWindowedPoSt = 5,
//PreCommitSector = 6, // Deprecated
ProveCommitSector = 7,
//ProveCommitSector = 7, // Deprecated
ExtendSectorExpiration = 8,
TerminateSectors = 9,
DeclareFaults = 10,
Expand All @@ -119,7 +119,7 @@ pub enum Method {
ApplyRewards = 14,
ReportConsensusFault = 15,
WithdrawBalance = 16,
ConfirmSectorProofsValid = 17,
//ConfirmSectorProofsValid = 17, // Deprecated
ChangeMultiaddrs = 18,
CompactPartitions = 19,
CompactSectorNumbers = 20,
Expand Down Expand Up @@ -1950,116 +1950,6 @@ impl Actor {
Ok(ProveCommitSectors3Return { activation_results: result })
}

/// Checks state of the corresponding sector pre-commitment, then schedules the proof to be verified in bulk
/// by the power actor.
/// If valid, the power actor will call ConfirmSectorProofsValid at the end of the same epoch as this message.
fn prove_commit_sector(
rt: &impl Runtime,
params: ProveCommitSectorParams,
) -> Result<(), ActorError> {
// Validate caller and parameters.
let st: State = rt.state()?;
let store = rt.store();
// Note: this accepts any caller for legacy, but probably shouldn't.
// Since the miner can provide arbitrary control addresses, there's not much advantage
// in allowing any caller, but some risk if there's an exploitable bug.
rt.validate_immediate_caller_accept_any()?;

if params.sector_number > MAX_SECTOR_NUMBER {
return Err(actor_error!(illegal_argument, "sector number greater than maximum"));
}

// Validate pre-commit.
let precommit = st
.get_precommitted_sector(store, params.sector_number)
.with_context(|| format!("loading pre-commit {}", params.sector_number))?
.ok_or_else(|| {
actor_error!(not_found, "no pre-commited sector {}", params.sector_number)
})?;

validate_seal_proofs(precommit.info.seal_proof, &[params.proof.clone()])?;

let allow_deals = true; // Legacy onboarding entry points allow pre-committed deals.
let all_or_nothing = true; // The singleton must succeed.
let (_, proof_inputs) =
validate_precommits(rt, &vec![precommit], allow_deals, all_or_nothing)?;
let miner_actor_id = rt.message().receiver().id().unwrap();

let svi = proof_inputs[0].to_seal_verify_info(miner_actor_id, &params.proof);
extract_send_result(rt.send_simple(
&STORAGE_POWER_ACTOR_ADDR,
ext::power::SUBMIT_POREP_FOR_BULK_VERIFY_METHOD,
IpldBlock::serialize_cbor(&svi)?,
TokenAmount::zero(),
))?;

Ok(())
}

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 @@ -5711,7 +5601,6 @@ impl ActorCode for Actor {
ChangeWorkerAddress|ChangeWorkerAddressExported => change_worker_address,
ChangePeerID|ChangePeerIDExported => change_peer_id,
SubmitWindowedPoSt => submit_windowed_post,
ProveCommitSector => prove_commit_sector,
ExtendSectorExpiration => extend_sector_expiration,
TerminateSectors => terminate_sectors,
DeclareFaults => declare_faults,
Expand All @@ -5721,7 +5610,6 @@ 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
12 changes: 2 additions & 10 deletions 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, StoragePower,
RegisteredUpdateProof, SectorNumber, SectorSize,
};
use fvm_shared::ActorID;
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -88,15 +88,6 @@ 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 Expand Up @@ -129,6 +120,7 @@ pub struct SubmitWindowedPoStParams {
pub chain_commit_rand: Randomness,
}

// Deprecated as of FIP 0084 -- kept for legacy testing
#[derive(Serialize_tuple, Deserialize_tuple)]
pub struct ProveCommitSectorParams {
pub sector_number: SectorNumber,
Expand Down
10 changes: 2 additions & 8 deletions actors/miner/tests/exported_getters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,7 @@ fn collateral_getters() {

let precommit_params =
h.make_pre_commit_params(sector_no, precommit_epoch - 1, expiration, vec![]);
let precommit =
h.pre_commit_sector_and_get(&rt, precommit_params, PreCommitConfig::empty(), true);
h.pre_commit_sector_and_get(&rt, precommit_params, PreCommitConfig::empty(), true);

// run prove commit logic
rt.set_epoch(prove_commit_epoch);
Expand All @@ -125,12 +124,7 @@ fn collateral_getters() {
let pcc = ProveCommitConfig::empty();

let sector = h
.prove_commit_sector_and_confirm(
&rt,
&precommit,
h.make_prove_commit_params(sector_no),
pcc,
)
.deprecated_sector_commit(&rt, &vec![], h.make_prove_commit_params(sector_no), pcc)
.unwrap();

// query available balance
Expand Down
Loading

0 comments on commit ea7c454

Please sign in to comment.