Skip to content

Commit 70ed750

Browse files
21.01.26 Release
21.01.26 Release 8bb19eca78af40b4f8b8003eaa399f18410cd2da
2 parents c4459c1 + f1e0dea commit 70ed750

File tree

516 files changed

+22249
-4727
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

516 files changed

+22249
-4727
lines changed

Public/CITests/testCertoraClient.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -787,6 +787,10 @@ def rem_quotes(string: str) -> str:
787787
self.fail(f"test_jar_flag: failed for {args} - {e}")
788788

789789
def test_validation_funcs(self) -> None:
790+
VYPER_FILE = _p("V.vy")
791+
with open(VYPER_FILE, "w") as file:
792+
file.write("")
793+
790794
attrs_with_validation: List[AttrUtil.AttributeDefinition] = [] # type: ignore
791795
for attr in Attrs.EvmProverAttributes.attribute_list():
792796
if attr.attr_validation_func != AttrUtil.default_validation:
@@ -816,6 +820,10 @@ def test_validation_funcs(self) -> None:
816820
if TestUtil.INVALID_KEY in tested_object:
817821
TestUtil.validate_invalid_values(attr, tested_object[TestUtil.INVALID_KEY])
818822

823+
824+
Path(VYPER_FILE).unlink(missing_ok=True)
825+
826+
819827
def test_package_file(self) -> None:
820828
def check_run(expect: List[str]) -> None:
821829
packages_attr = getattr(result, 'packages', None)

Public/CITests/testCertoraUtils.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,16 @@ def path_test_file(filename: str) -> str:
293293
]
294294
},
295295

