Skip to content

Commit

Permalink
finish review
Browse files Browse the repository at this point in the history
  • Loading branch information
aarshkshah1992 committed Jan 11, 2024
1 parent 4d20e04 commit 6e3b5ca
Show file tree
Hide file tree
Showing 9 changed files with 112 additions and 178 deletions.
11 changes: 9 additions & 2 deletions actors/market/tests/random_cron_epoch_during_publish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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_for(&rt, SECTOR_EXPIRY, PROVIDER_ADDR, curr_epoch, SECTOR_NUMBER, &[deal_id], vec![]);
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);
}
Expand Down
13 changes: 7 additions & 6 deletions actors/miner/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1025,7 +1025,7 @@ impl Actor {
));
}

let mut sector_commds: HashMap<SectorNumber, Cid> = HashMap::new();
let mut sector_commds: HashMap<SectorNumber, Option<Cid>> = HashMap::new();
// Load sector infos for validation, failing if any don't exist.
let mut sectors = Sectors::load(&store, &state.sectors)
.context_code(ExitCode::USR_ILLEGAL_STATE, "failed to load sectors array")?;
Expand All @@ -1034,23 +1034,24 @@ impl Actor {
for (i, update) in params.sector_updates.iter().enumerate() {
sector_infos.push(sectors.must_get(update.sector)?);
let sector_type = sector_infos.last().unwrap().seal_proof;
let computed_commd =
unsealed_cid_from_pieces(rt, &update.pieces, sector_type)?.get_cid(sector_type)?;
let computed_commd = unsealed_cid_from_pieces(rt, &update.pieces, sector_type)?;

let unsealed_cid = computed_commd.get_cid(sector_type)?;

updates.push(ReplicaUpdateInner {
sector_number: update.sector,
deadline: update.deadline,
partition: update.partition,
new_sealed_cid: update.new_sealed_cid,
new_unsealed_cid: Some(computed_commd),
new_unsealed_cid: Some(unsealed_cid),
deals: vec![],
update_proof_type: params.update_proofs_type,
// Replica proof may be empty if an aggregate is being proven.
// Validation needs to accept this empty proof.
replica_proof: params.sector_proofs.get(i).unwrap_or(&RawBytes::default()).clone(),
});

sector_commds.insert(update.sector, computed_commd);
sector_commds.insert(update.sector, computed_commd.0);
}

// Validate inputs.
Expand Down Expand Up @@ -1197,7 +1198,7 @@ impl Actor {
emit::sector_updated(
rt,
update.sector,
sector_commds.get(&update.sector).copied(),
*sector_commds.get(&update.sector).unwrap(),
&pieces,
)?;
}
Expand Down
8 changes: 1 addition & 7 deletions actors/miner/tests/prove_commit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -510,13 +510,7 @@ fn drop_invalid_prove_commit_while_processing_valid_one() {
verified_deal_infos: HashMap::from([(sector_no_b, vec![test_verified_deal(100)])]),
..Default::default()
};
h.confirm_sector_proofs_valid_for(
&rt,
conf,
vec![pre_commit_a, pre_commit_b],
vec![sector_no_b],
)
.unwrap();
h.confirm_sector_proofs_valid(&rt, conf, vec![pre_commit_a, pre_commit_b]).unwrap();
let st = h.get_state(&rt);
assert!(st.get_sector(&rt.store, sector_no_a).unwrap().is_none());
assert!(st.get_sector(&rt.store, sector_no_b).unwrap().is_some());
Expand Down
8 changes: 4 additions & 4 deletions actors/miner/tests/prove_commit2_failures_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ fn reject_precommit_deals() {
expect_abort_contains_message(
ExitCode::USR_ILLEGAL_ARGUMENT,
"invalid pre-commit 0 while requiring activation success",
h.prove_commit_sectors2_for(&rt, &manifests, true, false, false, cfg, vec![]),
h.prove_commit_sectors2(&rt, &manifests, true, false, false, cfg),
);
h.check_state(&rt);
}
Expand All @@ -146,7 +146,7 @@ fn reject_all_proofs_fail() {
expect_abort_contains_message(
ExitCode::USR_ILLEGAL_ARGUMENT,
"no valid proofs",
h.prove_commit_sectors2_for(&rt, &activations, false, false, false, cfg, vec![]),
h.prove_commit_sectors2(&rt, &activations, false, false, false, cfg),
);
h.check_state(&rt);
}
Expand All @@ -159,7 +159,7 @@ fn reject_aggregate_proof_fails() {
expect_abort_contains_message(
ExitCode::USR_ILLEGAL_ARGUMENT,
"invalid aggregate proof",
h.prove_commit_sectors2_for(&rt, &activations, false, false, true, cfg, vec![]),
h.prove_commit_sectors2(&rt, &activations, false, false, true, cfg),
);
h.check_state(&rt);
}
Expand All @@ -172,7 +172,7 @@ fn reject_required_proof_failure() {
expect_abort_contains_message(
ExitCode::USR_ILLEGAL_ARGUMENT,
"invalid proof for sector 100 while requiring activation success",
h.prove_commit_sectors2_for(&rt, &activations, true, false, false, cfg, vec![]),
h.prove_commit_sectors2(&rt, &activations, true, false, false, cfg),
);
h.check_state(&rt);
}
Expand Down
27 changes: 7 additions & 20 deletions actors/miner/tests/prove_commit2_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -326,9 +326,8 @@ fn expired_precommit_dropped_batch() {
];

let cfg = ProveCommitSectors2Config { validation_failure: vec![0], ..Default::default() };
let (result, claims, notifications) = h
.prove_commit_sectors2_for(&rt, &manifests, false, false, false, cfg, vec![snos[1]])
.unwrap();
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
Expand Down Expand Up @@ -371,17 +370,7 @@ fn expired_precommit_dropped_aggregate() {
];

let cfg = ProveCommitSectors2Config { validation_failure: vec![0], ..Default::default() };
let (result, _, _) = h
.prove_commit_sectors2_for(
&rt,
&manifests,
false,
false,
true,
cfg,
vec![snos[1], snos[2], snos[3]],
)
.unwrap();
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,
Expand Down Expand Up @@ -412,9 +401,8 @@ fn invalid_proof_dropped() {
];

let cfg = ProveCommitSectors2Config { proof_failure: vec![0], ..Default::default() };
let (result, _, _) = h
.prove_commit_sectors2_for(&rt, &manifests, false, false, false, cfg, vec![snos[1]])
.unwrap();
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
Expand All @@ -439,9 +427,8 @@ fn invalid_claim_dropped() {
];

let cfg = ProveCommitSectors2Config { claim_failure: vec![0], ..Default::default() };
let (result, _, _) = h
.prove_commit_sectors2_for(&rt, &manifests, false, false, false, cfg, vec![snos[1]])
.unwrap();
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
Expand Down
15 changes: 6 additions & 9 deletions actors/miner/tests/prove_replica_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -340,9 +340,8 @@ fn invalid_update_dropped() {
sector_updates[0].deadline += 1; // Invalid update

let cfg = ProveReplicaUpdatesConfig { validation_failure: vec![0], ..Default::default() };
let (result, claims, notifications) = h
.prove_replica_updates2_batch_for(&rt, &sector_updates, false, false, cfg, vec![snos[1]])
.unwrap();
let (result, claims, notifications) =
h.prove_replica_updates2_batch(&rt, &sector_updates, false, false, cfg).unwrap();
assert_update_result(&[ExitCode::USR_ILLEGAL_ARGUMENT, ExitCode::OK], &result);

// Sector 0: no change.
Expand All @@ -369,9 +368,8 @@ fn invalid_proof_dropped() {
];

let cfg = ProveReplicaUpdatesConfig { proof_failure: vec![0], ..Default::default() };
let (result, _, _) = h
.prove_replica_updates2_batch_for(&rt, &sector_updates, false, false, cfg, vec![snos[1]])
.unwrap();
let (result, _, _) =
h.prove_replica_updates2_batch(&rt, &sector_updates, false, false, cfg).unwrap();
assert_update_result(&[ExitCode::USR_ILLEGAL_ARGUMENT, ExitCode::OK], &result);

verify_weights(&rt, &h, snos[0], 0, 0);
Expand All @@ -392,9 +390,8 @@ fn invalid_claim_dropped() {
];

let cfg = ProveReplicaUpdatesConfig { claim_failure: vec![0], ..Default::default() };
let (result, _, _) = h
.prove_replica_updates2_batch_for(&rt, &sector_updates, false, false, cfg, vec![snos[1]])
.unwrap();
let (result, _, _) =
h.prove_replica_updates2_batch(&rt, &sector_updates, false, false, cfg).unwrap();
assert_update_result(&[ExitCode::USR_ILLEGAL_ARGUMENT, ExitCode::OK], &result);

verify_weights(&rt, &h, snos[0], 0, 0);
Expand Down
Loading

0 comments on commit 6e3b5ca

Please sign in to comment.