mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-25 22:26:42 +00:00
Recover at traceTx
This commit is contained in:
parent
269b0fbc7a
commit
77dfc46606
1 changed files with 13 additions and 14 deletions
|
|
@ -612,20 +612,12 @@ func (api *API) traceBlock(ctx context.Context, block *types.Block, config *Trac
|
||||||
TxHash: tx.Hash(),
|
TxHash: tx.Hash(),
|
||||||
}
|
}
|
||||||
|
|
||||||
func() {
|
res, err := api.traceTx(ctx, tx, msg, txctx, blockCtx, statedb, config)
|
||||||
defer func() {
|
if err != nil {
|
||||||
if r := recover(); r != nil {
|
results[i] = &txTraceResult{TxHash: tx.Hash(), Error: err.Error()}
|
||||||
results[i] = &txTraceResult{TxHash: tx.Hash(), Error: fmt.Sprintf("panic: %v", r)}
|
} else {
|
||||||
}
|
|
||||||
}()
|
|
||||||
|
|
||||||
res, err := api.traceTx(ctx, tx, msg, txctx, blockCtx, statedb, config)
|
|
||||||
if err != nil {
|
|
||||||
results[i] = &txTraceResult{TxHash: tx.Hash(), Error: err.Error()}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
results[i] = &txTraceResult{TxHash: tx.Hash(), Result: res}
|
results[i] = &txTraceResult{TxHash: tx.Hash(), Result: res}
|
||||||
}()
|
}
|
||||||
}
|
}
|
||||||
return results, nil
|
return results, nil
|
||||||
}
|
}
|
||||||
|
|
@ -953,13 +945,20 @@ func (api *API) TraceCall(ctx context.Context, args ethapi.TransactionArgs, bloc
|
||||||
// traceTx configures a new tracer according to the provided configuration, and
|
// traceTx configures a new tracer according to the provided configuration, and
|
||||||
// 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, tx *types.Transaction, message *core.Message, txctx *Context, vmctx vm.BlockContext, statedb vm.StateDB, config *TraceConfig) (interface{}, error) {
|
func (api *API) traceTx(ctx context.Context, tx *types.Transaction, message *core.Message, txctx *Context, vmctx vm.BlockContext, statedb vm.StateDB, config *TraceConfig) (value interface{}, returnErr error) {
|
||||||
|
// Note that traceTx could panic, so we want to catch it and send a generic error message
|
||||||
var (
|
var (
|
||||||
tracer *Tracer
|
tracer *Tracer
|
||||||
err error
|
err error
|
||||||
timeout = defaultTraceTimeout
|
timeout = defaultTraceTimeout
|
||||||
usedGas uint64
|
usedGas uint64
|
||||||
)
|
)
|
||||||
|
defer func() {
|
||||||
|
if r := recover(); r != nil {
|
||||||
|
value = nil
|
||||||
|
returnErr = fmt.Errorf("panic occured: %s, could not trace tx: %s", r, tx.Hash())
|
||||||
|
}
|
||||||
|
}()
|
||||||
if config == nil {
|
if config == nil {
|
||||||
config = &TraceConfig{}
|
config = &TraceConfig{}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue