Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: forge-inspect script for contracts-core #344

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
147 changes: 147 additions & 0 deletions packages/contracts-core/.storage-layout
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
=======================
👁👁 STORAGE LAYOUT snapshot 👁👁
=======================

Current git commit b5327cb110c39445b6493a1ae5be871d9725d5a6



=======================
➡ 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 |
+-----------------------+-------------------------------------------------------+------+--------+-------+
3 changes: 2 additions & 1 deletion packages/contracts-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Copy link
Member

Choose a reason for hiding this comment

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

this should be added to the build script

},
"dependencies": {
"@openzeppelin/contracts": "^3.4.2",
Expand Down
35 changes: 35 additions & 0 deletions packages/contracts-core/scripts/storage-inspect.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/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

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"