Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[R4R]-fix: estimate gas evm error #77

Merged
merged 2 commits into from
Apr 15, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion internal/ethapi/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -1326,14 +1326,22 @@ func DoEstimateGas(ctx context.Context, b Backend, args TransactionArgs, blockNr
// Execute the binary search and hone in on an executable gas limit
for lo+1 < hi {
mid := (hi + lo) / 2
failed, _, err := executable(mid)
failed, result, err := executable(mid)

// If the error is not nil(consensus error), it means the provided message
// call or transaction will never be accepted no matter how much gas it is
// assigned. Return the error directly, don't struggle any more.
if err != nil {
return 0, err
}

if result != nil && result.Err != vm.ErrOutOfGas {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if result != nil && !errors.Is(result.Err, vm.ErrOutOfGas) may be better

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

if len(result.Revert()) > 0 {
return 0, newRevertError(result)
}
return 0, result.Err
}

if failed {
lo = mid
} else {
Expand Down
Loading