Skip to content

YulUtilFunctions: assert combined byte slice extent in updateByteSliceFunction#16753

Open
msooseth wants to merge 1 commit into
developfrom
yulutilfunctions-update-byte-slice-combined-assert
Open

YulUtilFunctions: assert combined byte slice extent in updateByteSliceFunction#16753
msooseth wants to merge 1 commit into
developfrom
yulutilfunctions-update-byte-slice-combined-assert

Conversation

@msooseth
Copy link
Copy Markdown
Contributor

@msooseth msooseth commented May 20, 2026

Summary

  • updateByteSliceFunction(_numBytes, _shiftBytes) currently asserts _numBytes <= 32 and _shiftBytes <= 32 independently, but not their combination.
  • The emitted mask ((1 << numBits) - 1) << shiftBits is only well-defined when _numBytes + _shiftBytes <= 32 — otherwise the mask spans bits ≥ 256 and Yul silently truncates it mod 2^256, producing a wrong storage update.
  • All current callers (only updateStorageValueFunction) already respect this invariant, so this is not a current bug — just a guard against future regressions.

Test plan

  • CI builds clean (the change only adds a solAssert next to two existing ones with the same bound).
  • No existing tests should regress since the new assertion is implied by current usage.

…eFunction

The two existing solAsserts bound _numBytes and _shiftBytes individually,
but the emitted mask ((1 << numBits) - 1) << shiftBits is only well-defined
when _numBytes + _shiftBytes <= 32. Add the combined assert as a guard
against future regressions.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant