mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-10 22:13:47 +00:00
chg : fix derference error on config without borTraceEnabled
This commit is contained in:
parent
7554a16c4f
commit
2f648fb91c
1 changed files with 40 additions and 7 deletions
|
|
@ -65,6 +65,8 @@ const (
|
||||||
defaultTracechainMemLimit = common.StorageSize(500 * 1024 * 1024)
|
defaultTracechainMemLimit = common.StorageSize(500 * 1024 * 1024)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var defaultBorTraceEnabled = newBoolPtr(false)
|
||||||
|
|
||||||
// Backend interface provides the common API services (that are provided by
|
// Backend interface provides the common API services (that are provided by
|
||||||
// both full and light clients) with access to necessary functions.
|
// both full and light clients) with access to necessary functions.
|
||||||
type Backend interface {
|
type Backend interface {
|
||||||
|
|
@ -269,10 +271,13 @@ func (api *API) TraceChain(ctx context.Context, start, end rpc.BlockNumber, conf
|
||||||
func (api *API) traceChain(ctx context.Context, start, end *types.Block, config *TraceConfig) (*rpc.Subscription, error) {
|
func (api *API) traceChain(ctx context.Context, start, end *types.Block, config *TraceConfig) (*rpc.Subscription, error) {
|
||||||
if config == nil {
|
if config == nil {
|
||||||
config = &TraceConfig{
|
config = &TraceConfig{
|
||||||
BorTraceEnabled: newBoolPtr(false),
|
BorTraceEnabled: defaultBorTraceEnabled,
|
||||||
BorTx: newBoolPtr(false),
|
BorTx: newBoolPtr(false),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if config.BorTraceEnabled == nil {
|
||||||
|
config.BorTraceEnabled = defaultBorTraceEnabled
|
||||||
|
}
|
||||||
// Tracing a chain is a **long** operation, only do with subscriptions
|
// Tracing a chain is a **long** operation, only do with subscriptions
|
||||||
notifier, supported := rpc.NotifierFromContext(ctx)
|
notifier, supported := rpc.NotifierFromContext(ctx)
|
||||||
if !supported {
|
if !supported {
|
||||||
|
|
@ -308,6 +313,10 @@ func (api *API) traceChain(ctx context.Context, start, end *types.Block, config
|
||||||
blockCtx := core.NewEVMBlockContext(task.block.Header(), api.chainContext(localctx), nil)
|
blockCtx := core.NewEVMBlockContext(task.block.Header(), api.chainContext(localctx), nil)
|
||||||
// Trace all the transactions contained within
|
// Trace all the transactions contained within
|
||||||
txs, stateSyncPresent := api.getAllBlockTransactions(ctx, task.block)
|
txs, stateSyncPresent := api.getAllBlockTransactions(ctx, task.block)
|
||||||
|
if !*config.BorTraceEnabled && stateSyncPresent {
|
||||||
|
txs = txs[:len(txs)-1]
|
||||||
|
stateSyncPresent = false
|
||||||
|
}
|
||||||
for i, tx := range txs {
|
for i, tx := range txs {
|
||||||
msg, _ := tx.AsMessage(signer, task.block.BaseFee())
|
msg, _ := tx.AsMessage(signer, task.block.BaseFee())
|
||||||
txctx := &Context{
|
txctx := &Context{
|
||||||
|
|
@ -324,8 +333,6 @@ func (api *API) traceChain(ctx context.Context, start, end *types.Block, config
|
||||||
if *config.BorTraceEnabled {
|
if *config.BorTraceEnabled {
|
||||||
config.BorTx = newBoolPtr(true)
|
config.BorTx = newBoolPtr(true)
|
||||||
res, err = api.traceTx(localctx, msg, txctx, blockCtx, task.statedb, config)
|
res, err = api.traceTx(localctx, msg, txctx, blockCtx, task.statedb, config)
|
||||||
} else {
|
|
||||||
break
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
res, err = api.traceTx(localctx, msg, txctx, blockCtx, task.statedb, config)
|
res, err = api.traceTx(localctx, msg, txctx, blockCtx, task.statedb, config)
|
||||||
|
|
@ -567,10 +574,13 @@ func prepareCallMessage(msg core.Message) statefull.Callmsg {
|
||||||
func (api *API) IntermediateRoots(ctx context.Context, hash common.Hash, config *TraceConfig) ([]common.Hash, error) {
|
func (api *API) IntermediateRoots(ctx context.Context, hash common.Hash, config *TraceConfig) ([]common.Hash, error) {
|
||||||
if config == nil {
|
if config == nil {
|
||||||
config = &TraceConfig{
|
config = &TraceConfig{
|
||||||
BorTraceEnabled: newBoolPtr(false),
|
BorTraceEnabled: defaultBorTraceEnabled,
|
||||||
BorTx: newBoolPtr(false),
|
BorTx: newBoolPtr(false),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if config.BorTraceEnabled == nil {
|
||||||
|
config.BorTraceEnabled = defaultBorTraceEnabled
|
||||||
|
}
|
||||||
|
|
||||||
block, _ := api.blockByHash(ctx, hash)
|
block, _ := api.blockByHash(ctx, hash)
|
||||||
if block == nil {
|
if block == nil {
|
||||||
|
|
@ -669,10 +679,13 @@ func (api *API) traceBlock(ctx context.Context, block *types.Block, config *Trac
|
||||||
|
|
||||||
if config == nil {
|
if config == nil {
|
||||||
config = &TraceConfig{
|
config = &TraceConfig{
|
||||||
BorTraceEnabled: newBoolPtr(false),
|
BorTraceEnabled: defaultBorTraceEnabled,
|
||||||
BorTx: newBoolPtr(false),
|
BorTx: newBoolPtr(false),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if config.BorTraceEnabled == nil {
|
||||||
|
config.BorTraceEnabled = defaultBorTraceEnabled
|
||||||
|
}
|
||||||
|
|
||||||
if block.NumberU64() == 0 {
|
if block.NumberU64() == 0 {
|
||||||
return nil, errors.New("genesis is not traceable")
|
return nil, errors.New("genesis is not traceable")
|
||||||
|
|
@ -779,7 +792,12 @@ func (api *API) traceBlock(ctx context.Context, block *types.Block, config *Trac
|
||||||
if failed != nil {
|
if failed != nil {
|
||||||
return nil, failed
|
return nil, failed
|
||||||
}
|
}
|
||||||
return results, nil
|
|
||||||
|
if !*config.BorTraceEnabled && stateSyncPresent {
|
||||||
|
return results[:len(results)-1], nil
|
||||||
|
} else {
|
||||||
|
return results, nil
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// standardTraceBlockToFile configures a new tracer which uses standard JSON output,
|
// standardTraceBlockToFile configures a new tracer which uses standard JSON output,
|
||||||
|
|
@ -939,10 +957,14 @@ func (api *API) containsTx(ctx context.Context, block *types.Block, hash common.
|
||||||
func (api *API) TraceTransaction(ctx context.Context, hash common.Hash, config *TraceConfig) (interface{}, error) {
|
func (api *API) TraceTransaction(ctx context.Context, hash common.Hash, config *TraceConfig) (interface{}, error) {
|
||||||
if config == nil {
|
if config == nil {
|
||||||
config = &TraceConfig{
|
config = &TraceConfig{
|
||||||
BorTraceEnabled: newBoolPtr(false),
|
BorTraceEnabled: defaultBorTraceEnabled,
|
||||||
BorTx: newBoolPtr(false),
|
BorTx: newBoolPtr(false),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if config.BorTraceEnabled == nil {
|
||||||
|
config.BorTraceEnabled = defaultBorTraceEnabled
|
||||||
|
}
|
||||||
|
|
||||||
tx, blockHash, blockNumber, index, err := api.backend.GetTransaction(ctx, hash)
|
tx, blockHash, blockNumber, index, err := api.backend.GetTransaction(ctx, hash)
|
||||||
if tx == nil {
|
if tx == nil {
|
||||||
// For BorTransaction, there will be no trace available
|
// For BorTransaction, there will be no trace available
|
||||||
|
|
@ -1041,6 +1063,17 @@ func (api *API) TraceCall(ctx context.Context, args ethapi.TransactionArgs, bloc
|
||||||
// executes the given message in the provided environment. The return value will
|
// executes the given message in the provided environment. The return value will
|
||||||
// be tracer dependent.
|
// be tracer dependent.
|
||||||
func (api *API) traceTx(ctx context.Context, message core.Message, txctx *Context, vmctx vm.BlockContext, statedb *state.StateDB, config *TraceConfig) (interface{}, error) {
|
func (api *API) traceTx(ctx context.Context, message core.Message, txctx *Context, vmctx vm.BlockContext, statedb *state.StateDB, config *TraceConfig) (interface{}, error) {
|
||||||
|
|
||||||
|
if config == nil {
|
||||||
|
config = &TraceConfig{
|
||||||
|
BorTraceEnabled: defaultBorTraceEnabled,
|
||||||
|
BorTx: newBoolPtr(false),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if config.BorTraceEnabled == nil {
|
||||||
|
config.BorTraceEnabled = defaultBorTraceEnabled
|
||||||
|
}
|
||||||
|
|
||||||
// Assemble the structured logger or the JavaScript tracer
|
// Assemble the structured logger or the JavaScript tracer
|
||||||
var (
|
var (
|
||||||
tracer vm.EVMLogger
|
tracer vm.EVMLogger
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue