Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
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
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ docs/
# Certora
.certora**
emv-*-certora*
certora/munged

# Hardhat
/types
Expand Down
12 changes: 5 additions & 7 deletions certora/harness/MorphoHarness.sol
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity 0.8.19;

import "../munged/Morpho.sol";
import "../munged/libraries/SharesMathLib.sol";
import "../munged/libraries/MarketParamsLib.sol";
import "../../src/Morpho.sol";
import "../../src/libraries/SharesMathLib.sol";
import "../../src/libraries/MarketParamsLib.sol";

contract MorphoHarness is Morpho {
using MarketParamsLib for MarketParams;
Expand Down Expand Up @@ -74,10 +74,8 @@ contract MorphoHarness is Morpho {
return marketParams.id();
}

function optimizedId(MarketParams memory marketParams) external pure returns (Id marketParamsId) {
assembly ("memory-safe") {
marketParamsId := keccak256(marketParams, mul(5, 32))
}
function refId(MarketParams memory marketParams) external pure returns (Id marketParamsId) {
marketParamsId = Id.wrap(keccak256(abi.encode(marketParams)));
}

function libMulDivUp(uint256 x, uint256 y, uint256 d) public pure returns (uint256) {
Expand Down
4 changes: 2 additions & 2 deletions certora/harness/TransferHarness.sol
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity ^0.8.12;

import "../munged/libraries/SafeTransferLib.sol";
import "../munged/interfaces/IERC20.sol";
import "../../src/libraries/SafeTransferLib.sol";
import "../../src/interfaces/IERC20.sol";

interface IERC20Extended is IERC20 {
function balanceOf(address) external view returns (uint256);
Expand Down
12 changes: 0 additions & 12 deletions certora/makefile

This file was deleted.

14 changes: 0 additions & 14 deletions certora/munging.patch

This file was deleted.

2 changes: 0 additions & 2 deletions certora/scripts/verifyAccrueInterest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

set -euxo pipefail

make -C certora munged

certoraRun \
certora/harness/MorphoHarness.sol \
--verify MorphoHarness:certora/specs/AccrueInterest.spec \
Expand Down
2 changes: 0 additions & 2 deletions certora/scripts/verifyConsistentState.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

set -euxo pipefail

make -C certora munged

certoraRun \
certora/harness/MorphoHarness.sol \
--verify MorphoHarness:certora/specs/ConsistentState.spec \
Expand Down
2 changes: 0 additions & 2 deletions certora/scripts/verifyExactMath.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

set -euxo pipefail

make -C certora munged

certoraRun \
certora/harness/MorphoHarness.sol \
--verify MorphoHarness:certora/specs/ExactMath.spec \
Expand Down
2 changes: 0 additions & 2 deletions certora/scripts/verifyExitLiquidity.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

set -euxo pipefail

make -C certora munged

certoraRun \
certora/harness/MorphoHarness.sol \
--verify MorphoHarness:certora/specs/ExitLiquidity.spec \
Expand Down
4 changes: 1 addition & 3 deletions certora/scripts/verifyHealth.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@

set -euxo pipefail

make -C certora munged

certoraRun \
certora/harness/MorphoHarness.sol \
certora/munged/mocks/OracleMock.sol \
src/mocks/OracleMock.sol \
--verify MorphoHarness:certora/specs/Health.spec \
--prover_args '-smt_hashingScheme plaininjectivity' \
--msg "Morpho Blue Health Check" \
Expand Down
2 changes: 0 additions & 2 deletions certora/scripts/verifyLibSummary.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

set -euxo pipefail

make -C certora munged

certoraRun \
certora/harness/MorphoHarness.sol \
--verify MorphoHarness:certora/specs/LibSummary.spec \
Expand Down
2 changes: 0 additions & 2 deletions certora/scripts/verifyLiveness.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

set -euxo pipefail

make -C certora munged

certoraRun \
certora/harness/MorphoInternalAccess.sol \
--verify MorphoInternalAccess:certora/specs/Liveness.spec \
Expand Down
2 changes: 0 additions & 2 deletions certora/scripts/verifyRatioMath.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

set -euxo pipefail

make -C certora munged

certoraRun \
certora/harness/MorphoHarness.sol \
--verify MorphoHarness:certora/specs/RatioMath.spec \
Expand Down
2 changes: 0 additions & 2 deletions certora/scripts/verifyReentrancy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

set -euxo pipefail

make -C certora munged

certoraRun \
certora/harness/MorphoHarness.sol \
--verify MorphoHarness:certora/specs/Reentrancy.spec \
Expand Down
2 changes: 0 additions & 2 deletions certora/scripts/verifyReverts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

set -euxo pipefail

make -C certora munged

certoraRun \
certora/harness/MorphoHarness.sol \
--verify MorphoHarness:certora/specs/Reverts.spec \
Expand Down
2 changes: 0 additions & 2 deletions certora/scripts/verifyTransfer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

set -euxo pipefail

make -C certora munged

certoraRun \
certora/harness/TransferHarness.sol \
certora/dispatch/ERC20Standard.sol \
Expand Down
10 changes: 5 additions & 5 deletions certora/specs/LibSummary.spec
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@ methods {
function libMulDivUp(uint256, uint256, uint256) external returns uint256 envfree;
function libMulDivDown(uint256, uint256, uint256) external returns uint256 envfree;
function libId(MorphoHarness.MarketParams) external returns MorphoHarness.Id envfree;
function optimizedId(MorphoHarness.MarketParams) external returns MorphoHarness.Id envfree;
function refId(MorphoHarness.MarketParams) external returns MorphoHarness.Id envfree;
}

// Check the summary of mulDivUp required by RatioMath.spec
// Check the summary of MathLib.mulDivUp required by RatioMath.spec
rule checkSummaryMulDivUp(uint256 x, uint256 y, uint256 d) {
uint256 result = libMulDivUp(x, y, d);
assert result * d >= x * y;
}

// Check the summary of mulDivDown required by RatioMath.spec
// Check the summary of MathLib.mulDivDown required by RatioMath.spec
rule checkSummaryMulDivDown(uint256 x, uint256 y, uint256 d) {
uint256 result = libMulDivDown(x, y, d);
assert result * d <= x * y;
}

// Check the munging of the MarketParams.id function.
// Check the summary of MarketParamsLib.id required by Liveness.spec
rule checkSummaryId(MorphoHarness.MarketParams marketParams) {
assert optimizedId(marketParams) == libId(marketParams);
assert libId(marketParams) == refId(marketParams);
}
6 changes: 6 additions & 0 deletions certora/specs/Liveness.spec
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ methods {
function fee(MorphoInternalAccess.Id) external returns uint256 envfree;
function lastUpdate(MorphoInternalAccess.Id) external returns uint256 envfree;
function libId(MorphoInternalAccess.MarketParams) external returns MorphoInternalAccess.Id envfree;
function refId(MorphoInternalAccess.MarketParams) external returns MorphoInternalAccess.Id envfree;

function _._accrueInterest(MorphoInternalAccess.MarketParams memory marketParams, MorphoInternalAccess.Id id) internal with (env e) => summaryAccrueInterest(e, marketParams, id) expect void;

function MarketParamsLib.id(MorphoInternalAccess.MarketParams memory marketParams) internal returns MorphoInternalAccess.Id => summaryId(marketParams);
function SafeTransferLib.safeTransfer(address token, address to, uint256 value) internal => summarySafeTransferFrom(token, currentContract, to, value);
function SafeTransferLib.safeTransferFrom(address token, address from, address to, uint256 value) internal => summarySafeTransferFrom(token, from, to, value);
}
Expand All @@ -22,6 +24,10 @@ ghost mapping(address => mathint) myBalances {
init_state axiom (forall address token. myBalances[token] == 0);
}

function summaryId(MorphoInternalAccess.MarketParams marketParams) returns MorphoInternalAccess.Id {
return refId(marketParams);
}

function summarySafeTransferFrom(address token, address from, address to, uint256 amount) {
if (from == currentContract) {
// Safe require because the reference implementation would revert.
Expand Down