Skip to content

chain-write: recover success from stale transmission views in WriteReport - #915

Closed
DylanTinianov wants to merge 10 commits into
mainfrom
gas-write-report-receipt-finality
Closed

DylanTinianov wants to merge 10 commits into
mainfrom
gas-write-report-receipt-finality

Conversation

@DylanTinianov

@DylanTinianov DylanTinianov commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

What

The WriteReport action answers a write request from the forwarder's transmission state, read through each node's own RPC. Two exits could previously end the action without a reply while the transaction actually landed on chain:

  • pollTransmissionInfo erroring (stalled view or request timeout)
  • GetFailedTransmissionHash returning ErrUnexpectedSuccessfulTransmission (the state read said failed, but the logs contain a success) — previously logged and returned as an error

Both paths skipped the receipt fetch and the gas usage record entirely.

Why

A node whose RPC view lagged the landing transaction never reported the fee for a write that succeeded, and the workflow received an error instead of the successful outcome. Since every node answers independently from its own view, timing skew between nodes produced divergent answers for the same on-chain write.

How it works now

recoverSuccessFromLogs answers from the transmission logs in both cases: a successful tx in the logs is ground truth, so its receipt is fetched and metered exactly like the normal success path. When the request context is already dead (poll timeout), the check runs on a fresh bounded deadline (finalReceiptCheckTimeout, 10s). Unexpected-success errors that cannot be recovered keep their existing error behavior — the recovery is strictly additive.

…port

The WriteReport action answers a write request from the forwarder's
transmission state, read through each node's own RPC. Two exits could
end the action without a reply while the transaction actually landed
on chain:

- pollTransmissionInfo erroring (stalled view or request timeout)
- GetFailedTransmissionHash returning ErrUnexpectedSuccessfulTransmission
  (state read said failed, logs contain a success), previously logged
  and returned as an error

Both paths skipped the receipt fetch and the gas usage record, so a
node whose RPC view lagged the landing tx never reported the fee, and
the workflow got an error for a write that succeeded.

recoverSuccessFromLogs now answers from the transmission logs in both
cases: a successful tx in the logs is ground truth, so its receipt is
fetched and metered like the normal success path, on a fresh bounded
deadline when the request context is already dead. Unexpected-success
errors that cannot be recovered keep their existing error behavior.

Tests: poll failure with a landed success recovers and meters;
InvalidReceiver state with an unexpected success returns success and
meters; poll errors without a success keep the original error.

Co-Authored-By: Claude Code <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

👋 DylanTinianov, thanks for creating this pull request!

To help reviewers, please consider creating future PRs as drafts first. This allows you to self-review and make any final changes before notifying the team.

Once you're ready, you can mark it as "Ready for review" to request feedback. Thanks!

@DylanTinianov DylanTinianov self-assigned this Nov 16, 2026
DylanTinianov and others added 3 commits November 16, 2026 18:26
unconvert: belowMinimum is already uint64; the conversion is
unnecessary and the gosec nolint comment with it.

Co-Authored-By: Claude Code <noreply@anthropic.com>
The gomod cache restore repeatedly failed with "tar: Cannot open:
File exists" on corrupted entries. Bump cache-version to rotate the
cache key and force a fresh save.

Co-Authored-By: Claude Code <noreply@anthropic.com>
@DylanTinianov
DylanTinianov marked this pull request as ready for review November 17, 2026 17:40
@DylanTinianov
DylanTinianov marked this pull request as draft November 17, 2026 19:45
@DylanTinianov
DylanTinianov marked this pull request as ready for review November 20, 2026 22:10
DylanTinianov and others added 4 commits November 20, 2026 17:10
The recoverSuccessFromLogs edit left it orphaned above the wrong
function, leaving meteringFromReply undocumented.

Co-Authored-By: Claude Code <noreply@anthropic.com>
When the write report's transmission poll fails, the gas usage is still
metered: the recovery function retries the log scan on a fresh 30s
deadline, fetching the receipt and emitting the meter record once the
node's RPC catches up.

Co-Authored-By: Claude Code <noreply@anthropic.com>
The write-report flow now recovers inline: when the poll fails, the
last-chance log scan (30s timeout) fetches the receipt and meters.
Previously the scan ran in a background goroutine, which raced with the
test and made the failure invisible.

Co-Authored-By: Claude Code <noreply@anthropic.com>
When the write report's transmission poll fails, the gas usage is still
metered: the recovery function retries the log scan on a fresh 30s
deadline, fetching the receipt and emitting the meter record once the
node's RPC catches up.

Co-Authored-By: Claude Code <noreply@anthropic.com>
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.

1 participant