Skip to content

Kartik/debug trace speedups v6.3 experimental#3099

Draft
Kbhat1 wants to merge 8 commits intorelease/v6.3from
kartik/debug-trace-speedups-v6.3-experimental
Draft

Kartik/debug trace speedups v6.3 experimental#3099
Kbhat1 wants to merge 8 commits intorelease/v6.3from
kartik/debug-trace-speedups-v6.3-experimental

Conversation

@Kbhat1
Copy link
Contributor

@Kbhat1 Kbhat1 commented Mar 20, 2026

Describe your changes and provide context

Testing performed to validate your change

Kbhat1 added 7 commits March 20, 2026 11:00
Keep the profiled block trace path on the default tracer only so explicit tracers like flatCallTracer continue using the legacy implementation and preserve per-transaction failure semantics.

Made-with: Cursor
…ncement

The parallel state-advancement path was skipping PrepareTx (which runs
the tracer ante handler: address association, sig verification, context
setup) before ApplyMessage. This meant snapshots given to worker N+1
could be missing ante-handler side effects from tx N.

Add PrepareTx to advanceState so the main thread's state matches what
profiledTraceTx produces on each worker. The TracerAnteHandler is
lightweight (no fee charging) so the overhead is minimal and parallelism
is preserved.

Also change failure handling: instead of aborting the entire RPC with a
top-level error on the first state-advancement failure, return partial
per-tx results with error entries for unreached txs, matching the
sequential path's semantics.

Made-with: Cursor
The DoesNotAbortOnFailedTx test asserted that both txs have non-empty
"result" fields. With PrepareTx in the parallel state advancement, a
failed tx's worker may receive a nonce error from the shared store
flush, producing an "error" entry instead of a "result" entry. The
second tx (not dispatched due to the break) gets an error fill entry.

Relax the assertion: verify that both txs have per-tx entries (either
result or error) and that no top-level abort occurred, which is the
test's actual intent.

Made-with: Cursor
Avoid a missing helper on the release backport branches by making the default tracer regression test self-contained.

Made-with: Cursor
@github-actions
Copy link

github-actions bot commented Mar 20, 2026

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

BuildFormatLintBreakingUpdated (UTC)
✅ passed✅ passed✅ passed✅ passedMar 20, 2026, 8:47 PM

@codecov
Copy link

codecov bot commented Mar 20, 2026

Codecov Report

❌ Patch coverage is 8.62069% with 318 lines in your changes missing coverage. Please review.
✅ Project coverage is 43.43%. Comparing base (b84fd97) to head (fc5bd23).

Files with missing lines Patch % Lines
evmrpc/block_trace_profiled.go 9.79% 245 Missing and 13 partials ⚠️
evmrpc/simulate.go 0.00% 20 Missing ⚠️
evmrpc/tracers.go 9.09% 19 Missing and 1 partial ⚠️
x/evm/state/statedb.go 0.00% 10 Missing ⚠️
sei-cosmos/types/context.go 0.00% 7 Missing ⚠️
app/app.go 0.00% 2 Missing ⚠️
x/evm/state/code.go 0.00% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@               Coverage Diff                @@
##           release/v6.3    #3099      +/-   ##
================================================
- Coverage         46.02%   43.43%   -2.60%     
================================================
  Files              1199     1867     +668     
  Lines            104568   155838   +51270     
================================================
+ Hits              48130    67681   +19551     
- Misses            52200    82090   +29890     
- Partials           4238     6067    +1829     
Flag Coverage Δ
sei-chain 42.26% <8.79%> (-0.31%) ⬇️
sei-cosmos 38.26% <0.00%> (?)
sei-db 45.67% <ø> (-0.02%) ⬇️
sei-ibc-go 55.96% <ø> (ø)
sei-tendermint 47.64% <ø> (+0.07%) ⬆️
sei-wasmd 41.54% <ø> (ø)
sei-wasmvm 39.88% <ø> (ø)

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

Files with missing lines Coverage Δ
x/evm/state/code.go 82.35% <0.00%> (ø)
app/app.go 75.50% <0.00%> (ø)
sei-cosmos/types/context.go 52.12% <0.00%> (ø)
x/evm/state/statedb.go 32.48% <0.00%> (-1.98%) ⬇️
evmrpc/simulate.go 65.87% <0.00%> (-3.31%) ⬇️
evmrpc/tracers.go 43.17% <9.09%> (-2.59%) ⬇️
evmrpc/block_trace_profiled.go 9.79% <9.79%> (ø)

... and 685 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.

"encoding/json"
"errors"
"fmt"
"runtime"

Check notice

Code scanning / CodeQL

Sensitive package import Note

Certain system packages contain functions which may be a possible source of non-determinism
Comment on lines +189 to +212
go func() {
defer pend.Done()
for task := range jobs {
tx := txs[task.index]
msg, _ := core.TransactionToMessage(tx, signer, block.BaseFee())
txctx := &tracers.Context{
BlockHash: blockHash,
BlockNumber: block.Number(),
TxIndex: task.index,
TxHash: tx.Hash(),
}
blockCtx, err := api.backend.GetBlockContext(ctx, block, task.statedb, api.backend)
if err != nil {
results[task.index] = &tracers.TxTraceResult{TxHash: tx.Hash(), Error: err.Error()}
continue
}
res, err := api.profiledTraceTx(ctx, tx, msg, txctx, blockCtx, task.statedb, config, nil)
if err != nil {
results[task.index] = &tracers.TxTraceResult{TxHash: tx.Hash(), Error: err.Error()}
} else {
results[task.index] = &tracers.TxTraceResult{TxHash: tx.Hash(), Result: res}
}
}
}()

Check notice

Code scanning / CodeQL

Spawning a Go routine Note

Spawning a Go routine may be a possible source of non-determinism
Comment on lines +368 to +376
go func() {
<-deadlineCtx.Done()
if errors.Is(deadlineCtx.Err(), context.DeadlineExceeded) {
tracerMtx.Lock()
tracer.Stop(errors.New("execution timeout"))
tracerMtx.Unlock()
evm.Cancel()
}
}()

Check notice

Code scanning / CodeQL

Spawning a Go routine Note

Spawning a Go routine may be a possible source of non-determinism
@Kbhat1 Kbhat1 marked this pull request as draft March 20, 2026 16:45
…shes

The parallel block trace path had a data race: worker goroutines read
from statedb copies whose CacheMultiStore chains cascaded to the
original's CacheMultiStore, while the main goroutine called
CleanupForTracer which flushed (Write()) those shared CacheMultiStore
layers concurrently.

Fix by introducing ResetForTracer() which resets in-memory state
(tempState, journal) and creates a new Snapshot layer without flushing
the CMS hierarchy. The parallel path uses PrepareTxNoFlush (which calls
ResetForTracer) instead of PrepareTx (which calls CleanupForTracer).
This ensures no goroutine calls Write() on any CMS layer that another
goroutine may be reading from.

Also fix Copy() to allocate a fresh backing array for snapshottedCtxs,
preventing the original and copy from aliasing the same slice memory.

Made-with: Cursor
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