Skip to content
This repository has been archived by the owner on Jan 8, 2025. It is now read-only.

fix: saturate memory offset taken from stack #950

Merged
merged 4 commits into from
Sep 17, 2024

Conversation

enitrat
Copy link
Contributor

@enitrat enitrat commented Sep 16, 2024

Pull Request type

Please check the type of change your PR introduces:

  • Bugfix
  • Feature
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no API changes)
  • Build-related changes
  • Documentation content changes
  • Other (please describe):

What is the current behavior?

Resolves: #

What is the new behavior?

  • In some cases, it was possible that a memory offset taken from the stack was absurdely high, but combined with a null size. In this case, since no memory was modified, no gas was charged for that, and the memory was not resized
  • This ensures that, for these high values, the program doesn't fail with a type execution error - rather, we saturate at the max_usize value, s.t. if size != 0, the memory expansion will create a failure because of a too high cost - and otherwise, the tx will pass.

Does this introduce a breaking change?

  • Yes
  • No

This change is Reviewable

@enitrat
Copy link
Contributor Author

enitrat commented Sep 17, 2024

Failing test will be solved upon rebasing on #949

@enitrat enitrat requested a review from obatirou September 17, 2024 08:22
@enitrat enitrat force-pushed the fix/saturate-memory-offsets branch from cd0bffd to e72474d Compare September 17, 2024 08:34
obatirou
obatirou previously approved these changes Sep 17, 2024
@enitrat enitrat merged commit fed4554 into main Sep 17, 2024
4 checks passed
@enitrat enitrat deleted the fix/saturate-memory-offsets branch September 17, 2024 14:01
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants