Skip to content

format: add virtual regions for computed values - #411

Draft
gnidan wants to merge 3 commits into
format-define-orderfrom
format-virtual-regions
Draft

gnidan wants to merge 3 commits into
format-define-orderfrom
format-virtual-regions

Conversation

@gnidan

@gnidan gnidan commented Nov 11, 2026 •

Copy link
Copy Markdown
Member

Implements #291.

This adds a region with "location": "virtual" for values that no EVM data location stores, e.g. a variable the optimizer removed. The pointer schema's dispatch does not change: a virtual region is just another region, and dereferencing still yields regions only.

Every region is base fields plus one addressing scheme. Virtual regions use a new third scheme, ethdebug/format/pointer/scheme/fragment: a width-bearing expression supplies the byte space (the expression's value), and optional offset (default 0) and length (default: to the end of the value) address into it. A fragment outside the value's bytes is invalid. The expression is evaluated against the same machine state as the pointer's other regions and may refer only to regions before it. Lookups follow the region's fields, so .offset and .length work and .slot does not; ~read gives the fragment's bytes.

group:
  - name: a
    location: stack
    slot: 2
  - name: x
    location: virtual
    expression:
      ~wordsized:
        ~sum:
          - ~read: a
          - 1

The reference implementation evaluates the expression while it makes the region concrete, keeps the bytes on the concrete region, and fills in the default offset and length; read returns the fragment. A new integration case reads a + 1 and the first 4 bytes of keccak256(a) from a storage variable over a solc trace.

Stacked on #408.

@github-actions

Copy link
Copy Markdown
Contributor
PR Preview Action v1.8.2

QR code for preview link

🚀 View preview at
https://ethdebug.github.io/format/pr-preview/pr-411/

Built to branch gh-pages at 2026-11-11 00:12 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

@gnidan

gnidan commented Nov 11, 2026

Copy link
Copy Markdown
Member Author

@djolertrk @cameel would be curious what you think of this approach to solving #291

This branch has not been deployed

No deployments
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