diff --git a/actors/market/src/emit.rs b/actors/market/src/emit.rs new file mode 100644 index 000000000..35348b38e --- /dev/null +++ b/actors/market/src/emit.rs @@ -0,0 +1,76 @@ +use fil_actors_runtime::runtime::Runtime; +use fil_actors_runtime::{ActorError, EventBuilder}; +use fvm_shared::deal::DealID; +use fvm_shared::ActorID; + +/// Indicates a deal has been published. +pub fn deal_published( + rt: &impl Runtime, + client: ActorID, + provider: ActorID, + deal_id: DealID, +) -> Result<(), ActorError> { + rt.emit_event( + &EventBuilder::new() + .typ("deal-published") + .with_parties(deal_id, client, provider) + .build()?, + ) +} + +/// Indicates a deal has been activated. +pub fn deal_activated( + rt: &impl Runtime, + deal_id: DealID, + client: ActorID, + provider: ActorID, +) -> Result<(), ActorError> { + rt.emit_event( + &EventBuilder::new() + .typ("deal-activated") + .with_parties(deal_id, client, provider) + .build()?, + ) +} + +/// Indicates a deal has been terminated. +pub fn deal_terminated( + rt: &impl Runtime, + deal_id: DealID, + client: ActorID, + provider: ActorID, +) -> Result<(), ActorError> { + rt.emit_event( + &EventBuilder::new() + .typ("deal-terminated") + .with_parties(deal_id, client, provider) + .build()?, + ) +} + +/// Indicates a deal has been completed successfully. +pub fn deal_completed( + rt: &impl Runtime, + deal_id: DealID, + client: ActorID, + provider: ActorID, +) -> Result<(), ActorError> { + rt.emit_event( + &EventBuilder::new() + .typ("deal-completed") + .with_parties(deal_id, client, provider) + .build()?, + ) +} + +trait WithParties { + fn with_parties(self, id: DealID, client: ActorID, provider: ActorID) -> EventBuilder; +} + +impl WithParties for EventBuilder { + fn with_parties(self, id: DealID, client: ActorID, provider: ActorID) -> EventBuilder { + self.field_indexed("id", &id) + .field_indexed("client", &client) + .field_indexed("provider", &provider) + } +} diff --git a/actors/market/src/lib.rs b/actors/market/src/lib.rs index 1218a0dde..e488c6b09 100644 --- a/actors/market/src/lib.rs +++ b/actors/market/src/lib.rs @@ -54,6 +54,7 @@ pub mod policy; pub mod testing; mod deal; +pub mod emit; mod state; mod types; @@ -482,6 +483,13 @@ impl Actor { .with_context_code(ExitCode::USR_ILLEGAL_ARGUMENT, || { format!("failed to notify deal with proposal cid {}", valid_deal.cid) })?; + + emit::deal_published( + rt, + valid_deal.proposal.client.id().unwrap(), + valid_deal.proposal.provider.id().unwrap(), + new_deal_ids[i], + )?; } Ok(PublishStorageDealsReturn { ids: new_deal_ids, valid_deals: valid_input_bf }) @@ -640,6 +648,16 @@ impl Actor { verified_infos, unsealed_cid: data_commitment, }); + + for (deal_id, proposal) in sector.deal_ids.iter().zip(&validated_proposals) { + emit::deal_activated( + rt, + *deal_id, + proposal.client.id().unwrap(), + proposal.provider.id().unwrap(), + )?; + } + batch_gen.add_success(); } @@ -833,6 +851,12 @@ impl Actor { state.slash_epoch = params.epoch; deal_states.push((*id, state)); + emit::deal_terminated( + rt, + *id, + deal.client.id().unwrap(), + deal.provider.id().unwrap(), + )?; } st.put_deal_states(rt.store(), &deal_states)?; @@ -919,7 +943,7 @@ impl Actor { })?; } - let (slash_amount, remove_deal) = + let (slash_amount, remove_deal, complete_success) = st.process_deal_update(rt.store(), &state, &deal, curr_epoch)?; if slash_amount.is_negative() { @@ -958,6 +982,15 @@ impl Actor { "failed to delete deal proposal: does not exist" )); } + + if complete_success { + emit::deal_completed( + rt, + deal_id, + deal.client.id().unwrap(), + deal.provider.id().unwrap(), + )?; + } } else { if !slash_amount.is_zero() { return Err(actor_error!( diff --git a/actors/market/src/state.rs b/actors/market/src/state.rs index f66d36f2c..584f4c143 100644 --- a/actors/market/src/state.rs +++ b/actors/market/src/state.rs @@ -740,7 +740,7 @@ impl State { state: &DealState, deal: &DealProposal, epoch: ChainEpoch, - ) -> Result<(TokenAmount, bool), ActorError> + ) -> Result<(TokenAmount, bool, bool), ActorError> where BS: Blockstore, { @@ -759,7 +759,7 @@ impl State { // This would be the case that the first callback somehow triggers before it is scheduled to // This is expected not to be able to happen if deal.start_epoch > epoch { - return Ok((TokenAmount::zero(), false)); + return Ok((TokenAmount::zero(), false, false)); } let payment_end_epoch = if ever_slashed { @@ -818,14 +818,14 @@ impl State { self.slash_balance(store, &deal.provider, &slashed, Reason::ProviderCollateral) .context("slashing balance")?; - return Ok((slashed, true)); + return Ok((slashed, true, false)); } if epoch >= deal.end_epoch { self.process_deal_expired(store, deal, state)?; - return Ok((TokenAmount::zero(), true)); + return Ok((TokenAmount::zero(), true, true)); } - Ok((TokenAmount::zero(), false)) + Ok((TokenAmount::zero(), false, false)) } /// Deal start deadline elapsed without appearing in a proven sector. diff --git a/actors/market/tests/activate_deal_failures.rs b/actors/market/tests/activate_deal_failures.rs index 0ca20fb96..3855cb1e4 100644 --- a/actors/market/tests/activate_deal_failures.rs +++ b/actors/market/tests/activate_deal_failures.rs @@ -131,6 +131,7 @@ fn assert_activation_failure( deal_ids: vec![deal_id], }], false, + vec![], ) .unwrap(); let res: BatchActivateDealsResult = diff --git a/actors/market/tests/batch_activate_deals.rs b/actors/market/tests/batch_activate_deals.rs index 555f5d83e..8961eb140 100644 --- a/actors/market/tests/batch_activate_deals.rs +++ b/actors/market/tests/batch_activate_deals.rs @@ -168,7 +168,8 @@ fn sectors_fail_and_succeed_independently_during_batch_activation() { }, ]; - let res = batch_activate_deals_raw(&rt, PROVIDER_ADDR, sectors_deals, false).unwrap(); + let res = + batch_activate_deals_raw(&rt, PROVIDER_ADDR, sectors_deals, false, vec![id_4]).unwrap(); let res: BatchActivateDealsResult = res.unwrap().deserialize().expect("VerifyDealsForActivation failed!"); @@ -227,7 +228,8 @@ fn handles_sectors_empty_of_deals_gracefully() { SectorDeals { sector_number: 3, deal_ids: vec![], sector_type, sector_expiry: END_EPOCH }, ]; - let res = batch_activate_deals_raw(&rt, PROVIDER_ADDR, sectors_deals, false).unwrap(); + let res = + batch_activate_deals_raw(&rt, PROVIDER_ADDR, sectors_deals, false, vec![id_1]).unwrap(); let res: BatchActivateDealsResult = res.unwrap().deserialize().expect("VerifyDealsForActivation failed!"); @@ -273,7 +275,7 @@ fn fails_to_activate_single_sector_duplicate_deals() { sector_expiry: END_EPOCH, }, ]; - let res = batch_activate_deals_raw(&rt, PROVIDER_ADDR, sectors_deals, false).unwrap(); + let res = batch_activate_deals_raw(&rt, PROVIDER_ADDR, sectors_deals, false, vec![]).unwrap(); let res: BatchActivateDealsResult = res.unwrap().deserialize().expect("VerifyDealsForActivation failed!"); @@ -328,7 +330,8 @@ fn fails_to_activate_cross_sector_duplicate_deals() { }, ]; - let res = batch_activate_deals_raw(&rt, PROVIDER_ADDR, sectors_deals, false).unwrap(); + let res = batch_activate_deals_raw(&rt, PROVIDER_ADDR, sectors_deals, false, vec![id_1, id_3]) + .unwrap(); let res: BatchActivateDealsResult = res.unwrap().deserialize().expect("VerifyDealsForActivation failed!"); diff --git a/actors/market/tests/cron_tick_deal_expiry.rs b/actors/market/tests/cron_tick_deal_expiry.rs index c203c1305..df2b6eba2 100644 --- a/actors/market/tests/cron_tick_deal_expiry.rs +++ b/actors/market/tests/cron_tick_deal_expiry.rs @@ -183,6 +183,13 @@ fn expired_deal_should_unlock_the_remaining_client_and_provider_locked_balance_a let p_escrow = get_balance(&rt, &PROVIDER_ADDR).balance; // move the current epoch so that deal is expired + expect_emitted( + &rt, + "deal-completed", + deal_id, + CLIENT_ADDR.id().unwrap(), + PROVIDER_ADDR.id().unwrap(), + ); rt.set_epoch(END_EPOCH + 1000); cron_tick(&rt); @@ -220,6 +227,13 @@ fn all_payments_are_made_for_a_deal_client_withdraws_collateral_and_client_accou // move the current epoch so that deal is expired rt.set_epoch(END_EPOCH + 100); + expect_emitted( + &rt, + "deal-completed", + deal_id, + CLIENT_ADDR.id().unwrap(), + PROVIDER_ADDR.id().unwrap(), + ); cron_tick(&rt); assert_eq!(deal_proposal.client_collateral, get_balance(&rt, &CLIENT_ADDR).balance); diff --git a/actors/market/tests/cron_tick_deal_slashing.rs b/actors/market/tests/cron_tick_deal_slashing.rs index 5319220d4..8087d3d10 100644 --- a/actors/market/tests/cron_tick_deal_slashing.rs +++ b/actors/market/tests/cron_tick_deal_slashing.rs @@ -136,7 +136,7 @@ fn deal_is_slashed_at_the_end_epoch_should_not_be_slashed_and_should_be_consider // as deal is considered to be expired. rt.set_epoch(END_EPOCH); - terminate_deals(&rt, PROVIDER_ADDR, &[SECTOR_NUMBER]); + terminate_deals_for(&rt, PROVIDER_ADDR, &[SECTOR_NUMBER], vec![]); // on the next cron tick, it will be processed as expired let current = END_EPOCH + 300; @@ -365,7 +365,7 @@ fn regular_payments_till_deal_expires_and_then_we_attempt_to_slash_it_but_it_wil // as deal is considered to be expired. let duration = END_EPOCH - current; rt.set_epoch(END_EPOCH); - terminate_deals(&rt, PROVIDER_ADDR, &[SECTOR_NUMBER]); + terminate_deals_for(&rt, PROVIDER_ADDR, &[SECTOR_NUMBER], vec![]); // next epoch for cron schedule is endEpoch + 300 -> // setting epoch to higher than that will cause deal to be expired, payment will be made diff --git a/actors/market/tests/harness.rs b/actors/market/tests/harness.rs index 41d7ee72c..68ca38bff 100644 --- a/actors/market/tests/harness.rs +++ b/actors/market/tests/harness.rs @@ -34,8 +34,8 @@ use fil_actors_runtime::{ network::EPOCHS_IN_DAY, runtime::{builtins::Type, Policy, Runtime}, test_utils::*, - ActorError, BatchReturn, Set, SetMultimap, BURNT_FUNDS_ACTOR_ADDR, CRON_ACTOR_ADDR, - DATACAP_TOKEN_ACTOR_ADDR, REWARD_ACTOR_ADDR, STORAGE_MARKET_ACTOR_ADDR, + ActorError, BatchReturn, EventBuilder, Set, SetMultimap, BURNT_FUNDS_ACTOR_ADDR, + CRON_ACTOR_ADDR, DATACAP_TOKEN_ACTOR_ADDR, REWARD_ACTOR_ADDR, STORAGE_MARKET_ACTOR_ADDR, STORAGE_POWER_ACTOR_ADDR, SYSTEM_ACTOR_ADDR, VERIFIED_REGISTRY_ACTOR_ADDR, }; use fvm_ipld_encoding::ipld_block::IpldBlock; @@ -324,6 +324,27 @@ pub fn activate_deals( current_epoch: ChainEpoch, sector_number: SectorNumber, deal_ids: &[DealID], +) -> BatchActivateDealsResult { + activate_deals_for( + rt, + sector_expiry, + provider, + current_epoch, + sector_number, + deal_ids, + deal_ids.into(), + ) +} + +/// Activate a single sector of deals +pub fn activate_deals_for( + rt: &MockRuntime, + sector_expiry: ChainEpoch, + provider: Address, + current_epoch: ChainEpoch, + sector_number: SectorNumber, + deal_ids: &[DealID], + expected_deal_activations: Vec, ) -> BatchActivateDealsResult { rt.set_epoch(current_epoch); let compute_cid = false; @@ -337,6 +358,7 @@ pub fn activate_deals( sector_type: RegisteredSealProof::StackedDRG8MiBV1, }], compute_cid, + expected_deal_activations, ) .unwrap(); @@ -371,7 +393,11 @@ pub fn batch_activate_deals( sector_type: RegisteredSealProof::StackedDRG8MiBV1, }) .collect(); - let ret = batch_activate_deals_raw(rt, provider, sectors_deals, compute_cid).unwrap(); + + let deal_ids = + sectors.iter().flat_map(|(_, _, deal_ids)| deal_ids).cloned().collect::>(); + + let ret = batch_activate_deals_raw(rt, provider, sectors_deals, compute_cid, deal_ids).unwrap(); let ret: BatchActivateDealsResult = ret.unwrap().deserialize().expect("VerifyDealsForActivation failed!"); @@ -387,10 +413,23 @@ pub fn batch_activate_deals_raw( provider: Address, sectors_deals: Vec, compute_cid: bool, + expected_activated_deals: Vec, ) -> Result, ActorError> { rt.set_caller(*MINER_ACTOR_CODE_ID, provider); rt.expect_validate_caller_type(vec![Type::Miner]); + for deal_id in expected_activated_deals { + let dp = get_deal_proposal(rt, deal_id); + + expect_emitted( + rt, + "deal-activated", + deal_id, + dp.client.id().unwrap(), + dp.provider.id().unwrap(), + ); + } + let params = BatchActivateDealsParams { sectors: sectors_deals, compute_cid }; let ret = rt.call::( @@ -552,6 +591,16 @@ pub fn cron_tick_and_assert_balances( updated_provider_locked = TokenAmount::zero(); } + if is_deal_expired { + expect_emitted( + rt, + "deal-completed", + deal_id, + client_addr.id().unwrap(), + provider_addr.id().unwrap(), + ); + } + cron_tick(rt); let client_acct = get_balance(rt, &client_addr); @@ -742,6 +791,13 @@ pub fn publish_deals( None, ExitCode::OK, ); + expect_emitted( + rt, + "deal-published", + deal_id, + deal.client.id().unwrap(), + deal.provider.id().unwrap(), + ); deal_id += 1; } @@ -1185,8 +1241,24 @@ pub fn generate_deal_proposal( ) } +pub fn terminate_deals_for( + rt: &MockRuntime, + miner_addr: Address, + sectors: &[SectorNumber], + expected_terminations: Vec, +) { + let ret = terminate_deals_raw(rt, miner_addr, sectors, expected_terminations).unwrap(); + assert!(ret.is_none()); + rt.verify(); +} + pub fn terminate_deals(rt: &MockRuntime, miner_addr: Address, sectors: &[SectorNumber]) { - let ret = terminate_deals_raw(rt, miner_addr, sectors).unwrap(); + let all_deal_ids = sectors + .iter() + .flat_map(|s| get_sector_deal_ids(rt, &miner_addr, *s)) + .collect::>(); + + let ret = terminate_deals_raw(rt, miner_addr, sectors, all_deal_ids).unwrap(); assert!(ret.is_none()); rt.verify(); } @@ -1195,6 +1267,7 @@ pub fn terminate_deals_raw( rt: &MockRuntime, miner_addr: Address, sector_numbers: &[SectorNumber], + terminated_deals: Vec, ) -> Result, ActorError> { rt.set_caller(*MINER_ACTOR_CODE_ID, miner_addr); rt.expect_validate_caller_type(vec![Type::Miner]); @@ -1202,6 +1275,17 @@ pub fn terminate_deals_raw( let bf = BitField::try_from_bits(sector_numbers.iter().copied()).unwrap(); let params = OnMinerSectorsTerminateParams { epoch: *rt.epoch.borrow(), sectors: bf }; + for deal_id in terminated_deals { + let d = get_deal_proposal(rt, deal_id); + expect_emitted( + rt, + "deal-terminated", + deal_id, + d.client.id().unwrap(), + d.provider.id().unwrap(), + ) + } + rt.call::( Method::OnMinerSectorsTerminate as u64, IpldBlock::serialize_cbor(¶ms).unwrap(), @@ -1262,3 +1346,15 @@ pub fn piece_info_from_deal(id: DealID, deal: &DealProposal) -> PieceChange { payload: serialize(&id, "deal id").unwrap(), } } + +pub fn expect_emitted(rt: &MockRuntime, typ: &str, id: DealID, client: ActorID, provider: ActorID) { + rt.expect_emitted_event( + EventBuilder::new() + .typ(typ) + .field_indexed("id", &id) + .field_indexed("client", &client) + .field_indexed("provider", &provider) + .build() + .unwrap(), + ); +} diff --git a/actors/market/tests/market_actor_test.rs b/actors/market/tests/market_actor_test.rs index 39321e754..b27c6cb61 100644 --- a/actors/market/tests/market_actor_test.rs +++ b/actors/market/tests/market_actor_test.rs @@ -941,6 +941,14 @@ fn provider_and_client_addresses_are_resolved_before_persisting_state_and_sent_t ExitCode::OK, ); + expect_emitted( + &rt, + "deal-published", + deal_id, + client_resolved.id().unwrap(), + provider_resolved.id().unwrap(), + ); + let ret: PublishStorageDealsReturn = rt .call::( Method::PublishStorageDeals as u64, @@ -1717,6 +1725,7 @@ fn fail_when_current_epoch_greater_than_start_epoch_of_deal() { deal_ids: vec![deal_id], }], false, + vec![], ) .unwrap(); @@ -1754,6 +1763,7 @@ fn fail_when_end_epoch_of_deal_greater_than_sector_expiry() { deal_ids: vec![deal_id], }], false, + vec![], ) .unwrap(); @@ -1807,6 +1817,7 @@ fn fail_to_activate_all_deals_if_one_deal_fails() { deal_ids: vec![deal_id1, deal_id2], }], false, + vec![], ) .unwrap(); let res: BatchActivateDealsResult = @@ -1944,6 +1955,9 @@ fn locked_fund_tracking_states() { None, ExitCode::OK, ); + + expect_emitted(&rt, "deal-completed", deal_id2, d2.client.id().unwrap(), p2.id().unwrap()); + cron_tick(&rt); assert_locked_fund_states(&rt, csf, plc, clc); check_state(&rt); @@ -2155,6 +2169,14 @@ fn insufficient_client_balance_in_a_batch() { ExitCode::OK, ); + expect_emitted( + &rt, + "deal-published", + next_deal_id, + deal2.client.id().unwrap(), + deal2.provider.id().unwrap(), + ); + rt.set_caller(*ACCOUNT_ACTOR_CODE_ID, WORKER_ADDR); let ret: PublishStorageDealsReturn = rt @@ -2297,6 +2319,14 @@ fn insufficient_provider_balance_in_a_batch() { rt.set_caller(*ACCOUNT_ACTOR_CODE_ID, WORKER_ADDR); + expect_emitted( + &rt, + "deal-published", + next_deal_id, + deal2.client.id().unwrap(), + deal2.provider.id().unwrap(), + ); + let ret: PublishStorageDealsReturn = rt .call::( Method::PublishStorageDeals as u64, @@ -2438,6 +2468,14 @@ fn psd_restricted_correctly() { ExitCode::OK, ); + expect_emitted( + &rt, + "deal-published", + next_deal_id, + deal.client.id().unwrap(), + deal.provider.id().unwrap(), + ); + let ret: PublishStorageDealsReturn = rt .call::( Method::PublishStorageDealsExported as MethodNum, diff --git a/actors/market/tests/on_miner_sectors_terminate.rs b/actors/market/tests/on_miner_sectors_terminate.rs index 95915712b..2934479f2 100644 --- a/actors/market/tests/on_miner_sectors_terminate.rs +++ b/actors/market/tests/on_miner_sectors_terminate.rs @@ -197,7 +197,7 @@ fn terminate_valid_deals_along_with_just_expired_deal() { let new_epoch = end_epoch - 1; rt.set_epoch(new_epoch); - terminate_deals(&rt, PROVIDER_ADDR, &[sector_number]); + terminate_deals_for(&rt, PROVIDER_ADDR, &[sector_number], vec![deal1, deal2]); assert_deals_terminated(&rt, new_epoch, &[deal1, deal2]); // Not cleaned up yet. assert_deals_not_terminated(&rt, &[deal3]); @@ -246,6 +246,14 @@ fn terminate_valid_deals_along_with_expired_and_cleaned_up_deal() { let new_epoch = end_epoch - 1; rt.set_epoch(new_epoch); + expect_emitted( + &rt, + "deal-completed", + deal_ids[1], + CLIENT_ADDR.id().unwrap(), + PROVIDER_ADDR.id().unwrap(), + ); + cron_tick(&rt); terminate_deals(&rt, PROVIDER_ADDR, &[sector_number]); @@ -375,7 +383,7 @@ fn do_not_terminate_deal_if_end_epoch_is_equal_to_or_less_than_current_epoch() { activate_deals(&rt, sector_expiry, PROVIDER_ADDR, current_epoch, sector_number, &[deal1]); assert!(ret.activation_results.all_ok()); rt.set_epoch(end_epoch); - terminate_deals(&rt, PROVIDER_ADDR, &[sector_number]); + terminate_deals_for(&rt, PROVIDER_ADDR, &[sector_number], vec![]); assert_deals_not_terminated(&rt, &[deal1]); // deal2 has end epoch less than current epoch when terminate is called @@ -392,7 +400,7 @@ fn do_not_terminate_deal_if_end_epoch_is_equal_to_or_less_than_current_epoch() { activate_deals(&rt, sector_expiry, PROVIDER_ADDR, current_epoch, sector_number, &[deal2]); assert!(ret.activation_results.all_ok()); rt.set_epoch(end_epoch + 1); - terminate_deals(&rt, PROVIDER_ADDR, &[sector_number]); + terminate_deals_for(&rt, PROVIDER_ADDR, &[sector_number], vec![]); assert_deals_not_terminated(&rt, &[deal2]); check_state(&rt); diff --git a/actors/market/tests/publish_storage_deals_failures.rs b/actors/market/tests/publish_storage_deals_failures.rs index 045815d2e..700350fad 100644 --- a/actors/market/tests/publish_storage_deals_failures.rs +++ b/actors/market/tests/publish_storage_deals_failures.rs @@ -24,7 +24,6 @@ use cid::Cid; use fil_actor_market::ext::account::{AuthenticateMessageParams, AUTHENTICATE_MESSAGE_METHOD}; mod harness; - use fvm_ipld_encoding::ipld_block::IpldBlock; use fvm_shared::sys::SendFlags; use harness::*; @@ -376,6 +375,14 @@ fn fail_when_deals_have_different_providers() { ExitCode::OK, ); + expect_emitted( + &rt, + "deal-published", + next_deal_id, + deal1.client.id().unwrap(), + deal1.provider.id().unwrap(), + ); + let psd_ret: PublishStorageDealsReturn = rt .call::( Method::PublishStorageDeals as u64, diff --git a/actors/market/tests/random_cron_epoch_during_publish.rs b/actors/market/tests/random_cron_epoch_during_publish.rs index b9ba93a22..ef7e77b75 100644 --- a/actors/market/tests/random_cron_epoch_during_publish.rs +++ b/actors/market/tests/random_cron_epoch_during_publish.rs @@ -152,8 +152,15 @@ fn activation_after_deal_start_epoch_but_before_it_is_processed_fails() { let curr_epoch = START_EPOCH + 1; rt.set_epoch(curr_epoch); - let res = - activate_deals(&rt, SECTOR_EXPIRY, PROVIDER_ADDR, curr_epoch, SECTOR_NUMBER, &[deal_id]); + let res = activate_deals_for( + &rt, + SECTOR_EXPIRY, + PROVIDER_ADDR, + curr_epoch, + SECTOR_NUMBER, + &[deal_id], + vec![], + ); assert_eq!(res.activation_results.codes(), vec![EX_DEAL_EXPIRED]); check_state(&rt); } diff --git a/actors/verifreg/src/lib.rs b/actors/verifreg/src/lib.rs index 25c05bb9f..31661fda6 100644 --- a/actors/verifreg/src/lib.rs +++ b/actors/verifreg/src/lib.rs @@ -174,9 +174,10 @@ impl Actor { // Validate caller is one of the verifiers, i.e. has an allowance (even if zero). let verifier_addr = rt.message().caller(); - let verifier_cap = st - .get_verifier_cap(rt.store(), &verifier_addr)? - .ok_or_else(|| actor_error!(not_found, "caller {} is not a verifier", verifier_addr))?; + let verifier_cap = + st.get_verifier_cap(rt.store(), &verifier_addr)?.ok_or_else(|| { + actor_error!(not_found, "caller {} is not a verifier", verifier_addr) + })?; // Disallow existing verifiers as clients. if st.get_verifier_cap(rt.store(), &client)?.is_some() { @@ -335,10 +336,13 @@ impl Actor { } for id in to_remove { - let existing = allocs.remove(params.client, *id).context_code( - ExitCode::USR_ILLEGAL_STATE, - format!("failed to remove allocation {}", id), - )?.unwrap(); // Unwrapping here as both paths to here should ensure the allocation exists. + let existing = allocs + .remove(params.client, *id) + .context_code( + ExitCode::USR_ILLEGAL_STATE, + format!("failed to remove allocation {}", id), + )? + .unwrap(); // Unwrapping here as both paths to here should ensure the allocation exists. emit::allocation_removed(rt, *id, existing.client, existing.provider)?; diff --git a/actors/verifreg/tests/harness/mod.rs b/actors/verifreg/tests/harness/mod.rs index 0ded5d741..eac9acfc5 100644 --- a/actors/verifreg/tests/harness/mod.rs +++ b/actors/verifreg/tests/harness/mod.rs @@ -34,7 +34,10 @@ use fil_actors_runtime::runtime::policy_constants::{ }; use fil_actors_runtime::runtime::Runtime; use fil_actors_runtime::test_utils::*; -use fil_actors_runtime::{make_empty_map, ActorError, AsActorError, BatchReturn, DATACAP_TOKEN_ACTOR_ADDR, STORAGE_MARKET_ACTOR_ADDR, SYSTEM_ACTOR_ADDR, VERIFIED_REGISTRY_ACTOR_ADDR, EventBuilder}; +use fil_actors_runtime::{ + make_empty_map, ActorError, AsActorError, BatchReturn, EventBuilder, DATACAP_TOKEN_ACTOR_ADDR, + STORAGE_MARKET_ACTOR_ADDR, SYSTEM_ACTOR_ADDR, VERIFIED_REGISTRY_ACTOR_ADDR, +}; pub const ROOT_ADDR: Address = Address::new_id(101); @@ -136,7 +139,6 @@ impl Harness { None, ); - rt.expect_emitted_event( EventBuilder::new() .typ("verifier-balance") diff --git a/vm_api/src/trace.rs b/vm_api/src/trace.rs index 3d01104a6..8ea020b0f 100644 --- a/vm_api/src/trace.rs +++ b/vm_api/src/trace.rs @@ -2,8 +2,8 @@ use fvm_ipld_encoding::ipld_block::IpldBlock; use fvm_shared::address::Address; use fvm_shared::econ::TokenAmount; use fvm_shared::error::{ErrorNumber, ExitCode}; -use fvm_shared::{ActorID, MethodNum}; use fvm_shared::event::ActorEvent; +use fvm_shared::{ActorID, MethodNum}; type ReturnValue = Option; @@ -209,4 +209,4 @@ impl Default for ExpectInvocation { events: vec![], } } -} \ No newline at end of file +}