fix(core): validate StorageProof structure in CheckTx#316
Open
raymondjacobson wants to merge 1 commit into
Open
fix(core): validate StorageProof structure in CheckTx#316raymondjacobson wants to merge 1 commit into
raymondjacobson wants to merge 1 commit into
Conversation
CheckTx previously only verified that a transaction was valid protobuf, accepting any structurally malformed tx into the mempool. Add a checkTxStructural step that rejects transactions with obviously invalid fields before they enter the mempool and get gossiped to peers. For StorageProof txs, reject if ProverAddresses is empty, Address is missing, or Height is zero. These are cheap checks that don't need block context or DB lookups. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
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.
Summary
`CheckTx` previously accepted any transaction that parsed as valid protobuf — no per-type validation. This meant a malformed `StorageProof` (e.g. with empty `ProverAddresses`) could enter the mempool and get gossiped across the network, even though it would later be rejected at `ProcessProposal` (#315).
This PR adds a `checkTxStructural` step to `CheckTx` that performs lightweight, context-free validation before a transaction enters the mempool. For `StorageProof` txs it checks:
These checks are purely structural — no DB lookups, no block height needed — so they add negligible latency to `CheckTx`.
The `checkTxStructural` method uses a type switch and is easy to extend with structural checks for other tx types in the future.
Defense in depth (full picture after #313, #315, this PR)
Test plan
🤖 Generated with Claude Code