-
Notifications
You must be signed in to change notification settings - Fork 361
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add storage layout diff checks (#2991)
- Loading branch information
Showing
9 changed files
with
111 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
'@hyperlane-xyz/sdk': patch | ||
'@hyperlane-xyz/core': patch | ||
--- | ||
|
||
Rename StaticProtocolFee hook to ProtocolFee for clarity |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
name: Check Storage Layout Changes | ||
|
||
on: | ||
pull_request: | ||
branches: [main] | ||
paths: | ||
- 'solidity/**' | ||
workflow_dispatch: | ||
|
||
jobs: | ||
diff-check: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
# Checkout the PR branch | ||
- name: Checkout PR branch | ||
uses: actions/checkout@v3 | ||
with: | ||
ref: ${{ github.event.pull_request.head.sha }} | ||
submodules: recursive | ||
|
||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: 18 | ||
|
||
- name: yarn-cache | ||
uses: actions/cache@v3 | ||
with: | ||
path: | | ||
**/node_modules | ||
.yarn | ||
key: ${{ runner.os }}-yarn-cache-${{ hashFiles('./yarn.lock') }} | ||
|
||
- name: yarn-install | ||
run: yarn install | ||
|
||
- name: foundry-install | ||
uses: onbjerg/foundry-toolchain@v1 | ||
|
||
# Run the command on PR branch | ||
- name: Run command on PR branch | ||
run: yarn workspace @hyperlane-xyz/core storage HEAD-storage | ||
|
||
# Checkout the target branch (base) | ||
- name: Checkout target branch (base) contracts | ||
env: | ||
BASE_REF: ${{ github.event.pull_request.base.sha }} | ||
run: | | ||
git fetch origin $BASE_REF | ||
git checkout $BASE_REF -- solidity/contracts | ||
# Run the command on the target branch | ||
- name: Run command on target branch | ||
run: yarn workspace @hyperlane-xyz/core storage base-storage | ||
|
||
# Compare outputs | ||
- name: Compare outputs | ||
run: diff --unified solidity/base-storage solidity/HEAD-storage > layout.diff | ||
|
||
- name: Comment PR with layout diff | ||
uses: yorhodes/actions-comment-pull-request@v2.4.6 | ||
with: | ||
header: Storage Layout Diff | ||
filePath: layout.diff | ||
mdLanguage: diff | ||
comment_tag: storagelayoutdiff |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ types/ | |
dist/ | ||
coverage/ | ||
coverage.json | ||
storage/ | ||
.env | ||
*lcov.info | ||
# Foundry | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/bin/bash | ||
OUTPUT_PATH=${1:-storage} | ||
EXCLUDE="test|mock|interfaces|libs|upgrade|README|Abstract|Static" | ||
|
||
IFS=$'\n' | ||
CONTRACT_FILES=($(find ./contracts -type f)) | ||
unset IFS | ||
|
||
echo "Generating layouts in $OUTPUT_PATH" | ||
mkdir -p $OUTPUT_PATH | ||
|
||
for file in "${CONTRACT_FILES[@]}"; | ||
do | ||
if [[ $file =~ .*($EXCLUDE).* ]]; then | ||
continue | ||
fi | ||
|
||
contract=$(basename "$file" .sol) | ||
echo "Generating storage layout of $contract" | ||
forge inspect "$contract" storage --pretty > "$OUTPUT_PATH/$contract.md" | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters