diff --git a/actors/miner/src/lib.rs b/actors/miner/src/lib.rs index 0e890e6e0..8ccee7151 100644 --- a/actors/miner/src/lib.rs +++ b/actors/miner/src/lib.rs @@ -122,13 +122,13 @@ pub enum Method { ProveCommitAggregate = 26, ProveReplicaUpdates = 27, PreCommitSectorBatch2 = 28, - ProveReplicaUpdates2 = 29, + //ProveReplicaUpdates2 = 29, // Deprecated ChangeBeneficiary = 30, GetBeneficiary = 31, ExtendSectorExpiration2 = 32, // MovePartitions = 33, ProveCommitSectors2 = 34, - ProveReplicaUpdates3 = 35, + ProveReplicaUpdates2 = 35, // Method numbers derived from FRC-0042 standards ChangeWorkerAddressExported = frc42_dispatch::method_hash!("ChangeWorkerAddress"), ChangePeerIDExported = frc42_dispatch::method_hash!("ChangePeerID"), @@ -799,7 +799,7 @@ impl Actor { let valid_precommits: Vec = batch_return.successes(&precommits).into_iter().cloned().collect(); - let data_activation_inputs: Vec = + let data_activation_inputs: Vec = valid_precommits.iter().map(|x| x.clone().into()).collect(); let rew = request_current_epoch_block_reward(rt)?; let pwr = request_current_total_power(rt)?; @@ -858,32 +858,6 @@ impl Actor { Self::prove_replica_updates_inner(rt, updates) } - fn prove_replica_updates2( - rt: &RT, - params: ProveReplicaUpdatesParams2, - ) -> Result - where - // + Clone because we messed up and need to keep a copy around between transactions. - // https://github.com/filecoin-project/builtin-actors/issues/133 - RT::Blockstore: Blockstore + Clone, - RT: Runtime, - { - let updates = params - .updates - .into_iter() - .map(|ru| ReplicaUpdateInner { - sector_number: ru.sector_number, - deadline: ru.deadline, - partition: ru.partition, - new_sealed_cid: ru.new_sealed_cid, - new_unsealed_cid: Some(ru.new_unsealed_cid), - deals: ru.deals, - update_proof_type: ru.update_proof_type, - replica_proof: ru.replica_proof, - }) - .collect(); - Self::prove_replica_updates_inner(rt, updates) - } fn prove_replica_updates_inner( rt: &RT, updates: Vec, @@ -925,14 +899,11 @@ impl Actor { let update_sector_infos: Vec = batch_return.successes(&update_sector_infos).iter().map(|x| (*x).clone()).collect(); - let data_activation_inputs: Vec = + let data_activation_inputs: Vec = update_sector_infos.iter().map(|x| x.into()).collect(); /* - For PRU1: - no CommD was specified on input so it must be computed for the first time here - For PRU2: - - CommD was specified on input but not checked so it must be computed and checked here */ let compute_commd = true; let (batch_return, data_activations) = @@ -1010,10 +981,10 @@ impl Actor { Ok(updated_bitfield) } - fn prove_replica_updates3( + fn prove_replica_updates2( rt: &impl Runtime, - params: ProveReplicaUpdates3Params, - ) -> Result { + params: ProveReplicaUpdates2Params, + ) -> Result { let state: State = rt.state()?; let store = rt.store(); let info = get_miner_info(store, &state)?; @@ -1191,7 +1162,7 @@ impl Actor { notify_data_consumers(rt, ¬ifications, params.require_notification_success)?; let result = util::stack(&[validation_batch, proven_batch, data_batch]); - Ok(ProveReplicaUpdates3Return { activation_results: result }) + Ok(ProveReplicaUpdates2Return { activation_results: result }) } fn dispute_windowed_post( @@ -1962,7 +1933,7 @@ impl Actor { ) })?; - let data_activations: Vec = + let data_activations: Vec = precommited_sectors.iter().map(|x| x.clone().into()).collect(); let info = get_miner_info(rt.store(), &st)?; @@ -5284,37 +5255,24 @@ pub struct DealsActivationInput { pub sector_type: RegisteredSealProof, } -// Inputs for activating builtin market deals for one sector -// and optionally confirming CommD for this sector matches expectation -struct DataActivationInput { - info: DealsActivationInput, - expected_commd: Option, -} - -impl From for DataActivationInput { - fn from(pci: SectorPreCommitOnChainInfo) -> DataActivationInput { - DataActivationInput { - info: DealsActivationInput { - deal_ids: pci.info.deal_ids, - sector_expiry: pci.info.expiration, - sector_number: pci.info.sector_number, - sector_type: pci.info.seal_proof, - }, - expected_commd: None, // CommD checks are always performed at precommit time +impl From for DealsActivationInput { + fn from(pci: SectorPreCommitOnChainInfo) -> DealsActivationInput { + DealsActivationInput { + deal_ids: pci.info.deal_ids, + sector_expiry: pci.info.expiration, + sector_number: pci.info.sector_number, + sector_type: pci.info.seal_proof, } } } -impl From<&UpdateAndSectorInfo<'_>> for DataActivationInput { - fn from(usi: &UpdateAndSectorInfo) -> DataActivationInput { - DataActivationInput { - info: DealsActivationInput { - sector_number: usi.sector_info.sector_number, - sector_expiry: usi.sector_info.expiration, - deal_ids: usi.update.deals.clone(), - sector_type: usi.sector_info.seal_proof, - }, - expected_commd: usi.update.new_unsealed_cid, +impl From<&UpdateAndSectorInfo<'_>> for DealsActivationInput { + fn from(usi: &UpdateAndSectorInfo) -> DealsActivationInput { + DealsActivationInput { + sector_number: usi.sector_info.sector_number, + sector_expiry: usi.sector_info.expiration, + deal_ids: usi.update.deals.clone(), + sector_type: usi.sector_info.seal_proof, } } } @@ -5428,61 +5386,11 @@ fn activate_sectors_pieces( Ok((claim_res.sector_results, activation_outputs)) } -// Activates deals with the built-in market actor and claims verified allocations. -// Deals are grouped by sector. -fn activate_sectors_deals( - rt: &impl Runtime, - activation_inputs: &[DataActivationInput], - compute_commd: bool, -) -> Result<(BatchReturn, Vec), ActorError> { - let mut market_activation_inputs = vec![]; - let mut declared_commds = vec![]; - for input in activation_inputs { - declared_commds.push(&input.expected_commd); - market_activation_inputs.push(input.info.clone()); - } - - let (batch_return, activation_outputs) = - batch_activate_deals_and_claim_allocations(rt, &market_activation_inputs, compute_commd)?; - if !compute_commd { - // no CommD computed so no checking required - return Ok((batch_return, activation_outputs)); - } - - // Computation of CommD was requested, so any Some() declared CommDs must be checked - let check_commds = batch_return.successes(&declared_commds); - let success_inputs = batch_return.successes(activation_inputs); - - for (declared_commd, result, input) in check_commds - .into_iter() - .zip(activation_outputs.iter()) - .zip(success_inputs.iter()) - .map(|((a, b), c)| (a, b, c)) - { - // Computation of CommD was requested, so None can be interpreted as zero data. - let computed_commd = - CompactCommD::new(result.unsealed_cid).get_cid(input.info.sector_type)?; - // If a CommD was declared, check it matches. - if let Some(declared_commd) = declared_commd { - if !declared_commd.eq(&computed_commd) { - return Err(actor_error!( - illegal_argument, - "unsealed CID does not match deals for sector {}, expected {} was {}", - input.info.sector_number, - computed_commd, - declared_commd - )); - } - } - } - - Ok((batch_return, activation_outputs)) -} - -/// Activates the deals then claims allocations for any verified deals +/// Activates deals then claims allocations for any verified deals +/// Deals and claims are grouped by sectors /// Successfully activated sectors have their DealSpaces returned /// Failure to claim datacap for any verified deal results in the whole batch failing -fn batch_activate_deals_and_claim_allocations( +fn activate_sectors_deals( rt: &impl Runtime, activation_infos: &[DealsActivationInput], compute_unsealed_cid: bool, @@ -5682,7 +5590,6 @@ impl ActorCode for Actor { ProveCommitAggregate => prove_commit_aggregate, ProveReplicaUpdates => prove_replica_updates, PreCommitSectorBatch2 => pre_commit_sector_batch2, - ProveReplicaUpdates2 => prove_replica_updates2, ChangeBeneficiary|ChangeBeneficiaryExported => change_beneficiary, GetBeneficiary|GetBeneficiaryExported => get_beneficiary, ExtendSectorExpiration2 => extend_sector_expiration2, @@ -5694,7 +5601,7 @@ impl ActorCode for Actor { GetPeerIDExported => get_peer_id, GetMultiaddrsExported => get_multiaddresses, ProveCommitSectors2 => prove_commit_sectors2, - ProveReplicaUpdates3 => prove_replica_updates3, + ProveReplicaUpdates2 => prove_replica_updates2, } } diff --git a/actors/miner/src/types.rs b/actors/miner/src/types.rs index 550720dc1..f414f1665 100644 --- a/actors/miner/src/types.rs +++ b/actors/miner/src/types.rs @@ -477,24 +477,7 @@ pub struct ProveReplicaUpdatesParams { } #[derive(Debug, Clone, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] -pub struct ReplicaUpdate2 { - pub sector_number: SectorNumber, - pub deadline: u64, - pub partition: u64, - pub new_sealed_cid: Cid, - pub new_unsealed_cid: Cid, - pub deals: Vec, - pub update_proof_type: RegisteredUpdateProof, - pub replica_proof: RawBytes, -} - -#[derive(Debug, Clone, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] -pub struct ProveReplicaUpdatesParams2 { - pub updates: Vec, -} - -#[derive(Debug, Clone, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] -pub struct ProveReplicaUpdates3Params { +pub struct ProveReplicaUpdates2Params { pub sector_updates: Vec, // Proofs for each sector, parallel to activation manifests. // Exactly one of sector_proofs or aggregate_proof must be non-empty. @@ -526,7 +509,7 @@ pub struct SectorUpdateManifest { } #[derive(Clone, Debug, Eq, PartialEq, Serialize_tuple, Deserialize_tuple)] -pub struct ProveReplicaUpdates3Return { +pub struct ProveReplicaUpdates2Return { pub activation_results: BatchReturn, } diff --git a/actors/miner/tests/prove_replica_test.rs b/actors/miner/tests/prove_replica_test.rs index e7f92f302..8a2d96f37 100644 --- a/actors/miner/tests/prove_replica_test.rs +++ b/actors/miner/tests/prove_replica_test.rs @@ -4,7 +4,7 @@ use fvm_shared::sector::{SectorNumber, StoragePower}; use fvm_shared::{bigint::Zero, clock::ChainEpoch, econ::TokenAmount, ActorID}; use fil_actor_miner::ext::verifreg::AllocationID; -use fil_actor_miner::ProveReplicaUpdates3Return; +use fil_actor_miner::ProveReplicaUpdates2Return; use fil_actor_miner::{ CompactCommD, PieceActivationManifest, SectorOnChainInfo, SectorPreCommitInfo, SectorPreCommitOnChainInfo, SectorUpdateManifest, State, @@ -45,9 +45,9 @@ fn prove_basic_updates() { make_update_manifest(&st, store, §ors[3], &[(piece_size, client_id, 1001, 2001)]), // Alloc and deal ]; - let result = h.prove_replica_updates3_batch(&rt, §or_updates, true, true).unwrap(); + let result = h.prove_replica_updates2_batch(&rt, §or_updates, true, true).unwrap(); assert_eq!( - ProveReplicaUpdates3Return { activation_results: BatchReturn::ok(sectors.len() as u32) }, + ProveReplicaUpdates2Return { activation_results: BatchReturn::ok(sectors.len() as u32) }, result ); diff --git a/actors/miner/tests/util.rs b/actors/miner/tests/util.rs index 863ef2682..55578104f 100644 --- a/actors/miner/tests/util.rs +++ b/actors/miner/tests/util.rs @@ -74,15 +74,15 @@ use fil_actor_miner::{ MinerConstructorParams as ConstructorParams, MinerInfo, Partition, PendingBeneficiaryChange, PieceActivationManifest, PieceChange, PieceReturn, PoStPartition, PowerPair, PreCommitSectorBatchParams, PreCommitSectorBatchParams2, PreCommitSectorParams, - ProveCommitAggregateParams, ProveCommitSectorParams, ProveReplicaUpdates3Params, - ProveReplicaUpdates3Return, RecoveryDeclaration, ReportConsensusFaultParams, SectorChanges, - SectorContentChangedParams, SectorContentChangedReturn, SectorOnChainInfo, SectorPreCommitInfo, - SectorPreCommitOnChainInfo, SectorReturn, SectorUpdateManifest, Sectors, State, - SubmitWindowedPoStParams, TerminateSectorsParams, TerminationDeclaration, - VerifiedAllocationKey, VestingFunds, WindowedPoSt, WithdrawBalanceParams, - WithdrawBalanceReturn, CRON_EVENT_PROVING_DEADLINE, REWARD_VESTING_SPEC, SECTORS_AMT_BITWIDTH, - SECTOR_CONTENT_CHANGED, + ProveCommitAggregateParams, ProveCommitSectorParams, RecoveryDeclaration, + ReportConsensusFaultParams, SectorChanges, SectorContentChangedParams, + SectorContentChangedReturn, SectorOnChainInfo, SectorPreCommitInfo, SectorPreCommitOnChainInfo, + SectorReturn, SectorUpdateManifest, Sectors, State, SubmitWindowedPoStParams, + TerminateSectorsParams, TerminationDeclaration, VerifiedAllocationKey, VestingFunds, + WindowedPoSt, WithdrawBalanceParams, WithdrawBalanceReturn, CRON_EVENT_PROVING_DEADLINE, + REWARD_VESTING_SPEC, SECTORS_AMT_BITWIDTH, SECTOR_CONTENT_CHANGED, }; +use fil_actor_miner::{ProveReplicaUpdates2Params, ProveReplicaUpdates2Return}; use fil_actor_power::{ CurrentTotalPowerReturn, EnrollCronEventParams, Method as PowerMethod, UpdateClaimedPowerParams, }; @@ -1107,18 +1107,18 @@ impl ActorHarness { } } - pub fn prove_replica_updates3_batch( + pub fn prove_replica_updates2_batch( &self, rt: &MockRuntime, sector_updates: &[SectorUpdateManifest], require_activation_success: bool, require_notification_success: bool, - ) -> Result { + ) -> Result { fn make_proof(i: u8) -> RawBytes { RawBytes::new(vec![i, i, i, i]) } - let params = ProveReplicaUpdates3Params { + let params = ProveReplicaUpdates2Params { sector_updates: sector_updates.into(), sector_proofs: sector_updates.iter().map(|su| make_proof(su.sector as u8)).collect(), aggregate_proof: RawBytes::default(), @@ -1235,9 +1235,9 @@ impl ActorHarness { ExitCode::OK, ); - let result: ProveReplicaUpdates3Return = rt + let result: ProveReplicaUpdates2Return = rt .call::( - MinerMethod::ProveReplicaUpdates3 as u64, + MinerMethod::ProveReplicaUpdates2 as u64, IpldBlock::serialize_cbor(¶ms).unwrap(), ) .unwrap() diff --git a/integration_tests/src/tests/extend_sectors_test.rs b/integration_tests/src/tests/extend_sectors_test.rs index 509901e4b..165979354 100644 --- a/integration_tests/src/tests/extend_sectors_test.rs +++ b/integration_tests/src/tests/extend_sectors_test.rs @@ -3,7 +3,7 @@ use fvm_shared::address::Address; use fvm_shared::bigint::Zero; use fvm_shared::clock::ChainEpoch; use fvm_shared::econ::TokenAmount; -use fvm_shared::piece::{PaddedPieceSize, PieceInfo}; +use fvm_shared::piece::PaddedPieceSize; use fvm_shared::sector::{RegisteredSealProof, SectorNumber, StoragePower}; use export_macro::vm_test; @@ -11,7 +11,7 @@ use fil_actor_market::{DealMetaArray, State as MarketState}; use fil_actor_miner::{ max_prove_commit_duration, power_for_sector, ExpirationExtension, ExpirationExtension2, ExtendSectorExpiration2Params, ExtendSectorExpirationParams, Method as MinerMethod, PowerPair, - ProveReplicaUpdatesParams2, ReplicaUpdate2, SectorClaim, SectorOnChainInfoFlags, Sectors, + ProveReplicaUpdatesParams, ReplicaUpdate, SectorClaim, SectorOnChainInfoFlags, Sectors, State as MinerState, }; use fil_actor_verifreg::Method as VerifregMethod; @@ -28,8 +28,8 @@ use crate::expects::Expect; use crate::util::{ advance_by_deadline_to_epoch, advance_by_deadline_to_epoch_while_proving, advance_by_deadline_to_index, advance_to_proving_deadline, bf_all, create_accounts, - create_miner, cron_tick, expect_invariants, get_deal, invariant_failure_patterns, - market_add_balance, market_publish_deal, miner_precommit_one_sector_v2, miner_prove_sector, + create_miner, cron_tick, expect_invariants, invariant_failure_patterns, market_add_balance, + market_publish_deal, miner_precommit_one_sector_v2, miner_prove_sector, precommit_meta_data_from_deals, sector_deadline, submit_windowed_post, verifreg_add_client, verifreg_add_verifier, PrecommitMetadata, }; @@ -628,17 +628,9 @@ pub fn extend_updated_sector_with_claims_test(v: &dyn VM) { // replica update let new_sealed_cid = make_sealed_cid(b"replica1"); - let deal = get_deal(v, deal_ids[0]); - let new_unsealed_cid = v - .primitives() - .compute_unsealed_sector_cid( - seal_proof, - &[PieceInfo { size: deal.piece_size, cid: deal.piece_cid }], - ) - .unwrap(); let (d_idx, p_idx) = sector_deadline(v, &miner_addr, sector_number); - let replica_update = ReplicaUpdate2 { + let replica_update = ReplicaUpdate { sector_number, deadline: d_idx, partition: p_idx, @@ -646,15 +638,14 @@ pub fn extend_updated_sector_with_claims_test(v: &dyn VM) { deals: deal_ids.clone(), update_proof_type: fvm_shared::sector::RegisteredUpdateProof::StackedDRG32GiBV1, replica_proof: vec![].into(), - new_unsealed_cid, }; let updated_sectors: BitField = apply_ok( v, &worker, &miner_addr, &TokenAmount::zero(), - MinerMethod::ProveReplicaUpdates2 as u64, - Some(ProveReplicaUpdatesParams2 { updates: vec![replica_update] }), + MinerMethod::ProveReplicaUpdates as u64, + Some(ProveReplicaUpdatesParams { updates: vec![replica_update] }), ) .deserialize() .unwrap(); @@ -665,7 +656,7 @@ pub fn extend_updated_sector_with_claims_test(v: &dyn VM) { ExpectInvocation { from: worker_id, to: miner_addr, - method: MinerMethod::ProveReplicaUpdates2 as u64, + method: MinerMethod::ProveReplicaUpdates as u64, subinvocs: Some(vec![ Expect::market_activate_deals( miner_id, diff --git a/integration_tests/src/tests/replica_update_test.rs b/integration_tests/src/tests/replica_update_test.rs index 5b8f6d40a..81cc34614 100644 --- a/integration_tests/src/tests/replica_update_test.rs +++ b/integration_tests/src/tests/replica_update_test.rs @@ -6,7 +6,7 @@ use fvm_shared::clock::ChainEpoch; use fvm_shared::deal::DealID; use fvm_shared::econ::TokenAmount; use fvm_shared::error::ExitCode; -use fvm_shared::piece::{PaddedPieceSize, PieceInfo}; +use fvm_shared::piece::PaddedPieceSize; use fvm_shared::sector::SectorSize; use fvm_shared::sector::StoragePower; use fvm_shared::sector::{RegisteredSealProof, SectorNumber}; @@ -17,9 +17,8 @@ use fil_actor_market::Method as MarketMethod; use fil_actor_miner::{ power_for_sector, DisputeWindowedPoStParams, ExpirationExtension, ExtendSectorExpirationParams, Method as MinerMethod, PowerPair, ProveCommitSectorParams, ProveReplicaUpdatesParams, - ProveReplicaUpdatesParams2, ReplicaUpdate, ReplicaUpdate2, SectorOnChainInfo, - SectorOnChainInfoFlags, Sectors, State as MinerState, TerminateSectorsParams, - TerminationDeclaration, SECTORS_AMT_BITWIDTH, + ReplicaUpdate, SectorOnChainInfo, SectorOnChainInfoFlags, Sectors, State as MinerState, + TerminateSectorsParams, TerminationDeclaration, SECTORS_AMT_BITWIDTH, }; use fil_actor_verifreg::Method as VerifregMethod; use fil_actors_runtime::runtime::Policy; @@ -37,16 +36,16 @@ use crate::expects::Expect; use crate::util::{ advance_by_deadline_to_epoch, advance_by_deadline_to_index, advance_to_proving_deadline, assert_invariants, bf_all, check_sector_active, check_sector_faulty, create_accounts, - create_miner, deadline_state, declare_recovery, expect_invariants, get_deal, get_network_stats, + create_miner, deadline_state, declare_recovery, expect_invariants, get_network_stats, invariant_failure_patterns, make_bitfield, market_publish_deal, miner_balance, miner_power, precommit_sectors_v2, prove_commit_sectors, sector_info, submit_invalid_post, submit_windowed_post, verifreg_add_client, verifreg_add_verifier, }; -pub fn replica_update_full_path_success_test(v: &dyn VM, v2: bool) { +pub fn replica_update_full_path_success_test(v: &dyn VM) { let policy = Policy::default(); let (sector_info, worker, miner_id, deadline_index, partition_index, sector_size) = - create_miner_and_upgrade_sector(v, v2); + create_miner_and_upgrade_sector(v); let sector_number = sector_info.sector_number; @@ -95,19 +94,14 @@ pub fn replica_update_full_path_success_test(v: &dyn VM, v2: bool) { assert_invariants(v, &Policy::default(), None) } -#[vm_test] -pub fn replica_update_full_path_success_v2(v: &dyn VM) { - replica_update_full_path_success_test(v, true); -} - #[vm_test] pub fn replica_update_full_path_success(v: &dyn VM) { - replica_update_full_path_success_test(v, false); + replica_update_full_path_success_test(v); } -pub fn upgrade_and_miss_post_test(v: &dyn VM, v2: bool) { +pub fn upgrade_and_miss_post_test(v: &dyn VM) { let (sector_info, worker, miner_id, deadline_index, partition_index, sector_size) = - create_miner_and_upgrade_sector(v, v2); + create_miner_and_upgrade_sector(v); let sector_number = sector_info.sector_number; let policy = Policy::default(); @@ -155,14 +149,9 @@ pub fn upgrade_and_miss_post_test(v: &dyn VM, v2: bool) { assert_invariants(v, &Policy::default(), None) } -#[vm_test] -pub fn upgrade_and_miss_post_v2(v: &dyn VM) { - upgrade_and_miss_post_test(v, true); -} - #[vm_test] pub fn upgrade_and_miss_post(v: &dyn VM) { - upgrade_and_miss_post_test(v, false); + upgrade_and_miss_post_test(v); } #[vm_test] @@ -531,7 +520,7 @@ pub fn bad_batch_size_failure_test(v: &dyn VM) { #[vm_test] pub fn nodispute_after_upgrade_test(v: &dyn VM) { - let (_, worker, miner_id, deadline_index, _, _) = create_miner_and_upgrade_sector(v, false); + let (_, worker, miner_id, deadline_index, _, _) = create_miner_and_upgrade_sector(v); let dispute_params = DisputeWindowedPoStParams { deadline: deadline_index, post_index: 0 }; apply_code( @@ -550,7 +539,7 @@ pub fn nodispute_after_upgrade_test(v: &dyn VM) { #[vm_test] pub fn upgrade_bad_post_dispute_test(v: &dyn VM) { let (sector_info, worker, miner_id, deadline_index, partition_index, _) = - create_miner_and_upgrade_sector(v, false); + create_miner_and_upgrade_sector(v); let policy = Policy::default(); let sector_number = sector_info.sector_number; @@ -652,7 +641,7 @@ pub fn bad_post_upgrade_dispute_test(v: &dyn VM) { #[vm_test] pub fn terminate_after_upgrade_test(v: &dyn VM) { let (sector_info, worker, miner_id, deadline_index, partition_index, _) = - create_miner_and_upgrade_sector(v, false); + create_miner_and_upgrade_sector(v); let sector_number = sector_info.sector_number; let terminate_params = TerminateSectorsParams { @@ -693,7 +682,7 @@ pub fn terminate_after_upgrade_test(v: &dyn VM) { pub fn extend_after_upgrade_test(v: &dyn VM) { let policy = Policy::default(); let (sector_info, worker, miner_id, deadline_index, partition_index, _) = - create_miner_and_upgrade_sector(v, false); + create_miner_and_upgrade_sector(v); let sector_number = sector_info.sector_number; let mut legacy_sector = sector_info; @@ -1016,15 +1005,8 @@ pub fn replica_update_verified_deal_test(v: &dyn VM) { // replica update let new_sealed_cid = make_sealed_cid(b"replica1"); - let deal = get_deal(v, deal_ids[0]); - let new_unsealed_cid = v - .primitives() - .compute_unsealed_sector_cid( - seal_proof, - &[PieceInfo { size: deal.piece_size, cid: deal.piece_cid }], - ) - .unwrap(); - let replica_update = ReplicaUpdate2 { + + let replica_update = ReplicaUpdate { sector_number, deadline: d_idx, partition: p_idx, @@ -1032,15 +1014,14 @@ pub fn replica_update_verified_deal_test(v: &dyn VM) { deals: deal_ids.clone(), update_proof_type: fvm_shared::sector::RegisteredUpdateProof::StackedDRG32GiBV1, replica_proof: vec![].into(), - new_unsealed_cid, }; let updated_sectors: BitField = apply_ok( v, &worker, &robust, &TokenAmount::zero(), - MinerMethod::ProveReplicaUpdates2 as u64, - Some(ProveReplicaUpdatesParams2 { updates: vec![replica_update] }), + MinerMethod::ProveReplicaUpdates as u64, + Some(ProveReplicaUpdatesParams { updates: vec![replica_update] }), ) .deserialize() .unwrap(); @@ -1051,7 +1032,7 @@ pub fn replica_update_verified_deal_test(v: &dyn VM) { ExpectInvocation { from: worker_id, to: maddr, - method: MinerMethod::ProveReplicaUpdates2 as u64, + method: MinerMethod::ProveReplicaUpdates as u64, subinvocs: Some(vec![ Expect::market_activate_deals( miner_id, @@ -1127,15 +1108,7 @@ pub fn replica_update_verified_deal_max_term_violated_test(v: &dyn VM) { // replica update let new_sealed_cid = make_sealed_cid(b"replica1"); - let deal = get_deal(v, deal_ids[0]); - let new_unsealed_cid = v - .primitives() - .compute_unsealed_sector_cid( - seal_proof, - &[PieceInfo { size: deal.piece_size, cid: deal.piece_cid }], - ) - .unwrap(); - let replica_update = ReplicaUpdate2 { + let replica_update = ReplicaUpdate { sector_number, deadline: d_idx, partition: p_idx, @@ -1143,15 +1116,14 @@ pub fn replica_update_verified_deal_max_term_violated_test(v: &dyn VM) { deals: deal_ids, update_proof_type: fvm_shared::sector::RegisteredUpdateProof::StackedDRG32GiBV1, replica_proof: vec![].into(), - new_unsealed_cid, }; apply_code( v, &worker, &robust, &TokenAmount::zero(), - MinerMethod::ProveReplicaUpdates2 as u64, - Some(ProveReplicaUpdatesParams2 { updates: vec![replica_update] }), + MinerMethod::ProveReplicaUpdates as u64, + Some(ProveReplicaUpdatesParams { updates: vec![replica_update] }), ExitCode::USR_ILLEGAL_ARGUMENT, ); } @@ -1309,7 +1281,6 @@ fn create_deals_frac( pub fn create_miner_and_upgrade_sector( v: &dyn VM, - v2: bool, ) -> (SectorOnChainInfo, Address, Address, u64, u64, SectorSize) { let addrs = create_accounts(v, 1, &TokenAmount::from_whole(100_000)); let (worker, owner) = (addrs[0], addrs[0]); @@ -1334,7 +1305,7 @@ pub fn create_miner_and_upgrade_sector( // replica update let new_sealed_cid = make_sealed_cid(b"replica1"); - let updated_sectors: BitField = if !v2 { + let updated_sectors: BitField = { let replica_update = ReplicaUpdate { sector_number, deadline: d_idx, @@ -1352,33 +1323,6 @@ pub fn create_miner_and_upgrade_sector( MinerMethod::ProveReplicaUpdates as u64, Some(ProveReplicaUpdatesParams { updates: vec![replica_update] }), ) - } else { - let deal = get_deal(v, deal_ids[0]); - let new_unsealed_cid = v - .primitives() - .compute_unsealed_sector_cid( - seal_proof, - &[PieceInfo { size: deal.piece_size, cid: deal.piece_cid }], - ) - .unwrap(); - let replica_update = ReplicaUpdate2 { - sector_number, - deadline: d_idx, - partition: p_idx, - new_sealed_cid, - deals: deal_ids.clone(), - update_proof_type: fvm_shared::sector::RegisteredUpdateProof::StackedDRG32GiBV1, - replica_proof: vec![].into(), - new_unsealed_cid, - }; - apply_ok( - v, - &worker, - &robust, - &TokenAmount::zero(), - MinerMethod::ProveReplicaUpdates2 as u64, - Some(ProveReplicaUpdatesParams2 { updates: vec![replica_update] }), - ) } .deserialize() .unwrap(); diff --git a/test_vm/tests/suite/replica_update_test.rs b/test_vm/tests/suite/replica_update_test.rs index b15ae49d0..e2ef8bf08 100644 --- a/test_vm/tests/suite/replica_update_test.rs +++ b/test_vm/tests/suite/replica_update_test.rs @@ -2,7 +2,6 @@ use fil_actors_integration_tests::tests::create_miner_and_upgrade_sector; use fil_actors_runtime::runtime::Policy; use fil_actors_runtime::test_blockstores::MemoryBlockstore; use std::rc::Rc; -use test_case::test_case; use test_vm::TestVM; use fil_actors_integration_tests::tests::{ @@ -19,30 +18,27 @@ use fil_actors_integration_tests::util::assert_invariants; // ---- Success cases ---- // Tests that an active CC sector can be correctly upgraded, and the expected state changes occur -#[test_case(false; "v1")] -#[test_case(true; "v2")] -fn replica_update_simple_path_success(v2: bool) { +#[test] +fn replica_update_simple_path_success() { let store = MemoryBlockstore::new(); let v = TestVM::new_with_singletons(store); - create_miner_and_upgrade_sector(&v, v2); + create_miner_and_upgrade_sector(&v); assert_invariants(&v, &Policy::default(), None); } // Tests a successful upgrade, followed by the sector going faulty and recovering -#[test_case(false; "v1")] -#[test_case(true; "v2")] -fn replica_update_full_path_success(v2: bool) { +#[test] +fn replica_update_full_path_success() { let store = MemoryBlockstore::new(); let v = TestVM::new_with_singletons(store); - replica_update_full_path_success_test(&v, v2); + replica_update_full_path_success_test(&v); } -#[test_case(false; "v1")] -#[test_case(true; "v2")] -fn upgrade_and_miss_post(v2: bool) { +#[test] +fn upgrade_and_miss_post() { let store = MemoryBlockstore::new(); let v = TestVM::new_with_singletons(store); - upgrade_and_miss_post_test(&v, v2); + upgrade_and_miss_post_test(&v); } #[test]