Skip to content

Commit

Permalink
Merge branch 'berkeley' into feature/no-offline-bootstrap-timeouts-be…
Browse files Browse the repository at this point in the history
…fore-genesis
  • Loading branch information
psteckler authored Oct 16, 2023
2 parents 93d01ae + b193f27 commit 7f11feb
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 28 deletions.
2 changes: 1 addition & 1 deletion buildkite/src/Jobs/Test/FuzzyZkappTest.dhall
Original file line number Diff line number Diff line change
Expand Up @@ -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
]
}
3 changes: 2 additions & 1 deletion src/lib/transaction_snark/test/dune
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
yojson
integers
;; local libraries
logger
random_oracle_input
pickles.backend
mina_base.import
Expand Down Expand Up @@ -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)))
54 changes: 35 additions & 19 deletions src/lib/transaction_snark/test/util.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion src/lib/transaction_snark/test/util.mli
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 8 additions & 6 deletions src/lib/transaction_snark/test/zkapp_fuzzy/zkapp_fuzzy.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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 ()) ->
Expand Down Expand Up @@ -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 ()) ->
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 )
Expand Down Expand Up @@ -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
Expand All @@ -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:
Expand Down

0 comments on commit 7f11feb

Please sign in to comment.