Skip to content

fix(evmrpc): pass raw tx bytes to DeliverTx in BlockByNumber TraceRunnable (CON-326)#3598

Merged
wen-coding merged 2 commits into
mainfrom
wen/block_replay_tx_bytes
Jun 16, 2026
Merged

fix(evmrpc): pass raw tx bytes to DeliverTx in BlockByNumber TraceRunnable (CON-326)#3598
wen-coding merged 2 commits into
mainfrom
wen/block_replay_tx_bytes

Conversation

@wen-coding

Copy link
Copy Markdown
Contributor

Summary

  • BlockByNumber replays non-traced (Cosmos) transactions via a TraceRunnable closure but was passing abci.RequestDeliverTxV2{} (empty) to DeliverTx
  • BaseApp.DeliverTx sets ctx.TxBytes = req.Tx before calling the ante handler; with an empty req.Tx, ctx.TxBytes() is nil
  • The Cosmos ante handler charges TxSizeCostPerByte * len(ctx.TxBytes()) gas — nil bytes means 0 gas charged, diverging from actual on-chain execution
  • Fix: capture txBytes := tmBlock.Block.Txs[i] before the closure (also making the loop variable capture explicit and version-independent) and pass RequestDeliverTxV2{Tx: txBytes}
  • replayTransactionTillIndex already did this correctly; BlockByNumber was the only callsite missing it

Test plan

  • TestBlockByNumberNonTracedTxPassesTxBytes — new test using a minimal BaseApp with a spy ante handler that captures ctx.TxBytes(); asserts it equals the raw tx bytes from the block. Verified it fails without the fix and passes with it.

🤖 Generated with Claude Code

…nable

Non-traced Cosmos transactions replayed via BlockByNumber were passing an
empty RequestDeliverTxV2{} to DeliverTx, leaving ctx.TxBytes() nil.
The ante handler reads ctx.TxBytes() to charge TxSizeCostPerByte gas,
so a nil value causes divergence from the original on-chain execution.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@cursor

cursor Bot commented Jun 16, 2026

Copy link
Copy Markdown

PR Summary

Medium Risk
Touches EVM RPC block trace replay and DeliverTx/ante gas semantics; the change is small and aligns behavior with replayTransactionTillIndex, but incorrect tracing could still affect debug_traceBlock state fidelity before this fix.

Overview
Block tracing replay for non-EVM txs now passes the block’s raw Cosmos tx bytes into DeliverTx when BlockByNumber builds a TraceRunnable, instead of an empty RequestDeliverTxV2. That keeps ctx.TxBytes() populated in the ante handler so tx-size gas matches on-chain execution during block traces.

The change also hoists txBytes and txHash out of the closure for stable capture. A new test runs BlockByNumber on a bank send and asserts the spy ante handler sees the same bytes as the block tx.

Reviewed by Cursor Bugbot for commit 66f9018. Bugbot is set up for automated code reviews on this repo. Configure here.

@github-actions

github-actions Bot commented Jun 16, 2026

Copy link
Copy Markdown

The latest Buf updates on your PR. Results from workflow Buf / buf (pull_request).

BuildFormatLintBreakingUpdated (UTC)
✅ passed✅ passed✅ passed✅ passedJun 16, 2026, 4:46 PM

@codecov

codecov Bot commented Jun 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 58.25%. Comparing base (4cf4ede) to head (66f9018).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3598      +/-   ##
==========================================
- Coverage   58.96%   58.25%   -0.72%     
==========================================
  Files        2208     2140      -68     
  Lines      181757   173969    -7788     
==========================================
- Hits       107164   101337    -5827     
+ Misses      64976    63612    -1364     
+ Partials     9617     9020     -597     
Flag Coverage Δ
sei-chain-pr 67.31% <100.00%> (?)
sei-db 70.41% <ø> (ø)
sei-db-state-db ?

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
evmrpc/simulate.go 75.10% <100.00%> (+0.10%) ⬆️

... and 272 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@wen-coding wen-coding requested a review from pompon0 June 16, 2026 15:57
@wen-coding wen-coding added this pull request to the merge queue Jun 16, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jun 16, 2026
@wen-coding wen-coding added this pull request to the merge queue Jun 16, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jun 16, 2026
@wen-coding wen-coding enabled auto-merge June 16, 2026 16:44
@wen-coding wen-coding added this pull request to the merge queue Jun 16, 2026
Merged via the queue into main with commit d22adc8 Jun 16, 2026
94 of 96 checks passed
@wen-coding wen-coding deleted the wen/block_replay_tx_bytes branch June 16, 2026 17:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants