Skip to content

Commit

Permalink
fix: Add --json flag to checkStorageLayout's forge inspect command (
Browse files Browse the repository at this point in the history
#795)

* WIP: Fix checkStorageLayout script

dumping logs to see what the JSON is

* Add --json flag

* Update checkStorageLayout.sh
  • Loading branch information
nicholaspai authored Dec 9, 2024
1 parent e23fab1 commit a51d56f
Show file tree
Hide file tree
Showing 7 changed files with 1,071 additions and 3 deletions.
6 changes: 3 additions & 3 deletions scripts/checkStorageLayout.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#!/bin/bash

CONTRACTS=("Arbitrum_SpokePool" "Optimism_SpokePool" "Polygon_SpokePool" "Linea_SpokePool" "ZkSync_SpokePool" "Ethereum_SpokePool" "Base_SpokePool" "Mode_SpokePool" "Blast_SpokePool")
CONTRACTS=("Arbitrum_SpokePool" "Optimism_SpokePool" "Polygon_SpokePool" "Linea_SpokePool" "ZkSync_SpokePool" "Ethereum_SpokePool" "Base_SpokePool" "Mode_SpokePool" "Blast_SpokePool" "AlephZero_SpokePool" "Redstone_SpokePool" "Scroll_SpokePool" "WorldChain_SpokePool" "Zora_SpokePool" "PolygonZkEVM_SpokePool")
if [[ "$1" == "--overwrite" ]]; then
for CONTRACT in "${CONTRACTS[@]}"; do
echo "Overwrite flag detected. Creating new storage layout snapshot of the $CONTRACT contract"
forge inspect $CONTRACT storagelayout > ./storage-layouts/temp.$CONTRACT.json
forge inspect $CONTRACT storagelayout --json > ./storage-layouts/temp.$CONTRACT.json
# Delete any astId keys from the file, which seem to change every time the bytecode changes
# and the types object which also contains astId changes. We only care about the size and relative
# location of state variable slots.
Expand All @@ -18,7 +18,7 @@ fi
for CONTRACT in "${CONTRACTS[@]}"; do
echo "Comparing storage layout snapshot of the $CONTRACT contract at ./storage-layouts/$CONTRACT.json with current storage layout"
echo "Created temporary storage layout file at ./storage-layouts/proposed.$CONTRACT.json"
forge inspect $CONTRACT storagelayout > ./storage-layouts/temp.$CONTRACT.json
forge inspect $CONTRACT storagelayout --json > ./storage-layouts/temp.$CONTRACT.json
# Delete any astId keys from the file, which seem to change every time the bytecode changes
# and the types object which also contains astId changes. We only care about the size and relative
# location of state variable slots.
Expand Down
166 changes: 166 additions & 0 deletions storage-layouts/AlephZero_SpokePool.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
{
"storage": [
{
"contract": "contracts/AlephZero_SpokePool.sol:AlephZero_SpokePool",
"label": "_initialized",
"offset": 0,
"slot": "0"
},
{
"contract": "contracts/AlephZero_SpokePool.sol:AlephZero_SpokePool",
"label": "_initializing",
"offset": 1,
"slot": "0"
},
{
"contract": "contracts/AlephZero_SpokePool.sol:AlephZero_SpokePool",
"label": "__gap",
"offset": 0,
"slot": "1"
},
{
"contract": "contracts/AlephZero_SpokePool.sol:AlephZero_SpokePool",
"label": "__gap",
"offset": 0,
"slot": "51"
},
{
"contract": "contracts/AlephZero_SpokePool.sol:AlephZero_SpokePool",
"label": "_status",
"offset": 0,
"slot": "101"
},
{
"contract": "contracts/AlephZero_SpokePool.sol:AlephZero_SpokePool",
"label": "__gap",
"offset": 0,
"slot": "102"
},
{
"contract": "contracts/AlephZero_SpokePool.sol:AlephZero_SpokePool",
"label": "__gap",
"offset": 0,
"slot": "151"
},
{
"contract": "contracts/AlephZero_SpokePool.sol:AlephZero_SpokePool",
"label": "_HASHED_NAME",
"offset": 0,
"slot": "1151"
},
{
"contract": "contracts/AlephZero_SpokePool.sol:AlephZero_SpokePool",
"label": "_HASHED_VERSION",
"offset": 0,
"slot": "1152"
},
{
"contract": "contracts/AlephZero_SpokePool.sol:AlephZero_SpokePool",
"label": "__gap",
"offset": 0,
"slot": "1153"
},
{
"contract": "contracts/AlephZero_SpokePool.sol:AlephZero_SpokePool",
"label": "crossDomainAdmin",
"offset": 0,
"slot": "2153"
},
{
"contract": "contracts/AlephZero_SpokePool.sol:AlephZero_SpokePool",
"label": "withdrawalRecipient",
"offset": 0,
"slot": "2154"
},
{
"contract": "contracts/AlephZero_SpokePool.sol:AlephZero_SpokePool",
"label": "DEPRECATED_wrappedNativeToken",
"offset": 0,
"slot": "2155"
},
{
"contract": "contracts/AlephZero_SpokePool.sol:AlephZero_SpokePool",
"label": "DEPRECATED_depositQuoteTimeBuffer",
"offset": 20,
"slot": "2155"
},
{
"contract": "contracts/AlephZero_SpokePool.sol:AlephZero_SpokePool",
"label": "numberOfDeposits",
"offset": 24,
"slot": "2155"
},
{
"contract": "contracts/AlephZero_SpokePool.sol:AlephZero_SpokePool",
"label": "pausedFills",
"offset": 28,
"slot": "2155"
},
{
"contract": "contracts/AlephZero_SpokePool.sol:AlephZero_SpokePool",
"label": "pausedDeposits",
"offset": 29,
"slot": "2155"
},
{
"contract": "contracts/AlephZero_SpokePool.sol:AlephZero_SpokePool",
"label": "rootBundles",
"offset": 0,
"slot": "2156"
},
{
"contract": "contracts/AlephZero_SpokePool.sol:AlephZero_SpokePool",
"label": "enabledDepositRoutes",
"offset": 0,
"slot": "2157"
},
{
"contract": "contracts/AlephZero_SpokePool.sol:AlephZero_SpokePool",
"label": "DEPRECATED_relayFills",
"offset": 0,
"slot": "2158"
},
{
"contract": "contracts/AlephZero_SpokePool.sol:AlephZero_SpokePool",
"label": "DEPRECATED_fillCounter",
"offset": 0,
"slot": "2159"
},
{
"contract": "contracts/AlephZero_SpokePool.sol:AlephZero_SpokePool",
"label": "DEPRECATED_depositCounter",
"offset": 0,
"slot": "2160"
},
{
"contract": "contracts/AlephZero_SpokePool.sol:AlephZero_SpokePool",
"label": "DEPRECATED_refundsRequested",
"offset": 0,
"slot": "2161"
},
{
"contract": "contracts/AlephZero_SpokePool.sol:AlephZero_SpokePool",
"label": "fillStatuses",
"offset": 0,
"slot": "2162"
},
{
"contract": "contracts/AlephZero_SpokePool.sol:AlephZero_SpokePool",
"label": "__gap",
"offset": 0,
"slot": "2163"
},
{
"contract": "contracts/AlephZero_SpokePool.sol:AlephZero_SpokePool",
"label": "l2GatewayRouter",
"offset": 0,
"slot": "3162"
},
{
"contract": "contracts/AlephZero_SpokePool.sol:AlephZero_SpokePool",
"label": "whitelistedTokens",
"offset": 0,
"slot": "3163"
}
]
}
166 changes: 166 additions & 0 deletions storage-layouts/PolygonZkEVM_SpokePool.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
{
"storage": [
{
"contract": "contracts/PolygonZkEVM_SpokePool.sol:PolygonZkEVM_SpokePool",
"label": "_initialized",
"offset": 0,
"slot": "0"
},
{
"contract": "contracts/PolygonZkEVM_SpokePool.sol:PolygonZkEVM_SpokePool",
"label": "_initializing",
"offset": 1,
"slot": "0"
},
{
"contract": "contracts/PolygonZkEVM_SpokePool.sol:PolygonZkEVM_SpokePool",
"label": "__gap",
"offset": 0,
"slot": "1"
},
{
"contract": "contracts/PolygonZkEVM_SpokePool.sol:PolygonZkEVM_SpokePool",
"label": "__gap",
"offset": 0,
"slot": "51"
},
{
"contract": "contracts/PolygonZkEVM_SpokePool.sol:PolygonZkEVM_SpokePool",
"label": "_status",
"offset": 0,
"slot": "101"
},
{
"contract": "contracts/PolygonZkEVM_SpokePool.sol:PolygonZkEVM_SpokePool",
"label": "__gap",
"offset": 0,
"slot": "102"
},
{
"contract": "contracts/PolygonZkEVM_SpokePool.sol:PolygonZkEVM_SpokePool",
"label": "__gap",
"offset": 0,
"slot": "151"
},
{
"contract": "contracts/PolygonZkEVM_SpokePool.sol:PolygonZkEVM_SpokePool",
"label": "_HASHED_NAME",
"offset": 0,
"slot": "1151"
},
{
"contract": "contracts/PolygonZkEVM_SpokePool.sol:PolygonZkEVM_SpokePool",
"label": "_HASHED_VERSION",
"offset": 0,
"slot": "1152"
},
{
"contract": "contracts/PolygonZkEVM_SpokePool.sol:PolygonZkEVM_SpokePool",
"label": "__gap",
"offset": 0,
"slot": "1153"
},
{
"contract": "contracts/PolygonZkEVM_SpokePool.sol:PolygonZkEVM_SpokePool",
"label": "crossDomainAdmin",
"offset": 0,
"slot": "2153"
},
{
"contract": "contracts/PolygonZkEVM_SpokePool.sol:PolygonZkEVM_SpokePool",
"label": "withdrawalRecipient",
"offset": 0,
"slot": "2154"
},
{
"contract": "contracts/PolygonZkEVM_SpokePool.sol:PolygonZkEVM_SpokePool",
"label": "DEPRECATED_wrappedNativeToken",
"offset": 0,
"slot": "2155"
},
{
"contract": "contracts/PolygonZkEVM_SpokePool.sol:PolygonZkEVM_SpokePool",
"label": "DEPRECATED_depositQuoteTimeBuffer",
"offset": 20,
"slot": "2155"
},
{
"contract": "contracts/PolygonZkEVM_SpokePool.sol:PolygonZkEVM_SpokePool",
"label": "numberOfDeposits",
"offset": 24,
"slot": "2155"
},
{
"contract": "contracts/PolygonZkEVM_SpokePool.sol:PolygonZkEVM_SpokePool",
"label": "pausedFills",
"offset": 28,
"slot": "2155"
},
{
"contract": "contracts/PolygonZkEVM_SpokePool.sol:PolygonZkEVM_SpokePool",
"label": "pausedDeposits",
"offset": 29,
"slot": "2155"
},
{
"contract": "contracts/PolygonZkEVM_SpokePool.sol:PolygonZkEVM_SpokePool",
"label": "rootBundles",
"offset": 0,
"slot": "2156"
},
{
"contract": "contracts/PolygonZkEVM_SpokePool.sol:PolygonZkEVM_SpokePool",
"label": "enabledDepositRoutes",
"offset": 0,
"slot": "2157"
},
{
"contract": "contracts/PolygonZkEVM_SpokePool.sol:PolygonZkEVM_SpokePool",
"label": "DEPRECATED_relayFills",
"offset": 0,
"slot": "2158"
},
{
"contract": "contracts/PolygonZkEVM_SpokePool.sol:PolygonZkEVM_SpokePool",
"label": "DEPRECATED_fillCounter",
"offset": 0,
"slot": "2159"
},
{
"contract": "contracts/PolygonZkEVM_SpokePool.sol:PolygonZkEVM_SpokePool",
"label": "DEPRECATED_depositCounter",
"offset": 0,
"slot": "2160"
},
{
"contract": "contracts/PolygonZkEVM_SpokePool.sol:PolygonZkEVM_SpokePool",
"label": "DEPRECATED_refundsRequested",
"offset": 0,
"slot": "2161"
},
{
"contract": "contracts/PolygonZkEVM_SpokePool.sol:PolygonZkEVM_SpokePool",
"label": "fillStatuses",
"offset": 0,
"slot": "2162"
},
{
"contract": "contracts/PolygonZkEVM_SpokePool.sol:PolygonZkEVM_SpokePool",
"label": "__gap",
"offset": 0,
"slot": "2163"
},
{
"contract": "contracts/PolygonZkEVM_SpokePool.sol:PolygonZkEVM_SpokePool",
"label": "l2PolygonZkEVMBridge",
"offset": 0,
"slot": "3162"
},
{
"contract": "contracts/PolygonZkEVM_SpokePool.sol:PolygonZkEVM_SpokePool",
"label": "adminCallValidated",
"offset": 20,
"slot": "3162"
}
]
}
Loading

0 comments on commit a51d56f

Please sign in to comment.