-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
certora setup for stakemanager and vault
- Loading branch information
1 parent
cf7a8b6
commit 766e412
Showing
6 changed files
with
120 additions
and
5 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
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,22 @@ | ||
{ | ||
"files": [ | ||
"contracts/StakeManager.sol", | ||
"contracts/StakeVault.sol", | ||
"certora/helpers/ERC20A.sol" | ||
], | ||
"link" : [ | ||
"StakeVault:STAKED_TOKEN=ERC20A", | ||
"StakeManager:stakedToken=ERC20A", | ||
"StakeVault:stakeManager=StakeManager" | ||
], | ||
"msg": "Verifying StakeVault.sol", | ||
"rule_sanity": "basic", | ||
"verify": "StakeVault:certora/specs/StakeVault.spec", | ||
"optimistic_loop": true, | ||
"loop_iter": "3", | ||
"packages": [ | ||
"@openzeppelin=lib/openzeppelin-contracts" | ||
] | ||
} | ||
|
||
|
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,9 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity ^0.8.18; | ||
|
||
import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; | ||
|
||
contract ERC20A is ERC20 { | ||
constructor(string memory name_, string memory symbol_) ERC20(name_, symbol_) {} | ||
} |
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,4 +1,50 @@ | ||
using ERC20A as staked; | ||
methods { | ||
function staked.balanceOf(address) external returns (uint256) envfree; | ||
} | ||
|
||
function isMigrationfunction(method f) returns bool { | ||
return f.selector == sig:leave().selector || | ||
f.selector == sig:migrate(address,StakeManager.Account).selector || | ||
f.selector == sig:migrate().selector; | ||
} | ||
|
||
rule shouldPass { | ||
assert true; | ||
/* assume that migration is zero, causing the verification to take into account only | ||
cases where it is zero. specifically no externall call to the migration contract */ | ||
function simplification() { | ||
require currentContract.migration == 0; | ||
} | ||
|
||
|
||
rule reachability(method f) | ||
{ | ||
calldataarg args; | ||
env e; | ||
f(e,args); | ||
satisfy true; | ||
} | ||
|
||
/** | ||
@title when there is no migration - some functions must revert. | ||
Other function should have non reverting cases | ||
**/ | ||
rule revertsWhenNoMigration(method f) { | ||
calldataarg args; | ||
env e; | ||
require currentContract.migration == 0; | ||
f@withrevert(e,args); | ||
bool reverted = lastReverted; | ||
if (!isMigrationfunction(f)) | ||
satisfy !reverted; | ||
assert isMigrationfunction(f) => reverted; | ||
} | ||
|
||
rule whoChangeERC20Balance( method f ) filtered { f -> f.contract != staked } | ||
{ | ||
address user; | ||
uint256 before = staked.balanceOf(user); | ||
calldataarg args; | ||
env e; | ||
f(e,args); | ||
assert before == staked.balanceOf(user); | ||
} |
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 @@ | ||
using ERC20A as staked; | ||
using StakeManager as stakeManger; | ||
methods { | ||
function ERC20A.balanceOf(address) external returns (uint256) envfree; | ||
} | ||
|
||
/* assume that migration is zero, causing to ignore cases where it is not zero */ | ||
function simplification() { | ||
require stakeManger.migration == 0; | ||
} | ||
|
||
rule reachability(method f){ | ||
calldataarg args; | ||
env e; | ||
simplification(); | ||
f(e,args); | ||
satisfy true; | ||
} | ||
|
||
|
||
|
||
rule whoChangeERC20Balance( method f ) | ||
{ | ||
simplification(); | ||
address user; | ||
uint256 before = staked.balanceOf(user); | ||
calldataarg args; | ||
env e; | ||
f(e,args); | ||
assert before == staked.balanceOf(user); | ||
} |
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