-
Notifications
You must be signed in to change notification settings - Fork 21
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
fix(levm): prevent unsafe arithmetic #1095
Merged
Merged
Conversation
This file contains 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
…reum_rust into levm/refactor/db
…reum_rust into levm/refactor/db
…reum_rust into levm/refactor/db
…reum_rust into levm/refactor/db
**Motivation** <!-- Why does this pull request exist? What are its goals? --> - The objective is to run ef tests without panicking, so that they don't interrupt execution. **Description** <!-- A clear and concise general description of the changes this PR introduces --> Some reasons tests panicked: - Trying to resize memory to a very high number that the system doesn't tolerate - This was fixed by just resizing only if the gas limit allows it. The EVM doesn't have a "max" memory size, this max is limited by the gas avaiable. Opcodes that didn't have gas implemented were a problem so I partially implemented gas costs for them, just for their memory expansion cost. - Trying to add with overflow - For this error normal addition was replaced for `checked_add` and returned an error if it overflowed. <!-- Link to issues: Resolves #111, Resolves #222 --> Closes #issue_number --------- Co-authored-by: ilitteri <[email protected]>
ilitteri
reviewed
Nov 14, 2024
ilitteri
reviewed
Nov 14, 2024
ilitteri
reviewed
Nov 14, 2024
ilitteri
approved these changes
Nov 14, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Motivation
The idea is to prevent arithmetic overflows and underflows in the levm code.
Description
Design desitions:
checked_add
and added aConsumedGasOverflow
error.checked_add
and theStackOverflow
errorVM::execute
method I decided to do not raise an error, because the previous behavior was to do not raise errors, so used the saturating functionsInvalidOpcode
errorCloses #1075