Repository navigation
Description
Problem
crates/incentive/src/tx.rs exists (#1355) because each hand-written send-and-receipt sequence made the same mistake. When get_receipt() fails, the error names no transaction. That is the case where the operator needs the hash most. The transaction may still be in flight, and sending it again can cause a duplicate spend.
Four production sites still have this bug. Each one sends, then calls pending.get_receipt() and does not first read *pending.tx_hash(). The receipt error therefore carries no hash:
| Site | Call | Error on receipt failure |
|---|---|---|
crates/cli/src/commands/pool.rs close_and_forget (~L577) |
closePool |
"closePool receipt failed" |
crates/cli/src/commands/pool.rs reclaim_and_forget (~L635) |
reclaim |
"reclaim receipt failed" |
crates/client/src/buyer_pool.rs open_pool (~L499) |
openPool |
"await openPool receipt" + PoolOpenFailureReason::RpcError |
crates/node/src/buyer_pool.rs reclaim sweep (~L2418) |
reclaim |
warn! "reclaim sweep: reclaim receipt failed" (no tx field) |
openPool has the highest stakes: it escrows a USDC deposit. If an operator re-runs it after a receipt timeout, they can open a second pool.
Sites that already handle this correctly can serve as models:
client/src/buyer_pool.rsUSDCapprove(~L396) andtopUp(~L819) capture*pending.tx_hash()before the wait.node/src/onchain_tx.rsawait_receiptdoes the same and recovers the receipt by hash.
Why the CLI pair is hand-written
close_and_forget / reclaim_and_forget turn both an estimation-time revert and a mined revert into one pool-specific message. They do this because a pool that someone else already closed is a normal race. tx::send_for_receipt would report that as a generic error. The tx.rs module doc names these two sites and says that they lose the hash (#2412).
Fix
At each of the four sites, either:
- route the call through
decdn_incentive::tx::send_for_receiptwith aSendOutcome. The CLI pair can then map its revert arm to the pool-specific message. Or: - capture
let tx = *pending.tx_hash();beforeget_receipt()and put it in the error (or as atxfield on the nodewarn!).
Then remove the "loses the hash too" sentence from the tx.rs module doc. If no hand-written exception is left, remove the paragraph.
Checks
- A unit test per CLI site where the receipt fetch fails, asserting that the error string contains the tx hash. A provider whose
eth_getTransactionReceipterrors is enough. rg -n '\.get_receipt\(\)' crates --glob '!crates/e2e/**' --glob '!**/tests*'shows only sites that readtx_hash()first, or that go throughtx.rs/onchain_tx.rs.
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Projects
- StatusShow more project fieldsDone
Activity
docs: correct pool/lane wording found in review
refactor: retire remaining payment-channel identifiers and stale chan…
fix: name the tx on mined pool-tx reverts and tighten tx-hash docs
fix: log the openPool broadcast and name the tx on approve/topUp fail…
fix: keep the tx hash when a pool tx receipt fetch fails (#2414)