Add support for inline extension nodes in TrieProof#6351
Add support for inline extension nodes in TrieProof#6351ernestognw merged 31 commits intoOpenZeppelin:masterfrom
Conversation
|
The latest updates on your security scan. Learn more about OpenZeppelin Platform.
|
|
WalkthroughThis pull request refactors the core trie traversal logic in the TrieProof contract by converting the branching conditional flow into a perpetual for-loop structure. The rewrite enables iterative descent through trie nodes with early exits. Key changes include replacing per-iteration RLP processing branches with a single loop that repeatedly decodes the current node, handling branch nodes via Memory.Slice child slices and _getNodeId calls, and updating leaf/extension node logic with explicit path remainder validation. Error handling is refined with updated error messages (UNPARSEABLE_NODE replacing UNKNOWN_NODE_PREFIX, and new conditions for INVALID_PATH_REMAINDER and EMPTY_EXTENSION_PATH_REMAINDER). A new private helper function _isExtensionChild is introduced to support traversal decisions. The final leaf validation is preserved through existing _validateLastItem logic. Possibly related PRs
🚥 Pre-merge checks | ✅ 2 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches🧪 Generate unit tests (beta)
⚔️ Resolve merge conflicts (beta)
Tip Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@contracts/utils/cryptography/TrieProof.sol`:
- Around line 145-148: The code calls _isExtensionChild(childSlice, proof[i +
1], proofLength, i) and accesses proof[i+1] without ensuring i+1 < proofLength,
which can revert for the final index; add an explicit bounds guard (e.g. if (i +
1 >= proofLength) break;) before any proof[i + 1] indexing or change
_isExtensionChild to accept an optional/conditional next-slice (move the proof
indexing into _isExtensionChild and first check i + 1 < proofLength there).
Apply the same fix to the other occurrence around the encoded/childSlice
handling (the block that currently uses proof[i + 1] at ~180-183) so both call
sites never index out of bounds.
50d8ad8 to
78d3896
Compare
|
The previous implementation using Calling I'm using |
|
I pushed ernestognw@ab19efc that github is not seeing :/ |
…/ernestognw/openzeppelin-contracts into trieproof/inline-extension-nodes
Fixes #????
PR Checklist
npx changeset add)