Skip to content

Commit

Permalink
Rename PCS2/PRU2 to PCS3/PRU3 (#1485)
Browse files Browse the repository at this point in the history
  • Loading branch information
anorth committed Jan 22, 2024
1 parent 53cb47e commit 3ad21ac
Show file tree
Hide file tree
Showing 12 changed files with 54 additions and 54 deletions.
24 changes: 12 additions & 12 deletions actors/miner/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ pub enum Method {
GetBeneficiary = 31,
ExtendSectorExpiration2 = 32,
// MovePartitions = 33,
ProveCommitSectors2 = 34,
ProveReplicaUpdates2 = 35,
ProveCommitSectors3 = 34,
ProveReplicaUpdates3 = 35,
// Method numbers derived from FRC-0042 standards
ChangeWorkerAddressExported = frc42_dispatch::method_hash!("ChangeWorkerAddress"),
ChangePeerIDExported = frc42_dispatch::method_hash!("ChangePeerID"),
Expand Down Expand Up @@ -981,10 +981,10 @@ impl Actor {
Ok(updated_bitfield)
}

fn prove_replica_updates2(
fn prove_replica_updates3(
rt: &impl Runtime,
params: ProveReplicaUpdates2Params,
) -> Result<ProveReplicaUpdates2Return, ActorError> {
params: ProveReplicaUpdates3Params,
) -> Result<ProveReplicaUpdates3Return, ActorError> {
let state: State = rt.state()?;
let store = rt.store();
let info = get_miner_info(store, &state)?;
Expand Down Expand Up @@ -1167,7 +1167,7 @@ impl Actor {
notify_data_consumers(rt, &notifications, params.require_notification_success)?;

let result = util::stack(&[validation_batch, proven_batch, data_batch]);
Ok(ProveReplicaUpdates2Return { activation_results: result })
Ok(ProveReplicaUpdates3Return { activation_results: result })
}

fn dispute_windowed_post(
Expand Down Expand Up @@ -1676,10 +1676,10 @@ impl Actor {
Ok(())
}

fn prove_commit_sectors2(
fn prove_commit_sectors3(
rt: &impl Runtime,
params: ProveCommitSectors2Params,
) -> Result<ProveCommitSectors2Return, ActorError> {
params: ProveCommitSectors3Params,
) -> Result<ProveCommitSectors3Return, ActorError> {
let state: State = rt.state()?;
let store = rt.store();
let policy = rt.policy();
Expand Down Expand Up @@ -1863,7 +1863,7 @@ impl Actor {
notify_data_consumers(rt, &notifications, params.require_notification_success)?;

let result = util::stack(&[validation_batch, proven_batch, data_batch]);
Ok(ProveCommitSectors2Return { activation_results: result })
Ok(ProveCommitSectors3Return { activation_results: result })
}

/// Checks state of the corresponding sector pre-commitment, then schedules the proof to be verified in bulk
Expand Down Expand Up @@ -5631,8 +5631,8 @@ impl ActorCode for Actor {
GetVestingFundsExported => get_vesting_funds,
GetPeerIDExported => get_peer_id,
GetMultiaddrsExported => get_multiaddresses,
ProveCommitSectors2 => prove_commit_sectors2,
ProveReplicaUpdates2 => prove_replica_updates2,
ProveCommitSectors3 => prove_commit_sectors3,
ProveReplicaUpdates3 => prove_replica_updates3,
}
}

Expand Down
8 changes: 4 additions & 4 deletions actors/miner/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ pub struct ProveCommitSectorParams {
}

#[derive(Clone, Debug, Eq, PartialEq, Serialize_tuple, Deserialize_tuple)]
pub struct ProveCommitSectors2Params {
pub struct ProveCommitSectors3Params {
// Activation manifest for each sector being proven.
pub sector_activations: Vec<SectorActivationManifest>,
// Proofs for each sector, parallel to activation manifests.
Expand Down Expand Up @@ -194,7 +194,7 @@ pub struct DataActivationNotification {

#[derive(Clone, Debug, Eq, PartialEq, Serialize_tuple, Deserialize_tuple)]
#[serde(transparent)]
pub struct ProveCommitSectors2Return {
pub struct ProveCommitSectors3Return {
pub activation_results: BatchReturn,
}

Expand Down Expand Up @@ -478,7 +478,7 @@ pub struct ProveReplicaUpdatesParams {
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)]
pub struct ProveReplicaUpdates2Params {
pub struct ProveReplicaUpdates3Params {
pub sector_updates: Vec<SectorUpdateManifest>,
// Proofs for each sector, parallel to activation manifests.
// Exactly one of sector_proofs or aggregate_proof must be non-empty.
Expand Down Expand Up @@ -511,7 +511,7 @@ pub struct SectorUpdateManifest {

#[derive(Clone, Debug, Eq, PartialEq, Serialize_tuple, Deserialize_tuple)]
#[serde(transparent)]
pub struct ProveReplicaUpdates2Return {
pub struct ProveReplicaUpdates3Return {
pub activation_results: BatchReturn,
}

Expand Down
8 changes: 4 additions & 4 deletions actors/miner/tests/prove_commit2_failures_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use fvm_shared::{bigint::Zero, clock::ChainEpoch, econ::TokenAmount, ActorID};

use fil_actor_miner::ext::verifreg::AllocationID;
use fil_actor_miner::{
ProveCommitSectors2Params, SectorActivationManifest, ERR_NOTIFICATION_RECEIVER_ABORTED,
ProveCommitSectors3Params, SectorActivationManifest, ERR_NOTIFICATION_RECEIVER_ABORTED,
ERR_NOTIFICATION_REJECTED,
};
use fil_actors_runtime::test_utils::{expect_abort_contains_message, MockRuntime};
Expand Down Expand Up @@ -41,7 +41,7 @@ fn reject_unauthorized_caller() {
fn reject_no_proof_types() {
let (h, rt, activations) = setup_precommits(&[(0, 0, 0)]);
let cfg = ProveCommitSectors2Config {
param_twiddle: Some(Box::new(|p: &mut ProveCommitSectors2Params| {
param_twiddle: Some(Box::new(|p: &mut ProveCommitSectors3Params| {
p.sector_proofs = vec![];
p.aggregate_proof = RawBytes::default();
})),
Expand All @@ -59,7 +59,7 @@ fn reject_no_proof_types() {
fn reject_both_proof_types() {
let (h, rt, activations) = setup_precommits(&[(0, 0, 0)]);
let cfg = ProveCommitSectors2Config {
param_twiddle: Some(Box::new(|p: &mut ProveCommitSectors2Params| {
param_twiddle: Some(Box::new(|p: &mut ProveCommitSectors3Params| {
p.sector_proofs = vec![RawBytes::new(vec![1, 2, 3, 4])];
p.aggregate_proof = RawBytes::new(vec![1, 2, 3, 4])
})),
Expand All @@ -77,7 +77,7 @@ fn reject_both_proof_types() {
fn reject_mismatched_proof_len() {
let (h, rt, activations) = setup_precommits(&[(0, 0, 0)]);
let cfg = ProveCommitSectors2Config {
param_twiddle: Some(Box::new(|p: &mut ProveCommitSectors2Params| {
param_twiddle: Some(Box::new(|p: &mut ProveCommitSectors3Params| {
p.sector_proofs.push(RawBytes::new(vec![1, 2, 3, 4]));
})),
..Default::default()
Expand Down
4 changes: 2 additions & 2 deletions actors/miner/tests/prove_commit2_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use fvm_shared::{bigint::Zero, clock::ChainEpoch, econ::TokenAmount, ActorID};

use fil_actor_miner::ext::verifreg::{AllocationClaim, SectorAllocationClaims};
use fil_actor_miner::{
DataActivationNotification, PieceChange, ProveCommitSectors2Return, SectorChanges,
DataActivationNotification, PieceChange, ProveCommitSectors3Return, SectorChanges,
SectorOnChainInfo, SectorPreCommitInfo,
};
use fil_actors_runtime::cbor::serialize;
Expand Down Expand Up @@ -526,6 +526,6 @@ fn precommit_sectors_from(
precommits
}

fn assert_commit_result(expected: &[ExitCode], result: &ProveCommitSectors2Return) {
fn assert_commit_result(expected: &[ExitCode], result: &ProveCommitSectors3Return) {
assert_eq!(BatchReturn::of(expected), result.activation_results);
}
10 changes: 5 additions & 5 deletions actors/miner/tests/prove_replica_failures_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use fvm_shared::ActorID;

use fil_actor_miner::ext::verifreg::AllocationID;
use fil_actor_miner::{
ProveReplicaUpdates2Params, SectorUpdateManifest, State, ERR_NOTIFICATION_RECEIVER_ABORTED,
ProveReplicaUpdates3Params, SectorUpdateManifest, State, ERR_NOTIFICATION_RECEIVER_ABORTED,
ERR_NOTIFICATION_REJECTED,
};
use fil_actors_runtime::runtime::Runtime;
Expand Down Expand Up @@ -43,7 +43,7 @@ fn reject_unauthorized_caller() {
fn reject_no_proof_types() {
let (h, rt, sector_updates) = setup(1, 0, 0, 0);
let cfg = ProveReplicaUpdatesConfig {
param_twiddle: Some(Box::new(|p: &mut ProveReplicaUpdates2Params| {
param_twiddle: Some(Box::new(|p: &mut ProveReplicaUpdates3Params| {
p.sector_proofs = vec![];
p.aggregate_proof = RawBytes::default();
})),
Expand All @@ -61,7 +61,7 @@ fn reject_no_proof_types() {
fn reject_both_proof_types() {
let (h, rt, sector_updates) = setup(1, 0, 0, 0);
let cfg = ProveReplicaUpdatesConfig {
param_twiddle: Some(Box::new(|p: &mut ProveReplicaUpdates2Params| {
param_twiddle: Some(Box::new(|p: &mut ProveReplicaUpdates3Params| {
p.sector_proofs = vec![RawBytes::new(vec![1, 2, 3, 4])];
p.aggregate_proof = RawBytes::new(vec![1, 2, 3, 4])
})),
Expand All @@ -79,7 +79,7 @@ fn reject_both_proof_types() {
fn reject_mismatched_proof_len() {
let (h, rt, sector_updates) = setup(1, 0, 0, 0);
let cfg = ProveReplicaUpdatesConfig {
param_twiddle: Some(Box::new(|p: &mut ProveReplicaUpdates2Params| {
param_twiddle: Some(Box::new(|p: &mut ProveReplicaUpdates3Params| {
p.sector_proofs.push(RawBytes::new(vec![1, 2, 3, 4]));
})),
..Default::default()
Expand All @@ -96,7 +96,7 @@ fn reject_mismatched_proof_len() {
fn reject_aggregate_proof() {
let (h, rt, sector_updates) = setup(1, 0, 0, 0);
let cfg = ProveReplicaUpdatesConfig {
param_twiddle: Some(Box::new(|p: &mut ProveReplicaUpdates2Params| {
param_twiddle: Some(Box::new(|p: &mut ProveReplicaUpdates3Params| {
p.sector_proofs = vec![];
p.aggregate_proof = RawBytes::new(vec![1, 2, 3, 4])
})),
Expand Down
4 changes: 2 additions & 2 deletions actors/miner/tests/prove_replica_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use fvm_shared::{clock::ChainEpoch, ActorID};

use fil_actor_miner::ext::verifreg::{AllocationClaim, SectorAllocationClaims};
use fil_actor_miner::{DataActivationNotification, PieceChange, SectorChanges, State};
use fil_actor_miner::{ProveReplicaUpdates2Return, SectorOnChainInfo};
use fil_actor_miner::{ProveReplicaUpdates3Return, SectorOnChainInfo};
use fil_actors_runtime::cbor::serialize;
use fil_actors_runtime::test_utils::{expect_abort_contains_message, MockRuntime};
use fil_actors_runtime::{runtime::Runtime, BatchReturn, EPOCHS_IN_DAY, STORAGE_MARKET_ACTOR_ADDR};
Expand Down Expand Up @@ -506,6 +506,6 @@ fn setup_empty_sectors(count: usize) -> (ActorHarness, MockRuntime, Vec<SectorOn
(h, rt, sectors)
}

fn assert_update_result(expected: &[ExitCode], result: &ProveReplicaUpdates2Return) {
fn assert_update_result(expected: &[ExitCode], result: &ProveReplicaUpdates3Return) {
assert_eq!(BatchReturn::of(expected), result.activation_results);
}
26 changes: 13 additions & 13 deletions actors/miner/tests/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,16 @@ use fil_actor_miner::{
MinerConstructorParams as ConstructorParams, MinerInfo, Partition, PendingBeneficiaryChange,
PieceActivationManifest, PieceChange, PieceReturn, PoStPartition, PowerPair,
PreCommitSectorBatchParams, PreCommitSectorBatchParams2, PreCommitSectorParams,
ProveCommitAggregateParams, ProveCommitSectorParams, ProveCommitSectors2Params,
ProveCommitSectors2Return, RecoveryDeclaration, ReportConsensusFaultParams,
ProveCommitAggregateParams, ProveCommitSectorParams, ProveCommitSectors3Params,
ProveCommitSectors3Return, RecoveryDeclaration, ReportConsensusFaultParams,
SectorActivationManifest, 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_miner::{ProveReplicaUpdates3Params, ProveReplicaUpdates3Return};
use fil_actor_power::{
CurrentTotalPowerReturn, EnrollCronEventParams, Method as PowerMethod, UpdateClaimedPowerParams,
};
Expand Down Expand Up @@ -1093,7 +1093,7 @@ impl ActorHarness {
aggregate: bool,
cfg: ProveCommitSectors2Config,
) -> Result<
(ProveCommitSectors2Return, Vec<SectorAllocationClaims>, Vec<SectorChanges>),
(ProveCommitSectors3Return, Vec<SectorAllocationClaims>, Vec<SectorChanges>),
ActorError,
> {
fn make_proof(i: u8) -> RawBytes {
Expand All @@ -1102,7 +1102,7 @@ impl ActorHarness {
rt.set_caller(*ACCOUNT_ACTOR_CODE_ID, cfg.caller.unwrap_or(self.worker));
rt.expect_validate_caller_addr(self.caller_addrs());

let mut params = ProveCommitSectors2Params {
let mut params = ProveCommitSectors3Params {
sector_activations: sector_activations.into(),
aggregate_proof: if aggregate { make_proof(0) } else { RawBytes::default() },
sector_proofs: if !aggregate {
Expand Down Expand Up @@ -1304,12 +1304,12 @@ impl ActorHarness {
}

let result = rt.call::<Actor>(
MinerMethod::ProveCommitSectors2 as u64,
MinerMethod::ProveCommitSectors3 as u64,
IpldBlock::serialize_cbor(&params).unwrap(),
);
let result = result
.map(|r| {
let ret: ProveCommitSectors2Return = r.unwrap().deserialize().unwrap();
let ret: ProveCommitSectors3Return = r.unwrap().deserialize().unwrap();
assert_eq!(sector_activations.len(), ret.activation_results.size());
ret
})
Expand All @@ -1333,7 +1333,7 @@ impl ActorHarness {
require_notification_success: bool,
cfg: ProveReplicaUpdatesConfig,
) -> Result<
(ProveReplicaUpdates2Return, Vec<SectorAllocationClaims>, Vec<SectorChanges>),
(ProveReplicaUpdates3Return, Vec<SectorAllocationClaims>, Vec<SectorChanges>),
ActorError,
> {
fn make_proof(i: u8) -> RawBytes {
Expand All @@ -1342,7 +1342,7 @@ impl ActorHarness {
rt.set_caller(*ACCOUNT_ACTOR_CODE_ID, cfg.caller.unwrap_or(self.worker));
rt.expect_validate_caller_addr(self.caller_addrs());

let mut params = ProveReplicaUpdates2Params {
let mut params = ProveReplicaUpdates3Params {
sector_updates: sector_updates.into(),
sector_proofs: sector_updates.iter().map(|su| make_proof(su.sector as u8)).collect(),
aggregate_proof: RawBytes::default(),
Expand Down Expand Up @@ -1488,12 +1488,12 @@ impl ActorHarness {
}

let result = rt.call::<Actor>(
MinerMethod::ProveReplicaUpdates2 as u64,
MinerMethod::ProveReplicaUpdates3 as u64,
IpldBlock::serialize_cbor(&params).unwrap(),
);
let result = result
.map(|r| {
let ret: ProveReplicaUpdates2Return = r.unwrap().deserialize().unwrap();
let ret: ProveReplicaUpdates3Return = r.unwrap().deserialize().unwrap();
assert_eq!(sector_updates.len(), ret.activation_results.size());
ret
})
Expand Down Expand Up @@ -2918,7 +2918,7 @@ pub struct PreCommitBatchConfig {
#[derive(Default)]
pub struct ProveReplicaUpdatesConfig {
pub caller: Option<Address>,
pub param_twiddle: Option<Box<dyn FnOnce(&mut ProveReplicaUpdates2Params)>>,
pub param_twiddle: Option<Box<dyn FnOnce(&mut ProveReplicaUpdates3Params)>>,
pub validation_failure: Vec<usize>, // Expect validation failure for these sector indices.
pub proof_failure: Vec<usize>, // Simulate proof failure for these sector indices.
pub claim_failure: Vec<usize>, // Simulate verified claim failure for these sector indices.
Expand All @@ -2929,7 +2929,7 @@ pub struct ProveReplicaUpdatesConfig {
#[derive(Default)]
pub struct ProveCommitSectors2Config {
pub caller: Option<Address>,
pub param_twiddle: Option<Box<dyn FnOnce(&mut ProveCommitSectors2Params)>>,
pub param_twiddle: Option<Box<dyn FnOnce(&mut ProveCommitSectors3Params)>>,
pub validation_failure: Vec<usize>, // Expect validation failure for these sector indices.
pub proof_failure: Vec<usize>, // Simulate proof failure for these sector indices.
pub claim_failure: Vec<usize>, // Simulate verified claim failure for these sector indices.
Expand Down
8 changes: 4 additions & 4 deletions integration_tests/src/tests/prove_commit2_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use num_traits::Zero;
use fil_actor_market::Method as MarketMethod;
use fil_actor_miner::{
max_prove_commit_duration, CompactCommD, DataActivationNotification, PieceActivationManifest,
PieceChange, ProveCommitSectors2Params, SectorActivationManifest, SectorChanges,
PieceChange, ProveCommitSectors3Params, SectorActivationManifest, SectorChanges,
SectorContentChangedParams, SectorOnChainInfoFlags,
};
use fil_actor_miner::{Method as MinerMethod, VerifiedAllocationKey};
Expand Down Expand Up @@ -221,7 +221,7 @@ pub fn prove_commit_sectors2_test(v: &dyn VM) {

// Prove-commit
let proofs = vec![RawBytes::new(vec![1, 2, 3, 4]); manifests.len()];
let params = ProveCommitSectors2Params {
let params = ProveCommitSectors3Params {
sector_activations: manifests.clone(),
sector_proofs: proofs,
aggregate_proof: RawBytes::default(),
Expand All @@ -233,13 +233,13 @@ pub fn prove_commit_sectors2_test(v: &dyn VM) {
&worker,
&maddr,
&TokenAmount::zero(),
MinerMethod::ProveCommitSectors2 as u64,
MinerMethod::ProveCommitSectors3 as u64,
Some(params.clone()),
);
ExpectInvocation {
from: worker_id,
to: maddr,
method: MinerMethod::ProveCommitSectors2 as u64,
method: MinerMethod::ProveCommitSectors3 as u64,
params: Some(IpldBlock::serialize_cbor(&params).unwrap()),
subinvocs: Some(vec![
// Verified claims
Expand Down
Loading

0 comments on commit 3ad21ac

Please sign in to comment.