From b5327cb110c39445b6493a1ae5be871d9725d5a6 Mon Sep 17 00:00:00 2001 From: "Odysseas.eth" Date: Tue, 14 Jun 2022 11:40:59 +0300 Subject: [PATCH 1/3] feat: forge-inspect all contracts --- packages/contracts-core/.storage-layout | 147 ++++++++++++++++++ .../contracts-core/scripts/storage-inspect.sh | 37 +++++ 2 files changed, 184 insertions(+) create mode 100644 packages/contracts-core/.storage-layout create mode 100755 packages/contracts-core/scripts/storage-inspect.sh diff --git a/packages/contracts-core/.storage-layout b/packages/contracts-core/.storage-layout new file mode 100644 index 00000000..1c2f3dfb --- /dev/null +++ b/packages/contracts-core/.storage-layout @@ -0,0 +1,147 @@ +======================= +👁👁 STORAGE LAYOUT snapshot 👁👁 +======================= + +Current git commit 6b642faf413fc19cfa241abb06a7538f3bcbc811 + + + +======================= +➡ Home +======================= + ++----------------+---------------------------+------+--------+-------+ +| Name | Type | Slot | Offset | Bytes | ++====================================================================+ +| _initialized | bool | 0 | 0 | 1 | +|----------------+---------------------------+------+--------+-------| +| _initializing | bool | 0 | 1 | 1 | +|----------------+---------------------------+------+--------+-------| +| queue | struct QueueLib.Queue | 1 | 0 | 64 | +|----------------+---------------------------+------+--------+-------| +| __GAP | uint256[49] | 3 | 0 | 1568 | +|----------------+---------------------------+------+--------+-------| +| tree | struct MerkleLib.Tree | 52 | 0 | 1056 | +|----------------+---------------------------+------+--------+-------| +| __GAP | uint256[49] | 85 | 0 | 1568 | +|----------------+---------------------------+------+--------+-------| +| __gap | uint256[50] | 134 | 0 | 1600 | +|----------------+---------------------------+------+--------+-------| +| _owner | address | 184 | 0 | 20 | +|----------------+---------------------------+------+--------+-------| +| __gap | uint256[49] | 185 | 0 | 1568 | +|----------------+---------------------------+------+--------+-------| +| updater | address | 234 | 0 | 20 | +|----------------+---------------------------+------+--------+-------| +| state | enum NomadBase.States | 234 | 20 | 1 | +|----------------+---------------------------+------+--------+-------| +| committedRoot | bytes32 | 235 | 0 | 32 | +|----------------+---------------------------+------+--------+-------| +| __GAP | uint256[47] | 236 | 0 | 1504 | +|----------------+---------------------------+------+--------+-------| +| nonces | mapping(uint32 => uint32) | 283 | 0 | 32 | +|----------------+---------------------------+------+--------+-------| +| updaterManager | contract IUpdaterManager | 284 | 0 | 20 | +|----------------+---------------------------+------+--------+-------| +| __GAP | uint256[48] | 285 | 0 | 1536 | ++----------------+---------------------------+------+--------+-------+ + +======================= +➡ Replica +======================= + ++-------------------+-----------------------------+------+--------+-------+ +| Name | Type | Slot | Offset | Bytes | ++=========================================================================+ +| _initialized | bool | 0 | 0 | 1 | +|-------------------+-----------------------------+------+--------+-------| +| _initializing | bool | 0 | 1 | 1 | +|-------------------+-----------------------------+------+--------+-------| +| __gap | uint256[50] | 1 | 0 | 1600 | +|-------------------+-----------------------------+------+--------+-------| +| _owner | address | 51 | 0 | 20 | +|-------------------+-----------------------------+------+--------+-------| +| __gap | uint256[49] | 52 | 0 | 1568 | +|-------------------+-----------------------------+------+--------+-------| +| updater | address | 101 | 0 | 20 | +|-------------------+-----------------------------+------+--------+-------| +| state | enum NomadBase.States | 101 | 20 | 1 | +|-------------------+-----------------------------+------+--------+-------| +| committedRoot | bytes32 | 102 | 0 | 32 | +|-------------------+-----------------------------+------+--------+-------| +| __GAP | uint256[47] | 103 | 0 | 1504 | +|-------------------+-----------------------------+------+--------+-------| +| remoteDomain | uint32 | 150 | 0 | 4 | +|-------------------+-----------------------------+------+--------+-------| +| optimisticSeconds | uint256 | 151 | 0 | 32 | +|-------------------+-----------------------------+------+--------+-------| +| entered | uint8 | 152 | 0 | 1 | +|-------------------+-----------------------------+------+--------+-------| +| confirmAt | mapping(bytes32 => uint256) | 153 | 0 | 32 | +|-------------------+-----------------------------+------+--------+-------| +| messages | mapping(bytes32 => bytes32) | 154 | 0 | 32 | +|-------------------+-----------------------------+------+--------+-------| +| __GAP | uint256[45] | 155 | 0 | 1440 | ++-------------------+-----------------------------+------+--------+-------+ + +======================= +➡ UpdaterManager +======================= + ++----------+---------+------+--------+-------+ +| Name | Type | Slot | Offset | Bytes | ++============================================+ +| _owner | address | 0 | 0 | 20 | +|----------+---------+------+--------+-------| +| home | address | 1 | 0 | 20 | +|----------+---------+------+--------+-------| +| _updater | address | 2 | 0 | 20 | ++----------+---------+------+--------+-------+ + +======================= +➡ XAppConnectionManager +======================= + ++--------------------+---------------------------------------------+------+--------+-------+ +| Name | Type | Slot | Offset | Bytes | ++==========================================================================================+ +| _owner | address | 0 | 0 | 20 | +|--------------------+---------------------------------------------+------+--------+-------| +| home | contract Home | 1 | 0 | 20 | +|--------------------+---------------------------------------------+------+--------+-------| +| replicaToDomain | mapping(address => uint32) | 2 | 0 | 32 | +|--------------------+---------------------------------------------+------+--------+-------| +| domainToReplica | mapping(uint32 => address) | 3 | 0 | 32 | +|--------------------+---------------------------------------------+------+--------+-------| +| watcherPermissions | mapping(address => mapping(uint32 => bool)) | 4 | 0 | 32 | ++--------------------+---------------------------------------------+------+--------+-------+ + +======================= +➡ GovernanceRouter +======================= + ++-----------------------+-------------------------------------------------------+------+--------+-------+ +| Name | Type | Slot | Offset | Bytes | ++=======================================================================================================+ +| _initialized | bool | 0 | 0 | 1 | +|-----------------------+-------------------------------------------------------+------+--------+-------| +| _initializing | bool | 0 | 1 | 1 | +|-----------------------+-------------------------------------------------------+------+--------+-------| +| recoveryActiveAt | uint256 | 1 | 0 | 32 | +|-----------------------+-------------------------------------------------------+------+--------+-------| +| recoveryManager | address | 2 | 0 | 20 | +|-----------------------+-------------------------------------------------------+------+--------+-------| +| governor | address | 3 | 0 | 20 | +|-----------------------+-------------------------------------------------------+------+--------+-------| +| governorDomain | uint32 | 3 | 20 | 4 | +|-----------------------+-------------------------------------------------------+------+--------+-------| +| xAppConnectionManager | contract XAppConnectionManager | 4 | 0 | 20 | +|-----------------------+-------------------------------------------------------+------+--------+-------| +| routers | mapping(uint32 => bytes32) | 5 | 0 | 32 | +|-----------------------+-------------------------------------------------------+------+--------+-------| +| domains | uint32[] | 6 | 0 | 32 | +|-----------------------+-------------------------------------------------------+------+--------+-------| +| inboundCallBatches | mapping(bytes32 => enum GovernanceRouter.BatchStatus) | 7 | 0 | 32 | +|-----------------------+-------------------------------------------------------+------+--------+-------| +| __GAP | uint256[42] | 8 | 0 | 1344 | ++-----------------------+-------------------------------------------------------+------+--------+-------+ diff --git a/packages/contracts-core/scripts/storage-inspect.sh b/packages/contracts-core/scripts/storage-inspect.sh new file mode 100755 index 00000000..f57e60fe --- /dev/null +++ b/packages/contracts-core/scripts/storage-inspect.sh @@ -0,0 +1,37 @@ +#!/usr/bin/env bash + +set -e + + +if ! command -v forge &> /dev/null +then + echo "forge could not be found. Please install forge by running:" + echo "curl -L https://foundry.paradigm.xyz | bash" + exit +fi + +contracts=( +Home +Replica +UpdaterManager +XAppConnectionManager +GovernanceRouter +) + +dir=$(dirname "$0") + +echo "Creating storage layout diagrams.." + +echo "=======================" > $dir/../.storage-layout +echo "👁👁 STORAGE LAYOUT snapshot 👁👁" >> $dir/../.storage-layout +echo "=======================" >> $dir/../.storage-layout +echo -e "\nCurrent git commit $(git rev-parse HEAD) \n\n" >> $dir/../.storage-layout + +for contract in ${contracts[@]} +do + echo -e "\n=======================" >> $dir/../.storage-layout + echo "➡ $contract">> $dir/../.storage-layout + echo -e "=======================\n" >> $dir/../.storage-layout + FOUNDRY_PROFILE=core forge inspect --pretty $contract storage-layout >> $dir/../.storage-layout +done +echo "Storage layout snapshot stored at $dir/../.storage-layout" From 4bdee7ce55d1ed4e96a2883a76b2185c14350ce3 Mon Sep 17 00:00:00 2001 From: "Odysseas.eth" Date: Tue, 14 Jun 2022 11:46:14 +0300 Subject: [PATCH 2/3] feat: add storage inspect to yarn scripts --- packages/contracts-core/.storage-layout | 2 +- packages/contracts-core/package.json | 3 ++- packages/contracts-core/scripts/storage-inspect.sh | 1 - 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/contracts-core/.storage-layout b/packages/contracts-core/.storage-layout index 1c2f3dfb..7a90bae1 100644 --- a/packages/contracts-core/.storage-layout +++ b/packages/contracts-core/.storage-layout @@ -2,7 +2,7 @@ 👁👁 STORAGE LAYOUT snapshot 👁👁 ======================= -Current git commit 6b642faf413fc19cfa241abb06a7538f3bcbc811 +Current git commit b5327cb110c39445b6493a1ae5be871d9725d5a6 diff --git a/packages/contracts-core/package.json b/packages/contracts-core/package.json index 22978461..6c1fdc1c 100644 --- a/packages/contracts-core/package.json +++ b/packages/contracts-core/package.json @@ -31,7 +31,8 @@ "link:node_modules": "ln -s ../../node_modules", "snapshot": "forge clean && FOUNDRY_PROFILE=core forge snapshot", "snapshot:check": "forge clean && FOUNDRY_PROFILE=core forge snapshot --check", - "gen-proof": "../../scripts/accumulator-cli" + "gen-proof": "../../scripts/accumulator-cli", + "gen-sl": "scripts/storage-inspect.sh" }, "dependencies": { "@openzeppelin/contracts": "^3.4.2", diff --git a/packages/contracts-core/scripts/storage-inspect.sh b/packages/contracts-core/scripts/storage-inspect.sh index f57e60fe..66792908 100755 --- a/packages/contracts-core/scripts/storage-inspect.sh +++ b/packages/contracts-core/scripts/storage-inspect.sh @@ -2,7 +2,6 @@ set -e - if ! command -v forge &> /dev/null then echo "forge could not be found. Please install forge by running:" From d2ebabeabff42b563176f32239a64d92a934c865 Mon Sep 17 00:00:00 2001 From: "Odysseas.eth" Date: Mon, 27 Jun 2022 19:26:11 +0300 Subject: [PATCH 3/3] fix: remove git commit from produced artifacts --- packages/contracts-core/scripts/storage-inspect.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/contracts-core/scripts/storage-inspect.sh b/packages/contracts-core/scripts/storage-inspect.sh index 66792908..2f5baee8 100755 --- a/packages/contracts-core/scripts/storage-inspect.sh +++ b/packages/contracts-core/scripts/storage-inspect.sh @@ -24,7 +24,6 @@ echo "Creating storage layout diagrams.." echo "=======================" > $dir/../.storage-layout echo "👁👁 STORAGE LAYOUT snapshot 👁👁" >> $dir/../.storage-layout echo "=======================" >> $dir/../.storage-layout -echo -e "\nCurrent git commit $(git rev-parse HEAD) \n\n" >> $dir/../.storage-layout for contract in ${contracts[@]} do