fix(blockassembly): validate batch txid lengths#919
Merged
gokutheengineer merged 3 commits intoJun 4, 2026
Merged
Conversation
Validate AddTxBatch txids before constructing hashes so malformed direct gRPC requests return clean indexed errors instead of panicking.
Contributor
Benchmark Comparison ReportBaseline: Current: Summary
All benchmark results (sec/op)
Threshold: >10% with p < 0.05 | Generated: 2026-05-22 13:21 UTC |
Contributor
|
🤖 Claude Code Review Status: Complete Current Review: Found one consistency issue:
Positives:
|
freemans13
approved these changes
May 22, 2026
|
icellan
approved these changes
May 26, 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.



Summary
AddTxBatchrequest txid is exactly 32 bytes before converting it tochainhash.Hash.AddTxBatch.Problem
BlockAssembly.AddTxBatchconstructedsubtreepkg.Nodevalues usingchainhash.Hash(req.Txid)without first checking thatreq.Txidwas exactly 32 bytes.AddTxand the columnar client path already perform this validation, so direct gRPC callers using the row-oriented batch endpoint could send malformed txids and trigger a panic instead of receiving a normal request error.Fix
AddTxBatchnow validateslen(req.Txid) == 32inside the batch loop before constructing the node. The returned error includes the failing request index and observed length, for example:Test Plan
go test ./services/blockassembly -run 'TestAddTxBatch'The regression test verifies malformed short and long txids do not panic, return an error, and include both
invalid txid lengthand the failing index in the error message.