Skip to content

Commit

Permalink
Add early return in ComputeTxEnv for state sync transactions (#12316)
Browse files Browse the repository at this point in the history
Port #12315 for Erigon 3
  • Loading branch information
shohamc1 authored Oct 15, 2024
1 parent cce322f commit ae68dc0
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions turbo/transactions/tracing.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,6 @@ func ComputeTxEnv(ctx context.Context, engine consensus.EngineReader, block *typ
// Create the parent state database
statedb := state.New(reader)

if txIndex == 0 && len(block.Transactions()) == 0 {
return nil, evmtypes.BlockContext{}, evmtypes.TxContext{}, statedb, reader, nil
}
getHeader := func(hash libcommon.Hash, n uint64) *types.Header {
h, _ := headerReader.HeaderByNumber(ctx, dbtx, n)
return h
Expand All @@ -73,6 +70,11 @@ func ComputeTxEnv(ctx context.Context, engine consensus.EngineReader, block *typ

blockContext := core.NewEVMBlockContext(header, core.GetHashFn(header, getHeader), engine, nil, cfg)

if txIndex == len(block.Transactions()) {
// tx is a state sync transaction
return nil, blockContext, evmtypes.TxContext{}, statedb, nil, nil
}

// Recompute transactions up to the target index.
signer := types.MakeSigner(cfg, block.NumberU64(), block.Time())
rules := cfg.Rules(blockContext.BlockNumber, blockContext.Time)
Expand Down

0 comments on commit ae68dc0

Please sign in to comment.