Skip to content

Commit f546edd

Browse files
committed
fix #683
1 parent 15019ef commit f546edd

File tree

4 files changed

+19
-14
lines changed

4 files changed

+19
-14
lines changed

core/block_validator.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import (
2626
"github.com/scroll-tech/go-ethereum/core/rawdb"
2727
"github.com/scroll-tech/go-ethereum/core/state"
2828
"github.com/scroll-tech/go-ethereum/core/types"
29+
"github.com/scroll-tech/go-ethereum/core/vm"
2930
"github.com/scroll-tech/go-ethereum/ethdb"
3031
"github.com/scroll-tech/go-ethereum/log"
3132
"github.com/scroll-tech/go-ethereum/metrics"
@@ -69,7 +70,7 @@ func NewBlockValidator(config *params.ChainConfig, blockchain *BlockChain, engin
6970
}
7071

7172
type tracerWrapper interface {
72-
CreateTraceEnvAndGetBlockTrace(*params.ChainConfig, ChainContext, consensus.Engine, ethdb.Database, *state.StateDB, *types.Block, *types.Block, bool) (*types.BlockTrace, error)
73+
CreateTraceEnvAndGetBlockTrace(*params.ChainConfig, *vm.LogConfig, ChainContext, consensus.Engine, ethdb.Database, *state.StateDB, *types.Block, *types.Block, bool) (*types.BlockTrace, error)
7374
}
7475

7576
func (v *BlockValidator) SetupTracerAndCircuitCapacityChecker(tracer tracerWrapper) {
@@ -298,7 +299,7 @@ func (v *BlockValidator) createTraceEnvAndGetBlockTrace(block *types.Block) (*ty
298299
return nil, err
299300
}
300301

301-
return v.tracer.CreateTraceEnvAndGetBlockTrace(v.config, v.bc, v.engine, v.bc.db, statedb, parent, block, true)
302+
return v.tracer.CreateTraceEnvAndGetBlockTrace(v.config, nil, v.bc, v.engine, v.bc.db, statedb, parent, block, true)
302303
}
303304

304305
func (v *BlockValidator) validateCircuitRowConsumption(block *types.Block) (*types.RowConsumption, error) {

eth/tracers/api_blocktrace.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ type TraceBlock interface {
2323
}
2424

2525
type scrollTracerWrapper interface {
26-
CreateTraceEnvAndGetBlockTrace(*params.ChainConfig, core.ChainContext, consensus.Engine, ethdb.Database, *state.StateDB, *types.Block, *types.Block, bool) (*types.BlockTrace, error)
26+
CreateTraceEnvAndGetBlockTrace(*params.ChainConfig, *vm.LogConfig, core.ChainContext, consensus.Engine, ethdb.Database, *state.StateDB, *types.Block, *types.Block, bool) (*types.BlockTrace, error)
2727
}
2828

2929
// GetBlockTraceByNumberOrHash replays the block and returns the structured BlockTrace by hash or number.
@@ -109,5 +109,5 @@ func (api *API) createTraceEnvAndGetBlockTrace(ctx context.Context, config *Trac
109109
}
110110

111111
chaindb := api.backend.ChainDb()
112-
return api.scrollTracerWrapper.CreateTraceEnvAndGetBlockTrace(api.backend.ChainConfig(), api.chainContext(ctx), api.backend.Engine(), chaindb, statedb, parent, block, true)
112+
return api.scrollTracerWrapper.CreateTraceEnvAndGetBlockTrace(api.backend.ChainConfig(), config.LogConfig, api.chainContext(ctx), api.backend.Engine(), chaindb, statedb, parent, block, true)
113113
}

rollup/pipeline/pipeline.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,7 @@ func (p *Pipeline) traceAndApply(tx *types.Transaction) (*types.Receipt, *types.
491491
// 2.1 when starting handling the first tx, `state.refund` is 0 by default,
492492
// 2.2 after tracing, the state is either committed in `core.ApplyTransaction`, or reverted, so the `state.refund` can be cleared,
493493
// 2.3 when starting handling the following txs, `state.refund` comes as 0
494-
trace, err = tracing.NewTracerWrapper().CreateTraceEnvAndGetBlockTrace(p.chain.Config(), p.chain, p.chain.Engine(), p.chain.Database(),
494+
trace, err = tracing.NewTracerWrapper().CreateTraceEnvAndGetBlockTrace(p.chain.Config(), nil, p.chain, p.chain.Engine(), p.chain.Database(),
495495
p.state, p.parent, types.NewBlockWithHeader(&p.Header).WithBody([]*types.Transaction{tx}, nil), commitStateAfterApply)
496496
// `w.current.traceEnv.State` & `w.current.state` share a same pointer to the state, so only need to revert `w.current.state`
497497
// revert to snapshot for calling `core.ApplyMessage` again, (both `traceEnv.GetBlockTrace` & `core.ApplyTransaction` will call `core.ApplyMessage`)

rollup/tracing/tracing.go

+13-9
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ func NewTracerWrapper() *TracerWrapper {
4545
}
4646

4747
// CreateTraceEnvAndGetBlockTrace wraps the whole block tracing logic for a block
48-
func (tw *TracerWrapper) CreateTraceEnvAndGetBlockTrace(chainConfig *params.ChainConfig, chainContext core.ChainContext, engine consensus.Engine, chaindb ethdb.Database, statedb *state.StateDB, parent *types.Block, block *types.Block, commitAfterApply bool) (*types.BlockTrace, error) {
49-
traceEnv, err := CreateTraceEnv(chainConfig, chainContext, engine, chaindb, statedb, parent, block, commitAfterApply)
48+
func (tw *TracerWrapper) CreateTraceEnvAndGetBlockTrace(chainConfig *params.ChainConfig, logConfig *vm.LogConfig, chainContext core.ChainContext, engine consensus.Engine, chaindb ethdb.Database, statedb *state.StateDB, parent *types.Block, block *types.Block, commitAfterApply bool) (*types.BlockTrace, error) {
49+
traceEnv, err := CreateTraceEnv(chainConfig, logConfig, chainContext, engine, chaindb, statedb, parent, block, commitAfterApply)
5050
if err != nil {
5151
return nil, err
5252
}
@@ -98,6 +98,15 @@ type txTraceTask struct {
9898
}
9999

100100
func CreateTraceEnvHelper(chainConfig *params.ChainConfig, logConfig *vm.LogConfig, blockCtx vm.BlockContext, startL1QueueIndex uint64, coinbase common.Address, statedb *state.StateDB, rootBefore common.Hash, block *types.Block, commitAfterApply bool) *TraceEnv {
101+
if logConfig == nil {
102+
logConfig = &vm.LogConfig{
103+
DisableStorage: true,
104+
DisableStack: true,
105+
EnableMemory: false,
106+
EnableReturnData: true,
107+
}
108+
}
109+
101110
return &TraceEnv{
102111
logConfig: logConfig,
103112
commitAfterApply: commitAfterApply,
@@ -119,7 +128,7 @@ func CreateTraceEnvHelper(chainConfig *params.ChainConfig, logConfig *vm.LogConf
119128
}
120129
}
121130

122-
func CreateTraceEnv(chainConfig *params.ChainConfig, chainContext core.ChainContext, engine consensus.Engine, chaindb ethdb.Database, statedb *state.StateDB, parent *types.Block, block *types.Block, commitAfterApply bool) (*TraceEnv, error) {
131+
func CreateTraceEnv(chainConfig *params.ChainConfig, logConfig *vm.LogConfig, chainContext core.ChainContext, engine consensus.Engine, chaindb ethdb.Database, statedb *state.StateDB, parent *types.Block, block *types.Block, commitAfterApply bool) (*TraceEnv, error) {
123132
var coinbase common.Address
124133

125134
var err error
@@ -150,12 +159,7 @@ func CreateTraceEnv(chainConfig *params.ChainConfig, chainContext core.ChainCont
150159
}
151160
env := CreateTraceEnvHelper(
152161
chainConfig,
153-
&vm.LogConfig{
154-
DisableStorage: true,
155-
DisableStack: true,
156-
EnableMemory: false,
157-
EnableReturnData: true,
158-
},
162+
logConfig,
159163
core.NewEVMBlockContext(block.Header(), chainContext, chainConfig, nil),
160164
*startL1QueueIndex,
161165
coinbase,

0 commit comments

Comments
 (0)