-
Notifications
You must be signed in to change notification settings - Fork 20k
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
ethclient.EstimateGas
blocktag param
#25001
Labels
Comments
Makes sense to me. Please submit a PR. |
tynes
added a commit
to tynes/go-ethereum
that referenced
this issue
Jun 1, 2022
This commit adds the blocknumber param to the `ethclient`'s gas estimation function. This lets users choose the block number to estimate gas against. If `nil` is passed, then `pending` will be used to preserve existing behavior. Technically, a block tag can be used here but a blocknumber is used for simplicity. Gas estimation takes similar params as `eth_call`, and there are two different functions on the `ethclient` for doing `eth_call` - one by block number and one by block hash. The simulated backend is not updated to take into account the block number parameter, it will still use the pending state. That functionality can be added in the future if desired. Closes ethereum#25001
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Rationale
The ability to pass a block tag with the RPC call
eth_estimateGas
was merged in #21545. This was done to make the RPC spec compliant.The
ethclient
does not have an extra argument to be able to pass through a block tag, so"pending"
is always used.go-ethereum/ethclient/ethclient.go
Line 512 in 8c0c043
go-ethereum/internal/ethapi/api.go
Lines 1116 to 1117 in 8c0c043
For some users of
ethclient
, the difference between"pending"
and"latest"
can result in the gas estimation failing or succeeding. Ideallyethclient.EstimateGas
can be extended to accept an additional block tag argument.This is an API breaking change but fairly simple to fix, passing
nil
should default to"pending"
so that the same behavior is maintained.Implementation
The
bind.ContractBackend
interface will need to be updated as well for it to build.I am willing to finish the implementation if this is considered an acceptable change.
The text was updated successfully, but these errors were encountered: