You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently the JSON-RPC relay relies too much on the logic for fallback gas estimations instead of properly preparing and sending eth_estimateGas requests to the mirror node. At the same time, we want to rethrow errors from the mirror node in case of contract reverts to give the user feedback about failed contract calls/creations, because popular tools (e.g., hardhat) rely on the eth_estimateGas method to retrieve a revert reason for failed transactions.
With the current logic which relies on the fallback estimations, this is really hard to implement, because the only way to do it is to compare the error message we receive from the mirror node with every possible error that is possible to be thrown from contract reverts. Obviously, this is not the way we want this to work,
Steps to reproduce
We can observe in the logs, many requests to the estimate gas endpoint in mirror node fail the validations and the relay opts to the fallback estimations (example logs are given below).
Additional context
Example logs:
[2024-08-20 18:25:24.145 +0000] DEBUG (rpc-server/14667 on hedera-json-rpc-relay-linux-large-nvtx2-4sp7f): [Request ID: 8e1d2f0d-5180-4f89-a736-e34c31f425f9] Validating method parameters for eth_estimateGas, params: [{"value":"0x18cef949392f5e000","to":"0x00000000000000000000000000000000000003ea"}]
[2024-08-20 18:25:24.145 +0000] TRACE (relay-eth/14667 on hedera-json-rpc-relay-linux-large-nvtx2-4sp7f): [Request ID: 8e1d2f0d-5180-4f89-a736-e34c31f425f9] estimateGas(transaction={"value":"0x18cef949392f5e000","to":"0x00000000000000000000000000000000000003ea"}, _blockParam=undefined)
[2024-08-20 18:25:24.154 +0000] DEBUG (mirror-node/14667 on hedera-json-rpc-relay-linux-large-nvtx2-4sp7f): [Request ID: 8e1d2f0d-5180-4f89-a736-e34c31f425f9] [POST] contracts/call Contract Revert: ( StatusCode: '400', StatusText: '', Detail: 'undefined',Data: '{"_status":{"messages":[{"message":"from field must not be empty","detail":"","data":""}]}}')
[2024-08-20 18:25:24.154 +0000] ERROR (relay-eth/14667 on hedera-json-rpc-relay-linux-large-nvtx2-4sp7f): [Request ID: 8e1d2f0d-5180-4f89-a736-e34c31f425f9] Error raised while fetching estimateGas from mirror-node: {"detail":"","data":"","statusCode":400}
[2024-08-20 18:25:24.155 +0000] TRACE (redisCache/14667 on hedera-json-rpc-relay-linux-large-nvtx2-4sp7f): [Request ID: 8e1d2f0d-5180-4f89-a736-e34c31f425f9] returning cached value account_0x00000000000000000000000000000000000003ea:"{\"account\":\"0.0.1002\",\"alias\":null,\"auto_renew_period\":7776000,\"balance\":{\"balance\":798448269546,\"timestamp\":\"1724178111.719078683\",\"tokens\":[{\"token_id\":\"0.0.1041\",\"balance\":99999999990}]},\"created_timestamp\":\"1724178041.158822890\",\"decline_reward\":false,\"deleted\":false,\"ethereum_nonce\":0,\"evm_address\":\"0x00000000000000000000000000000000000003ea\",\"expiry_timestamp\":\"1731954041.158822890\",\"key\":{\"_type\":\"ECDSA_SECP256K1\",\"key\":\"024778141fffe462dbb3817c93e4252b2d6f5f5667fa71f34b84280265c01d408f\"},\"max_automatic_token_associations\":0,\"memo\":\"\",\"pending_reward\":0,\"receiver_sig_required\":false,\"staked_account_id\":null,\"staked_node_id\":null,\"stake_period_start\":null,\"transactions\":[],\"links\":{\"next\":null}}" on eth_estimateGas call
[2024-08-20 18:25:24.155 +0000] WARN (relay-eth/14667 on hedera-json-rpc-relay-linux-large-nvtx2-4sp7f): [Request ID: 8e1d2f0d-5180-4f89-a736-e34c31f425f9] Returning predefined gas for simple transfer: 0x5208
Hedera network
No response
Version
v0.54.2
Operating system
None
The text was updated successfully, but these errors were encountered:
Description
Currently the JSON-RPC relay relies too much on the logic for fallback gas estimations instead of properly preparing and sending
eth_estimateGas
requests to the mirror node. At the same time, we want to rethrow errors from the mirror node in case of contract reverts to give the user feedback about failed contract calls/creations, because popular tools (e.g., hardhat) rely on theeth_estimateGas
method to retrieve a revert reason for failed transactions.With the current logic which relies on the fallback estimations, this is really hard to implement, because the only way to do it is to compare the error message we receive from the mirror node with every possible error that is possible to be thrown from contract reverts. Obviously, this is not the way we want this to work,
Steps to reproduce
We can observe in the logs, many requests to the estimate gas endpoint in mirror node fail the validations and the relay opts to the fallback estimations (example logs are given below).
Additional context
Example logs:
Hedera network
No response
Version
v0.54.2
Operating system
None
The text was updated successfully, but these errors were encountered: