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

[Merged by Bors] - AtxBuilder verification of initial PoST #6031

Closed
wants to merge 18 commits into from

Conversation

acud
Copy link
Contributor

@acud acud commented Jun 11, 2024

Motivation

In #5921, an edge case is described where a node may start with a certain amount of SUs, generate an initial PoST but for possible reasons, the number of SUs may change before the first ATX is broadcasted. This means that the initial PoST is no longer valid and needs to be regenerated (costing the miner another epoch before being able to submit the initial ATX).

Description

This PR fixes the issue by adding an extra check that verifies that the rust process has the same parameters (SUs among them) by executing a proof validation for the existing cached proof with the parameters that are used by the rust process (therefore, if the rust service is restarted with different parameters, this will be caught by this changeset).

Closes #5921

Test Plan

Unit test coverage in activation_test.go and nipost_test.go

TODO

  • missing test in nipost_test.go
  • fix broken tests

@acud acud self-assigned this Jun 11, 2024
Copy link
Member

@fasmat fasmat left a comment

Choose a reason for hiding this comment

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

Overall looks good to me so far. 🙂

I would just also drop the publishEpoch parameter for BuildNiPost (since it is part of the challenge anyway) and maybe add a test to nipost_test.go that checks that a new initial post is generated when the existing initial post fails validation.

Right now the CI fails because the packages activation/e2e, node and systest need to be updated to the new interface of the nipostBuilder. In all cases it should just be passing a (already existing instance of the post verifier) to the NewNIPostBuilder function.

