Skip to content

fix(incentive): report a chain read that fails before the send as rejected, not possibly broadcast - #2567

Merged
thiras merged 2 commits into
mainfrom
fix/2431-send-leg-marker
Oct 20, 2026
Merged

thiras merged 2 commits into
mainfrom
fix/2431-send-leg-marker

Conversation

@thiras

@thiras thiras commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Closes #2431

Problem

decdn_incentive::tx::send_broadcast_unknown read every transport-class send() 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 call eth_sendRawTransaction. A timeout or a 5xx on one of those reads returned the same ContractError::TransportError as a lost send, so nothing was signed but:

  • pool close --all / reclaim --all counted the pool unconfirmed and told the operator to check for a transaction that does not exist;
  • open_pool / top_up held an OpenUnconfirmed / TopUpUnconfirmed entry the settle loop then had to resolve against the chain;
  • send_for_receipt reported MaybeBroadcast (publish statuses, bond, register, appeal, key rotation), and the USDC approve said it may be pending.

Common in practice on the dRPC free tier, which fails reads often.

Fix

The issue's sketch (provider.fill(..) then send_tx_envelope(..)) does not compile against the bound the call sites have: fill is an inherent method of alloy's FillProvider, not on the Provider trait, and every sender is generic over P: Provider (or DynProvider in sponsord-core).

So the split is structural instead: decdn_incentive::tx::SendLegLayer is an alloy ProviderLayer that ProviderBuilder places below the fillers, where the one request it sees is the send (FillProvider::send_transaction_internal fills, signs, then calls the inner provider's hook with the envelope). It wraps a failure of that request in SendLegFailure and lets a JSON-RPC error response through unchanged, so already known, nonce rejections, reverts and oversized-batch answers keep their shape. DynProvider forwards the hook, so the marker survives erasure. The wrapper prints as the inner error and its source() is the inner error's source, so the operator-facing chain (sanitize_err_chain) is unchanged.

send_broadcast_unknown is now three-way:

  1. marked send failure → today's transport rules on the inner error (4xx refused, local faults no; 5xx and everything else unknown);
  2. unmarked already known / known transaction answer → unknown (fix(incentive): treat an "already known" send rejection as possibly broadcast #2560);
  3. anything else → nothing sent (a chain read that failed before the send, a signing fault, a local fault).

decdn_client::provider::build_provider, the node's wallet providers (seller_wallet / buyer_wallet) and sponsord-core's treasury_provider carry 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-client senders must add the layer, or every transport failure reads as "nothing sent"; build_provider and the open_pool / top_up docs say so, and the CHANGELOG entry names it.

Review pass (second commit)

  • SendLegProvider marks all five send hooks FillProvider forwards (send_transaction_internal, send_transaction_sync_internal, send_raw_transaction, send_raw_transaction_sync, send_raw_transaction_conditional), with a test per entry point.
  • The marked branch reads an HTTP 4xx carrying 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 with Retry-After stays unknown. Both were "may have broadcast" before.
  • SendLegFailure::from_transport_error for a send made on the provider directly; the builder guards use it.
  • e2e ChainFixture::provider_for carries the layer (it feeds the real open_pool / ensure_allowance path in ClientFixture and the sponsord anvil tests).
  • Read-leg coverage added for reclaim / reclaim --all, the node's open slot (a_read_failed_open_holds_no_slot: no OpenHeld, open_unresolved stays 0, no row, the next miss sends again), and every mocked adoption fixture; the negative tests assert the read that failed (eth_estimateGas).
  • Doc wording: every "a transport failure" that now means only the send request (publish statuses, 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-client senders 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 and is_nonce_collision still reads it; an erased provider still marks; only a marked custom transport error is a SendLegFailure.
  • tx/tests.rs: classifier matrix (marked 5xx / reset / NullResp → unknown; marked 4xx / local → not; the same errors unmarked → not); send_for_receipt through 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 reaches eth_sendRawTransaction → MaybeBroadcast with the warning.
  • buyer_pool/tests.rs: open_pool, top_up, ensure_allowance on a gas-filler provider whose reads fail → no OpenUnconfirmed / TopUpUnconfirmed, entry released, approve not "may be pending", open still PoolOpenFailureReason::RpcError.
  • pool/tests.rs: close_and_forget on a filler provider whose reads fail → no TxUnconfirmed; close --all counts both pools failed, 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_replaced holds nothing (its mock leaves the open's reads unanswered).
  • Builder guards: build_provider, both node wallet providers and treasury_provider mark 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

  1. Classifier arm for an unmarked transport failure flipped back to true → the 9 fill-leg tests in tx, buyer_pool, pool fail.
  2. .layer(SendLegLayer) removed from build_provider → wallet_builder_marks_a_failed_send_request fails.
  3. Layer removed from 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 passed
  • cargo nextest run -p decdn-node buyer_pool runtime payment_settlement onchain_tx — 334 passed
  • cargo nextest run -p decdn-client --features public-api-test public_api — snapshot unchanged
  • cargo fmt -- --check, cargo clippy --workspace --all-targets --all-features -- -D warnings, CARGO_BUILD_WARNINGS=deny cargo doc --workspace --no-deps --document-private-items, pre-commit on the changed files — clean

Not in scope

🤖 Generated with Claude Code

…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]>
Copilot AI balanced review requested due to automatic review settings October 20, 2026 15:47
@thiras thiras self-assigned this Oct 20, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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

@github-code-quality

github-code-quality Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Code coverage overview

Languages: Rust

Rust / code-coverage/cargo-llvm-cov

main 0a31c9e fix/2431-send-leg-ma... 3161b26 +/-
77% 77% 0%
View coverage of the 10 most impacted files.
File main 0a31c9e fix/2431-send-leg-ma... 3161b26 +/-
crates/protocol/src/framing.rs 93% 92% -1%
crates/node/src/runtime/mod.rs 26% 26% 0%
crates/e2e/src/chain.rs 7% 7% 0%
crates/incentiv...src/test_rpc.rs 97% 97% 0%
crates/node/src/buyer_pool.rs 81% 82% +1%
crates/cli/src/...ommands/pool.rs 70% 71% +1%
crates/sponsord...ore/src/pool.rs 81% 82% +1%
crates/node/src/dht/publish.rs 78% 80% +2%
crates/incentive/src/tx.rs 75% 77% +2%
crates/incentiv.../tx/send_leg.rs 0% 100% +100%

ℹ️ Calculations represent line coverage. Results may change as calculations are updated.


Updated October 20, 2026 16:40 UTC

…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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: a transport failure while filling a tx is reported as a possible broadcast

2 participants