Repository navigation
Description
Context
Surfaced while writing the #763 buyer-channel reconciliation e2e (PR for #763). Not introduced by that work — it is a pre-existing concern in the on-chain settlement paths.
Problem
The buyer and seller PaymentChannelService providers are built with ProviderBuilder::new() (recommended fillers, incl. the default nonce filler) in crates/node/src/runtime/mod.rs (e.g. :886 seller wallet, :969 buyer wallet) and in the anvil e2e.
When reclaimExpired is submitted for a channel that is not yet expired on-chain, it reverts (ChannelNotExpired, custom error 0xd56b7c97). Observed behavior on anvil: the failed send appears to leave the provider's cached nonce advanced, so the next transaction from that wallet carries a gapped nonce, sits unmined, and its get_receipt() polls until timeout (~780s in the repro), effectively wedging all subsequent buyer transactions until the process restarts.
This matters because the code expects reclaimExpired to revert and be retried:
BuyerChannelState::is_expired_atdoc (crates/incentive/src/buyer_channel.rs): "a too-early attempt simply reverts and is retried" under host-clock-vs-chain skew.try_reclaim(crates/node/src/buyer_channel.rs) and theopen_or_reuse_channelreclaim-before-reopen bail path both sendreclaimExpiredthat can revert.
So under clock skew (or the bail path), a single reverting reclaimExpired could strand the node's buyer transaction lane.
Repro
In the #763 PR an e2e sub-scenario that deliberately triggered a not-yet-reclaimable reclaimExpired via open_or_reuse_channel, immediately followed by another buyer tx, hung for ~780s. Removing that sub-scenario avoided it; the hang is the symptom of the nonce gap.
What to investigate / fix
- Confirm whether alloy 2.0.5's default nonce filler (
CachedNonceManager) increments the cached nonce during a fill whoseeth_estimateGasthen reverts (leaking it), vs. a fetch-each-time manager. - If it leaks: decide on a remediation — e.g. a nonce manager that does not advance on a failed send, resetting/refetching the cached nonce after a send error, or pre-checking expiry off-chain before submitting
reclaimExpiredso a revert is never issued. - Add regression coverage (the reverting-reclaim-then-next-tx sequence) once a fix lands.
Refs
- PR for Buyer-channel robustness follow-ups: orphan-deposit reconciliation + concurrent-open / multi-row reclaim e2e coverage #763 (buyer-channel reconciliation) — discovered here; that PR avoids triggering it.
crates/node/src/runtime/mod.rsprovider construction;crates/node/src/buyer_channel.rstry_reclaim/open_or_reuse_channel.
🤖 Generated with Claude Code
Activity
github-actions commentedon Jun 14, 2026
🎯 Triage report
Pre-existing bug in the
PaymentChannelService: alloy'sCachedNonceManageradvances its cached nonce when filling a transaction (before broadcast), so areclaimExpiredcall that reverts on-chain (ChannelNotExpired) leaves the cached nonce incremented — subsequent transactions from the same wallet carry a gapped nonce, sit unmined, and blockget_receipt()for the full ~780s poll timeout. Sincetry_reclaimandopen_or_reuse_channeldeliberately expectreclaimExpiredto revert under clock skew, any clock-skew event today can silently wedge the entire buyer tx lane until process restart.📊 Assessment
bug,rust,technical,high🔗 Similar issues
💡 Notes and suggestions
Root-cause confirmation (step 1)
Alloy's
CachedNonceManager(alloy-network/src/transaction/signer.rsin alloy-rs/alloy ≥0.5) increments the cached nonce insidefill_transactionbefore theeth_sendRawTransactioncall. Ifeth_estimateGas(run by the filler pipeline) returns an error, the increment still happens. This is a known limitation documented in alloy issues; fetching each time (NonceManagerLayer::new_with_policy(NoncePolicy::FetchEach)) avoids it at the cost of one extraeth_getTransactionCountRPC per tx.Remediation options (most to least surgical):
Off-chain expiry pre-check (preferred, zero RPC overhead): Before calling
reclaimExpired, read the channel'sexpiresAtfrom the contract state (already available viaPaymentChannel::channels()) and compare against the latest block timestamp. Only submit ifblock.timestamp >= expiresAt. This eliminates the revert entirely and aligns with how the rest of the node avoids known-failing txs. Theis_expired_athelper inBuyerChannelStatealready does the host-clock side; it just needs a chain-timestamp cross-check.Switch to fetch-each nonce manager: Replace
ProviderBuilder::new()with an explicitNonceManagerLayerconfigured to fetch fresh from chain on every fill. Robust against any future revert path; adds ~1 RPC per tx (~few ms on localhost, negligible on Sepolia vs. payment channel latency). Touch points:crates/node/src/runtime/mod.rsseller (:886) and buyer (:969) wallet construction.Nonce reset on send error: Wrap calls to
send_transactionin an error handler that callseth_getTransactionCount(wallet, "pending")and resets the manager's cached value. More complex, as alloy doesn't expose a public reset API — would require a custom middleware layer.Regression test checklist:
CachedNonceManageragainst a mock RPC; confirm nonce is/isn't leaked wheneth_estimateGasreturnsChannelNotExpiredanvil_settlement_e2e.rs, re-add the sub-scenario from the Buyer-channel robustness follow-ups: orphan-deposit reconciliation + concurrent-open / multi-row reclaim e2e coverage #763 PR that deliberately submits a not-yet-reclaimablereclaimExpired, then immediately issues another buyer tx — the second tx should confirm within the timeout windowCode references:
crates/node/src/runtime/mod.rs:886(seller wallet),:969(buyer wallet) — provider constructioncrates/node/src/buyer_channel.rs—try_reclaim,open_or_reuse_channelcrates/incentive/src/buyer_channel.rs—BuyerChannelState::is_expired_at(clock-side check; needs chain-timestamp companion)Add this agentic workflows to your repo
To install this agentic workflow, run
fix(node): use simple nonce management so a reverting reclaimExpired …
fix(node): use simple nonce management so a reverting reclaimExpired …
refactor(node): shared send→receipt→status core for the on-chain tx l…