activation/activation_test.go Outdated Show resolved Hide resolved
activation/activation_test.go Outdated Show resolved Hide resolved
activation/activation_test.go Outdated Show resolved Hide resolved
activation/activation_test.go Outdated Show resolved Hide resolved
activation/nipost_test.go Outdated Show resolved Hide resolved
@@ -53,9 +53,10 @@ type nipostBuilder interface {
ctx context.Context,
sig *signing.EdSigner,
publish types.EpochID,
challenge types.Hash32,
challengeHash types.Hash32,
postChallenge *types.NIPostChallenge,
Copy link
Contributor

Choose a reason for hiding this comment

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

NIT: technically its a poet challenge. The hash of it is sent to the poet service. It collects the data that needs to be proven that was selected and known before registering to the poet.

The challenge for PoST is the hash of the poet proof.

Suggested change
postChallenge *types.NIPostChallenge,
nipostChallenge *types.NIPostChallenge,

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure if I fully understand, if it is a poet challenge then why are you suggesting to rename it to nipostChallenge? and is there a semantic difference between a postChallenge and a nipostChallenge?

Copy link
Contributor

Choose a reason for hiding this comment

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

The hash of the nipost challenge is the one submitted to the poet (that's why I said "poet challenge", a "challenge for the poet").

is there a semantic difference between a postChallenge and a nipostChallenge?

The naming is confusing, we have too many "challenges". The simplified flow is:

  1. build nipost challenge
  2. submit hash of nipost challenge to the poet
  3. wait 2w, obtain the poet proof
  4. use the root of the poet proof as the challenge to generate the PoST ("post challenge"):
    proof, postInfo, err := nb.Proof(postCtx, signer.NodeID(), poetProofRef[:])

activation/activation.go Outdated Show resolved Hide resolved
@acud acud force-pushed the atx-initial-post-check branch from 8d60b7b to f11e652 Compare June 12, 2024 13:34
Copy link

codecov bot commented Jun 12, 2024

Codecov Report

Attention: Patch coverage is 73.46939% with 13 lines in your changes missing coverage. Please review.

Project coverage is 81.3%. Comparing base (d4597f0) to head (6b80265).
Report is 1 commits behind head on develop.

Files Patch % Lines
activation/activation.go 63.6% 4 Missing and 4 partials ⚠️
activation/nipost.go 80.7% 3 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##           develop   #6031     +/-   ##
=========================================
- Coverage     81.3%   81.3%   -0.1%     
=========================================
  Files          296     296             
  Lines        31635   31667     +32     
=========================================
+ Hits         25741   25766     +25     
+ Misses        4213    4212      -1     
- Partials      1681    1689      +8     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@acud acud force-pushed the atx-initial-post-check branch from db361d1 to 35fb662 Compare June 12, 2024 19:56
@acud
Copy link
Contributor Author

acud commented Jun 12, 2024

bors try

@spacemesh-bors
Copy link

🔒 Permission denied

Existing reviewers: click here to make acud a reviewer

@acud
Copy link
Contributor Author

acud commented Jun 12, 2024

bors try

@spacemesh-bors
Copy link

🔒 Permission denied

Existing reviewers: click here to make acud a reviewer

@acud acud marked this pull request as ready for review June 13, 2024 00:49
@acud acud requested review from dshulyak and ivan4th as code owners June 13, 2024 00:49
@acud
Copy link
Contributor Author

acud commented Jun 13, 2024

So marked this as ready for review. I think it's good for a review now.
The CI is green apart from the codecov complaint. Not sure if it's a blocker but I'll find out soon enough :)

@acud acud force-pushed the atx-initial-post-check branch from a1c2990 to 4966611 Compare June 13, 2024 00:51
@poszu
Copy link
Contributor

poszu commented Jun 13, 2024

bors try

spacemesh-bors bot added a commit that referenced this pull request Jun 13, 2024
activation/activation_multi_test.go Show resolved Hide resolved
activation/e2e/activation_test.go Outdated Show resolved Hide resolved
activation/nipost.go Outdated Show resolved Hide resolved
@spacemesh-bors
Copy link

try

Build succeeded:

@fasmat
Copy link
Member

fasmat commented Jun 13, 2024

We should also add this fix to the CHANGELOG 🙂

@acud
Copy link
Contributor Author

acud commented Jun 13, 2024

bors try

spacemesh-bors bot added a commit that referenced this pull request Jun 13, 2024
@spacemesh-bors
Copy link

try

Build failed:

@acud
Copy link
Contributor Author

acud commented Jun 13, 2024

bors try

spacemesh-bors bot added a commit that referenced this pull request Jun 13, 2024
@spacemesh-bors
Copy link

try

Build succeeded:

@acud acud force-pushed the atx-initial-post-check branch from 435b11c to 6b80265 Compare June 13, 2024 22:36
@acud
Copy link
Contributor Author

acud commented Jun 13, 2024

bors try

spacemesh-bors bot added a commit that referenced this pull request Jun 13, 2024
@fasmat
Copy link
Member

fasmat commented Jun 13, 2024

bors cancel

@fasmat
Copy link
Member

fasmat commented Jun 13, 2024

bors merge

spacemesh-bors bot pushed a commit that referenced this pull request Jun 13, 2024
## Motivation
In #5921, an edge case is described where a node may start with a certain amount of SUs, generate an initial PoST but for possible reasons, the number of SUs may change before the first ATX is broadcasted. This means that the initial PoST is no longer valid and needs to be regenerated (costing the miner another epoch before being able to submit the initial ATX).
@spacemesh-bors
Copy link

Build failed:

@spacemesh-bors
Copy link

try

Build failed:

@acud
Copy link
Contributor Author

acud commented Jun 13, 2024

bors merge

spacemesh-bors bot pushed a commit that referenced this pull request Jun 13, 2024
## Motivation
In #5921, an edge case is described where a node may start with a certain amount of SUs, generate an initial PoST but for possible reasons, the number of SUs may change before the first ATX is broadcasted. This means that the initial PoST is no longer valid and needs to be regenerated (costing the miner another epoch before being able to submit the initial ATX).
@spacemesh-bors
Copy link

Pull request successfully merged into develop.

Build succeeded:

@spacemesh-bors spacemesh-bors bot changed the title AtxBuilder verification of initial PoST [Merged by Bors] - AtxBuilder verification of initial PoST Jun 14, 2024
@spacemesh-bors spacemesh-bors bot closed this Jun 14, 2024
@spacemesh-bors spacemesh-bors bot deleted the atx-initial-post-check branch June 14, 2024 00:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

AtxBuilder should validate initial PoST loaded from DB
3 participants