From 29b145cd4443cc3c53ecfe3a151af5d27a4a6372 Mon Sep 17 00:00:00 2001 From: Alex North <445306+anorth@users.noreply.github.com> Date: Mon, 16 Oct 2023 07:18:28 +1100 Subject: [PATCH] Tests for prove_commit_sectors2 (#1437) --- actors/miner/tests/prove_commit2_test.rs | 503 +++++++++++++++++++++-- actors/miner/tests/prove_replica_test.rs | 6 +- actors/miner/tests/util.rs | 69 ++-- 3 files changed, 529 insertions(+), 49 deletions(-) diff --git a/actors/miner/tests/prove_commit2_test.rs b/actors/miner/tests/prove_commit2_test.rs index 5a8d40ff12..6456e58d51 100644 --- a/actors/miner/tests/prove_commit2_test.rs +++ b/actors/miner/tests/prove_commit2_test.rs @@ -1,8 +1,16 @@ +use fvm_ipld_encoding::RawBytes; +use fvm_shared::error::ExitCode; use fvm_shared::sector::SectorNumber; use fvm_shared::{bigint::Zero, clock::ChainEpoch, econ::TokenAmount, ActorID}; -use fil_actor_miner::{ProveCommitSectors2Return, SectorPreCommitInfo}; -use fil_actors_runtime::{BatchReturn, EPOCHS_IN_DAY}; +use fil_actor_miner::ext::verifreg::{AllocationClaim, SectorAllocationClaims}; +use fil_actor_miner::{ + DataActivationNotification, PieceChange, ProveCommitSectors2Return, SectorChanges, + SectorOnChainInfo, SectorPreCommitInfo, +}; +use fil_actors_runtime::cbor::serialize; +use fil_actors_runtime::test_utils::MockRuntime; +use fil_actors_runtime::{BatchReturn, EPOCHS_IN_DAY, STORAGE_MARKET_ACTOR_ADDR}; use util::*; mod util; @@ -12,42 +20,87 @@ const DEFAULT_SECTOR_EXPIRATION_DAYS: ChainEpoch = 220; const FIRST_SECTOR_NUMBER: SectorNumber = 100; #[test] -fn prove_commit2_basic() { - let h = ActorHarness::new_with_options(HarnessOptions::default()); - let rt = h.new_runtime(); - rt.set_balance(BIG_BALANCE.clone()); - h.construct_and_verify(&rt); - - // Precommit sectors - let precommit_epoch = *rt.epoch.borrow(); - let sector_count = 4; - let sector_expiry = *rt.epoch.borrow() + DEFAULT_SECTOR_EXPIRATION_DAYS * EPOCHS_IN_DAY; - let precommits = make_fake_commd_precommits( - &h, - FIRST_SECTOR_NUMBER, - precommit_epoch - 1, - sector_expiry, - sector_count, - ); - h.pre_commit_sector_batch_v2(&rt, &precommits, true, &TokenAmount::zero()).unwrap(); +fn commit_batch() { + let (h, mut rt) = setup_basic(); + let precommits = precommit_sectors(&mut rt, &h, 4); let snos: Vec = precommits.iter().map(|pci: &SectorPreCommitInfo| pci.sector_number).collect(); // Prove them in batch, each with a single piece. let piece_size = h.sector_size as u64; - let sector_activations = vec![ + let manifests = vec![ make_activation_manifest(snos[0], &[(piece_size, 0, 0, 0)]), // No alloc or deal make_activation_manifest(snos[1], &[(piece_size, CLIENT_ID, 1000, 0)]), // Just an alloc make_activation_manifest(snos[2], &[(piece_size, 0, 0, 2000)]), // Just a deal make_activation_manifest(snos[3], &[(piece_size, CLIENT_ID, 1001, 2001)]), // Alloc and deal ]; - rt.set_epoch(precommit_epoch + rt.policy.pre_commit_challenge_delay + 1); let cfg = ProveCommitSectors2Config::default(); - let result = h.prove_commit_sectors2(&rt, §or_activations, true, true, false, cfg).unwrap(); + let (result, claims, notifications) = + h.prove_commit_sectors2(&rt, &manifests, true, true, false, cfg).unwrap(); + assert_commit_result(&[ExitCode::OK; 4], &result); + let sectors: Vec = snos.iter().map(|sno| h.get_sector(&rt, *sno)).collect(); + + // Explicitly verify claims match what we expect. assert_eq!( - ProveCommitSectors2Return { activation_results: BatchReturn::ok(precommits.len() as u32) }, - result + vec![ + SectorAllocationClaims { + sector: snos[0], + expiry: sectors[0].expiration, + claims: vec![], + }, + SectorAllocationClaims { + sector: snos[1], + expiry: sectors[1].expiration, + claims: vec![AllocationClaim { + client: CLIENT_ID, + allocation_id: 1000, + data: manifests[1].pieces[0].cid, + size: manifests[1].pieces[0].size, + }], + }, + SectorAllocationClaims { + sector: snos[2], + expiry: sectors[2].expiration, + claims: vec![], + }, + SectorAllocationClaims { + sector: snos[3], + expiry: sectors[3].expiration, + claims: vec![AllocationClaim { + client: CLIENT_ID, + allocation_id: 1001, + data: manifests[3].pieces[0].cid, + size: manifests[3].pieces[0].size, + }], + }, + ], + claims + ); + + // Explicitly verify notifications match what we expect. + assert_eq!( + vec![ + SectorChanges { + sector: snos[2], + minimum_commitment_epoch: sectors[2].expiration, + added: vec![PieceChange { + data: manifests[2].pieces[0].cid, + size: manifests[2].pieces[0].size, + payload: serialize(&2000, "").unwrap(), + },], + }, + SectorChanges { + sector: snos[3], + minimum_commitment_epoch: sectors[3].expiration, + added: vec![PieceChange { + data: manifests[3].pieces[0].cid, + size: manifests[3].pieces[0].size, + payload: serialize(&2001, "").unwrap(), + },], + }, + ], + notifications ); // Sector 0: Even though there's no "deal", the data weight is set. @@ -60,3 +113,403 @@ fn prove_commit2_basic() { verify_weights(&rt, &h, snos[3], 0, piece_size); h.check_state(&rt); } + +#[test] +fn multiple_pieces_in_sector() { + let (h, mut rt) = setup_basic(); + let precommits = precommit_sectors(&mut rt, &h, 2); + let snos: Vec = + precommits.iter().map(|pci: &SectorPreCommitInfo| pci.sector_number).collect(); + + // Half-size pieces + let piece_size = h.sector_size as u64 / 2; + let manifests = vec![ + make_activation_manifest( + snos[0], + &[(piece_size, CLIENT_ID, 1000, 2000), (piece_size, CLIENT_ID, 1001, 2001)], + ), + make_activation_manifest( + snos[1], + &[(piece_size, CLIENT_ID, 1002, 2002), (piece_size, 0, 0, 0)], + ), + ]; + + let cfg = ProveCommitSectors2Config::default(); + let (result, claims, notifications) = + h.prove_commit_sectors2(&rt, &manifests, true, true, false, cfg).unwrap(); + assert_commit_result(&[ExitCode::OK, ExitCode::OK], &result); + let sectors: Vec = snos.iter().map(|sno| h.get_sector(&rt, *sno)).collect(); + + // Explicitly verify claims match what we expect. + assert_eq!( + vec![ + SectorAllocationClaims { + sector: snos[0], + expiry: sectors[0].expiration, + claims: vec![ + AllocationClaim { + client: CLIENT_ID, + allocation_id: 1000, + data: manifests[0].pieces[0].cid, + size: manifests[0].pieces[0].size, + }, + AllocationClaim { + client: CLIENT_ID, + allocation_id: 1001, + data: manifests[0].pieces[1].cid, + size: manifests[0].pieces[1].size, + }, + ], + }, + SectorAllocationClaims { + sector: snos[1], + expiry: sectors[1].expiration, + claims: vec![AllocationClaim { + client: CLIENT_ID, + allocation_id: 1002, + data: manifests[1].pieces[0].cid, + size: manifests[1].pieces[0].size, + }], + }, + ], + claims + ); + + // Explicitly verify notifications match what we expect. + assert_eq!( + vec![ + SectorChanges { + sector: snos[0], + minimum_commitment_epoch: sectors[0].expiration, + added: vec![ + PieceChange { + data: manifests[0].pieces[0].cid, + size: manifests[0].pieces[0].size, + payload: serialize(&2000, "").unwrap(), + }, + PieceChange { + data: manifests[0].pieces[1].cid, + size: manifests[0].pieces[1].size, + payload: serialize(&2001, "").unwrap(), + }, + ], + }, + SectorChanges { + sector: snos[1], + minimum_commitment_epoch: sectors[1].expiration, + added: vec![PieceChange { + data: manifests[1].pieces[0].cid, + size: manifests[1].pieces[0].size, + payload: serialize(&2002, "").unwrap(), + },], + }, + ], + notifications + ); + + verify_weights(&rt, &h, snos[0], 0, piece_size * 2); + verify_weights(&rt, &h, snos[1], piece_size, piece_size); + h.check_state(&rt); +} + +#[test] +fn multiple_notifs_for_piece() { + let (h, mut rt) = setup_basic(); + let precommits = precommit_sectors(&mut rt, &h, 2); + let snos: Vec = + precommits.iter().map(|pci: &SectorPreCommitInfo| pci.sector_number).collect(); + + let piece_size = h.sector_size as u64 / 2; + let mut manifests = vec![ + make_activation_manifest( + snos[0], + &[(piece_size, CLIENT_ID, 0, 0), (piece_size, CLIENT_ID, 0, 0)], + ), + make_activation_manifest(snos[1], &[(piece_size, CLIENT_ID, 0, 0)]), + ]; + // 2 notifications for sector[0], piece[0] + manifests[0].pieces[0].notify.push(DataActivationNotification { + address: STORAGE_MARKET_ACTOR_ADDR, + payload: RawBytes::from(vec![6, 6, 6, 6]), + }); + manifests[0].pieces[0].notify.push(DataActivationNotification { + address: STORAGE_MARKET_ACTOR_ADDR, + payload: RawBytes::from(vec![7, 7, 7, 7]), + }); + // One notification for sector[0], piece[1] + manifests[0].pieces[1].notify.push(DataActivationNotification { + address: STORAGE_MARKET_ACTOR_ADDR, + payload: RawBytes::from(vec![8, 8, 8, 8]), + }); + // One notification for sector[1], piece[0] + manifests[1].pieces[0].notify.push(DataActivationNotification { + address: STORAGE_MARKET_ACTOR_ADDR, + payload: RawBytes::from(vec![9, 9, 9, 9]), + }); + + let cfg = ProveCommitSectors2Config::default(); + let (result, _, notifications) = + h.prove_commit_sectors2(&rt, &manifests, true, true, false, cfg).unwrap(); + assert_commit_result(&[ExitCode::OK, ExitCode::OK], &result); + let sectors: Vec = snos.iter().map(|sno| h.get_sector(&rt, *sno)).collect(); + + // Explicitly verify notifications match what we expect. + assert_eq!( + vec![ + SectorChanges { + sector: snos[0], + minimum_commitment_epoch: sectors[0].expiration, + added: vec![ + PieceChange { + data: manifests[0].pieces[0].cid, + size: manifests[0].pieces[0].size, + payload: RawBytes::from(vec![6, 6, 6, 6]), + }, + PieceChange { + data: manifests[0].pieces[0].cid, + size: manifests[0].pieces[0].size, + payload: RawBytes::from(vec![7, 7, 7, 7]), + }, + PieceChange { + data: manifests[0].pieces[1].cid, + size: manifests[0].pieces[1].size, + payload: RawBytes::from(vec![8, 8, 8, 8]), + }, + ], + }, + SectorChanges { + sector: snos[1], + minimum_commitment_epoch: sectors[1].expiration, + added: vec![PieceChange { + data: manifests[1].pieces[0].cid, + size: manifests[1].pieces[0].size, + payload: RawBytes::from(vec![9, 9, 9, 9]), + },], + }, + ], + notifications + ); + + verify_weights(&rt, &h, snos[0], piece_size * 2, 0); + verify_weights(&rt, &h, snos[1], piece_size, 0); + h.check_state(&rt); +} + +#[test] +fn expired_precommit_dropped_batch() { + let (h, mut rt) = setup_basic(); + let precommits1 = precommit_sectors(&mut rt, &h, 1); + let epoch = *rt.epoch.borrow(); + rt.set_epoch(epoch + 31 * EPOCHS_IN_DAY); // The first precommit expired. + + let precommits2 = + precommit_sectors_from(&mut rt, &h, precommits1[0].sector_number + 1, 1, false); + let precommits = [&precommits1[..], &precommits2[..]].concat(); + let snos: Vec = + precommits.iter().map(|pci: &SectorPreCommitInfo| pci.sector_number).collect(); + + let piece_size = h.sector_size as u64; + let manifests = vec![ + make_activation_manifest(snos[0], &[(piece_size, CLIENT_ID, 1000, 2000)]), + make_activation_manifest(snos[1], &[(piece_size, CLIENT_ID, 1001, 2001)]), + ]; + + let cfg = ProveCommitSectors2Config { validation_failure: vec![0], ..Default::default() }; + let (result, claims, notifications) = + h.prove_commit_sectors2(&rt, &manifests, false, false, false, cfg).unwrap(); + assert_commit_result(&[ExitCode::USR_ILLEGAL_ARGUMENT, ExitCode::OK], &result); + + // Sector 0: not committed + assert_eq!(precommits1[0], h.get_precommit(&rt, snos[0]).info); + let st = h.get_state(&rt); + assert!(st.get_sector(&rt.store, precommits[0].sector_number).unwrap().is_none()); + // Sector 1: verified weight. + verify_weights(&rt, &h, snos[1], 0, piece_size); + assert_eq!(1, claims.len()); + assert_eq!(precommits[1].sector_number, claims[0].sector); + assert_eq!(1, notifications.len()); + assert_eq!(precommits[1].sector_number, notifications[0].sector); + h.check_state(&rt); +} + +#[test] +fn expired_precommit_dropped_aggregate() { + let (h, mut rt) = setup_basic(); + let precommits1 = precommit_sectors(&mut rt, &h, 1); + let epoch = *rt.epoch.borrow(); + rt.set_epoch(epoch + 31 * EPOCHS_IN_DAY); // The first precommit expired. + + let precommits2 = + precommit_sectors_from(&mut rt, &h, precommits1[0].sector_number + 1, 3, false); + let precommits = [&precommits1[..], &precommits2[..]].concat(); + let snos: Vec = + precommits.iter().map(|pci: &SectorPreCommitInfo| pci.sector_number).collect(); + + let piece_size = h.sector_size as u64; + let manifests = vec![ + make_activation_manifest(snos[0], &[(piece_size, CLIENT_ID, 1000, 2000)]), + make_activation_manifest(snos[1], &[(piece_size, CLIENT_ID, 1001, 2001)]), + make_activation_manifest(snos[2], &[(piece_size, CLIENT_ID, 1002, 2002)]), + make_activation_manifest(snos[3], &[(piece_size, CLIENT_ID, 1003, 2003)]), + ]; + + let cfg = ProveCommitSectors2Config { validation_failure: vec![0], ..Default::default() }; + let (result, _, _) = h.prove_commit_sectors2(&rt, &manifests, false, false, true, cfg).unwrap(); + assert_commit_result( + &[ExitCode::USR_ILLEGAL_ARGUMENT, ExitCode::OK, ExitCode::OK, ExitCode::OK], + &result, + ); + + // Sector 0: not committed + assert_eq!(precommits1[0], h.get_precommit(&rt, snos[0]).info); + let st = h.get_state(&rt); + assert!(st.get_sector(&rt.store, precommits[0].sector_number).unwrap().is_none()); + // Sectors 1-3: verified weight. + verify_weights(&rt, &h, snos[1], 0, piece_size); + verify_weights(&rt, &h, snos[2], 0, piece_size); + verify_weights(&rt, &h, snos[3], 0, piece_size); + h.check_state(&rt); +} + +#[test] +fn invalid_proof_dropped() { + let (h, mut rt) = setup_basic(); + let precommits = precommit_sectors(&mut rt, &h, 2); + let snos: Vec = + precommits.iter().map(|pci: &SectorPreCommitInfo| pci.sector_number).collect(); + + let piece_size = h.sector_size as u64; + let manifests = vec![ + make_activation_manifest(snos[0], &[(piece_size, CLIENT_ID, 1000, 2000)]), + make_activation_manifest(snos[1], &[(piece_size, CLIENT_ID, 1001, 2001)]), + ]; + + let cfg = ProveCommitSectors2Config { proof_failure: vec![0], ..Default::default() }; + let (result, _, _) = + h.prove_commit_sectors2(&rt, &manifests, false, false, false, cfg).unwrap(); + assert_commit_result(&[ExitCode::USR_ILLEGAL_ARGUMENT, ExitCode::OK], &result); + + // Sector 0: not committed + let st = h.get_state(&rt); + assert!(st.get_sector(&rt.store, precommits[0].sector_number).unwrap().is_none()); + // Sector 1: verified weight. + verify_weights(&rt, &h, snos[1], 0, piece_size); + h.check_state(&rt); +} + +#[test] +fn invalid_claim_dropped() { + let (h, mut rt) = setup_basic(); + let precommits = precommit_sectors(&mut rt, &h, 2); + let snos: Vec = + precommits.iter().map(|pci: &SectorPreCommitInfo| pci.sector_number).collect(); + + let piece_size = h.sector_size as u64; + let manifests = vec![ + make_activation_manifest(snos[0], &[(piece_size, CLIENT_ID, 1000, 2000)]), + make_activation_manifest(snos[1], &[(piece_size, CLIENT_ID, 1001, 2001)]), + ]; + + let cfg = ProveCommitSectors2Config { claim_failure: vec![0], ..Default::default() }; + let (result, _, _) = + h.prove_commit_sectors2(&rt, &manifests, false, false, false, cfg).unwrap(); + assert_commit_result(&[ExitCode::USR_ILLEGAL_ARGUMENT, ExitCode::OK], &result); + + // Sector 0: not committed + let st = h.get_state(&rt); + assert!(st.get_sector(&rt.store, precommits[0].sector_number).unwrap().is_none()); + // Sector 1: verified weight. + verify_weights(&rt, &h, snos[1], 0, piece_size); +} + +#[test] +fn aborted_notification_dropped() { + let (h, mut rt) = setup_basic(); + let precommits = precommit_sectors(&mut rt, &h, 2); + let snos: Vec = + precommits.iter().map(|pci: &SectorPreCommitInfo| pci.sector_number).collect(); + + let piece_size = h.sector_size as u64; + let manifests = vec![ + make_activation_manifest(snos[0], &[(piece_size, CLIENT_ID, 1000, 2000)]), + make_activation_manifest(snos[1], &[(piece_size, CLIENT_ID, 1001, 2001)]), + ]; + + let cfg = ProveCommitSectors2Config { + notification_result: Some(ExitCode::USR_UNSPECIFIED), + ..Default::default() + }; + let (result, _, _) = + h.prove_commit_sectors2(&rt, &manifests, false, false, false, cfg).unwrap(); + + // All sectors succeed anyway. + assert_commit_result(&[ExitCode::OK; 2], &result); + // All power activated anyway. + verify_weights(&rt, &h, snos[0], 0, piece_size); + verify_weights(&rt, &h, snos[1], 0, piece_size); +} + +#[test] +fn rejected_notification_dropped() { + let (h, mut rt) = setup_basic(); + let precommits = precommit_sectors(&mut rt, &h, 2); + let snos: Vec = + precommits.iter().map(|pci: &SectorPreCommitInfo| pci.sector_number).collect(); + + let piece_size = h.sector_size as u64; + let manifests = vec![ + make_activation_manifest(snos[0], &[(piece_size, CLIENT_ID, 1000, 2000)]), + make_activation_manifest(snos[1], &[(piece_size, CLIENT_ID, 1001, 2001)]), + ]; + + let cfg = ProveCommitSectors2Config { notification_rejected: true, ..Default::default() }; + let (result, _, _) = + h.prove_commit_sectors2(&rt, &manifests, false, false, false, cfg).unwrap(); + + // All sectors succeed anyway. + assert_commit_result(&[ExitCode::OK; 2], &result); + // All power activated anyway. + verify_weights(&rt, &h, snos[0], 0, piece_size); + verify_weights(&rt, &h, snos[1], 0, piece_size); +} + +fn setup_basic() -> (ActorHarness, MockRuntime) { + let h = ActorHarness::new_with_options(HarnessOptions::default()); + let rt = h.new_runtime(); + rt.set_balance(BIG_BALANCE.clone()); + h.construct_and_verify(&rt); + (h, rt) +} + +fn precommit_sectors( + rt: &mut MockRuntime, + h: &ActorHarness, + sector_count: usize, +) -> Vec { + precommit_sectors_from(rt, h, FIRST_SECTOR_NUMBER, sector_count, true) +} + +fn precommit_sectors_from( + rt: &mut MockRuntime, + h: &ActorHarness, + first_sector_number: SectorNumber, + sector_count: usize, + first_for_miner: bool, +) -> Vec { + let precommit_epoch = *rt.epoch.borrow(); + let sector_expiry = *rt.epoch.borrow() + DEFAULT_SECTOR_EXPIRATION_DAYS * EPOCHS_IN_DAY; + let precommits = make_fake_commd_precommits( + h, + first_sector_number, + precommit_epoch - 1, + sector_expiry, + sector_count, + ); + h.pre_commit_sector_batch_v2(rt, &precommits, first_for_miner, &TokenAmount::zero()).unwrap(); + rt.set_epoch(precommit_epoch + rt.policy.pre_commit_challenge_delay + 1); + precommits +} + +fn assert_commit_result(expected: &[ExitCode], result: &ProveCommitSectors2Return) { + assert_eq!(BatchReturn::of(expected), result.activation_results); +} diff --git a/actors/miner/tests/prove_replica_test.rs b/actors/miner/tests/prove_replica_test.rs index 501a0de0d5..33a77c7d57 100644 --- a/actors/miner/tests/prove_replica_test.rs +++ b/actors/miner/tests/prove_replica_test.rs @@ -332,7 +332,7 @@ fn invalid_update_dropped() { sector_updates[0].deadline += 1; // Invalid update let cfg = ProveReplicaUpdatesConfig { validation_failure: vec![0], ..Default::default() }; - let (result, _, _) = + let (result, claims, notifications) = h.prove_replica_updates2_batch(&rt, §or_updates, false, false, cfg).unwrap(); assert_update_result(&[ExitCode::USR_ILLEGAL_ARGUMENT, ExitCode::OK], &result); @@ -340,6 +340,10 @@ fn invalid_update_dropped() { verify_weights(&rt, &h, snos[0], 0, 0); // Sector 1: verified weight. verify_weights(&rt, &h, snos[1], 0, piece_size); + assert_eq!(1, claims.len()); + assert_eq!(snos[1], claims[0].sector); + assert_eq!(1, notifications.len()); + assert_eq!(snos[1], notifications[0].sector); h.check_state(&rt); } diff --git a/actors/miner/tests/util.rs b/actors/miner/tests/util.rs index 22b5c93563..8e7c6e53b1 100644 --- a/actors/miner/tests/util.rs +++ b/actors/miner/tests/util.rs @@ -1092,7 +1092,10 @@ impl ActorHarness { require_notification_success: bool, aggregate: bool, cfg: ProveCommitSectors2Config, - ) -> Result { + ) -> Result< + (ProveCommitSectors2Return, Vec, Vec), + ActorError, + > { fn make_proof(i: u8) -> RawBytes { RawBytes::new(vec![i, i, i, i]) } @@ -1145,25 +1148,30 @@ impl ActorHarness { } else { let mut svis = vec![]; let mut result = vec![]; - sector_activations.iter().zip(precommits).enumerate().for_each(|(i, (sa, pci))| { - svis.push(SealVerifyInfo { - registered_proof: self.seal_proof_type, - sector_id: SectorID { - miner: STORAGE_MARKET_ACTOR_ADDR.id().unwrap(), - number: sa.sector_number, - }, - deal_ids: vec![], - randomness: Randomness(seal_int_rands.get(i).cloned().unwrap().into()), - interactive_randomness: Randomness( - seal_int_rands.get(i).cloned().unwrap().into(), - ), - proof: make_proof(sa.sector_number as u8).into(), - sealed_cid: pci.info.sealed_cid, - unsealed_cid: comm_ds[i], + sector_activations + .iter() + .zip(precommits) + .enumerate() + .filter(|(i, _)| !cfg.validation_failure.contains(&i)) + .for_each(|(i, (sa, pci))| { + svis.push(SealVerifyInfo { + registered_proof: self.seal_proof_type, + sector_id: SectorID { + miner: STORAGE_MARKET_ACTOR_ADDR.id().unwrap(), + number: sa.sector_number, + }, + deal_ids: vec![], + randomness: Randomness(seal_int_rands.get(i).cloned().unwrap().into()), + interactive_randomness: Randomness( + seal_int_rands.get(i).cloned().unwrap().into(), + ), + proof: make_proof(sa.sector_number as u8).into(), + sealed_cid: pci.info.sealed_cid, + unsealed_cid: comm_ds[i], + }); + let proof_ok = !cfg.proof_failure.contains(&i); + result.push(proof_ok); }); - let proof_ok = !cfg.proof_failure.contains(&i); - result.push(proof_ok); - }); rt.expect_batch_verify_seals(svis, Ok(result)) } @@ -1173,7 +1181,7 @@ impl ActorHarness { let mut expected_qa_power = StoragePower::zero(); let mut expected_sector_notifications = Vec::new(); // Assuming all to f05 for (i, sa) in sector_activations.iter().enumerate() { - if cfg.validation_failure.contains(&i) { + if cfg.validation_failure.contains(&i) || cfg.proof_failure.contains(&i) { continue; } expect_compute_unsealed_cid_from_pieces( @@ -1243,7 +1251,7 @@ impl ActorHarness { VERIFIED_REGISTRY_ACTOR_ADDR, CLAIM_ALLOCATIONS_METHOD, IpldBlock::serialize_cbor(&ClaimAllocationsParams { - sectors: sector_allocation_claims, + sectors: sector_allocation_claims.clone(), all_or_nothing: require_activation_success, }) .unwrap(), @@ -1260,6 +1268,21 @@ impl ActorHarness { // Expect pledge & power updates. self.expect_query_network_info(rt); expect_update_pledge(rt, &expected_pledge); + // Pay aggregation fee for successful proofs. + if aggregate { + let proven_count = + sector_activations.len() - (cfg.validation_failure.len() + cfg.proof_failure.len()); + let expected_fee = aggregate_prove_commit_network_fee(proven_count, &self.base_fee); + assert!(expected_fee.is_positive()); + rt.expect_send_simple( + BURNT_FUNDS_ACTOR_ADDR, + METHOD_SEND, + None, + expected_fee, + None, + ExitCode::OK, + ); + } // Expect SectorContentChanged notification to market. let sector_notification_resps: Vec = expected_sector_notifications @@ -1273,7 +1296,7 @@ impl ActorHarness { STORAGE_MARKET_ACTOR_ADDR, SECTOR_CONTENT_CHANGED, IpldBlock::serialize_cbor(&SectorContentChangedParams { - sectors: expected_sector_notifications, + sectors: expected_sector_notifications.clone(), }) .unwrap(), TokenAmount::zero(), @@ -1300,7 +1323,7 @@ impl ActorHarness { Err(e) })?; rt.verify(); - Ok(result) + Ok((result, sector_allocation_claims, expected_sector_notifications)) } // Invokes prove_replica_updates2 with a batch of sector updates, and