Repository navigation
fix(rpc): bound asynchronous transaction broadcasts - #1478
Conversation
Limit unfinished async broadcasts per node with fail-fast admission and reuse the existing too-many-requests response. Tie accepted work to node shutdown while preserving request independence and configured timeouts. Add regression coverage for limits, cancellation, slot release, races, HTTP batches, and local-only node lifecycle. <sub>🤖 Co-authored by [Claudius the Magnificent](https://github.com/lklimek/claudius) AI Agent</sub> Co-Authored-By: Claude gpt-6-astra <[email protected]>
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository: dashpay/tenderdash/.coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
|
PR HygieneState: waiting-bots · commit
Self-review is an author attestation that you have read the diff: This check passes when the policy is satisfied; the repository decides whether merging requires it. |
|
@thepastaclaw review No review for |
thepastaclaw
left a comment
There was a problem hiding this comment.
Final validation — Phase 2 only (queue backlog)
The reported admission-capacity race is not present. BroadcastTx invokes Mempool.CheckTx synchronously and only consumes the callback result after that call returns; therefore the deferred release and shutdown idle signal occur after the complete CheckTx invocation, including post-callback mempool work.
Review provenance
Source: reviewer 1: gpt-6-astra (agent: phase2-reviewer, role: general); reviewer 2: gpt-6-astra (agent: phase2-reviewer, role: tenderdash-consensus-security); final verifier: gpt-6-astra (agent: astra-verifier, role: final-verifier)
- Triage:
normalbygpt-6-astra(effort low) — The change adds nontrivial RPC admission control with concurrency, cancellation, timeout, and node-lifecycle interactions across several files, but does not change consensus, funds handling, cryptography, peer-facing deserialization, or storage migrations. - Phase 1 reviewers: not run (skipped for throughput: 21 PRs queued, above the 10 limit)
- Fresh verifier:
gpt-6-astra— final-verifier; agentastra-verifier - Phase 2 reviewers:
gpt-6-astra— general (completed, effort high); agentphase2-reviewer,gpt-6-astra— tenderdash-consensus-security (completed, effort high); agentphase2-reviewer
Out-of-scope follow-up suggestions (1)
These are valid observations, but they are outside this PR's scope and should be handled in separate issues or author/maintainer-requested PRs rather than blocking this review.
- Bound socket ABCI requests retained after caller timeout — The socket client adds sent requests to reqSent but removes them only when a response arrives. A positive broadcast timeout can therefore release the RPC admission slot while the socket request remains retained if the application consumes the request without responding, allowing repeated submissions to accumulate transport state. This behavior predates this PR and is explicitly outside its admission-control scope.
- Follow-up: Track separately in a follow-up issue or PR with bounded outstanding socket requests while preserving FIFO response matching.
Replace the active counter and idle channel with the existing x/sync weighted semaphore. Cancel admission before acquiring all slots to drain accepted calls, then release the slots for repeated shutdown callers. Cover concurrent shutdown, timeout retries, and idle shutdown with an already-canceled context. Co-Authored-By: Codex <[email protected]> <sub>🤖 Co-authored by [Claudius the Magnificent](https://github.com/lklimek/claudius) AI Agent</sub>
thepastaclaw
left a comment
There was a problem hiding this comment.
⚠️ DEGRADED — Re-review — Final validation — Phase 1 + Phase 2
⚠️ DEGRADED review. The primary review models were unavailable (gpt-6-astraunavailable: All credentials for model gpt-6-astra are cooling down (last error: usage_limit_reached: The usage limit has been reache), so this review ran on stand-in models:gpt-5.6-luna→muse-spark-1.3-contributor,gpt-5.6-sol→muse-spark-1.3-contributor,gpt-5.6-terra→muse-spark-1.3-contributor,gpt-6-astra→muse-spark-1.3-contributor. Both review phases and the independent verifiers still ran, but on weaker models, with Phase 1 capped athigheffort. Treat the verdict as provisional; a full-strength re-review will run on the next push once the primary models are back.
This change correctly bounds async broadcasts, but StopAsyncBroadcasts never resets admission state, so a node Start retried after a failed OnStart can never succeed. The bound, cancellation, and shutdown-drain logic otherwise check out.
🔴 1 blocking
Review provenance
Source: reviewer 1: glm-5.3-flash (agent: phase1-reviewer, role: general); reviewer 2: glm-5.3-flash (agent: phase1-reviewer, role: tenderdash-consensus-security); reviewer 3: muse-spark-1.3-contributor (standing in for gpt-6-astra) (agent: phase2-reviewer, role: general); reviewer 4: muse-spark-1.3-contributor (standing in for gpt-6-astra) (agent: phase2-reviewer, role: tenderdash-consensus-security); reviewer 5: muse-spark-1.3-contributor (standing in for gpt-6-astra) (agent: phase2-reviewer, role: general); reviewer 6: muse-spark-1.3-contributor (standing in for gpt-6-astra) (agent: phase2-reviewer, role: tenderdash-consensus-security); final verifier: muse-spark-1.3-contributor (standing in for gpt-6-astra) (agent: astra-verifier, role: final-verifier)
- Degraded mode:
gpt-6-astraunavailable: All credentials for model gpt-6-astra are cooling down (last error: usage_limit_reached: The usage limit has been reache (detected by probe, since 2026-09-20T20:45:34Z); stand-insgpt-5.6-luna→muse-spark-1.3-contributor,gpt-5.6-sol→muse-spark-1.3-contributor,gpt-5.6-terra→muse-spark-1.3-contributor,gpt-6-astra→muse-spark-1.3-contributor; Phase 1 effort capped athigh - Triage:
normalbymuse-spark-1.3-contributor(standing in forgpt-6-astra) (effort low) — Adds bounded admission control for async broadcasts across config, node, and RPC with new concurrency logic, but does not change consensus, funds, crypto, peer deserialization, or migrations. - Phase 1 reviewers:
glm-5.3-flash— general (completed, effort high); agentphase1-reviewer,glm-5.3-flash— tenderdash-consensus-security (completed, effort high); agentphase1-reviewer - Phase 1 model:
glm-5.3-flash— zai quota: 5h 98% left, weekly 99% left; passed overgemini-3.8-flash-high(lane failed) - Fresh final gate: an independent Phase-2 review ran after iterative findings were reconciled
- Fresh verifier:
muse-spark-1.3-contributor(standing in forgpt-6-astra) — final-verifier; agentastra-verifier - Phase 2 reviewers:
muse-spark-1.3-contributor(standing in forgpt-6-astra) — general (completed, effort high); agentphase2-reviewer,muse-spark-1.3-contributor(standing in forgpt-6-astra) — tenderdash-consensus-security (completed, effort high); agentphase2-reviewer,muse-spark-1.3-contributor(standing in forgpt-6-astra) — general (completed, effort high); agentphase2-reviewer,muse-spark-1.3-contributor(standing in forgpt-6-astra) — tenderdash-consensus-security (completed, effort high); agentphase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.
In `internal/rpc/core/async_broadcast.go`:
- [BLOCKING] internal/rpc/core/async_broadcast.go:22-63: StopAsyncBroadcasts never resets state, blocking node Start retry
StopAsyncBroadcasts cancels the admission context and drains the semaphore but leaves the started state set, while StartAsyncBroadcasts refuses to run whenever that state is set. The BaseService contract (libs/service/service.go) explicitly allows calling Start again after OnStart fails, and node OnStart has exactly that path: if the RPC listener fails to start after admission started, it stops admission and returns the error, so a retry (e.g. after a transient listen-address conflict) fails with a misleading "async broadcasts already started" instead of starting cleanly. The fix must reset the started marker only after the full drain succeeds (jobs are still outstanding when drain fails, so Start must keep refusing), and it must keep the canceled admission context so post-stop calls still fail with context.Canceled as the existing shutdown and node-lifecycle tests require — hence Start should key "already started" off a.cancel, not a.ctx.
Out-of-scope follow-up suggestions (1)
These are valid observations, but they are outside this PR's scope and should be handled in separate issues or author/maintainer-requested PRs rather than blocking this review.
- Positive timeout-broadcast-tx weakens the async bound at the ABCI transport layer — With the default zero timeout each admitted slot is held until CheckTx returns, so the semaphore strictly bounds outstanding work. With a positive rpc.timeout-broadcast-tx the slot is released on caller timeout while an already-sent socket ABCI CheckTx request may still be processed app-side (disclosed in the PR description). This is outside this change's scope and requires non-default operator config.
- Follow-up: File a separate issue to propagate cancellation into the socket ABCI client on caller timeout or document that a positive timeout-broadcast-tx trades strictness of the bound for responsiveness.
TL;DR: Nodes now cap unfinished asynchronous transaction submissions and reject excess requests immediately instead of accumulating work without limit.
User story
As a node operator, I want asynchronous transaction submissions to consume bounded resources, to achieve predictable node availability under heavy or hostile RPC traffic.
Scenario
Base flow
Clients submit transactions through
broadcast_tx_asyncwhile application validation is slow or blocked.Actual behavior
Every request starts detached work, so unfinished
CheckTxcalls and goroutines can grow without bound.Expected behavior
The node accepts at most the configured number of unfinished asynchronous broadcasts and returns JSON-RPC
-32004immediately when capacity is full.Detailed discussion
Issue being fixed or feature implemented
broadcast_tx_asyncused a background context and created one goroutine per request without admission control. Connection and batch limits did not bound work retained after the RPC response.What was done?
rpc.max-concurrent-broadcast-tx-async, with a default of 100; zero selects that finite default and negative values are invalid.Too many requestsresponse when saturated.CheckTxactually returns and copied transaction bytes before returning to local callers.Transport-level retention of already-sent socket ABCI requests after a positive caller timeout remains outside this change. The default zero timeout used by Tenderdash and Dashmate keeps each admitted request counted until it finishes.
How Has This Been Tested?
Regression tests first reproduced admission beyond the default limit and acceptance of an already-canceled request. Focused tests then covered default and custom limits, concurrent and batched callers, cancellation, slot release, timeout behavior, shutdown races, HTTP error mapping, configuration rendering, and node lifecycle without a listener.
The focused golangci-lint v2.13.2 run reported zero issues, and
git diff --checkpassed.Breaking Changes
None. Successful responses and timeout semantics remain unchanged. Saturated callers can now receive the existing
Too many requestserror.Checklist
For repository code-owners and collaborators only
🤖 Co-authored by Claudius the Magnificent AI Agent