Skip to content

Commit

Permalink
Add an invariant for singleton address
Browse files Browse the repository at this point in the history
  • Loading branch information
mmv08 committed May 17, 2023
1 parent ad9b319 commit 5c79cfe
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion certora/specs/Safe.spec
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ definition reachableOnly(method f) returns bool =
f.selector != sig:setup(address[],uint256,address,bytes,address,address,uint256,address).selector
&& f.selector != sig:simulateAndRevert(address,bytes).selector;


/// Nonce must never decrease
rule nonceMonotonicity(method f) filtered {
f -> noHavoc(f) && reachableOnly(f)
Expand Down Expand Up @@ -81,4 +82,22 @@ invariant noDeadEnds(address dead, address lost)
requireInvariant noDeadEnds(dead, module);
requireInvariant noDeadEnds(module, dead);
}
}
}


// The singleton is a private variable, so we need to use a ghost variable to track it.
ghost address ghostSingletonAddress {
init_state axiom ghostSingletonAddress == 0;
}

hook Sstore SafeHarness.(slot 0) address newSingletonAddress STORAGE {
ghostSingletonAddress = newSingletonAddress;
}

hook Sstore SafeHarness.(slot 24440054405305269366569402256811496959409073762505157381672968839269610695612) address newSingletonAddress STORAGE {
ghostSingletonAddress = newSingletonAddress;
}

invariant sigletonAddressNeverChanges()
ghostSingletonAddress == 0
filtered { f -> reachableOnly(f) }

0 comments on commit 5c79cfe

Please sign in to comment.