-
Notifications
You must be signed in to change notification settings - Fork 93
feat: removed fallback predefined gas value for eth_estimateGas when failed to retrieve gas estimate from Mirror Node #4678
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
base: main
Are you sure you want to change the base?
Conversation
…led to retrieve gas estimate from Mirror Node Signed-off-by: Logan Nguyen <[email protected]>
Signed-off-by: Logan Nguyen <[email protected]>
Signed-off-by: Logan Nguyen <[email protected]>
Signed-off-by: Logan Nguyen <[email protected]>
Test Results 20 files ±0 274 suites +2 22m 2s ⏱️ +22s Results for commit e090cab. ± Comparison against base commit 2e9648a. This pull request removes 4 and adds 11 tests. Note that renamed tests count towards both.♻️ This comment has been updated with latest results. |
ba724a6 to
73e81bd
Compare
Signed-off-by: Logan Nguyen <[email protected]>
…ACTION Signed-off-by: Logan Nguyen <[email protected]>
Signed-off-by: Logan Nguyen <[email protected]>
…etwork Signed-off-by: Logan Nguyen <[email protected]>
96c154f to
d2ff67c
Compare
| # DEBUG_API_ENABLED: | ||
| # TXPOOL_API_ENABLED: | ||
| # FILTER_API_ENABLED: | ||
| # ESTIMATE_GAS_THROWS: |
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.
Note for reviewers: Since estimateGas no longer falls back to predefined gas and always throws, the ESTIMATE_GAS_THROWS config no longer has any meaningful effect, so it has been removed.
| return this.statusCode === MirrorNodeClientError.ErrorCodes.CONTRACT_REVERT_EXECUTED; | ||
| } | ||
|
|
||
| public isContractRevertOpcodeExecuted() { |
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.
Note for reviewers: These two are now consolidated into a single method, isContractRevert(), which explicitly checks for the error.message === MirrorNodeClientError.messages.CONTRACT_REVERT_EXECUTED instead of falling back to a 400 status code as before, which wasn't accurate since not all 400 errors indicate a contract revert.
| } | ||
|
|
||
| throw predefined.COULD_NOT_ESTIMATE_GAS_PRICE; | ||
| throw predefined.INTERNAL_ERROR('Failed to retrieve gas price from network fees'); |
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.
Note for reviewers: Previously, this was thrown as COULD_NOT_ESTIMATE_GAS_PRICE, which was inaccurate since this method is used for eth_gasPrice, not estimation. I’ve updated it to use INTERNAL_ERROR instead, as reaching this point indicates an unexpected code issue rather than a gas-related problem from the Mirror Node.
| message: `Error occurred during transaction simulation: ${errMessage}`, | ||
| }); | ||
| }, | ||
| COULD_NOT_RETRIEVE_LATEST_BLOCK: new JsonRpcError({ |
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.
Note for reviewers: Renamed to COULD_NOT_SIMULATE_TRANSACTION so it can be used for both eth_estimateGas and eth_call when they encounter issues submitting requests to the Mirror Node’s /call endpoint, which handles transaction simulation under the hood.
Signed-off-by: Logan Nguyen <[email protected]>
d2ff67c to
e090cab
Compare
Codecov Report❌ Patch coverage is
@@ Coverage Diff @@
## main #4678 +/- ##
==========================================
- Coverage 95.47% 95.43% -0.05%
==========================================
Files 129 129
Lines 20928 20859 -69
Branches 1793 1790 -3
==========================================
- Hits 19982 19906 -76
- Misses 926 934 +8
+ Partials 20 19 -1
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 1 file with indirect coverage changes 🚀 New features to boost your workflow:
|
Description
This PR fixes inconsistent error handling in
eth_estimateGasby removing the fallback gas behavior that masked legitimate errors.Problem: Previously, when the Mirror Node returned any error other than
CONTRACT_REVERT_EXECUTED, the Relay would silently return a predefined fallback gas estimate. This hid real errors from users, who would then submit transactions that were guaranteed to fail on-chain.Solution: This PR enables the Relay now properly propagates errors according to industry standards (aligned with Geth, Besu, and major providers):
3(CONTRACT_REVERT)-32000(COULD_NOT_SIMULATE_TRANSACTION)Related issue(s)
Fixes #4459
Testing Guide
Contract revert scenario:
eth_estimateGason a contract function that reverts3and revert messageNon-existent sender account:
eth_estimateGaswith afromaddress that doesn't exist on the network-32000and message containing "Error occurred during transaction simulation"Valid gas estimation:
eth_estimateGaswith valid from/to addresses and valid contract call dataChanges from original design (optional)
Additional work needed (optional)
N/A
Checklist