mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-26 06:36:43 +00:00
clean up the code some more. ensure that block txs aren't executed in parallel for TraceChain
This commit is contained in:
parent
40176b7d3b
commit
709a3e8794
1 changed files with 15 additions and 15 deletions
|
|
@ -257,7 +257,7 @@ func (api *API) traceChain(start, end *types.Block, config *TraceConfig, closed
|
||||||
tracker = newStateTracker(maximumPendingTraceStates, start.NumberU64())
|
tracker = newStateTracker(maximumPendingTraceStates, start.NumberU64())
|
||||||
err error
|
err error
|
||||||
)
|
)
|
||||||
opt, err := traceExecOpt(config)
|
opt, err := traceExecOpt(false, config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Warn("invalid trace configuration", "err", err)
|
log.Warn("invalid trace configuration", "err", err)
|
||||||
return nil
|
return nil
|
||||||
|
|
@ -420,7 +420,7 @@ func (api *API) traceBlockCustomTracer(ctx context.Context, block *types.Block,
|
||||||
instantiateTracer := func(ctx *Context) (*Tracer, error) {
|
instantiateTracer := func(ctx *Context) (*Tracer, error) {
|
||||||
return api.instantiateTracer(config, ctx)
|
return api.instantiateTracer(config, ctx)
|
||||||
}
|
}
|
||||||
opt, err := traceExecOpt(config)
|
opt, err := traceExecOpt(true, config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
@ -479,7 +479,7 @@ func (api *API) TraceBadBlock(ctx context.Context, hash common.Hash, config *Tra
|
||||||
return api.instantiateTracer(config, ctx)
|
return api.instantiateTracer(config, ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
opt, err := traceExecOpt(config)
|
opt, err := traceExecOpt(true, config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
@ -572,12 +572,6 @@ func (api *API) StandardTraceBadBlockToFile(ctx context.Context, hash common.Has
|
||||||
return api.standardTraceBlockToFile(ctx, block, config)
|
return api.standardTraceBlockToFile(ctx, block, config)
|
||||||
}
|
}
|
||||||
|
|
||||||
type traceExecOptions struct {
|
|
||||||
txTimeout time.Duration
|
|
||||||
reexec uint64
|
|
||||||
parallel bool
|
|
||||||
}
|
|
||||||
|
|
||||||
func (api *API) retrieveBlockPrestate(ctx context.Context, block *types.Block, execOpt *traceExecOptions, readOnly, preferDisk bool) (db *state.StateDB, stateRelease StateReleaseFunc, err error) {
|
func (api *API) retrieveBlockPrestate(ctx context.Context, block *types.Block, execOpt *traceExecOptions, readOnly, preferDisk bool) (db *state.StateDB, stateRelease StateReleaseFunc, err error) {
|
||||||
if block.NumberU64() == 0 {
|
if block.NumberU64() == 0 {
|
||||||
return nil, nil, fmt.Errorf("genesis is not traceable")
|
return nil, nil, fmt.Errorf("genesis is not traceable")
|
||||||
|
|
@ -595,7 +589,6 @@ func (api *API) retrieveBlockPrestate(ctx context.Context, block *types.Block, e
|
||||||
}
|
}
|
||||||
|
|
||||||
func (api *API) traceBlockWithState(ctx context.Context, block *types.Block, statedb *state.StateDB, execOpt *traceExecOptions, instantiateTracer func(*Context) (*Tracer, error)) ([]*txTraceResult, error) {
|
func (api *API) traceBlockWithState(ctx context.Context, block *types.Block, statedb *state.StateDB, execOpt *traceExecOptions, instantiateTracer func(*Context) (*Tracer, error)) ([]*txTraceResult, error) {
|
||||||
// TODO: this changes the semantics of traceChain a bit. double-check that it's alright to call ProcessBeaconBlockRoot and ProcessParentBlockHash here
|
|
||||||
blockCtx := core.NewEVMBlockContext(block.Header(), api.chainContext(ctx), nil)
|
blockCtx := core.NewEVMBlockContext(block.Header(), api.chainContext(ctx), nil)
|
||||||
evm := vm.NewEVM(blockCtx, statedb, api.backend.ChainConfig(), vm.Config{})
|
evm := vm.NewEVM(blockCtx, statedb, api.backend.ChainConfig(), vm.Config{})
|
||||||
if beaconRoot := block.BeaconRoot(); beaconRoot != nil {
|
if beaconRoot := block.BeaconRoot(); beaconRoot != nil {
|
||||||
|
|
@ -804,11 +797,18 @@ func (api *API) standardTraceTxToFile(ctx context.Context, block *types.Block, t
|
||||||
|
|
||||||
func traceCallExecOpt(config *TraceCallConfig) (*traceExecOptions, error) {
|
func traceCallExecOpt(config *TraceCallConfig) (*traceExecOptions, error) {
|
||||||
if config == nil {
|
if config == nil {
|
||||||
return traceExecOpt(nil)
|
return traceExecOpt(false, nil)
|
||||||
}
|
}
|
||||||
return traceExecOpt(&config.TraceConfig)
|
return traceExecOpt(false, &config.TraceConfig)
|
||||||
}
|
}
|
||||||
func traceExecOpt(config *TraceConfig) (*traceExecOptions, error) {
|
|
||||||
|
type traceExecOptions struct {
|
||||||
|
txTimeout time.Duration
|
||||||
|
reexec uint64
|
||||||
|
parallel bool
|
||||||
|
}
|
||||||
|
|
||||||
|
func traceExecOpt(allowParallelTx bool, config *TraceConfig) (*traceExecOptions, error) {
|
||||||
opt := &traceExecOptions{
|
opt := &traceExecOptions{
|
||||||
defaultTraceTimeout,
|
defaultTraceTimeout,
|
||||||
defaultTraceReexec,
|
defaultTraceReexec,
|
||||||
|
|
@ -828,7 +828,7 @@ func traceExecOpt(config *TraceConfig) (*traceExecOptions, error) {
|
||||||
// JS tracers have high overhead. In this case run a parallel
|
// JS tracers have high overhead. In this case run a parallel
|
||||||
// process that generates states in one thread and traces txes
|
// process that generates states in one thread and traces txes
|
||||||
// in separate worker threads.
|
// in separate worker threads.
|
||||||
opt.parallel = config.Tracer != nil && *config.Tracer != "" && DefaultDirectory.IsJS(*config.Tracer)
|
opt.parallel = allowParallelTx && config.Tracer != nil && *config.Tracer != "" && DefaultDirectory.IsJS(*config.Tracer)
|
||||||
}
|
}
|
||||||
return opt, nil
|
return opt, nil
|
||||||
}
|
}
|
||||||
|
|
@ -964,7 +964,7 @@ func (api *API) TraceTransaction(ctx context.Context, hash common.Hash, config *
|
||||||
if blockNumber == 0 {
|
if blockNumber == 0 {
|
||||||
return nil, errors.New("genesis is not traceable")
|
return nil, errors.New("genesis is not traceable")
|
||||||
}
|
}
|
||||||
opt, err := traceExecOpt(config)
|
opt, err := traceExecOpt(false, config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue