Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into ci/invariant
Browse files Browse the repository at this point in the history
  • Loading branch information
MathisGD committed Mar 7, 2024
2 parents a5b900f + 8fd9262 commit ae79557
Show file tree
Hide file tree
Showing 67 changed files with 3,192 additions and 406 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/certora.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Certora

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

jobs:
verify:
runs-on: ubuntu-latest

strategy:
fail-fast: false

matrix:
conf:
- AccrueInterest
- AssetsAccounting
- ConsistentState
- ExactMath
- Health
- LibSummary
- Liveness
- RatioMath
- Reentrancy
- Reverts
- Transfer

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

- name: Install python
uses: actions/setup-python@v4

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

- 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/solc
- name: Verify ${{ matrix.conf }}
run: certoraRun certora/confs/${{ matrix.conf }}.conf
env:
CERTORAKEY: ${{ secrets.CERTORAKEY }}
2 changes: 1 addition & 1 deletion .github/workflows/foundry.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
uses: foundry-rs/foundry-toolchain@v1

- name: Run Forge tests in ${{ matrix.type }} mode
run: forge test -vvv
run: yarn test:forge -vvv
env:
FOUNDRY_FUZZ_RUNS: ${{ matrix.fuzz-runs }}
FOUNDRY_FUZZ_MAX_TEST_REJECTS: ${{ matrix.max-test-rejects }}
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/npm-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@ jobs:
publish-to-npm:
name: Publish to NPM
runs-on: ubuntu-latest

environment:
name: npm
url: https://www.npmjs.com/package/@morpho-org/morpho-blue

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Publish to npm
run: |
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc
yarn publish --access public
yarn publish --access public --ignore-scripts
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ docs/
# Node modules
/node_modules

# Certora
.certora**
emv-*-certora*

# Hardhat
/types
/cache_hardhat
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ All audits are stored in the [audits](./audits/)' folder.
## Licences

The primary license for Morpho Blue is the Business Source License 1.1 (`BUSL-1.1`), see [`LICENSE`](./LICENSE).
However, all files in the following folders can also be licensed under `GPL-2.0-or-later` (as indicated in their SPDX headers): [`src/interfaces`](./src/interfaces), [`src/libraries`](./src/libraries), [`src/mocks`](./src/mocks), [`test`](./test).
However, all files in the following folders can also be licensed under `GPL-2.0-or-later` (as indicated in their SPDX headers): [`src/interfaces`](./src/interfaces), [`src/libraries`](./src/libraries), [`src/mocks`](./src/mocks), [`test`](./test), [`certora`](./certora).
Binary file not shown.
389 changes: 389 additions & 0 deletions certora/LICENSE

Large diffs are not rendered by default.

287 changes: 287 additions & 0 deletions certora/README.md

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions certora/confs/AccrueInterest.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"files": [
"certora/harness/MorphoHarness.sol",
],
"verify": "MorphoHarness:certora/specs/AccrueInterest.spec",
"prover_args": [
"-depth 3",
"-smt_hashingScheme plaininjectivity",
"-mediumTimeout 30",
],
"rule_sanity": "basic",
"server": "production",
"msg": "Morpho Blue Accrue Interest"
}
9 changes: 9 additions & 0 deletions certora/confs/AssetsAccounting.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"files": [
"certora/harness/MorphoHarness.sol",
],
"verify": "MorphoHarness:certora/specs/AssetsAccounting.spec",
"rule_sanity": "basic",
"server": "production",
"msg": "Morpho Blue Assets Accounting"
}
9 changes: 9 additions & 0 deletions certora/confs/ConsistentState.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"files": [
"certora/harness/MorphoHarness.sol",
],
"verify": "MorphoHarness:certora/specs/ConsistentState.spec",
"rule_sanity": "basic",
"server": "production",
"msg": "Morpho Blue Consistent State"
}
14 changes: 14 additions & 0 deletions certora/confs/ExactMath.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"files": [
"certora/harness/MorphoHarness.sol",
],
"verify": "MorphoHarness:certora/specs/ExactMath.spec",
"rule_sanity": "basic",
"prover_args": [
"-depth 3",
"-smt_hashingScheme plaininjectivity",
"-mediumTimeout 30",
],
"server": "production",
"msg": "Morpho Blue Exact Math"
}
13 changes: 13 additions & 0 deletions certora/confs/Health.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"files": [
"certora/harness/MorphoHarness.sol",
"src/mocks/OracleMock.sol"
],
"verify": "MorphoHarness:certora/specs/Health.spec",
"rule_sanity": "basic",
"prover_args": [
"-smt_hashingScheme plaininjectivity",
],
"server": "production",
"msg": "Morpho Blue Health"
}
9 changes: 9 additions & 0 deletions certora/confs/LibSummary.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"files": [
"certora/harness/MorphoHarness.sol",
],
"verify": "MorphoHarness:certora/specs/LibSummary.spec",
"rule_sanity": "basic",
"server": "production",
"msg": "Morpho Blue Lib Summary"
}
9 changes: 9 additions & 0 deletions certora/confs/Liveness.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"files": [
"certora/harness/MorphoInternalAccess.sol",
],
"verify": "MorphoInternalAccess:certora/specs/Liveness.spec",
"rule_sanity": "basic",
"server": "production",
"msg": "Morpho Blue Liveness"
}
14 changes: 14 additions & 0 deletions certora/confs/RatioMath.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"files": [
"certora/harness/MorphoHarness.sol",
],
"verify": "MorphoHarness:certora/specs/RatioMath.spec",
"rule_sanity": "basic",
"prover_args": [
"-smt_hashingScheme plaininjectivity",
"-mediumTimeout 30",
"-timeout 3600",
],
"server": "production",
"msg": "Morpho Blue Ratio Math"
}
12 changes: 12 additions & 0 deletions certora/confs/Reentrancy.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"files": [
"certora/harness/MorphoHarness.sol",
],
"verify": "MorphoHarness:certora/specs/Reentrancy.spec",
"rule_sanity": "basic",
"prover_args": [
"-enableStorageSplitting false",
],
"server": "production",
"msg": "Morpho Blue Reentrancy"
}
9 changes: 9 additions & 0 deletions certora/confs/Reverts.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"files": [
"certora/harness/MorphoHarness.sol",
],
"verify": "MorphoHarness:certora/specs/Reverts.spec",
"rule_sanity": "basic",
"server": "production",
"msg": "Morpho Blue Reverts"
}
12 changes: 12 additions & 0 deletions certora/confs/Transfer.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"files": [
"certora/harness/TransferHarness.sol",
"certora/dispatch/ERC20Standard.sol",
"certora/dispatch/ERC20USDT.sol",
"certora/dispatch/ERC20NoRevert.sol",
],
"verify": "TransferHarness:certora/specs/Transfer.spec",
"rule_sanity": "basic",
"server": "production",
"msg": "Morpho Blue Transfer"
}
48 changes: 48 additions & 0 deletions certora/dispatch/ERC20NoRevert.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity ^0.8.0;

