This repository has been archived by the owner on Sep 27, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 188
/
ManagerFullSolution.spec
67 lines (50 loc) · 2.24 KB
/
ManagerFullSolution.spec
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
methods {
getCurrentManager(uint256 fundId) returns (address) envfree
getPendingManager(uint256 fundId) returns (address) envfree
isActiveManager(address a) returns (bool) envfree
}
invariant ManagerZeroIsNotActive()
!isActiveManager(0)
invariant step0_uniqueManagerAsInvariant(uint256 fundId1, uint256 fundId2)
fundId1 != fundId2 => (getCurrentManager(fundId1) != getCurrentManager(fundId2) )
invariant step1_uniqueManagerAsInvariant(uint256 fundId1, uint256 fundId2)
fundId1 != fundId2 => (getCurrentManager(fundId1) != getCurrentManager(fundId2) ||
getCurrentManager(fundId1) == 0 || getCurrentManager(fundId2) == 0 )
invariant step2_activeCurrentManger(uint256 fundId)
getCurrentManager(fundId) != 0 => isActiveManager(getCurrentManager(fundId))
invariant step3_activeCurrentManger(uint256 fundId)
getCurrentManager(fundId) != 0 => isActiveManager(getCurrentManager(fundId))
{
preserved claimManagement(uint256 fundIdClaimed) with(env e) {
require fundIdClaimed == fundId;
}
}
invariant step4_uniqueManagerAsInvariant(uint256 fundId1, uint256 fundId2)
fundId1 != fundId2 => (getCurrentManager(fundId1) != getCurrentManager(fundId2) ||
getCurrentManager(fundId1) == 0 || getCurrentManager(fundId2) == 0 )
{
preserved {
requireInvariant step3_activeCurrentManger(fundId1);
requireInvariant step3_activeCurrentManger(fundId2);
}
}
rule uniqueManagerAsRule(uint256 fundId1, uint256 fundId2, method f) {
require fundId1 != fundId2;
require getCurrentManager(fundId1) != 0 => isActiveManager(getCurrentManager(fundId1));
require getCurrentManager(fundId2) != 0 => isActiveManager(getCurrentManager(fundId2));
require getCurrentManager(fundId1) != getCurrentManager(fundId2) ;
env e;
if (f.selector == claimManagement(uint256).selector)
{
uint256 id;
require id == fundId1 || id == fundId2;
claimManagement(e, id);
}
else {
calldataarg args;
f(e,args);
}
assert getCurrentManager(fundId1) != getCurrentManager(fundId2), "managers not different";
assert getCurrentManager(fundId1) != 0 => isActiveManager(getCurrentManager(fundId1)), "manager of fund1 is not active";
assert getCurrentManager(fundId2) != 0 => isActiveManager(getCurrentManager(fundId2)), "manager of fund2 is not active";
}