blockassembly: make GetTransactionHashes context-aware and prevent hanging GetBlockAssemblyTxs#939
Conversation
|
🤖 Claude Code Review Status: Complete Current Review: This PR correctly implements context-aware cancellation for Findings:
Verified:
|
Benchmark Comparison ReportBaseline: Current: Summary
All benchmark results (sec/op)
Threshold: >10% with p < 0.05 | Generated: 2026-06-04 12:39 UTC |
freemans13
left a comment
There was a problem hiding this comment.
Approve. Clean, minimal fix that closes a real availability hazard on the GetBlockAssemblyTxs diagnostic path.
- Correctness solid: size-1 buffered response channel absorbs the main loop's unconditional send (
SubtreeProcessor.go:766) even after the caller returns onctx.Done()— no goroutine leak. Both select arms (request send + response receive) are ctx-guarded. - nil vs empty is safe: the loop always builds the slice with
make(..., 0, ...), so thetxHashes == nil && ctx.Err() != nilguard can't misfire on a legitimately empty result. - Consistent with the established
GetSubtreeHashespattern in the same file. - Good, deterministic regression tests, including the post-cancellation processor-send case.
Minor (non-blocking) suggestion: add a one-line comment to TestGetBlockAssemblyTxsReturnsWhenContextCancelled noting it relies on the processor not being started (so the timeout always wins) — protects it from a future edit adding Start() and racing.
Recommend confirming CI is green before merge (I didn't run the local Go suite).
|



Summary
This change fixes a hanging-path in block assembly diagnostics by making subtree transaction-hash retrieval context-aware.
subtreeprocessor.GetTransactionHashesto acceptcontext.Context, use a buffered response channel, and return early on cancellation/timeouts.GetBlockAssemblyTxsto pass the RPC context into subtree processor calls and propagate cancellation as a gRPC error.GetBlockAssemblyTxsreturns on context timeout instead of hangingWhy
GetBlockAssemblyTxscould block indefinitely when the subtree processor loop was busy/unavailable, even if the RPC context was canceled. This makes the diagnostic endpoint safer under incident conditions and avoids tying up gRPC workers.Test plan
go test ./services/blockassembly/subtreeprocessor -run 'TestGetTransactionHashes'go test ./services/blockassembly -run 'TestGetBlockAssemblyTxs'