ergo-nipopow: validate the initial proof before selection - #914
Merged
kushti merged 1 commit intoAug 3, 2026
Merged
Conversation
kushti
approved these changes
Aug 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Merge dependency
This PR is ready for code review, but it must not merge before #852 and #866.
The current structural predicate rejects real JVM-node proofs until #852 fixes
prefix lookback semantics and #866 fixes canonical interlink-key encoding.
Neither prerequisite's diff is included here.
A manual replay of a mainnet proof ending at block 1,784,124 confirmed the
boundary: the proof is rejected by the candidate on standalone
developandselected when the same candidate is stacked on the exact #852 and #866 heads.
The current #852 head also needs formatting cleanup, and the current #866 head
trips the crate's
clippy::expect_useddenial.Summary
structural validity predicate before it can become
best_prooflength and canonical first-occurrence key position before validation calls
the unchecked packer
process()API unchangedproofs and encoding bounds, genesis anchoring, valid admission, and recovery
Why
NipopowVerifier::processpreviously stored the first genesis-anchored proofwithout calling the predicate used during later proof comparisons. A
structurally invalid first proof could therefore become observable through
best_proof()andbest_chain().This PR applies the existing predicate to that initial state transition. It
also makes interlink validation reject an empty-vector/proof mismatch, a run
longer than 255 entries, or a run beginning after position 255 before reaching
pack_interlinks.Invalid proofs continue to be ignored with
Ok(()), leaving the verifier emptyso that a later valid proof can be accepted.
Validation
Candidate on the #863 dependency-repair head:
ergo-chain-generationlibrary tests: 28/28cargo fmt --all -- --checkcargo clippy -p ergo-nipopow -p ergo-chain-generation --all-targets -- -D warningsCandidate stacked on #852, #866, #863, and #903:
ergo-chain-generationlibrary tests: 28/28ergo-nipopowlibrary tests: 2/2and initial proof selected
The RED phases separately demonstrated the initial-selection bypass, three
unchecked-packer panics, and acceptance of a sparse run beginning at position
256. All focused cases pass with the complete change.
Fresh
developcurrently cannot resolve the yankedcore2dependency, soCargo validation used #863. The isolated JSON target additionally used #903.
Those build repairs are not included in this PR.
Scope
This PR does not add proof-of-work,
m/k, or continuous-mode difficultyvalidation, and it does not claim complete JVM parity, deployed exploitation,
or established funds impact.