From 67b7bcc3799b6cfd0694bed93723d270360609b5 Mon Sep 17 00:00:00 2001 From: Jeremy Wei Date: Thu, 13 Jun 2024 21:49:02 -0400 Subject: [PATCH] Ignore insufficient funds errors on tracing (#31) * Ignore insufficient funds errors on tracing * fix * do error contains --- eth/tracers/api.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/eth/tracers/api.go b/eth/tracers/api.go index 0fb6501399..929f41cb0a 100644 --- a/eth/tracers/api.go +++ b/eth/tracers/api.go @@ -25,6 +25,7 @@ import ( "math/big" "os" "runtime" + "strings" "sync" "time" @@ -990,6 +991,10 @@ func (api *API) traceTx(ctx context.Context, tx *types.Transaction, message *cor statedb.SetTxContext(txctx.TxHash, txctx.TxIndex) _, err = core.ApplyTransactionWithEVM(message, api.backend.ChainConfig(), new(core.GasPool).AddGas(message.GasLimit), statedb, vmctx.BlockNumber, txctx.BlockHash, tx, &usedGas, vmenv) if err != nil { + // Due to how our mempool works, a transaction with insufficient funds can be included in a block. For tracing purposes, we should ignore this. + if strings.Contains(err.Error(), core.ErrInsufficientFunds.Error()) { + return json.RawMessage(`{}`), nil + } return nil, fmt.Errorf("tracing failed: %w", err) } return tracer.GetResult()