contract ERC20NoRevert {
address public owner;
uint256 public totalSupply;
mapping(address => uint256) public balanceOf;
mapping(address => mapping(address => uint256)) public allowance;

constructor() {
owner = msg.sender;
}

modifier onlyOwner() {
require(msg.sender == owner);
_;
}

function _transfer(address _from, address _to, uint256 _amount) internal returns (bool) {
if (balanceOf[_from] < _amount) {
return false;
}
balanceOf[_from] -= _amount;
balanceOf[_to] += _amount;
return true;
}

function transfer(address _to, uint256 _amount) public returns (bool) {
return _transfer(msg.sender, _to, _amount);
}

function transferFrom(address _from, address _to, uint256 _amount) public returns (bool) {
if (allowance[_from][msg.sender] < _amount) {
return false;
}
allowance[_from][msg.sender] -= _amount;
return _transfer(_from, _to, _amount);
}

function approve(address _spender, uint256 _amount) public {
allowance[msg.sender][_spender] = _amount;
}

function mint(address _receiver, uint256 _amount) public onlyOwner {
balanceOf[_receiver] += _amount;
totalSupply += _amount;
}
}
42 changes: 42 additions & 0 deletions certora/dispatch/ERC20Standard.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity ^0.8.0;

contract ERC20Standard {
address public owner;
uint256 public totalSupply;
mapping(address => uint256) public balanceOf;
mapping(address => mapping(address => uint256)) public allowance;

constructor() {
owner = msg.sender;
}

modifier onlyOwner() {
require(msg.sender == owner);
_;
}

function _transfer(address _from, address _to, uint256 _amount) internal returns (bool) {
balanceOf[_from] -= _amount;
balanceOf[_to] += _amount;
return true;
}

function transfer(address _to, uint256 _amount) public returns (bool) {
return _transfer(msg.sender, _to, _amount);
}

function transferFrom(address _from, address _to, uint256 _amount) public returns (bool) {
allowance[_from][msg.sender] -= _amount;
return _transfer(_from, _to, _amount);
}

function approve(address _spender, uint256 _amount) public {
allowance[msg.sender][_spender] = _amount;
}

function mint(address _receiver, uint256 _amount) public onlyOwner {
balanceOf[_receiver] += _amount;
totalSupply += _amount;
}
}
45 changes: 45 additions & 0 deletions certora/dispatch/ERC20USDT.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity ^0.8.0;

contract ERC20USDT {
address public owner;
uint256 public totalSupply;
mapping(address => uint256) public balanceOf;
mapping(address => mapping(address => uint256)) public allowance;

constructor() {
owner = msg.sender;
}

modifier onlyOwner() {
require(msg.sender == owner);
_;
}

function _transfer(address _from, address _to, uint256 _amount) internal {
balanceOf[_from] -= _amount;
balanceOf[_to] += _amount;
}

function transfer(address _to, uint256 _amount) public {
_transfer(msg.sender, _to, _amount);
}

function transferFrom(address _from, address _to, uint256 _amount) public {
if (allowance[_from][msg.sender] < type(uint256).max) {
allowance[_from][msg.sender] -= _amount;
}
_transfer(_from, _to, _amount);
}

function approve(address _spender, uint256 _amount) public {
require(!((_amount != 0) && (allowance[msg.sender][_spender] != 0)));

allowance[msg.sender][_spender] = _amount;
}

function mint(address _receiver, uint256 _amount) public onlyOwner {
balanceOf[_receiver] += _amount;
totalSupply += _amount;
}
}
6 changes: 6 additions & 0 deletions certora/gambit.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"filename" : "../src/Morpho.sol",
"sourceroot": "..",
"num_mutants": 15,
"solc_remappings": []
}
Loading

0 comments on commit ae79557

Please sign in to comment.