Repository navigation
fix(incentive): report a chain read that fails before the send as rejected, not possibly broadcast - #2567
Merged
Conversation
…ected, not possibly broadcast `send_broadcast_unknown` read every transport-class `send()` failure as "the transaction may have broadcast". A wallet provider reads the pending nonce, the gas estimate, the fees and the chain id before it signs and sends, so a timeout or a 5xx on one of those reads told the operator to check for a transaction that was never signed, `pool close --all` counted the pool unconfirmed, and `openPool` / `topUp` held an unconfirmed escrow the settle loop then had to resolve. alloy's `Provider` trait has no `fill`, so the split cannot be a helper over `P: Provider`. `decdn_incentive::tx::SendLegLayer` is a provider layer that sits below the fillers, where the one request it sees is the send; it wraps a failure of that request in `SendLegFailure` and lets a JSON-RPC error response through unchanged. The classifier reads a marked failure with the transport rules (4xx refused, 5xx and the rest unknown), an unmarked `already known` answer as unknown, and everything else as nothing sent. `build_provider`, the node's wallet providers and sponsord's treasury provider carry the layer; the filler-free test fixtures do too. Closes #2431 Co-Authored-By: Claude Fable 5.1 <[email protected]>
There was a problem hiding this comment.
🟢 Approval recommended
The supplied changes and regression coverage support the intended behavior; only an optional documentation typo remains.
No open issues 🎉
What changed in this PR
Fixes #2431 by distinguishing failed transaction preparation reads from failed send requests, avoiding false broadcast warnings while preserving uncertain-send handling.
Changes:
- Adds a send-leg marker and updates transaction-error classification.
- Installs the layer in client, node, and sponsorship providers.
- Adds regression tests and documents provider requirements.
| File | Description |
|---|---|
| docs/sponsord/operator.md | Clarifies when top-ups remain unconfirmed. |
| docs/runbook.md | Clarifies unresolved-open diagnostics. |
| crates/sponsord-core/src/pool/tests.rs | Tests treasury send marking. |
| crates/sponsord-core/src/pool.rs | Layers the treasury provider. |
| crates/node/src/runtime/tests.rs | Tests both wallet providers. |
| crates/node/src/runtime/mod.rs | Layers node wallet providers. |
| crates/node/src/buyer_pool/tests.rs | Updates send-failure fixtures. |
| crates/incentive/src/tx/tests.rs | Tests preparation versus send failures. |
| crates/incentive/src/tx/send_leg/tests.rs | Tests marking, erasure, and error rendering. |
| crates/incentive/src/tx/send_leg.rs | Implements the send-leg marker layer. |
| crates/incentive/src/tx.rs | Updates broadcast uncertainty classification. |
| crates/incentive/src/test_rpc.rs | Layers the scripted test provider. |
| crates/incentive/Cargo.toml | Adds async-trait dependency. |
| crates/client/src/provider/tests.rs | Tests wallet-builder send marking. |
| crates/client/src/provider.rs | Layers the client wallet provider. |
| crates/client/src/funding/adoption_tests.rs | Distinguishes held sends from failed reads. |
| crates/client/src/buyer_pool/tests.rs | Tests preparation failures without escrow holds. |
| crates/client/src/buyer_pool.rs | Documents classification and provider requirements. |
| crates/cli/src/commands/pool/tests.rs | Tests close failures and sweep counts. |
| crates/cli/src/commands/pool.rs | Clarifies send-failure documentation. |
| CHANGELOG.md | Records behavior and SDK requirements. |
| Cargo.lock | Updates dependency records. |
Review effort: Balanced
Code coverage overviewLanguages: Rust Rust / code-coverage/cargo-llvm-cov
View coverage of the 10 most impacted files.
ℹ️ Calculations represent line coverage. Results may change as calculations are updated. Updated |
…onnected send as rejected `SendLegProvider` marks the five send hooks alloy's `FillProvider` forwards, not only `send_transaction_internal`. The marked branch of `send_broadcast_unknown` reads an HTTP 4xx that carries `Retry-After` (a rate limit) and a reqwest request that never connected or could not be built as nothing sent. `SendLegFailure::from_transport_error` decodes a send made on the provider directly. The e2e `ChainFixture::provider_for` carries the layer, as the client senders it feeds require. The read leg is covered for `reclaim` and `reclaim --all`, the node's open slot, and every mocked adoption fixture; the negative tests name the read that failed. Doc comments that said "a transport failure" where only the send request counts now say so. Co-Authored-By: Claude Fable 5.1 <[email protected]>
This was referenced Oct 20, 2026
Open
Merged
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.
Closes #2431
Problem
decdn_incentive::tx::send_broadcast_unknownread every transport-classsend()failure as "the transaction may have broadcast". The production providers run the fillers first (eth_getTransactionCount,eth_estimateGas, the fee reads,eth_chainId), sign, and only then calleth_sendRawTransaction. A timeout or a 5xx on one of those reads returned the sameContractError::TransportErroras a lost send, so nothing was signed but:pool close --all/reclaim --allcounted the poolunconfirmedand told the operator to check for a transaction that does not exist;open_pool/top_upheld anOpenUnconfirmed/TopUpUnconfirmedentry the settle loop then had to resolve against the chain;send_for_receiptreportedMaybeBroadcast(publish statuses, bond, register, appeal, key rotation), and the USDCapprovesaid it may be pending.Common in practice on the dRPC free tier, which fails reads often.
Fix
The issue's sketch (
provider.fill(..)thensend_tx_envelope(..)) does not compile against the bound the call sites have:fillis an inherent method of alloy'sFillProvider, not on theProvidertrait, and every sender is generic overP: Provider(orDynProviderin sponsord-core).So the split is structural instead:
decdn_incentive::tx::SendLegLayeris an alloyProviderLayerthatProviderBuilderplaces below the fillers, where the one request it sees is the send (FillProvider::send_transaction_internalfills, signs, then calls the inner provider's hook with the envelope). It wraps a failure of that request inSendLegFailureand lets a JSON-RPC error response through unchanged, soalready known, nonce rejections, reverts and oversized-batch answers keep their shape.DynProviderforwards the hook, so the marker survives erasure. The wrapper prints as the inner error and itssource()is the inner error's source, so the operator-facing chain (sanitize_err_chain) is unchanged.send_broadcast_unknownis now three-way:already known/known transactionanswer → unknown (fix(incentive): treat an "already known" send rejection as possibly broadcast #2560);decdn_client::provider::build_provider, the node's wallet providers (seller_wallet/buyer_wallet) and sponsord-core'streasury_providercarry the layer. Every filler-free mocked fixture that asserts "a transport-failed send is unconfirmed" carries it too, which is the proof that the classifier is now structural: without it those #2416 / #1577 tests fail (mutation-checked).An SDK host that builds its own provider for the
decdn-clientsenders must add the layer, or every transport failure reads as "nothing sent";build_providerand theopen_pool/top_updocs say so, and the CHANGELOG entry names it.Review pass (second commit)
SendLegProvidermarks all five send hooksFillProviderforwards (send_transaction_internal,send_transaction_sync_internal,send_raw_transaction,send_raw_transaction_sync,send_raw_transaction_conditional), with a test per entry point.Retry-After(a 429 on the free dRPC tier) and a reqwest request that never connected or could not be built as nothing sent; a 503 withRetry-Afterstays unknown. Both were "may have broadcast" before.SendLegFailure::from_transport_errorfor a send made on the provider directly; the builder guards use it.ChainFixture::provider_forcarries the layer (it feeds the realopen_pool/ensure_allowancepath inClientFixtureand the sponsord anvil tests).reclaim/reclaim --all, the node's open slot (a_read_failed_open_holds_no_slot: noOpenHeld,open_unresolvedstays 0, no row, the next miss sends again), and every mocked adoption fixture; the negative tests assert the read that failed (eth_estimateGas).publishstatuses, keeper,source.rs,OpenUnconfirmed/TopUpUnconfirmed) says so; the node comment no longer claims the seller leg reads the marker.Design trade-off, stated plainly: a provider built without the layer now reads a lost send as "nothing sent" (before this PR it read as "may have broadcast"). Every in-repo builder carries the layer and has a guard test, and the SDK docs say so, but nothing at the type level enforces it. The inverted design (mark the reads at the RPC-client level so a bare provider stays fail-safe) would wrap every read error in the node's watchers and classifiers, which is why it was not taken. A marker-trait bound on the
decdn-clientsenders is a possible follow-up.Tests
tx/send_leg/tests.rs: a failed send request is marked and prints unchanged (Display,sanitize_error_sources,sanitize_err_chain); a JSON-RPC rejection passes through unmarked andis_nonce_collisionstill reads it; an erased provider still marks; only a marked custom transport error is aSendLegFailure.tx/tests.rs: classifier matrix (marked 5xx / reset /NullResp→ unknown; marked 4xx / local → not; the same errors unmarked → not);send_for_receiptthrough a nonce filler and a wallet on an empty mock: a call with no nonce fails the nonce read →Rejected, no "double-submit"; a fully specified call reacheseth_sendRawTransaction→MaybeBroadcastwith the warning.buyer_pool/tests.rs:open_pool,top_up,ensure_allowanceon a gas-filler provider whose reads fail → noOpenUnconfirmed/TopUpUnconfirmed, entry released,approvenot "may be pending", open stillPoolOpenFailureReason::RpcError.pool/tests.rs:close_and_forgeton a filler provider whose reads fail → noTxUnconfirmed;close --allcounts both poolsfailed, none "may have broadcast".adoption_tests.rs: the fix: Ctrl-C during an openPool receipt wait loses the tx hash and re-opens on re-run #2418 run-handle test now fails the send itself (filler-free, marked) and still holds the open; a sibling with fillers fails the gas estimate and holds nothing;a_full_closing_pool_is_replacedholds nothing (its mock leaves the open's reads unanswered).build_provider, both node wallet providers andtreasury_providermark a send request that fails against a closed port (a fully specified request, so the first request on the wire is the send).Mutation checks
true→ the 9 fill-leg tests intx,buyer_pool,poolfail..layer(SendLegLayer)removed frombuild_provider→wallet_builder_marks_a_failed_send_requestfails.mocked_pool(alone) → the three fix: pool send errors do not warn that a transport failure may have broadcast #2416 transport tests fail.Gate (local)
cargo nextest run --no-fail-fast -p decdn-incentive -p decdn-client -p decdn-cli -p sponsord-core— 2357 passedcargo nextest run -p decdn-node buyer_pool runtime payment_settlement onchain_tx— 334 passedcargo nextest run -p decdn-client --features public-api-test public_api— snapshot unchangedcargo fmt -- --check,cargo clippy --workspace --all-targets --all-features -- -D warnings,CARGO_BUILD_WARNINGS=deny cargo doc --workspace --no-deps --document-private-items,pre-commiton the changed files — cleanNot in scope
onchain_tx::TxOutcome::SendErrstill says "no transaction was issued" for a marked send-leg failure onredeemManyand the reclaim sweep; the marker makes that fixable later.nonce too lowis treated as a foreign collision and double-escrows #2562's hash-lookup follow-up (sign locally, resolvenonce too lowby hash) is unchanged.nonce too lowsend as possibly broadcast (#2562) #2563 editstx.rsbelowsend_broadcast_unknown; this branch is onmainand should rebase cleanly after it merges.🤖 Generated with Claude Code