Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: miner: add niporep params cbor forms vector tests #1543

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 19 additions & 19 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 23 additions & 12 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ members = [
"runtime",
"test_vm",
"vm_api",
"integration_tests"
"integration_tests",
]

[workspace.package]
Expand Down Expand Up @@ -54,10 +54,16 @@ fil_actors_runtime = { workspace = true }
num-traits = { workspace = true }

[dependencies]
clap = { version = "4.3.0", features = ["derive", "std", "help", "usage", "error-context"], default-features = false }
clap = { version = "4.3.0", features = [
"derive",
"std",
"help",
"usage",
"error-context",
], default-features = false }

[features]
default = [] ## translates to mainnet
default = [] ## translates to mainnet
mainnet = []
caterpillarnet = []
butterflynet = []
Expand Down Expand Up @@ -110,22 +116,27 @@ rlp = { version = "0.5.1", default-features = false }
substrate-bn = { version = "0.6.0", default-features = false }

# IPLD/Encoding
cid = { version = "0.10.1", default-features = false, features = ["serde-codec", "std"] }
multihash = { version = "0.18.1", default-features = false , features = ["multihash-impl"]}
cid = { version = "0.10.1", default-features = false, features = [
"serde-codec",
"std",
] }
multihash = { version = "0.18.1", default-features = false, features = [
"multihash-impl",
] }
libipld-core = { version = "0.13.1", features = ["serde-codec"] }
integer-encoding = { version = "3.0.3", default-features = false }

# helix-onchain
fvm_actor_utils = "9.0.0"
frc42_dispatch = "5.0.0"
frc46_token = "9.0.0"
fvm_actor_utils = "11.0.0"
frc42_dispatch = "7.0.0"
frc46_token = "11.0.0"

# FVM
fvm_sdk = "~4.0"
fvm_shared = "~4.0"
fvm_sdk = "4.3.0"
fvm_shared = "4.3.0"
fvm_ipld_encoding = "0.4.0"
fvm_ipld_blockstore = "0.2.0"
fvm_ipld_hamt = "0.8.0"
fvm_ipld_hamt = "0.9.0"
fvm_ipld_kamt = "0.3.0"
fvm_ipld_amt = { version = "0.6.2" }
fvm_ipld_bitfield = "0.6.0"
Expand All @@ -149,7 +160,7 @@ fil_actor_system = { path = "actors/system" }
fil_actor_verifreg = { path = "actors/verifreg" }
fil_actors_evm_shared = { path = "actors/evm/shared" }
fil_actors_runtime = { path = "runtime" }
fil_builtin_actors_state = { path = "state"}
fil_builtin_actors_state = { path = "state" }
fil_actors_integration_tests = { version = "1.0.0", path = "integration_tests" }
vm_api = { version = "1.0.0", path = "vm_api" }
test_vm = { path = "test_vm" }
Expand Down
1 change: 1 addition & 0 deletions actors/miner/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ lazy_static = { workspace = true }
log = { workspace = true }
byteorder = { workspace = true }
itertools = { workspace = true }
const-hex = { workspace = true }

[dev-dependencies]
fil_actors_runtime = { workspace = true, features = ["test_utils", "sector-default"] }
Expand Down
21 changes: 21 additions & 0 deletions actors/miner/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,27 @@ pub struct ProveCommitSectorParams {
pub proof: RawBytes,
}

// Note no UnsealedCID because it must be "zero" data.
#[derive(Clone, Debug, Eq, PartialEq, Serialize_tuple, Deserialize_tuple)]
pub struct SectorNIActivationInfo {
pub sealing_number: SectorNumber, // Sector number used to generate replica id
pub sealer_id: ActorID, // Must be set to ID of receiving actor for now
pub sealed_cid: Cid, // CommR
pub sector_number: SectorNumber, // Unique id of sector in actor state
pub seal_rand_epoch: ChainEpoch,
pub expiration: ChainEpoch,
}