296+
Vf.validate_vyper_custom_std_json_in_map: {
297+
'valid': [
298+
{path_test_file('V.vy'): path_test_file('erc20.json')}
299+
],
300+
'invalid': [
301+
{path_test_file('V.vy'): path_test_file('not_exist.json')},
302+
{'notexist.vy': path_test_file('erc20.json')}
303+
]
304+
},
305+
296306
Vf.validate_solc_optimize_map: {
297307
'valid': [
298308
{'A': '15', 'B': '15', 'C.sol': '0'}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
contract C {
2+
3+
function basicMul(uint x, uint y) public pure returns (uint) {
4+
unchecked {
5+
return x * y;
6+
}
7+
}
8+
9+
function byConst(uint x) public pure returns (uint) {
10+
unchecked {
11+
return x * 7;
12+
}
13+
}
14+
15+
function mixed(uint x, uint y) public pure returns (int) {
16+
unchecked {
17+
return int256(uint128(y) * x) + 7;
18+
}
19+
}
20+
21+
function twoMuls(uint x, uint y) public pure returns (uint) {
22+
unchecked {
23+
return x * y * x;
24+
}
25+
}
26+
27+
function shouldPass(uint x, uint y) public pure returns (uint) {
28+
require(x < 1000 && y < 1000);
29+
unchecked {
30+
return x * y;
31+
}
32+
}
33+
34+
function minus_fail(uint x, uint y) public pure returns (uint) {
35+
unchecked {
36+
return x - y;
37+
}
38+
}
39+
40+
function minus_pass(uint x, uint y) public pure returns (uint) {
41+
require(x >= y);
42+
unchecked {
43+
return x - y;
44+
}
45+
}
46+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
use builtin rule uncheckedOverflows;
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
files: [
3+
"C.sol",
4+
],
5+
verify: "C:C.spec",
6+
"unchecked_overflow_builtin" : true,
7+
"solc": "solc8.28"
8+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"rules": {
3+
"uncheckedOverflows": {
4+
"FAIL": [
5+
"basicMul(uint256,uint256)",
6+
"byConst(uint256)",
7+
"minus_fail(uint256,uint256)"
8+
],
9+
"SUCCESS": [
10+
"minus_pass(uint256,uint256)",
11+
"shouldPass(uint256,uint256)"
12+
],
13+
"mixed(uint256,uint256)": [
14+
"FAIL",
15+
"FAIL"
16+
],
17+
"twoMuls(uint256,uint256)": [
18+
"FAIL",
19+
"FAIL"
20+
]
21+
}
22+
}
23+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"files": [
3+
"./Test.sol"
4+
],
5+
"optimistic_hashing": true,
6+
"solc": "solc8.13",
7+
"verify": "Test:./Test.spec"
8+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity ^0.8.0;
3+
4+
contract Test {
5+
// Simple struct (no arrays)
6+
struct SimpleStruct {
7+
uint256 x;
8+
int128 y;
9+
}
10+
11+
// Struct with array field
12+
struct StructWithArray {
13+
uint256 id;
14+
uint256[] values;
15+
}
16+
17+
// Struct with nested struct and array
18+
struct StructWithNestedAndArray {
19+
SimpleStruct inner;
20+
uint256[] arr;
21+
}
22+
23+
// For testing array of structs
24+
function createSimpleStruct(uint256 x, int128 y) external pure returns (SimpleStruct memory) {
25+
return SimpleStruct(x, y);
26+
}
27+
28+
function createIntArray(uint256 a, uint256 b, uint256 c) external pure returns (uint256[] memory) {
29+
uint256[] memory arr = new uint256[](3);
30+
arr[0] = a;
31+
arr[1] = b;
32+
arr[2] = c;
33+
return arr;
34+
}
35+
36+
function createStructWithArray(uint256 id, uint256 a, uint256 b) external pure returns (StructWithArray memory) {
37+
uint256[] memory values = new uint256[](2);
38+
values[0] = a;
39+
values[1] = b;
40+
return StructWithArray(id, values);
41+
}
42+
}
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
using Test as test;
2+
3+
methods {
4+
function createSimpleStruct(uint256 x, int128 y) external returns (Test.SimpleStruct memory) envfree;
5+
function createIntArray(uint256 a, uint256 b, uint256 c) external returns (uint256[] memory) envfree;
6+
function createStructWithArray(uint256 id, uint256 a, uint256 b) external returns (Test.StructWithArray memory) envfree;
7+
}
8+
9+
// Test 1: Compare primitive arrays (uint256[])
10+
rule comparePrimitiveArrays {
11+
uint256[] arr1; uint256[] arr2;
12+
13+
// Can't use `<=>` here because that causes double polarity of the quantifier and breaks grounding
14+
assert arr1 == arr2 => (arr1.length == arr2.length && (forall uint256 i. i < arr1.length => arr1[i] == arr2[i]));
15+
assert (arr1.length == arr2.length && (forall uint256 i. i < arr1.length => arr1[i] == arr2[i])) => arr1 == arr2;
16+
}
17+
18+
// Test 2: Reflexivity of array comparison
19+
rule arrayComparisonReflexive {
20+
uint256[] arr;
21+
assert arr == arr;
22+
}
23+
24+
// Test 3: Symmetry of array comparison
25+
rule arrayComparisonSymmetric {
26+
uint256[] arr1; uint256[] arr2;
27+
assert (arr1 == arr2) == (arr2 == arr1);
28+
}
29+
30+
// Test 4: Compare function return array
31+
rule compareFunctionReturnArray {
32+
uint256 a; uint256 b; uint256 c;
33+
uint256[] arr;
34+
require arr.length == 3;
35+
require arr[0] == a && arr[1] == b && arr[2] == c;
36+
assert createIntArray(a, b, c) == arr;
37+
}
38+
39+
// Test 5: Compare structs containing arrays
40+
rule compareStructsWithArrays {
41+
Test.StructWithArray s1; Test.StructWithArray s2;
42+
assert s1 == s2 <=> (s1.id == s2.id && s1.values == s2.values);
43+
}
44+
45+
// Test 6: Compare structs with array - reflexive
46+
rule structWithArrayReflexive {
47+
Test.StructWithArray s;
48+
assert s == s;
49+
}
50+
51+
// Test 7: Function returning struct with array
52+
rule compareFunctionReturnStructWithArray {
53+
uint256 id; uint256 a; uint256 b;
54+
Test.StructWithArray s;
55+
require s.id == id;
56+
require s.values.length == 2;
57+
require s.values[0] == a && s.values[1] == b;
58+
assert createStructWithArray(id, a, b) == s;
59+
}
60+
61+
// Test 8: Different lengths means not equal
62+
rule differentLengthsNotEqual {
63+
uint256[] arr1; uint256[] arr2;
64+
require arr1.length != arr2.length;
65+
assert arr1 != arr2;
66+
}
67+
68+
// Test 9: Empty arrays are equal
69+
rule emptyArraysEqual {
70+
uint256[] arr1; uint256[] arr2;
71+
require arr1.length == 0;
72+
require arr2.length == 0;
73+
assert arr1 == arr2;
74+
}
75+
76+
// Test 10: Compare int256 arrays
77+
rule compareIntArrays {
78+
int256[] arr1; int256[] arr2;
79+
80+
// Can't use `<=>` here because that causes double polarity of the quantifier and breaks grounding
81+
assert arr1 == arr2 => (arr1.length == arr2.length && (forall uint256 i. i < arr1.length => arr1[i] == arr2[i]));
82+
assert (arr1.length == arr2.length && (forall uint256 i. i < arr1.length => arr1[i] == arr2[i])) => arr1 == arr2;
83+
}
84+
85+
// Test 11: Compare struct with nested struct and array field
86+
rule compareStructWithNestedAndArray {
87+
Test.StructWithNestedAndArray s1; Test.StructWithNestedAndArray s2;
88+
assert s1 == s2 <=> (s1.inner.x == s2.inner.x && s1.inner.y == s2.inner.y && s1.arr == s2.arr);
89+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"rules": {
3+
"arrayComparisonReflexive": "SUCCESS",
4+
"arrayComparisonSymmetric": "SUCCESS",
5+
"compareFunctionReturnArray": "SUCCESS",
6+
"compareFunctionReturnStructWithArray": "SUCCESS",
7+
"compareIntArrays": "SUCCESS",
8+
"comparePrimitiveArrays": "SUCCESS",
9+
"compareStructWithNestedAndArray": "SUCCESS",
10+
"compareStructsWithArrays": "SUCCESS",
11+
"differentLengthsNotEqual": "SUCCESS",
12+
"emptyArraysEqual": "SUCCESS",
13+
"envfreeFuncsStaticCheck": {
14+
"SUCCESS": [
15+
"createIntArray(uint256,uint256,uint256)",
16+
"createSimpleStruct(uint256,int128)",
17+
"createStructWithArray(uint256,uint256,uint256)"
18+
]
19+
},
20+
"structWithArrayReflexive": "SUCCESS"
21+
}
22+
}

0 commit comments

Comments
 (0)