diff --git a/buildkite/src/Jobs/Test/FuzzyZkappTest.dhall b/buildkite/src/Jobs/Test/FuzzyZkappTest.dhall index 0d3ccc55cc4..5dd541ab0e0 100644 --- a/buildkite/src/Jobs/Test/FuzzyZkappTest.dhall +++ b/buildkite/src/Jobs/Test/FuzzyZkappTest.dhall @@ -51,6 +51,6 @@ Pipeline.build mode = PipelineMode.Type.Stable }, steps = [ - buildTestCmd "dev" "src/lib/transaction_snark/test/zkapp_fuzzy/zkapp_fuzzy.exe" 3600 150 Size.Small + buildTestCmd "dev" "src/lib/transaction_snark/test/zkapp_fuzzy/zkapp_fuzzy.exe" 4200 150 Size.Small ] } diff --git a/src/lib/transaction_snark/test/dune b/src/lib/transaction_snark/test/dune index b284a1566af..a65c221c0c7 100644 --- a/src/lib/transaction_snark/test/dune +++ b/src/lib/transaction_snark/test/dune @@ -14,6 +14,7 @@ yojson integers ;; local libraries + logger random_oracle_input pickles.backend mina_base.import @@ -56,5 +57,5 @@ (library_flags -linkall) (inline_tests (flags -verbose -show-counts)) (preprocess - (pps ppx_snarky ppx_version ppx_jane ppx_sexp_conv)) + (pps ppx_mina ppx_snarky ppx_version ppx_jane ppx_sexp_conv)) (instrumentation (backend bisect_ppx))) diff --git a/src/lib/transaction_snark/test/util.ml b/src/lib/transaction_snark/test/util.ml index a8329d17aea..b9fab627abb 100644 --- a/src/lib/transaction_snark/test/util.ml +++ b/src/lib/transaction_snark/test/util.ml @@ -72,8 +72,11 @@ type pass_number = Pass_1 | Pass_2 let pass_number_to_int = function Pass_1 -> 1 | Pass_2 -> 2 -let check_zkapp_command_with_merges_exn ?expected_failure ?ignore_outside_snark - ?global_slot ?(state_body = genesis_state_body) ledger zkapp_commands = +let logger_null = Logger.null () + +let check_zkapp_command_with_merges_exn ?(logger = logger_null) + ?expected_failure ?ignore_outside_snark ?global_slot + ?(state_body = genesis_state_body) ledger zkapp_commands = let module T = (val Lazy.force snark_module) in let ignore_outside_snark = Option.value ~default:false ignore_outside_snark in let state_view = Mina_state.Protocol_state.Body.view state_body in @@ -226,29 +229,42 @@ let check_zkapp_command_with_merges_exn ?expected_failure ?ignore_outside_snark failwith "no witnesses generated" | (witness, spec, stmt) :: rest -> let open Async.Deferred.Or_error.Let_syntax in + let start = Time.now () in let%bind p1 = Async.Deferred.Or_error.try_with ~here:[%here] (fun () -> T.of_zkapp_command_segment_exn ~statement:stmt ~witness ~spec ) in - Async.Deferred.List.fold ~init:(Ok p1) rest - ~f:(fun acc (witness, spec, stmt) -> - let%bind prev = Async.Deferred.return acc in - let%bind curr = - Async.Deferred.Or_error.try_with ~here:[%here] - (fun () -> - T.of_zkapp_command_segment_exn - ~statement:stmt ~witness ~spec ) - in - let sok_digest = - Sok_message.create ~fee:Fee.zero - ~prover: - (Quickcheck.random_value - Public_key.Compressed.gen ) - |> Sok_message.digest - in - T.merge ~sok_digest prev curr ) + let%map result = + Async.Deferred.List.fold ~init:(Ok p1) rest + ~f:(fun acc (witness, spec, stmt) -> + let%bind prev = Async.Deferred.return acc in + let%bind curr = + Async.Deferred.Or_error.try_with ~here:[%here] + (fun () -> + T.of_zkapp_command_segment_exn + ~statement:stmt ~witness ~spec ) + in + let sok_digest = + Sok_message.create ~fee:Fee.zero + ~prover: + (Quickcheck.random_value + Public_key.Compressed.gen ) + |> Sok_message.digest + in + T.merge ~sok_digest prev curr ) + in + [%log info] + ~metadata: + [ ( "duration" + , `String + Time.( + Span.to_short_string + @@ diff (Time.now ()) start) ) + ] + "transaction snark computation takes $duration" ; + result in let p = Or_error.ok_exn p in ( match statement_opt with diff --git a/src/lib/transaction_snark/test/util.mli b/src/lib/transaction_snark/test/util.mli index 483994b795c..393c6316bca 100644 --- a/src/lib/transaction_snark/test/util.mli +++ b/src/lib/transaction_snark/test/util.mli @@ -54,7 +54,8 @@ type pass_number = Pass_1 | Pass_2 Raises if either the snark generation or application fails *) val check_zkapp_command_with_merges_exn : - ?expected_failure:Mina_base.Transaction_status.Failure.t * pass_number + ?logger:Logger.t + -> ?expected_failure:Mina_base.Transaction_status.Failure.t * pass_number -> ?ignore_outside_snark:bool -> ?global_slot:Mina_numbers.Global_slot_since_genesis.t -> ?state_body:Transaction_protocol_state.Block_data.t diff --git a/src/lib/transaction_snark/test/zkapp_fuzzy/zkapp_fuzzy.ml b/src/lib/transaction_snark/test/zkapp_fuzzy/zkapp_fuzzy.ml index f43d21add56..e9902915780 100644 --- a/src/lib/transaction_snark/test/zkapp_fuzzy/zkapp_fuzzy.ml +++ b/src/lib/transaction_snark/test/zkapp_fuzzy/zkapp_fuzzy.ml @@ -115,7 +115,7 @@ let generate_zkapp_commands_and_apply_them_consecutively_5_times ~successful match%map try_with (fun () -> with_timeout (Time.Span.of_int_sec individual_test_timeout) - @@ U.check_zkapp_command_with_merges_exn ~global_slot ledger + @@ U.check_zkapp_command_with_merges_exn ~logger ~global_slot ledger [ zkapp_command ] ) with | Ok (`Result ()) -> @@ -165,7 +165,7 @@ let generate_zkapp_commands_and_apply_them_freshly ~successful match%map try_with (fun () -> with_timeout (Time.Span.of_int_sec individual_test_timeout) - @@ U.check_zkapp_command_with_merges_exn ~global_slot ledger + @@ U.check_zkapp_command_with_merges_exn ~logger ~global_slot ledger [ zkapp_command ] ) with | Ok (`Result ()) -> @@ -213,7 +213,7 @@ let mk_invalid_test ~successful ~max_account_updates ~type_of_failure match%map try_with (fun () -> with_timeout (Time.Span.of_int_sec individual_test_timeout) - @@ U.check_zkapp_command_with_merges_exn + @@ U.check_zkapp_command_with_merges_exn ~logger ~expected_failure:expected_failure_status ledger [ zkapp_command ] ~global_slot ) with @@ -266,7 +266,7 @@ let test_timed_account ~successful ~max_account_updates ~individual_test_timeout match%map try_with (fun () -> with_timeout (Time.Span.of_int_sec individual_test_timeout) - @@ U.check_zkapp_command_with_merges_exn + @@ U.check_zkapp_command_with_merges_exn ~logger ~expected_failure: ( Transaction_status.Failure.Source_minimum_balance_violation , Pass_1 ) @@ -323,7 +323,9 @@ let () = let successful = ref true in let rec loop random = generate_zkapp_commands_and_apply_them_consecutively_5_times - ~successful ~max_account_updates ~individual_test_timeout random + ~successful ~max_account_updates + ~individual_test_timeout:(individual_test_timeout * 2) + random >>= generate_zkapp_commands_and_apply_them_freshly ~successful ~max_account_updates ~individual_test_timeout >>= mk_invalid_test ~successful ~max_account_updates @@ -335,7 +337,7 @@ let () = ~type_of_failure:(Update_not_permitted `App_state) ~expected_failure_status: (Update_not_permitted_app_state, Pass_2) - ~individual_test_timeout + ~individual_test_timeout:(individual_test_timeout * 2) >>= mk_invalid_test ~successful ~max_account_updates ~type_of_failure:(Update_not_permitted `Verification_key) ~expected_failure_status: