-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #38 from morpho-org/colin@verif/pre-liquidations-r…
…epay Verif pre-liquidations repay
- Loading branch information
Showing
7 changed files
with
123 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ jobs: | |
matrix: | ||
conf: | ||
- Immutability | ||
- Liveness | ||
- Reentrancy | ||
|
||
steps: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,16 @@ | ||
{ | ||
"files": [ | ||
"src/PreLiquidation.sol", | ||
], | ||
"solc": "solc-0.8.27", | ||
"solc_via_ir" : true, | ||
"verify": "PreLiquidation:certora/specs/Immutability.spec", | ||
"prover_args": [ | ||
"-depth 3", | ||
"-mediumTimeout 20", | ||
"-timeout 120", | ||
], | ||
"rule_sanity": "basic", | ||
"server": "production", | ||
"msg": "PreLiquidation Immutability", | ||
"files": [ | ||
"src/PreLiquidation.sol" | ||
], | ||
"solc": "solc-0.8.27", | ||
"solc_via_ir": true, | ||
"verify": "PreLiquidation:certora/specs/Immutability.spec", | ||
"prover_args": [ | ||
"-depth 3", | ||
"-mediumTimeout 20", | ||
"-timeout 120" | ||
], | ||
"rule_sanity": "basic", | ||
"server": "production", | ||
"msg": "PreLiquidation Immutability" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
{ | ||
"files": [ | ||
"src/PreLiquidation.sol", | ||
"lib/morpho-blue/src/Morpho.sol" | ||
], | ||
"link": [ | ||
"PreLiquidation:MORPHO=Morpho" | ||
], | ||
"parametric_contracts": [ | ||
"PreLiquidation" | ||
], | ||
"solc_via_ir": true, | ||
"verify": "PreLiquidation:certora/specs/Liveness.spec", | ||
"solc_optimize_map": { | ||
"Morpho": "99999", | ||
"PreLiquidation": "99999" | ||
}, | ||
"solc_map": { | ||
"Morpho": "solc-0.8.19", | ||
"PreLiquidation": "solc-0.8.27" | ||
}, | ||
"prover_args": [ | ||
"-depth 3", | ||
"-mediumTimeout 20", | ||
"-timeout 120", | ||
"-smt_nonLinearArithmetic true" | ||
], | ||
"rule_sanity": "basic", | ||
"server": "production", | ||
"msg": "PreLiquidation Liveness" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
{ | ||
"files": [ | ||
"src/PreLiquidation.sol", | ||
], | ||
"solc": "solc-0.8.27", | ||
"solc_via_ir" : true, | ||
"verify": "PreLiquidation:certora/specs/Reentrancy.spec", | ||
"prover_args": [ | ||
"-enableStorageSplitting false", | ||
"-depth 3", | ||
"-mediumTimeout 20", | ||
"-timeout 120", | ||
], | ||
"rule_sanity": "basic", | ||
"server": "production", | ||
"msg": "PreLiquidation Reentrancy", | ||
"files": [ | ||
"src/PreLiquidation.sol" | ||
], | ||
"solc": "solc-0.8.27", | ||
"solc_via_ir": true, | ||
"verify": "PreLiquidation:certora/specs/Reentrancy.spec", | ||
"prover_args": [ | ||
"-enableStorageSplitting false", | ||
"-depth 3", | ||
"-mediumTimeout 20", | ||
"-timeout 120" | ||
], | ||
"rule_sanity": "basic", | ||
"server": "production", | ||
"msg": "PreLiquidation Reentrancy" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// SPDX-License-Identifier: GPL-2.0-or-later | ||
|
||
using PreLiquidation as preLiq; | ||
|
||
methods { | ||
function preLiq.MORPHO() external returns address envfree; | ||
} | ||
|
||
// True when `preLiquidate` has been called. | ||
persistent ghost bool preLiquidateCalled; | ||
|
||
// True when `onMorphoRepay` has been called. | ||
persistent ghost bool onMorphoRepayCalled; | ||
|
||
hook CALL(uint g, address addr, uint value, uint argsOffset, uint argsLength, uint retOffset, uint retLength) uint rc { | ||
if (selector == sig:preLiquidate(address, uint256, uint256, bytes).selector) { | ||
preLiquidateCalled = true; | ||
} else if (selector == sig:onMorphoRepay(uint256, bytes).selector) { | ||
onMorphoRepayCalled = true; | ||
} | ||
} | ||
|
||
// Check that pre-liquidations happen if and only if `onMorphoRepay` is called. | ||
rule preLiquidateRepays(method f, env e, calldataarg data) { | ||
// Set up the initial state. | ||
require !preLiquidateCalled; | ||
require !onMorphoRepayCalled; | ||
|
||
// Safe require because Morpho cannot send transactions. | ||
require e.msg.sender != preLiq.MORPHO(); | ||
// Capture the first method call which is not performed with a CALL opcode. | ||
if (f.selector == sig:preLiquidate(address, uint256, uint256, bytes).selector) { | ||
preLiquidateCalled = true; | ||
} else if (f.selector == sig:onMorphoRepay(uint256, bytes).selector) { | ||
onMorphoRepayCalled = true; | ||
} | ||
|
||
f@withrevert(e,data); | ||
|
||
// Avoid failing vacuity checks, either the proposition is true or the execution reverts. | ||
assert !lastReverted => (preLiquidateCalled <=> onMorphoRepayCalled); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters