blockchain: Fix potential overflow in DoEstimateGas#492
Merged
2dvorak merged 1 commit intokaiachain:devfrom Aug 6, 2025
Merged
blockchain: Fix potential overflow in DoEstimateGas#4922dvorak merged 1 commit intokaiachain:devfrom
DoEstimateGas#4922dvorak merged 1 commit intokaiachain:devfrom
Conversation
ian0371
approved these changes
Aug 5, 2025
blukat29
approved these changes
Aug 5, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposed changes
blockchain.DoEstimateGasas reported in eth/gasestimator: fix potential overflow ethereum/go-ethereum#32255.Types of changes
Please put an x in the boxes related to your change.
Checklist
Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.
I have read the CLA Document and I hereby sign the CLAin first time contribute$ make test)Related issues
Further comments
I tried to add test case in
api/api_eth_test.gofor the overflow leading to misbehavior, however it was tricky.gaslimithowever the search could easily find out the correct value if the estimated gas was realistic.Instead I simulated the tx execution that requires very large gas with a something like:
The
blockchain.DoEstimateGasreached timeout without the fix, and returned a very large estimated gas with the fix.However to use the simulated tx execution, I had to bypass actual API functions like
api.EstimateGasand directly callblockchain.DoEstimateGas. That make the test case irrelevant to API test. So I did not include the test case in this PR. Also I didn't feel like adding a new test function for theblockchain.DoEstimateGasitself (e.g., createblockchain/evm_test.go).If you're interested, here's the test case:
diff