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.
When calling eth_estimateGas, if the EVM throws an error, it will result in the program throwing an "insufficient funds for gas * price + value" error instead of the correct EVM error.
Cause: When estimating gas in the layer 2, it includes gas cost from the layer 1. This causes a slight shortage when estimating gas using the user's entire balance. Additionally, during the re-estimation process, if an EVM error occurs but is not an out-of-gas error, it will be ignored. This ultimately leads to the entire estimation process failing to correctly throw an EVM error. Therefore, each estimation should include a check for an EVM result. If the result is not empty and not an out-of-gas error, the estimation should be terminated, and an exception should be thrown.
Reproduction steps: Deploy an ERC20 contract and use the transfer function. Test with three different accounts to verify that the ERC20InsufficientBalance error is correctly thrown. The balances of the three accounts are 0 MNT, 0.1 MNT, and 1000 MNT, respectively.