-
Notifications
You must be signed in to change notification settings - Fork 2
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
eth_estimateGas
CIP-64 and CIP-66 compatibility
#91
Conversation
8ce472c
to
38f8f25
Compare
38f8f25
to
d8eb5a6
Compare
d33f580
to
8a7081a
Compare
eth_estimateGas
CIP-64 and CIP-66 compatibility
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The diff here looks a bit confusing - basically I just moved the CeloAPI
from the celoapi/backend.go
to the celoapi/api.go
file, and then added the new CeloBackend
implementation in the celoapi/backend.go
file.
8a7081a
to
2833a73
Compare
This commit fixes wrong gas calculation in `eth_estimateGas` calls, when the additional `feeCurrency` parameter is used. The TransactionArgs struct is used in transaction related endpoints like `eth_sendTransaction`, `eth_signTransaction`, `eth_estimateGas` and many more. CIP-64 and CIP-66 transaction types make use of an additional transaction parameter `feeCurrency` and some client libraries are already sending this in the RPC request body, however the remote procedures omitted this during unmarshaling and the value was never passed to the EVM. Now the TransactionArgs struct includes an optional FeeCurrency field for correct unmarshaling, and the field is passed along downstream when constructing EVM messages out of the struct. This e.g. allows gas estimation to consider the different intrinsic gas for transactions paid in non-native token.
2833a73
to
545e43e
Compare
dc37292
to
947fc1c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only nitpicking left. Feel free to change or merge right away.
* rpc: include feeCurrency in transaction-args This commit fixes wrong gas calculation in `eth_estimateGas` calls, when the additional `feeCurrency` parameter is used. The TransactionArgs struct is used in transaction related endpoints like `eth_sendTransaction`, `eth_signTransaction`, `eth_estimateGas` and many more. CIP-64 and CIP-66 transaction types make use of an additional transaction parameter `feeCurrency` and some client libraries are already sending this in the RPC request body, however the remote procedures omitted this during unmarshaling and the value was never passed to the EVM. Now the TransactionArgs struct includes an optional FeeCurrency field for correct unmarshaling, and the field is passed along downstream when constructing EVM messages out of the struct. This e.g. allows gas estimation to consider the different intrinsic gas for transactions paid in non-native token. * Rename celoapi file * Add Backend wrapper for Celo functionality * Make transaction-args CIP-64/66 compatible * Make eth_estimateGas CIP64 and CIP66 compatible * Move error message inside function
* rpc: include feeCurrency in transaction-args This commit fixes wrong gas calculation in `eth_estimateGas` calls, when the additional `feeCurrency` parameter is used. The TransactionArgs struct is used in transaction related endpoints like `eth_sendTransaction`, `eth_signTransaction`, `eth_estimateGas` and many more. CIP-64 and CIP-66 transaction types make use of an additional transaction parameter `feeCurrency` and some client libraries are already sending this in the RPC request body, however the remote procedures omitted this during unmarshaling and the value was never passed to the EVM. Now the TransactionArgs struct includes an optional FeeCurrency field for correct unmarshaling, and the field is passed along downstream when constructing EVM messages out of the struct. This e.g. allows gas estimation to consider the different intrinsic gas for transactions paid in non-native token. * Rename celoapi file * Add Backend wrapper for Celo functionality * Make transaction-args CIP-64/66 compatible * Make eth_estimateGas CIP64 and CIP66 compatible * Move error message inside function
* rpc: include feeCurrency in transaction-args This commit fixes wrong gas calculation in `eth_estimateGas` calls, when the additional `feeCurrency` parameter is used. The TransactionArgs struct is used in transaction related endpoints like `eth_sendTransaction`, `eth_signTransaction`, `eth_estimateGas` and many more. CIP-64 and CIP-66 transaction types make use of an additional transaction parameter `feeCurrency` and some client libraries are already sending this in the RPC request body, however the remote procedures omitted this during unmarshaling and the value was never passed to the EVM. Now the TransactionArgs struct includes an optional FeeCurrency field for correct unmarshaling, and the field is passed along downstream when constructing EVM messages out of the struct. This e.g. allows gas estimation to consider the different intrinsic gas for transactions paid in non-native token. * Rename celoapi file * Add Backend wrapper for Celo functionality * Make transaction-args CIP-64/66 compatible * Make eth_estimateGas CIP64 and CIP66 compatible * Move error message inside function
* rpc: include feeCurrency in transaction-args This commit fixes wrong gas calculation in `eth_estimateGas` calls, when the additional `feeCurrency` parameter is used. The TransactionArgs struct is used in transaction related endpoints like `eth_sendTransaction`, `eth_signTransaction`, `eth_estimateGas` and many more. CIP-64 and CIP-66 transaction types make use of an additional transaction parameter `feeCurrency` and some client libraries are already sending this in the RPC request body, however the remote procedures omitted this during unmarshaling and the value was never passed to the EVM. Now the TransactionArgs struct includes an optional FeeCurrency field for correct unmarshaling, and the field is passed along downstream when constructing EVM messages out of the struct. This e.g. allows gas estimation to consider the different intrinsic gas for transactions paid in non-native token. * Rename celoapi file * Add Backend wrapper for Celo functionality * Make transaction-args CIP-64/66 compatible * Make eth_estimateGas CIP64 and CIP66 compatible * Move error message inside function
* rpc: include feeCurrency in transaction-args This commit fixes wrong gas calculation in `eth_estimateGas` calls, when the additional `feeCurrency` parameter is used. The TransactionArgs struct is used in transaction related endpoints like `eth_sendTransaction`, `eth_signTransaction`, `eth_estimateGas` and many more. CIP-64 and CIP-66 transaction types make use of an additional transaction parameter `feeCurrency` and some client libraries are already sending this in the RPC request body, however the remote procedures omitted this during unmarshaling and the value was never passed to the EVM. Now the TransactionArgs struct includes an optional FeeCurrency field for correct unmarshaling, and the field is passed along downstream when constructing EVM messages out of the struct. This e.g. allows gas estimation to consider the different intrinsic gas for transactions paid in non-native token. * Rename celoapi file * Add Backend wrapper for Celo functionality * Make transaction-args CIP-64/66 compatible * Make eth_estimateGas CIP64 and CIP66 compatible * Move error message inside function
* rpc: include feeCurrency in transaction-args This commit fixes wrong gas calculation in `eth_estimateGas` calls, when the additional `feeCurrency` parameter is used. The TransactionArgs struct is used in transaction related endpoints like `eth_sendTransaction`, `eth_signTransaction`, `eth_estimateGas` and many more. CIP-64 and CIP-66 transaction types make use of an additional transaction parameter `feeCurrency` and some client libraries are already sending this in the RPC request body, however the remote procedures omitted this during unmarshaling and the value was never passed to the EVM. Now the TransactionArgs struct includes an optional FeeCurrency field for correct unmarshaling, and the field is passed along downstream when constructing EVM messages out of the struct. This e.g. allows gas estimation to consider the different intrinsic gas for transactions paid in non-native token. * Rename celoapi file * Add Backend wrapper for Celo functionality * Make transaction-args CIP-64/66 compatible * Make eth_estimateGas CIP64 and CIP66 compatible * Move error message inside function
* rpc: include feeCurrency in transaction-args This commit fixes wrong gas calculation in `eth_estimateGas` calls, when the additional `feeCurrency` parameter is used. The TransactionArgs struct is used in transaction related endpoints like `eth_sendTransaction`, `eth_signTransaction`, `eth_estimateGas` and many more. CIP-64 and CIP-66 transaction types make use of an additional transaction parameter `feeCurrency` and some client libraries are already sending this in the RPC request body, however the remote procedures omitted this during unmarshaling and the value was never passed to the EVM. Now the TransactionArgs struct includes an optional FeeCurrency field for correct unmarshaling, and the field is passed along downstream when constructing EVM messages out of the struct. This e.g. allows gas estimation to consider the different intrinsic gas for transactions paid in non-native token. * Rename celoapi file * Add Backend wrapper for Celo functionality * Make transaction-args CIP-64/66 compatible * Make eth_estimateGas CIP64 and CIP66 compatible * Move error message inside function
* rpc: include feeCurrency in transaction-args This commit fixes wrong gas calculation in `eth_estimateGas` calls, when the additional `feeCurrency` parameter is used. The TransactionArgs struct is used in transaction related endpoints like `eth_sendTransaction`, `eth_signTransaction`, `eth_estimateGas` and many more. CIP-64 and CIP-66 transaction types make use of an additional transaction parameter `feeCurrency` and some client libraries are already sending this in the RPC request body, however the remote procedures omitted this during unmarshaling and the value was never passed to the EVM. Now the TransactionArgs struct includes an optional FeeCurrency field for correct unmarshaling, and the field is passed along downstream when constructing EVM messages out of the struct. This e.g. allows gas estimation to consider the different intrinsic gas for transactions paid in non-native token. * Rename celoapi file * Add Backend wrapper for Celo functionality * Make transaction-args CIP-64/66 compatible * Make eth_estimateGas CIP64 and CIP66 compatible * Move error message inside function
* rpc: include feeCurrency in transaction-args This commit fixes wrong gas calculation in `eth_estimateGas` calls, when the additional `feeCurrency` parameter is used. The TransactionArgs struct is used in transaction related endpoints like `eth_sendTransaction`, `eth_signTransaction`, `eth_estimateGas` and many more. CIP-64 and CIP-66 transaction types make use of an additional transaction parameter `feeCurrency` and some client libraries are already sending this in the RPC request body, however the remote procedures omitted this during unmarshaling and the value was never passed to the EVM. Now the TransactionArgs struct includes an optional FeeCurrency field for correct unmarshaling, and the field is passed along downstream when constructing EVM messages out of the struct. This e.g. allows gas estimation to consider the different intrinsic gas for transactions paid in non-native token. * Rename celoapi file * Add Backend wrapper for Celo functionality * Make transaction-args CIP-64/66 compatible * Make eth_estimateGas CIP64 and CIP66 compatible * Move error message inside function
* rpc: include feeCurrency in transaction-args This commit fixes wrong gas calculation in `eth_estimateGas` calls, when the additional `feeCurrency` parameter is used. The TransactionArgs struct is used in transaction related endpoints like `eth_sendTransaction`, `eth_signTransaction`, `eth_estimateGas` and many more. CIP-64 and CIP-66 transaction types make use of an additional transaction parameter `feeCurrency` and some client libraries are already sending this in the RPC request body, however the remote procedures omitted this during unmarshaling and the value was never passed to the EVM. Now the TransactionArgs struct includes an optional FeeCurrency field for correct unmarshaling, and the field is passed along downstream when constructing EVM messages out of the struct. This e.g. allows gas estimation to consider the different intrinsic gas for transactions paid in non-native token. * Rename celoapi file * Add Backend wrapper for Celo functionality * Make transaction-args CIP-64/66 compatible * Make eth_estimateGas CIP64 and CIP66 compatible * Move error message inside function
* rpc: include feeCurrency in transaction-args This commit fixes wrong gas calculation in `eth_estimateGas` calls, when the additional `feeCurrency` parameter is used. The TransactionArgs struct is used in transaction related endpoints like `eth_sendTransaction`, `eth_signTransaction`, `eth_estimateGas` and many more. CIP-64 and CIP-66 transaction types make use of an additional transaction parameter `feeCurrency` and some client libraries are already sending this in the RPC request body, however the remote procedures omitted this during unmarshaling and the value was never passed to the EVM. Now the TransactionArgs struct includes an optional FeeCurrency field for correct unmarshaling, and the field is passed along downstream when constructing EVM messages out of the struct. This e.g. allows gas estimation to consider the different intrinsic gas for transactions paid in non-native token. * Rename celoapi file * Add Backend wrapper for Celo functionality * Make transaction-args CIP-64/66 compatible * Make eth_estimateGas CIP64 and CIP66 compatible * Move error message inside function
* rpc: include feeCurrency in transaction-args This commit fixes wrong gas calculation in `eth_estimateGas` calls, when the additional `feeCurrency` parameter is used. The TransactionArgs struct is used in transaction related endpoints like `eth_sendTransaction`, `eth_signTransaction`, `eth_estimateGas` and many more. CIP-64 and CIP-66 transaction types make use of an additional transaction parameter `feeCurrency` and some client libraries are already sending this in the RPC request body, however the remote procedures omitted this during unmarshaling and the value was never passed to the EVM. Now the TransactionArgs struct includes an optional FeeCurrency field for correct unmarshaling, and the field is passed along downstream when constructing EVM messages out of the struct. This e.g. allows gas estimation to consider the different intrinsic gas for transactions paid in non-native token. * Rename celoapi file * Add Backend wrapper for Celo functionality * Make transaction-args CIP-64/66 compatible * Make eth_estimateGas CIP64 and CIP66 compatible * Move error message inside function
* rpc: include feeCurrency in transaction-args This commit fixes wrong gas calculation in `eth_estimateGas` calls, when the additional `feeCurrency` parameter is used. The TransactionArgs struct is used in transaction related endpoints like `eth_sendTransaction`, `eth_signTransaction`, `eth_estimateGas` and many more. CIP-64 and CIP-66 transaction types make use of an additional transaction parameter `feeCurrency` and some client libraries are already sending this in the RPC request body, however the remote procedures omitted this during unmarshaling and the value was never passed to the EVM. Now the TransactionArgs struct includes an optional FeeCurrency field for correct unmarshaling, and the field is passed along downstream when constructing EVM messages out of the struct. This e.g. allows gas estimation to consider the different intrinsic gas for transactions paid in non-native token. * Rename celoapi file * Add Backend wrapper for Celo functionality * Make transaction-args CIP-64/66 compatible * Make eth_estimateGas CIP64 and CIP66 compatible * Move error message inside function
* rpc: include feeCurrency in transaction-args This commit fixes wrong gas calculation in `eth_estimateGas` calls, when the additional `feeCurrency` parameter is used. The TransactionArgs struct is used in transaction related endpoints like `eth_sendTransaction`, `eth_signTransaction`, `eth_estimateGas` and many more. CIP-64 and CIP-66 transaction types make use of an additional transaction parameter `feeCurrency` and some client libraries are already sending this in the RPC request body, however the remote procedures omitted this during unmarshaling and the value was never passed to the EVM. Now the TransactionArgs struct includes an optional FeeCurrency field for correct unmarshaling, and the field is passed along downstream when constructing EVM messages out of the struct. This e.g. allows gas estimation to consider the different intrinsic gas for transactions paid in non-native token. * Rename celoapi file * Add Backend wrapper for Celo functionality * Make transaction-args CIP-64/66 compatible * Make eth_estimateGas CIP64 and CIP66 compatible * Move error message inside function
* rpc: include feeCurrency in transaction-args This commit fixes wrong gas calculation in `eth_estimateGas` calls, when the additional `feeCurrency` parameter is used. The TransactionArgs struct is used in transaction related endpoints like `eth_sendTransaction`, `eth_signTransaction`, `eth_estimateGas` and many more. CIP-64 and CIP-66 transaction types make use of an additional transaction parameter `feeCurrency` and some client libraries are already sending this in the RPC request body, however the remote procedures omitted this during unmarshaling and the value was never passed to the EVM. Now the TransactionArgs struct includes an optional FeeCurrency field for correct unmarshaling, and the field is passed along downstream when constructing EVM messages out of the struct. This e.g. allows gas estimation to consider the different intrinsic gas for transactions paid in non-native token. * Rename celoapi file * Add Backend wrapper for Celo functionality * Make transaction-args CIP-64/66 compatible * Make eth_estimateGas CIP64 and CIP66 compatible * Move error message inside function
What was the issue?
This fixes wrong gas calculation in
eth_estimateGas
calls, when the additionalfeeCurrency
parameter is used.The TransactionArgs struct is used in transaction related endpoints like
eth_sendTransaction
,eth_signTransaction
,eth_estimateGas
and many more.CIP-64 and CIP-66 transaction types make use of an additional transaction parameter
feeCurrency
and some client libraries are already sending this in the RPC request body, however the remote procedures omitted this during unmarshalling and the value was never passed to the EVM.Additionally, the
TransactionArgs
to EVMMessage
conversion was not compatible with fee-currency conversion yet (see #109) and currency-conversion of internal checks against e.g. thebase-fee
were missing. Similarly, the binary-search-like gas-estimation algorithm did not consider the fee currency conversion during determining upper-bounds of the search-space.What this PR implements
ethapi.Backend
wrapperethapi.CeloBackend
is implemented that extends the original with some Celo-specific methods. The initial implementation (celoapi.Backend
) of this wrapped backend has a LRU cache for exchange rates. It is now passed to some RPC services instead of the unwrapped backend.FeeCurrency
field for correct unmarshalling, and the field is passed along downstream when constructing EVM messages out of the struct.This e.g. allows gas estimation to consider the different intrinsic gas for transactions paid in non-native token.
MaxFeeInFeeCurrency
and this field is thus required in order to be converted internally to a CIP-66 transactionThe binary search algorithm inDoEstimate
now simulates CIP-64/66 transactions once without any gas-payment deduction, in order to determine the available fee-currency balance for capping the search-space. This is analogous to the EIP1559/legacy transactions, but since the transactions fee-currency "value" isn't encoded directly as a transaction field (Value
), the full transaction has to be simulated to observe the fee currencies' contract state after applying the transaction.