Skip to content
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

[EVM] Meaningful error message for eth_call balance override overflow #1783

Merged
merged 2 commits into from
Jul 26, 2024

Conversation

jewei1997
Copy link
Contributor

@jewei1997 jewei1997 commented Jul 25, 2024

Describe your changes and provide context

If a user calls eth_call with a very high balance override, it isn't possible for us to actually set that address to uint256 max due to how our usei, wei logic works as well as a constraint we have that any intermediate balance must have at most 256 bits.

Specifically, when we set balances in the statedb, we need to set so that the usei balance * 10^12 + 10^12 is less than uint256 max. However, there is no integer such that usei balance * 10^12 + 10^12 == uint256 max, so if the user wanted to actually do a balance override to uint256 max, we are not able to do so.

Therefore, the best can do is produce a meaningful error message when the balance overflows.

Testing performed to validate your change

unit test

Copy link

codecov bot commented Jul 25, 2024

Codecov Report

Attention: Patch coverage is 57.14286% with 3 lines in your changes missing coverage. Please review.

Project coverage is 61.25%. Comparing base (0812c51) to head (83b6a20).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1783      +/-   ##
==========================================
- Coverage   61.38%   61.25%   -0.13%     
==========================================
  Files         257      257              
  Lines       22272    22279       +7     
==========================================
- Hits        13672    13648      -24     
- Misses       7639     7672      +33     
+ Partials      961      959       -2     
Files Coverage Δ
evmrpc/simulate.go 64.53% <57.14%> (-0.19%) ⬇️

... and 4 files with indirect coverage changes

@jewei1997 jewei1997 merged commit 7574464 into main Jul 26, 2024
47 of 48 checks passed
@jewei1997 jewei1997 deleted the eth-call-infinite-balance-override-main branch July 26, 2024 12:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants