Skip to content

Commit

Permalink
chore: add certora CI integration (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
0x-r4bbit authored Dec 11, 2023
1 parent 4d029c0 commit 5ea5fef
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 2 deletions.
3 changes: 2 additions & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ Ensure you completed **all of the steps** below before submitting your pull requ

- [ ] Added natspec comments?
- [ ] Ran `forge snapshot`?
- [ ] Ran `yarn lint`?
- [ ] Ran `pnpm lint`?
- [ ] Ran `forge test`?
- [ ] Ran `pnpm verify`?
48 changes: 48 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,51 @@ jobs:
run: |
echo "## Coverage result" >> $GITHUB_STEP_SUMMARY
echo "✅ Uploaded to Codecov" >> $GITHUB_STEP_SUMMARY
verify:
needs: ["lint", "build"]
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
with:
submodules: recursive

- 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: pip3 install certora-cli==5.0.5

- name: Install Solidity
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/solc
- name: "Install Pnpm"
uses: "pnpm/action-setup@v2"
with:
version: "8"

- name: "Install Node.js"
uses: "actions/setup-node@v3"
with:
cache: "pnpm"
node-version: "lts/*"

- name: "Install the Node.js dependencies"
run: "pnpm install"

- name: Verify rules
run: "pnpm verify"
env:
CERTORAKEY: ${{ secrets.CERTORAKEY }}

strategy:
fail-fast: false
max-parallel: 16
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ yarn.lock
!broadcast
broadcast/*
broadcast/*/31337/

.certora_internal
9 changes: 9 additions & 0 deletions certora/certora.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"files": ["src/Foo.sol"],
"msg": "Verifying Foo.sol",
"rule_sanity": "basic",
"verify": "Foo:certora/specs/Foo.spec",
"wait_for_results": "all",
}


10 changes: 10 additions & 0 deletions certora/specs/Foo.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
methods {
function id(uint256) external returns (uint256) envfree;
}

rule checkIdOutputIsAlwaysEqualToInput {
uint256 input;

assert id(input) == input;
}

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
"scripts": {
"clean": "rm -rf cache out",
"lint": "pnpm lint:sol && pnpm prettier:check",
"lint:sol": "forge fmt --check && pnpm solhint {script,src,test}/**/*.sol",
"verify": "certoraRun certora/certora.conf",
"lint:sol": "forge fmt --check && pnpm solhint {script,src,test,certora}/**/*.sol",
"prettier:check": "prettier --check **/*.{json,md,yml} --ignore-path=.prettierignore",
"prettier:write": "prettier --write **/*.{json,md,yml} --ignore-path=.prettierignore"
}
Expand Down

0 comments on commit 5ea5fef

Please sign in to comment.