Repository navigation
Conversation
When the node refuses a claim's stored transaction, for example because its fee cap is below the base fee, the sender re-signs the claim at the same nonce with the configured fees, persists it, and broadcasts it. Every hash signed for a claim is kept in a new claim_txs table, and a receipt for any of them settles the claim.
There was a problem hiding this comment.
When the node refuses a claim's stored transaction, the sender now re-signs the claim at the same nonce with the current fees. A new claim_txs table, filled by a versioned migration, records every hash signed for a claim, and a successful receipt for any of them settles it. Nothing blocks: the remaining issues are narrow edge cases in which a claim can be marked failed after it was paid or can stay stuck. Both codex findings held up and are kept as suggestions; the Go toolchain was not available, so the tests were not run.
Non-blocking
4 findings on the changed lines, as inline comments.
seidroid review · decision approve · session b332e398fc1b48daa4d242aed2ece05d · turn resp_claude_65bc93f6ceca0ce5bab708b6cc2bd2b9 · item e0f689bfa0455577904b06b6c5c50adf
Findings: 0 blocking | 4 non-blocking | 4 posted inline
| return nil, err | ||
| case receipt.Status == types.ReceiptStatusSuccessful: | ||
| return receipt, nil | ||
| case spent || hash == common.HexToHash(c.TxHash): |
There was a problem hiding this comment.
suggestion — (Raised by codex; confirmed.) Outside reconcile, a failed receipt for the latest hash marks the claim failed, but an earlier variant at the same nonce can still be in a mempool, and on Giga a failed receipt leaves the nonce unspent. The variants differ only in fees, so a re-signed transaction with a higher fee cap can fail on insufficient balance while the older one later succeeds. The recipient is then paid after the claim is marked failed. Failed claims don't count toward the limits, so the address can claim and be paid again. Treat a failed latest receipt like a failed older one until the nonce is spent, and let reconcile decide.
There was a problem hiding this comment.
Fixed in 61feac0. A failed receipt no longer fails the claim from confirm: it triggers a resync, which fills the nonce instead of rebroadcasting, and reconcile settles the claim once the nonce is spent, so a successful earlier variant still confirms it. Covered by the "re-signed transaction fails before the old one lands" case.
| if err := update(ctx, tx, from, set, id, args...); err != nil { | ||
| return err | ||
| } | ||
| if _, err := tx.ExecContext(ctx, `INSERT INTO claim_txs (hash, claim_id, signed_at) VALUES (?, ?, ?)`, |
There was a problem hiding this comment.
suggestion — (Raised by codex; confirmed.) Signing is deterministic, so changing the fees from A to B and back to A reproduces a hash that is already in claim_txs. rebroadcast only compares the new hash with the current one, so this INSERT hits the primary-key constraint and Resign rolls back. Every later resync repeats the failure, and the A transaction is never broadcast. Treat an existing row for the same claim as idempotent (for example, ON CONFLICT DO NOTHING plus a claim_id check).
There was a problem hiding this comment.
Fixed in 61feac0. The insert is now an upsert that only matches a row for the same claim, so re-signing back to an earlier hash is idempotent, and a hash owned by another claim returns ErrHashTaken. Covered in TestResignKeepsEveryHash.
| // Resign replaces a sent claim's transaction with one re-signed at the same | ||
| // nonce, keeping the earlier hashes in TxHashes. Call it before broadcasting. | ||
| func (s *Store) Resign(ctx context.Context, id string, hash common.Hash, raw []byte, now time.Time) error { | ||
| return s.sign(ctx, StatusSent, id, hash, now, `tx_hash = ?, raw_tx = ?`, hash.Hex(), raw) |
There was a problem hiding this comment.
suggestion — Resign leaves sent_at at the time of the first broadcast, which by now is long past ConfirmTimeout. reconcile uses sent_at as the grace period for a receipt that has not been indexed yet. If another resync runs soon after a re-sign, for example because a different claim's rebroadcast left the sender stuck, a re-signed transaction that has landed but whose receipt is not visible yet is marked failed as 'nonce spent elsewhere', which allows a second payment. Base the grace period on the latest signed_at, or update sent_at in Resign.
There was a problem hiding this comment.
Fixed in 61feac0. Resign now sets sent_at, so both the confirm timeout and the reconcile grace period start from the latest signature.
| // spent: on Giga a failed receipt leaves the nonce unspent, so a later | ||
| // re-signed transaction can still land. | ||
| func (s *Sender) receipt(ctx context.Context, c *store.Claim, spent bool) (*types.Receipt, error) { | ||
| hashes, err := s.store.TxHashes(ctx, c.ID) |
There was a problem hiding this comment.
suggestion — receipt() reads hashes only from claim_txs and never falls back to c.TxHash. Suppose the binary is rolled back after the migration: the older binary marks claims sent without adding claim_txs rows, and the backfill does not run again at user_version 2. When the newer binary returns, those claims never confirm, and reconcile marks them 'nonce spent elsewhere' even though they were paid. Always include c.TxHash among the hashes checked.
There was a problem hiding this comment.
Fixed in 61feac0. receipt() now always checks the claim's current hash as well. TestSettlesClaimWithoutHashHistory covers a claim with no claim_txs rows.
A failed receipt for the latest transaction no longer fails the claim while an earlier one can still land: resync spends the nonce and reconcile settles it. Re-signing back to an earlier hash is idempotent, Resign restarts the sent time, and receipts also check the claim's current hash.
A claim keeps the nonce it was signed at, and resync only rebroadcast its stored transaction. If the node never admitted that transaction, for example because its fee cap fell below the base fee, the nonce stayed unspent and every later transfer stalled behind it. Raising the fee caps did not help, since the transaction was already signed.
Now, when the node refuses a stored transaction, the sender re-signs the claim at the same nonce with the configured fees, persists it, and broadcasts it. A new migration adds a claim_txs table that keeps every hash signed for a claim, backfilled from the claims already sent, and the sender checks all of them along with the claim's current hash: a successful receipt for any of them settles the claim, so an old transaction that lands after the re-sign still confirms it exactly once. Because an earlier transaction can still land after a later one fails, a failed receipt settles the claim only once its nonce is spent: resync fills the nonce and reconcile decides. The store now applies migrations in order, tracked by SQLite's user_version.
Fixes PLT-1634.