Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
alexytsu committed May 30, 2023
1 parent 3cc64e4 commit 943c209
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 37 deletions.
2 changes: 1 addition & 1 deletion actors/miner/src/ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ pub mod market {
}
}

#[derive(Clone, Serialize_tuple, Deserialize_tuple)]
#[derive(Serialize_tuple, Deserialize_tuple, Clone)]
pub struct ActivateDealsResult {
#[serde(with = "bigint_ser")]
pub nonverified_deal_space: BigInt,
Expand Down
10 changes: 4 additions & 6 deletions actors/miner/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@ pub use termination::*;
pub use types::*;
pub use vesting_state::*;

use crate::ext::market::DealSpaces;

// The following errors are particular cases of illegal state.
// They're not expected to ever happen, but if they do, distinguished codes can help us
// diagnose the problem.
Expand Down Expand Up @@ -4798,7 +4796,7 @@ fn confirm_sector_proofs_valid_internal(
// a constant number of them.
let activation = rt.curr_epoch();

let activated_sectors: Vec<(&SectorPreCommitOnChainInfo, DealSpaces)> =
let activated_sectors: Vec<(SectorPreCommitOnChainInfo, ext::market::DealSpaces)> =
match batch_activate_deals_and_claim_allocations(
rt,
pre_commits
Expand All @@ -4817,7 +4815,7 @@ fn confirm_sector_proofs_valid_internal(
None => {
return Err(actor_error!(illegal_argument, "all prove commits failed to validate"));
}
Some(activated_sectors) => pre_commits.iter().zip(activated_sectors).collect(),
Some(activated_sectors) => pre_commits.into_iter().zip(activated_sectors).collect(),
};

let (total_pledge, newly_vested) = rt.transaction(|state: &mut State, rt| {
Expand Down Expand Up @@ -4885,7 +4883,7 @@ fn confirm_sector_proofs_valid_internal(
sector_number: pre_commit.info.sector_number,
seal_proof: pre_commit.info.seal_proof,
sealed_cid: pre_commit.info.sealed_cid,
deal_ids: pre_commit.info.deal_ids.clone(),
deal_ids: pre_commit.info.deal_ids,
expiration: pre_commit.info.expiration,
activation,
deal_weight,
Expand Down Expand Up @@ -5051,7 +5049,7 @@ fn batch_activate_deals_and_claim_allocations(
.claim_results
.iter()
.zip(activation_results)
.map(|(claim_result, claim_info)| DealSpaces {
.map(|(claim_result, claim_info)| ext::market::DealSpaces {
deal_space: claim_info.0.nonverified_deal_space,
verified_deal_space: claim_result.claimed_space.clone(),
})
Expand Down
71 changes: 41 additions & 30 deletions actors/miner/tests/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1054,6 +1054,9 @@ impl ActorHarness {
pcs: &[SectorPreCommitOnChainInfo],
) {
let mut valid_pcs = Vec::new();
// claim FIL+ allocations
let mut sectors_claims: Vec<SectorAllocationClaim> = Vec::new();

for pc in pcs {
if !pc.info.deal_ids.is_empty() {
let deal_spaces = cfg.deal_spaces(&pc.info.sector_number);
Expand Down Expand Up @@ -1092,8 +1095,7 @@ impl ActorHarness {
valid_pcs.push(pc);
}
} else {
// calim FIL+ allocations
let sector_claims: Vec<SectorAllocationClaim> = ret
let mut sector_claims: Vec<SectorAllocationClaim> = ret
.verified_infos
.iter()
.map(|info| SectorAllocationClaim {
Expand All @@ -1105,40 +1107,49 @@ impl ActorHarness {
sector_expiry: pc.info.expiration,
})
.collect();

let claim_allocation_params = ClaimAllocationsParams {
sectors: sector_claims.clone(),
all_or_nothing: true,
};

// TODO handle failures of claim allocations
// use exit code map for claim allocations in config
valid_pcs.push(pc);
let claim_allocs_ret = ClaimAllocationsReturn {
batch_info: BatchReturn::ok(ret.verified_infos.len() as u32),
claim_results: sector_claims
.iter()
.map(|claim| SectorAllocationClaimResult {
claimed_space: claim.size.0.into(),
sector: claim.sector,
sector_expiry: claim.sector_expiry,
})
.collect(),
};
rt.expect_send_simple(
VERIFIED_REGISTRY_ACTOR_ADDR,
CLAIM_ALLOCATIONS_METHOD as u64,
IpldBlock::serialize_cbor(&claim_allocation_params).unwrap(),
TokenAmount::zero(),
IpldBlock::serialize_cbor(&claim_allocs_ret).unwrap(),
ExitCode::OK,
);
sectors_claims.append(&mut sector_claims);
}
} else {
// empty deal ids
valid_pcs.push(pc);
}
}

let claim_allocation_params =
ClaimAllocationsParams { sectors: sectors_claims.clone(), all_or_nothing: true };

// TODO handle failures of claim allocations
// use exit code map for claim allocations in config

let claim_allocs_ret = ClaimAllocationsReturn {
batch_info: BatchReturn::ok(sectors_claims.len() as u32),
claim_results: sectors_claims
.iter()
.map(|claim| SectorAllocationClaimResult {
claimed_space: claim.size.0.into(),
sector: claim.sector,
sector_expiry: claim.sector_expiry,
})
.collect(),
};
rt.expect_send_simple(
VERIFIED_REGISTRY_ACTOR_ADDR,
CLAIM_ALLOCATIONS_METHOD as u64,
IpldBlock::serialize_cbor(&claim_allocation_params).unwrap(),
TokenAmount::zero(),
IpldBlock::serialize_cbor(&claim_allocs_ret).unwrap(),
ExitCode::OK,
);

rt.expect_send_simple(
STORAGE_POWER_ACTOR_ADDR,
UPDATE_PLEDGE_TOTAL_METHOD,
None,
TokenAmount::zero(),
None,
ExitCode::OK,
);

if !valid_pcs.is_empty() {
let mut expected_pledge = TokenAmount::zero();
let mut expected_qa_power = BigInt::from(0);
Expand Down

0 comments on commit 943c209

Please sign in to comment.