Skip to content

Clarify the direction of offset in storage regions #307

Description

@djolertrk

The segment schema says offset: 0 means the segment "begins at the start of the specified slot", but not whether that's the most or the least significant byte.

The reference implementation (packages/pointers/src/read.ts) slices the word from byte 0, i.e. the most significant byte, and a length that runs past the slot continues into the next one, which also only makes sense that way.

Solidity's storage layout counts from the other end (packed values are "lower-order aligned"), so solc has to convert its offsets when emitting
pointers. This came up in review of that code because the schema text doesn't settle it. It would help if the description said explicitly that offset counts from the most significant byte, ideally with a packed example like a uint8 in the last byte at "offset": 31.

See this for the context: argotorg/solidity#16990 (comment)

cc @cameel @gnidan

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions