Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Non Interactive Proof of Replication #1537

Closed
wants to merge 19 commits into from

Conversation

NemanjaLu92
Copy link
Contributor

@NemanjaLu92 NemanjaLu92 commented Apr 13, 2024

Copy link
Member

@anorth anorth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks to be on the right track, though missing some considerations. I assume it's just WIP, but thought I'd take a look anyway.

  • Validation of anything that would have been checked at PreCommit and is still relevant (e.g. sector number, expiration epoch, ...)
  • Different path for aggregate vs batched proofs
  • Fetch chain randomness according to the epoch specified for each sector

runtime/src/runtime/fvm.rs Outdated Show resolved Hide resolved
actors/miner/src/lib.rs Outdated Show resolved Hide resolved
actors/miner/src/lib.rs Outdated Show resolved Hide resolved
actors/miner/src/lib.rs Outdated Show resolved Hide resolved
Copy link
Member

@anorth anorth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd defer thorough review until this is complete (especially handling aggregate proofs), but still looking good so far.

Cargo.toml Outdated Show resolved Hide resolved
actors/miner/src/lib.rs Outdated Show resolved Hide resolved
actors/miner/src/lib.rs Outdated Show resolved Hide resolved
expected_storage_pledge: storage_pledge.clone(),
power_base_epoch: activation_epoch,
replaced_day_reward: TokenAmount::zero(),
sector_key_cid: None,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Kubuxu this is how current CC sectors are represented, just confirming we want to keep doing the same thing. Whether a sector can be updated is determined by [verified_]deal_weight == 0, and if so the sealed_cid is copied into this sector key cid upon the first update.

actors/miner/src/lib.rs Outdated Show resolved Hide resolved
actors/miner/src/lib.rs Outdated Show resolved Hide resolved
actors/miner/src/policy.rs Outdated Show resolved Hide resolved
actors/miner/src/types.rs Show resolved Hide resolved
test_vm/tests/suite/prove_commit3_test.rs Outdated Show resolved Hide resolved
actors/miner/src/types.rs Outdated Show resolved Hide resolved
actors/miner/src/types.rs Outdated Show resolved Hide resolved
runtime/src/runtime/fvm.rs Outdated Show resolved Hide resolved
runtime/src/runtime/fvm.rs Outdated Show resolved Hide resolved
@rvagg
Copy link
Member

rvagg commented May 24, 2024

I had a go at documenting the constants in go-state-types here: filecoin-project/go-state-types#270

I'd appreciate feedback on them to make sure I'm understanding and describing them well.

@BigLep
Copy link
Member

BigLep commented Jun 13, 2024

For anyone watching this PR, the latest status discussions have been happening in https://filecoinproject.slack.com/archives/C06EZQ2DTD0/p1718256559056139

@NemanjaLu92 NemanjaLu92 marked this pull request as ready for review June 13, 2024 23:41
actors/miner/src/types.rs Outdated Show resolved Hide resolved
actors/miner/src/types.rs Outdated Show resolved Hide resolved
actors/miner/src/lib.rs Outdated Show resolved Hide resolved
actors/miner/src/lib.rs Outdated Show resolved Hide resolved
actors/miner/src/lib.rs Outdated Show resolved Hide resolved
actors/miner/src/lib.rs Outdated Show resolved Hide resolved
actors/miner/src/lib.rs Outdated Show resolved Hide resolved
Comment on lines +200 to +207
apply_ok(
v,
&worker,
&maddr,
&TokenAmount::zero(),
MinerMethod::ProveCommitSectorsNI as u64,
Some(params.clone()),
);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
apply_ok(
v,
&worker,
&maddr,
&TokenAmount::zero(),
MinerMethod::ProveCommitSectorsNI as u64,
Some(params.clone()),
);
let ret_br: BatchReturn = apply_ok(
v,
&worker,
&maddr,
&TokenAmount::zero(),
MinerMethod::ProveCommitSectorsNI as u64,
Some(params.clone()),
)
.deserialize()
.unwrap();
assert_eq!(ret_br.len(), 2);
assert!(ret_bf.ok());
assert_eq!(ret_bf.size(), 4);
// something more to inspect codes and/or successes

would be really nice to check the return value in this, and the successful case in prove_commit_ni_whole_success_test (I'm ~guessing at the suggested code here based on the very few [unfortunately] instances of checking, such as in integration_tests/src/tests/replica_update_test.rs).

}

#[test]
fn prove_too_much_sector_ni_fail() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
fn prove_too_much_sector_ni_fail() {
fn prove_too_many_sectors_ni_fail() {

&params.aggregate_proof,
sector_numbers.len(),
policy,
false,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
false,
true,

&params.aggregate_proof,
params.sectors.len() as u64,
policy,
true,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
true,
false,

Comment on lines +5023 to +5024
false => (policy.min_aggregated_sectors, policy.max_aggregated_sectors),
true => (policy.min_aggregated_sectors_ni, policy.max_aggregated_sectors_ni),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
false => (policy.min_aggregated_sectors, policy.max_aggregated_sectors),
true => (policy.min_aggregated_sectors_ni, policy.max_aggregated_sectors_ni),
true => (policy.min_aggregated_sectors, policy.max_aggregated_sectors),
false => (policy.min_aggregated_sectors_ni, policy.max_aggregated_sectors_ni),

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

parameter name still doesn't match usage; either change its name or change the usage in here and at callsites

Comment on lines +4945 to +4949
warn!(
"seal challenge epoch {} must be before now {}",
sector.seal_rand_epoch, curr_epoch
);
fail_validation = true;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
warn!(
"seal challenge epoch {} must be before now {}",
sector.seal_rand_epoch, curr_epoch
);
fail_validation = true;
return Err(actor_error!(
illegal_argument,
"seal challenge epoch {} must be before now {}",
sector.seal_rand_epoch, curr_epoch
));

just fail the whole lot in this case I think

Copy link
Member

@anorth anorth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looking good now. I found a minor problem in the test expectations, but nothing else. I will now leave it to you and @rvagg to close out the final comments.

fail_validation = true;
}

if sector.seal_rand_epoch >= curr_epoch {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An explicit hard fail is probably the best option. But if we didn't do it explicitly here, it would abort anyway, either when attempting to fetch the randomness or when verifying the proof later.


if params.sectors.len() > 5 {
let aggregate_fee = aggregate_prove_commit_network_fee(
params.sectors.len() - fail_count - 5,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Either the test at line 912 should be params.sectors.len() - fail_count > 5 or the fail count should not be subtracted here. As-is, this can give a negative (underflow) sector count, or expect the wrong fee. You should be able to hit this with a test (submit 6, fail 2), and then fix the expectation.

@rvagg rvagg mentioned this pull request Jun 25, 2024
@aarshkshah1992
Copy link
Contributor

Should we close this PR now that #1559 is merged ?

@rvagg
Copy link
Member

rvagg commented Jun 25, 2024

merged in #1559 🥳 thanks @NemanjaLu92 !

@rvagg rvagg closed this Jun 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

6 participants