Ignore insufficient funds errors on tracing (#31)

* Ignore insufficient funds errors on tracing

* fix

* do error contains
This commit is contained in:
Jeremy Wei 2024-06-13 21:49:02 -04:00 committed by GitHub
parent 2ae2853ed2
commit 67b7bcc379
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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()