#[derive(Clone, Debug, Eq, PartialEq, Serialize_tuple, Deserialize_tuple)]
pub struct ProveCommitSectorsNIParams {
pub sectors: Vec<SectorNIActivationInfo>, // Information about sealing of each sector
pub aggregate_proof: RawBytes, // Aggregate proof for all sectors
pub seal_proof_type: RegisteredSealProof, // Proof type for each seal (must be an NI-PoRep variant)
pub aggregate_proof_type: RegisteredAggregateProof, // Proof type for aggregation
pub proving_deadline: u64, // The Window PoST deadline index at which to schedule the new sectors
pub require_activation_success: bool, // Whether to abort if any sector activation fails
}

#[derive(Clone, Debug, Eq, PartialEq, Serialize_tuple, Deserialize_tuple)]
pub struct ProveCommitSectors3Params {
// Activation manifest for each sector being proven.
Expand Down
82 changes: 82 additions & 0 deletions actors/miner/tests/types_test.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
// Tests to match with Go github.com/filecoin-project/go-state-types/builtin/*/miner
mod serialization {
use std::str::FromStr;

use cid::Cid;
use fil_actor_miner::{ProveCommitSectorsNIParams, SectorNIActivationInfo};
use fvm_ipld_encoding::ipld_block::IpldBlock;
use fvm_shared::sector::{RegisteredAggregateProof, RegisteredSealProof};

#[test]
fn prove_commit_sectors_ni_params() {
let test_cases = vec![
(
ProveCommitSectorsNIParams {
sectors: vec![],
aggregate_proof: vec![].into(),
seal_proof_type: RegisteredSealProof::StackedDRG32GiBV1P1,
aggregate_proof_type: RegisteredAggregateProof::SnarkPackV2,
proving_deadline: 2,
require_activation_success: false,
},
// [[],byte[],8,1,2,false]
"868040080102f4",
),
(
ProveCommitSectorsNIParams {
sectors: vec![SectorNIActivationInfo {
sealing_number: 1,
sealer_id: 2,
sealed_cid: Cid::from_str("bagboea4seaaqa").unwrap(),
sector_number: 3,
seal_rand_epoch: 4,
expiration: 5,
}],
seal_proof_type: RegisteredSealProof::StackedDRG32GiBV1P2_Feat_NiPoRep,
aggregate_proof: vec![0xde, 0xad, 0xbe, 0xef].into(),
aggregate_proof_type: RegisteredAggregateProof::SnarkPackV2,
proving_deadline: 6,
require_activation_success: true,
},
// [[[1,2,bagboea4seaaqa,3,4,5]],byte[deadbeef],18,1,6,true]
"8681860102d82a49000182e2039220010003040544deadbeef120106f5",
),
(
ProveCommitSectorsNIParams {
sectors: vec![
SectorNIActivationInfo {
sealing_number: 1,
sealer_id: 2,
sealed_cid: Cid::from_str("bagboea4seaaqa").unwrap(),
sector_number: 3,
seal_rand_epoch: 4,
expiration: 5,
},
SectorNIActivationInfo {
sealing_number: 6,
sealer_id: 7,
sealed_cid: Cid::from_str("bagboea4seaaqc").unwrap(),
sector_number: 8,
seal_rand_epoch: 9,
expiration: 10,
},
],
seal_proof_type: RegisteredSealProof::StackedDRG32GiBV1P2_Feat_NiPoRep,
aggregate_proof: vec![0xde, 0xad, 0xbe, 0xef].into(),
aggregate_proof_type: RegisteredAggregateProof::SnarkPackV2,
proving_deadline: 11,
require_activation_success: false,
},
// [[[1,2,bagboea4seaaqa,3,4,5],[6,7,bagboea4seaaqc,8,9,10]],byte[deadbeef],18,1,11,false]
"8682860102d82a49000182e20392200100030405860607d82a49000182e2039220010108090a44deadbeef12010bf4",
),
];

for (params, expected_hex) in test_cases {
let encoded = IpldBlock::serialize_cbor(&params).unwrap().unwrap();
assert_eq!(const_hex::encode(&encoded.data), expected_hex);
let decoded: ProveCommitSectorsNIParams = IpldBlock::deserialize(&encoded).unwrap();
assert_eq!(params, decoded);
}
}
}
Loading