Skip to content

Commit

Permalink
Merge pull request #36 from 0xPolygonHermez/feature/err-info
Browse files Browse the repository at this point in the history
print error data for calls to estimate gas
  • Loading branch information
dpunish3r authored May 23, 2024
2 parents 9b73f0b + b850b0c commit de59b1d
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions ethtxmanager/ethtxmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto/kzg4844"
"github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/rpc"
"github.com/holiman/uint256"
)

Expand Down Expand Up @@ -232,6 +233,9 @@ func (c *Client) Add(ctx context.Context, to *common.Address, forcedNonce *uint6
// get gas
gas, err = c.etherman.EstimateGasBlobTx(ctx, c.from, to, gasPrice, gasTipCap, value, data)
if err != nil {
if de, ok := err.(rpc.DataError); ok {
err = fmt.Errorf("%w (%v)", err, de.ErrorData())
}
err := fmt.Errorf("failed to estimate gas blob tx: %w, data: %v", err, common.Bytes2Hex(data))
log.Error(err.Error())
log.Debugf("failed to estimate gas for blob tx: from: %v, to: %v, value: %v", c.from.String(), to.String(), value.String())
Expand All @@ -248,6 +252,9 @@ func (c *Client) Add(ctx context.Context, to *common.Address, forcedNonce *uint6
// get gas
gas, err = c.etherman.EstimateGas(ctx, c.from, to, value, data)
if err != nil {
if de, ok := err.(rpc.DataError); ok {
err = fmt.Errorf("%w (%v)", err, de.ErrorData())
}
err := fmt.Errorf("failed to estimate gas: %w, data: %v", err, common.Bytes2Hex(data))
log.Error(err.Error())
log.Debugf("failed to estimate gas for tx: from: %v, to: %v, value: %v", c.from.String(), to.String(), value.String())
Expand Down Expand Up @@ -814,13 +821,19 @@ func (c *Client) reviewMonitoredTx(ctx context.Context, mTx *monitoredTx, mTxLog

gas, err = c.etherman.EstimateGasBlobTx(ctx, mTx.From, mTx.To, mTx.GasPrice, mTx.GasTipCap, mTx.Value, mTx.Data)
if err != nil {
if de, ok := err.(rpc.DataError); ok {
err = fmt.Errorf("%w (%v)", err, de.ErrorData())
}
err := fmt.Errorf("failed to estimate gas blob tx: %w", err)
mTxLogger.Errorf(err.Error())
return err
}
} else {
gas, err = c.etherman.EstimateGas(ctx, mTx.From, mTx.To, mTx.Value, mTx.Data)
if err != nil {
if de, ok := err.(rpc.DataError); ok {
err = fmt.Errorf("%w (%v)", err, de.ErrorData())
}
err := fmt.Errorf("failed to estimate gas: %w", err)
mTxLogger.Errorf(err.Error())
return err
Expand Down

0 comments on commit de59b1d

Please sign in to comment.