feat: bound Merkle proof depth at verification - #722
Merged
thlpkee20-wq merged 2 commits intoJul 30, 2026
Conversation
|
@Bojest001 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
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.
This change adds a hard upper bound for snapshot proof length to prevent excessively deep Merkle proofs from exceeding contract memory and gas limits during verification.
What changed
Introduced a contract-level proof-depth cap via MAX_PROOF_DEPTH = 32
Added a new structured error, ProofTooDeep, for over-limit proofs
Emits a proof_reject_depth event when a proof exceeds the allowed depth
Added regression tests covering:
proofs at the exact limit being accepted
proofs one level above the limit being rejected
Why
Very deep proofs can become expensive and risky in Soroban due to memory and execution constraints. Rejecting them early keeps verification bounded and predictable while preserving a clear, structured failure mode for off-chain callers.
Notes
The bound is documented in the Merkle helper developer notes.
The change is intentionally lightweight and easy to review.
closes #571