Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
JukLee0ira committed Sep 10, 2024
1 parent 9718a79 commit db0f84b
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions internal/ethapi/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -1478,21 +1478,30 @@ func DoEstimateGas(ctx context.Context, b Backend, args TransactionArgs, blockNr

// Reject the transaction as invalid if it still fails at the highest allowance
if hi == cap {
ok, res, err := executable(hi)
ok, result, err := executable(hi)
if err != nil {
return 0, err
}

if !ok {
if res.Err != vm.ErrOutOfGas {
if len(res.ReturnData) > 0 {
return 0, newRevertError(res.ReturnData)
if result != nil && result.Err != vm.ErrOutOfGas {
var revert string
if len(result.Revert()) > 0 {
ret, err := abi.UnpackRevert(result.Revert())
if err != nil {
revert = hexutil.Encode(result.Revert())
} else {
revert = ret
}
}
return 0, estimateGasError{
error: "always failing transaction",
vmerr: result.Err,
revert: revert,
}
return 0, res.Err
}

// Otherwise, the specified gas cap is too low
return 0, fmt.Errorf("gas required exceeds allowance (%d)", cap)
return 0, estimateGasError{error: fmt.Sprintf("gas required exceeds allowance (%d)", cap)}
}
}
return hexutil.Uint64(hi), nil
Expand Down

0 comments on commit db0f84b

Please sign in to comment.