mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-25 06:06:44 +00:00
add panic catch in TraceTransaction (#41)
* add panic catch in TraceTransaction * fix * fix * fix
This commit is contained in:
parent
aac6bf6d09
commit
21ee50facc
1 changed files with 15 additions and 3 deletions
|
|
@ -829,7 +829,13 @@ func containsTx(block *types.Block, hash common.Hash) bool {
|
||||||
|
|
||||||
// TraceTransaction returns the structured logs created during the execution of EVM
|
// TraceTransaction returns the structured logs created during the execution of EVM
|
||||||
// and returns them as a JSON object.
|
// and returns them as a JSON object.
|
||||||
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) (value interface{}, returnErr error) {
|
||||||
|
defer func() {
|
||||||
|
if r := recover(); r != nil {
|
||||||
|
value = nil
|
||||||
|
returnErr = fmt.Errorf("panic occurred: %v, could not trace tx: %s", r, hash.Hex())
|
||||||
|
}
|
||||||
|
}()
|
||||||
tx, blockHash, blockNumber, index, err := api.backend.GetTransaction(ctx, hash)
|
tx, blockHash, blockNumber, index, err := api.backend.GetTransaction(ctx, hash)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
@ -876,7 +882,13 @@ func (api *API) TraceTransaction(ctx context.Context, hash common.Hash, config *
|
||||||
// after executing the specified block. However, if a transaction index is provided,
|
// after executing the specified block. However, if a transaction index is provided,
|
||||||
// the trace will be conducted on the state after executing the specified transaction
|
// the trace will be conducted on the state after executing the specified transaction
|
||||||
// within the specified block.
|
// within the specified block.
|
||||||
func (api *API) TraceCall(ctx context.Context, args ethapi.TransactionArgs, blockNrOrHash rpc.BlockNumberOrHash, config *TraceCallConfig) (interface{}, error) {
|
func (api *API) TraceCall(ctx context.Context, args ethapi.TransactionArgs, blockNrOrHash rpc.BlockNumberOrHash, config *TraceCallConfig) (value interface{}, returnErr error) {
|
||||||
|
defer func() {
|
||||||
|
if r := recover(); r != nil {
|
||||||
|
value = nil
|
||||||
|
returnErr = fmt.Errorf("panic occurred: %v, could not trace tx: %s", r, args.ToTransaction().Hash().Hex())
|
||||||
|
}
|
||||||
|
}()
|
||||||
// Try to retrieve the specified block
|
// Try to retrieve the specified block
|
||||||
var (
|
var (
|
||||||
err error
|
err error
|
||||||
|
|
@ -955,7 +967,7 @@ func (api *API) traceTx(ctx context.Context, tx *types.Transaction, message *cor
|
||||||
defer func() {
|
defer func() {
|
||||||
if r := recover(); r != nil {
|
if r := recover(); r != nil {
|
||||||
value = nil
|
value = nil
|
||||||
returnErr = fmt.Errorf("panic occured: %v, could not trace tx: %s", r, tx.Hash())
|
returnErr = fmt.Errorf("panic occurred: %v, could not trace tx: %s", r, tx.Hash())
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
if config == nil {
|
if config == nil {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue