Skip to content

Commit e6aa067

Browse files
committed
refactor: address review comments
1 parent a8db00d commit e6aa067

13 files changed

+76
-118
lines changed

certora/DssVestMintable.conf

+14-25
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,25 @@
11
{
2+
"verify": "DssVestMintable:certora/DssVestMintable.spec",
3+
"parametric_contracts": [
4+
"DssVestMintable"
5+
],
26
"files": [
37
"src/DssVest.sol:DssVestMintable",
4-
"certora/mocks/DSToken.sol",
5-
"certora/mocks/MockAuthority.sol",
8+
"certora/harness/DSToken.sol",
9+
"certora/harness/MockAuthority.sol"
610
],
7-
"link": [
8-
"DssVestMintable:gem=DSToken",
9-
"DSToken:authority=MockAuthority"
10-
],
11-
"rule_sanity": "basic",
12-
"multi_assert_check": true,
13-
"wait_for_results": "all",
14-
"solc_map": {
15-
"DssVestMintable": "solc-0.6.12",
16-
"DSToken": "solc-0.6.12",
17-
"MockAuthority": "solc-0.6.12"
18-
},
11+
"solc": "solc-0.6.12",
1912
"solc_optimize_map": {
2013
"DssVestMintable": "200",
2114
"DSToken": "0",
2215
"MockAuthority": "0"
2316
},
24-
"verify": "DssVestMintable:certora/DssVestMintable.spec",
25-
"prover_args": [
26-
"-smt_hashingScheme plainInjectivity",
27-
"-s [yices,z3]",
28-
"-splitParallel true",
29-
"-mediumTimeout 3600",
30-
"-depth 30",
31-
"-enableSolidityBasedInlining true"
17+
"link": [
18+
"DssVestMintable:gem=DSToken",
19+
"DSToken:authority=MockAuthority"
3220
],
33-
"parametric_contracts": [
34-
"DssVestMintable"
35-
]
21+
"build_cache": true,
22+
"rule_sanity": "basic",
23+
"multi_assert_check": true,
24+
"wait_for_results": "all"
3625
}

certora/DssVestMintable.spec

+9-12
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
// DssVestMintable.spec
22

3-
// certoraRun src/DssVest.sol:DssVestMintable certora/DSToken.sol certora/MockAuthority.sol --link DssVestMintable:gem=DSToken DSToken:authority=MockAuthority --verify DssVestMintable:certora/DssVestMintable.spec --rule_sanity
4-
53
using DSToken as token;
64
using MockAuthority as authority;
75

@@ -38,14 +36,13 @@ hook Sload uint256 value locked {
3836
require lockedGhost() == value;
3937
}
4038

41-
invariant everythingNotSetIfUsrNotSet(uint256 _id) usr(_id) == 0 => bgn(_id) == 0 && clf(_id) == 0 && fin(_id) == 0 && mgr(_id) == 0 && res(_id) == 0 && tot(_id) == 0 && rxd(_id) == 0
42-
filtered { f -> !f.isFallback }
43-
invariant usrCantBeZeroIfCreate(uint256 _id) _id > 0 && _id <= ids() => usr(_id) != 0
44-
filtered { f -> !f.isFallback }
45-
invariant clfGreaterOrEqualBgn(uint256 _id) clf(_id) >= bgn(_id)
46-
filtered { f -> !f.isFallback }
47-
invariant finGreaterOrEqualClf(uint256 _id) fin(_id) >= clf(_id)
48-
filtered { f -> !f.isFallback }
39+
invariant everythingNotSetIfUsrNotSet(uint256 _id) usr(_id) == 0 => bgn(_id) == 0 && clf(_id) == 0 && fin(_id) == 0 && mgr(_id) == 0 && res(_id) == 0 && tot(_id) == 0 && rxd(_id) == 0;
40+
41+
invariant usrCantBeZeroIfCreate(uint256 _id) _id > 0 && _id <= ids() => usr(_id) != 0;
42+
43+
invariant clfGreaterOrEqualBgn(uint256 _id) clf(_id) >= bgn(_id);
44+
45+
invariant finGreaterOrEqualClf(uint256 _id) fin(_id) >= clf(_id);
4946

5047
// The following invariant is replaced with a rule as it was kind of difficult to be finished this way.
5148
// Leaving this commented for possible future option to be finished.
@@ -286,8 +283,8 @@ rule create_revert(address _usr, uint256 _tot, uint256 _bgn, uint256 _tau, uint2
286283

287284
create@withrevert(e, _usr, _tot, _bgn, _tau, _eta, _mgr);
288285

289-
mathint clf = to_mathint(_bgn) + to_mathint(_eta);
290-
mathint fin = to_mathint(_bgn) + to_mathint(_tau);
286+
mathint clf = _bgn + _eta;
287+
mathint fin = _bgn + _tau;
291288

292289
bool revert1 = e.msg.value > 0;
293290
bool revert2 = ward != 1;

certora/DssVestSuckable.conf

+18-31
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,38 @@
11
{
2+
"verify": "DssVestSuckable:certora/DssVestSuckable.spec",
3+
"parametric_contracts": [
4+
"DssVestSuckable"
5+
],
26
"files": [
37
"src/DssVest.sol:DssVestSuckable",
4-
"certora/mocks/ChainLog.sol",
5-
"certora/mocks/Dai.sol",
6-
"certora/mocks/DaiJoin.sol",
7-
"certora/mocks/DSToken.sol",
8-
"certora/mocks/MockAuthority.sol",
9-
"certora/mocks/Vat.sol"
10-
],
11-
"link": [
12-
"DssVestSuckable:chainlog=ChainLog",
13-
"DssVestSuckable:join=DaiJoin",
14-
"DssVestSuckable:vat=Vat",
15-
"DaiJoin:vat=Vat",
16-
"DaiJoin:dai=Dai"
8+
"certora/harness/ChainLog.sol",
9+
"certora/harness/Dai.sol",
10+
"certora/harness/DaiJoin.sol",
11+
"certora/harness/Vat.sol"
1712
],
18-
"rule_sanity": "basic",
19-
"multi_assert_check": true,
20-
"wait_for_results": "all",
2113
"solc_map": {
2214
"DssVestSuckable": "solc-0.6.12",
2315
"ChainLog": "solc-0.6.12",
2416
"Dai": "solc-0.5.12",
2517
"DaiJoin": "solc-0.5.12",
26-
"DSToken": "solc-0.6.12",
27-
"MockAuthority": "solc-0.6.12",
2818
"Vat": "solc-0.5.12"
2919
},
3020
"solc_optimize_map": {
3121
"DssVestSuckable": "200",
3222
"ChainLog": "0",
3323
"Dai": "0",
3424
"DaiJoin": "0",
35-
"DSToken": "0",
36-
"MockAuthority": "0",
3725
"Vat": "0"
3826
},
39-
"verify": "DssVestSuckable:certora/DssVestSuckable.spec",
40-
"prover_args": [
41-
"-smt_hashingScheme plainInjectivity",
42-
"-s [yices,z3]",
43-
"-splitParallel true",
44-
"-mediumTimeout 3600",
45-
"-depth 30",
46-
"-enableSolidityBasedInlining true"
27+
"link": [
28+
"DssVestSuckable:chainlog=ChainLog",
29+
"DssVestSuckable:join=DaiJoin",
30+
"DssVestSuckable:vat=Vat",
31+
"DaiJoin:vat=Vat",
32+
"DaiJoin:dai=Dai"
4733
],
48-
"parametric_contracts": [
49-
"DssVestSuckable"
50-
]
34+
"build_cache": true,
35+
"rule_sanity": "basic",
36+
"multi_assert_check": true,
37+
"wait_for_results": "all"
5138
}

certora/DssVestSuckable.spec

+11-14
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
// DssVestSuckable.spec
22

3-
// certoraRun src/DssVest.sol:DssVestSuckable certora/ChainLog.sol certora/Vat.sol certora/DaiJoin.sol certora/Dai.sol --link DssVestSuckable:chainlog=ChainLog DssVestSuckable:vat=Vat DssVestSuckable:join=DaiJoin DaiJoin:vat=Vat DaiJoin:dai=Dai --verify DssVestSuckable:certora/DssVestSuckable.spec --rule_sanity
4-
53
using ChainLog as chainlog;
64
using DaiJoin as join;
75
using Vat as vat;
@@ -38,7 +36,6 @@ methods {
3836
function dai.balanceOf(address) external returns (uint256) envfree;
3937
}
4038

41-
/* definition max_uint48 returns uint256 = 2^48 - 1; */
4239
definition RAY() returns uint256 = 10^27;
4340

4441
ghost lockedGhost() returns uint256;
@@ -51,14 +48,14 @@ hook Sload uint256 value locked {
5148
require lockedGhost() == value;
5249
}
5350

54-
invariant everythingNotSetIfUsrNotSet(uint256 _id) usr(_id) == 0 => bgn(_id) == 0 && clf(_id) == 0 && fin(_id) == 0 && mgr(_id) == 0 && res(_id) == 0 && tot(_id) == 0 && rxd(_id) == 0
55-
filtered { f -> !f.isFallback }
56-
invariant usrCantBeZeroIfCreate(uint256 _id) _id > 0 && _id <= ids() => usr(_id) != 0
57-
filtered { f -> !f.isFallback }
58-
invariant clfGreaterOrEqualBgn(uint256 _id) clf(_id) >= bgn(_id)
59-
filtered { f -> !f.isFallback }
60-
invariant finGreaterOrEqualClf(uint256 _id) fin(_id) >= clf(_id)
61-
filtered { f -> !f.isFallback }
51+
invariant everythingNotSetIfUsrNotSet(uint256 _id) usr(_id) == 0 => bgn(_id) == 0 && clf(_id) == 0 && fin(_id) == 0 && mgr(_id) == 0 && res(_id) == 0 && tot(_id) == 0 && rxd(_id) == 0;
52+
53+
invariant usrCantBeZeroIfCreate(uint256 _id) _id > 0 && _id <= ids() => usr(_id) != 0;
54+
55+
invariant clfGreaterOrEqualBgn(uint256 _id) clf(_id) >= bgn(_id);
56+
57+
invariant finGreaterOrEqualClf(uint256 _id) fin(_id) >= clf(_id);
58+
6259

6360
// The following invariant is replaced with a rule as it was kind of difficult to be finished this way.
6461
// Leaving this commented for possible future option to be finished.
@@ -75,7 +72,7 @@ filtered { f -> !f.isFallback }
7572
// init_state axiom rxd(_id) == 0;
7673
// }
7774

78-
rule rxdLessOrEqualTot(method f) filtered { f -> !f.isFallback } {
75+
rule rxdLessOrEqualTot(method f) {
7976
env e;
8077
uint256 _id;
8178

@@ -299,8 +296,8 @@ rule create_revert(address _usr, uint256 _tot, uint256 _bgn, uint256 _tau, uint2
299296

300297
create@withrevert(e, _usr, _tot, _bgn, _tau, _eta, _mgr);
301298

302-
mathint clf = to_mathint(_bgn) + to_mathint(_eta);
303-
mathint fin = to_mathint(_bgn) + to_mathint(_tau);
299+
mathint clf = _bgn + _eta;
300+
mathint fin = _bgn + _tau;
304301

305302
bool revert1 = e.msg.value > 0;
306303
bool revert2 = ward != 1;

certora/DssVestTransferrable.conf

+12-22
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,22 @@
11
{
2+
"verify": "DssVestTransferrable:certora/DssVestTransferrable.spec",
3+
"parametric_contracts": [
4+
"DssVestTransferrable"
5+
],
26
"files": [
37
"src/DssVest.sol:DssVestTransferrable",
4-
"certora/mocks/Dai.sol",
8+
"certora/harness/Dai.sol"
59
],
6-
"link": [
7-
"DssVestTransferrable:gem=Dai"
8-
],
9-
"rule_sanity": "basic",
10-
"multi_assert_check": true,
11-
"wait_for_results": "all",
12-
"solc_map": {
13-
"DssVestTransferrable": "solc-0.6.12",
14-
"Dai": "solc-0.6.12"
15-
},
10+
"solc": "solc-0.6.12",
1611
"solc_optimize_map": {
1712
"DssVestTransferrable": "200",
1813
"Dai": "0"
1914
},
20-
"verify": "DssVestTransferrable:certora/DssVestTransferrable.spec",
21-
"prover_args": [
22-
"-smt_hashingScheme plainInjectivity",
23-
"-s [yices,z3]",
24-
"-splitParallel true",
25-
"-mediumTimeout 3600",
26-
"-depth 30",
27-
"-enableSolidityBasedInlining true"
15+
"link": [
16+
"DssVestTransferrable:gem=Dai"
2817
],
29-
"parametric_contracts": [
30-
"DssVestTransferrable"
31-
]
18+
"build_cache": true,
19+
"rule_sanity": "basic",
20+
"multi_assert_check": true,
21+
"wait_for_results": "all"
3222
}

certora/DssVestTransferrable.spec

+11-13
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
// DssVestTransferrable.spec
22

3-
// certoraRun src/DssVest.sol:DssVestTransferrable certora/Dai.sol --link DssVestTransferrable:gem=Dai --verify DssVestTransferrable:certora/DssVestTransferrable.spec --rule_sanity
4-
53
using Dai as dai;
64

75
methods {
@@ -36,14 +34,14 @@ hook Sload uint256 value locked {
3634
require lockedGhost() == value;
3735
}
3836

39-
invariant everythingNotSetIfUsrNotSet(uint256 _id) usr(_id) == 0 => bgn(_id) == 0 && clf(_id) == 0 && fin(_id) == 0 && mgr(_id) == 0 && res(_id) == 0 && tot(_id) == 0 && rxd(_id) == 0
40-
filtered { f -> !f.isFallback }
41-
invariant usrCantBeZeroIfCreate(uint256 _id) _id > 0 && _id <= ids() => usr(_id) != 0
42-
filtered { f -> !f.isFallback }
43-
invariant clfGreaterOrEqualBgn(uint256 _id) clf(_id) >= bgn(_id)
44-
filtered { f -> !f.isFallback }
45-
invariant finGreaterOrEqualClf(uint256 _id) fin(_id) >= clf(_id)
46-
filtered { f -> !f.isFallback }
37+
invariant everythingNotSetIfUsrNotSet(uint256 _id) usr(_id) == 0 => bgn(_id) == 0 && clf(_id) == 0 && fin(_id) == 0 && mgr(_id) == 0 && res(_id) == 0 && tot(_id) == 0 && rxd(_id) == 0;
38+
39+
invariant usrCantBeZeroIfCreate(uint256 _id) _id > 0 && _id <= ids() => usr(_id) != 0;
40+
41+
invariant clfGreaterOrEqualBgn(uint256 _id) clf(_id) >= bgn(_id);
42+
43+
invariant finGreaterOrEqualClf(uint256 _id) fin(_id) >= clf(_id);
44+
4745

4846
// The following invariant is replaced with a rule as it was kind of difficult to be finished this way.
4947
// Leaving this commented for possible future option to be finished.
@@ -60,7 +58,7 @@ filtered { f -> !f.isFallback }
6058
// init_state axiom rxd(_id) == 0;
6159
// }
6260

63-
rule rxdLessOrEqualTot(method f) filtered { f -> !f.isFallback } {
61+
rule rxdLessOrEqualTot(method f) {
6462
env e;
6563
uint256 _id;
6664

@@ -284,8 +282,8 @@ rule create_revert(address _usr, uint256 _tot, uint256 _bgn, uint256 _tau, uint2
284282

285283
create@withrevert(e, _usr, _tot, _bgn, _tau, _eta, _mgr);
286284

287-
mathint clf = to_mathint(_bgn) + to_mathint(_eta);
288-
mathint fin = to_mathint(_bgn) + to_mathint(_tau);
285+
mathint clf = _bgn + _eta;
286+
mathint fin = _bgn + _tau;
289287

290288
bool revert1 = e.msg.value > 0;
291289
bool revert2 = ward != 1;
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

src/DssVest.t.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ contract DssVestTest is DSTest {
310310

311311
function testAccrued() public {
312312
uint256 id = mVest.create(address(this), 100 * days_vest, block.timestamp + 10 days, 100 days, 0, address(0));
313-
assertTrue(mVest.valid(id), "0");
313+
assertTrue(mVest.valid(id));
314314

315315
assertEq(mVest.accrued(id), 0, "1");
316316
hevm.warp(block.timestamp + 43200);

0 commit comments

Comments
 (0)