Skip to content

Commit

Permalink
feat: add CI and munging
Browse files Browse the repository at this point in the history
  • Loading branch information
QGarchery committed Sep 19, 2023
1 parent ba9af93 commit e3f8412
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 2 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/certora.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Certora

on:
push:
branches:
- main
pull_request:
workflow_dispatch:

jobs:
verify:
runs-on: ubuntu-latest

steps:
- name: Generate a token
id: generate-token
uses: tibdex/github-app-token@b62528385c34dbc9f38e5f4225ac829252d1ea92
with:
app_id: ${{ secrets.APP_ID }}
private_key: ${{ secrets.APP_PRIVATE_KEY }}

- uses: actions/checkout@v3
with:
token: ${{ steps.generate-token.outputs.token }}
submodules: recursive

- name: Install python
uses: actions/setup-python@v4
with:
python-version: "3.10"

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

- name: Install solc
run: |
wget https://github.com/ethereum/solidity/releases/download/v0.8.19/solc-static-linux
chmod +x solc-static-linux
sudo mv solc-static-linux /usr/local/bin/solc8.19
- name: Verify rule ${{ matrix.script }}
run: |
echo "key length" ${#CERTORAKEY}
bash certora/scripts/${{ matrix.script }} --solc solc8.19
env:
CERTORAKEY: ${{ secrets.CERTORAKEY }}

strategy:
fail-fast: false

matrix:
script:
- verifyLiveness.sh
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,10 @@ out/
# Docs
docs/

# Certora
.certora**
emv-*-certora*
certora/munged

# Dotenv file
.env
12 changes: 12 additions & 0 deletions certora/makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
munged: $(wildcard ../src/*.sol) munging.patch
@rm -rf munged
@cp -r ../src munged
@patch -p0 -d munged < munging.patch

record:
diff -ruN ../src munged | sed 's+\.\./src/++g' | sed 's+munged/++g' > munging.patch

clean:
rm -rf munged

.PHONY: record clean # do not add munged here, as it is useful to protect munged edits
12 changes: 12 additions & 0 deletions certora/munging.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
diff -ruN Irm.sol Irm.sol
--- Irm.sol 2023-09-19 15:59:58.045886731 +0200
+++ Irm.sol 2023-09-19 16:09:50.491751975 +0200
@@ -38,7 +38,7 @@
/// @notice Speed factor (scaled by WAD).
uint256 public immutable SPEED_FACTOR;
/// @notice Target utilization (scaled by WAD).
- uint256 public immutable TARGET_UTILIZATION;
+ uint256 public TARGET_UTILIZATION;
/// @notice Initial rate (scaled by WAD).
uint128 public immutable INITIAL_RATE;

Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@

set -euxo pipefail

make -C certora munged

certoraRun \
src/Irm.sol \
--verify Irm:certora/specs/liveness.spec \
--msg "IRM liveness" \
--verify Irm:certora/specs/Liveness.spec \
--msg "IRM Liveness" \
--solc_via_ir \
--solc_optimize 200 \
"$@"
File renamed without changes.

0 comments on commit e3f8412

Please sign in to comment.