Skip to content

Niv/fix sanity failure #183

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: cli-beta
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@
**/emv*
**/collect.json

.vscode/
15 changes: 12 additions & 3 deletions CVLByExample/TransientStorage/Hooks/Mutexer.spec
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,21 @@ hook ALL_TSTORE(uint loc, uint v) {

hook ALL_TLOAD(uint loc) uint v {
if (loc == getContractLock() && executingContract == currentContract) {
require contract_lock_status == isLocked(v);
require contract_lock_status == isLocked(v), "Match contract lock status";
}
}

invariant lockStatusDontChange()
!contract_lock_status;
// invariant version is getting SANITY_FAILURE using the below rule instead
// invariant lockStatusDontChange()
// !contract_lock_status;
Comment on lines +23 to +25
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which sanity failure did you receive on this invariant?

I couldn't find a link to a failing job here:
https://certora.atlassian.net/browse/CERT-9252


rule lockStatusDontChange() {
require !contract_lock_status, "Pre condition"; // require contract is not locked
// Check that after any method call, the lock is not held
method f; env e; calldataarg args;
f(e, args);
assert !contract_lock_status;
}

// if contract was locked function call always reverted
rule checkContractLockReverts(){
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
invariant isUnlocked(env e)
getLock(e) == 0;

invariant deltaZeroWhenUnlocked(env e)
getLock(e) == 0 => getDelta(e) == 0;

invariant deltaEqualsStorage(env e)
getDelta(e) == currentContract.storageValue
{
preserved onTransactionBoundary with(env e2) {
requireInvariant isUnlocked(e2);
require getLock(e2) == 0, "Contract must be unlocked";
requireInvariant deltaZeroWhenUnlocked(e2);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,6 @@ hook Sstore _customers[KEY address user].accounts.length uint256 newLength {
numOfAccounts[user] = newLength;
}

/**
An internal step check to verify that our ghost works as expected, it should mirror the number of accounts.
Once the sload is defined, this invariant becomes a tautology
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once the sload is defined, this invariant becomes a tautology

Is sload now defined nowadays, so is this why we see the sanity failure for trivial post condition of the invariant?

*/
invariant checkNumOfAccounts(address user)
numOfAccounts[user] == bank.getNumberOfAccounts(user);

/// This Sload is required in order to eliminate adding unintializaed account balance to sumBalances.
hook Sload uint256 length _customers[KEY address user].accounts.length {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ contract ConstantProductPool is ERC20 {
}

constructor(address _token0, address _token1) {
require(token0 != address(0));
require(token0 != token1);
require(_token0 != address(0));
require(_token0 != _token1);
token0 = _token0;
token1 = _token1;
locked = 1;
Expand Down
2 changes: 1 addition & 1 deletion DEFI/LiquidityPool/certora/specs/Full.spec
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ rule sharesRoundingTripFavoursContract(env e) {
prove bug fix
*/
invariant noClientHasSharesWithMoreValueThanDepositedAmount(address a)
sharesToAmount(balanceOf(a)) <= depositedAmount()
totalSupply() == 0 || sharesToAmount(balanceOf(a)) <= depositedAmount()
{
preserved with(env e) {
require balanceOf(a) + balanceOf(e.msg.sender) < totalSupply();
Expand Down