Skip to content

Commit

Permalink
cleanup after verified claim scenario
Browse files Browse the repository at this point in the history
  • Loading branch information
alexytsu committed Aug 30, 2023
1 parent 26117bb commit b820b60
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 10 deletions.
1 change: 1 addition & 0 deletions actors/market/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1005,6 +1005,7 @@ impl Actor {
rt: &impl Runtime,
params: ProcessDealsParams,
) -> Result<ProcessDealsReturn, ActorError> {
rt.validate_immediate_caller_accept_any()?;
let curr_epoch = rt.curr_epoch();
let mut total_slashed = TokenAmount::zero();
let mut expired_deals: Vec<DealID> = Vec::new();
Expand Down
10 changes: 3 additions & 7 deletions actors/market/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -675,13 +675,9 @@ impl State {
let ever_slashed = state.slash_epoch != EPOCH_UNDEFINED;

if !ever_updated {
self.remove_pending_deal(store, *deal_cid)?.ok_or_else(|| {
actor_error!(
illegal_state,
"failed to delete pending proposal: cid {} does not exist",
deal_cid
)
})?;
// pending deal might have already been removed in first cron_tick, so we don't care if
// it's already missing
self.remove_pending_deal(store, *deal_cid)?;
}

// if the deal was ever updated, make sure it didn't happen in the future
Expand Down
10 changes: 7 additions & 3 deletions integration_tests/src/tests/verified_claim_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ use crate::util::{
advance_by_deadline_to_index, advance_to_proving_deadline, assert_invariants, create_accounts,
create_miner, cron_tick, datacap_extend_claim, datacap_get_balance, expect_invariants,
invariant_failure_patterns, market_add_balance, market_publish_deal,
miner_extend_sector_expiration2, miner_precommit_sector, miner_prove_sector, sector_deadline,
submit_windowed_post, verifreg_add_client, verifreg_add_verifier, verifreg_extend_claim_terms,
verifreg_remove_expired_allocations,
miner_extend_sector_expiration2, miner_precommit_sector, miner_prove_sector,
provider_process_deal_updates, 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 @@ -356,6 +356,10 @@ 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);

// provider must process the deals to receive payment and cleanup state
provider_process_deal_updates(v, &miner_id, &deals);
// TODO: assert that the right payouts have been made

expect_invariants(
v,
&Policy::default(),
Expand Down
13 changes: 13 additions & 0 deletions integration_tests/src/util/workflows.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std::cmp::min;

use fil_actor_market::ProcessDealsParams;
use frc46_token::receiver::FRC46TokenReceived;
use frc46_token::receiver::FRC46_TOKEN_TYPE;
use frc46_token::token::types::TransferFromParams;
Expand Down Expand Up @@ -523,6 +524,18 @@ pub fn miner_extend_sector_expiration2(
.matches(v.take_invocations().last().unwrap());
}

pub fn provider_process_deal_updates(v: &dyn VM, provider: &Address, deals: &[DealID]) {
let params = ProcessDealsParams { deal_ids: deals.to_vec() };
apply_ok(
v,
provider,
&STORAGE_MARKET_ACTOR_ADDR,
&TokenAmount::zero(),
MarketMethod::ProcessDealUpdatesExported as u64,
Some(params),
);
}

pub fn advance_by_deadline_to_epoch(v: &dyn VM, maddr: &Address, e: ChainEpoch) -> DeadlineInfo {
// keep advancing until the epoch of interest is within the deadline
// if e is dline.last() == dline.close -1 cron is not run
Expand Down

0 comments on commit b820b60

Please sign in to comment.