-
-
Notifications
You must be signed in to change notification settings - Fork 17
Introduce CI Pipeline for Gas Optimization, Storage Safety, and Contract Integrity Validation #69
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
Merged
KanishkSogani
merged 29 commits into
StabilityNexus:main
from
aniket866:advance-workflows
Apr 4, 2026
Merged
Changes from 20 commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
9900b2a
advance-worflows
aniket866 680be7f
advance-worflows
aniket866 7a46d10
Code rabbit follow up
aniket866 085732e
Code rabbit follow up
aniket866 1b5f9e3
Code rabbit follow up
aniket866 0b1af16
Code rabbit follow up
aniket866 73974b9
code-rabbit-local-fix
aniket866 917f07a
Merge branch 'advance-workflows' of https://github.com/aniket866/Iden…
aniket866 5cb0bb4
code-rabbit-local-fix
aniket866 8761690
local-code-rabbit-fix
aniket866 d3b3d1e
local-code-rabbit-fix
aniket866 8912709
Code rabbit follow up
aniket866 aa44c29
Code rabbit follow up
aniket866 f2da137
Code rabbit follow up
aniket866 c493e3a
Code rabbit follow-up
aniket866 c0320de
code-rabbit-followup
aniket866 b321fba
gas-snap-shot-fix
aniket866 c23b99e
gas-snapshot
aniket866 3d6a0f8
Copilot-suggestions
aniket866 198453c
Copilot-suggestions
aniket866 f4ea87e
Copilot-fix
aniket866 eec5ddf
Update 4naly3er workflow for optimization report
aniket866 cafd272
Update .github/workflows/contract-size.yml
aniket866 631ca6a
Update .github/workflows/mythril.yml
aniket866 c1ffe53
Update .github/workflows/mythril.yml
aniket866 835e9b4
Code rabbit follow-up
aniket866 4a41210
Code rabbit follow-up
aniket866 e14020c
Code rabbit follow-up
aniket866 c37c2ed
Fixing-ci-fails
aniket866 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,38 @@ | ||
| IdentityTokenTest:test_DeleteAttribute() (gas: 104049) | ||
| IdentityTokenTest:test_DeleteAttribute_EmitsEvent() (gas: 103782) | ||
| IdentityTokenTest:test_DeleteAttribute_NeverSet_DoesNotRevert() (gas: 96220) | ||
| IdentityTokenTest:test_DeleteAttribute_ThenReSet() (gas: 133002) | ||
| IdentityTokenTest:test_DeleteAttribute_Twice_DoesNotRevert() (gas: 106037) | ||
| IdentityTokenTest:test_Endorse() (gas: 280823) | ||
| IdentityTokenTest:test_GetAttribute() (gas: 121241) | ||
| IdentityTokenTest:test_GetAttribute_MatchesRawMapping() (gas: 123833) | ||
| IdentityTokenTest:test_GetIdentityByOwner_ReturnsEmptyIfNoToken() (gas: 10630) | ||
| IdentityTokenTest:test_GetIdentityByOwner_ReturnsTokenId() (gas: 87786) | ||
| IdentityTokenTest:test_GetIdentity_EndorsementCountUpdates() (gas: 269741) | ||
| IdentityTokenTest:test_GetIdentity_ReturnsCorrectFields() (gas: 98926) | ||
| IdentityTokenTest:test_GetIdentity_RevertsForNonexistentToken() (gas: 12336) | ||
| IdentityTokenTest:test_HasIdentity_False() (gas: 10198) | ||
| IdentityTokenTest:test_HasIdentity_True() (gas: 86907) | ||
| IdentityTokenTest:test_IsExpired_FalseBeforeExpiry() (gas: 261330) | ||
| IdentityTokenTest:test_IsExpired_FalseWhenNoValidUntil() (gas: 88627) | ||
| IdentityTokenTest:test_IsExpired_TrueAfterExpiry() (gas: 261752) | ||
| IdentityTokenTest:test_IsVerified_FalseWithExpiredEndorsement() (gas: 281042) | ||
| IdentityTokenTest:test_IsVerified_FalseWithNoEndorsements() (gas: 88627) | ||
| IdentityTokenTest:test_IsVerified_TrueWithActiveEndorsement() (gas: 260278) | ||
| IdentityTokenTest:test_Mint() (gas: 88284) | ||
| IdentityTokenTest:test_OverwriteAttribute() (gas: 129040) | ||
| IdentityTokenTest:test_RevertIf_BatchLengthMismatch() (gas: 92319) | ||
| IdentityTokenTest:test_RevertIf_CompromisedIdentityDeletesAttribute() (gas: 325685) | ||
| IdentityTokenTest:test_RevertIf_NotOwnerBatchSetsAttribute() (gas: 91542) | ||
| IdentityTokenTest:test_RevertIf_NotOwnerDeletesAttribute() (gas: 121538) | ||
| IdentityTokenTest:test_RevertIf_NotOwnerSetsAttribute() (gas: 90472) | ||
| IdentityTokenTest:test_RevertIf_NotOwnerUsesSetName() (gas: 89907) | ||
| IdentityTokenTest:test_SchemaConstants() (gas: 3090) | ||
| IdentityTokenTest:test_SetAttribute() (gas: 120877) | ||
| IdentityTokenTest:test_SetAttribute_EmptyValue() (gas: 99664) | ||
| IdentityTokenTest:test_SetAttribute_LongURL() (gas: 189521) | ||
| IdentityTokenTest:test_SetAttribute_SocialLinks() (gas: 188857) | ||
| IdentityTokenTest:test_SetAttributesBatch() (gas: 220621) | ||
| IdentityTokenTest:test_SetAttributesBatch_SingleEntry() (gas: 122819) | ||
| IdentityTokenTest:test_SetGithub() (gas: 120296) | ||
| IdentityTokenTest:test_SetName() (gas: 120329) |
This file contains hidden or 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,41 @@ | ||
| name: 4naly3er Report | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main, master] | ||
| pull_request: | ||
| branches: [main, master] | ||
|
|
||
| jobs: | ||
| analyzer_4naly3er: | ||
| name: 4naly3er Gas Optimization Report | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| submodules: recursive | ||
|
|
||
| - name: Setup Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: "24" | ||
|
|
||
| - name: Install 4naly3er | ||
| run: | | ||
| git clone https://github.com/Picodes/4naly3er | ||
| cd 4naly3er | ||
| rm -f src/issues/NC/uselessOverride.ts || true | ||
| corepack enable | ||
| yarn install | ||
|
|
||
| - name: Run 4naly3er on src/ | ||
| run: | | ||
| cd 4naly3er | ||
| yarn analyze ../src ../4naly3er-report.md | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
|
|
||
| - name: Upload 4naly3er report | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: 4naly3er-report | ||
| path: 4naly3er-report.md | ||
This file contains hidden or 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,65 @@ | ||
| name: ABI Diff Check | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main, master] | ||
| pull_request: | ||
| branches: [main, master] | ||
|
|
||
| env: | ||
| FOUNDRY_PROFILE: ci | ||
|
|
||
| jobs: | ||
| abi-diff: | ||
| name: ABI Diff Check | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| submodules: recursive | ||
|
|
||
| - name: Install Foundry | ||
| uses: foundry-rs/foundry-toolchain@v1 | ||
|
|
||
| - name: Build contracts | ||
| run: forge build | ||
|
|
||
| - name: Generate ABIs and diff against baseline | ||
| run: | | ||
| mkdir -p .abi-current | ||
| CHANGED=0 | ||
|
|
||
| if [ ! -d .abi-baselines ]; then | ||
| echo "No .abi-baselines directory. Skipping check." | ||
| exit 0 | ||
| fi | ||
|
|
||
| # Derive contract names from existing baselines to avoid placeholder drift. | ||
| mapfile -t CONTRACTS < <(find .abi-baselines -type f -name '*.json' -exec basename {} .json \;) | ||
| if [ "${#CONTRACTS[@]}" -eq 0 ]; then | ||
| echo "No ABI baselines found in .abi-baselines/. Skipping ABI diff." | ||
| exit 0 | ||
| fi | ||
|
|
||
| for contract in "${CONTRACTS[@]}"; do | ||
| if ! forge inspect "$contract" abi > ".abi-current/${contract}.json" 2>/dev/null; then | ||
| echo "::error::Failed to generate ABI for $contract" | ||
| CHANGED=1 | ||
| continue | ||
| fi | ||
|
|
||
| baseline=".abi-baselines/${contract}.json" | ||
| if [ -f "$baseline" ]; then | ||
| if ! diff -u "$baseline" ".abi-current/${contract}.json"; then | ||
| echo "❌ ABI changed for $contract — this may be a breaking change!" | ||
| CHANGED=1 | ||
| fi | ||
| else | ||
| echo "::error::No ABI baseline for $contract. Add .abi-baselines/${contract}.json" | ||
| CHANGED=1 | ||
| fi | ||
|
aniket866 marked this conversation as resolved.
|
||
| done | ||
|
|
||
| if [ "$CHANGED" -eq 1 ]; then | ||
| exit 1 | ||
| fi | ||
This file contains hidden or 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,46 @@ | ||
| name: Contract Size Check | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main, master] | ||
| pull_request: | ||
| branches: [main, master] | ||
|
|
||
| env: | ||
| FOUNDRY_PROFILE: ci | ||
|
|
||
| jobs: | ||
| contract-size: | ||
| name: Contract Size Check | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| submodules: recursive | ||
|
|
||
| - name: Install Foundry | ||
| uses: foundry-rs/foundry-toolchain@v1 | ||
|
|
||
| - name: Build and check contract sizes | ||
| run: | | ||
| forge build --sizes 2>&1 | tee sizes.txt | ||
| # Fail if any contract is >= 23616 bytes (warn zone before 24KB EIP-170 limit) | ||
| if awk ' | ||
| BEGIN { found = 0 } | ||
| /^\s*\|/ && $0 !~ /Contract/ { | ||
| size = 0 | ||
| for (i = 1; i <= NF; i++) { | ||
| if ($i ~ /^[0-9]+$/) { | ||
| size = $i | ||
| } | ||
| } | ||
| if (size + 0 >= 23616) { | ||
| found = 1 | ||
| } | ||
| } | ||
| END { exit(found ? 0 : 1) } | ||
|
aniket866 marked this conversation as resolved.
Outdated
|
||
| ' sizes.txt; then | ||
| echo "❌ One or more contracts are dangerously close to or over the 24KB limit." | ||
| exit 1 | ||
| fi | ||
This file contains hidden or 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,37 @@ | ||
| name: Coverage Report | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main, master] | ||
| pull_request: | ||
| branches: [main, master] | ||
|
|
||
| env: | ||
| FOUNDRY_PROFILE: ci | ||
|
|
||
| jobs: | ||
| coverage: | ||
| name: Coverage Report | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| submodules: recursive | ||
|
|
||
| - name: Install Foundry | ||
| uses: foundry-rs/foundry-toolchain@v1 | ||
|
|
||
| - name: Install lcov | ||
| run: | | ||
| sudo apt-get update | ||
| sudo apt-get install -y lcov | ||
|
|
||
| - name: Generate coverage report | ||
| run: forge coverage --report lcov | ||
|
|
||
| - name: Upload to Codecov | ||
| uses: codecov/codecov-action@v4 | ||
| with: | ||
| files: ./lcov.info | ||
| fail_ci_if_error: false | ||
| token: ${{ secrets.CODECOV_TOKEN }} |
This file contains hidden or 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,25 @@ | ||
| name: Gas Report | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main, master] | ||
| pull_request: | ||
| branches: [main, master] | ||
|
|
||
| env: | ||
| FOUNDRY_PROFILE: ci | ||
|
|
||
| jobs: | ||
| gas-report: | ||
| name: Gas Report on Test Run | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| submodules: recursive | ||
|
|
||
| - name: Install Foundry | ||
| uses: foundry-rs/foundry-toolchain@v1 | ||
|
|
||
| - name: Run tests with gas report | ||
| run: forge test --gas-report |
This file contains hidden or 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,33 @@ | ||
| name: Gas Snapshot Diff | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main, master] | ||
| pull_request: | ||
| branches: [main, master] | ||
|
|
||
| env: | ||
| FOUNDRY_PROFILE: ci | ||
|
|
||
| jobs: | ||
| gas-snapshot: | ||
| name: Gas Snapshot Diff | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| submodules: recursive | ||
|
|
||
| - name: Install Foundry | ||
| uses: foundry-rs/foundry-toolchain@v1 | ||
|
aniket866 marked this conversation as resolved.
|
||
|
|
||
| - name: Compare gas snapshot diff | ||
| run: | | ||
| if [ ! -f .gas-snapshot ]; then | ||
| echo "::error::.gas-snapshot is missing. Commit a baseline snapshot to enable gas regression checks." | ||
| exit 1 | ||
| fi | ||
| if ! forge snapshot --diff .gas-snapshot; then | ||
| echo "❌ Gas usage increased. Review the diff above." | ||
| exit 1 | ||
|
aniket866 marked this conversation as resolved.
|
||
| fi | ||
This file contains hidden or 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,39 @@ | ||
| name: Mythril Security Scan | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main, master] | ||
| pull_request: | ||
| branches: [main, master] | ||
|
|
||
| env: | ||
| FOUNDRY_PROFILE: ci | ||
|
|
||
| jobs: | ||
| mythril: | ||
| name: Mythril Security Scan | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| submodules: recursive | ||
|
|
||
| - name: Install Foundry | ||
| uses: foundry-rs/foundry-toolchain@v1 | ||
|
|
||
| - name: Build contracts | ||
| run: forge build | ||
|
|
||
| - name: Run Mythril on all contracts | ||
| run: | | ||
| sudo apt-get update && sudo apt-get install -y jq | ||
| find out -name "*.json" | while read artifact; do | ||
| CONTRACT=$(jq -r '.contractName // empty' "$artifact") | ||
| BYTECODE=$(jq -r '.deployedBytecode.object // empty' "$artifact") | ||
| if [ -n "$CONTRACT" ] && [ -n "$BYTECODE" ] && [ "$BYTECODE" != "0x" ]; then | ||
| echo "🔍 Scanning $CONTRACT from $artifact ..." | ||
| docker run --rm \ | ||
| mythril/myth analyze "$BYTECODE" \ | ||
| --execution-timeout 60 | ||
|
aniket866 marked this conversation as resolved.
|
||
| fi | ||
| done | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.