mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-25 06:06:44 +00:00
refactor(trace): wrap the core routine in CreateTraceEnv (#460)
This commit is contained in:
parent
d4597e369e
commit
be1600f078
2 changed files with 34 additions and 21 deletions
|
|
@ -66,6 +66,28 @@ type txTraceTask struct {
|
||||||
index int
|
index int
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 {
|
||||||
|
return &TraceEnv{
|
||||||
|
logConfig: logConfig,
|
||||||
|
commitAfterApply: commitAfterApply,
|
||||||
|
chainConfig: chainConfig,
|
||||||
|
coinbase: coinbase,
|
||||||
|
signer: types.MakeSigner(chainConfig, block.Number()),
|
||||||
|
state: statedb,
|
||||||
|
blockCtx: blockCtx,
|
||||||
|
StorageTrace: &types.StorageTrace{
|
||||||
|
RootBefore: rootBefore,
|
||||||
|
RootAfter: block.Root(),
|
||||||
|
Proofs: make(map[string][]hexutil.Bytes),
|
||||||
|
StorageProofs: make(map[string]map[string][]hexutil.Bytes),
|
||||||
|
},
|
||||||
|
ZkTrieTracer: make(map[string]state.ZktrieProofTracer),
|
||||||
|
ExecutionResults: make([]*types.ExecutionResult, block.Transactions().Len()),
|
||||||
|
TxStorageTraces: make([]*types.StorageTrace, block.Transactions().Len()),
|
||||||
|
StartL1QueueIndex: startL1QueueIndex,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func CreateTraceEnv(chainConfig *params.ChainConfig, chainContext ChainContext, engine consensus.Engine, chaindb ethdb.Database, statedb *state.StateDB, parent *types.Block, block *types.Block, commitAfterApply bool) (*TraceEnv, error) {
|
func CreateTraceEnv(chainConfig *params.ChainConfig, chainContext ChainContext, engine consensus.Engine, chaindb ethdb.Database, statedb *state.StateDB, parent *types.Block, block *types.Block, commitAfterApply bool) (*TraceEnv, error) {
|
||||||
var coinbase common.Address
|
var coinbase common.Address
|
||||||
var err error
|
var err error
|
||||||
|
|
@ -94,29 +116,20 @@ func CreateTraceEnv(chainConfig *params.ChainConfig, chainContext ChainContext,
|
||||||
log.Error("missing FirstQueueIndexNotInL2Block for block during trace call", "number", parent.NumberU64(), "hash", parent.Hash())
|
log.Error("missing FirstQueueIndexNotInL2Block for block during trace call", "number", parent.NumberU64(), "hash", parent.Hash())
|
||||||
return nil, fmt.Errorf("missing FirstQueueIndexNotInL2Block for block during trace call: hash=%v, parentHash=%vv", block.Hash(), parent.Hash())
|
return nil, fmt.Errorf("missing FirstQueueIndexNotInL2Block for block during trace call: hash=%v, parentHash=%vv", block.Hash(), parent.Hash())
|
||||||
}
|
}
|
||||||
|
env := CreateTraceEnvHelper(
|
||||||
env := &TraceEnv{
|
chainConfig,
|
||||||
logConfig: &vm.LogConfig{
|
&vm.LogConfig{
|
||||||
EnableMemory: false,
|
EnableMemory: false,
|
||||||
EnableReturnData: true,
|
EnableReturnData: true,
|
||||||
},
|
},
|
||||||
commitAfterApply: commitAfterApply,
|
NewEVMBlockContext(block.Header(), chainContext, chainConfig, nil),
|
||||||
chainConfig: chainConfig,
|
*startL1QueueIndex,
|
||||||
coinbase: coinbase,
|
coinbase,
|
||||||
signer: types.MakeSigner(chainConfig, block.Number()),
|
statedb,
|
||||||
state: statedb,
|
parent.Root(),
|
||||||
blockCtx: NewEVMBlockContext(block.Header(), chainContext, chainConfig, nil),
|
block,
|
||||||
StorageTrace: &types.StorageTrace{
|
commitAfterApply,
|
||||||
RootBefore: parent.Root(),
|
)
|
||||||
RootAfter: block.Root(),
|
|
||||||
Proofs: make(map[string][]hexutil.Bytes),
|
|
||||||
StorageProofs: make(map[string]map[string][]hexutil.Bytes),
|
|
||||||
},
|
|
||||||
ZkTrieTracer: make(map[string]state.ZktrieProofTracer),
|
|
||||||
ExecutionResults: make([]*types.ExecutionResult, block.Transactions().Len()),
|
|
||||||
TxStorageTraces: make([]*types.StorageTrace, block.Transactions().Len()),
|
|
||||||
StartL1QueueIndex: *startL1QueueIndex,
|
|
||||||
}
|
|
||||||
|
|
||||||
key := coinbase.String()
|
key := coinbase.String()
|
||||||
if _, exist := env.Proofs[key]; !exist {
|
if _, exist := env.Proofs[key]; !exist {
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ import (
|
||||||
const (
|
const (
|
||||||
VersionMajor = 4 // Major version component of the current release
|
VersionMajor = 4 // Major version component of the current release
|
||||||
VersionMinor = 3 // Minor version component of the current release
|
VersionMinor = 3 // Minor version component of the current release
|
||||||
VersionPatch = 43 // Patch version component of the current release
|
VersionPatch = 44 // Patch version component of the current release
|
||||||
VersionMeta = "sepolia" // Version metadata to append to the version string
|
VersionMeta = "sepolia" // Version metadata to append to the version string
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue