Skip to content

Commit

Permalink
refactor(StakeManager): make function names more descriptive
Browse files Browse the repository at this point in the history
Some of the functions on our contracts were confusing.
This commit changes them so they describe what they actually do.
  • Loading branch information
0x-r4bbit committed Jun 19, 2024
1 parent d953391 commit 3c4c463
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 87 deletions.
8 changes: 4 additions & 4 deletions certora/specs/StakeManager.spec
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ methods {
function staked.balanceOf(address) external returns (uint256) envfree;
function totalSupplyBalance() external returns (uint256) envfree;
function totalSupplyMP() external returns (uint256) envfree;
function oldManager() external returns (address) envfree;
function previousManager() external returns (address) envfree;
function _.migrateFrom(address, bool, StakeManager.Account) external => NONDET;
function _.increaseMPFromMigration(uint256) external => NONDET;
function _.increaseTotalMP(uint256) external => NONDET;
function _.migrationInitialize(uint256,uint256,uint256,uint256) external => NONDET;
function accounts(address) external returns(address, uint256, uint256, uint256, uint256, uint256, uint256) envfree;
function Math.mulDiv(uint256 a, uint256 b, uint256 c) internal returns uint256 => mulDivSummary(a,b,c);
Expand Down Expand Up @@ -54,14 +54,14 @@ function isMigrationfunction(method f) returns bool {
cases where it is zero. specifically no externall call to the migration contract */
function simplification(env e) {
require currentContract.migration == 0;
require currentContract.oldManager() == 0;
require currentContract.previousManager() == 0;
require e.msg.sender != 0;
}

definition requiresPreviousManager(method f) returns bool = (
f.selector == sig:migrationInitialize(uint256,uint256,uint256,uint256).selector ||
f.selector == sig:migrateFrom(address,bool,StakeManager.Account).selector ||
f.selector == sig:increaseMPFromMigration(uint256).selector
f.selector == sig:increaseTotalMP(uint256).selector
);

definition requiresNextManager(method f) returns bool = (
Expand Down
2 changes: 1 addition & 1 deletion certora/specs/StakeManagerProcessAccount.spec
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ hook Sstore accounts[KEY address addr].balance uint256 newValue (uint256 oldValu
definition requiresPreviousManager(method f) returns bool = (
f.selector == sig:migrationInitialize(uint256,uint256,uint256,uint256).selector ||
f.selector == sig:migrateFrom(address,bool,StakeManager.Account).selector ||
f.selector == sig:increaseMPFromMigration(uint256).selector
f.selector == sig:increaseTotalMP(uint256).selector
);

definition requiresNextManager(method f) returns bool = (
Expand Down
2 changes: 1 addition & 1 deletion certora/specs/StakeManagerStartMigration.spec
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ methods {
function staked.balanceOf(address) external returns (uint256) envfree;
function totalSupplyBalance() external returns (uint256) envfree;
function totalSupplyMP() external returns (uint256) envfree;
function oldManager() external returns (address) envfree;
function previousManager() external returns (address) envfree;
function accounts(address) external returns(address, uint256, uint256, uint256, uint256, uint256, uint256) envfree;

function _.migrationInitialize(uint256,uint256,uint256,uint256) external => DISPATCHER(true);
Expand Down
4 changes: 2 additions & 2 deletions certora/specs/StakeVault.spec
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ methods {
function ERC20A.totalSupply() external returns(uint256) envfree;
function StakeManager.accounts(address) external returns(address, uint256, uint256, uint256, uint256, uint256, uint256) envfree;
function _.migrateFrom(address, bool, StakeManager.Account) external => DISPATCHER(true);
function _.increaseMPFromMigration(uint256) external => DISPATCHER(true);
function _.increaseTotalMP(uint256) external => DISPATCHER(true);
function _.owner() external => DISPATCHER(true);
function Math.mulDiv(uint256 a, uint256 b, uint256 c) internal returns uint256 => mulDivSummary(a,b,c);
}
Expand All @@ -27,7 +27,7 @@ function getAccountBalance(address addr) returns uint256 {
definition isMigrationFunction(method f) returns bool = (
f.selector == sig:stakeManager.migrationInitialize(uint256,uint256,uint256,uint256).selector ||
f.selector == sig:stakeManager.migrateFrom(address,bool,StakeManager.Account).selector ||
f.selector == sig:stakeManager.increaseMPFromMigration(uint256).selector ||
f.selector == sig:stakeManager.increaseTotalMP(uint256).selector ||
f.selector == sig:stakeManager.startMigration(address).selector
);

Expand Down
Loading

0 comments on commit 3c4c463

Please sign in to comment.