Skip to content

Commit

Permalink
feat: check update root storage change
Browse files Browse the repository at this point in the history
  • Loading branch information
QGarchery committed Mar 11, 2024
1 parent 223f718 commit 0b41773
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
6 changes: 3 additions & 3 deletions certora/specs/MerkleTrees.spec
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
methods {
function newInternalNode(address, MerkleTreeLib.InternalNode) external envfree;

function getValue(address, address) external returns uint256 envfree;
function isEmpty(address, address) external returns bool envfree;
function isWellFormed(address, address) external returns bool envfree;
function getValue(address, address) external returns(uint256) envfree;
function isEmpty(address, address) external returns(bool) envfree;
function isWellFormed(address, address) external returns(bool) envfree;
}

invariant zeroIsEmpty(address tree)
Expand Down
23 changes: 17 additions & 6 deletions certora/specs/RewardsDistributor.spec
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,27 @@ using MerkleTrees as MerkleTrees;
using MorphoToken as MorphoToken;

methods {
function prevRoot() external returns bytes32 envfree;
function currRoot() external returns bytes32 envfree;
function claimed(address) external returns uint256 envfree;
function prevRoot() external returns(bytes32) envfree;
function currRoot() external returns(bytes32) envfree;
function claimed(address) external returns(uint256) envfree;
function updateRoot(bytes32) external envfree;
function claim(address, uint256, bytes32[]) external envfree;

function MerkleTrees.getValue(address, address) external returns uint256 envfree;
function MerkleTrees.getHash(address, address) external returns bytes32 envfree;
function MerkleTrees.getValue(address, address) external returns(uint256) envfree;
function MerkleTrees.getHash(address, address) external returns(bytes32) envfree;
function MerkleTrees.wellFormedPath(address, address, bytes32[]) external envfree;

function MorphoToken.balanceOf(address) external returns uint256 envfree;
function MorphoToken.balanceOf(address) external returns(uint256) envfree;
}

// Check how updateRoot changes the storage.
rule updateRootStorageChange(bytes32 _newRoot) {
bytes32 rootBefore = currRoot();

updateRoot(_newRoot);

assert prevRoot() == rootBefore;
assert currRoot() == _newRoot;
}

// Check an account claimed amount is correctly updated.
Expand Down

0 comments on commit 0b41773

Please sign in to comment.