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

L2 bridges audit - adding CI Integration for Certora's Formal Verification #61

Merged
merged 54 commits into from
Sep 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
9e6b97d
certora folder added
MichaelMorami May 26, 2022
4e1a67b
fix: Fix natspec typo
miguelmtzinf Jun 8, 2022
fd3a14b
Merge pull request #55 from aave/fix/natspec-typo
miguelmtzinf Jun 8, 2022
8daa8c6
Added spec and script for OptimismExecutor
Roy-Certora Jun 9, 2022
8146e8a
Created munged direcotry
Roy-Certora Jun 12, 2022
0b799e2
Updated bridge spec and harnessed files.
Roy-Certora Jun 12, 2022
12e9ec9
Updated Harness and Spec
Roy-Certora Jun 13, 2022
7d77157
Verified rules in spec. Changed target calls mocks.
Roy-Certora Jun 15, 2022
a418d3f
Updated OptimisimBridge spec
Roy-Certora Jun 15, 2022
ce4e579
Updated optimism executor spec
Roy-Certora Jun 16, 2022
4ee6817
Added a target call mock contract.
Roy-Certora Jun 20, 2022
eb2e92f
Added verification for Polygon Bridge
Roy-Certora Jun 21, 2022
8c19aad
Updated Polygon and Optimism specs
Roy-Certora Jun 21, 2022
c045e17
splitting certora's gitignore from main gitignore
MichaelMorami Jun 29, 2022
e400e15
Updated Polygon & Optimism spec (after review)
Roy-Certora Jul 7, 2022
ab25975
Update PolygonBridge.spec
Roy-Certora Jul 7, 2022
b548a7e
Added Arbitrum verficiation
Roy-Certora Jul 10, 2022
165bfdc
adding certora files to gitignore
MichaelMorami Jul 12, 2022
2cc4cde
deleting json file
MichaelMorami Jul 12, 2022
5042534
adding the verification report
MichaelMorami Jul 12, 2022
3f7f87a
Create README.md
Roy-Certora Jul 13, 2022
93a3392
Update README.md
Roy-Certora Jul 13, 2022
1d4d7e7
Updated independentQueuedActions rule
Roy-Certora Jul 14, 2022
f1948de
updated report
MichaelMorami Jul 16, 2022
9072c5d
Update Formal Verification Report of AAVE L2 Bridge.pdf
Roy-Certora Jul 16, 2022
a236f06
Updated noIncarnations rule.
Roy-Certora Jul 17, 2022
8fa25b0
Update AddressAliasHelper library to work with solidity 0.8 version (…
miguelmtzinf Jul 20, 2022
35bb42a
feat: Add CI setup
miguelmtzinf Jul 22, 2022
9d8b8a8
Merge pull request #60 from aave/feat/ci
miguelmtzinf Jul 22, 2022
f7846d7
Merge branch 'l2-bridges-audit' of github.com:Certora/governance-cros…
MichaelMorami Jul 31, 2022
b838633
Merge pull request #1 from Certora/master
MichaelMorami Jul 31, 2022
749d33d
Merge branch 'l2-bridges-audit' of github.com:Certora/governance-cros…
MichaelMorami Jul 31, 2022
70efdf6
adding mocks to munged + updating arbitrum dependency
MichaelMorami Aug 3, 2022
a13e2e0
created harness patch and munged directory
MichaelMorami Aug 3, 2022
e7e2595
adding git action
MichaelMorami Aug 3, 2022
517a645
fixing yaml
MichaelMorami Aug 3, 2022
84d9354
adding ls checks for munged
MichaelMorami Aug 3, 2022
17a9bcc
fixing yaml
MichaelMorami Aug 3, 2022
6d313c5
adding optimism and polygon yamls
MichaelMorami Aug 3, 2022
ba5ac50
testing git action on staging
MichaelMorami Aug 3, 2022
fc31feb
changing the yaml back to cloud
MichaelMorami Aug 3, 2022
ac415c9
removing complexity check
MichaelMorami Aug 10, 2022
bee89dd
fixing error in line 105
MichaelMorami Aug 10, 2022
17c0407
installing certora-cli-alpha-master instead of certora-cli
MichaelMorami Aug 10, 2022
ecaf17d
adding debug
MichaelMorami Aug 10, 2022
7f3e77e
removing debug
MichaelMorami Aug 15, 2022
1dd917f
returning to certora-clo
MichaelMorami Aug 15, 2022
032e362
going back to regular cli
MichaelMorami Aug 23, 2022
4479f07
removing munged content
MichaelMorami Aug 23, 2022
39ec885
updating python version to 3.9
MichaelMorami Aug 24, 2022
7381a17
removing non existing rule in polygon
MichaelMorami Aug 24, 2022
d9dea30
adding mocks to munged + updating arbitrum dependency
MichaelMorami Aug 3, 2022
dea23ea
setting CI integration for formal verification by Certora
MichaelMorami Aug 24, 2022
1bc9a60
Merge branch 'l2-bridges-audit' of github.com:Certora/governance-cros…
MichaelMorami Aug 24, 2022
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
74 changes: 74 additions & 0 deletions .github/workflows/certora-arbitrum.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: certora-arbitrum

on:
push:
branches:
- main
- l2-bridges-audit
pull_request:
branches:
- main

workflow_dispatch:

jobs:
verify:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Check key
env:
CERTORAKEY: ${{ secrets.CERTORAKEY }}
run: echo "key length" ${#CERTORAKEY}

- name: Install python
uses: actions/setup-python@v2
with: { python-version: 3.9 }

- name: Install java
uses: actions/setup-java@v1
with: { java-version: "11", java-package: jre }

- name: Install certora cli
run: pip install certora-cli

- name: Install solc
run: |
wget https://github.com/ethereum/solidity/releases/download/v0.8.10/solc-static-linux
chmod +x solc-static-linux
sudo mv solc-static-linux /usr/local/bin/solc8.10

- name: Verify rule ${{ matrix.rule }}
run: |
cd certora
touch applyHarness.patch
make munged
cd ..
echo "key length" ${#CERTORAKEY}
sh certora/scripts/${{ matrix.rule }}
env:
CERTORAKEY: ${{ secrets.CERTORAKEY }}

strategy:
fail-fast: false
max-parallel: 16
matrix:
rule:
- verifyArbitrum.sh executedValidTransition2
- verifyArbitrum.sh onlyCancelCanCancel
- verifyArbitrum.sh onlyQueuedAreExecuted
- verifyArbitrum.sh expiredForever
- verifyArbitrum.sh actionNotCanceledAndExecuted
- verifyArbitrum.sh properDelay
- verifyArbitrum.sh notCanceledNotExecuted
- verifyArbitrum.sh minDelayLtMaxDelay
- verifyArbitrum.sh whoChangedStateVariables
- verifyArbitrum.sh executeCannotCancel
- verifyArbitrum.sh whoChangesActionsSetState
- verifyArbitrum.sh canceledForever
- verifyArbitrum.sh executedForever
- verifyArbitrum.sh executeRevertsBeforeDelay
- verifyArbitrum.sh noIncarnations1 noIncarnations2 noIncarnations3
- verifyArbitrum.sh actionDuplicate holdYourHorses executeFailsIfExpired executedValidTransition1 queuePriviliged afterQueueHashQueued queue2Reachability cancelPriviliged independentQueuedActions queueCannotCancel queueDoesntModifyStateVariables queuedStateConsistency queuedChangedCounter sameExecutionTimesReverts cancelExclusive
74 changes: 74 additions & 0 deletions .github/workflows/certora-optimism.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: certora-optimism

on:
push:
branches:
- main
- l2-bridges-audit
pull_request:
branches:
- main

workflow_dispatch:

jobs:
verify:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Check key
env:
CERTORAKEY: ${{ secrets.CERTORAKEY }}
run: echo "key length" ${#CERTORAKEY}

- name: Install python
uses: actions/setup-python@v2
with: { python-version: 3.9 }

- name: Install java
uses: actions/setup-java@v1
with: { java-version: "11", java-package: jre }

- name: Install certora cli
run: pip install certora-cli

- name: Install solc
run: |
wget https://github.com/ethereum/solidity/releases/download/v0.8.10/solc-static-linux
chmod +x solc-static-linux
sudo mv solc-static-linux /usr/local/bin/solc8.10

- name: Verify rule ${{ matrix.rule }}
run: |
cd certora
touch applyHarness.patch
make munged
cd ..
echo "key length" ${#CERTORAKEY}
sh certora/scripts/${{ matrix.rule }}
env:
CERTORAKEY: ${{ secrets.CERTORAKEY }}

strategy:
fail-fast: false
max-parallel: 16
matrix:
rule:
- verifyOptimism.sh executedValidTransition2
- verifyOptimism.sh onlyCancelCanCancel
- verifyOptimism.sh onlyQueuedAreExecuted
- verifyOptimism.sh expiredForever
- verifyOptimism.sh actionNotCanceledAndExecuted
- verifyOptimism.sh properDelay
- verifyOptimism.sh notCanceledNotExecuted
- verifyOptimism.sh minDelayLtMaxDelay
- verifyOptimism.sh whoChangedStateVariables
- verifyOptimism.sh executeCannotCancel
- verifyOptimism.sh whoChangesActionsSetState
- verifyOptimism.sh canceledForever
- verifyOptimism.sh executedForever
- verifyOptimism.sh executeRevertsBeforeDelay
- verifyOptimism.sh noIncarnations1 noIncarnations2 noIncarnations3
- verifyOptimism.sh actionDuplicate holdYourHorses executeFailsIfExpired executedValidTransition1 queuePriviliged afterQueueHashQueued queue2Reachability cancelPriviliged independentQueuedActions queueCannotCancel queueDoesntModifyStateVariables queuedStateConsistency queuedChangedCounter sameExecutionTimesReverts cancelExclusive
74 changes: 74 additions & 0 deletions .github/workflows/certora-polygon.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: certora-polygon

on:
push:
branches:
- main
- l2-bridges-audit
pull_request:
branches:
- main

workflow_dispatch:

jobs:
verify:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Check key
env:
CERTORAKEY: ${{ secrets.CERTORAKEY }}
run: echo "key length" ${#CERTORAKEY}

- name: Install python
uses: actions/setup-python@v2
with: { python-version: 3.9 }

- name: Install java
uses: actions/setup-java@v1
with: { java-version: "11", java-package: jre }

- name: Install certora cli
run: pip install certora-cli

- name: Install solc
run: |
wget https://github.com/ethereum/solidity/releases/download/v0.8.10/solc-static-linux
chmod +x solc-static-linux
sudo mv solc-static-linux /usr/local/bin/solc8.10

- name: Verify rule ${{ matrix.rule }}
run: |
cd certora
touch applyHarness.patch
make munged
cd ..
echo "key length" ${#CERTORAKEY}
sh certora/scripts/${{ matrix.rule }}
env:
CERTORAKEY: ${{ secrets.CERTORAKEY }}

strategy:
fail-fast: false
max-parallel: 16
matrix:
rule:
- verifyPolygon.sh executedValidTransition2
- verifyPolygon.sh onlyCancelCanCancel
- verifyPolygon.sh onlyQueuedAreExecuted
- verifyPolygon.sh expiredForever
- verifyPolygon.sh actionNotCanceledAndExecuted
- verifyPolygon.sh properDelay
- verifyPolygon.sh notCanceledNotExecuted
- verifyPolygon.sh minDelayLtMaxDelay
- verifyPolygon.sh whoChangedStateVariables
- verifyPolygon.sh executeCannotCancel
- verifyPolygon.sh whoChangesActionsSetState
- verifyPolygon.sh canceledForever
- verifyPolygon.sh executedForever
- verifyPolygon.sh executeRevertsBeforeDelay
- verifyPolygon.sh noIncarnations1 noIncarnations2 noIncarnations3
- verifyPolygon.sh actionDuplicate holdYourHorses executeFailsIfExpired executedValidTransition1 queuePriviliged afterQueueHashQueued cancelPriviliged independentQueuedActions queueCannotCancel queueDoesntModifyStateVariables queuedStateConsistency queuedChangedCounter sameExecutionTimesReverts cancelExclusive
35 changes: 35 additions & 0 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Build
'on':
push:
branches:
- master
pull_request:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
env:
ALCHEMY_KEY: '${{secrets.ALCHEMY_KEY}}'
strategy:
matrix:
node-version:
- 16.x
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 16.0.x
cache: npm
- name: Install Dependencies
run: npm ci
- name: Compilation
run: 'npm run compile'
- name: Tests
run: 'npm run test'
- name: Fork Tests
run: 'npm run test-fork'
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,9 @@ coverage.json

.DS_Store

deployments/
deployments/

# Certora
.certora*
.last_confs
certora_*
24 changes: 24 additions & 0 deletions certora/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
default: help

PATCH = applyHarness.patch
CONTRACTS_DIR = ../contracts
MUNGED_DIR = munged

help:
@echo "usage:"
@echo " make clean: remove all generated files (those ignored by git)"
@echo " make $(MUNGED_DIR): create $(MUNGED_DIR) directory by applying the patch file to $(CONTRACTS_DIR)"
@echo " make record: record a new patch file capturing the differences between $(CONTRACTS_DIR) and $(MUNGED_DIR)"

munged: $(wildcard $(CONTRACTS_DIR)/*.sol) $(PATCH)
rm -rf $@
cp -r $(CONTRACTS_DIR) $@
patch -p0 -d $@ < $(PATCH)

record:
diff -ruN $(CONTRACTS_DIR) $(MUNGED_DIR) | sed 's+\.\./contracts/++g' | sed 's+munged/++g' > $(PATCH)

clean:
git clean -fdX
touch $(PATCH)

28 changes: 28 additions & 0 deletions certora/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
## Verification Overview
The current directory contains Certora's formal verification of AAVE's L2 bridge protocol.
In this directory you will find three subdirectories:

1. specs - Contains all the specification files that were written by Certora for the bridge protocol. We have created two spec files, `Optimism_ArbitrumBridge.spec`, `PolygonBridge.spec`, the first is used to verify Optimism and Arbitrum executors and the second for Polygon. The choice for this separation relies on the contracts inhertiance of these three bridges protocols.
We emphasize that essentially the rules in both specs are the same (by context, name and logical idea), but the implementation might be a bit different due to implementation differences (for example the name given to the 'external queue' function.)

2. scripts - Contains all the necessary run scripts to execute the spec files on the Certora Prover. These scripts composed of a run command of Certora Prover, contracts to take into account in the verification context, declaration of the compiler and a set of additional settings. Each script is named after the bridge type it verifies. Note that the Optimism and Arbitrum bridges are verified by the same spec file, but have separate scripts.

3. harness - Contains all the inheriting contracts that add/simplify functionalities to the original contract. You will also find a set of symbolic and dummy implementations of external contracts on which the executors rely.
These harnesses, i.e. extensions/simplifications, are necessary to run the verifications. Assumptions and under-approximations are also done in a few places, in order to supply partial coverage where full coverage is not achievable.
One harness worth explaining is the mockTarget and mockTargetPoly contracts that were created in order to simualte the low-level calls of the executed transactions.

</br>

---

## Running Instructions
To run a verification job:

1. Open terminal and `cd` your way to the main AAVE L2 repository.

2. Run the script you'd like to get results for:
```
sh certora/scripts/verifyOptimism.sh
```

</br>
Loading