Skip to content

Commit 1ad0b38

Browse files
committed
turn on z3 dynamic tests
1 parent a1a5e50 commit 1ad0b38

File tree

2 files changed

+80
-25
lines changed

2 files changed

+80
-25
lines changed

nix/hevm-tests/default.nix

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ in
1414
yulEquivalence-cvc4 = runWithSolver ./yul-equivalence.nix "cvc4";
1515

1616
# z3 takes 3hrs to run these tests on a fast machine, and even then ~180 timeout
17-
#smtChecker-z3 = runWithSolver ./smt-checker.nix "z3";
17+
smtChecker-z3 = runWithSolver ./smt-checker.nix "z3";
1818
smtChecker-cvc4 = runWithSolver ./smt-checker.nix "cvc4";
1919
}

nix/hevm-tests/smt-checker.nix

+79-24
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,35 @@ let
4747
"types/array_dynamic_3_fail.sol"
4848
];
4949

50+
z3Timeout = [
51+
"operators/compound_assignment_division_1.sol"
52+
"operators/compound_assignment_division_2.sol"
53+
"operators/delete_array_index_2d.sol"
54+
];
55+
56+
dynamic = [
57+
# OpCalldatacopy
58+
"loops/for_loop_array_assignment_memory_memory.sol"
59+
"loops/for_loop_array_assignment_memory_storage.sol"
60+
"loops/while_loop_array_assignment_memory_memory.sol"
61+
"loops/while_loop_array_assignment_memory_storage.sol"
62+
"types/address_call.sol"
63+
"types/address_delegatecall.sol"
64+
"types/address_staticcall.sol"
65+
"types/array_aliasing_storage_2.sol"
66+
"types/array_aliasing_storage_3.sol"
67+
"types/array_aliasing_storage_5.sol"
68+
"types/array_branch_1d.sol"
69+
"types/array_branches_1d.sol"
70+
"types/array_dynamic_parameter_1.sol"
71+
"types/array_dynamic_parameter_1_fail.sol"
72+
"types/bytes_1.sol"
73+
"types/bytes_2.sol"
74+
"types/bytes_2_fail.sol"
75+
"types/mapping_unsupported_key_type_1.sol"
76+
"types/function_type_array_as_reference_type.sol"
77+
];
78+
5079
ignored = [
5180

5281
# --- constructor arguments ---
@@ -115,26 +144,26 @@ let
115144
# OpJump
116145
"complex/slither/external_function.sol"
117146

118-
# OpCalldatacopy
119-
"loops/for_loop_array_assignment_memory_memory.sol"
120-
"loops/for_loop_array_assignment_memory_storage.sol"
121-
"loops/while_loop_array_assignment_memory_memory.sol"
122-
"loops/while_loop_array_assignment_memory_storage.sol"
123-
"types/address_call.sol"
124-
"types/address_delegatecall.sol"
125-
"types/address_staticcall.sol"
126-
"types/array_aliasing_storage_2.sol"
127-
"types/array_aliasing_storage_3.sol"
128-
"types/array_aliasing_storage_5.sol"
129-
"types/array_branch_1d.sol"
130-
"types/array_branches_1d.sol"
131-
"types/array_dynamic_parameter_1.sol"
132-
"types/array_dynamic_parameter_1_fail.sol"
133-
"types/bytes_1.sol"
134-
"types/bytes_2.sol"
135-
"types/bytes_2_fail.sol"
136-
"types/mapping_unsupported_key_type_1.sol"
137-
"types/function_type_array_as_reference_type.sol"
147+
# # OpCalldatacopy
148+
# "loops/for_loop_array_assignment_memory_memory.sol"
149+
# "loops/for_loop_array_assignment_memory_storage.sol"
150+
# "loops/while_loop_array_assignment_memory_memory.sol"
151+
# "loops/while_loop_array_assignment_memory_storage.sol"
152+
# "types/address_call.sol"
153+
# "types/address_delegatecall.sol"
154+
# "types/address_staticcall.sol"
155+
# "types/array_aliasing_storage_2.sol"
156+
# "types/array_aliasing_storage_3.sol"
157+
# "types/array_aliasing_storage_5.sol"
158+
# "types/array_branch_1d.sol"
159+
# "types/array_branches_1d.sol"
160+
# "types/array_dynamic_parameter_1.sol"
161+
# "types/array_dynamic_parameter_1_fail.sol"
162+
# "types/bytes_1.sol"
163+
# "types/bytes_2.sol"
164+
# "types/bytes_2_fail.sol"
165+
# "types/mapping_unsupported_key_type_1.sol"
166+
# "types/function_type_array_as_reference_type.sol"
138167

139168
# OpBlockhash
140169
"special/blockhash.sol"
@@ -223,8 +252,8 @@ let
223252
# symbolic` on all contracts within.
224253
# $1 == input file
225254
# $2 == hevm smt backend
255+
# $3 == dynamic?
226256
checkWithHevm = pkgs.writeShellScript "checkWithHevm" ''
227-
228257
# write json file to store for later debugging
229258
testName=$(${testName} $1)
230259
json=$out/jsonFiles/$testName.json
@@ -236,7 +265,7 @@ let
236265
237266
explore() {
238267
set -x
239-
hevm_output=$(${timeout} 90s ${hevm} symbolic --code "$1" --solver "$2" --json-file "$3" $4 2>&1)
268+
hevm_output=$(${timeout} 90s ${hevm} symbolic --code "$1" --solver "$2" --json-file "$3" $4 $5 2>&1)
240269
status=$?
241270
set +x
242271
@@ -273,10 +302,15 @@ let
273302
iterations="--max-iterations 3"
274303
fi
275304
305+
dynamic=""
306+
if ! [[ -z "$3" ]]; then
307+
dynamic="--calldata-model DynamicCD"
308+
fi
309+
276310
${echo}
277311
${echo} exploring runtime bytecode:
278312
bin_runtime=$(${jq} -r --arg c $contract -c '.contracts[$c]."bin-runtime"' $json)
279-
explore "$bin_runtime" "$2" "$json" "$iterations"
313+
explore "$bin_runtime" "$2" "$json" "$iterations" "$dynamic"
280314
done
281315
282316
exit 0
@@ -305,14 +339,35 @@ let
305339
exit 0
306340
fi
307341
342+
z3Timeouts=(${toString z3Timeout})
343+
if [[ " ''${z3Timeouts[@]} " =~ " ''${testName} " ]] && [[ $2 = "z3" ]]; then
344+
${echo} "skipping test:" ${testName}
345+
${echo} "${strings.ignore}"
346+
exit 0
347+
fi
348+
349+
dynamicFlag=""
350+
dynamicTests=(${toString dynamic})
351+
if [[ " ''${dynamicTests[@]} " =~ " ''${testName} " ]]; then
352+
# echo $2
353+
if [[ $2 = "z3" ]]; then
354+
dynamicFlag=1
355+
else
356+
${echo} "skipping test:" ${testName}
357+
${echo} "${strings.ignore}"
358+
359+
exit 0
360+
fi
361+
fi
362+
308363
${grep} -q 'Error trying to invoke SMT solver.' $1
309364
if [ $? == 0 ]; then ${echo} ${strings.smtCheckerFailed} && exit; fi
310365
${grep} -q 'Assertion checker does not yet implement' $1
311366
if [ $? == 0 ]; then ${echo} ${strings.smtCheckerFailed} && exit; fi
312367
${grep} -q 'Assertion checker does not yet support' $1
313368
if [ $? == 0 ]; then ${echo} ${strings.smtCheckerFailed} && exit; fi
314369
315-
hevm_output=$(${checkWithHevm} $1 $2 2>&1)
370+
hevm_output=$(${checkWithHevm} $1 $2 "$dynamicFlag" 2>&1)
316371
echo "$hevm_output"
317372
318373
${grep} -q '${strings.timeout}' <<< "$hevm_output"

0 commit comments

Comments
 (0)