-
Notifications
You must be signed in to change notification settings - Fork 12
Update eth_estimateGas to correctly handle execution reverts
#303
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
Conversation
WalkthroughThe recent modifications to Changes
Assessment against linked issues
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
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.
Actionable comments posted: 0
Outside diff range and nitpick comments (1)
services/requester/requester.go (1)
Line range hint
667-667: Consider refactoring thegetErrorForCodefunction to improve maintainability. Perhaps using a map or separate smaller functions could help reduce complexity.
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (2)
- services/requester/requester.go (2 hunks)
- tests/web3js/eth_deploy_contract_and_interact_test.js (1 hunks)
Files not summarized due to errors (1)
- tests/web3js/eth_deploy_contract_and_interact_test.js: Error: Server error. Please try again later.
Additional context used
golangci-lint
services/requester/requester.go
561-561: Function 'signAndSend' is too long (82 > 60) (funlen)
667-667: Function 'getErrorForCode' has too many statements (66 > 40) (funlen)
Additional comments not posted (3)
tests/web3js/eth_deploy_contract_and_interact_test.js (2)
176-192: LGTM! Consider adding comments explaining the specific custom error handling during gas estimation.
194-210: LGTM! Consider adding comments explaining the specific assertion error handling during gas estimation.services/requester/requester.go (1)
375-383: LGTM! The changes to handle execution reverts inEstimateGasare aligned with the PR objectives. Consider adding unit tests to cover these new error handling scenarios.
| ) | ||
| } | ||
|
|
||
| // check that revert reason for custom error is correctly returned for gas estimation |
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.
lets create maybe gast estimation test separately, because it feels to me we will have multiple tests with weird cases
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.
You are right. It has become quite large, I must admit. I'll leave it for another PR though.
| // Note that this is not actually consumed in the end. | ||
| // TODO: Consider moving this to `EVM.dryRun`, if we want the | ||
| // fix to also apply for the EVM API, on Cadence side. | ||
| gasConsumed := evmResult.GasConsumed + params.SstoreSentryGasEIP2200 + 1 |
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.
so we removed this because we handle it in the EVM core now?
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.
Yes, exactly, this is done by EVM.dryRun now.
services/requester/requester.go
Outdated
| if evmResult.ErrorCode == evmTypes.ExecutionErrCodeExecutionReverted { | ||
| return 0, errs.NewRevertError(evmResult.ReturnedData) | ||
| } | ||
| return 0, getErrorForCode(evmResult.ErrorCode) |
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.
don't have this function now inside evm core?
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.
Oh, good point, I forgot that it was added 😇
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.
Updated in 2192050
devbugging
left a comment
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.
Nice, left some minor comments. Good work.
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.
Actionable comments posted: 0
Outside diff range and nitpick comments (1)
services/requester/requester.go (1)
Line range hint
559-559: RefactorsignAndSendto reduce complexity and improve maintainability.Consider breaking down the function into smaller, more manageable functions, each handling a specific part of the transaction process. This could improve readability and maintainability.
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- services/requester/requester.go (4 hunks)
Additional context used
golangci-lint
services/requester/requester.go
559-559: Function 'signAndSend' is too long (82 > 60) (funlen)
Additional comments not posted (2)
services/requester/requester.go (2)
373-378: Improved handling of execution reverts inEstimateGasaligns with PR objectives and enhances robustness.
381-381: Simplification of gas consumption calculation appears correct, assuming upstream handling ofSstoreSentryGasEIP2200. Ensure this assumption is verified.Verification successful
The results indicate that the
SstoreSentryGasEIP2200constant was removed as part of a commit that addressed gas estimation failures with SSTORE refunds. This change confirms that the handling ofSstoreSentryGasEIP2200has been intentionally removed and is no longer necessary.
- Commit
6ccd2c6f3bf24edd0c9e776a459cdad293387bcaexplicitly removed the usage ofparams.SstoreSentryGasEIP2200fromservices/requester/requester.go.Thus, the simplification of the gas consumption calculation is valid and does not require the previously included constant.
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify that the upstream changes correctly handle the `SstoreSentryGasEIP2200` case. # Test: Search for handling of `SstoreSentryGasEIP2200` in upstream modules. rg --type go $'SstoreSentryGasEIP2200'Length of output: 37
Script:
#!/bin/bash # Description: Verify if `SstoreSentryGasEIP2200` has been renamed or removed and check for its handling. # Test 1: Search for any definitions or mentions of `SstoreSentryGasEIP2200`. rg 'SstoreSentryGasEIP2200' # Test 2: Search for any gas-related constants or variables that might have replaced `SstoreSentryGasEIP2200`. rg --type go 'Sstore|Gas|EIP2200' # Test 3: Check for any recent changes in the repository that might have affected `SstoreSentryGasEIP2200`. git log -p -G'SstoreSentryGasEIP2200'Length of output: 31320
Closes: #302
Description
Also remove the temporary fix regarding the gas estimation failures for calls that had gas refunds from
SSTOREopcode. This issue was fixed upstream, onEVM.dryRun.For contributor use:
masterbranchFiles changedin the Github PR explorerSummary by CodeRabbit
Refactor
EstimateGasfunction.Bug Fixes