fix(Certora specs): make specs compile again

There have been a bunch of breaking changes in the staking contract that
resulted in our specs not compiling.

This commit fixes this, however it does not yet ensure the prover is
satisfied.
This commit is contained in:
r4bbit 2024-03-01 10:35:19 +01:00
parent 3c7a0c868f
commit 109b684a2c
No known key found for this signature in database
GPG Key ID: E95F1E9447DC91A9
2 changed files with 17 additions and 18 deletions

View File

@ -1,26 +1,26 @@
using ERC20A as staked; using ERC20A as staked;
methods { methods {
function staked.balanceOf(address) external returns (uint256) envfree; function staked.balanceOf(address) external returns (uint256) envfree;
function stakeSupply() external returns (uint256) envfree; function totalSupplyBalance() external returns (uint256) envfree;
function multiplierSupply() external returns (uint256) envfree; function totalSupplyMP() external returns (uint256) envfree;
function oldManager() external returns (address) envfree; function oldManager() external returns (address) envfree;
function _.migrateFrom(address, bool, StakeManager.Account) external => NONDET; function _.migrateFrom(address, bool, StakeManager.Account) external => NONDET;
function _.increaseMPFromMigration(uint256) external => NONDET; function _.increaseMPFromMigration(uint256) external => NONDET;
function _.migrationInitialize(uint256,uint256,uint256,uint256) external => NONDET; function _.migrationInitialize(uint256,uint256,uint256,uint256) external => NONDET;
function accounts(address) external returns(uint256, uint256, uint256, uint256, uint256, address) envfree; function accounts(address) external returns(address, uint256, uint256, uint256, uint256, uint256, uint256) envfree;
} }
function getAccountMultiplierPoints(address addr) returns uint256 { function getAccountMultiplierPoints(address addr) returns uint256 {
uint256 multiplierPoints; uint256 multiplierPoints;
_, _, multiplierPoints, _, _, _ = accounts(addr); _, _, _, multiplierPoints, _, _, _ = accounts(addr);
return multiplierPoints; return multiplierPoints;
} }
function getAccountBalance(address addr) returns uint256 { function getAccountBalance(address addr) returns uint256 {
uint256 balance; uint256 balance;
_, balance, _, _, _, _ = accounts(addr); _, balance, _, _, _, _, _ = accounts(addr);
return balance; return balance;
} }
@ -59,17 +59,17 @@ hook Sstore accounts[KEY address addr].balance uint256 newValue (uint256 oldValu
sumOfBalances = sumOfBalances - oldValue + newValue; sumOfBalances = sumOfBalances - oldValue + newValue;
} }
hook Sstore accounts[KEY address addr].multiplier uint256 newValue (uint256 oldValue) STORAGE { hook Sstore accounts[KEY address addr].currentMP uint256 newValue (uint256 oldValue) STORAGE {
sumOfMultipliers = sumOfMultipliers - oldValue + newValue; sumOfMultipliers = sumOfMultipliers - oldValue + newValue;
} }
invariant sumOfBalancesIsStakeSupply() invariant sumOfBalancesIsStakeSupply()
sumOfBalances == to_mathint(stakeSupply()); sumOfBalances == to_mathint(totalSupplyBalance());
invariant sumOfMultipliersIsMultiplierSupply() invariant sumOfMultipliersIsMultiplierSupply()
sumOfMultipliers == to_mathint(multiplierSupply()) sumOfMultipliers == to_mathint(totalSupplyMP())
{ preserved with (env e) { { preserved with () {
simplification(e); simplification();
} }
} }

View File

@ -3,27 +3,26 @@ using StakeManagerNew as newStakeManager;
methods { methods {
function staked.balanceOf(address) external returns (uint256) envfree; function staked.balanceOf(address) external returns (uint256) envfree;
function stakeSupply() external returns (uint256) envfree; function totalSupplyBalance() external returns (uint256) envfree;
function multiplierSupply() external returns (uint256) envfree; function totalSupplyMP() external returns (uint256) envfree;
function oldManager() external returns (address) envfree; function oldManager() external returns (address) envfree;
function accounts(address) external returns(uint256, uint256, uint256, uint256, uint256, address) envfree; function accounts(address) external returns(address, uint256, uint256, uint256, uint256, uint256, uint256) envfree;
function _.migrationInitialize(uint256,uint256,uint256,uint256) external => DISPATCHER(true); function _.migrationInitialize(uint256,uint256,uint256,uint256) external => DISPATCHER(true);
function StakeManagerNew.stakeSupply() external returns (uint256) envfree; function StakeManagerNew.totalSupplyBalance() external returns (uint256) envfree;
//function _.stakeSupply() external => DISPATCHER(true);
} }
function getAccountMultiplierPoints(address addr) returns uint256 { function getAccountMultiplierPoints(address addr) returns uint256 {
uint256 multiplierPoints; uint256 multiplierPoints;
_, _, multiplierPoints, _, _, _ = accounts(addr); _, _, _, multiplierPoints, _, _, _ = accounts(addr);
return multiplierPoints; return multiplierPoints;
} }
function getAccountBalance(address addr) returns uint256 { function getAccountBalance(address addr) returns uint256 {
uint256 balance; uint256 balance;
_, balance, _, _, _, _ = accounts(addr); _, balance, _, _, _, _, _ = accounts(addr);
return balance; return balance;
} }
@ -101,7 +100,7 @@ rule startMigrationCorrect {
startMigration(e, newContract); startMigration(e, newContract);
assert currentContract.migration == newContract; assert currentContract.migration == newContract;
assert newStakeManager.stakeSupply() == currentContract.stakeSupply(); assert newStakeManager.totalSupplyBalance() == currentContract.totalSupplyBalance();
} }
rule migrationLockedIn { rule migrationLockedIn {