Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into feat/ddo-actor-events
Browse files Browse the repository at this point in the history
  • Loading branch information
aarshkshah1992 committed Jan 30, 2024
2 parents 1722310 + 859c731 commit a35b1cc
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 35 deletions.
1 change: 1 addition & 0 deletions actors/market/tests/on_miner_sectors_terminate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ fn terminate_valid_deals_along_with_expired_and_cleaned_up_deal() {
check_state(&rt);
}

// Converted from: https://github.com/filecoin-project/specs-actors/blob/d56b240af24517443ce1f8abfbdab7cb22d331f1/actors/builtin/market/market_test.go#L1415
#[test]
fn do_not_terminate_deal_if_end_epoch_is_equal_to_or_less_than_current_epoch() {
let start_epoch = 10;
Expand Down
2 changes: 1 addition & 1 deletion integration_tests/src/tests/batch_onboarding_deals_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ pub fn batch_onboarding_deals_test(v: &dyn VM) {
// Associate deals with sectors.
let sector_precommit_data = deals
.into_iter()
.map(|(id, _)| precommit_meta_data_from_deals(v, vec![id], SEAL_PROOF))
.map(|(id, _)| precommit_meta_data_from_deals(v, &[id], SEAL_PROOF))
.collect();

// Pre-commit as single batch.
Expand Down
4 changes: 2 additions & 2 deletions integration_tests/src/tests/extend_sectors_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ pub fn extend_legacy_sector_with_deals_test(v: &dyn VM, do_extend2: bool) {
&miner_id,
seal_proof,
sector_number,
precommit_meta_data_from_deals(v, deals, seal_proof),
precommit_meta_data_from_deals(v, &deals, seal_proof),
true,
deal_start + 180 * EPOCHS_IN_DAY,
);
Expand Down Expand Up @@ -393,7 +393,7 @@ pub fn commit_sector_with_max_duration_deal_test(v: &dyn VM) {
&miner_id,
seal_proof,
sector_number,
precommit_meta_data_from_deals(v, deals, seal_proof),
precommit_meta_data_from_deals(v, &deals, seal_proof),
true,
deal_start + deal_lifetime,
);
Expand Down
18 changes: 10 additions & 8 deletions integration_tests/src/tests/terminate_test.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
use std::ops::Neg;

use fvm_shared::bigint::Zero;
use fvm_shared::econ::TokenAmount;
use fvm_shared::error::ExitCode;
use fvm_shared::piece::PaddedPieceSize;
use fvm_shared::sector::{RegisteredSealProof, StoragePower};
use num_traits::cast::FromPrimitive;

use export_macro::vm_test;
use fil_actor_cron::Method as CronMethod;
use fil_actor_market::{
Expand All @@ -15,15 +24,8 @@ use fil_actors_runtime::{
CRON_ACTOR_ADDR, STORAGE_MARKET_ACTOR_ADDR, STORAGE_MARKET_ACTOR_ID, STORAGE_POWER_ACTOR_ADDR,
SYSTEM_ACTOR_ADDR, VERIFIED_REGISTRY_ACTOR_ADDR,
};
use fvm_shared::bigint::Zero;
use fvm_shared::deal::DealID;
use fvm_shared::econ::TokenAmount;
use fvm_shared::error::ExitCode;
use fvm_shared::piece::PaddedPieceSize;
use fvm_shared::sector::{RegisteredSealProof, StoragePower};
use fvm_shared::ActorID;
use num_traits::cast::FromPrimitive;
use std::ops::Neg;
use vm_api::trace::ExpectInvocation;
use vm_api::util::{apply_ok, get_state, DynBlockstore};
use vm_api::VM;
Expand Down Expand Up @@ -175,7 +177,7 @@ pub fn terminate_sectors_test(v: &dyn VM) {
&miner_robust_addr,
seal_proof,
sector_number,
precommit_meta_data_from_deals(v, deal_ids.clone(), seal_proof),
precommit_meta_data_from_deals(v, &deal_ids, seal_proof),
true,
v.epoch() + 220 * EPOCHS_IN_DAY,
);
Expand Down
25 changes: 18 additions & 7 deletions integration_tests/src/tests/verified_claim_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use fvm_shared::piece::PaddedPieceSize;
use fvm_shared::sector::{RegisteredSealProof, SectorNumber, StoragePower};

use fil_actor_datacap::State as DatacapState;
use fil_actor_market::{DealArray, DealMetaArray};
use fil_actor_market::{DealArray, DealMetaArray, DealSettlementSummary};
use fil_actor_market::{
PendingDealAllocationsMap, State as MarketState, PENDING_ALLOCATIONS_CONFIG,
};
Expand Down Expand Up @@ -36,9 +36,9 @@ use crate::util::{
create_miner, cron_tick, datacap_extend_claim, datacap_get_balance, expect_invariants,
invariant_failure_patterns, market_add_balance, market_pending_deal_allocations,
market_publish_deal, miner_extend_sector_expiration2, miner_precommit_one_sector_v2,
miner_prove_sector, precommit_meta_data_from_deals, sector_deadline, submit_windowed_post,
verifreg_add_client, verifreg_add_verifier, verifreg_extend_claim_terms,
verifreg_remove_expired_allocations,
miner_prove_sector, precommit_meta_data_from_deals, provider_settle_deal_payments,
sector_deadline, submit_windowed_post, verifreg_add_client, verifreg_add_verifier,
verifreg_extend_claim_terms, verifreg_remove_expired_allocations,
};

/// Tests a scenario involving a verified deal from the built-in market, with associated
Expand Down Expand Up @@ -102,7 +102,7 @@ pub fn verified_claim_scenario_test(v: &dyn VM) {
&miner_id,
seal_proof,
sector_number,
precommit_meta_data_from_deals(v, deals, seal_proof),
precommit_meta_data_from_deals(v, &deals, seal_proof),
true,
deal_start + sector_term,
);
Expand Down Expand Up @@ -362,6 +362,17 @@ pub fn verified_claim_scenario_test(v: &dyn VM) {
assert_eq!(vec![claim_id], ret.considered);
assert!(ret.results.all_ok(), "results had failures {}", ret.results);

let market_state: MarketState = get_state(v, &STORAGE_MARKET_ACTOR_ADDR).unwrap();
let store = DynBlockstore::wrap(v.blockstore());
let proposals = DealArray::load(&market_state.proposals, &store).unwrap();
let proposal = proposals.get(deals[0]).unwrap().unwrap();
// provider must process the deals to receive payment and cleanup state
let ret = provider_settle_deal_payments(v, &miner_id, &deals);
assert_eq!(
ret.settlements.get(0).unwrap(),
&DealSettlementSummary { payment: proposal.total_storage_fee(), completed: true }
);

expect_invariants(
v,
&Policy::default(),
Expand Down Expand Up @@ -551,7 +562,7 @@ pub fn deal_passes_claim_fails_test(v: &dyn VM) {
&miner_id,
seal_proof,
sector_number_a,
precommit_meta_data_from_deals(v, vec![deal], seal_proof),
precommit_meta_data_from_deals(v, &[deal], seal_proof),
true,
sector_start + sector_term,
);
Expand All @@ -562,7 +573,7 @@ pub fn deal_passes_claim_fails_test(v: &dyn VM) {
&miner_id,
seal_proof,
sector_number_b,
precommit_meta_data_from_deals(v, vec![bad_deal], seal_proof),
precommit_meta_data_from_deals(v, &[bad_deal], seal_proof),
false,
sector_start + sector_term,
);
Expand Down
21 changes: 10 additions & 11 deletions integration_tests/src/util/mod.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
use cid::multihash::{Code, MultihashDigest};
use cid::Cid;
use fil_actor_market::{load_provider_sector_deals, DealProposal, DealState, State as MarketState};
use fil_actor_miner::ext::verifreg::AllocationID;
use fil_actor_miner::{
new_deadline_info_from_offset_and_epoch, CompactCommD, Deadline, DeadlineInfo,
GetBeneficiaryReturn, Method as MinerMethod, MinerInfo, PowerPair, SectorOnChainInfo,
State as MinerState,
};
use fil_actor_power::State as PowerState;
use fil_actor_reward::State as RewardState;
use fil_actor_verifreg::{Claim, ClaimID, State as VerifregState};
use fil_actors_runtime::cbor::serialize;
use fil_actors_runtime::test_utils::make_piece_cid;
use fil_actors_runtime::{
parse_uint_key, runtime::Policy, MessageAccumulator, REWARD_ACTOR_ADDR,
STORAGE_MARKET_ACTOR_ADDR, STORAGE_POWER_ACTOR_ADDR, VERIFIED_REGISTRY_ACTOR_ADDR,
};
use fil_builtin_actors_state::check::check_state_invariants;
use fvm_ipld_bitfield::BitField;
use fvm_ipld_encoding::{CborStore, RawBytes, DAG_CBOR};
use fvm_shared::address::Address;
Expand All @@ -19,17 +29,6 @@ use integer_encoding::VarInt;
use num_traits::Zero;
use regex::Regex;
use std::collections::HashMap;

use fil_actor_miner::ext::verifreg::AllocationID;
use fil_actor_miner::{
new_deadline_info_from_offset_and_epoch, CompactCommD, Deadline, DeadlineInfo,
GetBeneficiaryReturn, Method as MinerMethod, MinerInfo, PowerPair, SectorOnChainInfo,
State as MinerState,
};
use fil_actor_verifreg::{Claim, ClaimID, State as VerifregState};
use fil_actors_runtime::cbor::serialize;
use fil_actors_runtime::test_utils::make_piece_cid;
use fil_builtin_actors_state::check::check_state_invariants;
use vm_api::{
util::{apply_ok, get_state, pk_addrs_from, DynBlockstore},
VM,
Expand Down
11 changes: 5 additions & 6 deletions integration_tests/src/util/workflows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -349,21 +349,20 @@ pub fn precommit_sectors_v2(

pub fn precommit_meta_data_from_deals(
v: &dyn VM,
deal_ids: Vec<u64>,
deal_ids: &[u64],
seal_proof: RegisteredSealProof,
) -> PrecommitMetadata {
let state: MarketState = get_state(v, &STORAGE_MARKET_ACTOR_ADDR).unwrap();
let pieces: Vec<PieceInfo> = deal_ids
.clone()
.into_iter()
.map(|id: u64| {
let deal = state.get_proposal(&DynBlockstore::wrap(v.blockstore()), id).unwrap();
.iter()
.map(|id: &u64| {
let deal = state.get_proposal(&DynBlockstore::wrap(v.blockstore()), *id).unwrap();
PieceInfo { size: deal.piece_size, cid: deal.piece_cid }
})
.collect();

PrecommitMetadata {
deals: deal_ids,
deals: deal_ids.to_vec(),
commd: CompactCommD::of(
v.primitives().compute_unsealed_sector_cid(seal_proof, &pieces).unwrap(),
),
Expand Down

0 comments on commit a35b1cc

Please sign in to comment.