Repository navigation
Reject upgrades of length 0 - #930
Merged
Merged
Conversation
[Low impact] The change affects only proof upgrades with an empty range. The PR appears safe to merge, with a non-blocking rejection gap for nonempty receivers.
|
| } | ||
|
|
||
| function verifyUpgrade({ fork, upgrade }, blockRoot, batch) { | ||
| if (upgrade.length === 0) throw INVALID_OPERATION('Invalid upgrade') |
There was a problem hiding this comment.
applyProof can still accept a zero-length upgrade when the receiver already has data. With a receiver at length 1, the exact proof in the new test reaches MerkleTree.refit first. Refit removes the empty upgrade, so verification skips this check and returns true. Check the original upgrade length before refitting, and add a test with a nonempty receiver.
Knowledge Base Used:
Prompt To Fix With AI
This is a comment left during a code review.
Path: lib/merkle-tree.js
Line: 1070
Comment:
**Zero-length proofs still pass**
`applyProof` can still accept a zero-length upgrade when the receiver already has data. With a receiver at length 1, the exact proof in the new test reaches `MerkleTree.refit` first. Refit removes the empty upgrade, so verification skips this check and returns `true`. Check the original upgrade length before refitting, and add a test with a nonempty receiver.
**Knowledge Base Used:**
- [Data integrity and Merkle verification](https://app.greptile.com/-/switch-tenant?tenant=tetherio&next=%2Fcustom-context%2Fknowledge-base%2Fholepunchto%2Fhypercore%2F-%2Fdocs%2Fdata-integrity.md)
- [Merkle tree operations](https://app.greptile.com/-/switch-tenant?tenant=tetherio&next=%2Fcustom-context%2Fknowledge-base%2Fholepunchto%2Fhypercore%2F-%2Fdocs%2Fmerkle-tree-operations.md)
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.
mafintosh
approved these changes
Nov 4, 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.
Co-authored with AI