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

Window PoSt challenge generation should not depend on sector order #1270

Open
porcuquine opened this issue Sep 1, 2020 · 3 comments
Open

Comments

@porcuquine
Copy link
Collaborator

porcuquine commented Sep 1, 2020

Description

Window PoSt challenge generation currently depends on the ordering of provided sectors.

This is considered to be a 'protocol bug' in that this is the behavior which has been specified and audited. However, it allows for miners to influence challenges by shuffling their sectors. One possible (and probably cleanest) solution is to make challenge-generation independent of sector ordering — at the cost of a breaking change (so extant Window PoSts would not verify with the new code, requiring a network reset or proofs upgrade).

In the current code, the function generate_leaf_challenges appears to do the right thing, but this function is only called from Election PoSt so is not actually used.

pub fn generate_leaf_challenges<T: Domain>(
pub_params: &PublicParams,
randomness: T,
sector_id: u64,
challenge_count: usize,
) -> Result<Vec<u64>> {
let mut challenges = Vec::with_capacity(challenge_count);
for leaf_challenge_index in 0..challenge_count {
let challenge = generate_leaf_challenge(
pub_params,
randomness,
sector_id,
leaf_challenge_index as u64,
)?;
challenges.push(challenge)
}
Ok(challenges)
}

Notice, however, that in generate_public_input for Fallback PoSt, challenge_index depends on i (the sector's index within the submitted partition). This must not be the case.

let challenge_index = ((partition_index * pub_params.sector_count + i)
* pub_params.challenge_count
+ n) as u64;
let challenged_leaf_start = fallback::generate_leaf_challenge(
&pub_params,
pub_inputs.randomness,
sector.id.into(),
challenge_index,
)?;
Instead, the challenge_index can just be n. Each sector's challenge indexes should range from 0 to challenge_count.

The same can be seen in the vanilla proof:

.map(|n| {
let challenge_index = ((j * num_sectors_per_chunk + i)
* pub_params.challenge_count
+ n) as u64;
let challenged_leaf_start = generate_leaf_challenge(
pub_params,
pub_inputs.randomness,
sector_id.into(),
challenge_index,
)?;

Acceptance criteria

Window PoSt challenge generation does not depend on the ordering of provided sectors.

Risks + pitfalls

This will be a breaking change to proofs: a proof generated with the previous Window PoSt will not verify. Therefore, we will either:

  • need a network reset; or
  • need a proofs upgrade (with new RegisteredProof for modified Window PoSt).

This decision must be made at the project level, and we can support either path. If the proofs upgrade is selected, a new issue should be created; and both that new issue and the current should be addressed in the PR realizing this work.

Note that because Winning PoSt uses only a single partition, this change should not affect Winning PoSt challenge generation. Therefore, we don't technically need a new RegisteredProof. We should at least verify that this is true if we opt for a proofs upgrade.

In that case, we must either actually upgrade Winning PoSt also (which may be simplest) — or else explicitly verify that old Winning PoSt proofs still pass (and that challenge generation is unaffected).

Where to begin

  • vanilla proof:
    .map(|n| {
    let challenge_index = ((j * num_sectors_per_chunk + i)
    * pub_params.challenge_count
    + n) as u64;
    let challenged_leaf_start = generate_leaf_challenge(
    pub_params,
    pub_inputs.randomness,
    sector_id.into(),
    challenge_index,
    )?;
  • circuit input generation:
    let challenge_index = ((partition_index * pub_params.sector_count + i)
    * pub_params.challenge_count
    + n) as u64;
    let challenged_leaf_start = fallback::generate_leaf_challenge(
    &pub_params,
    pub_inputs.randomness,
    sector.id.into(),
    challenge_index,
    )?;
@porcuquine
Copy link
Collaborator Author

@porcuquine porcuquine changed the title Window PoSt challenge generation Window PoSt challenge generation should not depend on sector order Sep 1, 2020
@porcuquine
Copy link
Collaborator Author

@cryptonemo I think this is the one we considered as a good candidate for a proofs-upgrade test. Will obviously have to think about branching strategy so we don't introduce a breaking change elsewhere until ready to actually upgrade.

@cryptonemo
Copy link
Collaborator

This was addressed in 2 PRs in different ways that didn't land:

#1284
#1286

Re-open if this remains an issue.

@shawnrader shawnrader self-assigned this Sep 26, 2022
cryptonemo added a commit that referenced this issue Feb 24, 2023
cryptonemo added a commit that referenced this issue Mar 1, 2023
cryptonemo added a commit that referenced this issue Mar 6, 2023
cryptonemo added a commit that referenced this issue Mar 7, 2023
cryptonemo added a commit that referenced this issue Mar 8, 2023
* feat: minimal changes to fix the open 'grindability issue'

Some more details here:
#1270

* feat: simplify some tests in filecoin-proofs
* fix: apply review feedback and re-factor
* feat(storage-proofs-post): add grindability tests (#1663)
* fix: apply review feedback and refactor
* style: clippy update
* fix: apply review feedback

---------

Co-authored-by: DrPeterVanNostrand <jnz@riseup.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants