refactor(rpc): type the MMR proof leaf as a fixed 32-byte array - #237
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests.
... and 1 file with indirect coverage changes 🚀 New features to boost your workflow:
|
|
Commit: 8fd2a73
|
The proof builder already required exactly 32 bytes and rejected anything else with InvalidLeafLength, but the wire type was Vec<u8>. A wrong-sized leaf was therefore only caught after the handler had resolved the block commitment through a bitcoind height lookup. Typing the parameter as [u8; 32] moves the check into parameter deserialization and makes the signature state the invariant the builder already enforces, which lets the error variant go away. Well-formed requests are unaffected: both types encode as an array of 32 numbers.
prajwolrg
force-pushed
the
fix/mmr-proof-leaf-fixed-size
branch
from
August 18, 2026 02:25
20de155 to
2e19251
Compare
prajwolrg
marked this pull request as ready for review
August 18, 2026 02:38
🔒 AI Security Review (claude-opus-5)✅ No security issues found. |
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.
Description
getExportEntryMMRProoftook itsleafparameter asVec<u8>, but the only thing the endpoint can do with a leaf is look it up as a 32-byte entry hash.build_export_entry_mmr_proofdid the length check itself and returnedInvalidLeafLengthfor anything else, so the wire type was looser than the code behind it. The practical effect was that a wrong-sized leaf still cost aget_block_heightround trip to bitcoind before being rejected.Typing the parameter as
[u8; 32]pushes the check into jsonrpsee's parameter deserialization, ahead of the handler. The signature now says what the builder already enforced, and the error variant is no longer reachable, so it is gone along with the test that covered it.Type of Change
Notes to Reviewers
The JSON wire format does not change.
Vec<u8>and[u8; 32]both serialize as an array of 32 numbers, so any well-formed request that worked before still works. What changes for a malformed request is where it fails: a jsonrpsee parameter parse error instead of an application error from the handler.The generated client signature does change for anyone building this crate with the
clientfeature, since the parameter type is part of it. Nothing in this repo calls it.Checklist
The removed test asserted the error the type system now makes unrepresentable, so there is nothing left to test at that layer. The remaining
build_export_entry_mmr_prooftests pass unchanged.