Skip to content

Conversation

yash-atreya
Copy link
Member

@yash-atreya yash-atreya commented Aug 29, 2025

Motivation

towards #3869

Solution

Example JSON output
   "stateDiff": {
      "0x0000000000000000000000000000000000000000000000000000000000000001": {
        "previousValue": "0x0000000000000000000000000000000000000000000000000000000000000000",
        "newValue": "0x00000000000000000000000000000000000000000000000000000000000000c7",
        "label": "longString",
        "type": "string",
        "offset": 0,
        "slot": "1",
        "members": [
          {
            "label": "longString[0]",
            "type": "string",
            "offset": 0,
            "slot": "80084422859880547211683076133703299733277748156566366325829078699459944778998"
          },
          {
            "label": "longString[1]",
            "type": "string",
            "offset": 0,
            "slot": "80084422859880547211683076133703299733277748156566366325829078699459944778999"
          },
          {
            "label": "longString[2]",
            "type": "string",
            "offset": 0,
            "slot": "80084422859880547211683076133703299733277748156566366325829078699459944779000"
          },
          {
            "label": "longString[3]",
            "type": "string",
            "offset": 0,
            "slot": "80084422859880547211683076133703299733277748156566366325829078699459944779001"
          }
        ],
        "decoded": {
          "previousValue": "",
          "newValue": "This is a very long string that exceeds 32 bytes and will be stored differently in Solidity storage"
        }
      },
      "0xb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf6": {
        "previousValue": "0x0000000000000000000000000000000000000000000000000000000000000000",
        "newValue": "0x5468697320697320612076657279206c6f6e6720737472696e67207468617420",
        "label": "longString[0]",
        "type": "string",
        "offset": 0,
        "slot": "80084422859880547211683076133703299733277748156566366325829078699459944778998",
        "decoded": {
          "previousValue": "0x0000000000000000000000000000000000000000000000000000000000000000",
          "newValue": "0x5468697320697320612076657279206c6f6e6720737472696e67207468617420"
        }
      },
      "0xb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf7": {
        "previousValue": "0x0000000000000000000000000000000000000000000000000000000000000000",
        "newValue": "0x6578636565647320333220627974657320616e642077696c6c2062652073746f",
        "label": "longString[1]",
        "type": "string",
        "offset": 0,
        "slot": "80084422859880547211683076133703299733277748156566366325829078699459944778999",
        "decoded": {
          "previousValue": "0x0000000000000000000000000000000000000000000000000000000000000000",
          "newValue": "0x6578636565647320333220627974657320616e642077696c6c2062652073746f"
        }
      },
      "0xb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf8": {
        "previousValue": "0x0000000000000000000000000000000000000000000000000000000000000000",
        "newValue": "0x72656420646966666572656e746c7920696e20536f6c69646974792073746f72",
        "label": "longString[2]",
        "type": "string",
        "offset": 0,
        "slot": "80084422859880547211683076133703299733277748156566366325829078699459944779000",
        "decoded": {
          "previousValue": "0x0000000000000000000000000000000000000000000000000000000000000000",
          "newValue": "0x72656420646966666572656e746c7920696e20536f6c69646974792073746f72"
        }
      },
      "0xb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf9": {
        "previousValue": "0x0000000000000000000000000000000000000000000000000000000000000000",
        "newValue": "0x6167650000000000000000000000000000000000000000000000000000000000",
        "label": "longString[3]",
        "type": "string",
        "offset": 0,
        "slot": "80084422859880547211683076133703299733277748156566366325829078699459944779001",
        "decoded": {
          "previousValue": "0x0000000000000000000000000000000000000000000000000000000000000000",
          "newValue": "0x6167650000000000000000000000000000000000000000000000000000000000"
        }
      }
    }

PR Checklist

  • Added Tests
  • Added Documentation
  • Breaking changes

@yash-atreya yash-atreya self-assigned this Sep 1, 2025
@yash-atreya yash-atreya moved this to In Progress in Foundry Sep 1, 2025
@yash-atreya yash-atreya moved this from In Progress to Ready For Review in Foundry Sep 2, 2025
@yash-atreya yash-atreya marked this pull request as ready for review September 2, 2025 13:11
@zerosnacks zerosnacks self-requested a review September 4, 2025 13:52
zerosnacks
zerosnacks previously approved these changes Sep 4, 2025
Copy link
Collaborator

@grandizzy grandizzy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good, left some comments / nits, pls check

Copy link
Collaborator

@grandizzy grandizzy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

@yash-atreya yash-atreya merged commit 1b3b9b4 into master Sep 8, 2025
23 checks passed
@yash-atreya yash-atreya deleted the yash/decode-bytes-strings-state-diffs branch September 8, 2025 11:12
@github-project-automation github-project-automation bot moved this from Ready For Review to Done in Foundry Sep 8, 2025
@grandizzy grandizzy added this to the v1.4.0 milestone Sep 8, 2025
@grandizzy grandizzy moved this from Done to Completed in Foundry Sep 8, 2025
MerkleBoy pushed a commit to MerkleBoy/foundry that referenced this pull request Sep 17, 2025
…undry-rs#11476)

* feat(common): identify bytes and string slots using storageLayout

* fmt

* clippy

* aggregate and decode bytes and strings

* cleanup

* nits

* clippy

* fmt

* nit

* cleanup

* identify the slots using the length of data in base slot value

* nit

* fix

* fix mapping identification

* nit

* fmt

* nit

* Update crates/common/src/slot_identifier.rs

* Update crates/common/src/slot_identifier.rs

* cleanup: slot_identifier

* cleanup

* nit

---------

Co-authored-by: zerosnacks <95942363+zerosnacks@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Completed
Development

Successfully merging this pull request may close these issues.

3 participants