Closed nhynes closed 9 months ago
Currently the JS and Go compat APIs return a hard-coded amount when asked to estimate gas.
See: https://github.com/oasisprotocol/sapphire-paratime/blob/2ee5b3868f56134e9b6ec2cdb2a87cd0104de0ce/clients/js/src/compat.ts#L171 https://github.com/oasisprotocol/sapphire-paratime/blob/2ee5b3868f56134e9b6ec2cdb2a87cd0104de0ce/clients/go/compat.go#L231
However, the implementation of eth_estimateGas in oasis-web3-gateway seems to have a full implementation.
Need to double check gas estimation works as expected, then re-enable it.
Yes, this is now supported, although for gas estimation will currently always zeroize the sender in order to avoid it being used to bypass access control and potentially exposing secret data through a side channel. The problem is that estimate gas queries are not signed, so you cannot authenticate the caller.
For this reason, when execution fails during gas estimation, the estimate will currently be artifically inflated to account for the fact that access control checks are usually in the front (as otherwise the estimate would be an underestimate most of the time). This is not ideal and needs some more thought.
For this reason, when execution fails during gas estimation, the estimate will currently be artifically inflated to account for the fact that access control checks are usually in the front (as otherwise the estimate would be an underestimate most of the time). This is not ideal and needs some more thought.
I vote this is an okay present day solution.
If you're not using signed queries, and passing explicit authentication to the function (e.g. an EIP-712 signature, username/password, WebAuthN attestation) this will not be a problem.
Description
We would like to use
eth_estimateGas
when possible and return the non-hardcoded amount.