Skip to content

Commit

Permalink
fix(niporep): hard-fail on future sector seal randomness
Browse files Browse the repository at this point in the history
  • Loading branch information
rvagg committed Jun 25, 2024
1 parent 5238ef4 commit 03c6878
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
13 changes: 7 additions & 6 deletions actors/miner/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4947,8 +4947,7 @@ fn validate_ni_sectors(
for (i, sector) in sectors.iter().enumerate() {
let mut fail_validation = false;

let set = sector_numbers.get(sector.sector_number);
if set {
if sector_numbers.get(sector.sector_number) {
return Err(actor_error!(
illegal_argument,
"duplicate sector number {}",
Expand Down Expand Up @@ -4990,11 +4989,13 @@ fn validate_ni_sectors(
}

if sector.seal_rand_epoch >= curr_epoch {
warn!(
// hard-fail because we can't access necessary randomness from the future
return Err(actor_error!(
illegal_argument,
"seal challenge epoch {} must be before now {}",
sector.seal_rand_epoch, curr_epoch
);
fail_validation = true;
sector.seal_rand_epoch,
curr_epoch
));
}

if sector.seal_rand_epoch < challenge_earliest {
Expand Down
4 changes: 3 additions & 1 deletion integration_tests/src/tests/prove_commit_niporep_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,9 @@ pub fn prove_commit_ni_partial_success_not_required_test(v: &dyn VM) {
})
.collect();

sectors_info[0].seal_rand_epoch = activation_epoch;
// non-fatal error
sectors_info[0].seal_rand_epoch =
v.epoch() - policy.max_prove_commit_ni_randomness_lookback - 1;

let invalid_sector_nos = sector_nos.iter().take(1).copied().collect::<Vec<_>>();
let valid_sector_nos = sector_nos.iter().skip(1).copied().collect::<Vec<_>>();
Expand Down

0 comments on commit 03c6878

Please sign in to comment.