From 60ba82404568d3406ae6a6caade305e00d4b101e Mon Sep 17 00:00:00 2001 From: mrmr1993 Date: Tue, 5 Jul 2022 17:46:46 +0100 Subject: [PATCH 001/144] Add call function to zkapps_examples --- src/lib/zkapps_examples/dune | 1 + src/lib/zkapps_examples/zkapps_examples.ml | 18 ++++++++++++++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/lib/zkapps_examples/dune b/src/lib/zkapps_examples/dune index 7cdf0acad4f..c4c3a8e5177 100644 --- a/src/lib/zkapps_examples/dune +++ b/src/lib/zkapps_examples/dune @@ -2,6 +2,7 @@ (name zkapps_examples) (libraries ;; opam libraries + base async_kernel core_kernel ;; local libraries diff --git a/src/lib/zkapps_examples/zkapps_examples.ml b/src/lib/zkapps_examples/zkapps_examples.ml index e405788ebcf..203ed007626 100644 --- a/src/lib/zkapps_examples/zkapps_examples.ml +++ b/src/lib/zkapps_examples/zkapps_examples.ml @@ -1,3 +1,4 @@ +open Core_kernel open Async_kernel open Snark_params.Tick open Snark_params.Tick.Run @@ -176,7 +177,7 @@ module Party_under_construction = struct let open Snark_params.Tick in let (Typ typ) = typ in let fields, aux = typ.value_to_fields x in - let fields = Array.map Field.Var.constant fields in + let fields = Array.map ~f:Field.Var.constant fields in typ.var_of_fields (fields, aux) in let default = @@ -242,7 +243,7 @@ module Party_under_construction = struct let open Snark_params.Tick in let (Typ typ) = typ in let fields, aux = typ.value_to_fields x in - let fields = Array.map Field.Var.constant fields in + let fields = Array.map ~f:Field.Var.constant fields in typ.var_of_fields (fields, aux) in let default = @@ -292,6 +293,8 @@ module Party_under_construction = struct ; token_id : Token_id.Checked.t ; account_condition : Account_condition.t ; update : Update.t + ; rev_calls : + (Zkapp_call_forest.Checked.party * Zkapp_call_forest.Checked.t) list } let create ~public_key ?(token_id = Token_id.(Checked.constant default)) () @@ -300,6 +303,7 @@ module Party_under_construction = struct ; token_id ; account_condition = Account_condition.create () ; update = Update.create () + ; rev_calls = [] } let to_party_and_calls (t : t) : @@ -310,7 +314,7 @@ module Party_under_construction = struct let open Snark_params.Tick in let (Typ typ) = typ in let fields, aux = typ.value_to_fields x in - let fields = Array.map Field.Var.constant fields in + let fields = Array.map ~f:Field.Var.constant fields in typ.var_of_fields (fields, aux) in let party : Party.Body.Checked.t = @@ -361,7 +365,11 @@ module Party_under_construction = struct ; caller = t.token_id } in - let calls = exists Zkapp_call_forest.typ ~compute:(fun () -> []) in + let calls = + List.fold_left ~init:(Zkapp_call_forest.Checked.empty ()) t.rev_calls + ~f:(fun acc (party, calls) -> + Zkapp_call_forest.Checked.push ~party ~calls acc ) + in (party, calls) let assert_state_unproved (t : t) = @@ -378,6 +386,8 @@ module Party_under_construction = struct let set_full_state app_state (t : t) = { t with update = Update.set_full_state app_state t.update } + + let call (t : t) call_data = { t with rev_calls = call_data :: t.rev_calls } end end From 9ec279bbdce8e6e492d402b151c153bc3dab355d Mon Sep 17 00:00:00 2001 From: mrmr1993 Date: Tue, 5 Jul 2022 17:46:46 +0100 Subject: [PATCH 002/144] Allow zkapps_examples circuits to return an auxiliary output --- .../empty_update/zkapps_empty_update.ml | 11 +++++++---- .../initialize_state/zkapps_initialize_state.ml | 14 ++++++++++---- src/lib/zkapps_examples/zkapps_examples.ml | 11 ++++++++--- 3 files changed, 25 insertions(+), 11 deletions(-) diff --git a/src/lib/zkapps_examples/empty_update/zkapps_empty_update.ml b/src/lib/zkapps_examples/empty_update/zkapps_empty_update.ml index 39bb2e208d6..a3acf06ff33 100644 --- a/src/lib/zkapps_examples/empty_update/zkapps_empty_update.ml +++ b/src/lib/zkapps_examples/empty_update/zkapps_empty_update.ml @@ -7,10 +7,13 @@ open Zkapps_examples *) let main public_key = Zkapps_examples.wrap_main (fun () -> - Party_under_construction.In_circuit.create - ~public_key:(Public_key.Compressed.var_of_t public_key) - ~token_id:Token_id.(Checked.constant default) - () ) + let party = + Party_under_construction.In_circuit.create + ~public_key:(Public_key.Compressed.var_of_t public_key) + ~token_id:Token_id.(Checked.constant default) + () + in + (party, ()) ) let rule public_key : _ Pickles.Inductive_rule.t = { identifier = "Empty update"; prevs = []; main = main public_key } diff --git a/src/lib/zkapps_examples/initialize_state/zkapps_initialize_state.ml b/src/lib/zkapps_examples/initialize_state/zkapps_initialize_state.ml index 1403db40613..ea47b2c2e61 100644 --- a/src/lib/zkapps_examples/initialize_state/zkapps_initialize_state.ml +++ b/src/lib/zkapps_examples/initialize_state/zkapps_initialize_state.ml @@ -27,8 +27,11 @@ let initialize public_key = let initial_state = List.map ~f:Field.constant (Lazy.force initial_state) in - party |> Party_under_construction.In_circuit.assert_state_unproved - |> Party_under_construction.In_circuit.set_full_state initial_state ) + let party = + party |> Party_under_construction.In_circuit.assert_state_unproved + |> Party_under_construction.In_circuit.set_full_state initial_state + in + (party, ()) ) type _ Snarky_backendless.Request.t += | New_state : Field.Constant.t list Snarky_backendless.Request.t @@ -52,8 +55,11 @@ let update_state public_key = let new_state = exists (Typ.list ~length:8 Field.typ) ~request:(fun () -> New_state) in - party |> Party_under_construction.In_circuit.assert_state_proved - |> Party_under_construction.In_circuit.set_full_state new_state ) + let party = + party |> Party_under_construction.In_circuit.assert_state_proved + |> Party_under_construction.In_circuit.set_full_state new_state + in + (party, ()) ) let initialize_rule public_key : _ Pickles.Inductive_rule.t = { identifier = "Initialize snapp"; prevs = []; main = initialize public_key } diff --git a/src/lib/zkapps_examples/zkapps_examples.ml b/src/lib/zkapps_examples/zkapps_examples.ml index 203ed007626..156f6220526 100644 --- a/src/lib/zkapps_examples/zkapps_examples.ml +++ b/src/lib/zkapps_examples/zkapps_examples.ml @@ -295,6 +295,7 @@ module Party_under_construction = struct ; update : Update.t ; rev_calls : (Zkapp_call_forest.Checked.party * Zkapp_call_forest.Checked.t) list + ; call_data : Field.t option } let create ~public_key ?(token_id = Token_id.(Checked.constant default)) () @@ -304,6 +305,7 @@ module Party_under_construction = struct ; account_condition = Account_condition.create () ; update = Update.create () ; rev_calls = [] + ; call_data = None } let to_party_and_calls (t : t) : @@ -326,7 +328,7 @@ module Party_under_construction = struct ; increment_nonce = Boolean.false_ ; events = var_of_t Zkapp_account.Events.typ [] ; sequence_events = var_of_t Zkapp_account.Events.typ [] - ; call_data = Field.zero + ; call_data = Option.value ~default:Field.zero t.call_data ; preconditions = { Party.Preconditions.Checked.network = var_of_t Zkapp_precondition.Protocol_state.typ @@ -388,6 +390,8 @@ module Party_under_construction = struct { t with update = Update.set_full_state app_state t.update } let call (t : t) call_data = { t with rev_calls = call_data :: t.rev_calls } + + let set_call_data call_data (t : t) = { t with call_data = Some call_data } end end @@ -451,9 +455,10 @@ open Pickles_types open Hlist let wrap_main f { Pickles.Inductive_rule.public_input = () } = + let public_output, auxiliary_output = f () in { Pickles.Inductive_rule.previous_proof_statements = [] - ; public_output = f () - ; auxiliary_output = () + ; public_output + ; auxiliary_output } let compile : From 330a2704acb6a7b2fbe4b65cc65c87aa5cb35858 Mon Sep 17 00:00:00 2001 From: mrmr1993 Date: Tue, 5 Jul 2022 17:46:46 +0100 Subject: [PATCH 003/144] API tweaks for piping --- src/lib/mina_base/zkapp_call_forest.ml | 2 ++ src/lib/zkapps_examples/zkapps_examples.ml | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/lib/mina_base/zkapp_call_forest.ml b/src/lib/mina_base/zkapp_call_forest.ml index 0fecef7d626..b70cb61c9fb 100644 --- a/src/lib/mina_base/zkapp_call_forest.ml +++ b/src/lib/mina_base/zkapp_call_forest.ml @@ -6,6 +6,8 @@ type t = , Parties.Digest.Forest.t ) Parties.Call_forest.t +type party = (Party.t, Parties.Digest.Party.t) With_hash.t + let empty () = [] let if_ = Parties.value_if diff --git a/src/lib/zkapps_examples/zkapps_examples.ml b/src/lib/zkapps_examples/zkapps_examples.ml index 156f6220526..71b4f84f5ff 100644 --- a/src/lib/zkapps_examples/zkapps_examples.ml +++ b/src/lib/zkapps_examples/zkapps_examples.ml @@ -389,7 +389,8 @@ module Party_under_construction = struct let set_full_state app_state (t : t) = { t with update = Update.set_full_state app_state t.update } - let call (t : t) call_data = { t with rev_calls = call_data :: t.rev_calls } + let call party calls (t : t) = + { t with rev_calls = (party, calls) :: t.rev_calls } let set_call_data call_data (t : t) = { t with call_data = Some call_data } end From 885380c9732dc26387f36de420179e6cfc145315 Mon Sep 17 00:00:00 2001 From: mrmr1993 Date: Tue, 5 Jul 2022 17:46:46 +0100 Subject: [PATCH 004/144] Add basic zkApps call test --- src/lib/mina_base/zkapp_call_forest.ml | 35 +- .../test/zkapps_examples/calls/calls.ml | 314 ++++++++++++++++++ .../test/zkapps_examples/calls/dune | 47 +++ src/lib/zkapps_examples/calls/dune | 30 ++ src/lib/zkapps_examples/calls/zkapps_calls.ml | 231 +++++++++++++ 5 files changed, 646 insertions(+), 11 deletions(-) create mode 100644 src/lib/transaction_snark/test/zkapps_examples/calls/calls.ml create mode 100644 src/lib/transaction_snark/test/zkapps_examples/calls/dune create mode 100644 src/lib/zkapps_examples/calls/dune create mode 100644 src/lib/zkapps_examples/calls/zkapps_calls.ml diff --git a/src/lib/mina_base/zkapp_call_forest.ml b/src/lib/mina_base/zkapp_call_forest.ml index b70cb61c9fb..c74000d2324 100644 --- a/src/lib/mina_base/zkapp_call_forest.ml +++ b/src/lib/mina_base/zkapp_call_forest.ml @@ -37,17 +37,30 @@ module Checked = struct let party_typ () : (party, (Party.t, Parties.Digest.Party.t) With_hash.t) Typ.t = - Typ.(Party.Body.typ () * Prover_value.typ () * Parties.Digest.Party.typ) - |> Typ.transport - ~back:(fun ((body, authorization), hash) -> - { With_hash.data = { Party.body; authorization }; hash } ) - ~there:(fun { With_hash.data = { Party.body; authorization }; hash } -> - ((body, authorization), hash) ) - |> Typ.transport_var - ~back:(fun ((party, control), hash) -> - { party = { hash; data = party }; control } ) - ~there:(fun { party = { hash; data = party }; control } -> - ((party, control), hash) ) + let (Typ typ) = + Typ.(Party.Body.typ () * Prover_value.typ () * Parties.Digest.Party.typ) + |> Typ.transport + ~back:(fun ((body, authorization), hash) -> + { With_hash.data = { Party.body; authorization }; hash } ) + ~there:(fun { With_hash.data = { Party.body; authorization }; hash } -> + ((body, authorization), hash) ) + |> Typ.transport_var + ~back:(fun ((party, control), hash) -> + { party = { hash; data = party }; control } ) + ~there:(fun { party = { hash; data = party }; control } -> + ((party, control), hash) ) + in + Typ + { typ with + check = + (fun ({ party = { hash; data = party }; control = _ } as x) -> + make_checked (fun () -> + run_checked (typ.check x) ; + Field.Assert.equal + (hash :> Field.t) + ( Parties.Call_forest.Digest.Party.Checked.create party + :> Field.t ) ) ) + } type t = ( ( Party.t diff --git a/src/lib/transaction_snark/test/zkapps_examples/calls/calls.ml b/src/lib/transaction_snark/test/zkapps_examples/calls/calls.ml new file mode 100644 index 00000000000..f93eb529375 --- /dev/null +++ b/src/lib/transaction_snark/test/zkapps_examples/calls/calls.ml @@ -0,0 +1,314 @@ +open Transaction_snark_tests.Util +open Core_kernel +open Mina_base +open Signature_lib +module Impl = Pickles.Impls.Step +module Inner_curve = Snark_params.Tick.Inner_curve +module Nat = Pickles_types.Nat +module Local_state = Mina_state.Local_state +module Parties_segment = Transaction_snark.Parties_segment +module Statement = Transaction_snark.Statement + +let%test_module "Initialize state test" = + ( module struct + let () = Base.Backtrace.elide := false + + let sk = Private_key.create () + + let pk = Public_key.of_private_key_exn sk + + let pk_compressed = Public_key.compress pk + + let account_id = Account_id.create pk_compressed Token_id.default + + (* This is only value to use as an auxiliary_typ *) + let option_typ (Typ typ : ('var, 'value) Impl.Typ.t) : + ('var option, 'value option) Impl.Typ.t = + Typ + { var_to_fields = + (function + | None -> + ([||], None) + | Some x -> + let fields, aux = typ.var_to_fields x in + (fields, Some aux) ) + ; var_of_fields = + (function + | _, None -> + None + | fields, Some aux -> + Some (typ.var_of_fields (fields, aux)) ) + ; value_to_fields = + (function + | None -> + ([||], None) + | Some x -> + let fields, aux = typ.value_to_fields x in + (fields, Some aux) ) + ; value_of_fields = + (function + | _, None -> + None + | fields, Some aux -> + Some (typ.value_of_fields (fields, aux)) ) + ; size_in_field_elements = typ.size_in_field_elements + ; constraint_system_auxiliary = (fun () -> None) + ; check = (fun _ -> assert false) + } + + let ( tag + , _ + , p_module + , Pickles.Provers. + [ initialize_prover + ; update_state_call_prover + ; call_prover + ; recursive_call_prover + ] ) = + Zkapps_examples.compile () ~cache:Cache_dir.cache + ~auxiliary_typ: + (option_typ Impl.(Typ.(list ~length:8 Field.typ * Field.typ))) + ~branches:(module Nat.N4) + ~max_proofs_verified:(module Nat.N0) + ~name:"empty_update" + ~constraint_constants: + (Genesis_constants.Constraint_constants.to_snark_keys_header + constraint_constants ) + ~choices:(fun ~self:_ -> + [ Zkapps_calls.initialize_rule pk_compressed + ; Zkapps_calls.update_state_call_rule pk_compressed + ; Zkapps_calls.call_rule pk_compressed + ; Zkapps_calls.recursive_call_rule pk_compressed + ] ) + + type calls_kind = Recurse of calls_kind | Call + + module P = (val p_module) + + let vk = Pickles.Side_loaded.Verification_key.of_compiled tag + + module Deploy_party = struct + let party_body : Party.Body.t = + { Party.Body.dummy with + public_key = pk_compressed + ; update = + { Party.Update.dummy with + verification_key = + Set + { data = vk + ; hash = + (* TODO: This function should live in + [Side_loaded_verification_key]. + *) + Zkapp_account.digest_vk vk + } + ; permissions = + Set + { edit_state = Proof + ; send = Proof + ; receive = Proof + ; set_delegate = Proof + ; set_permissions = Proof + ; set_verification_key = Proof + ; set_zkapp_uri = Proof + ; edit_sequence_state = Proof + ; set_token_symbol = Proof + ; increment_nonce = Proof + ; set_voting_for = Proof + } + } + ; use_full_commitment = true + ; preconditions = + { Party.Preconditions.network = + Zkapp_precondition.Protocol_state.accept + ; account = Accept + } + } + + let party : Party.t = + (* TODO: This is a pain. *) + { body = party_body; authorization = Signature Signature.dummy } + end + + module Initialize_party = struct + let party, _ = Async.Thread_safe.block_on_async_exn initialize_prover + end + + module Update_state_party = struct + let old_state = List.init 8 ~f:(fun _ -> Snark_params.Tick.Field.one) + + let handler (calls_kind : calls_kind) old_state = + let open Snark_params.Tick.Run in + let rec make_call calls_kind input : + (Field.Constant.t list * Field.Constant.t) + * Zkapp_call_forest.party + * Zkapp_call_forest.t = + match calls_kind with + | Call -> + let tree, aux = + Async.Thread_safe.block_on_async_exn + (call_prover ~handler:(Zkapps_calls.call_handler input)) + in + ( Option.value_exn aux + , { data = tree.party; hash = tree.party_digest } + , tree.calls ) + | Recurse calls_kind -> + let tree, aux = + Async.Thread_safe.block_on_async_exn + (recursive_call_prover + ~handler: + (Zkapps_calls.recursive_call_handler input + (make_call calls_kind) ) ) + in + ( Option.value_exn aux + , { data = tree.party; hash = tree.party_digest } + , tree.calls ) + in + Zkapps_calls.update_state_handler old_state (make_call calls_kind) + + let party calls_kind = + Async.Thread_safe.block_on_async_exn + (update_state_call_prover ~handler:(handler calls_kind old_state)) + |> fst + end + + let test_parties ?expected_failure parties = + let memo = Signed_command_memo.empty in + let transaction_commitment : Parties.Transaction_commitment.t = + (* TODO: This is a pain. *) + let other_parties_hash = Parties.Call_forest.hash parties in + Parties.Transaction_commitment.create ~other_parties_hash + in + let fee_payer : Party.Fee_payer.t = + { body = + { Party.Body.Fee_payer.dummy with + public_key = pk_compressed + ; fee = Currency.Fee.(of_int 100) + } + ; authorization = Signature.dummy + } + in + let memo_hash = Signed_command_memo.hash memo in + let full_commitment = + Parties.Transaction_commitment.create_complete transaction_commitment + ~memo_hash + ~fee_payer_hash: + (Parties.Call_forest.Digest.Party.create + (Party.of_fee_payer fee_payer) ) + in + let sign_all ({ fee_payer; other_parties; memo } : Parties.t) : Parties.t + = + let fee_payer = + match fee_payer with + | { body = { public_key; _ }; _ } + when Public_key.Compressed.equal public_key pk_compressed -> + { fee_payer with + authorization = + Schnorr.Chunked.sign sk + (Random_oracle.Input.Chunked.field full_commitment) + } + | fee_payer -> + fee_payer + in + let other_parties = + Parties.Call_forest.map other_parties ~f:(function + | ({ body = { public_key; use_full_commitment; _ } + ; authorization = Signature _ + } as party : + Party.t ) + when Public_key.Compressed.equal public_key pk_compressed -> + let commitment = + if use_full_commitment then full_commitment + else transaction_commitment + in + { party with + authorization = + Signature + (Schnorr.Chunked.sign sk + (Random_oracle.Input.Chunked.field commitment) ) + } + | party -> + party ) + in + { fee_payer; other_parties; memo } + in + let parties : Parties.t = + sign_all { fee_payer; other_parties = parties; memo } + in + Ledger.with_ledger ~depth:ledger_depth ~f:(fun ledger -> + let account = + Account.create account_id + Currency.Balance.( + Option.value_exn (add_amount zero (Currency.Amount.of_int 500))) + in + let _, loc = + Ledger.get_or_create_account ledger account_id account + |> Or_error.ok_exn + in + Async.Thread_safe.block_on_async_exn (fun () -> + check_parties_with_merges_exn ?expected_failure ledger [ parties ] ) ; + Ledger.get ledger loc ) + + let%test_unit "Initialize and update nonrecursive" = + let account = + [] + |> Parties.Call_forest.cons_tree (Update_state_party.party Call) + |> Parties.Call_forest.cons_tree Initialize_party.party + |> Parties.Call_forest.cons Deploy_party.party + |> test_parties + in + let zkapp_state = + (Option.value_exn (Option.value_exn account).zkapp).app_state + in + Pickles_types.Vector.iter + ~f:(fun x -> assert (Snark_params.Tick.Field.(equal one) x)) + zkapp_state + + let%test_unit "Initialize and update single recursive" = + let account = + [] + |> Parties.Call_forest.cons_tree + (Update_state_party.party (Recurse Call)) + |> Parties.Call_forest.cons_tree Initialize_party.party + |> Parties.Call_forest.cons Deploy_party.party + |> test_parties + in + let zkapp_state = + (Option.value_exn (Option.value_exn account).zkapp).app_state + in + Pickles_types.Vector.iter + ~f:(fun x -> assert (Snark_params.Tick.Field.(equal one) x)) + zkapp_state + + let%test_unit "Initialize and update double recursive" = + let account = + [] + |> Parties.Call_forest.cons_tree + (Update_state_party.party (Recurse (Recurse Call))) + |> Parties.Call_forest.cons_tree Initialize_party.party + |> Parties.Call_forest.cons Deploy_party.party + |> test_parties + in + let zkapp_state = + (Option.value_exn (Option.value_exn account).zkapp).app_state + in + Pickles_types.Vector.iter + ~f:(fun x -> assert (Snark_params.Tick.Field.(equal one) x)) + zkapp_state + + let%test_unit "Initialize and update triple recursive" = + let account = + [] + |> Parties.Call_forest.cons_tree + (Update_state_party.party (Recurse (Recurse (Recurse Call)))) + |> Parties.Call_forest.cons_tree Initialize_party.party + |> Parties.Call_forest.cons Deploy_party.party + |> test_parties + in + let zkapp_state = + (Option.value_exn (Option.value_exn account).zkapp).app_state + in + Pickles_types.Vector.iter + ~f:(fun x -> assert (Snark_params.Tick.Field.(equal one) x)) + zkapp_state + end ) diff --git a/src/lib/transaction_snark/test/zkapps_examples/calls/dune b/src/lib/transaction_snark/test/zkapps_examples/calls/dune new file mode 100644 index 00000000000..582d2f57fed --- /dev/null +++ b/src/lib/transaction_snark/test/zkapps_examples/calls/dune @@ -0,0 +1,47 @@ +(library + (name calls) + (libraries + ;; opam libraries + async + async_kernel + async_unix + base + core + core_kernel + ppx_inline_test.config + yojson + ;; local libraries + cache_dir + currency + data_hash_lib + genesis_constants + pasta_bindings + kimchi_backend + kimchi_pasta + merkle_ledger + mina_base + mina_base.import + mina_ledger + mina_numbers + mina_state + mina_transaction_logic + pickles + pickles.backend + pickles_types + random_oracle_input + random_oracle + sgn + signature_lib + snark_params + snarky.backendless + transaction_protocol_state + transaction_snark + transaction_snark_tests + with_hash + zkapps_calls + zkapps_examples + ) + (inline_tests) + (preprocess + (pps ppx_snarky ppx_version ppx_jane)) + (instrumentation (backend bisect_ppx))) diff --git a/src/lib/zkapps_examples/calls/dune b/src/lib/zkapps_examples/calls/dune new file mode 100644 index 00000000000..e03ca4e55ff --- /dev/null +++ b/src/lib/zkapps_examples/calls/dune @@ -0,0 +1,30 @@ +(library + (name zkapps_calls) + (libraries + ;; opam libraries + base + core_kernel + ;; local libraries + crypto_params + currency + pasta_bindings + kimchi_backend + kimchi_backend_common + kimchi_pasta + mina_base + pickles + pickles.backend + pickles_types + random_oracle + random_oracle_input + snarky.backendless + snark_params + sgn + signature_lib + tuple_lib + with_hash + zkapps_examples) + (instrumentation (backend bisect_ppx)) + (preprocess + (pps + ppx_version))) diff --git a/src/lib/zkapps_examples/calls/zkapps_calls.ml b/src/lib/zkapps_examples/calls/zkapps_calls.ml new file mode 100644 index 00000000000..74be9be1da5 --- /dev/null +++ b/src/lib/zkapps_examples/calls/zkapps_calls.ml @@ -0,0 +1,231 @@ +open Core_kernel +open Snark_params.Tick.Run +open Signature_lib +open Mina_base +open Zkapps_examples + +let initial_state = + lazy + [ Field.Constant.zero + ; Field.Constant.zero + ; Field.Constant.zero + ; Field.Constant.zero + ; Field.Constant.zero + ; Field.Constant.zero + ; Field.Constant.zero + ; Field.Constant.zero + ] + +let initialize public_key = + Zkapps_examples.wrap_main (fun () -> + let party = + Party_under_construction.In_circuit.create + ~public_key:(Public_key.Compressed.var_of_t public_key) + ~token_id:Token_id.(Checked.constant default) + () + in + let initial_state = + List.map ~f:Field.constant (Lazy.force initial_state) + in + let party = + party |> Party_under_construction.In_circuit.assert_state_unproved + |> Party_under_construction.In_circuit.set_full_state initial_state + in + (party, None) ) + +let call_data_hash ~old_state ~new_state ~blinding_value = + let open Random_oracle.Checked in + Array.reduce_exn ~f:Random_oracle_input.Chunked.append + Random_oracle_input.Chunked. + [| field blinding_value + ; field_elements (Array.of_list old_state) + ; field_elements (Array.of_list new_state) + |] + |> pack_input + |> update ~state:initial_state + |> digest + +type _ Snarky_backendless.Request.t += + | Old_state : Field.Constant.t list Snarky_backendless.Request.t + | Call_data : + Field.Constant.t list + -> ( (Field.Constant.t list * Field.Constant.t) + * Zkapp_call_forest.party + * Zkapp_call_forest.t ) + Snarky_backendless.Request.t + +let update_state_handler (old_state : Field.Constant.t list) + (compute_call : + Field.Constant.t list + -> (Field.Constant.t list * Field.Constant.t) + * Zkapp_call_forest.party + * Zkapp_call_forest.t ) + (Snarky_backendless.Request.With { request; respond }) = + match request with + | Old_state -> + respond (Provide old_state) + | Call_data input -> + respond (Provide (compute_call input)) + | _ -> + respond Unhandled + +let update_state_call public_key = + Zkapps_examples.wrap_main (fun () -> + let party = + Party_under_construction.In_circuit.create + ~public_key:(Public_key.Compressed.var_of_t public_key) + ~token_id:Token_id.(Checked.constant default) + () + in + let old_state = + exists (Typ.list ~length:8 Field.typ) ~request:(fun () -> Old_state) + in + let (new_state, blinding_value), called_party, sub_calls = + exists + (Typ.tuple3 + Typ.(list ~length:8 Field.typ * Field.typ) + (Zkapp_call_forest.Checked.party_typ ()) + Zkapp_call_forest.typ ) + ~request:(fun () -> + let input = + As_prover.read (Typ.list ~length:8 Field.typ) old_state + in + Call_data input ) + in + let () = + (* Check that previous party's call data is consistent. *) + let call_data_hash = + call_data_hash ~old_state ~new_state ~blinding_value + in + Field.Assert.equal call_data_hash called_party.party.data.call_data + in + let party = + party |> Party_under_construction.In_circuit.assert_state_proved + |> Party_under_construction.In_circuit.set_full_state old_state + |> Party_under_construction.In_circuit.call called_party sub_calls + in + (party, None) ) + +type _ Snarky_backendless.Request.t += + | Call_input : Field.Constant.t list Snarky_backendless.Request.t + +let call_handler (call_input : Field.Constant.t list) + (Snarky_backendless.Request.With { request; respond }) = + match request with + | Call_input -> + respond (Provide call_input) + | _ -> + respond Unhandled + +let call public_key = + Zkapps_examples.wrap_main (fun () -> + let party = + Party_under_construction.In_circuit.create + ~public_key:(Public_key.Compressed.var_of_t public_key) + ~token_id:Token_id.(Checked.constant default) + () + in + let old_state = + exists (Typ.list ~length:8 Field.typ) ~request:(fun () -> Call_input) + in + let blinding_value = exists Field.typ ~compute:Field.Constant.random in + let modify_value = exists Field.typ ~compute:Field.Constant.random in + let new_state = + List.map old_state ~f:(fun x -> Field.add x modify_value) + in + let call_data_hash = + call_data_hash ~old_state ~new_state ~blinding_value + in + let party = + party |> Party_under_construction.In_circuit.assert_state_proved + |> Party_under_construction.In_circuit.set_call_data call_data_hash + in + (party, Some (new_state, blinding_value)) ) + +type _ Snarky_backendless.Request.t += + | Recursive_call_input : Field.Constant.t list Snarky_backendless.Request.t + | Recursive_call_data : + Field.Constant.t list + -> ( (Field.Constant.t list * Field.Constant.t) + * Zkapp_call_forest.party + * Zkapp_call_forest.t ) + Snarky_backendless.Request.t + +let recursive_call_handler (recursive_call_input : Field.Constant.t list) + (compute_call : + Field.Constant.t list + -> (Field.Constant.t list * Field.Constant.t) + * Zkapp_call_forest.party + * Zkapp_call_forest.t ) + (Snarky_backendless.Request.With { request; respond }) = + match request with + | Recursive_call_input -> + respond (Provide recursive_call_input) + | Recursive_call_data input -> + respond (Provide (compute_call input)) + | _ -> + respond Unhandled + +let recursive_call public_key = + Zkapps_examples.wrap_main (fun () -> + let party = + Party_under_construction.In_circuit.create + ~public_key:(Public_key.Compressed.var_of_t public_key) + ~token_id:Token_id.(Checked.constant default) + () + in + let old_state = + exists (Typ.list ~length:8 Field.typ) ~request:(fun () -> + Recursive_call_input ) + in + let (new_state, blinding_value), called_party, sub_calls = + exists + (Typ.tuple3 + Typ.(list ~length:8 Field.typ * Field.typ) + (Zkapp_call_forest.Checked.party_typ ()) + Zkapp_call_forest.typ ) + ~request:(fun () -> + let input = + As_prover.read (Typ.list ~length:8 Field.typ) old_state + in + Recursive_call_data input ) + in + let () = + (* Check that previous party's call data is consistent. *) + let call_data_hash = + call_data_hash ~old_state ~new_state ~blinding_value + in + Field.Assert.equal call_data_hash called_party.party.data.call_data + in + let blinding_value = exists Field.typ ~compute:Field.Constant.random in + let modify_value = exists Field.typ ~compute:Field.Constant.random in + let new_state = + List.map old_state ~f:(fun x -> Field.add x modify_value) + in + let call_data_hash = + call_data_hash ~old_state ~new_state ~blinding_value + in + let party = + party |> Party_under_construction.In_circuit.assert_state_proved + |> Party_under_construction.In_circuit.set_call_data call_data_hash + |> Party_under_construction.In_circuit.call called_party sub_calls + in + (party, Some (new_state, blinding_value)) ) + +let initialize_rule public_key : _ Pickles.Inductive_rule.t = + { identifier = "Initialize snapp"; prevs = []; main = initialize public_key } + +let update_state_call_rule public_key : _ Pickles.Inductive_rule.t = + { identifier = "Update state call" + ; prevs = [] + ; main = update_state_call public_key + } + +let call_rule public_key : _ Pickles.Inductive_rule.t = + { identifier = "Call"; prevs = []; main = call public_key } + +let recursive_call_rule public_key : _ Pickles.Inductive_rule.t = + { identifier = "Recursive call" + ; prevs = [] + ; main = recursive_call public_key + } From 52e7b385acdf86194c8e0fcc17fb0454008fa901 Mon Sep 17 00:00:00 2001 From: mrmr1993 Date: Mon, 1 Aug 2022 13:46:00 +0100 Subject: [PATCH 005/144] Remove unused API --- .../empty_update/zkapps_empty_update.ml | 7 - .../zkapps_initialize_state.ml | 12 -- src/lib/zkapps_examples/zkapps_examples.ml | 157 ------------------ 3 files changed, 176 deletions(-) diff --git a/src/lib/zkapps_examples/empty_update/zkapps_empty_update.ml b/src/lib/zkapps_examples/empty_update/zkapps_empty_update.ml index 5e9351dbf9c..16150b11eee 100644 --- a/src/lib/zkapps_examples/empty_update/zkapps_empty_update.ml +++ b/src/lib/zkapps_examples/empty_update/zkapps_empty_update.ml @@ -18,10 +18,3 @@ let rule public_key : _ Pickles.Inductive_rule.t = ; main = main public_key ; uses_lookup = false } - -(* TODO: This shouldn't exist, the circuit should just return the requisite - value. -*) -let generate_party public_key = - Party_under_construction.create ~public_key ~token_id:Token_id.default () - |> Party_under_construction.to_party diff --git a/src/lib/zkapps_examples/initialize_state/zkapps_initialize_state.ml b/src/lib/zkapps_examples/initialize_state/zkapps_initialize_state.ml index f3cbdae0809..f1b86347e02 100644 --- a/src/lib/zkapps_examples/initialize_state/zkapps_initialize_state.ml +++ b/src/lib/zkapps_examples/initialize_state/zkapps_initialize_state.ml @@ -68,15 +68,3 @@ let update_state_rule public_key : _ Pickles.Inductive_rule.t = ; main = update_state public_key ; uses_lookup = false } - -let generate_initialize_party public_key = - Party_under_construction.create ~public_key ~token_id:Token_id.default () - |> Party_under_construction.assert_state_unproved - |> Party_under_construction.set_full_state (Lazy.force initial_state) - |> Party_under_construction.to_party - -let generate_update_state_party public_key new_state = - Party_under_construction.create ~public_key ~token_id:Token_id.default () - |> Party_under_construction.assert_state_proved - |> Party_under_construction.set_full_state new_state - |> Party_under_construction.to_party diff --git a/src/lib/zkapps_examples/zkapps_examples.ml b/src/lib/zkapps_examples/zkapps_examples.ml index 54cf3f5ed1f..1e26736528c 100644 --- a/src/lib/zkapps_examples/zkapps_examples.ml +++ b/src/lib/zkapps_examples/zkapps_examples.ml @@ -6,163 +6,6 @@ open Signature_lib open Mina_base module Party_under_construction = struct - module Account_condition = struct - type t = { state_proved : bool option } - - let create () = { state_proved = None } - - let to_predicate ({ state_proved } : t) : Zkapp_precondition.Account.t = - (* TODO: Don't do this. *) - let default : Zkapp_precondition.Account.t = - { balance = Ignore - ; nonce = Ignore - ; receipt_chain_hash = Ignore - ; delegate = Ignore - ; state = - [ Ignore; Ignore; Ignore; Ignore; Ignore; Ignore; Ignore; Ignore ] - ; sequence_state = Ignore - ; proved_state = Ignore - ; is_new = Ignore - } - in - let proved_state = - match state_proved with - | None -> - default.proved_state - | Some state_proved -> - Zkapp_basic.Or_ignore.Check state_proved - in - { default with proved_state } - - let assert_state_proved (t : t) = - match t.state_proved with - | None -> - { state_proved = Some true } - | Some b -> - if not b then failwith "State is already unproved" ; - t - - let assert_state_unproved (t : t) = - match t.state_proved with - | None -> - { state_proved = Some false } - | Some b -> - if b then failwith "State is already proved" ; - t - end - - module Update = struct - type t = { app_state : Field.Constant.t option Zkapp_state.V.t } - - let create () = - { app_state = [ None; None; None; None; None; None; None; None ] } - - let to_parties_update ({ app_state } : t) : Party.Update.t = - let default : Party.Update.t = - { app_state = [ Keep; Keep; Keep; Keep; Keep; Keep; Keep; Keep ] - ; delegate = Keep - ; verification_key = Keep - ; permissions = Keep - ; zkapp_uri = Keep - ; token_symbol = Keep - ; timing = Keep - ; voting_for = Keep - } - in - let app_state = - Pickles_types.Vector.map ~f:Zkapp_basic.Set_or_keep.of_option app_state - in - { default with app_state } - - let set_full_state app_state (_t : t) = - match app_state with - | [ a0; a1; a2; a3; a4; a5; a6; a7 ] -> - { app_state = - [ Some a0 - ; Some a1 - ; Some a2 - ; Some a3 - ; Some a4 - ; Some a5 - ; Some a6 - ; Some a7 - ] - } - | _ -> - failwith "Incorrect length of app_state" - end - - type t = - { public_key : Public_key.Compressed.t - ; token_id : Token_id.t - ; account_condition : Account_condition.t - ; update : Update.t - } - - let create ~public_key ?(token_id = Token_id.default) () = - { public_key - ; token_id - ; account_condition = Account_condition.create () - ; update = Update.create () - } - - let to_party (t : t) : Party.Body.t = - { public_key = t.public_key - ; token_id = t.token_id - ; update = Update.to_parties_update t.update - ; balance_change = { magnitude = Amount.zero; sgn = Pos } - ; increment_nonce = false - ; events = [] - ; sequence_events = [] - ; call_data = Field.Constant.zero - ; preconditions = - { Party.Preconditions.network = - { snarked_ledger_hash = Ignore - ; timestamp = Ignore - ; blockchain_length = Ignore - ; min_window_density = Ignore - ; last_vrf_output = () - ; total_currency = Ignore - ; global_slot_since_hard_fork = Ignore - ; global_slot_since_genesis = Ignore - ; staking_epoch_data = - { ledger = - { Epoch_ledger.Poly.hash = Ignore; total_currency = Ignore } - ; seed = Ignore - ; start_checkpoint = Ignore - ; lock_checkpoint = Ignore - ; epoch_length = Ignore - } - ; next_epoch_data = - { ledger = - { Epoch_ledger.Poly.hash = Ignore; total_currency = Ignore } - ; seed = Ignore - ; start_checkpoint = Ignore - ; lock_checkpoint = Ignore - ; epoch_length = Ignore - } - } - ; account = Full (Account_condition.to_predicate t.account_condition) - } - ; use_full_commitment = false - ; caller = t.token_id - } - - let assert_state_unproved (t : t) = - { t with - account_condition = - Account_condition.assert_state_unproved t.account_condition - } - - let assert_state_proved (t : t) = - { t with - account_condition = - Account_condition.assert_state_proved t.account_condition - } - - let set_full_state app_state (t : t) = - { t with update = Update.set_full_state app_state t.update } - module In_circuit = struct module Account_condition = struct type t = { state_proved : Boolean.var option } From a6fc3a668395e60021a580529233ce76c1787644 Mon Sep 17 00:00:00 2001 From: mrmr1993 Date: Mon, 1 Aug 2022 13:55:16 +0100 Subject: [PATCH 006/144] Simplify Zkapps_examples.wrap_main API --- .../empty_update/zkapps_empty_update.ml | 12 ++---------- .../zkapps_initialize_state.ml | 19 ++++--------------- src/lib/zkapps_examples/zkapps_examples.ml | 8 ++++++-- 3 files changed, 12 insertions(+), 27 deletions(-) diff --git a/src/lib/zkapps_examples/empty_update/zkapps_empty_update.ml b/src/lib/zkapps_examples/empty_update/zkapps_empty_update.ml index 16150b11eee..540e2aba3a3 100644 --- a/src/lib/zkapps_examples/empty_update/zkapps_empty_update.ml +++ b/src/lib/zkapps_examples/empty_update/zkapps_empty_update.ml @@ -1,16 +1,8 @@ open Signature_lib -open Mina_base -open Zkapps_examples -(* TODO: Should be able to *return* stmt instead of consuming it. - Modify snarky to do this. -*) let main public_key = - Zkapps_examples.wrap_main (fun () -> - Party_under_construction.In_circuit.create - ~public_key:(Public_key.Compressed.var_of_t public_key) - ~token_id:Token_id.(Checked.constant default) - () ) + Zkapps_examples.wrap_main + ~public_key:(Public_key.Compressed.var_of_t public_key) (fun party -> party) let rule public_key : _ Pickles.Inductive_rule.t = { identifier = "Empty update" diff --git a/src/lib/zkapps_examples/initialize_state/zkapps_initialize_state.ml b/src/lib/zkapps_examples/initialize_state/zkapps_initialize_state.ml index f1b86347e02..373d0120632 100644 --- a/src/lib/zkapps_examples/initialize_state/zkapps_initialize_state.ml +++ b/src/lib/zkapps_examples/initialize_state/zkapps_initialize_state.ml @@ -1,7 +1,6 @@ open Core_kernel open Snark_params.Tick.Run open Signature_lib -open Mina_base open Zkapps_examples let initial_state = @@ -17,13 +16,8 @@ let initial_state = ] let initialize public_key = - Zkapps_examples.wrap_main (fun () -> - let party = - Party_under_construction.In_circuit.create - ~public_key:(Public_key.Compressed.var_of_t public_key) - ~token_id:Token_id.(Checked.constant default) - () - in + Zkapps_examples.wrap_main + ~public_key:(Public_key.Compressed.var_of_t public_key) (fun party -> let initial_state = List.map ~f:Field.constant (Lazy.force initial_state) in @@ -42,13 +36,8 @@ let update_state_handler (new_state : Field.Constant.t list) respond Unhandled let update_state public_key = - Zkapps_examples.wrap_main (fun () -> - let party = - Party_under_construction.In_circuit.create - ~public_key:(Public_key.Compressed.var_of_t public_key) - ~token_id:Token_id.(Checked.constant default) - () - in + Zkapps_examples.wrap_main + ~public_key:(Public_key.Compressed.var_of_t public_key) (fun party -> let new_state = exists (Typ.list ~length:8 Field.typ) ~request:(fun () -> New_state) in diff --git a/src/lib/zkapps_examples/zkapps_examples.ml b/src/lib/zkapps_examples/zkapps_examples.ml index 1e26736528c..cf5700016cd 100644 --- a/src/lib/zkapps_examples/zkapps_examples.ml +++ b/src/lib/zkapps_examples/zkapps_examples.ml @@ -285,9 +285,13 @@ let to_party party : Zkapp_statement.Checked.t * return_type Prover_value.t = open Pickles_types open Hlist -let wrap_main f { Pickles.Inductive_rule.public_input = () } = +let wrap_main ~public_key ?token_id f + { Pickles.Inductive_rule.public_input = () } = + let party = + Party_under_construction.In_circuit.create ~public_key ?token_id () + in { Pickles.Inductive_rule.previous_proof_statements = [] - ; public_output = f () + ; public_output = f party ; auxiliary_output = () } From 5eb7dfb6a9a90d5c92ef3aad1c60be9b03cdaaf7 Mon Sep 17 00:00:00 2001 From: mrmr1993 Date: Mon, 1 Aug 2022 13:57:22 +0100 Subject: [PATCH 007/144] Use List.init --- .../initialize_state/zkapps_initialize_state.ml | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/src/lib/zkapps_examples/initialize_state/zkapps_initialize_state.ml b/src/lib/zkapps_examples/initialize_state/zkapps_initialize_state.ml index 373d0120632..f846fec4fbc 100644 --- a/src/lib/zkapps_examples/initialize_state/zkapps_initialize_state.ml +++ b/src/lib/zkapps_examples/initialize_state/zkapps_initialize_state.ml @@ -4,16 +4,7 @@ open Signature_lib open Zkapps_examples let initial_state = - lazy - [ Field.Constant.zero - ; Field.Constant.zero - ; Field.Constant.zero - ; Field.Constant.zero - ; Field.Constant.zero - ; Field.Constant.zero - ; Field.Constant.zero - ; Field.Constant.zero - ] + lazy (List.init 8 ~f:(fun _ -> Field.Constant.zero)) let initialize public_key = Zkapps_examples.wrap_main From 26aa4aaf3cb1a7205dd0966762e2b9376a862739 Mon Sep 17 00:00:00 2001 From: mrmr1993 Date: Mon, 1 Aug 2022 14:10:43 +0100 Subject: [PATCH 008/144] Create and use an object-oriented API for zkApps examples --- .../empty_update/zkapps_empty_update.ml | 3 +- .../zkapps_initialize_state.ml | 12 +++---- src/lib/zkapps_examples/zkapps_examples.ml | 35 ++++++++++++++----- 3 files changed, 34 insertions(+), 16 deletions(-) diff --git a/src/lib/zkapps_examples/empty_update/zkapps_empty_update.ml b/src/lib/zkapps_examples/empty_update/zkapps_empty_update.ml index 540e2aba3a3..c592430758a 100644 --- a/src/lib/zkapps_examples/empty_update/zkapps_empty_update.ml +++ b/src/lib/zkapps_examples/empty_update/zkapps_empty_update.ml @@ -2,7 +2,8 @@ open Signature_lib let main public_key = Zkapps_examples.wrap_main - ~public_key:(Public_key.Compressed.var_of_t public_key) (fun party -> party) + ~public_key:(Public_key.Compressed.var_of_t public_key) + ignore let rule public_key : _ Pickles.Inductive_rule.t = { identifier = "Empty update" diff --git a/src/lib/zkapps_examples/initialize_state/zkapps_initialize_state.ml b/src/lib/zkapps_examples/initialize_state/zkapps_initialize_state.ml index f846fec4fbc..2f3f899d880 100644 --- a/src/lib/zkapps_examples/initialize_state/zkapps_initialize_state.ml +++ b/src/lib/zkapps_examples/initialize_state/zkapps_initialize_state.ml @@ -1,10 +1,8 @@ open Core_kernel open Snark_params.Tick.Run open Signature_lib -open Zkapps_examples -let initial_state = - lazy (List.init 8 ~f:(fun _ -> Field.Constant.zero)) +let initial_state = lazy (List.init 8 ~f:(fun _ -> Field.Constant.zero)) let initialize public_key = Zkapps_examples.wrap_main @@ -12,8 +10,8 @@ let initialize public_key = let initial_state = List.map ~f:Field.constant (Lazy.force initial_state) in - party |> Party_under_construction.In_circuit.assert_state_unproved - |> Party_under_construction.In_circuit.set_full_state initial_state ) + party#assert_state_unproved ; + party#set_full_state initial_state ) type _ Snarky_backendless.Request.t += | New_state : Field.Constant.t list Snarky_backendless.Request.t @@ -32,8 +30,8 @@ let update_state public_key = let new_state = exists (Typ.list ~length:8 Field.typ) ~request:(fun () -> New_state) in - party |> Party_under_construction.In_circuit.assert_state_proved - |> Party_under_construction.In_circuit.set_full_state new_state ) + party#assert_state_proved ; + party#set_full_state new_state ) let initialize_rule public_key : _ Pickles.Inductive_rule.t = { identifier = "Initialize snapp" diff --git a/src/lib/zkapps_examples/zkapps_examples.ml b/src/lib/zkapps_examples/zkapps_examples.ml index cf5700016cd..6319a313a37 100644 --- a/src/lib/zkapps_examples/zkapps_examples.ml +++ b/src/lib/zkapps_examples/zkapps_examples.ml @@ -226,6 +226,24 @@ module Party_under_construction = struct end end +class party ~public_key ?token_id = + object + val mutable party = + Party_under_construction.In_circuit.create ~public_key ?token_id () + + method assert_state_proved = + party <- Party_under_construction.In_circuit.assert_state_proved party + + method assert_state_unproved = + party <- Party_under_construction.In_circuit.assert_state_unproved party + + method set_full_state app_state = + party <- + Party_under_construction.In_circuit.set_full_state app_state party + + method party_under_construction = party + end + (* TODO: Move this somewhere convenient. *) let dummy_constraints () = let x = exists Field.typ ~compute:(fun () -> Field.Constant.of_int 3) in @@ -260,10 +278,12 @@ type return_type = list } -let to_party party : Zkapp_statement.Checked.t * return_type Prover_value.t = +let to_party (party : party) : + Zkapp_statement.Checked.t * return_type Prover_value.t = dummy_constraints () ; let party, calls = - Party_under_construction.In_circuit.to_party_and_calls party + Party_under_construction.In_circuit.to_party_and_calls + party#party_under_construction in let party_digest = Parties.Call_forest.Digest.Party.Checked.create party in let public_output : Zkapp_statement.Checked.t = @@ -287,11 +307,10 @@ open Hlist let wrap_main ~public_key ?token_id f { Pickles.Inductive_rule.public_input = () } = - let party = - Party_under_construction.In_circuit.create ~public_key ?token_id () - in + let party = new party ~public_key ?token_id in + f party ; { Pickles.Inductive_rule.previous_proof_statements = [] - ; public_output = f party + ; public_output = party ; auxiliary_output = () } @@ -324,7 +343,7 @@ let compile : , heightss , unit , unit - , Party_under_construction.In_circuit.t + , party , unit (* TODO: Remove? *) , auxiliary_var , auxiliary_value ) @@ -363,7 +382,7 @@ let compile : , heightss , unit , unit - , Party_under_construction.In_circuit.t + , party , unit , auxiliary_var , auxiliary_value ) From 6fb2077e5b43760d947c3a7d4e8b0271a39218bd Mon Sep 17 00:00:00 2001 From: mrmr1993 Date: Mon, 8 Aug 2022 13:33:00 +0100 Subject: [PATCH 009/144] Add doc-comments for initialize rule --- src/lib/zkapps_examples/calls/zkapps_calls.ml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/lib/zkapps_examples/calls/zkapps_calls.ml b/src/lib/zkapps_examples/calls/zkapps_calls.ml index 8d3401cfc64..046721d90f1 100644 --- a/src/lib/zkapps_examples/calls/zkapps_calls.ml +++ b/src/lib/zkapps_examples/calls/zkapps_calls.ml @@ -3,8 +3,16 @@ open Snark_params.Tick.Run open Signature_lib open Mina_base +(** State to initialize the zkApp to after deployment. *) let initial_state = lazy (List.init 8 ~f:(fun _ -> Field.Constant.zero)) +(** Rule to initialize the zkApp. + + Asserts that the state was not last updated by a proof (ie. the zkApp is + freshly deployed, or that the state was modified -- tampered with -- + without using a proof). + The app state is set to the initial state. +*) let initialize public_key = Zkapps_examples.wrap_main ~public_key:(Public_key.Compressed.var_of_t public_key) (fun party -> From 2e096ecc39592c5a1a9b122bb311908df2e6673d Mon Sep 17 00:00:00 2001 From: mrmr1993 Date: Mon, 8 Aug 2022 13:47:32 +0100 Subject: [PATCH 010/144] Only update the first element of the state for call example --- .../test/zkapps_examples/calls/calls.ml | 7 +- src/lib/zkapps_examples/calls/zkapps_calls.ml | 65 ++++++++----------- src/lib/zkapps_examples/zkapps_examples.ml | 13 ++++ 3 files changed, 42 insertions(+), 43 deletions(-) diff --git a/src/lib/transaction_snark/test/zkapps_examples/calls/calls.ml b/src/lib/transaction_snark/test/zkapps_examples/calls/calls.ml index f93eb529375..2971c88b850 100644 --- a/src/lib/transaction_snark/test/zkapps_examples/calls/calls.ml +++ b/src/lib/transaction_snark/test/zkapps_examples/calls/calls.ml @@ -66,8 +66,7 @@ let%test_module "Initialize state test" = ; recursive_call_prover ] ) = Zkapps_examples.compile () ~cache:Cache_dir.cache - ~auxiliary_typ: - (option_typ Impl.(Typ.(list ~length:8 Field.typ * Field.typ))) + ~auxiliary_typ:(option_typ Impl.(Typ.(Field.typ * Field.typ))) ~branches:(module Nat.N4) ~max_proofs_verified:(module Nat.N0) ~name:"empty_update" @@ -135,12 +134,12 @@ let%test_module "Initialize state test" = end module Update_state_party = struct - let old_state = List.init 8 ~f:(fun _ -> Snark_params.Tick.Field.one) + let old_state = Snark_params.Tick.Field.one let handler (calls_kind : calls_kind) old_state = let open Snark_params.Tick.Run in let rec make_call calls_kind input : - (Field.Constant.t list * Field.Constant.t) + (Field.Constant.t * Field.Constant.t) * Zkapp_call_forest.party * Zkapp_call_forest.t = match calls_kind with diff --git a/src/lib/zkapps_examples/calls/zkapps_calls.ml b/src/lib/zkapps_examples/calls/zkapps_calls.ml index 046721d90f1..c3c821e913f 100644 --- a/src/lib/zkapps_examples/calls/zkapps_calls.ml +++ b/src/lib/zkapps_examples/calls/zkapps_calls.ml @@ -28,26 +28,26 @@ let call_data_hash ~old_state ~new_state ~blinding_value = Array.reduce_exn ~f:Random_oracle_input.Chunked.append Random_oracle_input.Chunked. [| field blinding_value - ; field_elements (Array.of_list old_state) - ; field_elements (Array.of_list new_state) + ; field_elements [| old_state |] + ; field_elements [| new_state |] |] |> pack_input |> update ~state:initial_state |> digest type _ Snarky_backendless.Request.t += - | Old_state : Field.Constant.t list Snarky_backendless.Request.t + | Old_state : Field.Constant.t Snarky_backendless.Request.t | Call_data : - Field.Constant.t list - -> ( (Field.Constant.t list * Field.Constant.t) + Field.Constant.t + -> ( (Field.Constant.t * Field.Constant.t) * Zkapp_call_forest.party * Zkapp_call_forest.t ) Snarky_backendless.Request.t -let update_state_handler (old_state : Field.Constant.t list) +let update_state_handler (old_state : Field.Constant.t) (compute_call : - Field.Constant.t list - -> (Field.Constant.t list * Field.Constant.t) + Field.Constant.t + -> (Field.Constant.t * Field.Constant.t) * Zkapp_call_forest.party * Zkapp_call_forest.t ) (Snarky_backendless.Request.With { request; respond }) = @@ -62,19 +62,15 @@ let update_state_handler (old_state : Field.Constant.t list) let update_state_call public_key = Zkapps_examples.wrap_main ~public_key:(Public_key.Compressed.var_of_t public_key) (fun party -> - let old_state = - exists (Typ.list ~length:8 Field.typ) ~request:(fun () -> Old_state) - in + let old_state = exists Field.typ ~request:(fun () -> Old_state) in let (new_state, blinding_value), called_party, sub_calls = exists (Typ.tuple3 - Typ.(list ~length:8 Field.typ * Field.typ) + Typ.(Field.typ * Field.typ) (Zkapp_call_forest.Checked.party_typ ()) Zkapp_call_forest.typ ) ~request:(fun () -> - let input = - As_prover.read (Typ.list ~length:8 Field.typ) old_state - in + let input = As_prover.read Field.typ old_state in Call_data input ) in let () = @@ -85,14 +81,14 @@ let update_state_call public_key = Field.Assert.equal call_data_hash called_party.party.data.call_data in party#assert_state_proved ; - party#set_full_state old_state ; + party#set_state 0 old_state ; party#call called_party sub_calls ; None ) type _ Snarky_backendless.Request.t += - | Call_input : Field.Constant.t list Snarky_backendless.Request.t + | Call_input : Field.Constant.t Snarky_backendless.Request.t -let call_handler (call_input : Field.Constant.t list) +let call_handler (call_input : Field.Constant.t) (Snarky_backendless.Request.With { request; respond }) = match request with | Call_input -> @@ -103,14 +99,10 @@ let call_handler (call_input : Field.Constant.t list) let call public_key = Zkapps_examples.wrap_main ~public_key:(Public_key.Compressed.var_of_t public_key) (fun party -> - let old_state = - exists (Typ.list ~length:8 Field.typ) ~request:(fun () -> Call_input) - in + let old_state = exists Field.typ ~request:(fun () -> Call_input) in let blinding_value = exists Field.typ ~compute:Field.Constant.random in let modify_value = exists Field.typ ~compute:Field.Constant.random in - let new_state = - List.map old_state ~f:(fun x -> Field.add x modify_value) - in + let new_state = Field.add old_state modify_value in let call_data_hash = call_data_hash ~old_state ~new_state ~blinding_value in @@ -119,18 +111,18 @@ let call public_key = Some (new_state, blinding_value) ) type _ Snarky_backendless.Request.t += - | Recursive_call_input : Field.Constant.t list Snarky_backendless.Request.t + | Recursive_call_input : Field.Constant.t Snarky_backendless.Request.t | Recursive_call_data : - Field.Constant.t list - -> ( (Field.Constant.t list * Field.Constant.t) + Field.Constant.t + -> ( (Field.Constant.t * Field.Constant.t) * Zkapp_call_forest.party * Zkapp_call_forest.t ) Snarky_backendless.Request.t -let recursive_call_handler (recursive_call_input : Field.Constant.t list) +let recursive_call_handler (recursive_call_input : Field.Constant.t) (compute_call : - Field.Constant.t list - -> (Field.Constant.t list * Field.Constant.t) + Field.Constant.t + -> (Field.Constant.t * Field.Constant.t) * Zkapp_call_forest.party * Zkapp_call_forest.t ) (Snarky_backendless.Request.With { request; respond }) = @@ -146,19 +138,16 @@ let recursive_call public_key = Zkapps_examples.wrap_main ~public_key:(Public_key.Compressed.var_of_t public_key) (fun party -> let old_state = - exists (Typ.list ~length:8 Field.typ) ~request:(fun () -> - Recursive_call_input ) + exists Field.typ ~request:(fun () -> Recursive_call_input) in let (new_state, blinding_value), called_party, sub_calls = exists (Typ.tuple3 - Typ.(list ~length:8 Field.typ * Field.typ) + Typ.(Field.typ * Field.typ) (Zkapp_call_forest.Checked.party_typ ()) Zkapp_call_forest.typ ) ~request:(fun () -> - let input = - As_prover.read (Typ.list ~length:8 Field.typ) old_state - in + let input = As_prover.read Field.typ old_state in Recursive_call_data input ) in let () = @@ -170,9 +159,7 @@ let recursive_call public_key = in let blinding_value = exists Field.typ ~compute:Field.Constant.random in let modify_value = exists Field.typ ~compute:Field.Constant.random in - let new_state = - List.map old_state ~f:(fun x -> Field.add x modify_value) - in + let new_state = Field.add old_state modify_value in let call_data_hash = call_data_hash ~old_state ~new_state ~blinding_value in diff --git a/src/lib/zkapps_examples/zkapps_examples.ml b/src/lib/zkapps_examples/zkapps_examples.ml index e715de10892..5d15bca51d3 100644 --- a/src/lib/zkapps_examples/zkapps_examples.ml +++ b/src/lib/zkapps_examples/zkapps_examples.ml @@ -131,6 +131,13 @@ module Party_under_construction = struct } | _ -> failwith "Incorrect length of app_state" + + let set_state i value (t : t) = + if i < 0 || i >= 8 then failwith "Incorrect index" ; + { app_state = + Pickles_types.Vector.mapi t.app_state ~f:(fun j old_value -> + if i = j then Some value else old_value ) + } end type t = @@ -234,6 +241,9 @@ module Party_under_construction = struct let set_full_state app_state (t : t) = { t with update = Update.set_full_state app_state t.update } + let set_state idx data (t : t) = + { t with update = Update.set_state idx data t.update } + let call party calls (t : t) = { t with rev_calls = (party, calls) :: t.rev_calls } @@ -252,6 +262,9 @@ class party ~public_key ?token_id = method assert_state_unproved = party <- Party_under_construction.In_circuit.assert_state_unproved party + method set_state idx data = + party <- Party_under_construction.In_circuit.set_state idx data party + method set_full_state app_state = party <- Party_under_construction.In_circuit.set_full_state app_state party From 84e2b7a7330c8718fb93fd39df08c5699febd571 Mon Sep 17 00:00:00 2001 From: mrmr1993 Date: Mon, 8 Aug 2022 14:41:21 +0100 Subject: [PATCH 011/144] Add explicit Call_data type --- .../test/zkapps_examples/calls/calls.ml | 25 +-- src/lib/zkapps_examples/calls/dune | 3 +- src/lib/zkapps_examples/calls/zkapps_calls.ml | 181 +++++++++++++----- 3 files changed, 148 insertions(+), 61 deletions(-) diff --git a/src/lib/transaction_snark/test/zkapps_examples/calls/calls.ml b/src/lib/transaction_snark/test/zkapps_examples/calls/calls.ml index 2971c88b850..bb188e334d7 100644 --- a/src/lib/transaction_snark/test/zkapps_examples/calls/calls.ml +++ b/src/lib/transaction_snark/test/zkapps_examples/calls/calls.ml @@ -66,7 +66,7 @@ let%test_module "Initialize state test" = ; recursive_call_prover ] ) = Zkapps_examples.compile () ~cache:Cache_dir.cache - ~auxiliary_typ:(option_typ Impl.(Typ.(Field.typ * Field.typ))) + ~auxiliary_typ:(option_typ Zkapps_calls.Call_data.Output.typ) ~branches:(module Nat.N4) ~max_proofs_verified:(module Nat.N0) ~name:"empty_update" @@ -137,9 +137,8 @@ let%test_module "Initialize state test" = let old_state = Snark_params.Tick.Field.one let handler (calls_kind : calls_kind) old_state = - let open Snark_params.Tick.Run in let rec make_call calls_kind input : - (Field.Constant.t * Field.Constant.t) + Zkapps_calls.Call_data.Output.Constant.t * Zkapp_call_forest.party * Zkapp_call_forest.t = match calls_kind with @@ -256,11 +255,12 @@ let%test_module "Initialize state test" = |> Parties.Call_forest.cons Deploy_party.party |> test_parties in - let zkapp_state = + let (first_state :: zkapp_state) = (Option.value_exn (Option.value_exn account).zkapp).app_state in + assert (Snark_params.Tick.Field.(equal one) first_state) ; Pickles_types.Vector.iter - ~f:(fun x -> assert (Snark_params.Tick.Field.(equal one) x)) + ~f:(fun x -> assert (Snark_params.Tick.Field.(equal zero) x)) zkapp_state let%test_unit "Initialize and update single recursive" = @@ -272,11 +272,12 @@ let%test_module "Initialize state test" = |> Parties.Call_forest.cons Deploy_party.party |> test_parties in - let zkapp_state = + let (first_state :: zkapp_state) = (Option.value_exn (Option.value_exn account).zkapp).app_state in + assert (Snark_params.Tick.Field.(equal one) first_state) ; Pickles_types.Vector.iter - ~f:(fun x -> assert (Snark_params.Tick.Field.(equal one) x)) + ~f:(fun x -> assert (Snark_params.Tick.Field.(equal zero) x)) zkapp_state let%test_unit "Initialize and update double recursive" = @@ -288,11 +289,12 @@ let%test_module "Initialize state test" = |> Parties.Call_forest.cons Deploy_party.party |> test_parties in - let zkapp_state = + let (first_state :: zkapp_state) = (Option.value_exn (Option.value_exn account).zkapp).app_state in + assert (Snark_params.Tick.Field.(equal one) first_state) ; Pickles_types.Vector.iter - ~f:(fun x -> assert (Snark_params.Tick.Field.(equal one) x)) + ~f:(fun x -> assert (Snark_params.Tick.Field.(equal zero) x)) zkapp_state let%test_unit "Initialize and update triple recursive" = @@ -304,10 +306,11 @@ let%test_module "Initialize state test" = |> Parties.Call_forest.cons Deploy_party.party |> test_parties in - let zkapp_state = + let (first_state :: zkapp_state) = (Option.value_exn (Option.value_exn account).zkapp).app_state in + assert (Snark_params.Tick.Field.(equal one) first_state) ; Pickles_types.Vector.iter - ~f:(fun x -> assert (Snark_params.Tick.Field.(equal one) x)) + ~f:(fun x -> assert (Snark_params.Tick.Field.(equal zero) x)) zkapp_state end ) diff --git a/src/lib/zkapps_examples/calls/dune b/src/lib/zkapps_examples/calls/dune index e03ca4e55ff..f66ec1b4f73 100644 --- a/src/lib/zkapps_examples/calls/dune +++ b/src/lib/zkapps_examples/calls/dune @@ -27,4 +27,5 @@ (instrumentation (backend bisect_ppx)) (preprocess (pps - ppx_version))) + ppx_version + h_list.ppx))) diff --git a/src/lib/zkapps_examples/calls/zkapps_calls.ml b/src/lib/zkapps_examples/calls/zkapps_calls.ml index c3c821e913f..24f71b471ee 100644 --- a/src/lib/zkapps_examples/calls/zkapps_calls.ml +++ b/src/lib/zkapps_examples/calls/zkapps_calls.ml @@ -23,31 +23,110 @@ let initialize public_key = party#set_full_state initial_state ; None ) -let call_data_hash ~old_state ~new_state ~blinding_value = - let open Random_oracle.Checked in - Array.reduce_exn ~f:Random_oracle_input.Chunked.append - Random_oracle_input.Chunked. - [| field blinding_value - ; field_elements [| old_state |] - ; field_elements [| new_state |] - |] - |> pack_input - |> update ~state:initial_state - |> digest +(** The type underlying the opaque call data digest field used by the call + rules. +*) +module Call_data = struct + (** The type of inputs that the zkApp rules receive when called by another + zkApp. + *) + module Input = struct + module Constant = struct + type t = { old_state : Field.Constant.t } [@@deriving hlist] + + let to_ro_input { old_state } = + Random_oracle_input.Chunked.field_elements [| old_state |] + end + + module Circuit = struct + type t = { old_state : Field.t } [@@deriving hlist] + + let to_ro_input { old_state } = + Random_oracle_input.Chunked.field_elements [| old_state |] + end + + let typ = + Typ.of_hlistable ~value_to_hlist:Constant.to_hlist + ~value_of_hlist:Constant.of_hlist ~var_to_hlist:Circuit.to_hlist + ~var_of_hlist:Circuit.of_hlist [ Field.typ ] + end + + (** The type of outputs that the zkApp rules receive when called by another + zkApp. + *) + module Output = struct + module Constant = struct + type t = + { blinding_value : Field.Constant.t; new_state : Field.Constant.t } + [@@deriving hlist] + + let to_ro_input { blinding_value; new_state } = + Random_oracle_input.Chunked.field_elements + [| blinding_value; new_state |] + end + + module Circuit = struct + type t = { blinding_value : Field.t; new_state : Field.t } + [@@deriving hlist] + + let to_ro_input { blinding_value; new_state } = + Random_oracle_input.Chunked.field_elements + [| blinding_value; new_state |] + end + + let typ = + Typ.of_hlistable ~value_to_hlist:Constant.to_hlist + ~value_of_hlist:Constant.of_hlist ~var_to_hlist:Circuit.to_hlist + ~var_of_hlist:Circuit.of_hlist [ Field.typ; Field.typ ] + end + + module Constant = struct + type t = { input : Input.Constant.t; output : Output.Constant.t } + [@@deriving hlist] + + let to_ro_input { input; output } = + Random_oracle_input.Chunked.append + (Input.Constant.to_ro_input input) + (Output.Constant.to_ro_input output) + + let digest (t : t) = + let open Random_oracle in + to_ro_input t |> pack_input |> update ~state:initial_state |> digest + end + + module Circuit = struct + type t = { input : Input.Circuit.t; output : Output.Circuit.t } + [@@deriving hlist] + + let to_ro_input { input; output } = + Random_oracle_input.Chunked.append + (Input.Circuit.to_ro_input input) + (Output.Circuit.to_ro_input output) + + let digest (t : t) = + let open Random_oracle.Checked in + to_ro_input t |> pack_input |> update ~state:initial_state |> digest + end + + let typ = + Typ.of_hlistable ~value_to_hlist:Constant.to_hlist + ~value_of_hlist:Constant.of_hlist ~var_to_hlist:Circuit.to_hlist + ~var_of_hlist:Circuit.of_hlist [ Input.typ; Output.typ ] +end type _ Snarky_backendless.Request.t += | Old_state : Field.Constant.t Snarky_backendless.Request.t | Call_data : - Field.Constant.t - -> ( (Field.Constant.t * Field.Constant.t) + Call_data.Input.Constant.t + -> ( Call_data.Output.Constant.t * Zkapp_call_forest.party * Zkapp_call_forest.t ) Snarky_backendless.Request.t let update_state_handler (old_state : Field.Constant.t) (compute_call : - Field.Constant.t - -> (Field.Constant.t * Field.Constant.t) + Call_data.Input.Constant.t + -> Call_data.Output.Constant.t * Zkapp_call_forest.party * Zkapp_call_forest.t ) (Snarky_backendless.Request.With { request; respond }) = @@ -63,22 +142,23 @@ let update_state_call public_key = Zkapps_examples.wrap_main ~public_key:(Public_key.Compressed.var_of_t public_key) (fun party -> let old_state = exists Field.typ ~request:(fun () -> Old_state) in - let (new_state, blinding_value), called_party, sub_calls = + let call_inputs = { Call_data.Input.Circuit.old_state } in + let call_outputs, called_party, sub_calls = exists - (Typ.tuple3 - Typ.(Field.typ * Field.typ) + (Typ.tuple3 Call_data.Output.typ (Zkapp_call_forest.Checked.party_typ ()) Zkapp_call_forest.typ ) ~request:(fun () -> - let input = As_prover.read Field.typ old_state in + let input = As_prover.read Call_data.Input.typ call_inputs in Call_data input ) in let () = (* Check that previous party's call data is consistent. *) - let call_data_hash = - call_data_hash ~old_state ~new_state ~blinding_value + let call_data_digest = + Call_data.Circuit.digest + { input = call_inputs; output = call_outputs } in - Field.Assert.equal call_data_hash called_party.party.data.call_data + Field.Assert.equal call_data_digest called_party.party.data.call_data in party#assert_state_proved ; party#set_state 0 old_state ; @@ -86,9 +166,9 @@ let update_state_call public_key = None ) type _ Snarky_backendless.Request.t += - | Call_input : Field.Constant.t Snarky_backendless.Request.t + | Call_input : Call_data.Input.Constant.t Snarky_backendless.Request.t -let call_handler (call_input : Field.Constant.t) +let call_handler (call_input : Call_data.Input.Constant.t) (Snarky_backendless.Request.With { request; respond }) = match request with | Call_input -> @@ -99,30 +179,30 @@ let call_handler (call_input : Field.Constant.t) let call public_key = Zkapps_examples.wrap_main ~public_key:(Public_key.Compressed.var_of_t public_key) (fun party -> - let old_state = exists Field.typ ~request:(fun () -> Call_input) in + let input = exists Call_data.Input.typ ~request:(fun () -> Call_input) in let blinding_value = exists Field.typ ~compute:Field.Constant.random in let modify_value = exists Field.typ ~compute:Field.Constant.random in - let new_state = Field.add old_state modify_value in - let call_data_hash = - call_data_hash ~old_state ~new_state ~blinding_value - in + let new_state = Field.add input.old_state modify_value in + let output = { Call_data.Output.Circuit.blinding_value; new_state } in + let call_data_digest = Call_data.Circuit.digest { input; output } in party#assert_state_proved ; - party#set_call_data call_data_hash ; - Some (new_state, blinding_value) ) + party#set_call_data call_data_digest ; + Some output ) type _ Snarky_backendless.Request.t += - | Recursive_call_input : Field.Constant.t Snarky_backendless.Request.t + | Recursive_call_input : + Call_data.Input.Constant.t Snarky_backendless.Request.t | Recursive_call_data : - Field.Constant.t - -> ( (Field.Constant.t * Field.Constant.t) + Call_data.Input.Constant.t + -> ( Call_data.Output.Constant.t * Zkapp_call_forest.party * Zkapp_call_forest.t ) Snarky_backendless.Request.t -let recursive_call_handler (recursive_call_input : Field.Constant.t) +let recursive_call_handler (recursive_call_input : Call_data.Input.Constant.t) (compute_call : - Field.Constant.t - -> (Field.Constant.t * Field.Constant.t) + Call_data.Input.Constant.t + -> Call_data.Output.Constant.t * Zkapp_call_forest.party * Zkapp_call_forest.t ) (Snarky_backendless.Request.With { request; respond }) = @@ -137,36 +217,39 @@ let recursive_call_handler (recursive_call_input : Field.Constant.t) let recursive_call public_key = Zkapps_examples.wrap_main ~public_key:(Public_key.Compressed.var_of_t public_key) (fun party -> - let old_state = - exists Field.typ ~request:(fun () -> Recursive_call_input) + let call_inputs = + exists Call_data.Input.typ ~request:(fun () -> Recursive_call_input) in - let (new_state, blinding_value), called_party, sub_calls = + let recursive_call_outputs, called_party, sub_calls = exists - (Typ.tuple3 - Typ.(Field.typ * Field.typ) + (Typ.tuple3 Call_data.Output.typ (Zkapp_call_forest.Checked.party_typ ()) Zkapp_call_forest.typ ) ~request:(fun () -> - let input = As_prover.read Field.typ old_state in + let input = As_prover.read Call_data.Input.typ call_inputs in Recursive_call_data input ) in let () = (* Check that previous party's call data is consistent. *) - let call_data_hash = - call_data_hash ~old_state ~new_state ~blinding_value + let call_data_digest = + Call_data.Circuit.digest + { input = call_inputs; output = recursive_call_outputs } in - Field.Assert.equal call_data_hash called_party.party.data.call_data + Field.Assert.equal call_data_digest called_party.party.data.call_data in let blinding_value = exists Field.typ ~compute:Field.Constant.random in let modify_value = exists Field.typ ~compute:Field.Constant.random in - let new_state = Field.add old_state modify_value in + let new_state = Field.add recursive_call_outputs.new_state modify_value in + let call_outputs = + { Call_data.Output.Circuit.blinding_value; new_state } + in let call_data_hash = - call_data_hash ~old_state ~new_state ~blinding_value + Call_data.Circuit.digest { input = call_inputs; output = call_outputs } in party#assert_state_proved ; party#set_call_data call_data_hash ; party#call called_party sub_calls ; - Some (new_state, blinding_value) ) + Some call_outputs ) let initialize_rule public_key : _ Pickles.Inductive_rule.t = { identifier = "Initialize snapp" From 28e344944105094b7f17f31880f4cc08a4620e09 Mon Sep 17 00:00:00 2001 From: mrmr1993 Date: Mon, 8 Aug 2022 15:22:44 +0100 Subject: [PATCH 012/144] Use the same requests for all circuits --- src/lib/zkapps_examples/calls/zkapps_calls.ml | 84 +++++++++---------- 1 file changed, 38 insertions(+), 46 deletions(-) diff --git a/src/lib/zkapps_examples/calls/zkapps_calls.ml b/src/lib/zkapps_examples/calls/zkapps_calls.ml index 24f71b471ee..511269654ac 100644 --- a/src/lib/zkapps_examples/calls/zkapps_calls.ml +++ b/src/lib/zkapps_examples/calls/zkapps_calls.ml @@ -3,26 +3,6 @@ open Snark_params.Tick.Run open Signature_lib open Mina_base -(** State to initialize the zkApp to after deployment. *) -let initial_state = lazy (List.init 8 ~f:(fun _ -> Field.Constant.zero)) - -(** Rule to initialize the zkApp. - - Asserts that the state was not last updated by a proof (ie. the zkApp is - freshly deployed, or that the state was modified -- tampered with -- - without using a proof). - The app state is set to the initial state. -*) -let initialize public_key = - Zkapps_examples.wrap_main - ~public_key:(Public_key.Compressed.var_of_t public_key) (fun party -> - let initial_state = - List.map ~f:Field.constant (Lazy.force initial_state) - in - party#assert_state_unproved ; - party#set_full_state initial_state ; - None ) - (** The type underlying the opaque call data digest field used by the call rules. *) @@ -116,15 +96,38 @@ end type _ Snarky_backendless.Request.t += | Old_state : Field.Constant.t Snarky_backendless.Request.t - | Call_data : + | (* TODO: Tweak pickles so this can be an explicit input. *) + Get_call_input : + Call_data.Input.Constant.t Snarky_backendless.Request.t + | Execute_call : Call_data.Input.Constant.t -> ( Call_data.Output.Constant.t * Zkapp_call_forest.party * Zkapp_call_forest.t ) Snarky_backendless.Request.t +(** State to initialize the zkApp to after deployment. *) +let initial_state = lazy (List.init 8 ~f:(fun _ -> Field.Constant.zero)) + +(** Rule to initialize the zkApp. + + Asserts that the state was not last updated by a proof (ie. the zkApp is + freshly deployed, or that the state was modified -- tampered with -- + without using a proof). + The app state is set to the initial state. +*) +let initialize public_key = + Zkapps_examples.wrap_main + ~public_key:(Public_key.Compressed.var_of_t public_key) (fun party -> + let initial_state = + List.map ~f:Field.constant (Lazy.force initial_state) + in + party#assert_state_unproved ; + party#set_full_state initial_state ; + None ) + let update_state_handler (old_state : Field.Constant.t) - (compute_call : + (execute_call : Call_data.Input.Constant.t -> Call_data.Output.Constant.t * Zkapp_call_forest.party @@ -133,8 +136,8 @@ let update_state_handler (old_state : Field.Constant.t) match request with | Old_state -> respond (Provide old_state) - | Call_data input -> - respond (Provide (compute_call input)) + | Execute_call input -> + respond (Provide (execute_call input)) | _ -> respond Unhandled @@ -150,7 +153,7 @@ let update_state_call public_key = Zkapp_call_forest.typ ) ~request:(fun () -> let input = As_prover.read Call_data.Input.typ call_inputs in - Call_data input ) + Execute_call input ) in let () = (* Check that previous party's call data is consistent. *) @@ -165,13 +168,10 @@ let update_state_call public_key = party#call called_party sub_calls ; None ) -type _ Snarky_backendless.Request.t += - | Call_input : Call_data.Input.Constant.t Snarky_backendless.Request.t - let call_handler (call_input : Call_data.Input.Constant.t) (Snarky_backendless.Request.With { request; respond }) = match request with - | Call_input -> + | Get_call_input -> respond (Provide call_input) | _ -> respond Unhandled @@ -179,7 +179,9 @@ let call_handler (call_input : Call_data.Input.Constant.t) let call public_key = Zkapps_examples.wrap_main ~public_key:(Public_key.Compressed.var_of_t public_key) (fun party -> - let input = exists Call_data.Input.typ ~request:(fun () -> Call_input) in + let input = + exists Call_data.Input.typ ~request:(fun () -> Get_call_input) + in let blinding_value = exists Field.typ ~compute:Field.Constant.random in let modify_value = exists Field.typ ~compute:Field.Constant.random in let new_state = Field.add input.old_state modify_value in @@ -189,28 +191,18 @@ let call public_key = party#set_call_data call_data_digest ; Some output ) -type _ Snarky_backendless.Request.t += - | Recursive_call_input : - Call_data.Input.Constant.t Snarky_backendless.Request.t - | Recursive_call_data : - Call_data.Input.Constant.t - -> ( Call_data.Output.Constant.t - * Zkapp_call_forest.party - * Zkapp_call_forest.t ) - Snarky_backendless.Request.t - let recursive_call_handler (recursive_call_input : Call_data.Input.Constant.t) - (compute_call : + (execute_call : Call_data.Input.Constant.t -> Call_data.Output.Constant.t * Zkapp_call_forest.party * Zkapp_call_forest.t ) (Snarky_backendless.Request.With { request; respond }) = match request with - | Recursive_call_input -> + | Get_call_input -> respond (Provide recursive_call_input) - | Recursive_call_data input -> - respond (Provide (compute_call input)) + | Execute_call input -> + respond (Provide (execute_call input)) | _ -> respond Unhandled @@ -218,7 +210,7 @@ let recursive_call public_key = Zkapps_examples.wrap_main ~public_key:(Public_key.Compressed.var_of_t public_key) (fun party -> let call_inputs = - exists Call_data.Input.typ ~request:(fun () -> Recursive_call_input) + exists Call_data.Input.typ ~request:(fun () -> Get_call_input) in let recursive_call_outputs, called_party, sub_calls = exists @@ -227,7 +219,7 @@ let recursive_call public_key = Zkapp_call_forest.typ ) ~request:(fun () -> let input = As_prover.read Call_data.Input.typ call_inputs in - Recursive_call_data input ) + Execute_call input ) in let () = (* Check that previous party's call data is consistent. *) From e921775cff534008405a7dc9dcdeb02c04204a56 Mon Sep 17 00:00:00 2001 From: mrmr1993 Date: Mon, 8 Aug 2022 15:31:11 +0100 Subject: [PATCH 013/144] Add a helper function for calls between parties --- src/lib/zkapps_examples/calls/zkapps_calls.ml | 65 ++++++++----------- 1 file changed, 27 insertions(+), 38 deletions(-) diff --git a/src/lib/zkapps_examples/calls/zkapps_calls.ml b/src/lib/zkapps_examples/calls/zkapps_calls.ml index 511269654ac..609dd432838 100644 --- a/src/lib/zkapps_examples/calls/zkapps_calls.ml +++ b/src/lib/zkapps_examples/calls/zkapps_calls.ml @@ -94,6 +94,7 @@ module Call_data = struct ~var_of_hlist:Circuit.of_hlist [ Input.typ; Output.typ ] end +(** Circuit requests, to get values and run code outside of the snark. *) type _ Snarky_backendless.Request.t += | Old_state : Field.Constant.t Snarky_backendless.Request.t | (* TODO: Tweak pickles so this can be an explicit input. *) @@ -106,6 +107,27 @@ type _ Snarky_backendless.Request.t += * Zkapp_call_forest.t ) Snarky_backendless.Request.t +(** Helper function for executing zkApp calls. *) +let execute_call party call_inputs = + let call_outputs, called_party, sub_calls = + exists + (Typ.tuple3 Call_data.Output.typ + (Zkapp_call_forest.Checked.party_typ ()) + Zkapp_call_forest.typ ) + ~request:(fun () -> + let input = As_prover.read Call_data.Input.typ call_inputs in + Execute_call input ) + in + let () = + (* Check that previous party's call data is consistent. *) + let call_data_digest = + Call_data.Circuit.digest { input = call_inputs; output = call_outputs } + in + Field.Assert.equal call_data_digest called_party.party.data.call_data + in + party#call called_party sub_calls ; + call_outputs.new_state + (** State to initialize the zkApp to after deployment. *) let initial_state = lazy (List.init 8 ~f:(fun _ -> Field.Constant.zero)) @@ -145,27 +167,11 @@ let update_state_call public_key = Zkapps_examples.wrap_main ~public_key:(Public_key.Compressed.var_of_t public_key) (fun party -> let old_state = exists Field.typ ~request:(fun () -> Old_state) in - let call_inputs = { Call_data.Input.Circuit.old_state } in - let call_outputs, called_party, sub_calls = - exists - (Typ.tuple3 Call_data.Output.typ - (Zkapp_call_forest.Checked.party_typ ()) - Zkapp_call_forest.typ ) - ~request:(fun () -> - let input = As_prover.read Call_data.Input.typ call_inputs in - Execute_call input ) - in - let () = - (* Check that previous party's call data is consistent. *) - let call_data_digest = - Call_data.Circuit.digest - { input = call_inputs; output = call_outputs } - in - Field.Assert.equal call_data_digest called_party.party.data.call_data - in + let new_state = execute_call party { old_state } in + ignore new_state ; + (* TODO *) party#assert_state_proved ; party#set_state 0 old_state ; - party#call called_party sub_calls ; None ) let call_handler (call_input : Call_data.Input.Constant.t) @@ -212,26 +218,10 @@ let recursive_call public_key = let call_inputs = exists Call_data.Input.typ ~request:(fun () -> Get_call_input) in - let recursive_call_outputs, called_party, sub_calls = - exists - (Typ.tuple3 Call_data.Output.typ - (Zkapp_call_forest.Checked.party_typ ()) - Zkapp_call_forest.typ ) - ~request:(fun () -> - let input = As_prover.read Call_data.Input.typ call_inputs in - Execute_call input ) - in - let () = - (* Check that previous party's call data is consistent. *) - let call_data_digest = - Call_data.Circuit.digest - { input = call_inputs; output = recursive_call_outputs } - in - Field.Assert.equal call_data_digest called_party.party.data.call_data - in + let new_state = execute_call party call_inputs in let blinding_value = exists Field.typ ~compute:Field.Constant.random in let modify_value = exists Field.typ ~compute:Field.Constant.random in - let new_state = Field.add recursive_call_outputs.new_state modify_value in + let new_state = Field.add new_state modify_value in let call_outputs = { Call_data.Output.Circuit.blinding_value; new_state } in @@ -240,7 +230,6 @@ let recursive_call public_key = in party#assert_state_proved ; party#set_call_data call_data_hash ; - party#call called_party sub_calls ; Some call_outputs ) let initialize_rule public_key : _ Pickles.Inductive_rule.t = From ad410b69762b27a7314df7303555235a665b02ce Mon Sep 17 00:00:00 2001 From: mrmr1993 Date: Mon, 8 Aug 2022 15:53:49 +0100 Subject: [PATCH 014/144] Rename call to register_call --- src/lib/zkapps_examples/calls/zkapps_calls.ml | 2 +- src/lib/zkapps_examples/zkapps_examples.ml | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/lib/zkapps_examples/calls/zkapps_calls.ml b/src/lib/zkapps_examples/calls/zkapps_calls.ml index 609dd432838..9349e55fb1d 100644 --- a/src/lib/zkapps_examples/calls/zkapps_calls.ml +++ b/src/lib/zkapps_examples/calls/zkapps_calls.ml @@ -125,7 +125,7 @@ let execute_call party call_inputs = in Field.Assert.equal call_data_digest called_party.party.data.call_data in - party#call called_party sub_calls ; + party#register_call called_party sub_calls ; call_outputs.new_state (** State to initialize the zkApp to after deployment. *) diff --git a/src/lib/zkapps_examples/zkapps_examples.ml b/src/lib/zkapps_examples/zkapps_examples.ml index 5d15bca51d3..17d3a09568c 100644 --- a/src/lib/zkapps_examples/zkapps_examples.ml +++ b/src/lib/zkapps_examples/zkapps_examples.ml @@ -244,7 +244,7 @@ module Party_under_construction = struct let set_state idx data (t : t) = { t with update = Update.set_state idx data t.update } - let call party calls (t : t) = + let register_call party calls (t : t) = { t with rev_calls = (party, calls) :: t.rev_calls } let set_call_data call_data (t : t) = { t with call_data = Some call_data } @@ -272,9 +272,10 @@ class party ~public_key ?token_id = method set_call_data call_data = party <- Party_under_construction.In_circuit.set_call_data call_data party - method call called_party sub_calls = + method register_call called_party sub_calls = party <- - Party_under_construction.In_circuit.call called_party sub_calls party + Party_under_construction.In_circuit.register_call called_party sub_calls + party method party_under_construction = party end From e4dce45e333d451f2a6b1c501b2c56c2db0c0193 Mon Sep 17 00:00:00 2001 From: mrmr1993 Date: Mon, 8 Aug 2022 16:07:46 +0100 Subject: [PATCH 015/144] Set the zkApp state to the returned value, make increases predictable --- .../test/zkapps_examples/calls/calls.ml | 65 +++++++++++++++---- src/lib/zkapps_examples/calls/zkapps_calls.ml | 23 +++++-- 2 files changed, 67 insertions(+), 21 deletions(-) diff --git a/src/lib/transaction_snark/test/zkapps_examples/calls/calls.ml b/src/lib/transaction_snark/test/zkapps_examples/calls/calls.ml index bb188e334d7..61911266237 100644 --- a/src/lib/transaction_snark/test/zkapps_examples/calls/calls.ml +++ b/src/lib/transaction_snark/test/zkapps_examples/calls/calls.ml @@ -80,7 +80,9 @@ let%test_module "Initialize state test" = ; Zkapps_calls.recursive_call_rule pk_compressed ] ) - type calls_kind = Recurse of calls_kind | Call + type calls_kind = + | Recurse of Snark_params.Tick.Run.Field.Constant.t * calls_kind + | Call of Snark_params.Tick.Run.Field.Constant.t module P = (val p_module) @@ -134,7 +136,7 @@ let%test_module "Initialize state test" = end module Update_state_party = struct - let old_state = Snark_params.Tick.Field.one + let old_state = Snark_params.Tick.Field.zero let handler (calls_kind : calls_kind) old_state = let rec make_call calls_kind input : @@ -142,21 +144,22 @@ let%test_module "Initialize state test" = * Zkapp_call_forest.party * Zkapp_call_forest.t = match calls_kind with - | Call -> + | Call increase_amount -> let tree, aux = Async.Thread_safe.block_on_async_exn - (call_prover ~handler:(Zkapps_calls.call_handler input)) + (call_prover + ~handler:(Zkapps_calls.call_handler input increase_amount) ) in ( Option.value_exn aux , { data = tree.party; hash = tree.party_digest } , tree.calls ) - | Recurse calls_kind -> + | Recurse (increase_amount, calls_kind) -> let tree, aux = Async.Thread_safe.block_on_async_exn (recursive_call_prover ~handler: (Zkapps_calls.recursive_call_handler input - (make_call calls_kind) ) ) + increase_amount (make_call calls_kind) ) ) in ( Option.value_exn aux , { data = tree.party; hash = tree.party_digest } @@ -248,9 +251,16 @@ let%test_module "Initialize state test" = Ledger.get ledger loc ) let%test_unit "Initialize and update nonrecursive" = + let increments = + Array.init 1 ~f:(fun _ -> Snark_params.Tick.Field.random ()) + in + let expected_result = + Array.reduce_exn ~f:Snark_params.Tick.Field.add increments + in let account = [] - |> Parties.Call_forest.cons_tree (Update_state_party.party Call) + |> Parties.Call_forest.cons_tree + (Update_state_party.party (Call increments.(0))) |> Parties.Call_forest.cons_tree Initialize_party.party |> Parties.Call_forest.cons Deploy_party.party |> test_parties @@ -258,16 +268,23 @@ let%test_module "Initialize state test" = let (first_state :: zkapp_state) = (Option.value_exn (Option.value_exn account).zkapp).app_state in - assert (Snark_params.Tick.Field.(equal one) first_state) ; + assert (Snark_params.Tick.Field.equal expected_result first_state) ; Pickles_types.Vector.iter ~f:(fun x -> assert (Snark_params.Tick.Field.(equal zero) x)) zkapp_state let%test_unit "Initialize and update single recursive" = + let increments = + Array.init 2 ~f:(fun _ -> Snark_params.Tick.Field.random ()) + in + let expected_result = + Array.reduce_exn ~f:Snark_params.Tick.Field.add increments + in let account = [] |> Parties.Call_forest.cons_tree - (Update_state_party.party (Recurse Call)) + (Update_state_party.party + (Recurse (increments.(0), Call increments.(1))) ) |> Parties.Call_forest.cons_tree Initialize_party.party |> Parties.Call_forest.cons Deploy_party.party |> test_parties @@ -275,16 +292,25 @@ let%test_module "Initialize state test" = let (first_state :: zkapp_state) = (Option.value_exn (Option.value_exn account).zkapp).app_state in - assert (Snark_params.Tick.Field.(equal one) first_state) ; + assert (Snark_params.Tick.Field.equal expected_result first_state) ; Pickles_types.Vector.iter ~f:(fun x -> assert (Snark_params.Tick.Field.(equal zero) x)) zkapp_state let%test_unit "Initialize and update double recursive" = + let increments = + Array.init 3 ~f:(fun _ -> Snark_params.Tick.Field.random ()) + in + let expected_result = + Array.reduce_exn ~f:Snark_params.Tick.Field.add increments + in let account = [] |> Parties.Call_forest.cons_tree - (Update_state_party.party (Recurse (Recurse Call))) + (Update_state_party.party + (Recurse + ( increments.(0) + , Recurse (increments.(1), Call increments.(2)) ) ) ) |> Parties.Call_forest.cons_tree Initialize_party.party |> Parties.Call_forest.cons Deploy_party.party |> test_parties @@ -292,16 +318,27 @@ let%test_module "Initialize state test" = let (first_state :: zkapp_state) = (Option.value_exn (Option.value_exn account).zkapp).app_state in - assert (Snark_params.Tick.Field.(equal one) first_state) ; + assert (Snark_params.Tick.Field.equal expected_result first_state) ; Pickles_types.Vector.iter ~f:(fun x -> assert (Snark_params.Tick.Field.(equal zero) x)) zkapp_state let%test_unit "Initialize and update triple recursive" = + let increments = + Array.init 4 ~f:(fun _ -> Snark_params.Tick.Field.random ()) + in + let expected_result = + Array.reduce_exn ~f:Snark_params.Tick.Field.add increments + in let account = [] |> Parties.Call_forest.cons_tree - (Update_state_party.party (Recurse (Recurse (Recurse Call)))) + (Update_state_party.party + (Recurse + ( increments.(0) + , Recurse + ( increments.(1) + , Recurse (increments.(2), Call increments.(3)) ) ) ) ) |> Parties.Call_forest.cons_tree Initialize_party.party |> Parties.Call_forest.cons Deploy_party.party |> test_parties @@ -309,7 +346,7 @@ let%test_module "Initialize state test" = let (first_state :: zkapp_state) = (Option.value_exn (Option.value_exn account).zkapp).app_state in - assert (Snark_params.Tick.Field.(equal one) first_state) ; + assert (Snark_params.Tick.Field.equal expected_result first_state) ; Pickles_types.Vector.iter ~f:(fun x -> assert (Snark_params.Tick.Field.(equal zero) x)) zkapp_state diff --git a/src/lib/zkapps_examples/calls/zkapps_calls.ml b/src/lib/zkapps_examples/calls/zkapps_calls.ml index 9349e55fb1d..c8a614a8d4f 100644 --- a/src/lib/zkapps_examples/calls/zkapps_calls.ml +++ b/src/lib/zkapps_examples/calls/zkapps_calls.ml @@ -100,6 +100,7 @@ type _ Snarky_backendless.Request.t += | (* TODO: Tweak pickles so this can be an explicit input. *) Get_call_input : Call_data.Input.Constant.t Snarky_backendless.Request.t + | Increase_amount : Field.Constant.t Snarky_backendless.Request.t | Execute_call : Call_data.Input.Constant.t -> ( Call_data.Output.Constant.t @@ -168,17 +169,18 @@ let update_state_call public_key = ~public_key:(Public_key.Compressed.var_of_t public_key) (fun party -> let old_state = exists Field.typ ~request:(fun () -> Old_state) in let new_state = execute_call party { old_state } in - ignore new_state ; - (* TODO *) party#assert_state_proved ; - party#set_state 0 old_state ; + party#set_state 0 new_state ; None ) let call_handler (call_input : Call_data.Input.Constant.t) + (increase_amount : Field.Constant.t) (Snarky_backendless.Request.With { request; respond }) = match request with | Get_call_input -> respond (Provide call_input) + | Increase_amount -> + respond (Provide increase_amount) | _ -> respond Unhandled @@ -189,8 +191,10 @@ let call public_key = exists Call_data.Input.typ ~request:(fun () -> Get_call_input) in let blinding_value = exists Field.typ ~compute:Field.Constant.random in - let modify_value = exists Field.typ ~compute:Field.Constant.random in - let new_state = Field.add input.old_state modify_value in + let increase_amount = + exists Field.typ ~request:(fun () -> Increase_amount) + in + let new_state = Field.add input.old_state increase_amount in let output = { Call_data.Output.Circuit.blinding_value; new_state } in let call_data_digest = Call_data.Circuit.digest { input; output } in party#assert_state_proved ; @@ -198,6 +202,7 @@ let call public_key = Some output ) let recursive_call_handler (recursive_call_input : Call_data.Input.Constant.t) + (increase_amount : Field.Constant.t) (execute_call : Call_data.Input.Constant.t -> Call_data.Output.Constant.t @@ -207,6 +212,8 @@ let recursive_call_handler (recursive_call_input : Call_data.Input.Constant.t) match request with | Get_call_input -> respond (Provide recursive_call_input) + | Increase_amount -> + respond (Provide increase_amount) | Execute_call input -> respond (Provide (execute_call input)) | _ -> @@ -220,8 +227,10 @@ let recursive_call public_key = in let new_state = execute_call party call_inputs in let blinding_value = exists Field.typ ~compute:Field.Constant.random in - let modify_value = exists Field.typ ~compute:Field.Constant.random in - let new_state = Field.add new_state modify_value in + let increase_amount = + exists Field.typ ~request:(fun () -> Increase_amount) + in + let new_state = Field.add new_state increase_amount in let call_outputs = { Call_data.Output.Circuit.blinding_value; new_state } in From 93bcb226e1669d760e1a4a05d0c2da2d1b4b1573 Mon Sep 17 00:00:00 2001 From: mrmr1993 Date: Mon, 8 Aug 2022 16:10:33 +0100 Subject: [PATCH 016/144] Tweak the interface of `execute_call` --- src/lib/zkapps_examples/calls/zkapps_calls.ml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/lib/zkapps_examples/calls/zkapps_calls.ml b/src/lib/zkapps_examples/calls/zkapps_calls.ml index c8a614a8d4f..877acb7aa47 100644 --- a/src/lib/zkapps_examples/calls/zkapps_calls.ml +++ b/src/lib/zkapps_examples/calls/zkapps_calls.ml @@ -109,7 +109,8 @@ type _ Snarky_backendless.Request.t += Snarky_backendless.Request.t (** Helper function for executing zkApp calls. *) -let execute_call party call_inputs = +let execute_call party old_state = + let call_inputs = { Call_data.Input.Circuit.old_state } in let call_outputs, called_party, sub_calls = exists (Typ.tuple3 Call_data.Output.typ @@ -168,7 +169,7 @@ let update_state_call public_key = Zkapps_examples.wrap_main ~public_key:(Public_key.Compressed.var_of_t public_key) (fun party -> let old_state = exists Field.typ ~request:(fun () -> Old_state) in - let new_state = execute_call party { old_state } in + let new_state = execute_call party old_state in party#assert_state_proved ; party#set_state 0 new_state ; None ) @@ -222,10 +223,10 @@ let recursive_call_handler (recursive_call_input : Call_data.Input.Constant.t) let recursive_call public_key = Zkapps_examples.wrap_main ~public_key:(Public_key.Compressed.var_of_t public_key) (fun party -> - let call_inputs = + let ({ Call_data.Input.Circuit.old_state } as call_inputs) = exists Call_data.Input.typ ~request:(fun () -> Get_call_input) in - let new_state = execute_call party call_inputs in + let new_state = execute_call party old_state in let blinding_value = exists Field.typ ~compute:Field.Constant.random in let increase_amount = exists Field.typ ~request:(fun () -> Increase_amount) From e0ac7ac0c394e3437f26c8e03b463921c8094a8a Mon Sep 17 00:00:00 2001 From: mrmr1993 Date: Mon, 8 Aug 2022 16:27:39 +0100 Subject: [PATCH 017/144] Rename some rules, add some more doc-comments --- .../test/zkapps_examples/calls/calls.ml | 41 +++++------ src/lib/zkapps_examples/calls/zkapps_calls.ml | 71 ++++++++++++++----- 2 files changed, 74 insertions(+), 38 deletions(-) diff --git a/src/lib/transaction_snark/test/zkapps_examples/calls/calls.ml b/src/lib/transaction_snark/test/zkapps_examples/calls/calls.ml index 61911266237..ed9fcc3f745 100644 --- a/src/lib/transaction_snark/test/zkapps_examples/calls/calls.ml +++ b/src/lib/transaction_snark/test/zkapps_examples/calls/calls.ml @@ -62,8 +62,8 @@ let%test_module "Initialize state test" = , Pickles.Provers. [ initialize_prover ; update_state_call_prover - ; call_prover - ; recursive_call_prover + ; add_prover + ; add_and_call_prover ] ) = Zkapps_examples.compile () ~cache:Cache_dir.cache ~auxiliary_typ:(option_typ Zkapps_calls.Call_data.Output.typ) @@ -76,13 +76,13 @@ let%test_module "Initialize state test" = ~choices:(fun ~self:_ -> [ Zkapps_calls.initialize_rule pk_compressed ; Zkapps_calls.update_state_call_rule pk_compressed - ; Zkapps_calls.call_rule pk_compressed - ; Zkapps_calls.recursive_call_rule pk_compressed + ; Zkapps_calls.add_rule pk_compressed + ; Zkapps_calls.add_and_call_rule pk_compressed ] ) type calls_kind = - | Recurse of Snark_params.Tick.Run.Field.Constant.t * calls_kind - | Call of Snark_params.Tick.Run.Field.Constant.t + | Add_and_call of Snark_params.Tick.Run.Field.Constant.t * calls_kind + | Add of Snark_params.Tick.Run.Field.Constant.t module P = (val p_module) @@ -144,22 +144,22 @@ let%test_module "Initialize state test" = * Zkapp_call_forest.party * Zkapp_call_forest.t = match calls_kind with - | Call increase_amount -> + | Add increase_amount -> let tree, aux = Async.Thread_safe.block_on_async_exn - (call_prover - ~handler:(Zkapps_calls.call_handler input increase_amount) ) + (add_prover + ~handler:(Zkapps_calls.add_handler input increase_amount) ) in ( Option.value_exn aux , { data = tree.party; hash = tree.party_digest } , tree.calls ) - | Recurse (increase_amount, calls_kind) -> + | Add_and_call (increase_amount, calls_kind) -> let tree, aux = Async.Thread_safe.block_on_async_exn - (recursive_call_prover + (add_and_call_prover ~handler: - (Zkapps_calls.recursive_call_handler input - increase_amount (make_call calls_kind) ) ) + (Zkapps_calls.add_and_call_handler input increase_amount + (make_call calls_kind) ) ) in ( Option.value_exn aux , { data = tree.party; hash = tree.party_digest } @@ -260,7 +260,7 @@ let%test_module "Initialize state test" = let account = [] |> Parties.Call_forest.cons_tree - (Update_state_party.party (Call increments.(0))) + (Update_state_party.party (Add increments.(0))) |> Parties.Call_forest.cons_tree Initialize_party.party |> Parties.Call_forest.cons Deploy_party.party |> test_parties @@ -284,7 +284,7 @@ let%test_module "Initialize state test" = [] |> Parties.Call_forest.cons_tree (Update_state_party.party - (Recurse (increments.(0), Call increments.(1))) ) + (Add_and_call (increments.(0), Add increments.(1))) ) |> Parties.Call_forest.cons_tree Initialize_party.party |> Parties.Call_forest.cons Deploy_party.party |> test_parties @@ -308,9 +308,9 @@ let%test_module "Initialize state test" = [] |> Parties.Call_forest.cons_tree (Update_state_party.party - (Recurse + (Add_and_call ( increments.(0) - , Recurse (increments.(1), Call increments.(2)) ) ) ) + , Add_and_call (increments.(1), Add increments.(2)) ) ) ) |> Parties.Call_forest.cons_tree Initialize_party.party |> Parties.Call_forest.cons Deploy_party.party |> test_parties @@ -334,11 +334,12 @@ let%test_module "Initialize state test" = [] |> Parties.Call_forest.cons_tree (Update_state_party.party - (Recurse + (Add_and_call ( increments.(0) - , Recurse + , Add_and_call ( increments.(1) - , Recurse (increments.(2), Call increments.(3)) ) ) ) ) + , Add_and_call (increments.(2), Add increments.(3)) ) ) + ) ) |> Parties.Call_forest.cons_tree Initialize_party.party |> Parties.Call_forest.cons Deploy_party.party |> test_parties diff --git a/src/lib/zkapps_examples/calls/zkapps_calls.ml b/src/lib/zkapps_examples/calls/zkapps_calls.ml index 877acb7aa47..9ea0650e5b2 100644 --- a/src/lib/zkapps_examples/calls/zkapps_calls.ml +++ b/src/lib/zkapps_examples/calls/zkapps_calls.ml @@ -165,6 +165,15 @@ let update_state_handler (old_state : Field.Constant.t) | _ -> respond Unhandled +(** Rule to update the zkApp state. + + Asserts that the state was last updated by a proof (ie. that the zkApp has + been correctly initialized, and all subsequent updates have been via proof + executions). + + This calls into another zkApp method whose shape matches [Call_data], and + uses the output value as the new state. +*) let update_state_call public_key = Zkapps_examples.wrap_main ~public_key:(Public_key.Compressed.var_of_t public_key) (fun party -> @@ -174,7 +183,7 @@ let update_state_call public_key = party#set_state 0 new_state ; None ) -let call_handler (call_input : Call_data.Input.Constant.t) +let add_handler (call_input : Call_data.Input.Constant.t) (increase_amount : Field.Constant.t) (Snarky_backendless.Request.With { request; respond }) = match request with @@ -185,7 +194,21 @@ let call_handler (call_input : Call_data.Input.Constant.t) | _ -> respond Unhandled -let call public_key = +(** Callable zkApp addition rule. + + Takes the input from the call data, increases it by a number determined by + the prover (via the [Increase_amount] request), and constructs the call + data +{[ + { input = { old_state } + ; output = + { blinding_value = random () ; new_state = old_state + increase_amount } } +]} + + This also returns the [output] part of the call data to the prover, so that + it can be passed to the calling zkApp execution. +*) +let add public_key = Zkapps_examples.wrap_main ~public_key:(Public_key.Compressed.var_of_t public_key) (fun party -> let input = @@ -198,11 +221,10 @@ let call public_key = let new_state = Field.add input.old_state increase_amount in let output = { Call_data.Output.Circuit.blinding_value; new_state } in let call_data_digest = Call_data.Circuit.digest { input; output } in - party#assert_state_proved ; party#set_call_data call_data_digest ; Some output ) -let recursive_call_handler (recursive_call_input : Call_data.Input.Constant.t) +let add_and_call_handler (add_and_call_input : Call_data.Input.Constant.t) (increase_amount : Field.Constant.t) (execute_call : Call_data.Input.Constant.t @@ -212,7 +234,7 @@ let recursive_call_handler (recursive_call_input : Call_data.Input.Constant.t) (Snarky_backendless.Request.With { request; respond }) = match request with | Get_call_input -> - respond (Provide recursive_call_input) + respond (Provide add_and_call_input) | Increase_amount -> respond (Provide increase_amount) | Execute_call input -> @@ -220,25 +242,42 @@ let recursive_call_handler (recursive_call_input : Call_data.Input.Constant.t) | _ -> respond Unhandled -let recursive_call public_key = +(** Callable zkApp addition-and-call rule. + + Takes the input from the call data, and uses it to call into another zkApp + method whose shape matches [Call_data]. + The output value of this sub-call is used as the intermediate state, which + is then increased by a number determined by the prover (via the + [Increase_amount] request). + The return value is exposed to the caller by constructing the call data +{[ + { input = { old_state } + ; output = + { blinding_value = random () + ; new_state = intermediate_state + increase_amount } } +]} + + This also returns the [output] part of the call data to the prover, so that + it can be passed to the calling zkApp execution. +*) +let add_and_call public_key = Zkapps_examples.wrap_main ~public_key:(Public_key.Compressed.var_of_t public_key) (fun party -> let ({ Call_data.Input.Circuit.old_state } as call_inputs) = exists Call_data.Input.typ ~request:(fun () -> Get_call_input) in - let new_state = execute_call party old_state in + let intermediate_state = execute_call party old_state in let blinding_value = exists Field.typ ~compute:Field.Constant.random in let increase_amount = exists Field.typ ~request:(fun () -> Increase_amount) in - let new_state = Field.add new_state increase_amount in + let new_state = Field.add intermediate_state increase_amount in let call_outputs = { Call_data.Output.Circuit.blinding_value; new_state } in let call_data_hash = Call_data.Circuit.digest { input = call_inputs; output = call_outputs } in - party#assert_state_proved ; party#set_call_data call_data_hash ; Some call_outputs ) @@ -256,16 +295,12 @@ let update_state_call_rule public_key : _ Pickles.Inductive_rule.t = ; uses_lookup = false } -let call_rule public_key : _ Pickles.Inductive_rule.t = - { identifier = "Call" - ; prevs = [] - ; main = call public_key - ; uses_lookup = false - } +let add_rule public_key : _ Pickles.Inductive_rule.t = + { identifier = "Add"; prevs = []; main = add public_key; uses_lookup = false } -let recursive_call_rule public_key : _ Pickles.Inductive_rule.t = - { identifier = "Recursive call" +let add_and_call_rule public_key : _ Pickles.Inductive_rule.t = + { identifier = "Add-and-call call" ; prevs = [] - ; main = recursive_call public_key + ; main = add_and_call public_key ; uses_lookup = false } From 2bc47c7f9ce87d1a18186260c5e32af565203b68 Mon Sep 17 00:00:00 2001 From: mrmr1993 Date: Mon, 8 Aug 2022 16:31:07 +0100 Subject: [PATCH 018/144] Tweak the behaviour of add_and_call to make it clearer --- src/lib/zkapps_examples/calls/zkapps_calls.ml | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/lib/zkapps_examples/calls/zkapps_calls.ml b/src/lib/zkapps_examples/calls/zkapps_calls.ml index 9ea0650e5b2..c84e110163a 100644 --- a/src/lib/zkapps_examples/calls/zkapps_calls.ml +++ b/src/lib/zkapps_examples/calls/zkapps_calls.ml @@ -244,17 +244,15 @@ let add_and_call_handler (add_and_call_input : Call_data.Input.Constant.t) (** Callable zkApp addition-and-call rule. - Takes the input from the call data, and uses it to call into another zkApp - method whose shape matches [Call_data]. - The output value of this sub-call is used as the intermediate state, which - is then increased by a number determined by the prover (via the - [Increase_amount] request). + Takes the input from the call data, increases it by a number determined by + the prover (via the [Increase_amount] request), passes the result as the + input to another zkApp call method whose shape matches [Call_data]. The return value is exposed to the caller by constructing the call data {[ { input = { old_state } ; output = { blinding_value = random () - ; new_state = intermediate_state + increase_amount } } + ; new_state = call_other_zkapp(old_state + increase_amount) } } ]} This also returns the [output] part of the call data to the prover, so that @@ -266,12 +264,12 @@ let add_and_call public_key = let ({ Call_data.Input.Circuit.old_state } as call_inputs) = exists Call_data.Input.typ ~request:(fun () -> Get_call_input) in - let intermediate_state = execute_call party old_state in let blinding_value = exists Field.typ ~compute:Field.Constant.random in let increase_amount = exists Field.typ ~request:(fun () -> Increase_amount) in - let new_state = Field.add intermediate_state increase_amount in + let intermediate_state = Field.add old_state increase_amount in + let new_state = execute_call party intermediate_state in let call_outputs = { Call_data.Output.Circuit.blinding_value; new_state } in From 993be022f88504d0f4b9ce5b3ee788abdfab86af Mon Sep 17 00:00:00 2001 From: mrmr1993 Date: Mon, 8 Aug 2022 16:38:31 +0100 Subject: [PATCH 019/144] Stop hard-coding the public key --- .../test/zkapps_examples/calls/calls.ml | 26 +++--- src/lib/zkapps_examples/calls/zkapps_calls.ml | 80 +++++++++++++------ 2 files changed, 73 insertions(+), 33 deletions(-) diff --git a/src/lib/transaction_snark/test/zkapps_examples/calls/calls.ml b/src/lib/transaction_snark/test/zkapps_examples/calls/calls.ml index ed9fcc3f745..82563c75933 100644 --- a/src/lib/transaction_snark/test/zkapps_examples/calls/calls.ml +++ b/src/lib/transaction_snark/test/zkapps_examples/calls/calls.ml @@ -9,7 +9,7 @@ module Local_state = Mina_state.Local_state module Parties_segment = Transaction_snark.Parties_segment module Statement = Transaction_snark.Statement -let%test_module "Initialize state test" = +let%test_module "Composability test" = ( module struct let () = Base.Backtrace.elide := false @@ -74,10 +74,10 @@ let%test_module "Initialize state test" = (Genesis_constants.Constraint_constants.to_snark_keys_header constraint_constants ) ~choices:(fun ~self:_ -> - [ Zkapps_calls.initialize_rule pk_compressed - ; Zkapps_calls.update_state_call_rule pk_compressed - ; Zkapps_calls.add_rule pk_compressed - ; Zkapps_calls.add_and_call_rule pk_compressed + [ Zkapps_calls.initialize_rule + ; Zkapps_calls.update_state_call_rule + ; Zkapps_calls.add_rule + ; Zkapps_calls.add_and_call_rule ] ) type calls_kind = @@ -132,7 +132,10 @@ let%test_module "Initialize state test" = end module Initialize_party = struct - let party, _ = Async.Thread_safe.block_on_async_exn initialize_prover + let party, _ = + Async.Thread_safe.block_on_async_exn + (initialize_prover + ~handler:(Zkapps_calls.initialize_state_handler pk_compressed) ) end module Update_state_party = struct @@ -148,7 +151,9 @@ let%test_module "Initialize state test" = let tree, aux = Async.Thread_safe.block_on_async_exn (add_prover - ~handler:(Zkapps_calls.add_handler input increase_amount) ) + ~handler: + (Zkapps_calls.add_handler pk_compressed input + increase_amount ) ) in ( Option.value_exn aux , { data = tree.party; hash = tree.party_digest } @@ -158,14 +163,15 @@ let%test_module "Initialize state test" = Async.Thread_safe.block_on_async_exn (add_and_call_prover ~handler: - (Zkapps_calls.add_and_call_handler input increase_amount - (make_call calls_kind) ) ) + (Zkapps_calls.add_and_call_handler pk_compressed input + increase_amount (make_call calls_kind) ) ) in ( Option.value_exn aux , { data = tree.party; hash = tree.party_digest } , tree.calls ) in - Zkapps_calls.update_state_handler old_state (make_call calls_kind) + Zkapps_calls.update_state_handler pk_compressed old_state + (make_call calls_kind) let party calls_kind = Async.Thread_safe.block_on_async_exn diff --git a/src/lib/zkapps_examples/calls/zkapps_calls.ml b/src/lib/zkapps_examples/calls/zkapps_calls.ml index c84e110163a..07675ff511a 100644 --- a/src/lib/zkapps_examples/calls/zkapps_calls.ml +++ b/src/lib/zkapps_examples/calls/zkapps_calls.ml @@ -96,6 +96,7 @@ end (** Circuit requests, to get values and run code outside of the snark. *) type _ Snarky_backendless.Request.t += + | Public_key : Public_key.Compressed.t Snarky_backendless.Request.t | Old_state : Field.Constant.t Snarky_backendless.Request.t | (* TODO: Tweak pickles so this can be an explicit input. *) Get_call_input : @@ -133,6 +134,14 @@ let execute_call party old_state = (** State to initialize the zkApp to after deployment. *) let initial_state = lazy (List.init 8 ~f:(fun _ -> Field.Constant.zero)) +let initialize_state_handler (public_key : Public_key.Compressed.t) + (Snarky_backendless.Request.With { request; respond }) = + match request with + | Public_key -> + respond (Provide public_key) + | _ -> + respond Unhandled + (** Rule to initialize the zkApp. Asserts that the state was not last updated by a proof (ie. the zkApp is @@ -140,17 +149,22 @@ let initial_state = lazy (List.init 8 ~f:(fun _ -> Field.Constant.zero)) without using a proof). The app state is set to the initial state. *) -let initialize public_key = - Zkapps_examples.wrap_main - ~public_key:(Public_key.Compressed.var_of_t public_key) (fun party -> +let initialize input = + let public_key = + exists Public_key.Compressed.typ ~request:(fun () -> Public_key) + in + Zkapps_examples.wrap_main ~public_key + (fun party -> let initial_state = List.map ~f:Field.constant (Lazy.force initial_state) in party#assert_state_unproved ; party#set_full_state initial_state ; None ) + input -let update_state_handler (old_state : Field.Constant.t) +let update_state_handler (public_key : Public_key.Compressed.t) + (old_state : Field.Constant.t) (execute_call : Call_data.Input.Constant.t -> Call_data.Output.Constant.t @@ -158,6 +172,8 @@ let update_state_handler (old_state : Field.Constant.t) * Zkapp_call_forest.t ) (Snarky_backendless.Request.With { request; respond }) = match request with + | Public_key -> + respond (Provide public_key) | Old_state -> respond (Provide old_state) | Execute_call input -> @@ -174,19 +190,26 @@ let update_state_handler (old_state : Field.Constant.t) This calls into another zkApp method whose shape matches [Call_data], and uses the output value as the new state. *) -let update_state_call public_key = - Zkapps_examples.wrap_main - ~public_key:(Public_key.Compressed.var_of_t public_key) (fun party -> +let update_state_call input = + let public_key = + exists Public_key.Compressed.typ ~request:(fun () -> Public_key) + in + Zkapps_examples.wrap_main ~public_key + (fun party -> let old_state = exists Field.typ ~request:(fun () -> Old_state) in let new_state = execute_call party old_state in party#assert_state_proved ; party#set_state 0 new_state ; None ) + input -let add_handler (call_input : Call_data.Input.Constant.t) +let add_handler (public_key : Public_key.Compressed.t) + (call_input : Call_data.Input.Constant.t) (increase_amount : Field.Constant.t) (Snarky_backendless.Request.With { request; respond }) = match request with + | Public_key -> + respond (Provide public_key) | Get_call_input -> respond (Provide call_input) | Increase_amount -> @@ -208,9 +231,12 @@ let add_handler (call_input : Call_data.Input.Constant.t) This also returns the [output] part of the call data to the prover, so that it can be passed to the calling zkApp execution. *) -let add public_key = - Zkapps_examples.wrap_main - ~public_key:(Public_key.Compressed.var_of_t public_key) (fun party -> +let add input = + let public_key = + exists Public_key.Compressed.typ ~request:(fun () -> Public_key) + in + Zkapps_examples.wrap_main ~public_key + (fun party -> let input = exists Call_data.Input.typ ~request:(fun () -> Get_call_input) in @@ -223,8 +249,10 @@ let add public_key = let call_data_digest = Call_data.Circuit.digest { input; output } in party#set_call_data call_data_digest ; Some output ) + input -let add_and_call_handler (add_and_call_input : Call_data.Input.Constant.t) +let add_and_call_handler (public_key : Public_key.Compressed.t) + (add_and_call_input : Call_data.Input.Constant.t) (increase_amount : Field.Constant.t) (execute_call : Call_data.Input.Constant.t @@ -233,6 +261,8 @@ let add_and_call_handler (add_and_call_input : Call_data.Input.Constant.t) * Zkapp_call_forest.t ) (Snarky_backendless.Request.With { request; respond }) = match request with + | Public_key -> + respond (Provide public_key) | Get_call_input -> respond (Provide add_and_call_input) | Increase_amount -> @@ -258,9 +288,12 @@ let add_and_call_handler (add_and_call_input : Call_data.Input.Constant.t) This also returns the [output] part of the call data to the prover, so that it can be passed to the calling zkApp execution. *) -let add_and_call public_key = - Zkapps_examples.wrap_main - ~public_key:(Public_key.Compressed.var_of_t public_key) (fun party -> +let add_and_call input = + let public_key = + exists Public_key.Compressed.typ ~request:(fun () -> Public_key) + in + Zkapps_examples.wrap_main ~public_key + (fun party -> let ({ Call_data.Input.Circuit.old_state } as call_inputs) = exists Call_data.Input.typ ~request:(fun () -> Get_call_input) in @@ -278,27 +311,28 @@ let add_and_call public_key = in party#set_call_data call_data_hash ; Some call_outputs ) + input -let initialize_rule public_key : _ Pickles.Inductive_rule.t = +let initialize_rule : _ Pickles.Inductive_rule.t = { identifier = "Initialize snapp" ; prevs = [] - ; main = initialize public_key + ; main = initialize ; uses_lookup = false } -let update_state_call_rule public_key : _ Pickles.Inductive_rule.t = +let update_state_call_rule : _ Pickles.Inductive_rule.t = { identifier = "Update state call" ; prevs = [] - ; main = update_state_call public_key + ; main = update_state_call ; uses_lookup = false } -let add_rule public_key : _ Pickles.Inductive_rule.t = - { identifier = "Add"; prevs = []; main = add public_key; uses_lookup = false } +let add_rule : _ Pickles.Inductive_rule.t = + { identifier = "Add"; prevs = []; main = add; uses_lookup = false } -let add_and_call_rule public_key : _ Pickles.Inductive_rule.t = +let add_and_call_rule : _ Pickles.Inductive_rule.t = { identifier = "Add-and-call call" ; prevs = [] - ; main = add_and_call public_key + ; main = add_and_call ; uses_lookup = false } From 30010b914657196c75138630c31a5b746647c00e Mon Sep 17 00:00:00 2001 From: mrmr1993 Date: Mon, 8 Aug 2022 16:40:40 +0100 Subject: [PATCH 020/144] Make description more explicit --- src/lib/zkapps_examples/calls/zkapps_calls.ml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/lib/zkapps_examples/calls/zkapps_calls.ml b/src/lib/zkapps_examples/calls/zkapps_calls.ml index 07675ff511a..fa2005d9c5c 100644 --- a/src/lib/zkapps_examples/calls/zkapps_calls.ml +++ b/src/lib/zkapps_examples/calls/zkapps_calls.ml @@ -109,7 +109,11 @@ type _ Snarky_backendless.Request.t += * Zkapp_call_forest.t ) Snarky_backendless.Request.t -(** Helper function for executing zkApp calls. *) +(** Helper function for executing zkApp calls. + + The particular details of the called party are determined by the handler + for the [Execute_call] request. +*) let execute_call party old_state = let call_inputs = { Call_data.Input.Circuit.old_state } in let call_outputs, called_party, sub_calls = From 54de03114e1d9d77bcb3eadba3dcd25ce0c2f0b7 Mon Sep 17 00:00:00 2001 From: mrmr1993 Date: Mon, 8 Aug 2022 16:50:13 +0100 Subject: [PATCH 021/144] Restructure rules as modules --- .../test/zkapps_examples/calls/calls.ml | 19 +- src/lib/zkapps_examples/calls/zkapps_calls.ml | 386 +++++++++--------- 2 files changed, 207 insertions(+), 198 deletions(-) diff --git a/src/lib/transaction_snark/test/zkapps_examples/calls/calls.ml b/src/lib/transaction_snark/test/zkapps_examples/calls/calls.ml index 82563c75933..db188106b82 100644 --- a/src/lib/transaction_snark/test/zkapps_examples/calls/calls.ml +++ b/src/lib/transaction_snark/test/zkapps_examples/calls/calls.ml @@ -74,10 +74,10 @@ let%test_module "Composability test" = (Genesis_constants.Constraint_constants.to_snark_keys_header constraint_constants ) ~choices:(fun ~self:_ -> - [ Zkapps_calls.initialize_rule - ; Zkapps_calls.update_state_call_rule - ; Zkapps_calls.add_rule - ; Zkapps_calls.add_and_call_rule + [ Zkapps_calls.Rules.Initialize_state.rule + ; Zkapps_calls.Rules.Update_state.rule + ; Zkapps_calls.Rules.Add.rule + ; Zkapps_calls.Rules.Add_and_call.rule ] ) type calls_kind = @@ -135,7 +135,8 @@ let%test_module "Composability test" = let party, _ = Async.Thread_safe.block_on_async_exn (initialize_prover - ~handler:(Zkapps_calls.initialize_state_handler pk_compressed) ) + ~handler: + (Zkapps_calls.Rules.Initialize_state.handler pk_compressed) ) end module Update_state_party = struct @@ -152,7 +153,7 @@ let%test_module "Composability test" = Async.Thread_safe.block_on_async_exn (add_prover ~handler: - (Zkapps_calls.add_handler pk_compressed input + (Zkapps_calls.Rules.Add.handler pk_compressed input increase_amount ) ) in ( Option.value_exn aux @@ -163,14 +164,14 @@ let%test_module "Composability test" = Async.Thread_safe.block_on_async_exn (add_and_call_prover ~handler: - (Zkapps_calls.add_and_call_handler pk_compressed input - increase_amount (make_call calls_kind) ) ) + (Zkapps_calls.Rules.Add_and_call.handler pk_compressed + input increase_amount (make_call calls_kind) ) ) in ( Option.value_exn aux , { data = tree.party; hash = tree.party_digest } , tree.calls ) in - Zkapps_calls.update_state_handler pk_compressed old_state + Zkapps_calls.Rules.Update_state.handler pk_compressed old_state (make_call calls_kind) let party calls_kind = diff --git a/src/lib/zkapps_examples/calls/zkapps_calls.ml b/src/lib/zkapps_examples/calls/zkapps_calls.ml index fa2005d9c5c..80ea011aaba 100644 --- a/src/lib/zkapps_examples/calls/zkapps_calls.ml +++ b/src/lib/zkapps_examples/calls/zkapps_calls.ml @@ -135,153 +135,151 @@ let execute_call party old_state = party#register_call called_party sub_calls ; call_outputs.new_state -(** State to initialize the zkApp to after deployment. *) -let initial_state = lazy (List.init 8 ~f:(fun _ -> Field.Constant.zero)) - -let initialize_state_handler (public_key : Public_key.Compressed.t) - (Snarky_backendless.Request.With { request; respond }) = - match request with - | Public_key -> - respond (Provide public_key) - | _ -> - respond Unhandled - -(** Rule to initialize the zkApp. - - Asserts that the state was not last updated by a proof (ie. the zkApp is - freshly deployed, or that the state was modified -- tampered with -- - without using a proof). - The app state is set to the initial state. -*) -let initialize input = - let public_key = - exists Public_key.Compressed.typ ~request:(fun () -> Public_key) - in - Zkapps_examples.wrap_main ~public_key - (fun party -> - let initial_state = - List.map ~f:Field.constant (Lazy.force initial_state) +module Rules = struct + (** Rule to initialize the zkApp. + + Asserts that the state was not last updated by a proof (ie. the zkApp is + freshly deployed, or that the state was modified -- tampered with -- + without using a proof). + The app state is set to the initial state. + *) + module Initialize_state = struct + (** State to initialize the zkApp to after deployment. *) + let initial_state = lazy (List.init 8 ~f:(fun _ -> Field.Constant.zero)) + + let handler (public_key : Public_key.Compressed.t) + (Snarky_backendless.Request.With { request; respond }) = + match request with + | Public_key -> + respond (Provide public_key) + | _ -> + respond Unhandled + + let main input = + let public_key = + exists Public_key.Compressed.typ ~request:(fun () -> Public_key) in - party#assert_state_unproved ; - party#set_full_state initial_state ; - None ) - input - -let update_state_handler (public_key : Public_key.Compressed.t) - (old_state : Field.Constant.t) - (execute_call : - Call_data.Input.Constant.t - -> Call_data.Output.Constant.t - * Zkapp_call_forest.party - * Zkapp_call_forest.t ) - (Snarky_backendless.Request.With { request; respond }) = - match request with - | Public_key -> - respond (Provide public_key) - | Old_state -> - respond (Provide old_state) - | Execute_call input -> - respond (Provide (execute_call input)) - | _ -> - respond Unhandled - -(** Rule to update the zkApp state. - - Asserts that the state was last updated by a proof (ie. that the zkApp has - been correctly initialized, and all subsequent updates have been via proof - executions). - - This calls into another zkApp method whose shape matches [Call_data], and - uses the output value as the new state. -*) -let update_state_call input = - let public_key = - exists Public_key.Compressed.typ ~request:(fun () -> Public_key) - in - Zkapps_examples.wrap_main ~public_key - (fun party -> - let old_state = exists Field.typ ~request:(fun () -> Old_state) in - let new_state = execute_call party old_state in - party#assert_state_proved ; - party#set_state 0 new_state ; - None ) - input - -let add_handler (public_key : Public_key.Compressed.t) - (call_input : Call_data.Input.Constant.t) - (increase_amount : Field.Constant.t) - (Snarky_backendless.Request.With { request; respond }) = - match request with - | Public_key -> - respond (Provide public_key) - | Get_call_input -> - respond (Provide call_input) - | Increase_amount -> - respond (Provide increase_amount) - | _ -> - respond Unhandled - -(** Callable zkApp addition rule. - - Takes the input from the call data, increases it by a number determined by - the prover (via the [Increase_amount] request), and constructs the call - data + Zkapps_examples.wrap_main ~public_key + (fun party -> + let initial_state = + List.map ~f:Field.constant (Lazy.force initial_state) + in + party#assert_state_unproved ; + party#set_full_state initial_state ; + None ) + input + + let rule : _ Pickles.Inductive_rule.t = + { identifier = "Initialize snapp"; prevs = []; main; uses_lookup = false } + end + + (** Rule to update the zkApp state. + + Asserts that the state was last updated by a proof (ie. that the zkApp + has been correctly initialized, and all subsequent updates have been via + proof executions). + + This calls into another zkApp method whose shape matches [Call_data], and + uses the output value as the new state. + *) + module Update_state = struct + let handler (public_key : Public_key.Compressed.t) + (old_state : Field.Constant.t) + (execute_call : + Call_data.Input.Constant.t + -> Call_data.Output.Constant.t + * Zkapp_call_forest.party + * Zkapp_call_forest.t ) + (Snarky_backendless.Request.With { request; respond }) = + match request with + | Public_key -> + respond (Provide public_key) + | Old_state -> + respond (Provide old_state) + | Execute_call input -> + respond (Provide (execute_call input)) + | _ -> + respond Unhandled + + let main input = + let public_key = + exists Public_key.Compressed.typ ~request:(fun () -> Public_key) + in + Zkapps_examples.wrap_main ~public_key + (fun party -> + let old_state = exists Field.typ ~request:(fun () -> Old_state) in + let new_state = execute_call party old_state in + party#assert_state_proved ; + party#set_state 0 new_state ; + None ) + input + + let rule : _ Pickles.Inductive_rule.t = + { identifier = "Update state"; prevs = []; main; uses_lookup = false } + end + + (** Callable zkApp addition rule. + + Takes the input from the call data, increases it by a number determined + by the prover (via the [Increase_amount] request), and constructs the + call data {[ { input = { old_state } ; output = { blinding_value = random () ; new_state = old_state + increase_amount } } ]} - This also returns the [output] part of the call data to the prover, so that - it can be passed to the calling zkApp execution. -*) -let add input = - let public_key = - exists Public_key.Compressed.typ ~request:(fun () -> Public_key) - in - Zkapps_examples.wrap_main ~public_key - (fun party -> - let input = - exists Call_data.Input.typ ~request:(fun () -> Get_call_input) - in - let blinding_value = exists Field.typ ~compute:Field.Constant.random in - let increase_amount = - exists Field.typ ~request:(fun () -> Increase_amount) + This also returns the [output] part of the call data to the prover, so + that it can be passed to the calling zkApp execution. + *) + module Add = struct + let handler (public_key : Public_key.Compressed.t) + (call_input : Call_data.Input.Constant.t) + (increase_amount : Field.Constant.t) + (Snarky_backendless.Request.With { request; respond }) = + match request with + | Public_key -> + respond (Provide public_key) + | Get_call_input -> + respond (Provide call_input) + | Increase_amount -> + respond (Provide increase_amount) + | _ -> + respond Unhandled + + let main input = + let public_key = + exists Public_key.Compressed.typ ~request:(fun () -> Public_key) in - let new_state = Field.add input.old_state increase_amount in - let output = { Call_data.Output.Circuit.blinding_value; new_state } in - let call_data_digest = Call_data.Circuit.digest { input; output } in - party#set_call_data call_data_digest ; - Some output ) - input - -let add_and_call_handler (public_key : Public_key.Compressed.t) - (add_and_call_input : Call_data.Input.Constant.t) - (increase_amount : Field.Constant.t) - (execute_call : - Call_data.Input.Constant.t - -> Call_data.Output.Constant.t - * Zkapp_call_forest.party - * Zkapp_call_forest.t ) - (Snarky_backendless.Request.With { request; respond }) = - match request with - | Public_key -> - respond (Provide public_key) - | Get_call_input -> - respond (Provide add_and_call_input) - | Increase_amount -> - respond (Provide increase_amount) - | Execute_call input -> - respond (Provide (execute_call input)) - | _ -> - respond Unhandled - -(** Callable zkApp addition-and-call rule. - - Takes the input from the call data, increases it by a number determined by - the prover (via the [Increase_amount] request), passes the result as the - input to another zkApp call method whose shape matches [Call_data]. - The return value is exposed to the caller by constructing the call data + Zkapps_examples.wrap_main ~public_key + (fun party -> + let input = + exists Call_data.Input.typ ~request:(fun () -> Get_call_input) + in + let blinding_value = + exists Field.typ ~compute:Field.Constant.random + in + let increase_amount = + exists Field.typ ~request:(fun () -> Increase_amount) + in + let new_state = Field.add input.old_state increase_amount in + let output = { Call_data.Output.Circuit.blinding_value; new_state } in + let call_data_digest = Call_data.Circuit.digest { input; output } in + party#set_call_data call_data_digest ; + Some output ) + input + + let rule : _ Pickles.Inductive_rule.t = + { identifier = "Add method"; prevs = []; main; uses_lookup = false } + end + + (** Callable zkApp addition-and-call rule. + + Takes the input from the call data, increases it by a number determined + by the prover (via the [Increase_amount] request), and passes the result + as the input to another zkApp call method whose shape matches + [Call_data]. + The return value is exposed to the caller by constructing the call data {[ { input = { old_state } ; output = @@ -289,54 +287,64 @@ let add_and_call_handler (public_key : Public_key.Compressed.t) ; new_state = call_other_zkapp(old_state + increase_amount) } } ]} - This also returns the [output] part of the call data to the prover, so that - it can be passed to the calling zkApp execution. -*) -let add_and_call input = - let public_key = - exists Public_key.Compressed.typ ~request:(fun () -> Public_key) - in - Zkapps_examples.wrap_main ~public_key - (fun party -> - let ({ Call_data.Input.Circuit.old_state } as call_inputs) = - exists Call_data.Input.typ ~request:(fun () -> Get_call_input) - in - let blinding_value = exists Field.typ ~compute:Field.Constant.random in - let increase_amount = - exists Field.typ ~request:(fun () -> Increase_amount) - in - let intermediate_state = Field.add old_state increase_amount in - let new_state = execute_call party intermediate_state in - let call_outputs = - { Call_data.Output.Circuit.blinding_value; new_state } - in - let call_data_hash = - Call_data.Circuit.digest { input = call_inputs; output = call_outputs } + This also returns the [output] part of the call data to the prover, so + that it can be passed to the calling zkApp execution. + *) + module Add_and_call = struct + let handler (public_key : Public_key.Compressed.t) + (add_and_call_input : Call_data.Input.Constant.t) + (increase_amount : Field.Constant.t) + (execute_call : + Call_data.Input.Constant.t + -> Call_data.Output.Constant.t + * Zkapp_call_forest.party + * Zkapp_call_forest.t ) + (Snarky_backendless.Request.With { request; respond }) = + match request with + | Public_key -> + respond (Provide public_key) + | Get_call_input -> + respond (Provide add_and_call_input) + | Increase_amount -> + respond (Provide increase_amount) + | Execute_call input -> + respond (Provide (execute_call input)) + | _ -> + respond Unhandled + + let main input = + let public_key = + exists Public_key.Compressed.typ ~request:(fun () -> Public_key) in - party#set_call_data call_data_hash ; - Some call_outputs ) - input - -let initialize_rule : _ Pickles.Inductive_rule.t = - { identifier = "Initialize snapp" - ; prevs = [] - ; main = initialize - ; uses_lookup = false - } - -let update_state_call_rule : _ Pickles.Inductive_rule.t = - { identifier = "Update state call" - ; prevs = [] - ; main = update_state_call - ; uses_lookup = false - } - -let add_rule : _ Pickles.Inductive_rule.t = - { identifier = "Add"; prevs = []; main = add; uses_lookup = false } - -let add_and_call_rule : _ Pickles.Inductive_rule.t = - { identifier = "Add-and-call call" - ; prevs = [] - ; main = add_and_call - ; uses_lookup = false - } + Zkapps_examples.wrap_main ~public_key + (fun party -> + let ({ Call_data.Input.Circuit.old_state } as call_inputs) = + exists Call_data.Input.typ ~request:(fun () -> Get_call_input) + in + let blinding_value = + exists Field.typ ~compute:Field.Constant.random + in + let increase_amount = + exists Field.typ ~request:(fun () -> Increase_amount) + in + let intermediate_state = Field.add old_state increase_amount in + let new_state = execute_call party intermediate_state in + let call_outputs = + { Call_data.Output.Circuit.blinding_value; new_state } + in + let call_data_hash = + Call_data.Circuit.digest + { input = call_inputs; output = call_outputs } + in + party#set_call_data call_data_hash ; + Some call_outputs ) + input + + let rule : _ Pickles.Inductive_rule.t = + { identifier = "Add-and-call method" + ; prevs = [] + ; main + ; uses_lookup = false + } + end +end From b638e8a220fddf69fdea01b9b6235d52578bc91c Mon Sep 17 00:00:00 2001 From: mrmr1993 Date: Mon, 8 Aug 2022 16:57:19 +0100 Subject: [PATCH 022/144] Add more comments --- .../test/zkapps_examples/calls/calls.ml | 12 ++++++++++++ src/lib/zkapps_examples/calls/zkapps_calls.ml | 4 ++++ 2 files changed, 16 insertions(+) diff --git a/src/lib/transaction_snark/test/zkapps_examples/calls/calls.ml b/src/lib/transaction_snark/test/zkapps_examples/calls/calls.ml index db188106b82..6ec1a272786 100644 --- a/src/lib/transaction_snark/test/zkapps_examples/calls/calls.ml +++ b/src/lib/transaction_snark/test/zkapps_examples/calls/calls.ml @@ -56,6 +56,7 @@ let%test_module "Composability test" = ; check = (fun _ -> assert false) } + (* Build the provers for the various rules. *) let ( tag , _ , p_module @@ -80,6 +81,7 @@ let%test_module "Composability test" = ; Zkapps_calls.Rules.Add_and_call.rule ] ) + (** The type of call to dispatch. *) type calls_kind = | Add_and_call of Snark_params.Tick.Run.Field.Constant.t * calls_kind | Add of Snark_params.Tick.Run.Field.Constant.t @@ -142,6 +144,16 @@ let%test_module "Composability test" = module Update_state_party = struct let old_state = Snark_params.Tick.Field.zero + (** The request handler to use when running this party. + + This handler accepts a [calls_kind] and fills in the [Execute_call] + handlers with either the 'add' prover or the 'add-and-call' prover, + depending on the structure described by [calls_kind]. + + When the desired call is 'add-and-call', this handler recursively + builds the handler for the add-and-call circuit, inserting the + behaviour for [Execute_call] according to the given [calls_kind]. + *) let handler (calls_kind : calls_kind) old_state = let rec make_call calls_kind input : Zkapps_calls.Call_data.Output.Constant.t diff --git a/src/lib/zkapps_examples/calls/zkapps_calls.ml b/src/lib/zkapps_examples/calls/zkapps_calls.ml index 80ea011aaba..bf57c1f5500 100644 --- a/src/lib/zkapps_examples/calls/zkapps_calls.ml +++ b/src/lib/zkapps_examples/calls/zkapps_calls.ml @@ -147,6 +147,7 @@ module Rules = struct (** State to initialize the zkApp to after deployment. *) let initial_state = lazy (List.init 8 ~f:(fun _ -> Field.Constant.zero)) + (** The request handler for the rule. *) let handler (public_key : Public_key.Compressed.t) (Snarky_backendless.Request.With { request; respond }) = match request with @@ -183,6 +184,7 @@ module Rules = struct uses the output value as the new state. *) module Update_state = struct + (** The request handler for the rule. *) let handler (public_key : Public_key.Compressed.t) (old_state : Field.Constant.t) (execute_call : @@ -233,6 +235,7 @@ module Rules = struct that it can be passed to the calling zkApp execution. *) module Add = struct + (** The request handler for the rule. *) let handler (public_key : Public_key.Compressed.t) (call_input : Call_data.Input.Constant.t) (increase_amount : Field.Constant.t) @@ -291,6 +294,7 @@ module Rules = struct that it can be passed to the calling zkApp execution. *) module Add_and_call = struct + (** The request handler for the rule. *) let handler (public_key : Public_key.Compressed.t) (add_and_call_input : Call_data.Input.Constant.t) (increase_amount : Field.Constant.t) From 05a72f90db4434693008b4441e068297531cb767 Mon Sep 17 00:00:00 2001 From: mrmr1993 Date: Mon, 8 Aug 2022 17:00:00 +0100 Subject: [PATCH 023/144] Move handlers into their own let-defs, add a comment to recursive call --- .../test/zkapps_examples/calls/calls.ml | 26 ++++++++++++------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/src/lib/transaction_snark/test/zkapps_examples/calls/calls.ml b/src/lib/transaction_snark/test/zkapps_examples/calls/calls.ml index 6ec1a272786..9d70b7eeaea 100644 --- a/src/lib/transaction_snark/test/zkapps_examples/calls/calls.ml +++ b/src/lib/transaction_snark/test/zkapps_examples/calls/calls.ml @@ -161,23 +161,31 @@ let%test_module "Composability test" = * Zkapp_call_forest.t = match calls_kind with | Add increase_amount -> + (* Execute the 'add' rule. *) + let handler = + Zkapps_calls.Rules.Add.handler pk_compressed input + increase_amount + in let tree, aux = - Async.Thread_safe.block_on_async_exn - (add_prover - ~handler: - (Zkapps_calls.Rules.Add.handler pk_compressed input - increase_amount ) ) + Async.Thread_safe.block_on_async_exn (add_prover ~handler) in ( Option.value_exn aux , { data = tree.party; hash = tree.party_digest } , tree.calls ) | Add_and_call (increase_amount, calls_kind) -> + (* Execute the 'add-and-call' rule *) + let handler = + (* Build the handler for the call in 'add-and-call' rule by + recursively calling this function on the remainder of + [calls_kind]. + *) + let execute_call = make_call calls_kind in + Zkapps_calls.Rules.Add_and_call.handler pk_compressed input + increase_amount execute_call + in let tree, aux = Async.Thread_safe.block_on_async_exn - (add_and_call_prover - ~handler: - (Zkapps_calls.Rules.Add_and_call.handler pk_compressed - input increase_amount (make_call calls_kind) ) ) + (add_and_call_prover ~handler) in ( Option.value_exn aux , { data = tree.party; hash = tree.party_digest } From 8a04a3a83b24de91a2c65c0003cc33edfef2decf Mon Sep 17 00:00:00 2001 From: mrmr1993 Date: Mon, 8 Aug 2022 19:19:50 +0100 Subject: [PATCH 024/144] Factor common code from tests into a function --- .../test/zkapps_examples/calls/calls.ml | 97 ++++--------------- 1 file changed, 17 insertions(+), 80 deletions(-) diff --git a/src/lib/transaction_snark/test/zkapps_examples/calls/calls.ml b/src/lib/transaction_snark/test/zkapps_examples/calls/calls.ml index 9d70b7eeaea..51a0fb5cea3 100644 --- a/src/lib/transaction_snark/test/zkapps_examples/calls/calls.ml +++ b/src/lib/transaction_snark/test/zkapps_examples/calls/calls.ml @@ -277,41 +277,24 @@ let%test_module "Composability test" = check_parties_with_merges_exn ?expected_failure ledger [ parties ] ) ; Ledger.get ledger loc ) - let%test_unit "Initialize and update nonrecursive" = + let test_recursive num_calls = let increments = - Array.init 1 ~f:(fun _ -> Snark_params.Tick.Field.random ()) + Array.init num_calls ~f:(fun _ -> Snark_params.Tick.Field.random ()) in - let expected_result = - Array.reduce_exn ~f:Snark_params.Tick.Field.add increments - in - let account = - [] - |> Parties.Call_forest.cons_tree - (Update_state_party.party (Add increments.(0))) - |> Parties.Call_forest.cons_tree Initialize_party.party - |> Parties.Call_forest.cons Deploy_party.party - |> test_parties - in - let (first_state :: zkapp_state) = - (Option.value_exn (Option.value_exn account).zkapp).app_state - in - assert (Snark_params.Tick.Field.equal expected_result first_state) ; - Pickles_types.Vector.iter - ~f:(fun x -> assert (Snark_params.Tick.Field.(equal zero) x)) - zkapp_state - - let%test_unit "Initialize and update single recursive" = - let increments = - Array.init 2 ~f:(fun _ -> Snark_params.Tick.Field.random ()) + let calls_kind = + (* Recursively call [i+1] times. *) + let rec go i = + if i = 0 then Add increments.(0) + else Add_and_call (increments.(i), go (i - 1)) + in + go (num_calls - 1) in let expected_result = Array.reduce_exn ~f:Snark_params.Tick.Field.add increments in let account = [] - |> Parties.Call_forest.cons_tree - (Update_state_party.party - (Add_and_call (increments.(0), Add increments.(1))) ) + |> Parties.Call_forest.cons_tree (Update_state_party.party calls_kind) |> Parties.Call_forest.cons_tree Initialize_party.party |> Parties.Call_forest.cons Deploy_party.party |> test_parties @@ -320,62 +303,16 @@ let%test_module "Composability test" = (Option.value_exn (Option.value_exn account).zkapp).app_state in assert (Snark_params.Tick.Field.equal expected_result first_state) ; + (* Check that the rest of the state is unmodified. *) Pickles_types.Vector.iter ~f:(fun x -> assert (Snark_params.Tick.Field.(equal zero) x)) zkapp_state - let%test_unit "Initialize and update double recursive" = - let increments = - Array.init 3 ~f:(fun _ -> Snark_params.Tick.Field.random ()) - in - let expected_result = - Array.reduce_exn ~f:Snark_params.Tick.Field.add increments - in - let account = - [] - |> Parties.Call_forest.cons_tree - (Update_state_party.party - (Add_and_call - ( increments.(0) - , Add_and_call (increments.(1), Add increments.(2)) ) ) ) - |> Parties.Call_forest.cons_tree Initialize_party.party - |> Parties.Call_forest.cons Deploy_party.party - |> test_parties - in - let (first_state :: zkapp_state) = - (Option.value_exn (Option.value_exn account).zkapp).app_state - in - assert (Snark_params.Tick.Field.equal expected_result first_state) ; - Pickles_types.Vector.iter - ~f:(fun x -> assert (Snark_params.Tick.Field.(equal zero) x)) - zkapp_state + let%test_unit "Initialize and update nonrecursive" = test_recursive 1 - let%test_unit "Initialize and update triple recursive" = - let increments = - Array.init 4 ~f:(fun _ -> Snark_params.Tick.Field.random ()) - in - let expected_result = - Array.reduce_exn ~f:Snark_params.Tick.Field.add increments - in - let account = - [] - |> Parties.Call_forest.cons_tree - (Update_state_party.party - (Add_and_call - ( increments.(0) - , Add_and_call - ( increments.(1) - , Add_and_call (increments.(2), Add increments.(3)) ) ) - ) ) - |> Parties.Call_forest.cons_tree Initialize_party.party - |> Parties.Call_forest.cons Deploy_party.party - |> test_parties - in - let (first_state :: zkapp_state) = - (Option.value_exn (Option.value_exn account).zkapp).app_state - in - assert (Snark_params.Tick.Field.equal expected_result first_state) ; - Pickles_types.Vector.iter - ~f:(fun x -> assert (Snark_params.Tick.Field.(equal zero) x)) - zkapp_state + let%test_unit "Initialize and update single recursive" = test_recursive 2 + + let%test_unit "Initialize and update double recursive" = test_recursive 3 + + let%test_unit "Initialize and update triple recursive" = test_recursive 4 end ) From 09484cafb46bb49160239e91ceed76d2e0e00556 Mon Sep 17 00:00:00 2001 From: mrmr1993 Date: Mon, 29 Aug 2022 17:46:36 +0100 Subject: [PATCH 025/144] Rename to_ro_input to to_random_oracle_input --- src/lib/zkapps_examples/calls/zkapps_calls.ml | 28 +++++++++++-------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/src/lib/zkapps_examples/calls/zkapps_calls.ml b/src/lib/zkapps_examples/calls/zkapps_calls.ml index bf57c1f5500..41b20776c29 100644 --- a/src/lib/zkapps_examples/calls/zkapps_calls.ml +++ b/src/lib/zkapps_examples/calls/zkapps_calls.ml @@ -14,14 +14,14 @@ module Call_data = struct module Constant = struct type t = { old_state : Field.Constant.t } [@@deriving hlist] - let to_ro_input { old_state } = + let to_random_oracle_input { old_state } = Random_oracle_input.Chunked.field_elements [| old_state |] end module Circuit = struct type t = { old_state : Field.t } [@@deriving hlist] - let to_ro_input { old_state } = + let to_random_oracle_input { old_state } = Random_oracle_input.Chunked.field_elements [| old_state |] end @@ -40,7 +40,7 @@ module Call_data = struct { blinding_value : Field.Constant.t; new_state : Field.Constant.t } [@@deriving hlist] - let to_ro_input { blinding_value; new_state } = + let to_random_oracle_input { blinding_value; new_state } = Random_oracle_input.Chunked.field_elements [| blinding_value; new_state |] end @@ -49,7 +49,7 @@ module Call_data = struct type t = { blinding_value : Field.t; new_state : Field.t } [@@deriving hlist] - let to_ro_input { blinding_value; new_state } = + let to_random_oracle_input { blinding_value; new_state } = Random_oracle_input.Chunked.field_elements [| blinding_value; new_state |] end @@ -64,28 +64,32 @@ module Call_data = struct type t = { input : Input.Constant.t; output : Output.Constant.t } [@@deriving hlist] - let to_ro_input { input; output } = + let to_random_oracle_input { input; output } = Random_oracle_input.Chunked.append - (Input.Constant.to_ro_input input) - (Output.Constant.to_ro_input output) + (Input.Constant.to_random_oracle_input input) + (Output.Constant.to_random_oracle_input output) let digest (t : t) = let open Random_oracle in - to_ro_input t |> pack_input |> update ~state:initial_state |> digest + to_random_oracle_input t |> pack_input + |> update ~state:initial_state + |> digest end module Circuit = struct type t = { input : Input.Circuit.t; output : Output.Circuit.t } [@@deriving hlist] - let to_ro_input { input; output } = + let to_random_oracle_input { input; output } = Random_oracle_input.Chunked.append - (Input.Circuit.to_ro_input input) - (Output.Circuit.to_ro_input output) + (Input.Circuit.to_random_oracle_input input) + (Output.Circuit.to_random_oracle_input output) let digest (t : t) = let open Random_oracle.Checked in - to_ro_input t |> pack_input |> update ~state:initial_state |> digest + to_random_oracle_input t |> pack_input + |> update ~state:initial_state + |> digest end let typ = From adc8c81a19a2578d127f874942898db8bfae3893 Mon Sep 17 00:00:00 2001 From: mrmr1993 Date: Mon, 29 Aug 2022 17:54:09 +0100 Subject: [PATCH 026/144] Add expository comment to blinding_value --- src/lib/zkapps_examples/calls/zkapps_calls.ml | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/lib/zkapps_examples/calls/zkapps_calls.ml b/src/lib/zkapps_examples/calls/zkapps_calls.ml index 41b20776c29..e8beada9c30 100644 --- a/src/lib/zkapps_examples/calls/zkapps_calls.ml +++ b/src/lib/zkapps_examples/calls/zkapps_calls.ml @@ -37,7 +37,18 @@ module Call_data = struct module Output = struct module Constant = struct type t = - { blinding_value : Field.Constant.t; new_state : Field.Constant.t } + { blinding_value : Field.Constant.t + (** A random value, mixed into the hash with the returned value. + + This is used to hide the contents of the inter-app call's + arguments and return values from the protocol, so that one + zkApp can make assertions about private data on behalf on + another zkApp, or otherwise keep data secret. + When chosen at random, the probability of an adversary + finding the correct value is negligible (1 in ~2^254). + *) + ; new_state : Field.Constant.t + } [@@deriving hlist] let to_random_oracle_input { blinding_value; new_state } = From 7f58cf8f3351788ef82b4c0e766cfad569009b47 Mon Sep 17 00:00:00 2001 From: Paul Steckler Date: Mon, 29 Aug 2022 18:51:44 -0700 Subject: [PATCH 027/144] Wait to loaded persisted frontier in peers test --- .../test_executive/peers_reliability_test.ml | 5 ++- src/lib/integration_test_lib/event_type.ml | 25 +++++++++++- src/lib/integration_test_lib/event_type.mli | 7 ++++ src/lib/integration_test_lib/gossip_state.ml | 2 +- src/lib/integration_test_lib/intf.ml | 3 ++ .../integration_test_lib/wait_condition.ml | 21 ++++++++-- .../integration_test_lib/wait_condition.mli | 1 + .../transition_frontier.ml | 39 +++++++++++++++++-- .../transition_frontier.mli | 7 +++- 9 files changed, 98 insertions(+), 12 deletions(-) diff --git a/src/app/test_executive/peers_reliability_test.ml b/src/app/test_executive/peers_reliability_test.ml index b34ee8ccad5..ec16d645a17 100644 --- a/src/app/test_executive/peers_reliability_test.ml +++ b/src/app/test_executive/peers_reliability_test.ml @@ -75,7 +75,10 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct [%log info] "%s started again, will now wait for this node to initialize" (Node.id node_c) ; - let%bind () = wait_for t (Wait_condition.node_to_initialize node_c) in + let%bind () = wait_for t @@ Wait_condition.node_to_initialize node_c in + let%bind () = + wait_for t @@ Wait_condition.persisted_frontier_loaded () + in wait_for t ( Wait_condition.nodes_to_synchronize [ node_a; node_b; node_c ] |> Wait_condition.with_timeouts diff --git a/src/lib/integration_test_lib/event_type.ml b/src/lib/integration_test_lib/event_type.ml index 04b3eef8313..f5fb9932899 100644 --- a/src/lib/integration_test_lib/event_type.ml +++ b/src/lib/integration_test_lib/event_type.ml @@ -244,6 +244,19 @@ module Breadcrumb_added = struct let parse = From_daemon_log (structured_event_id, parse_func) end +module Persisted_frontier_loaded = struct + type t = unit [@@deriving to_yojson] + + let name = "persisted_frontier_loaded" + + let structured_event_id = + Transition_frontier.persisted_frontier_loaded_structured_events_id + + let parse_func = Fn.const (Or_error.return ()) + + let parse = From_daemon_log (structured_event_id, parse_func) +end + module Gossip = struct open Or_error.Let_syntax @@ -359,6 +372,7 @@ type 'a t = | Snark_work_gossip : Gossip.Snark_work.t t | Transactions_gossip : Gossip.Transactions.t t | Snark_work_failed : Snark_work_failed.t t + | Persisted_frontier_loaded : Persisted_frontier_loaded.t t type existential = Event_type : 'a t -> existential @@ -383,6 +397,8 @@ let existential_to_string = function "Transactions_gossip" | Event_type Snark_work_failed -> "Snark_work_failed" + | Event_type Persisted_frontier_loaded -> + "Persisted_frontier_loaded" let to_string e = existential_to_string (Event_type e) @@ -407,6 +423,8 @@ let existential_of_string_exn = function Event_type Transactions_gossip | "Snark_work_failed" -> Event_type Snark_work_failed + | "Persisted_frontier_loaded" -> + Event_type Persisted_frontier_loaded | _ -> failwith "invalid event type string" @@ -448,6 +466,7 @@ let all_event_types = ; Event_type Snark_work_gossip ; Event_type Transactions_gossip ; Event_type Snark_work_failed + ; Event_type Persisted_frontier_loaded ] let event_type_module : type a. a t -> (module Event_type_intf with type t = a) @@ -472,6 +491,8 @@ let event_type_module : type a. a t -> (module Event_type_intf with type t = a) (module Gossip.Transactions) | Snark_work_failed -> (module Snark_work_failed) + | Persisted_frontier_loaded -> + (module Persisted_frontier_loaded) let event_to_yojson event = let (Event (t, d)) = event in @@ -586,9 +607,11 @@ let dispatch_exn : type a b c. a t -> a -> b t -> (b -> c) -> c = h e | Block_gossip, Block_gossip -> h e + | Transactions_gossip, Transactions_gossip -> + h e | Snark_work_gossip, Snark_work_gossip -> h e - | Transactions_gossip, Transactions_gossip -> + | Persisted_frontier_loaded, Persisted_frontier_loaded -> h e | _ -> failwith "TODO: better error message :)" diff --git a/src/lib/integration_test_lib/event_type.mli b/src/lib/integration_test_lib/event_type.mli index 30b96f1e032..2e93f9b6776 100644 --- a/src/lib/integration_test_lib/event_type.mli +++ b/src/lib/integration_test_lib/event_type.mli @@ -79,6 +79,12 @@ module Breadcrumb_added : sig include Event_type_intf with type t := t end +module Persisted_frontier_loaded : sig + type t = unit + + include Event_type_intf with type t := t +end + module Gossip : sig module Direction : sig type t = Sent | Received [@@deriving yojson] @@ -133,6 +139,7 @@ type 'a t = | Snark_work_gossip : Gossip.Snark_work.t t | Transactions_gossip : Gossip.Transactions.t t | Snark_work_failed : Snark_work_failed.t t + | Persisted_frontier_loaded : Persisted_frontier_loaded.t t val to_string : 'a t -> string diff --git a/src/lib/integration_test_lib/gossip_state.ml b/src/lib/integration_test_lib/gossip_state.ml index 04478e4242a..bb0aed060e2 100644 --- a/src/lib/integration_test_lib/gossip_state.ml +++ b/src/lib/integration_test_lib/gossip_state.ml @@ -75,7 +75,7 @@ let add (gossip_state : t) (type a) ((gossip_message : a), (dir : Event_type.Gossip.Direction.t)) : unit = let set : a Set.t By_direction.t = match event_type with - | Block_gossip -> + | Event_type.Block_gossip -> gossip_state.blocks | Transactions_gossip -> gossip_state.transactions diff --git a/src/lib/integration_test_lib/intf.ml b/src/lib/integration_test_lib/intf.ml index 28128cce4e3..cbb2fbc8478 100644 --- a/src/lib/integration_test_lib/intf.ml +++ b/src/lib/integration_test_lib/intf.ml @@ -355,6 +355,7 @@ module Dsl = struct | Ledger_proofs_emitted_since_genesis | Block_height_growth | Zkapp_to_be_included_in_frontier + | Persisted_frontier_loaded val wait_condition_id : t -> wait_condition_id @@ -383,6 +384,8 @@ module Dsl = struct val zkapp_to_be_included_in_frontier : has_failures:bool -> parties:Mina_base.Parties.t -> t + + val persisted_frontier_loaded : unit -> t end module type Util_intf = sig diff --git a/src/lib/integration_test_lib/wait_condition.ml b/src/lib/integration_test_lib/wait_condition.ml index 424f68cd18f..249fea442ba 100644 --- a/src/lib/integration_test_lib/wait_condition.ml +++ b/src/lib/integration_test_lib/wait_condition.ml @@ -39,6 +39,7 @@ struct | Ledger_proofs_emitted_since_genesis | Block_height_growth | Zkapp_to_be_included_in_frontier + | Persisted_frontier_loaded type t = { id : wait_condition_id @@ -185,7 +186,7 @@ struct let soft_timeout_in_slots = 8 in { id = Signed_command_to_be_included_in_frontier ; description = - Printf.sprintf "signed command with hash %s" + sprintf "signed command with hash %s" (Transaction_hash.to_base58_check txn_hash) ; predicate = Network_state_predicate (check (), check) ; soft_timeout = Slots soft_timeout_in_slots @@ -199,8 +200,7 @@ struct else Predicate_continuation () in let description = - Printf.sprintf "[%d] snarked_ledgers to be generated since genesis" - num_proofs + sprintf "[%d] snarked_ledgers to be generated since genesis" num_proofs in { id = Ledger_proofs_emitted_since_genesis ; description @@ -265,4 +265,19 @@ struct ; soft_timeout = Slots soft_timeout_in_slots ; hard_timeout = Slots (soft_timeout_in_slots * 2) } + + let persisted_frontier_loaded () = + let check () _node + (_frontier_loaded : Event_type.Persisted_frontier_loaded.t) = + (* the fact of loading is sufficient, nothing else to check *) + Predicate_passed + in + let soft_timeout_in_slots = 8 in + { id = Persisted_frontier_loaded + ; description = "persisted transition frontier to load" + ; predicate = + Event_predicate (Event_type.Persisted_frontier_loaded, (), check) + ; soft_timeout = Slots soft_timeout_in_slots + ; hard_timeout = Slots (soft_timeout_in_slots * 2) + } end diff --git a/src/lib/integration_test_lib/wait_condition.mli b/src/lib/integration_test_lib/wait_condition.mli index 889f05c80a7..bec1b217971 100644 --- a/src/lib/integration_test_lib/wait_condition.mli +++ b/src/lib/integration_test_lib/wait_condition.mli @@ -30,6 +30,7 @@ module Make | Ledger_proofs_emitted_since_genesis | Block_height_growth | Zkapp_to_be_included_in_frontier + | Persisted_frontier_loaded type t = { id : wait_condition_id diff --git a/src/lib/transition_frontier/transition_frontier.ml b/src/lib/transition_frontier/transition_frontier.ml index 9a9bd3f66cc..26fbf98f698 100644 --- a/src/lib/transition_frontier/transition_frontier.ml +++ b/src/lib/transition_frontier/transition_frontier.ml @@ -60,6 +60,9 @@ type Structured_log_events.t += Added_breadcrumb_user_commands type Structured_log_events.t += Applying_diffs of { diffs : Yojson.Safe.t list } [@@deriving register_event { msg = "Applying diffs: $diffs" }] +type Structured_log_events.t += Persisted_frontier_loaded + [@@deriving register_event] + let genesis_root_data ~precomputed_values = let transition = Mina_block.Validated.lift @@ Mina_block.genesis ~precomputed_values @@ -174,6 +177,7 @@ let rec load_with_max_length : -> ( t , [> `Bootstrap_required | `Persistent_frontier_malformed + | `Snarked_ledger_mismatch | `Failure of string ] ) Deferred.Result.t = fun ~context:(module Context : CONTEXT) ~max_length @@ -184,15 +188,24 @@ let rec load_with_max_length : (* TODO: #3053 *) let continue persistent_frontier_instance ~ignore_consensus_local_state ~snarked_ledger_hash = + let snarked_ledger_hash_json = + Frozen_ledger_hash.to_yojson snarked_ledger_hash + in match Persistent_root.load_from_disk_exn persistent_root ~snarked_ledger_hash ~logger with - | Error _ as err -> + | Error _err as err_result -> + (* _err has type [> `Snarked_ledger_mismatch ] *) + [%log warn] "Persisted frontier failed to load" + ~metadata: + [ ("error", `String "SNARKed ledger mismatch on load from disk") + ; ("expected_snarked_ledger_hash", snarked_ledger_hash_json) + ] ; let%map () = Persistent_frontier.Instance.destroy persistent_frontier_instance in - err + err_result | Ok persistent_root_instance -> ( match%bind load_from_persistence_and_start @@ -202,13 +215,31 @@ let rec load_with_max_length : ~persistent_frontier_instance ignore_consensus_local_state with | Ok _ as result -> + [%str_log trace] Persisted_frontier_loaded + ~metadata:[ ("snarked_ledger_hash", snarked_ledger_hash_json) ] ; return result - | Error _ as err -> + | Error err as err_result -> + let err_str = + match err with + | `Failure msg -> + sprintf "Failure: %s" msg + | `Bootstrap_required -> + "Bootstrap required" + (* next two cases aren't reachable, needed for types to work out *) + | `Snarked_ledger_mismatch | `Persistent_frontier_malformed -> + failwith "Unexpected failure on loading transition frontier" + in + [%log warn] "Persisted frontier failed to load" + ~metadata: + [ ("error", `String err_str) + ; ("expected_snarked_ledger_hash", snarked_ledger_hash_json) + ] ; + let%map () = Persistent_frontier.Instance.destroy persistent_frontier_instance in Persistent_root.Instance.close persistent_root_instance ; - err ) + err_result ) in let persistent_frontier_instance = Persistent_frontier.create_instance_exn persistent_frontier diff --git a/src/lib/transition_frontier/transition_frontier.mli b/src/lib/transition_frontier/transition_frontier.mli index 3f05bf15dd1..4c1250b128a 100644 --- a/src/lib/transition_frontier/transition_frontier.mli +++ b/src/lib/transition_frontier/transition_frontier.mli @@ -36,6 +36,9 @@ type Structured_log_events.t += Added_breadcrumb_user_commands type Structured_log_events.t += Applying_diffs of { diffs : Yojson.Safe.t list } [@@deriving register_event] +type Structured_log_events.t += Persisted_frontier_loaded + [@@deriving register_event] + val max_catchup_chunk_length : int val catchup_tree : t -> Catchup_tree.t @@ -55,7 +58,7 @@ val load : -> catchup_mode:[ `Normal | `Super ] -> unit -> ( t - , [> `Failure of string + , [ `Failure of string | `Bootstrap_required | `Persistent_frontier_malformed | `Snarked_ledger_mismatch ] ) @@ -110,7 +113,7 @@ module For_tests : sig -> catchup_mode:[ `Normal | `Super ] -> unit -> ( t - , [> `Failure of string + , [ `Failure of string | `Bootstrap_required | `Persistent_frontier_malformed | `Snarked_ledger_mismatch ] ) From 3911ad53bea0b0abc766607d1892eabf5cced5e9 Mon Sep 17 00:00:00 2001 From: Paul Steckler Date: Tue, 30 Aug 2022 13:37:53 -0700 Subject: [PATCH 028/144] add a couple of txns to test --- .../test_executive/peers_reliability_test.ml | 74 ++++++++++++++++++- src/app/test_executive/zkapps.ml | 2 +- 2 files changed, 74 insertions(+), 2 deletions(-) diff --git a/src/app/test_executive/peers_reliability_test.ml b/src/app/test_executive/peers_reliability_test.ml index ec16d645a17..2205bde1f46 100644 --- a/src/app/test_executive/peers_reliability_test.ml +++ b/src/app/test_executive/peers_reliability_test.ml @@ -7,6 +7,8 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct open Engine open Dsl + open Test_common.Make (Inputs) + (* TODO: find a way to avoid this type alias (first class module signatures restrictions make this tricky) *) type network = Network.t @@ -24,6 +26,10 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct ; { balance = "1000"; timing = Untimed } ; { balance = "0"; timing = Untimed } ] + ; extra_genesis_accounts = + [ { balance = "3000"; timing = Untimed } + ; { balance = "3000"; timing = Untimed } + ] ; num_snark_workers = 0 } @@ -49,11 +55,77 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct in let%bind () = section - "network can't be paritioned if 2 nodes are hypothetically taken \ + "network can't be partitioned if 2 nodes are hypothetically taken \ offline" (Util.assert_peers_cant_be_partitioned ~max_disconnections:2 initial_connectivity_data ) in + (* a couple of transactions, so the persisted transition frontier is not trivial *) + let%bind () = + section_hard "send a payment" + (let get_pubkey node = + let network_keypair = Option.value_exn (Node.network_keypair node) in + network_keypair.keypair.public_key + |> Signature_lib.Public_key.compress + in + let sender_pub_key = get_pubkey node_a in + let receiver_pub_key = get_pubkey node_b in + let%bind { hash = txn_hash; _ } = + Node.must_send_payment ~logger node_c ~sender_pub_key + ~receiver_pub_key + ~amount:(Currency.Amount.of_int 1_000_000) + ~fee:(Currency.Fee.of_int 1_000) + in + wait_for t + (Wait_condition.signed_command_to_be_included_in_frontier ~txn_hash + ~node_included_in:(`Node node_c) ) ) + in + let%bind () = + let open Mina_base in + let wait_for_zkapp parties = + let%map () = + wait_for t + @@ Wait_condition.zkapp_to_be_included_in_frontier ~has_failures:false + ~parties + in + [%log info] "ZkApp transaction included in transition frontier" + in + section_hard "send a zkApp to create an account" + (let%bind parties_create_accounts = + let amount = Currency.Amount.of_int 10_000_000_000 in + let nonce = Account.Nonce.zero in + let memo = + Signed_command_memo.create_from_string_exn "Zkapp create account" + in + let fee = Currency.Fee.of_int 20_000_000 in + let sender_kp = + List.hd_exn @@ Network.extra_genesis_keypairs network + in + let (parties_spec : Transaction_snark.For_tests.Spec.t) = + { sender = (sender_kp, nonce) + ; fee + ; fee_payer = None + ; receivers = [] + ; amount + ; zkapp_account_keypairs = [ Signature_lib.Keypair.create () ] + ; memo + ; new_zkapp_account = true + ; snapp_update = Party.Update.dummy + ; current_auth = Permissions.Auth_required.Signature + ; call_data = Snark_params.Tick.Field.zero + ; events = [] + ; sequence_events = [] + ; preconditions = None + } + in + return + @@ Transaction_snark.For_tests.deploy_snapp + ~constraint_constants:(Network.constraint_constants network) + parties_spec + in + let%bind () = send_zkapp ~logger node_c parties_create_accounts in + wait_for_zkapp parties_create_accounts ) + in let%bind () = section "blocks are produced" (wait_for t (Wait_condition.blocks_to_be_produced 1)) diff --git a/src/app/test_executive/zkapps.ml b/src/app/test_executive/zkapps.ml index f3b79c5c776..a4271bdff29 100644 --- a/src/app/test_executive/zkapps.ml +++ b/src/app/test_executive/zkapps.ml @@ -520,7 +520,7 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct @@ Wait_condition.zkapp_to_be_included_in_frontier ~has_failures:false ~parties in - [%log info] "ZkApp transactions included in transition frontier" + [%log info] "ZkApp transaction included in transition frontier" in let compatible req_item ledg_item ~equal = match (req_item, ledg_item) with From a0a307137267070602a7aef526016c35acaf113d Mon Sep 17 00:00:00 2001 From: Paul Steckler Date: Tue, 30 Aug 2022 14:33:53 -0700 Subject: [PATCH 029/144] different sender keys --- src/app/test_executive/peers_reliability_test.ml | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/app/test_executive/peers_reliability_test.ml b/src/app/test_executive/peers_reliability_test.ml index 2205bde1f46..478cd03b6c6 100644 --- a/src/app/test_executive/peers_reliability_test.ml +++ b/src/app/test_executive/peers_reliability_test.ml @@ -61,6 +61,9 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct initial_connectivity_data ) in (* a couple of transactions, so the persisted transition frontier is not trivial *) + let[@warning "-8"] [ fish1; fish2 ] = + Network.extra_genesis_keypairs network + in let%bind () = section_hard "send a payment" (let get_pubkey node = @@ -68,8 +71,10 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct network_keypair.keypair.public_key |> Signature_lib.Public_key.compress in - let sender_pub_key = get_pubkey node_a in - let receiver_pub_key = get_pubkey node_b in + let sender_pub_key = + fish1.public_key |> Signature_lib.Public_key.compress + in + let receiver_pub_key = get_pubkey node_a in let%bind { hash = txn_hash; _ } = Node.must_send_payment ~logger node_c ~sender_pub_key ~receiver_pub_key @@ -98,9 +103,7 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct Signed_command_memo.create_from_string_exn "Zkapp create account" in let fee = Currency.Fee.of_int 20_000_000 in - let sender_kp = - List.hd_exn @@ Network.extra_genesis_keypairs network - in + let sender_kp = fish2 in let (parties_spec : Transaction_snark.For_tests.Spec.t) = { sender = (sender_kp, nonce) ; fee From d566048d8c1815573ed3f73d7cd7717b70f10b3f Mon Sep 17 00:00:00 2001 From: Paul Steckler Date: Tue, 30 Aug 2022 16:38:35 -0700 Subject: [PATCH 030/144] another try with keys --- .../test_executive/peers_reliability_test.ml | 31 ++++++------------- 1 file changed, 10 insertions(+), 21 deletions(-) diff --git a/src/app/test_executive/peers_reliability_test.ml b/src/app/test_executive/peers_reliability_test.ml index 478cd03b6c6..a61c2fc5fef 100644 --- a/src/app/test_executive/peers_reliability_test.ml +++ b/src/app/test_executive/peers_reliability_test.ml @@ -22,15 +22,13 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct { default with requires_graphql = true ; block_producers = - [ { balance = "1000"; timing = Untimed } - ; { balance = "1000"; timing = Untimed } - ; { balance = "0"; timing = Untimed } + [ { balance = "100_000"; timing = Untimed } + ; { balance = "100_000"; timing = Untimed } + ; { balance = "100_000"; timing = Untimed } ] - ; extra_genesis_accounts = - [ { balance = "3000"; timing = Untimed } - ; { balance = "3000"; timing = Untimed } - ] - ; num_snark_workers = 0 + ; extra_genesis_accounts = [ { balance = "9000"; timing = Untimed } ] + ; num_snark_workers = 2 + ; snark_worker_fee = "0.0001" } let run network t = @@ -61,20 +59,11 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct initial_connectivity_data ) in (* a couple of transactions, so the persisted transition frontier is not trivial *) - let[@warning "-8"] [ fish1; fish2 ] = - Network.extra_genesis_keypairs network - in + let fish = List.hd_exn @@ Network.extra_genesis_keypairs network in let%bind () = section_hard "send a payment" - (let get_pubkey node = - let network_keypair = Option.value_exn (Node.network_keypair node) in - network_keypair.keypair.public_key - |> Signature_lib.Public_key.compress - in - let sender_pub_key = - fish1.public_key |> Signature_lib.Public_key.compress - in - let receiver_pub_key = get_pubkey node_a in + (let%bind sender_pub_key = Util.pub_key_of_node node_a in + let%bind receiver_pub_key = Util.pub_key_of_node node_b in let%bind { hash = txn_hash; _ } = Node.must_send_payment ~logger node_c ~sender_pub_key ~receiver_pub_key @@ -103,7 +92,7 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct Signed_command_memo.create_from_string_exn "Zkapp create account" in let fee = Currency.Fee.of_int 20_000_000 in - let sender_kp = fish2 in + let sender_kp = fish in let (parties_spec : Transaction_snark.For_tests.Spec.t) = { sender = (sender_kp, nonce) ; fee From 43a6c89381f9fd43f050cc67d74e795531742d20 Mon Sep 17 00:00:00 2001 From: Paul Steckler Date: Tue, 30 Aug 2022 17:15:11 -0700 Subject: [PATCH 031/144] use bp node keys --- .../test_executive/peers_reliability_test.ml | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/app/test_executive/peers_reliability_test.ml b/src/app/test_executive/peers_reliability_test.ml index a61c2fc5fef..630847f4d7b 100644 --- a/src/app/test_executive/peers_reliability_test.ml +++ b/src/app/test_executive/peers_reliability_test.ml @@ -26,9 +26,6 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct ; { balance = "100_000"; timing = Untimed } ; { balance = "100_000"; timing = Untimed } ] - ; extra_genesis_accounts = [ { balance = "9000"; timing = Untimed } ] - ; num_snark_workers = 2 - ; snark_worker_fee = "0.0001" } let run network t = @@ -59,7 +56,6 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct initial_connectivity_data ) in (* a couple of transactions, so the persisted transition frontier is not trivial *) - let fish = List.hd_exn @@ Network.extra_genesis_keypairs network in let%bind () = section_hard "send a payment" (let%bind sender_pub_key = Util.pub_key_of_node node_a in @@ -75,7 +71,6 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct ~node_included_in:(`Node node_c) ) ) in let%bind () = - let open Mina_base in let wait_for_zkapp parties = let%map () = wait_for t @@ -87,12 +82,15 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct section_hard "send a zkApp to create an account" (let%bind parties_create_accounts = let amount = Currency.Amount.of_int 10_000_000_000 in - let nonce = Account.Nonce.zero in + let nonce = Mina_base.Account.Nonce.zero in let memo = - Signed_command_memo.create_from_string_exn "Zkapp create account" + Mina_base.Signed_command_memo.create_from_string_exn + "Zkapp create account" in let fee = Currency.Fee.of_int 20_000_000 in - let sender_kp = fish in + let sender_kp = + (Option.value_exn (Node.network_keypair node_a)).keypair + in let (parties_spec : Transaction_snark.For_tests.Spec.t) = { sender = (sender_kp, nonce) ; fee @@ -102,8 +100,8 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct ; zkapp_account_keypairs = [ Signature_lib.Keypair.create () ] ; memo ; new_zkapp_account = true - ; snapp_update = Party.Update.dummy - ; current_auth = Permissions.Auth_required.Signature + ; snapp_update = Mina_base.Party.Update.dummy + ; current_auth = Mina_base.Permissions.Auth_required.Signature ; call_data = Snark_params.Tick.Field.zero ; events = [] ; sequence_events = [] From 59c8993d8867f449919abdd3dddb8af47eba0815 Mon Sep 17 00:00:00 2001 From: Paul Steckler Date: Tue, 30 Aug 2022 18:10:59 -0700 Subject: [PATCH 032/144] try sending from different node --- src/app/test_executive/peers_reliability_test.ml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/test_executive/peers_reliability_test.ml b/src/app/test_executive/peers_reliability_test.ml index 630847f4d7b..8ffaa06e196 100644 --- a/src/app/test_executive/peers_reliability_test.ml +++ b/src/app/test_executive/peers_reliability_test.ml @@ -58,7 +58,7 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct (* a couple of transactions, so the persisted transition frontier is not trivial *) let%bind () = section_hard "send a payment" - (let%bind sender_pub_key = Util.pub_key_of_node node_a in + (let%bind sender_pub_key = Util.pub_key_of_node node_c in let%bind receiver_pub_key = Util.pub_key_of_node node_b in let%bind { hash = txn_hash; _ } = Node.must_send_payment ~logger node_c ~sender_pub_key @@ -89,7 +89,7 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct in let fee = Currency.Fee.of_int 20_000_000 in let sender_kp = - (Option.value_exn (Node.network_keypair node_a)).keypair + (Option.value_exn (Node.network_keypair node_c)).keypair in let (parties_spec : Transaction_snark.For_tests.Spec.t) = { sender = (sender_kp, nonce) From 8446be3b5b0d16ac323abbcc1818d950e9090fdd Mon Sep 17 00:00:00 2001 From: Paul Steckler Date: Tue, 30 Aug 2022 18:46:22 -0700 Subject: [PATCH 033/144] increase fee --- src/app/test_executive/peers_reliability_test.ml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/app/test_executive/peers_reliability_test.ml b/src/app/test_executive/peers_reliability_test.ml index 8ffaa06e196..a31162d50af 100644 --- a/src/app/test_executive/peers_reliability_test.ml +++ b/src/app/test_executive/peers_reliability_test.ml @@ -22,9 +22,9 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct { default with requires_graphql = true ; block_producers = - [ { balance = "100_000"; timing = Untimed } - ; { balance = "100_000"; timing = Untimed } - ; { balance = "100_000"; timing = Untimed } + [ { balance = "8_000_000_000"; timing = Untimed } + ; { balance = "8_000_000_000"; timing = Untimed } + ; { balance = "100_000_000"; timing = Untimed } ] } @@ -64,7 +64,7 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct Node.must_send_payment ~logger node_c ~sender_pub_key ~receiver_pub_key ~amount:(Currency.Amount.of_int 1_000_000) - ~fee:(Currency.Fee.of_int 1_000) + ~fee:(Currency.Fee.of_int 10_000_000) in wait_for t (Wait_condition.signed_command_to_be_included_in_frontier ~txn_hash From 5c71195b69d14b0fada47f50eccb8fb69c62f712 Mon Sep 17 00:00:00 2001 From: Paul Steckler Date: Tue, 30 Aug 2022 19:26:44 -0700 Subject: [PATCH 034/144] bigger balances --- src/app/test_executive/peers_reliability_test.ml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/app/test_executive/peers_reliability_test.ml b/src/app/test_executive/peers_reliability_test.ml index a31162d50af..71bedf43d8c 100644 --- a/src/app/test_executive/peers_reliability_test.ml +++ b/src/app/test_executive/peers_reliability_test.ml @@ -22,9 +22,9 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct { default with requires_graphql = true ; block_producers = - [ { balance = "8_000_000_000"; timing = Untimed } - ; { balance = "8_000_000_000"; timing = Untimed } - ; { balance = "100_000_000"; timing = Untimed } + [ { balance = "80_000_000_000"; timing = Untimed } + ; { balance = "80_000_000_000"; timing = Untimed } + ; { balance = "100_000_000_000"; timing = Untimed } ] } From 097dfa616c26ba412b8cb475262a6038e5471873 Mon Sep 17 00:00:00 2001 From: Paul Steckler Date: Tue, 30 Aug 2022 20:28:35 -0700 Subject: [PATCH 035/144] reformat balances --- src/app/test_executive/peers_reliability_test.ml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/app/test_executive/peers_reliability_test.ml b/src/app/test_executive/peers_reliability_test.ml index 71bedf43d8c..4495cb8fb1b 100644 --- a/src/app/test_executive/peers_reliability_test.ml +++ b/src/app/test_executive/peers_reliability_test.ml @@ -22,9 +22,9 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct { default with requires_graphql = true ; block_producers = - [ { balance = "80_000_000_000"; timing = Untimed } - ; { balance = "80_000_000_000"; timing = Untimed } - ; { balance = "100_000_000_000"; timing = Untimed } + [ { balance = "700000"; timing = Untimed } + ; { balance = "700000"; timing = Untimed } + ; { balance = "800000"; timing = Untimed } ] } From 8e05d24ba84c644d02d2d37d5c00839eb329e48c Mon Sep 17 00:00:00 2001 From: Paul Steckler Date: Tue, 30 Aug 2022 20:59:39 -0700 Subject: [PATCH 036/144] fix nonce --- src/app/test_executive/peers_reliability_test.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/test_executive/peers_reliability_test.ml b/src/app/test_executive/peers_reliability_test.ml index 4495cb8fb1b..2aee430d7cd 100644 --- a/src/app/test_executive/peers_reliability_test.ml +++ b/src/app/test_executive/peers_reliability_test.ml @@ -82,7 +82,7 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct section_hard "send a zkApp to create an account" (let%bind parties_create_accounts = let amount = Currency.Amount.of_int 10_000_000_000 in - let nonce = Mina_base.Account.Nonce.zero in + let nonce = Mina_base.Account.Nonce.(succ zero) in let memo = Mina_base.Signed_command_memo.create_from_string_exn "Zkapp create account" From 343e3ce56988f87e61ddeca7bf3193ef951bb03d Mon Sep 17 00:00:00 2001 From: Paul Steckler Date: Tue, 30 Aug 2022 22:37:58 -0700 Subject: [PATCH 037/144] does name matter? --- src/lib/integration_test_lib/event_type.ml | 2 +- src/lib/integration_test_lib/wait_condition.ml | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/lib/integration_test_lib/event_type.ml b/src/lib/integration_test_lib/event_type.ml index f5fb9932899..a97a6ac1ea8 100644 --- a/src/lib/integration_test_lib/event_type.ml +++ b/src/lib/integration_test_lib/event_type.ml @@ -247,7 +247,7 @@ end module Persisted_frontier_loaded = struct type t = unit [@@deriving to_yojson] - let name = "persisted_frontier_loaded" + let name = "Persisted_frontier_loaded" let structured_event_id = Transition_frontier.persisted_frontier_loaded_structured_events_id diff --git a/src/lib/integration_test_lib/wait_condition.ml b/src/lib/integration_test_lib/wait_condition.ml index 249fea442ba..792d6901cd8 100644 --- a/src/lib/integration_test_lib/wait_condition.ml +++ b/src/lib/integration_test_lib/wait_condition.ml @@ -73,7 +73,7 @@ struct network_state ~id:Nodes_to_initialize ~description: ( nodes |> List.map ~f:Node.id |> String.concat ~sep:", " - |> Printf.sprintf "[%s] to initialize" ) + |> sprintf "[%s] to initialize" ) ~f:(fun (state : Network_state.t) -> List.for_all nodes ~f:(fun node -> String.Map.find state.node_initialization (Node.id node) @@ -102,7 +102,7 @@ struct (2 * n) + 1 in { id = Blocks_to_be_produced - ; description = Printf.sprintf "%d blocks to be produced" n + ; description = sprintf "%d blocks to be produced" n ; predicate = Network_state_predicate (init, check) ; soft_timeout = Slots soft_timeout_in_slots ; hard_timeout = Slots (soft_timeout_in_slots * 2) @@ -117,8 +117,7 @@ struct else Predicate_continuation initial_height in let description = - Printf.sprintf "chain block height greater than equal to [%d] " - height_growth + sprintf "chain block height greater than equal to [%d] " height_growth in let soft_timeout_in_slots = (2 * height_growth) + 1 in { id = Block_height_growth @@ -151,7 +150,7 @@ struct |> String.concat ~sep:", " in { id = Nodes_to_synchronize - ; description = Printf.sprintf "%s to synchronize" formatted_nodes + ; description = sprintf "%s to synchronize" formatted_nodes ; predicate = Network_state_predicate (check (), check) ; soft_timeout = Slots soft_timeout_in_slots ; hard_timeout = Slots (soft_timeout_in_slots * 2) From 4cf9f1b53c7cbbc738d8de65f2bbc14f0dc85117 Mon Sep 17 00:00:00 2001 From: Gregor Date: Wed, 31 Aug 2022 08:29:36 +0200 Subject: [PATCH 038/144] [snarkyjs] run unit tests in CI --- buildkite/scripts/test-snarkyjs-bindings.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/buildkite/scripts/test-snarkyjs-bindings.sh b/buildkite/scripts/test-snarkyjs-bindings.sh index 22452beda25..140a0e462c9 100755 --- a/buildkite/scripts/test-snarkyjs-bindings.sh +++ b/buildkite/scripts/test-snarkyjs-bindings.sh @@ -12,6 +12,11 @@ make snarkyjs echo "Run SnarkyJS bindings unit tests..." node src/lib/snarky_js_bindings/tests/run-tests.mjs +echo "Run SnarkyJS unit tests..." +cd src/lib/snarky_js_bindings/snarkyjs +npm run test:unit +cd ../../../.. + echo "Build MinaSigner..." make mina_signer @@ -27,4 +32,3 @@ echo "Run SnarkyJS + MinaSigner tests..." node src/lib/snarky_js_bindings/test_module/simple-zkapp-mina-signer.js node src/lib/snarky_js_bindings/test_module/simple-zkapp-mock-apply.js node src/lib/snarky_js_bindings/test_module/inductive-proofs.js -node src/lib/snarky_js_bindings/test_module/to-hash-input.js From d9390fb74b4c501589c5e7c221305d1ba457426f Mon Sep 17 00:00:00 2001 From: Gregor Date: Wed, 31 Aug 2022 08:30:05 +0200 Subject: [PATCH 039/144] [snarkyjs] remove duplicate test --- .../test_module/to-hash-input.js | 151 ------------------ 1 file changed, 151 deletions(-) delete mode 100644 src/lib/snarky_js_bindings/test_module/to-hash-input.js diff --git a/src/lib/snarky_js_bindings/test_module/to-hash-input.js b/src/lib/snarky_js_bindings/test_module/to-hash-input.js deleted file mode 100644 index 7611afa7119..00000000000 --- a/src/lib/snarky_js_bindings/test_module/to-hash-input.js +++ /dev/null @@ -1,151 +0,0 @@ -import { - isReady, - Party, - PrivateKey, - Types, - Field, - Ledger, - UInt64, - UInt32, - Experimental, - Bool, - Permissions, - Sign, - Token, - shutdown, -} from "snarkyjs"; - -await isReady; - -let { asFieldsAndAux, jsLayout, packToFields } = Experimental; - -let party = Party.defaultParty(PrivateKey.random().toPublicKey()); - -// timing -let Timing = asFieldsAndAux( - jsLayout.Party.entries.body.entries.update.entries.timing.inner -); -let timing = party.body.update.timing.value; -timing.initialMinimumBalance = UInt64.one; -timing.vestingPeriod = UInt32.one; -timing.vestingIncrement = UInt64.from(2); -testInput(Timing, Ledger.hashInputFromJson.timing, timing); - -// permissions -let Permissions_ = asFieldsAndAux( - jsLayout.Party.entries.body.entries.update.entries.permissions.inner -); -let permissions = party.body.update.permissions; -permissions.isSome = Bool(true); -permissions.value = { - ...Permissions.default(), - setVerificationKey: Permissions.none(), - setPermissions: Permissions.none(), - receive: Permissions.proof(), -}; -testInput( - Permissions_, - Ledger.hashInputFromJson.permissions, - permissions.value -); - -// update -let Update = asFieldsAndAux(jsLayout.Party.entries.body.entries.update); -let update = party.body.update; - -update.timing.isSome = Bool(true); -update.appState[0].isSome = Bool(true); -update.appState[0].value = Field(9); -update.delegate.isSome = Bool(true); -let delegate = PrivateKey.random().toPublicKey(); -update.delegate.value = delegate; - -party.tokenSymbol.set("BLABLA"); -testInput(Update, Ledger.hashInputFromJson.update, update); - -// account precondition -let AccountPrecondition = asFieldsAndAux( - jsLayout.Party.entries.body.entries.preconditions.entries.account -); -let account = party.body.preconditions.account; -party.account.balance.assertEquals(UInt64.from(1e9)); -party.account.isNew.assertEquals(Bool(true)); -party.account.delegate.assertEquals(delegate); -account.state[0].isSome = Bool(true); -account.state[0].value = Field(9); -testInput( - AccountPrecondition, - Ledger.hashInputFromJson.accountPrecondition, - account -); - -// network precondition -let NetworkPrecondition = asFieldsAndAux( - jsLayout.Party.entries.body.entries.preconditions.entries.network -); -let network = party.body.preconditions.network; -party.network.stakingEpochData.ledger.hash.assertEquals(Field.random()); -party.network.nextEpochData.lockCheckpoint.assertEquals(Field.random()); - -testInput( - NetworkPrecondition, - Ledger.hashInputFromJson.networkPrecondition, - network -); - -// body -let Body = asFieldsAndAux(jsLayout.Party.entries.body); -let body = party.body; -body.balanceChange.magnitude = UInt64.from(14197832); -body.balanceChange.sgn = Sign.minusOne; -body.callData = Field.random(); -body.callDepth = 1; -body.incrementNonce = Bool(true); -let tokenOwner = PrivateKey.random().toPublicKey(); -body.tokenId = new Token({ tokenOwner }).id; -body.caller = body.tokenId; -testInput(Body, Ledger.hashInputFromJson.body, body); - -// party (should be same as body) -testInput( - Types.Party, - (partyJson) => - Ledger.hashInputFromJson.body(JSON.stringify(JSON.parse(partyJson).body)), - party -); - -console.log("all hash inputs are consistent! 🎉"); -shutdown(); - -function testInput(Module, toInputOcaml, value) { - let json = Module.toJSON(value); - // console.log(json); - let input1 = inputFromOcaml(toInputOcaml(JSON.stringify(json))); - let input2 = Module.toInput(value); - // console.log('snarkyjs', JSON.stringify(input2)); - // console.log(); - // console.log('protocol', JSON.stringify(input1)); - let ok1 = JSON.stringify(input2) === JSON.stringify(input1); - // console.log('ok?', ok1); - let fields1 = Ledger.hashInputFromJson.packInput(inputToOcaml(input1)); - let fields2 = packToFields(input2); - let ok2 = JSON.stringify(fields1) === JSON.stringify(fields2); - // console.log('packed ok?', ok2); - // console.log(); - if (!ok1 || !ok2) { - throw Error("inconsistent toInput"); - } -} - -function inputFromOcaml({ fields, packed }) { - return { - fields, - packed: packed.map(({ field, size }) => [field, size]), - }; -} -function inputToOcaml({ fields, packed }) { - return { - fields, - packed: packed.map(([field, size]) => ({ field, size })), - }; -} From 0efc821f03dee0cb299b8c0ff2c637a28e55e4f5 Mon Sep 17 00:00:00 2001 From: Gregor Date: Wed, 31 Aug 2022 08:33:55 +0200 Subject: [PATCH 040/144] bump snarkyjs --- src/lib/snarky_js_bindings/snarkyjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/snarky_js_bindings/snarkyjs b/src/lib/snarky_js_bindings/snarkyjs index 4e8f94fa722..b3990ce4e27 160000 --- a/src/lib/snarky_js_bindings/snarkyjs +++ b/src/lib/snarky_js_bindings/snarkyjs @@ -1 +1 @@ -Subproject commit 4e8f94fa722f2dc6ce743d0a3924cb68f0f77733 +Subproject commit b3990ce4e273a7486689319098f7c97a2a0dc183 From 9449c4d932ac05e2c079b9b29c8a5f47c31d492f Mon Sep 17 00:00:00 2001 From: Tang Jiawei Date: Wed, 31 Aug 2022 19:02:44 +0800 Subject: [PATCH 041/144] adding nightly env variable --- buildkite/src/Constants/ContainerEnvVars.dhall | 1 + 1 file changed, 1 insertion(+) diff --git a/buildkite/src/Constants/ContainerEnvVars.dhall b/buildkite/src/Constants/ContainerEnvVars.dhall index bf68d18205d..5ee60afb1a4 100644 --- a/buildkite/src/Constants/ContainerEnvVars.dhall +++ b/buildkite/src/Constants/ContainerEnvVars.dhall @@ -45,5 +45,6 @@ , "BUILDKITE_AGENT_META_DATA_QUEUE" , "BUILDKITE_TIMEOUT" , "BUILDKITE_STEP_IDENTIFIER" +, "NIGHTLY" ] From 9fe14f022e1fcabea7ce2fecf28c885b9afec259 Mon Sep 17 00:00:00 2001 From: Yves-Stan Le Cornec Date: Thu, 1 Sep 2022 16:44:21 +0200 Subject: [PATCH 042/144] fix generation of zkapp_test coverage --- src/app/archive/archive_lib/load_data.ml | 112 +++++++++++++---------- src/lib/consensus/proof_of_stake.ml | 6 +- 2 files changed, 66 insertions(+), 52 deletions(-) diff --git a/src/app/archive/archive_lib/load_data.ml b/src/app/archive/archive_lib/load_data.ml index cbc2a280ec8..6cebf2aa2e8 100644 --- a/src/app/archive/archive_lib/load_data.ml +++ b/src/app/archive/archive_lib/load_data.ml @@ -28,11 +28,11 @@ let account_identifier_of_id pool account_identifier_id = let get_amount_bounds pool amount_id = let open Zkapp_basic in - let query_db = Mina_caqti.query pool in let%map amount_db_opt = Option.value_map amount_id ~default:(return None) ~f:(fun id -> let%map amount = - query_db ~f:(fun db -> Processor.Zkapp_amount_bounds.load db id) + Mina_caqti.query pool ~f:(fun db -> + Processor.Zkapp_amount_bounds.load db id ) in Some amount ) in @@ -48,11 +48,11 @@ let get_amount_bounds pool amount_id = let get_global_slot_bounds pool id = let open Zkapp_basic in - let query_db = Mina_caqti.query pool in let%map bounds_opt = Option.value_map id ~default:(return None) ~f:(fun id -> let%map bounds = - query_db ~f:(fun db -> Processor.Zkapp_global_slot_bounds.load db id) + Mina_caqti.query pool ~f:(fun db -> + Processor.Zkapp_global_slot_bounds.load db id ) in let slot_of_int64 int64 = int64 |> Unsigned.UInt32.of_int64 @@ -66,11 +66,11 @@ let get_global_slot_bounds pool id = let get_length_bounds pool id = let open Zkapp_basic in - let query_db = Mina_caqti.query pool in let%map bl_db_opt = Option.value_map id ~default:(return None) ~f:(fun id -> let%map ts = - query_db ~f:(fun db -> Processor.Zkapp_length_bounds.load db id) + Mina_caqti.query pool ~f:(fun db -> + Processor.Zkapp_length_bounds.load db id ) in Some ts ) in @@ -85,7 +85,6 @@ let get_length_bounds pool id = let update_of_id pool update_id = let open Zkapp_basic in - let query_db = Mina_caqti.query pool in let with_pool ~f arg = let open Caqti_async in Pool.use @@ -101,7 +100,8 @@ let update_of_id pool update_id = ; timing_id ; voting_for_id } = - query_db ~f:(fun db -> Processor.Zkapp_updates.load db update_id) + Mina_caqti.query pool ~f:(fun db -> + Processor.Zkapp_updates.load db update_id ) in let%bind app_state = let%bind { element0 @@ -113,7 +113,7 @@ let update_of_id pool update_id = ; element6 ; element7 } = - query_db ~f:(fun db -> + Mina_caqti.query pool ~f:(fun db -> Processor.Zkapp_states_nullable.load db app_state_id ) in let field_ids = @@ -131,7 +131,8 @@ let update_of_id pool update_id = Deferred.List.map field_ids ~f:(fun id_opt -> Option.value_map id_opt ~default:(return None) ~f:(fun id -> let%map field = - query_db ~f:(fun db -> Processor.Zkapp_state_data.load db id) + Mina_caqti.query pool ~f:(fun db -> + Processor.Zkapp_state_data.load db id ) in Some field ) ) in @@ -154,7 +155,8 @@ let update_of_id pool update_id = let%map vk_opt = Option.value_map verification_key_id ~default:(return None) ~f:(fun id -> let%map vk = - query_db ~f:(fun db -> Processor.Zkapp_verification_keys.load db id) + Mina_caqti.query pool ~f:(fun db -> + Processor.Zkapp_verification_keys.load db id ) in Some vk ) in @@ -188,7 +190,8 @@ let update_of_id pool update_id = ; increment_nonce ; set_voting_for } = - query_db ~f:(fun db -> Processor.Zkapp_permissions.load db id) + Mina_caqti.query pool ~f:(fun db -> + Processor.Zkapp_permissions.load db id ) in (* same fields, different types *) Some @@ -225,7 +228,8 @@ let update_of_id pool update_id = ; vesting_period ; vesting_increment } = - query_db ~f:(fun db -> Processor.Zkapp_timing_info.load db id) + Mina_caqti.query pool ~f:(fun db -> + Processor.Zkapp_timing_info.load db id ) in let initial_minimum_balance = Currency.Balance.of_string initial_minimum_balance @@ -274,25 +278,25 @@ let update_of_id pool update_id = let staking_data_of_id pool id = let open Zkapp_basic in - let query_db = Mina_caqti.query pool in let%bind { epoch_ledger_id ; epoch_seed ; start_checkpoint ; lock_checkpoint ; epoch_length_id } = - query_db ~f:(fun db -> Processor.Zkapp_epoch_data.load db id) + Mina_caqti.query pool ~f:(fun db -> Processor.Zkapp_epoch_data.load db id) in let%bind ledger = let%bind { hash_id; total_currency_id } = - query_db ~f:(fun db -> + Mina_caqti.query pool ~f:(fun db -> Processor.Zkapp_epoch_ledger.load db epoch_ledger_id ) in let%bind hash = let%map hash_opt = Option.value_map hash_id ~default:(return None) ~f:(fun id -> let%map hash_str = - query_db ~f:(fun db -> Processor.Snarked_ledger_hash.load db id) + Mina_caqti.query pool ~f:(fun db -> + Processor.Snarked_ledger_hash.load db id ) in Some (Frozen_ledger_hash.of_base58_check_exn hash_str) ) in @@ -323,7 +327,6 @@ let staking_data_of_id pool id = let protocol_state_precondition_of_id pool id = let open Zkapp_basic in - let query_db = Mina_caqti.query pool in let%bind ({ snarked_ledger_hash_id ; timestamp_id ; blockchain_length_id @@ -335,14 +338,16 @@ let protocol_state_precondition_of_id pool id = ; next_epoch_data_id } : Processor.Zkapp_network_precondition.t ) = - query_db ~f:(fun db -> Processor.Zkapp_network_precondition.load db id) + Mina_caqti.query pool ~f:(fun db -> + Processor.Zkapp_network_precondition.load db id ) in let%bind snarked_ledger_hash = let%map hash_opt = Option.value_map snarked_ledger_hash_id ~default:(return None) ~f:(fun id -> let%map hash = - query_db ~f:(fun db -> Processor.Snarked_ledger_hash.load db id) + Mina_caqti.query pool ~f:(fun db -> + Processor.Snarked_ledger_hash.load db id ) in Some (Frozen_ledger_hash.of_base58_check_exn hash) ) in @@ -352,7 +357,8 @@ let protocol_state_precondition_of_id pool id = let%map ts_db_opt = Option.value_map timestamp_id ~default:(return None) ~f:(fun id -> let%map ts = - query_db ~f:(fun db -> Processor.Zkapp_timestamp_bounds.load db id) + Mina_caqti.query pool ~f:(fun db -> + Processor.Zkapp_timestamp_bounds.load db id ) in Some ts ) in @@ -390,20 +396,19 @@ let protocol_state_precondition_of_id pool id = : Zkapp_precondition.Protocol_state.t ) let load_events pool id = - let query_db = Mina_caqti.query pool in let%map fields_list = (* each id refers to an item in 'zkapp_state_data_array' *) let%bind field_array_ids = - query_db ~f:(fun db -> Processor.Zkapp_events.load db id) + Mina_caqti.query pool ~f:(fun db -> Processor.Zkapp_events.load db id) in Deferred.List.map (Array.to_list field_array_ids) ~f:(fun array_id -> let%bind field_ids = - query_db ~f:(fun db -> + Mina_caqti.query pool ~f:(fun db -> Processor.Zkapp_state_data_array.load db array_id ) in Deferred.List.map (Array.to_list field_ids) ~f:(fun field_id -> let%map field_str = - query_db ~f:(fun db -> + Mina_caqti.query pool ~f:(fun db -> Processor.Zkapp_state_data.load db field_id ) in Zkapp_basic.F.of_string field_str ) ) @@ -411,9 +416,9 @@ let load_events pool id = List.map fields_list ~f:Array.of_list let get_fee_payer_body ~pool body_id = - let query_db = Mina_caqti.query pool in let%bind { account_identifier_id; fee; valid_until; nonce } = - query_db ~f:(fun db -> Processor.Zkapp_fee_payer_body.load db body_id) + Mina_caqti.query pool ~f:(fun db -> + Processor.Zkapp_fee_payer_body.load db body_id ) in let%bind account_id = account_identifier_of_id pool account_identifier_id in let public_key = Account_id.public_key account_id in @@ -430,7 +435,6 @@ let get_fee_payer_body ~pool body_id = let get_other_party_body ~pool body_id = let open Zkapp_basic in - let query_db = Mina_caqti.query pool in let pk_of_id = pk_of_id pool in let%bind { account_identifier_id ; update_id @@ -445,7 +449,8 @@ let get_other_party_body ~pool body_id = ; use_full_commitment ; caller } = - query_db ~f:(fun db -> Processor.Zkapp_other_party_body.load db body_id) + Mina_caqti.query pool ~f:(fun db -> + Processor.Zkapp_other_party_body.load db body_id ) in let%bind account_id = account_identifier_of_id pool account_identifier_id in let public_key = Account_id.public_key account_id in @@ -467,7 +472,8 @@ let get_other_party_body ~pool body_id = let%bind sequence_events = load_events pool sequence_events_id in let%bind call_data = let%map field_str = - query_db ~f:(fun db -> Processor.Zkapp_state_data.load db call_data_id) + Mina_caqti.query pool ~f:(fun db -> + Processor.Zkapp_state_data.load db call_data_id ) in Zkapp_basic.F.of_string field_str in @@ -477,7 +483,7 @@ let get_other_party_body ~pool body_id = let%bind account_precondition = let%bind ({ kind; precondition_account_id; nonce } : Processor.Zkapp_account_precondition.t ) = - query_db ~f:(fun db -> + Mina_caqti.query pool ~f:(fun db -> Processor.Zkapp_account_precondition.load db zkapp_account_precondition_id ) in @@ -502,7 +508,7 @@ let get_other_party_body ~pool body_id = ; proved_state ; is_new } = - query_db ~f:(fun db -> + Mina_caqti.query pool ~f:(fun db -> Processor.Zkapp_precondition_account.load db (Option.value_exn precondition_account_id) ) in @@ -510,7 +516,7 @@ let get_other_party_body ~pool body_id = let%map balance_opt = Option.value_map balance_id ~default:(return None) ~f:(fun id -> let%map { balance_lower_bound; balance_upper_bound } = - query_db ~f:(fun db -> + Mina_caqti.query pool ~f:(fun db -> Processor.Zkapp_balance_bounds.load db id ) in let lower = Currency.Balance.of_string balance_lower_bound in @@ -523,7 +529,7 @@ let get_other_party_body ~pool body_id = let%map nonce_opt = Option.value_map nonce_id ~default:(return None) ~f:(fun id -> let%map { nonce_lower_bound; nonce_upper_bound } = - query_db ~f:(fun db -> + Mina_caqti.query pool ~f:(fun db -> Processor.Zkapp_nonce_bounds.load db id ) in let balance_of_int64 int64 = @@ -560,7 +566,7 @@ let get_other_party_body ~pool body_id = ; element6 ; element7 } = - query_db ~f:(fun db -> + Mina_caqti.query pool ~f:(fun db -> Processor.Zkapp_states_nullable.load db state_id ) in let elements = @@ -578,7 +584,7 @@ let get_other_party_body ~pool body_id = Deferred.List.map elements ~f:(fun id_opt -> Option.value_map id_opt ~default:(return None) ~f:(fun id -> let%map field_str = - query_db ~f:(fun db -> + Mina_caqti.query pool ~f:(fun db -> Processor.Zkapp_state_data.load db id ) in Some (Zkapp_basic.F.of_string field_str) ) ) @@ -590,7 +596,8 @@ let get_other_party_body ~pool body_id = Option.value_map sequence_state_id ~default:(return None) ~f:(fun id -> let%map field_str = - query_db ~f:(fun db -> Processor.Zkapp_state_data.load db id) + Mina_caqti.query pool ~f:(fun db -> + Processor.Zkapp_state_data.load db id ) in Some (Zkapp_basic.F.of_string field_str) ) in @@ -632,7 +639,6 @@ let get_other_party_body ~pool body_id = let get_account_accessed ~pool (account : Processor.Accounts_accessed.t) : (int * Account.t) Deferred.t = - let query_db = Mina_caqti.query pool in let with_pool ~f arg = let open Caqti_async in Pool.use @@ -658,13 +664,14 @@ let get_account_accessed ~pool (account : Processor.Accounts_accessed.t) : account in let%bind ({ public_key_id; token_id } : Processor.Account_identifiers.t) = - query_db ~f:(fun db -> + Mina_caqti.query pool ~f:(fun db -> Processor.Account_identifiers.load db account_identifier_id ) in let%bind public_key = pk_of_id public_key_id in let%bind token_id = token_of_id token_id in let%bind token_symbol = - query_db ~f:(fun db -> Processor.Token_symbols.load db token_symbol_id) + Mina_caqti.query pool ~f:(fun db -> + Processor.Token_symbols.load db token_symbol_id ) in let balance = Currency.Balance.of_string balance in let nonce = nonce |> Unsigned.UInt32.of_int64 |> Account.Nonce.of_uint32 in @@ -681,13 +688,15 @@ let get_account_accessed ~pool (account : Processor.Accounts_accessed.t) : in let%bind voting_for = let%map hash_str = - query_db ~f:(fun db -> Processor.Voting_for.load db voting_for_id) + Mina_caqti.query pool ~f:(fun db -> + Processor.Voting_for.load db voting_for_id ) in State_hash.of_base58_check_exn hash_str in let%bind timing = match%map - query_db ~f:(fun db -> Processor.Timing_info.load_opt db timing_id) + Mina_caqti.query pool ~f:(fun db -> + Processor.Timing_info.load_opt db timing_id ) with | None -> Account_timing.Untimed @@ -743,7 +752,8 @@ let get_account_accessed ~pool (account : Processor.Accounts_accessed.t) : ; increment_nonce ; set_voting_for } = - query_db ~f:(fun db -> Processor.Zkapp_permissions.load db permissions_id) + Mina_caqti.query pool ~f:(fun db -> + Processor.Zkapp_permissions.load db permissions_id ) in ( { edit_state ; send @@ -784,7 +794,8 @@ let get_account_accessed ~pool (account : Processor.Accounts_accessed.t) : ; element6 ; element7 } = - query_db ~f:(fun db -> Processor.Zkapp_states.load db app_state_id) + Mina_caqti.query pool ~f:(fun db -> + Processor.Zkapp_states.load db app_state_id ) in let elements = [ element0 @@ -800,7 +811,8 @@ let get_account_accessed ~pool (account : Processor.Accounts_accessed.t) : let%bind app_state = let%map field_strs = Deferred.List.map elements ~f:(fun id -> - query_db ~f:(fun db -> Processor.Zkapp_state_data.load db id) ) + Mina_caqti.query pool ~f:(fun db -> + Processor.Zkapp_state_data.load db id ) ) in let fields = List.map field_strs ~f:Zkapp_basic.F.of_string in Zkapp_state.V.of_list_exn fields @@ -809,7 +821,7 @@ let get_account_accessed ~pool (account : Processor.Accounts_accessed.t) : Option.value_map verification_key_id ~default:(return None) ~f:(fun id -> let%map { verification_key; hash } = - query_db ~f:(fun db -> + Mina_caqti.query pool ~f:(fun db -> Processor.Zkapp_verification_keys.load db id ) in let data = @@ -830,14 +842,15 @@ let get_account_accessed ~pool (account : Processor.Accounts_accessed.t) : |> Mina_numbers.Zkapp_version.of_uint32 in let%bind { element0; element1; element2; element3; element4 } = - query_db ~f:(fun db -> + Mina_caqti.query pool ~f:(fun db -> Processor.Zkapp_sequence_states.load db sequence_state_id ) in let elements = [ element0; element1; element2; element3; element4 ] in let%map sequence_state = let%map field_strs = Deferred.List.map elements ~f:(fun id -> - query_db ~f:(fun db -> Processor.Zkapp_state_data.load db id) ) + Mina_caqti.query pool ~f:(fun db -> + Processor.Zkapp_state_data.load db id ) ) in let fields = List.map field_strs ~f:Zkapp_basic.F.of_string in Pickles_types.Vector.Vector_5.of_list_exn fields @@ -860,7 +873,8 @@ let get_account_accessed ~pool (account : Processor.Accounts_accessed.t) : let%bind zkapp_uri = Option.value_map zkapp_db ~default:(return "https://dummy.com") ~f:(fun zkapp -> - query_db ~f:(fun db -> Processor.Zkapp_uri.load db zkapp.zkapp_uri_id) ) + Mina_caqti.query pool ~f:(fun db -> + Processor.Zkapp_uri.load db zkapp.zkapp_uri_id ) ) in (* TODO: token permissions is going away *) let account = diff --git a/src/lib/consensus/proof_of_stake.ml b/src/lib/consensus/proof_of_stake.ml index ca12209be43..187dc7873ad 100644 --- a/src/lib/consensus/proof_of_stake.ml +++ b/src/lib/consensus/proof_of_stake.ml @@ -1361,8 +1361,8 @@ module Data = struct in if_ (prev_relative_sub_window < next_relative_sub_window) - ~then_:Boolean.(gt_prev_sub_window && lt_next_sub_window) - ~else_:Boolean.(gt_prev_sub_window || lt_next_sub_window)) + ~then_:Boolean.(gt_prev_sub_window &&& lt_next_sub_window) + ~else_:Boolean.(gt_prev_sub_window ||| lt_next_sub_window)) in if_ (Checked.return same_sub_window) @@ -1385,7 +1385,7 @@ module Data = struct (Length.Checked.to_field constants.grace_period_end) ) ) in if_ - Boolean.(same_sub_window || in_grace_period) + Boolean.(same_sub_window ||| in_grace_period) ~then_:(Checked.return prev_min_window_density) ~else_: (Length.Checked.min current_window_density prev_min_window_density) From 4598a23c57ba7874575b34f687cefbea61c7ed3d Mon Sep 17 00:00:00 2001 From: Fabrizio Date: Thu, 1 Sep 2022 16:53:52 -0300 Subject: [PATCH 043/144] interface wip --- .../crypto/kimchi_backend/common/bigint.mli | 134 ++++++++++++++++++ .../common/kimchi_backend_common.ml | 15 ++ src/lib/crypto/kimchi_backend/dune | 35 +++-- .../crypto/kimchi_backend/kimchi_backend.ml | 31 +++- .../crypto/kimchi_backend/kimchi_backend.mli | 25 ++++ src/lib/crypto/kimchi_backend/pasta/dune | 35 +++-- .../kimchi_backend/pasta/kimchi_pasta.ml | 66 +++++++++ src/lib/crypto/kimchi_backend/pasta/pasta.ml | 1 - src/lib/crypto/kimchi_backend/pasta/pasta.mli | 11 ++ .../kimchi_backend/pasta/precomputed.mli | 9 ++ 10 files changed, 323 insertions(+), 39 deletions(-) create mode 100644 src/lib/crypto/kimchi_backend/common/bigint.mli create mode 100644 src/lib/crypto/kimchi_backend/common/kimchi_backend_common.ml create mode 100644 src/lib/crypto/kimchi_backend/kimchi_backend.mli create mode 100644 src/lib/crypto/kimchi_backend/pasta/kimchi_pasta.ml create mode 100644 src/lib/crypto/kimchi_backend/pasta/pasta.mli create mode 100644 src/lib/crypto/kimchi_backend/pasta/precomputed.mli diff --git a/src/lib/crypto/kimchi_backend/common/bigint.mli b/src/lib/crypto/kimchi_backend/common/bigint.mli new file mode 100644 index 00000000000..8b529d4109c --- /dev/null +++ b/src/lib/crypto/kimchi_backend/common/bigint.mli @@ -0,0 +1,134 @@ +module type Bindings = sig + type t + + val num_limbs : unit -> int + + val bytes_per_limb : unit -> int + + val compare : t -> t -> int + + val div : t -> t -> t + + val test_bit : t -> int -> bool + + val print : t -> unit + + val to_string : t -> string + + val of_numeral : string -> int -> int -> t + + val of_decimal_string : string -> t + + val to_bytes : t -> bytes + + val of_bytes : bytes -> t +end + +module type Intf = sig + type t + + val bin_size_t : t Bin_prot.Size.sizer + + val bin_write_t : t Bin_prot.Write.writer + + val bin_read_t : t Bin_prot.Read.reader + + val __bin_read_t__ : (int -> t) Bin_prot.Read.reader + + val bin_shape_t : Bin_prot.Shape.t + + val bin_writer_t : t Bin_prot.Type_class.writer + + val bin_reader_t : t Bin_prot.Type_class.reader + + val bin_t : t Bin_prot.Type_class.t + + val t_of_sexp : Ppx_sexp_conv_lib.Sexp.t -> t + + val sexp_of_t : t -> Ppx_sexp_conv_lib.Sexp.t + + val compare : t -> t -> int + + val div : t -> t -> t + + val test_bit : t -> int -> bool + + val print : t -> unit + + val to_string : t -> string + + val of_decimal_string : string -> t + + val to_bytes : t -> bytes + + val of_bytes : bytes -> t + + val num_limbs : int + + val bytes_per_limb : int + + val length_in_bytes : int + + val to_hex_string : t -> string + + val of_hex_string : ?reverse:bool -> string -> t + + val of_numeral : string -> base:int -> t +end + +module Make : functor + (B : Bindings) + (M : sig + val length_in_bytes : int + end) + -> sig + type t = B.t + + val bin_size_t : t Bin_prot.Size.sizer + + val bin_write_t : t Bin_prot.Write.writer + + val bin_read_t : t Bin_prot.Read.reader + + val __bin_read_t__ : (int -> t) Bin_prot.Read.reader + + val bin_shape_t : Bin_prot.Shape.t + + val bin_writer_t : t Bin_prot.Type_class.writer + + val bin_reader_t : t Bin_prot.Type_class.reader + + val bin_t : t Bin_prot.Type_class.t + + val t_of_sexp : Ppx_sexp_conv_lib.Sexp.t -> t + + val sexp_of_t : t -> Ppx_sexp_conv_lib.Sexp.t + + val compare : t -> t -> int + + val div : t -> t -> t + + val test_bit : t -> int -> bool + + val print : t -> unit + + val to_string : t -> string + + val of_decimal_string : string -> t + + val to_bytes : t -> bytes + + val of_bytes : bytes -> t + + val num_limbs : int + + val bytes_per_limb : int + + val length_in_bytes : int + + val to_hex_string : t -> string + + val of_hex_string : ?reverse:bool -> string -> t + + val of_numeral : string -> base:int -> t +end diff --git a/src/lib/crypto/kimchi_backend/common/kimchi_backend_common.ml b/src/lib/crypto/kimchi_backend/common/kimchi_backend_common.ml new file mode 100644 index 00000000000..8d36e7f64be --- /dev/null +++ b/src/lib/crypto/kimchi_backend/common/kimchi_backend_common.ml @@ -0,0 +1,15 @@ +module Bigint = Bigint +module Field = Field +module Curve = Curve +module Poly_comm = Poly_comm +module Plonk_constraint_system = Plonk_constraint_system +module Dlog_plonk_based_keypair = Dlog_plonk_based_keypair +module Constants = Constants +module Plonk_dlog_proof = Plonk_dlog_proof +module Plonk_dlog_oracles = Plonk_dlog_oracles +module Var = Var +module Scalar_challenge = Scalar_challenge +module Endoscale_round = Endoscale_round +module Scale_round = Scale_round +module Endoscale_scalar_round = Endoscale_scalar_round +module Intf = Intf \ No newline at end of file diff --git a/src/lib/crypto/kimchi_backend/dune b/src/lib/crypto/kimchi_backend/dune index 5b3bed2b41a..5cf761973b5 100644 --- a/src/lib/crypto/kimchi_backend/dune +++ b/src/lib/crypto/kimchi_backend/dune @@ -8,21 +8,20 @@ (preprocess (pps ppx_version ppx_jane ppx_deriving_yojson ppx_deriving.std)) (libraries - ;; opam libraries - integers - core_kernel - ppx_inline_test.config - ;; local libraries - kimchi_bindings - kimchi_types - pasta_bindings - snarkette - snarky.backendless - key_cache - hex - kimchi_backend.common - kimchi_backend.pasta - pickles_types - sponge - snarky.intf -)) + ;; opam libraries + integers + core_kernel + ppx_inline_test.config + ;; local libraries + kimchi_bindings + kimchi_types + pasta_bindings + snarkette + snarky.backendless + key_cache + hex + kimchi_backend.common + kimchi_backend.pasta + pickles_types + sponge + snarky.intf)) diff --git a/src/lib/crypto/kimchi_backend/kimchi_backend.ml b/src/lib/crypto/kimchi_backend/kimchi_backend.ml index 0b661fde39d..25f236126a3 100644 --- a/src/lib/crypto/kimchi_backend/kimchi_backend.ml +++ b/src/lib/crypto/kimchi_backend/kimchi_backend.ml @@ -1,3 +1,30 @@ -module Kimchi_backend_common = Kimchi_backend_common +module Kimchi_backend_common = struct + (* module Bigint = Kimchi_backend_common.Bigint *) + module Field = Kimchi_backend_common.Field + + (* module Curve = Kimchi_backend_common.Curve *) + (* module Poly_comm = Kimchi_backend_common.Poly_comm *) + (* module Plonk_constraint_system = Kimchi_backend_common.Plonk_constraint_system *) + (* module Dlog_plonk_based_keypair = *) + (* Kimchi_backend_common.Dlog_plonk_based_keypair *) + (* module Constants = Kimchi_backend_common.Constants *) + (* module Plonk_dlog_proof = Kimchi_backend_common.Plonk_dlog_proof *) + (* module Plonk_dlog_oracles = Kimchi_backend_common.Plonk_dlog_oracles *) + (* module Var = Kimchi_backend_common.Var *) + (* module Intf = Kimchi_backend_common.Intf *) + (* module Scalar_challenge = Kimchi_backend_common.Scalar_challenge *) + module Scalar_challenge = Kimchi_backend_common.Scalar_challenge + (* module Endoscale_round = Kimchi_backend_common.Endoscale_round *) + (* module Scale_round = Kimchi_backend_common.Scale_round *) + (* module Endoscale_scalar_round = Kimchi_backend_common.Endoscale_scalar_round *) +end + module Field = Kimchi_backend_common.Field -module Pasta = Kimchi_pasta + +module Pasta = struct + module Basic = Kimchi_pasta.Basic + module Pallas_based_plonk = Kimchi_pasta.Pallas_based_plonk + module Pasta = Kimchi_pasta.Pasta + module Precomputed = Kimchi_pasta.Precomputed + module Vesta_based_plonk = Kimchi_pasta.Vesta_based_plonk +end diff --git a/src/lib/crypto/kimchi_backend/kimchi_backend.mli b/src/lib/crypto/kimchi_backend/kimchi_backend.mli new file mode 100644 index 00000000000..4669c331290 --- /dev/null +++ b/src/lib/crypto/kimchi_backend/kimchi_backend.mli @@ -0,0 +1,25 @@ +module Kimchi_backend_common : sig + module Field : sig + (* module Bignum_bigint = Snarky_backendless.Backend_extended.Bignum_bigint *) + + (* module type Input_intf = Kimchi_backend_common.Field.Input_intf *) + + module type S = Kimchi_backend_common.Field.S + + (* module type S_with_version = Kimchi_backend_common.Field.S_with_version *) + + (* module Make = Kimchi_backend_common.Field.Make *) + end + + module Scalar_challenge = Kimchi_backend_common.Scalar_challenge +end + +module Field = Kimchi_backend_common.Field + +module Pasta : sig + module Basic = Kimchi_pasta.Basic + module Pallas_based_plonk = Kimchi_pasta.Pallas_based_plonk + module Pasta = Kimchi_pasta.Pasta + module Precomputed = Kimchi_pasta.Precomputed + module Vesta_based_plonk = Kimchi_pasta.Vesta_based_plonk +end diff --git a/src/lib/crypto/kimchi_backend/pasta/dune b/src/lib/crypto/kimchi_backend/pasta/dune index f97c4beb262..23af80fba42 100644 --- a/src/lib/crypto/kimchi_backend/pasta/dune +++ b/src/lib/crypto/kimchi_backend/pasta/dune @@ -6,22 +6,21 @@ (instrumentation (backend bisect_ppx)) (preprocess - (pps ppx_version ppx_jane ppx_deriving_yojson ppx_deriving.std)) + (pps ppx_version ppx_jane ppx_deriving_yojson ppx_deriving.std h_list.ppx)) (libraries - ;; opam libraries - ppx_inline_test.config - sexplib0 - core_kernel - bin_prot.shape - base.caml - ;; local libraries - sponge - pickles_types - kimchi_backend.common - promise - kimchi_bindings - kimchi_types - pasta_bindings - snarkette - ppx_version.runtime -)) + ;; opam libraries + ppx_inline_test.config + sexplib0 + core_kernel + bin_prot.shape + base.caml + ;; local libraries + sponge + pickles_types + kimchi_backend.common + promise + kimchi_bindings + kimchi_types + pasta_bindings + snarkette + ppx_version.runtime)) diff --git a/src/lib/crypto/kimchi_backend/pasta/kimchi_pasta.ml b/src/lib/crypto/kimchi_backend/pasta/kimchi_pasta.ml new file mode 100644 index 00000000000..e627940570a --- /dev/null +++ b/src/lib/crypto/kimchi_backend/pasta/kimchi_pasta.ml @@ -0,0 +1,66 @@ +module Pallas_based_plonk = struct + module Field = Pallas_based_plonk.Field + module Curve = Pallas_based_plonk.Curve + module Bigint = Pallas_based_plonk.Bigint + + let field_size = Pallas_based_plonk.field_size + + (* let lagrange = Vesta_based_plonk.lagrange *) + (* let with_lagrange = Vesta_based_plonk.with_lagrange *) + (* let with_lagranges = Vesta_based_plonk.with_lagranges *) + + module Verification_key = Pallas_based_plonk.Verification_key + module R1CS_constraint_system = Pallas_based_plonk.R1CS_constraint_system + module Var = Pallas_based_plonk.Var + module Rounds_vector = Pallas_based_plonk.Rounds_vector + module Rounds = Pallas_based_plonk.Rounds + module Keypair = Pallas_based_plonk.Keypair + module Proof = Pallas_based_plonk.Proof + module Proving_key = Pallas_based_plonk.Proving_key + module Oracles = Pallas_based_plonk.Oracles +end + +module Vesta_based_plonk = struct + module Field = Vesta_based_plonk.Field + module Curve = Vesta_based_plonk.Curve + module Bigint = Vesta_based_plonk.Bigint + + let field_size = Vesta_based_plonk.field_size + + (* let lagrange = Vesta_based_plonk.lagrange *) + (* let with_lagrange = Vesta_based_plonk.with_lagrange *) + (* let with_lagranges = Vesta_based_plonk.with_lagranges *) + + module Verification_key = Vesta_based_plonk.Verification_key + module R1CS_constraint_system = Vesta_based_plonk.R1CS_constraint_system + module Var = Vesta_based_plonk.Var + module Rounds_vector = Vesta_based_plonk.Rounds_vector + module Rounds = Vesta_based_plonk.Rounds + module Keypair = Vesta_based_plonk.Keypair + module Proof = Vesta_based_plonk.Proof + module Proving_key = Vesta_based_plonk.Proving_key + module Oracles = Vesta_based_plonk.Oracles +end + +module Pasta = struct + module Rounds = Pasta.Rounds + module Bigint256 = Pasta.Bigint256 + module Fp = Pasta.Fp + module Fq = Pasta.Fq + module Vesta = Pasta.Vesta + module Pallas = Pasta.Pallas + module Precomputed = Pasta.Precomputed +end + +module Basic = struct + module Rounds = Basic.Rounds + module Bigint256 = Basic.Bigint256 + module Fp = Basic.Fp + (* module Fq = Basic.Fq *) + (* module Vesta = Basic.Vesta *) + (* module Pallas = Basic.Pallas *) + (* module Fq_poly_comm = Basic.Fq_poly_comm *) + (* module Fp_poly_comm = Basic.Fp_poly_comm *) +end + +module Precomputed = Precomputed diff --git a/src/lib/crypto/kimchi_backend/pasta/pasta.ml b/src/lib/crypto/kimchi_backend/pasta/pasta.ml index b357410f03d..12e73aade8d 100644 --- a/src/lib/crypto/kimchi_backend/pasta/pasta.ml +++ b/src/lib/crypto/kimchi_backend/pasta/pasta.ml @@ -1,4 +1,3 @@ include Basic -module Vesta_based_plonk = Vesta_based_plonk module Pallas_based_plonk = Pallas_based_plonk module Precomputed = Precomputed diff --git a/src/lib/crypto/kimchi_backend/pasta/pasta.mli b/src/lib/crypto/kimchi_backend/pasta/pasta.mli new file mode 100644 index 00000000000..a8a8ac7404e --- /dev/null +++ b/src/lib/crypto/kimchi_backend/pasta/pasta.mli @@ -0,0 +1,11 @@ +module Rounds = Basic.Rounds +module Bigint256 = Basic.Bigint256 +module Fp = Basic.Fp +module Fq = Basic.Fq +module Vesta = Basic.Vesta +module Pallas = Basic.Pallas + +(* module Fq_poly_comm = Basic.Fq_poly_comm *) +(* module Fp_poly_comm = Basic.Fp_poly_comm *) +(* module Pallas_based_plonk = Pallas_based_plonk *) +module Precomputed = Precomputed diff --git a/src/lib/crypto/kimchi_backend/pasta/precomputed.mli b/src/lib/crypto/kimchi_backend/pasta/precomputed.mli new file mode 100644 index 00000000000..4500e6c5d08 --- /dev/null +++ b/src/lib/crypto/kimchi_backend/pasta/precomputed.mli @@ -0,0 +1,9 @@ +(* val g : string -> string *) + +module Lagrange_precomputations : sig + val index_of_domain_log2 : int -> int + + val vesta : (Pasta_bindings.Fq.t * Pasta_bindings.Fq.t) array array array + + val pallas : (Pasta_bindings.Fp.t * Pasta_bindings.Fp.t) array array array +end From 0a2dca0fd6ea50f47fa71a052b7a436c9bc9cf21 Mon Sep 17 00:00:00 2001 From: Paul Steckler Date: Thu, 1 Sep 2022 13:58:34 -0700 Subject: [PATCH 044/144] Lookup new account before stopping node --- src/app/test_executive/peers_reliability_test.ml | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/app/test_executive/peers_reliability_test.ml b/src/app/test_executive/peers_reliability_test.ml index 2aee430d7cd..d70b8721485 100644 --- a/src/app/test_executive/peers_reliability_test.ml +++ b/src/app/test_executive/peers_reliability_test.ml @@ -70,6 +70,7 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct (Wait_condition.signed_command_to_be_included_in_frontier ~txn_hash ~node_included_in:(`Node node_c) ) ) in + let zkapp_account_keypair = Signature_lib.Keypair.create () in let%bind () = let wait_for_zkapp parties = let%map () = @@ -97,7 +98,7 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct ; fee_payer = None ; receivers = [] ; amount - ; zkapp_account_keypairs = [ Signature_lib.Keypair.create () ] + ; zkapp_account_keypairs = [ zkapp_account_keypair ] ; memo ; new_zkapp_account = true ; snapp_update = Mina_base.Party.Update.dummy @@ -116,6 +117,16 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct let%bind () = send_zkapp ~logger node_c parties_create_accounts in wait_for_zkapp parties_create_accounts ) in + let%bind _account_data = + let pk = + zkapp_account_keypair.public_key |> Signature_lib.Public_key.compress + in + let account_id = + Mina_base.Account_id.create pk Mina_base.Token_id.default + in + Node.must_get_account_data ~logger node_c ~account_id + in + [%log info] "zkApp account was created on node about to be stopped" ; let%bind () = section "blocks are produced" (wait_for t (Wait_condition.blocks_to_be_produced 1)) From 7d31064a6535f174625c3fd32953ec2e28904117 Mon Sep 17 00:00:00 2001 From: Paul Steckler Date: Thu, 1 Sep 2022 15:03:30 -0700 Subject: [PATCH 045/144] Use section for account lookup --- .../test_executive/peers_reliability_test.ml | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/app/test_executive/peers_reliability_test.ml b/src/app/test_executive/peers_reliability_test.ml index d70b8721485..a5b5ae19c5c 100644 --- a/src/app/test_executive/peers_reliability_test.ml +++ b/src/app/test_executive/peers_reliability_test.ml @@ -117,14 +117,18 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct let%bind () = send_zkapp ~logger node_c parties_create_accounts in wait_for_zkapp parties_create_accounts ) in - let%bind _account_data = - let pk = - zkapp_account_keypair.public_key |> Signature_lib.Public_key.compress - in - let account_id = - Mina_base.Account_id.create pk Mina_base.Token_id.default - in - Node.must_get_account_data ~logger node_c ~account_id + let%bind () = + section "Checking for new zkApp account in node about to be stopped" + (let pk = + zkapp_account_keypair.public_key |> Signature_lib.Public_key.compress + in + let account_id = + Mina_base.Account_id.create pk Mina_base.Token_id.default + in + let%map _account_data = + Node.must_get_account_data ~logger node_c ~account_id + in + () ) in [%log info] "zkApp account was created on node about to be stopped" ; let%bind () = From bf2fca343643db7daa078f3b9d5d787148cd2065 Mon Sep 17 00:00:00 2001 From: Yves-Stan Le Cornec Date: Fri, 2 Sep 2022 10:12:37 +0200 Subject: [PATCH 046/144] Fix generation of src/lib/consensus coverage --- src/lib/consensus/proof_of_stake.ml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib/consensus/proof_of_stake.ml b/src/lib/consensus/proof_of_stake.ml index e55d28ca4fc..bb6186dbe3e 100644 --- a/src/lib/consensus/proof_of_stake.ml +++ b/src/lib/consensus/proof_of_stake.ml @@ -1354,8 +1354,8 @@ module Data = struct in if_ (prev_relative_sub_window < next_relative_sub_window) - ~then_:Boolean.(gt_prev_sub_window && lt_next_sub_window) - ~else_:Boolean.(gt_prev_sub_window || lt_next_sub_window)) + ~then_:Boolean.(gt_prev_sub_window &&& lt_next_sub_window) + ~else_:Boolean.(gt_prev_sub_window ||| lt_next_sub_window)) in if_ (Checked.return same_sub_window) @@ -1378,7 +1378,7 @@ module Data = struct (Length.Checked.to_integer constants.grace_period_end) ) ) in if_ - Boolean.(same_sub_window || in_grace_period) + Boolean.(same_sub_window ||| in_grace_period) ~then_:(Checked.return prev_min_window_density) ~else_: (Length.Checked.min current_window_density prev_min_window_density) From f8496def6ecd85605db2779faf2fce8d0cbca65c Mon Sep 17 00:00:00 2001 From: Yves-Stan Le Cornec Date: Mon, 5 Sep 2022 11:40:06 +0200 Subject: [PATCH 047/144] archive/archive_lib: eta-expand query_db functions Code instrumented by bisect_ppx is typed using weak type variables otherwise. --- src/app/archive/archive_lib/load_data.ml | 112 ++++++++++------------- 1 file changed, 49 insertions(+), 63 deletions(-) diff --git a/src/app/archive/archive_lib/load_data.ml b/src/app/archive/archive_lib/load_data.ml index 6cebf2aa2e8..0e6341fa1cd 100644 --- a/src/app/archive/archive_lib/load_data.ml +++ b/src/app/archive/archive_lib/load_data.ml @@ -28,11 +28,11 @@ let account_identifier_of_id pool account_identifier_id = let get_amount_bounds pool amount_id = let open Zkapp_basic in + let query_db ~f = Mina_caqti.query ~f pool in let%map amount_db_opt = Option.value_map amount_id ~default:(return None) ~f:(fun id -> let%map amount = - Mina_caqti.query pool ~f:(fun db -> - Processor.Zkapp_amount_bounds.load db id ) + query_db ~f:(fun db -> Processor.Zkapp_amount_bounds.load db id) in Some amount ) in @@ -48,11 +48,11 @@ let get_amount_bounds pool amount_id = let get_global_slot_bounds pool id = let open Zkapp_basic in + let query_db ~f = Mina_caqti.query ~f pool in let%map bounds_opt = Option.value_map id ~default:(return None) ~f:(fun id -> let%map bounds = - Mina_caqti.query pool ~f:(fun db -> - Processor.Zkapp_global_slot_bounds.load db id ) + query_db ~f:(fun db -> Processor.Zkapp_global_slot_bounds.load db id) in let slot_of_int64 int64 = int64 |> Unsigned.UInt32.of_int64 @@ -66,11 +66,11 @@ let get_global_slot_bounds pool id = let get_length_bounds pool id = let open Zkapp_basic in + let query_db ~f = Mina_caqti.query ~f pool in let%map bl_db_opt = Option.value_map id ~default:(return None) ~f:(fun id -> let%map ts = - Mina_caqti.query pool ~f:(fun db -> - Processor.Zkapp_length_bounds.load db id ) + query_db ~f:(fun db -> Processor.Zkapp_length_bounds.load db id) in Some ts ) in @@ -85,6 +85,7 @@ let get_length_bounds pool id = let update_of_id pool update_id = let open Zkapp_basic in + let query_db ~f = Mina_caqti.query ~f pool in let with_pool ~f arg = let open Caqti_async in Pool.use @@ -100,8 +101,7 @@ let update_of_id pool update_id = ; timing_id ; voting_for_id } = - Mina_caqti.query pool ~f:(fun db -> - Processor.Zkapp_updates.load db update_id ) + query_db ~f:(fun db -> Processor.Zkapp_updates.load db update_id) in let%bind app_state = let%bind { element0 @@ -113,7 +113,7 @@ let update_of_id pool update_id = ; element6 ; element7 } = - Mina_caqti.query pool ~f:(fun db -> + query_db ~f:(fun db -> Processor.Zkapp_states_nullable.load db app_state_id ) in let field_ids = @@ -131,8 +131,7 @@ let update_of_id pool update_id = Deferred.List.map field_ids ~f:(fun id_opt -> Option.value_map id_opt ~default:(return None) ~f:(fun id -> let%map field = - Mina_caqti.query pool ~f:(fun db -> - Processor.Zkapp_state_data.load db id ) + query_db ~f:(fun db -> Processor.Zkapp_state_data.load db id) in Some field ) ) in @@ -155,8 +154,7 @@ let update_of_id pool update_id = let%map vk_opt = Option.value_map verification_key_id ~default:(return None) ~f:(fun id -> let%map vk = - Mina_caqti.query pool ~f:(fun db -> - Processor.Zkapp_verification_keys.load db id ) + query_db ~f:(fun db -> Processor.Zkapp_verification_keys.load db id) in Some vk ) in @@ -190,8 +188,7 @@ let update_of_id pool update_id = ; increment_nonce ; set_voting_for } = - Mina_caqti.query pool ~f:(fun db -> - Processor.Zkapp_permissions.load db id ) + query_db ~f:(fun db -> Processor.Zkapp_permissions.load db id) in (* same fields, different types *) Some @@ -228,8 +225,7 @@ let update_of_id pool update_id = ; vesting_period ; vesting_increment } = - Mina_caqti.query pool ~f:(fun db -> - Processor.Zkapp_timing_info.load db id ) + query_db ~f:(fun db -> Processor.Zkapp_timing_info.load db id) in let initial_minimum_balance = Currency.Balance.of_string initial_minimum_balance @@ -278,25 +274,25 @@ let update_of_id pool update_id = let staking_data_of_id pool id = let open Zkapp_basic in + let query_db ~f = Mina_caqti.query ~f pool in let%bind { epoch_ledger_id ; epoch_seed ; start_checkpoint ; lock_checkpoint ; epoch_length_id } = - Mina_caqti.query pool ~f:(fun db -> Processor.Zkapp_epoch_data.load db id) + query_db ~f:(fun db -> Processor.Zkapp_epoch_data.load db id) in let%bind ledger = let%bind { hash_id; total_currency_id } = - Mina_caqti.query pool ~f:(fun db -> + query_db ~f:(fun db -> Processor.Zkapp_epoch_ledger.load db epoch_ledger_id ) in let%bind hash = let%map hash_opt = Option.value_map hash_id ~default:(return None) ~f:(fun id -> let%map hash_str = - Mina_caqti.query pool ~f:(fun db -> - Processor.Snarked_ledger_hash.load db id ) + query_db ~f:(fun db -> Processor.Snarked_ledger_hash.load db id) in Some (Frozen_ledger_hash.of_base58_check_exn hash_str) ) in @@ -327,6 +323,7 @@ let staking_data_of_id pool id = let protocol_state_precondition_of_id pool id = let open Zkapp_basic in + let query_db ~f = Mina_caqti.query ~f pool in let%bind ({ snarked_ledger_hash_id ; timestamp_id ; blockchain_length_id @@ -338,16 +335,14 @@ let protocol_state_precondition_of_id pool id = ; next_epoch_data_id } : Processor.Zkapp_network_precondition.t ) = - Mina_caqti.query pool ~f:(fun db -> - Processor.Zkapp_network_precondition.load db id ) + query_db ~f:(fun db -> Processor.Zkapp_network_precondition.load db id) in let%bind snarked_ledger_hash = let%map hash_opt = Option.value_map snarked_ledger_hash_id ~default:(return None) ~f:(fun id -> let%map hash = - Mina_caqti.query pool ~f:(fun db -> - Processor.Snarked_ledger_hash.load db id ) + query_db ~f:(fun db -> Processor.Snarked_ledger_hash.load db id) in Some (Frozen_ledger_hash.of_base58_check_exn hash) ) in @@ -357,8 +352,7 @@ let protocol_state_precondition_of_id pool id = let%map ts_db_opt = Option.value_map timestamp_id ~default:(return None) ~f:(fun id -> let%map ts = - Mina_caqti.query pool ~f:(fun db -> - Processor.Zkapp_timestamp_bounds.load db id ) + query_db ~f:(fun db -> Processor.Zkapp_timestamp_bounds.load db id) in Some ts ) in @@ -396,19 +390,20 @@ let protocol_state_precondition_of_id pool id = : Zkapp_precondition.Protocol_state.t ) let load_events pool id = + let query_db ~f = Mina_caqti.query ~f pool in let%map fields_list = (* each id refers to an item in 'zkapp_state_data_array' *) let%bind field_array_ids = - Mina_caqti.query pool ~f:(fun db -> Processor.Zkapp_events.load db id) + query_db ~f:(fun db -> Processor.Zkapp_events.load db id) in Deferred.List.map (Array.to_list field_array_ids) ~f:(fun array_id -> let%bind field_ids = - Mina_caqti.query pool ~f:(fun db -> + query_db ~f:(fun db -> Processor.Zkapp_state_data_array.load db array_id ) in Deferred.List.map (Array.to_list field_ids) ~f:(fun field_id -> let%map field_str = - Mina_caqti.query pool ~f:(fun db -> + query_db ~f:(fun db -> Processor.Zkapp_state_data.load db field_id ) in Zkapp_basic.F.of_string field_str ) ) @@ -416,9 +411,9 @@ let load_events pool id = List.map fields_list ~f:Array.of_list let get_fee_payer_body ~pool body_id = + let query_db ~f = Mina_caqti.query ~f pool in let%bind { account_identifier_id; fee; valid_until; nonce } = - Mina_caqti.query pool ~f:(fun db -> - Processor.Zkapp_fee_payer_body.load db body_id ) + query_db ~f:(fun db -> Processor.Zkapp_fee_payer_body.load db body_id) in let%bind account_id = account_identifier_of_id pool account_identifier_id in let public_key = Account_id.public_key account_id in @@ -435,6 +430,7 @@ let get_fee_payer_body ~pool body_id = let get_other_party_body ~pool body_id = let open Zkapp_basic in + let query_db ~f = Mina_caqti.query ~f pool in let pk_of_id = pk_of_id pool in let%bind { account_identifier_id ; update_id @@ -449,8 +445,7 @@ let get_other_party_body ~pool body_id = ; use_full_commitment ; caller } = - Mina_caqti.query pool ~f:(fun db -> - Processor.Zkapp_other_party_body.load db body_id ) + query_db ~f:(fun db -> Processor.Zkapp_other_party_body.load db body_id) in let%bind account_id = account_identifier_of_id pool account_identifier_id in let public_key = Account_id.public_key account_id in @@ -472,8 +467,7 @@ let get_other_party_body ~pool body_id = let%bind sequence_events = load_events pool sequence_events_id in let%bind call_data = let%map field_str = - Mina_caqti.query pool ~f:(fun db -> - Processor.Zkapp_state_data.load db call_data_id ) + query_db ~f:(fun db -> Processor.Zkapp_state_data.load db call_data_id) in Zkapp_basic.F.of_string field_str in @@ -483,7 +477,7 @@ let get_other_party_body ~pool body_id = let%bind account_precondition = let%bind ({ kind; precondition_account_id; nonce } : Processor.Zkapp_account_precondition.t ) = - Mina_caqti.query pool ~f:(fun db -> + query_db ~f:(fun db -> Processor.Zkapp_account_precondition.load db zkapp_account_precondition_id ) in @@ -508,7 +502,7 @@ let get_other_party_body ~pool body_id = ; proved_state ; is_new } = - Mina_caqti.query pool ~f:(fun db -> + query_db ~f:(fun db -> Processor.Zkapp_precondition_account.load db (Option.value_exn precondition_account_id) ) in @@ -516,7 +510,7 @@ let get_other_party_body ~pool body_id = let%map balance_opt = Option.value_map balance_id ~default:(return None) ~f:(fun id -> let%map { balance_lower_bound; balance_upper_bound } = - Mina_caqti.query pool ~f:(fun db -> + query_db ~f:(fun db -> Processor.Zkapp_balance_bounds.load db id ) in let lower = Currency.Balance.of_string balance_lower_bound in @@ -529,7 +523,7 @@ let get_other_party_body ~pool body_id = let%map nonce_opt = Option.value_map nonce_id ~default:(return None) ~f:(fun id -> let%map { nonce_lower_bound; nonce_upper_bound } = - Mina_caqti.query pool ~f:(fun db -> + query_db ~f:(fun db -> Processor.Zkapp_nonce_bounds.load db id ) in let balance_of_int64 int64 = @@ -566,7 +560,7 @@ let get_other_party_body ~pool body_id = ; element6 ; element7 } = - Mina_caqti.query pool ~f:(fun db -> + query_db ~f:(fun db -> Processor.Zkapp_states_nullable.load db state_id ) in let elements = @@ -584,7 +578,7 @@ let get_other_party_body ~pool body_id = Deferred.List.map elements ~f:(fun id_opt -> Option.value_map id_opt ~default:(return None) ~f:(fun id -> let%map field_str = - Mina_caqti.query pool ~f:(fun db -> + query_db ~f:(fun db -> Processor.Zkapp_state_data.load db id ) in Some (Zkapp_basic.F.of_string field_str) ) ) @@ -596,8 +590,7 @@ let get_other_party_body ~pool body_id = Option.value_map sequence_state_id ~default:(return None) ~f:(fun id -> let%map field_str = - Mina_caqti.query pool ~f:(fun db -> - Processor.Zkapp_state_data.load db id ) + query_db ~f:(fun db -> Processor.Zkapp_state_data.load db id) in Some (Zkapp_basic.F.of_string field_str) ) in @@ -639,6 +632,7 @@ let get_other_party_body ~pool body_id = let get_account_accessed ~pool (account : Processor.Accounts_accessed.t) : (int * Account.t) Deferred.t = + let query_db ~f = Mina_caqti.query ~f pool in let with_pool ~f arg = let open Caqti_async in Pool.use @@ -664,14 +658,13 @@ let get_account_accessed ~pool (account : Processor.Accounts_accessed.t) : account in let%bind ({ public_key_id; token_id } : Processor.Account_identifiers.t) = - Mina_caqti.query pool ~f:(fun db -> + query_db ~f:(fun db -> Processor.Account_identifiers.load db account_identifier_id ) in let%bind public_key = pk_of_id public_key_id in let%bind token_id = token_of_id token_id in let%bind token_symbol = - Mina_caqti.query pool ~f:(fun db -> - Processor.Token_symbols.load db token_symbol_id ) + query_db ~f:(fun db -> Processor.Token_symbols.load db token_symbol_id) in let balance = Currency.Balance.of_string balance in let nonce = nonce |> Unsigned.UInt32.of_int64 |> Account.Nonce.of_uint32 in @@ -688,15 +681,13 @@ let get_account_accessed ~pool (account : Processor.Accounts_accessed.t) : in let%bind voting_for = let%map hash_str = - Mina_caqti.query pool ~f:(fun db -> - Processor.Voting_for.load db voting_for_id ) + query_db ~f:(fun db -> Processor.Voting_for.load db voting_for_id) in State_hash.of_base58_check_exn hash_str in let%bind timing = match%map - Mina_caqti.query pool ~f:(fun db -> - Processor.Timing_info.load_opt db timing_id ) + query_db ~f:(fun db -> Processor.Timing_info.load_opt db timing_id) with | None -> Account_timing.Untimed @@ -752,8 +743,7 @@ let get_account_accessed ~pool (account : Processor.Accounts_accessed.t) : ; increment_nonce ; set_voting_for } = - Mina_caqti.query pool ~f:(fun db -> - Processor.Zkapp_permissions.load db permissions_id ) + query_db ~f:(fun db -> Processor.Zkapp_permissions.load db permissions_id) in ( { edit_state ; send @@ -794,8 +784,7 @@ let get_account_accessed ~pool (account : Processor.Accounts_accessed.t) : ; element6 ; element7 } = - Mina_caqti.query pool ~f:(fun db -> - Processor.Zkapp_states.load db app_state_id ) + query_db ~f:(fun db -> Processor.Zkapp_states.load db app_state_id) in let elements = [ element0 @@ -811,8 +800,7 @@ let get_account_accessed ~pool (account : Processor.Accounts_accessed.t) : let%bind app_state = let%map field_strs = Deferred.List.map elements ~f:(fun id -> - Mina_caqti.query pool ~f:(fun db -> - Processor.Zkapp_state_data.load db id ) ) + query_db ~f:(fun db -> Processor.Zkapp_state_data.load db id) ) in let fields = List.map field_strs ~f:Zkapp_basic.F.of_string in Zkapp_state.V.of_list_exn fields @@ -821,7 +809,7 @@ let get_account_accessed ~pool (account : Processor.Accounts_accessed.t) : Option.value_map verification_key_id ~default:(return None) ~f:(fun id -> let%map { verification_key; hash } = - Mina_caqti.query pool ~f:(fun db -> + query_db ~f:(fun db -> Processor.Zkapp_verification_keys.load db id ) in let data = @@ -842,15 +830,14 @@ let get_account_accessed ~pool (account : Processor.Accounts_accessed.t) : |> Mina_numbers.Zkapp_version.of_uint32 in let%bind { element0; element1; element2; element3; element4 } = - Mina_caqti.query pool ~f:(fun db -> + query_db ~f:(fun db -> Processor.Zkapp_sequence_states.load db sequence_state_id ) in let elements = [ element0; element1; element2; element3; element4 ] in let%map sequence_state = let%map field_strs = Deferred.List.map elements ~f:(fun id -> - Mina_caqti.query pool ~f:(fun db -> - Processor.Zkapp_state_data.load db id ) ) + query_db ~f:(fun db -> Processor.Zkapp_state_data.load db id) ) in let fields = List.map field_strs ~f:Zkapp_basic.F.of_string in Pickles_types.Vector.Vector_5.of_list_exn fields @@ -873,8 +860,7 @@ let get_account_accessed ~pool (account : Processor.Accounts_accessed.t) : let%bind zkapp_uri = Option.value_map zkapp_db ~default:(return "https://dummy.com") ~f:(fun zkapp -> - Mina_caqti.query pool ~f:(fun db -> - Processor.Zkapp_uri.load db zkapp.zkapp_uri_id ) ) + query_db ~f:(fun db -> Processor.Zkapp_uri.load db zkapp.zkapp_uri_id) ) in (* TODO: token permissions is going away *) let account = From b8341e0084f7f40897b6eb7f7a9cdf53c225f8dd Mon Sep 17 00:00:00 2001 From: Virgile Robles Date: Mon, 5 Sep 2022 15:00:47 +0200 Subject: [PATCH 048/144] Removing obsolete Makefile targets --- Makefile | 3 --- README-dev.md | 5 ----- scripts/web.sh | 16 ---------------- 3 files changed, 24 deletions(-) delete mode 100755 scripts/web.sh diff --git a/Makefile b/Makefile index ba913f116f1..eacb8cfd34b 100644 --- a/Makefile +++ b/Makefile @@ -294,9 +294,6 @@ genesis-ledger-ocaml: test-ppx: $(MAKE) -C src/lib/ppx_mina/tests -web: - ./scripts/web.sh - ######################################## ## Benchmarks diff --git a/README-dev.md b/README-dev.md index 32cf1ccf02f..21e6d628297 100644 --- a/README-dev.md +++ b/README-dev.md @@ -113,15 +113,10 @@ It also knows how to use Docker automatically. These are the most important `make` targets: - `build`: build everything -- `test`: run the tests - `libp2p_helper`: build the libp2p helper -- `web`: build the website, including the state explorer We use the [dune](https://github.com/ocaml/dune/) buildsystem for our OCaml code. -NOTE: all of the `test-*` targets (including `test-all`) won't run in the container. -`test` wraps them in the container. - ## Steps for adding a new dependency Rarely, you may edit one of our forked opam-pinned packages, or add a new system diff --git a/scripts/web.sh b/scripts/web.sh deleted file mode 100755 index c2481aa45d5..00000000000 --- a/scripts/web.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash - -set -e -pushd src - -eval `opam config env` - -dune b app/lite/main.bc.js app/lite/verifier_main.bc.js --profile=release - -cp _build/default/src/app/lite/main.bc.js app/website/static/ -cp _build/default/src/app/lite/verifier_main.bc.js app/website/static/ - -pushd app/website -dune b && make -popd -popd From 4f8d14aff55810813a64d6cfd8f96749090cd96a Mon Sep 17 00:00:00 2001 From: Virgile Robles Date: Mon, 5 Sep 2022 15:01:48 +0200 Subject: [PATCH 049/144] Link CONTRIBUTING from README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f68b644c983..b46e425073e 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ Mina is the first cryptocurrency with a lightweight, constant-sized blockchain. ## Contributing -Read the [Contributing Guide](https://docs.minaprotocol.com/en/developers/contributing) for information on how to make both technical and non-technical contributions. +Read the [Contributing Guide](https://docs.minaprotocol.com/en/developers/contributing) for high-level information on how to make both technical and non-technical contributions. To contribute to this repository, make sure to read its [CONTRIBUTING](CONTRIBUTING.md) document. ## Developers From b092dd4ee6364c236a677c3c7e98ed550f06c829 Mon Sep 17 00:00:00 2001 From: Virgile Robles Date: Mon, 5 Sep 2022 15:02:47 +0200 Subject: [PATCH 050/144] Mention reformat target --- README-dev.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README-dev.md b/README-dev.md index 21e6d628297..d492e5b24fc 100644 --- a/README-dev.md +++ b/README-dev.md @@ -114,6 +114,8 @@ These are the most important `make` targets: - `build`: build everything - `libp2p_helper`: build the libp2p helper +- `reformat`: automatically use `ocamlformat` to reformat the source files (use + it if the hook fails during a commit) We use the [dune](https://github.com/ocaml/dune/) buildsystem for our OCaml code. From 0fa6c6ed2cdf8b2dc8f9dc26e6b05ed77f7f0be5 Mon Sep 17 00:00:00 2001 From: Virgile Robles Date: Mon, 5 Sep 2022 15:24:00 +0200 Subject: [PATCH 051/144] Re-organize CI-failures, link to it, add docker section --- CONTRIBUTING.md | 9 ++++++-- README-ci-failures.md | 48 +++++++++++++++++++++++++++++++++++-------- README-dev.md | 2 +- 3 files changed, 47 insertions(+), 12 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3d802aceb3d..ed1d3eb287e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -67,6 +67,9 @@ If you are PRing from the main remote, add `ci-build-me` label when you want to Once a PR has been reviewed and approved, and all CI tests have passed, it can be merged by a maintainer (or by you, if you have this access). +If you encounter problems with the CI, read [CI FAILURES](README-ci-failures.md) +for common troubleshooting steps. + ## Documentation There are three main pieces of Mina documentation: @@ -76,8 +79,10 @@ There are three main pieces of Mina documentation: 2. The `README.md` files in various directories. These explain the contents of that directory at a high level: the purpose of the library, design constraints, anything else specific to that directory. -3. Inline code comments. There are very few of these, and we don't currently run ocamldoc - so they won't be exposed even as we write them. This should change eventually. +3. Inline code comments. There are unfortunately very few of these currently, + but this will slowly change. We are now running `ocamldoc` and the generated + documentation is browsable + [online](https://mina-docs.storage.googleapis.com/index.html). Changes to the software should come with changes to the documentation. diff --git a/README-ci-failures.md b/README-ci-failures.md index 905d2064917..7cd528d5a87 100644 --- a/README-ci-failures.md +++ b/README-ci-failures.md @@ -1,17 +1,11 @@ +## Jobs not starting + CI jobs are dispatched by a script which responds to both the `ci-build-me` label and comments by MinaProtocol organization members containing exactly `!ci-build-me`. If your CI job has not started after adding the `ci-build-me` label, please comment on the pull request with `!ci-build-me` to attempt to re-trigger the script. -**Please note:** -* If you encounter an error where jobs are not run, it should normally suffice - to retry the script with a `!ci-build-me` comment on your PR when the fix has - been deployed. -* If your CI error is related to a timeout logged by one of the integration - test runnners, this is a known issue and re-running the test in the CircleCI - interface will usually succeed. - If CI jobs are not running after applying both the `ci-build-me` label and comment, you may be able to find and fix the error in the script. The script lives in `frontend/ci-build-me/src/index.js`, and instructions for deploying @@ -19,11 +13,47 @@ the new version are in the readme at `frontend/ci-build-me/README.md`. You should still follow normal procedure: submit a pull request and await approval for the changes before attempting to deploy the fixed script. +## Integration test failures + +If your CI error is related to a timeout logged by one of the integration test +runnners, this is a known issue and re-running the test in the Buildkite +interface will usually succeed. + If an issue arises, please post an update in both `development` on the Mina Protocol discord and `engineering-internal` on the O(1) Labs discord with the details and links to the failures. -Where you have a bugfix for failing CI, or are seeing a CI failure across +## CI environment mismatch + +The CI runs its jobs in multiple Docker images. The images that it is using are +specified in `buildkite/src/Constants/COntainerImages.dhall`: the CI uses all +Debian images prefixed by `minaToolchainBuster`. + +Theses images are generated by the CI itself, in particular based on the content of the +`dockerfiles` directory and the `opam.export` file (which describes versions of +OCaml packages). If you PR modifies how the images are generated (for example by +changing a package version in `opam.export`), then the CI will not automatically +use these new images and will potentially fail. + +In this case, you should: +1. Let the CI run once with the old images. Jobs may fail, but ensure that jobs + of the form `Docker: toolchain-*` succeed. This is the step that creates new + Docker images from your PR. +2. Look for the newly generated images on + [Google Cloud](https://console.cloud.google.com/gcr/images/o1labs-192920/global/mina-toolchain) + where they have been automatically uploaded. Look for your branch name and + commit hash in the second column. You should find several images suffixed + with `-buster`, `-bullseye`, `-stretch` and `-focal` (Debian versions). +3. For each such image, retrieve its full name and hash by hovering its link and + clicking the `Copy full image name` tooltip that appears (or retrieve it on + the image's page). +4. Edit `buildkite/src/Constants/ContainerImages.dhall` and replace the name of + each `minaToolchain-*` image by the ones you retrieved. +5. Commit the change, the CI should now be using the new images. + +## Contact + +If you have a bugfix for failing CI, or are seeing a CI failure across multiple PRs, the best people to contact are: * @bkase (bkase#2492 on discord) (Europe - misc.) * @lk86 (linuskrom#2287 on discord) (US West Coast) diff --git a/README-dev.md b/README-dev.md index d492e5b24fc..668f5647568 100644 --- a/README-dev.md +++ b/README-dev.md @@ -105,7 +105,7 @@ let g:syntastic_ocaml_checkers=['merlin'] Emacs has a built-in autocomplete, via `M-x completion-at-point`, or simply `M-tab`. There are other Emacs autocompletion packages; see [Emacs from scratch](https://github.com/ocaml/merlin/wiki/emacs-from-scratch). -## Using the makefile +## Using the Makefile The makefile contains phony targets for all the common tasks that need to be done. It also knows how to use Docker automatically. From 8f342e31c2ece4bdc951a4b3e9309ebf58273426 Mon Sep 17 00:00:00 2001 From: Virgile Robles Date: Mon, 5 Sep 2022 18:00:24 +0200 Subject: [PATCH 052/144] Move branching strategy to the repo --- CONTRIBUTING.md | 8 +++- README-branching.md | 78 +++++++++++++++++++++++++++++++++++++ docs/res/branching_flow.png | 3 ++ 3 files changed, 88 insertions(+), 1 deletion(-) create mode 100644 README-branching.md create mode 100644 docs/res/branching_flow.png diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ed1d3eb287e..52366254641 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -43,7 +43,13 @@ labels. ## Pull Requests -Our branching workflow is [documented on the wiki](https://minaprotocol.notion.site/minaprotocol/Compatible-vs-Develop-branch-management-31c845b2924b4c518740eb9da4514dcc). +### Branching workflow + +Make sure to read about the [branching workflow](README-branching.md) to +understand on which branch (`compatible` or `develop`) you should be working, +and how to manage simultaneous PRs to both branches. + +### Continuous integration All pull requests go through Buildkite CI, which makes sure the code doesn't need to be reformatted, builds Mina in its various configurations, and runs all the diff --git a/README-branching.md b/README-branching.md new file mode 100644 index 00000000000..13e624cd5b6 --- /dev/null +++ b/README-branching.md @@ -0,0 +1,78 @@ +# Branch management: `compatible` vs `develop` + +The first section describes the reasoning behind the current state of branching, +and the second section gives you a few tips on how to handle this on a day to +day basis. + +## Rationale + +Instead of a single `main` or `master` branch, there are two active branches +`compatible` and `develop` at all times, where you might want to make changes. + +- `compatible` contains all changes which are literally backwards compatible + with what people currently run on mainnet. Any nodes running a version of + mina based off of compatible should connect to current mainnet just fine. +- `develop` contains changes which break backwards compatibility, or changes + that depend on past compatibility-breaking changes. “Not backwards + compatible” means that a daemon running this version of mina will not connect + to mainnet. + +Major changes to the daemon, protocol, or crypto sometimes will sometimes cause +backwards-compatibility breaking changes, and of course such changes need to be +done with deliberation and are not to be taken lightly. Changes to +infrastructure, auxiliary develop scripts, tests, CI, are usually not be +backwards compatibility breaking, and thereby should go into compatible (unless +you are doing something very special and you know what you’re doing). + +On a semi-regular basis, `compatible` gets manually merged into `develop` so +that — generally speaking — `develop` contains all changes in `compatible.` As +such, `develop` is a superset of `compatible` i.e. `develop` contains everything +that `compatible` contains, and more. + +### Hard fork + +Whenever a hard fork happens, the code in `develop` is released. When this +happens, the current `compatible` is entirely discarded and a new `compatible` +gets created based off of `develop` + +![Illustration of the branching strategy](docs/res/branching_flow.png) + +### Releases + +`release/1.X.X` branches are made off of `compatible` and tagged with alpha and +beta tags until the code is deemed stable, then the `release/1.X.X` branch is +merged into `master` and given a stable tag. Whenever code is tagged, if +anything is missing in in the upstream branches (compatible, develop) then the +tagged branch is also merged back for consistency. + +`release/2.0.0`is the branch where Berkeley QA Net releases are being cut, +between `compatible`and `develop` in the tree. So far nothing has been tagged +there but there will be `2.0.0alphaX` tags once the code is more stable and we +are closer to the Incentivized testnet. + +Unless it is an emergency, code should flow from feature branches +into `compatible`then in batches into the release branch for tagging and testing + +## Day to day + +When developing a feature, if it’s not something that breaks compatibility, then +you should be developing a feature branch, called `foo` for example, based off +of `compatible`. If you’re not sure whether or not your changes are breaking, +they probably are not and should build upon compatible. + +There is a CI job called “merges cleanly to develop” which runs whenever you +have a PR off of `compatible`. If that CI job passes, then you can simply merge +`foo` into `compatible`. If it does not pass, then when you’re done with your +changes to `foo` and the PR is all approved, then make a new branch+PR based off +of your original PR called `foo_DEVELOP` (for example), and then merge +`develop` into `foo_DEVELOP`. Fix any merge errors that result, then once +`foo_DEVELOP` is approved, you can merge it into `develop`. Once that’s done, +the “merges cleanly to develop” CI job in your original `foo` PR should +automagically start passing when you manually re-run it in CI, in which case you +can merge. + +If, after making `foo_DEVELOP`, you need to make changes to `foo`, then make +sure to merge `foo` into `foo_DEVELOP`. In order for the git magic to work, +`foo_DEVELOP` needs to be a superset of the commits from `foo`, and it also +needs to merge first. You can make further changes post-merge in `foo_DEVELOP` +as needed to ensure correctness. diff --git a/docs/res/branching_flow.png b/docs/res/branching_flow.png new file mode 100644 index 00000000000..4850b432e65 --- /dev/null +++ b/docs/res/branching_flow.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:01ab798f7a179a1f7d527f6b3d2f13d8371b90746796bcf0f01d0d8e1508514d +size 21897 From 1291777942dbc10e6ed9c7226856f5c0e02c3e12 Mon Sep 17 00:00:00 2001 From: Fabrizio Date: Tue, 6 Sep 2022 11:32:34 -0300 Subject: [PATCH 053/144] remove --- src/lib/crypto/kimchi_backend/pasta/dune | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/crypto/kimchi_backend/pasta/dune b/src/lib/crypto/kimchi_backend/pasta/dune index 23af80fba42..1b574e98c36 100644 --- a/src/lib/crypto/kimchi_backend/pasta/dune +++ b/src/lib/crypto/kimchi_backend/pasta/dune @@ -6,7 +6,7 @@ (instrumentation (backend bisect_ppx)) (preprocess - (pps ppx_version ppx_jane ppx_deriving_yojson ppx_deriving.std h_list.ppx)) + (pps ppx_version ppx_jane ppx_deriving_yojson ppx_deriving.std)) (libraries ;; opam libraries ppx_inline_test.config From b9a4670f19cdbeb412082c01f549a75fab53779e Mon Sep 17 00:00:00 2001 From: georgeee Date: Sat, 3 Sep 2022 13:35:41 +0200 Subject: [PATCH 054/144] Rename --discovery-keypair to --libp2p-keypair --- .../terraform/modules/google-cloud/coda-seed-node/main.tf | 2 +- helm/block-producer/templates/block-producer.yaml | 2 +- helm/seed-node/templates/seed-node.yaml | 2 +- nix/modules/mina.nix | 4 ++-- scripts/mina-local-network/mina-local-network.sh | 2 +- src/app/cli/src/cli_entrypoint/mina_cli_entrypoint.ml | 7 +++---- 6 files changed, 9 insertions(+), 10 deletions(-) diff --git a/automation/terraform/modules/google-cloud/coda-seed-node/main.tf b/automation/terraform/modules/google-cloud/coda-seed-node/main.tf index 781cf85c6d8..9b57a8b4f86 100644 --- a/automation/terraform/modules/google-cloud/coda-seed-node/main.tf +++ b/automation/terraform/modules/google-cloud/coda-seed-node/main.tf @@ -1,5 +1,5 @@ locals { - container_command = format("mina daemon -log-level Info -config-directory /root/.mina-config -client-port 8301 -rest-port 8304 -external-port 10001 -metrics-port 10000 -discovery-keypair %s -seed %s -config-file /root/daemon.json | tee log.txt", var.discovery_keypair, var.seed_peers) + container_command = format("mina daemon -log-level Info -config-directory /root/.mina-config -client-port 8301 -rest-port 8304 -external-port 10001 -metrics-port 10000 -libp2p-keypair %s -seed %s -config-file /root/daemon.json | tee log.txt", var.discovery_keypair, var.seed_peers) } resource "google_compute_address" "external_ip" { diff --git a/helm/block-producer/templates/block-producer.yaml b/helm/block-producer/templates/block-producer.yaml index c8ab35ea335..d60f2e04226 100644 --- a/helm/block-producer/templates/block-producer.yaml +++ b/helm/block-producer/templates/block-producer.yaml @@ -197,7 +197,7 @@ spec: "-enable-flooding", "true", {{- end -}} {{- if $config.libp2pSecret }} - "-discovery-keypair", "/root/libp2p-keys/key", + "-libp2p-keypair", "/root/libp2p-keys/key", {{- end -}} {{- range $.Values.mina.seedPeers }} "-peer", {{ . | quote }}, diff --git a/helm/seed-node/templates/seed-node.yaml b/helm/seed-node/templates/seed-node.yaml index 6d05b74451c..49c5b144aae 100644 --- a/helm/seed-node/templates/seed-node.yaml +++ b/helm/seed-node/templates/seed-node.yaml @@ -78,7 +78,7 @@ spec: "-config-file", "/config/daemon.json", {{- end }} {{- if $config.libp2pSecret }} - "-discovery-keypair", "/root/libp2p-keys/key", + "-libp2p-keypair", "/root/libp2p-keys/key", {{- end -}} {{- range $.Values.mina.seedPeers }} "-peer", {{ . | quote }}, diff --git a/nix/modules/mina.nix b/nix/modules/mina.nix index 5d88f83f3c3..f6d9283ceb7 100644 --- a/nix/modules/mina.nix +++ b/nix/modules/mina.nix @@ -66,7 +66,7 @@ inputs: type = nullOr path; default = null; }; - discovery-keypair = lib.mkOption { + libp2p-keypair = lib.mkOption { type = nullOr path; default = null; }; @@ -114,7 +114,7 @@ inputs: ${arg "external-ip"} \ ${arg "protocol-version"} \ ${arg "block-producer-key"} \ - ${arg "discovery-keypair"} \ + ${arg "libp2p-keypair"} \ ${ optionalString cfg.generate-genesis-proof "--generate-genesis-proof true" diff --git a/scripts/mina-local-network/mina-local-network.sh b/scripts/mina-local-network/mina-local-network.sh index 74f01426941..400ac759d86 100755 --- a/scripts/mina-local-network/mina-local-network.sh +++ b/scripts/mina-local-network/mina-local-network.sh @@ -436,7 +436,7 @@ fi # ---------- -spawn-node ${NODES_FOLDER}/seed ${SEED_START_PORT} -seed -discovery-keypair ${SEED_PEER_KEY} ${ARCHIVE_ADDRESS_CLI_ARG} +spawn-node ${NODES_FOLDER}/seed ${SEED_START_PORT} -seed -libp2p-keypair ${SEED_PEER_KEY} ${ARCHIVE_ADDRESS_CLI_ARG} SEED_PID=$! echo 'Waiting for seed to go up...' diff --git a/src/app/cli/src/cli_entrypoint/mina_cli_entrypoint.ml b/src/app/cli/src/cli_entrypoint/mina_cli_entrypoint.ml index 30cc18e07d8..804447af4b7 100644 --- a/src/app/cli/src/cli_entrypoint/mina_cli_entrypoint.ml +++ b/src/app/cli/src/cli_entrypoint/mina_cli_entrypoint.ml @@ -249,8 +249,7 @@ let setup_daemon logger = work in a block (default: true)" (optional bool) and libp2p_keypair = - flag "--discovery-keypair" ~aliases:[ "discovery-keypair" ] - (optional string) + flag "--libp2p-keypair" ~aliases:[ "libp2p-keypair" ] (optional string) ~doc: "KEYFILE Keypair (generated from `mina advanced \ generate-libp2p-keypair`) to use with libp2p discovery (default: \ @@ -555,8 +554,8 @@ let setup_daemon logger = | Error _ -> if String.contains s ',' then [%log warn] - "I think -discovery-keypair is in the old format, but \ - I failed to parse it! Using it as a path..." ; + "I think -libp2p-keypair is in the old format, but I \ + failed to parse it! Using it as a path..." ; None ) in match libp2p_keypair_old_format with From ff583b15f2eaa1c258d5f2b2c3fef89ee7e894ac Mon Sep 17 00:00:00 2001 From: georgeee Date: Sat, 3 Sep 2022 14:06:29 +0200 Subject: [PATCH 055/144] Use go 1.18 in with-lsp nix shell --- flake.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/flake.nix b/flake.nix index 0f351e04bdb..0582fbbb043 100644 --- a/flake.nix +++ b/flake.nix @@ -351,6 +351,8 @@ devShells.default = self.devShell.${system}; devShells.with-lsp = ocamlPackages.mina-dev.overrideAttrs (oa: { + buildInputs = oa.buildInputs + ++ [ pkgs.go_1_18 ]; nativeBuildInputs = oa.nativeBuildInputs ++ [ ocamlPackages.ocaml-lsp-server ]; shellHook = '' From dca28f20c96b083523a01ea0b751d46e0d7b0f31 Mon Sep 17 00:00:00 2001 From: georgeee Date: Sat, 3 Sep 2022 14:06:35 +0200 Subject: [PATCH 056/144] Make --libp2p-keypair a required flag --- nix/modules/mina.nix | 3 +- .../src/cli_entrypoint/mina_cli_entrypoint.ml | 46 ++++++++----------- src/app/cli/src/tests/coda_worker.ml | 2 +- src/lib/gossip_net/libp2p.ml | 25 ++++------ 4 files changed, 30 insertions(+), 46 deletions(-) diff --git a/nix/modules/mina.nix b/nix/modules/mina.nix index f6d9283ceb7..fdb252cf886 100644 --- a/nix/modules/mina.nix +++ b/nix/modules/mina.nix @@ -67,8 +67,7 @@ inputs: default = null; }; libp2p-keypair = lib.mkOption { - type = nullOr path; - default = null; + type = path; }; waitForRpc = lib.mkOption { diff --git a/src/app/cli/src/cli_entrypoint/mina_cli_entrypoint.ml b/src/app/cli/src/cli_entrypoint/mina_cli_entrypoint.ml index 804447af4b7..3f3d8ecba88 100644 --- a/src/app/cli/src/cli_entrypoint/mina_cli_entrypoint.ml +++ b/src/app/cli/src/cli_entrypoint/mina_cli_entrypoint.ml @@ -249,11 +249,10 @@ let setup_daemon logger = work in a block (default: true)" (optional bool) and libp2p_keypair = - flag "--libp2p-keypair" ~aliases:[ "libp2p-keypair" ] (optional string) + flag "--libp2p-keypair" ~aliases:[ "libp2p-keypair" ] (required string) ~doc: - "KEYFILE Keypair (generated from `mina advanced \ - generate-libp2p-keypair`) to use with libp2p discovery (default: \ - generate per-run temporary keypair)" + "KEYFILE Keypair (generated from `mina libp2p generate-keypair`) to \ + use with libp2p discovery" and is_seed = flag "--seed" ~aliases:[ "seed" ] ~doc:"Start the node as a seed node" no_arg @@ -547,28 +546,23 @@ let setup_daemon logger = in let%bind libp2p_keypair = let libp2p_keypair_old_format = - Option.bind libp2p_keypair ~f:(fun s -> - match Mina_net2.Keypair.of_string s with - | Ok kp -> - Some kp - | Error _ -> - if String.contains s ',' then - [%log warn] - "I think -libp2p-keypair is in the old format, but I \ - failed to parse it! Using it as a path..." ; - None ) - in - match libp2p_keypair_old_format with - | Some kp -> - return (Some kp) - | None -> ( - match libp2p_keypair with - | None -> - return None - | Some s -> - Secrets.Libp2p_keypair.Terminal_stdin.read_exn - ~should_prompt_user:false ~which:"libp2p keypair" s - |> Deferred.map ~f:Option.some ) + match Mina_net2.Keypair.of_string libp2p_keypair with + | Ok kp -> + Some kp + | Error _ -> + if String.contains libp2p_keypair ',' then + [%log warn] + "I think -libp2p-keypair is in the old format, but I \ + failed to parse it! Using it as a path..." ; + None + in + Option.value_map + ~default:(fun () -> + Secrets.Libp2p_keypair.Terminal_stdin.read_exn + ~should_prompt_user:false ~which:"libp2p keypair" libp2p_keypair + ) + ~f:(Fn.compose const Deferred.return) + libp2p_keypair_old_format () in let%bind () = let version_filename = conf_dir ^/ "mina.version" in diff --git a/src/app/cli/src/tests/coda_worker.ml b/src/app/cli/src/tests/coda_worker.ml index c0c4206b734..064cf2be82c 100644 --- a/src/app/cli/src/tests/coda_worker.ml +++ b/src/app/cli/src/tests/coda_worker.ml @@ -440,7 +440,7 @@ module T = struct ; validation_queue_size = 150 ; peer_exchange = true ; peer_protection_ratio = 0.2 - ; keypair = Some libp2p_keypair + ; keypair = libp2p_keypair ; all_peers_seen_metric = false ; known_private_ip_nets = [] ; time_controller diff --git a/src/lib/gossip_net/libp2p.ml b/src/lib/gossip_net/libp2p.ml index c55e1d99f95..403fb833c5d 100644 --- a/src/lib/gossip_net/libp2p.ml +++ b/src/lib/gossip_net/libp2p.ml @@ -49,7 +49,7 @@ module Config = struct ; pubsub_v1 : pubsub_topic_mode_t ; pubsub_v0 : pubsub_topic_mode_t ; validation_queue_size : int - ; mutable keypair : Mina_net2.Keypair.t option + ; mutable keypair : Mina_net2.Keypair.t ; all_peers_seen_metric : bool ; known_private_ip_nets : Core.Unix.Cidr.t list } @@ -242,14 +242,7 @@ module Make (Rpc_intf : Network_peer.Rpc_intf.Rpc_interface_intf) : with | Ok (Ok net2) -> ( let open Mina_net2 in - (* Make an ephemeral keypair for this session TODO: persist in the config dir *) - let%bind me = - match config.keypair with - | Some kp -> - return kp - | None -> - Mina_net2.generate_random_keypair net2 - in + let me = config.keypair in let my_peer_id = Keypair.to_peer_id me |> Peer.Id.to_string in Logger.append_to_global_metadata [ ("peer_id", `String my_peer_id) @@ -532,7 +525,7 @@ module Make (Rpc_intf : Network_peer.Rpc_intf.Rpc_interface_intf) : in match%map initializing_libp2p_result with | Ok pfs -> - (net2, pfs, me) + (net2, pfs) | Error e -> fail e ) | Ok (Error e) -> @@ -558,7 +551,7 @@ module Make (Rpc_intf : Network_peer.Rpc_intf.Rpc_interface_intf) : let%bind () = let rec on_libp2p_create res = net2_ref := - Deferred.map res ~f:(fun (n, _, _) -> + Deferred.map res ~f:(fun (n, _) -> ( match Sys.getenv "MINA_LIBP2P_HELPER_RESTART_INTERVAL_BASE" with @@ -584,7 +577,7 @@ module Make (Rpc_intf : Network_peer.Rpc_intf.Rpc_interface_intf) : () ) ; n ) ; let pf_impl f msg = - let%bind _, pf, _ = res in + let%bind _, pf = res in f pf msg in pfs_ref := @@ -594,11 +587,9 @@ module Make (Rpc_intf : Network_peer.Rpc_intf.Rpc_interface_intf) : ; publish_v1_snark_work = pf_impl (fun pf -> pf.publish_v1_snark_work) } ; - upon res (fun (_, _, me) -> - (* This is a hack so that we keep the same keypair across restarts. *) - config.keypair <- Some me ; - let logger = config.logger in - [%log trace] ~metadata:[] "Successfully restarted libp2p" ) + upon res (fun _ -> + [%log' trace config.logger] ~metadata:[] + "Successfully restarted libp2p" ) and start_libp2p () = let libp2p = create_libp2p config rpc_handlers first_peer_ivar From faa1415c04173fe535998da8703d54690bbaa61a Mon Sep 17 00:00:00 2001 From: georgeee Date: Sat, 3 Sep 2022 14:20:32 +0200 Subject: [PATCH 057/144] Move generate-libp2p-keypair Rename 'mina advanced generate-libp2p-keypair' as 'mina libp2p generate-keypair' --- automation/scripts/gen-keys-ledger.sh | 2 +- automation/scripts/generate-keys-and-ledger.sh | 2 +- src/app/cli/src/cli_entrypoint/mina_cli_entrypoint.ml | 1 + src/app/cli/src/init/client.ml | 7 +++++-- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/automation/scripts/gen-keys-ledger.sh b/automation/scripts/gen-keys-ledger.sh index 3e9d4624ce2..53f76bad42b 100755 --- a/automation/scripts/gen-keys-ledger.sh +++ b/automation/scripts/gen-keys-ledger.sh @@ -70,7 +70,7 @@ done echo "generating seeds' libp2p keys" mkdir "${KEYSDIR}/libp2p-keys" for i in $(seq 1 $SEEDS); do - mina advanced generate-libp2p-keypair --privkey-path "${KEYSDIR}/libp2p-keys/seed-${i}" 2>/dev/null + mina libp2p generate-keypair --privkey-path "${KEYSDIR}/libp2p-keys/seed-${i}" 2>/dev/null done diff --git a/automation/scripts/generate-keys-and-ledger.sh b/automation/scripts/generate-keys-and-ledger.sh index 6f3276111a4..a7e7551141e 100755 --- a/automation/scripts/generate-keys-and-ledger.sh +++ b/automation/scripts/generate-keys-and-ledger.sh @@ -110,7 +110,7 @@ function generate_key_files { docker run \ --mount type=bind,source=${output_dir},target=/keys \ --entrypoint /bin/bash $MINA_DAEMON_IMAGE \ - -c "MINA_LIBP2P_PASS='${privkey_pass}' mina advanced generate-libp2p-keypair -privkey-path /keys/${name_prefix}_libp2p_${k}" + -c "MINA_LIBP2P_PASS='${privkey_pass}' mina libp2p generate-keypair -privkey-path /keys/${name_prefix}_libp2p_${k}" done # ensure proper r+w permissions for access to keys external to container diff --git a/src/app/cli/src/cli_entrypoint/mina_cli_entrypoint.ml b/src/app/cli/src/cli_entrypoint/mina_cli_entrypoint.ml index 3f3d8ecba88..5c1e28f89dd 100644 --- a/src/app/cli/src/cli_entrypoint/mina_cli_entrypoint.ml +++ b/src/app/cli/src/cli_entrypoint/mina_cli_entrypoint.ml @@ -1728,6 +1728,7 @@ let mina_commands logger = ; ("client", Client.client) ; ("advanced", Client.advanced) ; ("ledger", Client.ledger) + ; ("libp2p", Client.libp2p) ; ( "internal" , Command.group ~summary:"Internal commands" (internal_commands logger) ) ; (Parallel.worker_command_name, Parallel.worker_command) diff --git a/src/app/cli/src/init/client.ml b/src/app/cli/src/init/client.ml index 2ea6c9f4287..08425c2dba8 100644 --- a/src/app/cli/src/init/client.ml +++ b/src/app/cli/src/init/client.ml @@ -1587,7 +1587,7 @@ let generate_libp2p_keypair = (* FIXME: I'd like to accumulate messages into this logger and only dump them out in failure paths. *) let logger = Logger.null () in (* Using the helper only for keypair generation requires no state. *) - File_system.with_temp_dir "coda-generate-libp2p-keypair" ~f:(fun tmpd -> + File_system.with_temp_dir "mina-generate-libp2p-keypair" ~f:(fun tmpd -> match%bind Mina_net2.create ~logger ~conf_dir:tmpd ~all_peers_seen_metric:false ~pids:(Child_processes.Termination.create_pid_table ()) @@ -2261,7 +2261,6 @@ let advanced = ; ("pooled-zkapp-commands", pooled_zkapp_commands) ; ("snark-pool-list", snark_pool_list) ; ("pending-snark-work", pending_snark_work) - ; ("generate-libp2p-keypair", generate_libp2p_keypair) ; ("compile-time-constants", compile_time_constants) ; ("node-status", node_status) ; ("visualization", Visualization.command_group) @@ -2290,3 +2289,7 @@ let ledger = ; ("hash", hash_ledger) ; ("currency", currency_in_ledger) ] + +let libp2p = + Command.group ~summary:"Libp2p commands" + [ ("generate-keypair", generate_libp2p_keypair) ] From 9267d26fa6512701d860fc239f04b5cc86f1f1f2 Mon Sep 17 00:00:00 2001 From: Nathan Holland Date: Tue, 6 Sep 2022 17:43:09 -0400 Subject: [PATCH 058/144] Update helm charts to initialize missing libp2p keypairs --- helm/archive-node/Chart.yaml | 2 +- helm/archive-node/templates/archive.yaml | 20 ++++++++++++++++ helm/block-producer/Chart.yaml | 2 +- .../templates/block-producer.yaml | 19 ++++++++++----- helm/block-producer/values.yaml | 2 -- helm/seed-node/Chart.yaml | 2 +- helm/seed-node/templates/seed-node.yaml | 19 ++++++++++----- helm/seed-node/values.yaml | 1 + helm/snark-worker/Chart.yaml | 2 +- .../templates/snark-coordinator.yaml | 24 ++++++++++++++++++- helm/snark-worker/values.yaml | 1 + 11 files changed, 75 insertions(+), 19 deletions(-) diff --git a/helm/archive-node/Chart.yaml b/helm/archive-node/Chart.yaml index 954d37bee63..d7ca746e38c 100644 --- a/helm/archive-node/Chart.yaml +++ b/helm/archive-node/Chart.yaml @@ -2,7 +2,7 @@ apiVersion: v2 name: archive-node description: A Helm chart for Mina Protocol's archive node type: application -version: 1.0.6 +version: 1.0.7 appVersion: 1.16.0 annotations: artifacthub.io/changes: | diff --git a/helm/archive-node/templates/archive.yaml b/helm/archive-node/templates/archive.yaml index 897ed01210e..8407f71d1ac 100644 --- a/helm/archive-node/templates/archive.yaml +++ b/helm/archive-node/templates/archive.yaml @@ -24,6 +24,19 @@ spec: prometheus.io/port: {{ .Values.archive.ports.metrics | quote }} prometheus.io/path: '/metrics' spec: + initContainers: + - name: libp2p-perms + image: {{ $.Values.mina.image | quote }} + command: + - bash + - -c + - mina libp2p generate-keypair --privkey-path /root/libp2p-keys/key + volumeMounts: + - name: actual-libp2p + mountPath: /root/libp2p-keys + env: + - name: MINA_LIBP2P_PASS + value: {{ $.Values.mina.privkeyPass | quote }} containers: {{- if .Values.archive.enableLocalDaemon }} - name: mina @@ -60,6 +73,7 @@ spec: {{- if .Values.mina.seedPeersURL }} "-peer-list-url", {{ .Values.mina.seedPeersURL | quote }}, {{- end -}} + "-libp2p-keypair", "/root/libp2p-keys/key", "-config-directory", "/root/.mina-config", "-client-port", "$(DAEMON_CLIENT_PORT)", "-rest-port", "$(DAEMON_REST_PORT)", @@ -85,6 +99,8 @@ spec: value: {{ .Values.mina.ports.p2p | quote }} - name: MINA_CLIENT_TRUSTLIST value: "10.0.0.0/8" + - name: MINA_LIBP2P_PASS + value: {{ $.Values.mina.privkeyPass | quote }} ports: - name: client-port protocol: TCP @@ -110,6 +126,8 @@ spec: - name: daemon-config mountPath: "/config/" {{- end }} + - name: actual-libp2p + mountPath: /root/libp2p-keys {{- end }} # Archive Process - name: archive @@ -151,3 +169,5 @@ spec: configMap: name: "{{ template "archive-node.fullname" . }}-daemon-config" {{- end }} + - name: actual-libp2p + emptyDir: {} diff --git a/helm/block-producer/Chart.yaml b/helm/block-producer/Chart.yaml index ba3e2cad4a0..0026d4cad5d 100644 --- a/helm/block-producer/Chart.yaml +++ b/helm/block-producer/Chart.yaml @@ -2,7 +2,7 @@ apiVersion: v2 name: block-producer description: A Helm chart for Mina Protocol's block producing network nodes type: application -version: 1.0.6 +version: 1.0.7 appVersion: 1.16.0 annotations: artifacthub.io/changes: | diff --git a/helm/block-producer/templates/block-producer.yaml b/helm/block-producer/templates/block-producer.yaml index d60f2e04226..f3b29623273 100644 --- a/helm/block-producer/templates/block-producer.yaml +++ b/helm/block-producer/templates/block-producer.yaml @@ -73,6 +73,19 @@ spec: mountPath: /libp2p-keys - name: actual-libp2p mountPath: /root/libp2p-keys + {{- else -}} + - name: libp2p-perms + image: {{ $.Values.mina.image | quote }} + command: + - bash + - -c + - mina libp2p generate-keypair --privkey-path /root/libp2p-keys/key + volumeMounts: + - name: actual-libp2p + mountPath: /root/libp2p-keys + env: + - name: MINA_LIBP2P_PASS + value: {{ $.Values.mina.privkeyPass | quote }} {{- end }} containers: {{ if $config.runWithUserAgent -}} @@ -196,9 +209,7 @@ spec: {{- if $config.enableGossipFlooding }} "-enable-flooding", "true", {{- end -}} - {{- if $config.libp2pSecret }} "-libp2p-keypair", "/root/libp2p-keys/key", - {{- end -}} {{- range $.Values.mina.seedPeers }} "-peer", {{ . | quote }}, {{- end -}} @@ -244,10 +255,8 @@ spec: value: "mina_network_block_data" - name: MINA_PRIVKEY_PASS value: {{ $.Values.mina.privkeyPass | quote }} - {{- if $config.libp2pSecret }} - name: MINA_LIBP2P_PASS value: {{ $.Values.mina.privkeyPass | quote }} - {{- end }} - name: MINA_CLIENT_TRUSTLIST value: "10.0.0.0/8" ports: @@ -272,10 +281,8 @@ spec: mountPath: /root/wallet-keys - name: config-dir mountPath: /root/.mina-config - {{- if $config.libp2pSecret }} - name: actual-libp2p mountPath: /root/libp2p-keys - {{- end }} {{- if $.Values.mina.uploadBlocksToGCloud }} - name: gcloud-keyfile mountPath: "/gcloud/" diff --git a/helm/block-producer/values.yaml b/helm/block-producer/values.yaml index 1dec0fa0ac4..7b382ff6ba5 100644 --- a/helm/block-producer/values.yaml +++ b/helm/block-producer/values.yaml @@ -51,7 +51,6 @@ blockProducerConfigs: isolated: false enableGossipFlooding: false enablePeerExchange: false - libp2pSecret: "libp2pYolo" enableArchive: true archiveAddress: archive-1:3086 - name: "test-2" @@ -61,7 +60,6 @@ blockProducerConfigs: isolated: false enableGossipFlooding: false enablePeerExchange: false - libp2pSecret: "libp2pYolo" enableArchive: false archiveAddress: archive-1:3086 - name: "test-3" diff --git a/helm/seed-node/Chart.yaml b/helm/seed-node/Chart.yaml index 9d760fdd67a..c609127ccb9 100644 --- a/helm/seed-node/Chart.yaml +++ b/helm/seed-node/Chart.yaml @@ -2,7 +2,7 @@ apiVersion: v2 name: seed-node description: A Helm chart for Mina Protocol's seed nodes type: application -version: 1.0.7 +version: 1.0.8 appVersion: 1.16.0 annotations: artifacthub.io/changes: | diff --git a/helm/seed-node/templates/seed-node.yaml b/helm/seed-node/templates/seed-node.yaml index 49c5b144aae..5b5f9df8178 100644 --- a/helm/seed-node/templates/seed-node.yaml +++ b/helm/seed-node/templates/seed-node.yaml @@ -37,6 +37,19 @@ spec: mountPath: /libp2p-keys - name: actual-libp2p mountPath: /root/libp2p-keys + {{- else -}} + - name: libp2p-perms + image: {{ $.Values.mina.image | quote }} + command: + - bash + - -c + - mina libp2p generate-keypair --privkey-path /root/libp2p-keys/key + volumeMounts: + - name: actual-libp2p + mountPath: /root/libp2p-keys + env: + - name: MINA_LIBP2P_PASS + value: {{ $.Values.mina.privkeyPass | quote }} {{- end }} containers: - name: mina @@ -77,9 +90,7 @@ spec: {{- if $.Values.mina.runtimeConfig }} "-config-file", "/config/daemon.json", {{- end }} - {{- if $config.libp2pSecret }} "-libp2p-keypair", "/root/libp2p-keys/key", - {{- end -}} {{- range $.Values.mina.seedPeers }} "-peer", {{ . | quote }}, {{- end }} @@ -111,10 +122,8 @@ spec: value: "mina_network_block_data" - name: DAEMON_EXTERNAL_PORT value: {{ default $.Values.mina.ports.p2p $config.externalPort | quote }} - {{- if $config.libp2pSecret }} - name: MINA_LIBP2P_PASS value: {{ $.Values.mina.privkeyPass | quote }} - {{- end }} ports: - name: client-port protocol: TCP @@ -133,10 +142,8 @@ spec: {{- include "healthcheck.seed.allChecks" $data | indent 8 }} imagePullPolicy: Always volumeMounts: - {{- if $config.libp2pSecret }} - name: actual-libp2p mountPath: /root/libp2p-keys - {{- end }} {{- if $.Values.mina.uploadBlocksToGCloud }} - name: gcloud-keyfile mountPath: "/gcloud/" diff --git a/helm/seed-node/values.yaml b/helm/seed-node/values.yaml index c75a4f0db32..7ce023df87f 100644 --- a/helm/seed-node/values.yaml +++ b/helm/seed-node/values.yaml @@ -8,6 +8,7 @@ mina: image: gcr.io/o1labs-192920/mina-daemon:1.2.0beta8-5b35b27-devnet useCustomEntrypoint: false customEntrypoint: "" + privkeyPass: "naughty blue worm" seedPeers: - /ip4/35.185.66.37/tcp/10105/p2p/12D3KooWQ7Pz3SPizarzx9ZhCJ6jNmQ2iDPgHQxVzRzqYU2SgRSd - /ip4/35.237.214.144/tcp/10120/p2p/12D3KooWGtjWnCcvkaSEbKuNbPivEogxqtLWcsJiQtURydptvrsA diff --git a/helm/snark-worker/Chart.yaml b/helm/snark-worker/Chart.yaml index b4aaa9f1a97..0fe0db21c9b 100644 --- a/helm/snark-worker/Chart.yaml +++ b/helm/snark-worker/Chart.yaml @@ -2,7 +2,7 @@ apiVersion: v2 name: snark-worker description: A Helm chart for Mina Protocol's SNARK worker nodes type: application -version: 1.0.4 +version: 1.0.5 appVersion: 1.16.0 annotations: artifacthub.io/changes: | diff --git a/helm/snark-worker/templates/snark-coordinator.yaml b/helm/snark-worker/templates/snark-coordinator.yaml index a336ccd8b98..df5310eef7d 100644 --- a/helm/snark-worker/templates/snark-coordinator.yaml +++ b/helm/snark-worker/templates/snark-coordinator.yaml @@ -22,6 +22,19 @@ spec: prometheus.io/port: {{ $.Values.mina.ports.metrics | quote }} prometheus.io/path: '/metrics' spec: + initContainers: + - name: libp2p-perms + image: {{ $.Values.mina.image | quote }} + command: + - bash + - -c + - mina libp2p generate-keypair --privkey-path /root/libp2p-keys/key + volumeMounts: + - name: actual-libp2p + mountPath: /root/libp2p-keys + env: + - name: MINA_LIBP2P_PASS + value: {{ $.Values.mina.privkeyPass | quote }} containers: - name: mina resources: @@ -46,6 +59,7 @@ spec: "-snark-worker-fee", "$(CODA_SNARK_FEE)", "-work-selection", "$(WORK_SELECTION)", "-enable-peer-exchange", "true", + "-libp2p-keypair", "/root/libp2p-keys/key", {{- if $.Values.mina.logTxnPoolGossip }} "-log-txn-pool-gossip", "true", {{- end -}} @@ -82,6 +96,8 @@ spec: value: {{ $.Values.mina.ports.p2p | quote }} - name: WORK_SELECTION value: {{$.Values.workSelectionAlgorithm | quote }} + - name: MINA_LIBP2P_PASS + value: {{ $.Values.mina.privkeyPass | quote }} ports: - name: client-port protocol: TCP @@ -100,13 +116,19 @@ spec: {{$data := dict "name" $name "healthcheck" $.Values.healthcheck }} {{- include "healthcheck.snarkCoordinator.allChecks" $data | indent 8 }} imagePullPolicy: Always - {{- if $.Values.mina.runtimeConfig }} volumeMounts: + {{- if $.Values.mina.runtimeConfig }} - name: daemon-config mountPath: "/config/" + {{- end }} + - name: actual-libp2p + mountPath: /root/libp2p-keys volumes: + {{- if $.Values.mina.runtimeConfig }} - name: daemon-config configMap: name: {{$.Values.coordinatorName }}-daemon-config {{- end }} + - name: actual-libp2p + emptyDir: {} {{- include "nodeSelector.preemptible" $.Values | indent 6 }} diff --git a/helm/snark-worker/values.yaml b/helm/snark-worker/values.yaml index 6316601a5dd..214d703dc60 100644 --- a/helm/snark-worker/values.yaml +++ b/helm/snark-worker/values.yaml @@ -13,6 +13,7 @@ mina: image: gcr.io/o1labs-192920/mina-daemon:1.2.0beta8-5b35b27-devnet useCustomEntrypoint: false customEntrypoint: "" + privkeyPass: "naughty blue worm" seedPeers: - /ip4/35.185.66.37/tcp/10105/p2p/12D3KooWQ7Pz3SPizarzx9ZhCJ6jNmQ2iDPgHQxVzRzqYU2SgRSd - /ip4/35.237.214.144/tcp/10120/p2p/12D3KooWGtjWnCcvkaSEbKuNbPivEogxqtLWcsJiQtURydptvrsA From e94a9e4fb1aa9b4cdcccbc9d7fad9875753facc4 Mon Sep 17 00:00:00 2001 From: georgeee Date: Wed, 7 Sep 2022 16:02:14 +0200 Subject: [PATCH 059/144] Fix a bug and re-enable TestBitswapSmoke Problem: when updating go-bitswap to v0.8.0, an integration was made improperly which led to TestBitswapSmoke failing. Solution: fix the bug in integration, namely call `bitswap.Server.NotifyNewBlocks` on every downloaded block. Additionally, go-bitswap is bumped to v0.9.0 and a small fix is applied to flake.nix. --- flake.nix | 2 ++ src/app/libp2p_helper/src/codanet.go | 4 ++-- src/app/libp2p_helper/src/go.mod | 2 +- src/app/libp2p_helper/src/go.sum | 4 ++-- src/app/libp2p_helper/src/libp2p_helper/bitswap.go | 8 ++++++-- .../libp2p_helper/src/libp2p_helper/bitswap_downloader.go | 4 ++-- .../src/libp2p_helper/bitswap_downloader_test.go | 2 +- src/app/libp2p_helper/src/libp2p_helper/bitswap_test.go | 4 ---- 8 files changed, 16 insertions(+), 14 deletions(-) diff --git a/flake.nix b/flake.nix index 0f351e04bdb..0582fbbb043 100644 --- a/flake.nix +++ b/flake.nix @@ -351,6 +351,8 @@ devShells.default = self.devShell.${system}; devShells.with-lsp = ocamlPackages.mina-dev.overrideAttrs (oa: { + buildInputs = oa.buildInputs + ++ [ pkgs.go_1_18 ]; nativeBuildInputs = oa.nativeBuildInputs ++ [ ocamlPackages.ocaml-lsp-server ]; shellHook = '' diff --git a/src/app/libp2p_helper/src/codanet.go b/src/app/libp2p_helper/src/codanet.go index 754bf33c05e..f9eb866ff36 100644 --- a/src/app/libp2p_helper/src/codanet.go +++ b/src/app/libp2p_helper/src/codanet.go @@ -226,7 +226,7 @@ type Helper struct { MsgStats *MessageStats Seeds []peer.AddrInfo NodeStatus []byte - HeartbeatPeer func(peer.ID) + HeartbeatPeer func(peer.ID) } type MessageStats struct { @@ -700,7 +700,7 @@ func MakeHelper(ctx context.Context, listenOn []ma.Multiaddr, externalAddr ma.Mu return nil, err } bitswapNetwork := bitnet.NewFromIpfsHost(host, kad, bitnet.Prefix(BitSwapExchange)) - bs := bitswap.New(context.Background(), bitswapNetwork, bstore.Blockstore()).(*bitswap.Bitswap) + bs := bitswap.New(context.Background(), bitswapNetwork, bstore.Blockstore()) // nil fields are initialized by beginAdvertising h := &Helper{ diff --git a/src/app/libp2p_helper/src/go.mod b/src/app/libp2p_helper/src/go.mod index 2b63c585a18..19fcc46c9e2 100644 --- a/src/app/libp2p_helper/src/go.mod +++ b/src/app/libp2p_helper/src/go.mod @@ -5,7 +5,7 @@ go 1.18 require ( capnproto.org/go/capnp/v3 v3.0.0-alpha.5 github.com/go-errors/errors v1.4.2 - github.com/ipfs/go-bitswap v0.8.0 + github.com/ipfs/go-bitswap v0.9.0 github.com/ipfs/go-block-format v0.0.3 github.com/ipfs/go-cid v0.2.0 github.com/ipfs/go-ds-badger v0.3.0 diff --git a/src/app/libp2p_helper/src/go.sum b/src/app/libp2p_helper/src/go.sum index c083e5be823..3bf0f3c767a 100644 --- a/src/app/libp2p_helper/src/go.sum +++ b/src/app/libp2p_helper/src/go.sum @@ -381,8 +381,8 @@ github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANyt github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo= github.com/ipfs/bbloom v0.0.4 h1:Gi+8EGJ2y5qiD5FbsbpX/TMNcJw8gSqr7eyjHa4Fhvs= github.com/ipfs/bbloom v0.0.4/go.mod h1:cS9YprKXpoZ9lT0n/Mw/a6/aFV6DTjTLYHeA+gyqMG0= -github.com/ipfs/go-bitswap v0.8.0 h1:UEV7kogQu2iGggkE9GhLykDrRCUpsNnpu2NODww/srw= -github.com/ipfs/go-bitswap v0.8.0/go.mod h1:/h8sBij8UVEaNWl8ABzpLRA5Y1cttdNUnpeGo2AA/LQ= +github.com/ipfs/go-bitswap v0.9.0 h1:/dZi/XhUN/aIk78pI4kaZrilUglJ+7/SCmOHWIpiy8E= +github.com/ipfs/go-bitswap v0.9.0/go.mod h1:zkfBcGWp4dQTQd0D0akpudhpOVUAJT9GbH9tDmR8/s4= github.com/ipfs/go-block-format v0.0.2/go.mod h1:AWR46JfpcObNfg3ok2JHDUfdiHRgWhJgCQF+KIgOPJY= github.com/ipfs/go-block-format v0.0.3 h1:r8t66QstRp/pd/or4dpnbVfXT5Gt7lOqRvC+/dDTpMc= github.com/ipfs/go-block-format v0.0.3/go.mod h1:4LmD4ZUw0mhO+JSKdpWwrzATiEfM7WWgQ8H5l6P8MVk= diff --git a/src/app/libp2p_helper/src/libp2p_helper/bitswap.go b/src/app/libp2p_helper/src/libp2p_helper/bitswap.go index 99d86646941..687f7a8ec45 100644 --- a/src/app/libp2p_helper/src/libp2p_helper/bitswap.go +++ b/src/app/libp2p_helper/src/libp2p_helper/bitswap.go @@ -197,8 +197,12 @@ func (bs *BitswapCtx) DeleteBlocks(keys [][32]byte) error { func (bs *BitswapCtx) ViewBlock(key [32]byte, callback func([]byte) error) error { return bs.storage.ViewBlock(bs.ctx, key, callback) } -func (bs *BitswapCtx) StoreBlock(block blocks.Block) error { - return bs.storage.StoreBlocks(bs.ctx, []blocks.Block{block}) +func (bs *BitswapCtx) StoreDownloadedBlock(block blocks.Block) error { + err := bs.storage.StoreBlocks(bs.ctx, []blocks.Block{block}) + if err != nil { + return err + } + return bs.engine.Server.NotifyNewBlocks(bs.ctx, block) } type BitswapBlockRequester struct { diff --git a/src/app/libp2p_helper/src/libp2p_helper/bitswap_downloader.go b/src/app/libp2p_helper/src/libp2p_helper/bitswap_downloader.go index dcc6ad17473..f8a73414c31 100644 --- a/src/app/libp2p_helper/src/libp2p_helper/bitswap_downloader.go +++ b/src/app/libp2p_helper/src/libp2p_helper/bitswap_downloader.go @@ -78,7 +78,7 @@ type BitswapState interface { DeleteStatus(key [32]byte) error DeleteBlocks(keys [][32]byte) error ViewBlock(key [32]byte, callback func([]byte) error) error - StoreBlock(block blocks.Block) error + StoreDownloadedBlock(block blocks.Block) error NodeDownloadParams() map[cid.Cid]map[root][]NodeIndex RootDownloadStates() map[root]*RootDownloadState MaxBlockSize() int @@ -251,7 +251,7 @@ func processDownloadedBlockStep(params map[root][]NodeIndex, block blocks.Block, func processDownloadedBlock(block blocks.Block, bs BitswapState) { bs.CheckInvariants() id := block.Cid() - err := bs.StoreBlock(block) + err := bs.StoreDownloadedBlock(block) if err != nil { bitswapLogger.Errorf("Failed to store block %s", id) } diff --git a/src/app/libp2p_helper/src/libp2p_helper/bitswap_downloader_test.go b/src/app/libp2p_helper/src/libp2p_helper/bitswap_downloader_test.go index cd6486d20b5..af1b2b5378b 100644 --- a/src/app/libp2p_helper/src/libp2p_helper/bitswap_downloader_test.go +++ b/src/app/libp2p_helper/src/libp2p_helper/bitswap_downloader_test.go @@ -702,7 +702,7 @@ func (bs *testBitswapState) ViewBlock(key [32]byte, callback func([]byte) error) } return callback(b) } -func (bs *testBitswapState) StoreBlock(block blocks.Block) error { +func (bs *testBitswapState) StoreDownloadedBlock(block blocks.Block) error { bs.blocks[block.Cid()] = block.RawData() return nil } diff --git a/src/app/libp2p_helper/src/libp2p_helper/bitswap_test.go b/src/app/libp2p_helper/src/libp2p_helper/bitswap_test.go index b5690549521..ec96f2ccd67 100644 --- a/src/app/libp2p_helper/src/libp2p_helper/bitswap_test.go +++ b/src/app/libp2p_helper/src/libp2p_helper/bitswap_test.go @@ -546,10 +546,6 @@ func TestBitswapMedium(t *testing.T) { } func TestBitswapSmoke(t *testing.T) { - if testing.Short() { - t.Skip("skipping TestBitswapSmoke in short mode") - return - } testBitswap(t, 50, 1, 1, 1<<16, true) } From 406b574ccba47bdf929a96f0dbbc6fc0c17c734d Mon Sep 17 00:00:00 2001 From: Alexander Bantyev Date: Fri, 2 Sep 2022 16:46:25 +0400 Subject: [PATCH 060/144] Nix: fix snarkyjs build --- flake.nix | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/flake.nix b/flake.nix index 0f351e04bdb..e614bb250d9 100644 --- a/flake.nix +++ b/flake.nix @@ -261,10 +261,10 @@ packages.snarky_js = nix-npm-buildPackage.buildNpmPackage { src = ./src/lib/snarky_js_bindings/snarkyjs; preBuild = '' - BINDINGS_PATH=./dist/node/node_bindings + BINDINGS_PATH=./src/node_bindings mkdir -p "$BINDINGS_PATH" - cp ${pkgs.plonk_wasm}/nodejs/plonk_wasm* ./dist/node/node_bindings - cp ${ocamlPackages.mina_client_sdk}/share/snarkyjs_bindings/snarky_js_node*.js ./dist/node/node_bindings + cp ${pkgs.plonk_wasm}/nodejs/plonk_wasm* "$BINDINGS_PATH" + cp ${ocamlPackages.mina_client_sdk}/share/snarkyjs_bindings/snarky_js_node*.js "$BINDINGS_PATH" chmod -R 777 "$BINDINGS_PATH" # TODO: deduplicate from ./scripts/build-snarkyjs-node.sh @@ -275,7 +275,7 @@ sed -i 's/function invalid_arg(s){throw \[0,Invalid_argument,s\]/function invalid_arg(s){throw joo_global_object.Error(s.c)/' "$BINDINGS_PATH"/snarky_js_node.bc.js sed -i 's/return \[0,Exn,t\]/return joo_global_object.Error(t.c)/' "$BINDINGS_PATH"/snarky_js_node.bc.js ''; - npmBuild = "npm run build -- --bindings=./dist/node/node_bindings"; + npmBuild = "npm run build"; # TODO: add snarky-run # TODO # checkPhase = "node ${./src/lib/snarky_js_bindings/tests/run-tests.mjs}" From 31db51822498b000b2605f072d0ca013cd04bede Mon Sep 17 00:00:00 2001 From: Alexander Bantyev Date: Wed, 7 Sep 2022 15:51:21 +0400 Subject: [PATCH 061/144] client_sdk.js tests: fix race condition --- src/app/client_sdk/tests/client_sdk.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/app/client_sdk/tests/client_sdk.js b/src/app/client_sdk/tests/client_sdk.js index 43fd050e1f6..a28db8ee68c 100644 --- a/src/app/client_sdk/tests/client_sdk.js +++ b/src/app/client_sdk/tests/client_sdk.js @@ -20,6 +20,8 @@ if (!nodeModulesExists || !fs.existsSync(`${nodeModules}/client_sdk`)) { } if (!nodeModulesExists || !fs.existsSync(`${nodeModules}/env`)) { fs.mkdirSync(`${nodeModules}/env`); +} +if (!nodeModulesExists || !fs.existsSync(`${nodeModules}/env/index.js`)) { fs.writeFileSync(`${nodeModules}/env/index.js`, "module.exports = {};"); } @@ -45,7 +47,6 @@ fs.readdirSync(wasmPath) }); let clientSDK = require("client_sdk"); -if (!nodeModulesExists) fs.rmSync(nodeModules, { recursive: true }); let didShutdown = false; From fe26006e3022d67d1a4759afd6aa2305490806d8 Mon Sep 17 00:00:00 2001 From: Paul Steckler Date: Wed, 7 Sep 2022 11:55:32 -0700 Subject: [PATCH 062/144] Rename Party, Parties --- frontend/mina-signer/src/MinaSigner.ts | 58 +- frontend/mina-signer/src/TSTypes.ts | 10 +- frontend/mina-signer/src/Utils.ts | 6 +- frontend/mina-signer/tests/party.test.ts | 38 +- graphql_schema.json | 100 +- scripts/mina-local-network/README.md | 2 +- scripts/send-parties-transaction.sh | 6 +- src/app/archive/archive_lib/extensional.ml | 6 +- src/app/archive/archive_lib/load_data.ml | 23 +- src/app/archive/archive_lib/processor.ml | 106 ++- src/app/archive/archive_lib/test.ml | 11 +- src/app/archive/create_schema.sql | 14 +- src/app/archive/drop_tables.sql | 6 +- src/app/archive/zkapp_tables.sql | 12 +- .../src/cli_entrypoint/mina_cli_entrypoint.ml | 10 +- src/app/cli/src/init/dune | 2 +- .../cli/src/init/{coda_run.ml => mina_run.ml} | 26 +- .../init/{coda_tracing.ml => mina_tracing.ml} | 0 .../src/init/transaction_snark_profiler.ml | 40 +- src/app/cli/src/tests/coda_worker.ml | 6 +- src/app/client_sdk/client_sdk.ml | 59 +- src/app/client_sdk/js_util.ml | 19 +- src/app/extract_blocks/extract_blocks.ml | 33 +- src/app/replayer/replayer.ml | 33 +- src/app/replayer/sql.ml | 4 +- src/app/replayer/test/archive_db.sql | 162 ++-- src/app/test_executive/dune | 2 +- src/app/test_executive/snarkyjs.ml | 23 +- src/app/test_executive/test_common.ml | 19 +- src/app/test_executive/zkapps.ml | 250 ++--- src/app/test_executive/zkapps_timing.ml | 110 ++- .../zkapp_test_transaction/lib/commands.ml | 152 +-- .../zkapp_test_transaction.ml | 32 +- .../ocaml-sodium/lib_test/test_scalar_mult.ml | 114 ++- src/graphql-ppx-config.inc | 4 +- src/lib/cli_lib/commands.ml | 2 +- src/lib/consensus/intf.ml | 4 +- src/lib/generated_graphql_queries/gen/gen.ml | 20 +- .../genesis_constants/genesis_constants.ml | 8 +- .../lib/genesis_ledger_helper_lib.ml | 19 +- .../hash_prefix_states/hash_prefix_states.ml | 15 +- .../hash_prefix_states/hash_prefix_states.mli | 14 +- src/lib/hash_prefixes/hash_prefixes.ml | 60 +- .../kubernetes_network.ml | 15 +- .../mina_automation.ml | 4 +- src/lib/integration_test_lib/intf.ml | 6 +- .../integration_test_lib/wait_condition.ml | 22 +- .../mina_base/{party.ml => account_update.ml} | 47 +- src/lib/mina_base/call_stack_digest.ml | 5 +- src/lib/mina_base/mina_base.ml | 4 +- src/lib/mina_base/receipt.ml | 39 +- src/lib/mina_base/receipt.mli | 15 +- src/lib/mina_base/stack_frame.ml | 51 +- src/lib/mina_base/transaction_status.ml | 56 +- src/lib/mina_base/unix/graphql_scalars.ml | 6 +- src/lib/mina_base/user_command.ml | 89 +- src/lib/mina_base/zkapp_call_forest.ml | 150 +-- .../{parties.ml => zkapp_command.ml} | 874 ++++++++++-------- src/lib/mina_base/zkapp_statement.ml | 48 +- .../mina_block/sample_precomputed_block.ml | 4 +- src/lib/mina_commands/mina_commands.ml | 16 +- .../mina_compile_config.ml | 6 +- src/lib/mina_generators/dune | 2 +- .../user_command_generators.ml | 85 +- ...erators.ml => zkapp_command_generators.ml} | 310 ++++--- ...ators.mli => zkapp_command_generators.mli} | 30 +- src/lib/mina_graphql/mina_graphql.ml | 116 ++- src/lib/mina_ledger/dune | 2 +- src/lib/mina_ledger/ledger.ml | 79 +- src/lib/mina_ledger/ledger.mli | 24 +- src/lib/mina_ledger/sparse_ledger.ml | 12 +- src/lib/mina_lib/mina_lib.ml | 22 +- src/lib/mina_lib/mina_lib.mli | 2 +- src/lib/mina_lib/mina_subscriptions.ml | 2 +- src/lib/mina_metrics/mina_metrics.mli | 6 +- .../mina_metrics/no_metrics/mina_metrics.ml | 6 +- .../prometheus_metrics/mina_metrics.ml | 25 +- src/lib/mina_net2/libp2p_stream.ml | 6 +- src/lib/mina_state/local_state.ml | 42 +- .../mina_wire_types/mina_base/mina_base.ml | 4 +- ...e_party.ml => mina_base_account_update.ml} | 0 .../mina_base/mina_base_user_command.ml | 7 +- ..._parties.ml => mina_base_zkapp_command.ml} | 28 +- ...arties.mli => mina_base_zkapp_command.mli} | 30 +- .../mina_wire_types/test/type_equalities.ml | 61 +- src/lib/network_pool/dune | 2 +- src/lib/network_pool/indexed_pool.ml | 94 +- src/lib/network_pool/transaction_pool.ml | 125 +-- src/lib/pickles/pickles.ml | 4 +- src/lib/runtime_config/runtime_config.ml | 16 +- src/lib/snark_worker/functor.ml | 37 +- src/lib/snark_worker/prod.ml | 44 +- .../lib/snarky_js_bindings_lib.ml | 187 ++-- src/lib/snarky_js_bindings/snarky_js_types.ml | 4 +- src/lib/snarky_js_bindings/snarkyjs | 2 +- .../simple-zkapp-mina-signer-quick.js | 8 +- .../test_module/simple-zkapp-mina-signer.js | 16 +- .../test_module/simple-zkapp-mock-apply.js | 24 +- .../test_module/simple-zkapp-token.js | 10 +- .../test_module/simple-zkapp.js | 16 +- .../test_module/to-hash-input.js | 50 +- src/lib/staged_ledger/dune | 2 +- src/lib/staged_ledger/staged_ledger.ml | 95 +- src/lib/string_sign/string_sign.ml | 3 +- src/lib/transaction/transaction.ml | 16 +- src/lib/transaction/transaction_hash.ml | 8 +- .../mina_transaction_logic.ml | 280 +++--- ...arties_logic.ml => zkapp_command_logic.ml} | 276 +++--- .../test/account_timing/account_timing.ml | 253 ++--- .../test/app_state/app_state.ml | 2 +- .../test/delegate/delegate.ml | 4 +- .../test/fee_payer/fee_payer.ml | 12 +- .../test/multisig_account/multisig_account.ml | 63 +- .../test/party_preconditions/dune | 2 +- .../party_preconditions.ml | 156 ++-- .../test/permissions/permissions.ml | 2 +- src/lib/transaction_snark/test/ring_sig.ml | 80 +- .../test/test_zkapp_update.ml | 4 +- .../test/token_symbol/token_symbol.ml | 2 +- .../transaction_union/transaction_union.ml | 2 +- src/lib/transaction_snark/test/util.ml | 60 +- src/lib/transaction_snark/test/util.mli | 10 +- .../test/verification_key/verification_key.ml | 4 +- .../test/voting_for/voting_for.ml | 4 +- .../test/zkapp_deploy/zkapp_deploy.ml | 32 +- .../transaction_snark/test/zkapp_fuzzy/dune | 2 +- .../test/zkapp_fuzzy/zkapp_fuzzy.ml | 116 +-- .../test/zkapp_payments/zkapp_payments.ml | 50 +- .../transaction_snark/test/zkapp_tokens/dune | 2 +- .../test/zkapp_tokens/zkapp_tokens.ml | 94 +- .../test/zkapp_uri/zkapp_uri.ml | 2 +- .../zkapps_examples/add_events/add_events.ml | 144 +-- .../empty_update/empty_update.ml | 66 +- .../initialize_state/initialize_state.ml | 144 +-- .../sequence_events/sequence_events.ml | 160 ++-- .../transaction_snark/transaction_snark.ml | 869 +++++++++-------- .../transaction_snark/transaction_snark.mli | 86 +- .../transaction_snark_scan_state.ml | 2 +- .../transaction_witness.ml | 14 +- .../transaction_witness.mli | 14 +- .../full_frontier/full_frontier.ml | 2 +- .../user_command_input/user_command_input.ml | 2 +- src/lib/verifier/common.ml | 37 +- .../dune | 6 +- .../zkapp_command_builder.ml} | 83 +- .../add_events/zkapps_add_events.ml | 9 +- .../empty_update/zkapps_empty_update.ml | 9 +- .../zkapps_initialize_state.ml | 41 +- .../sequence_events/zkapps_sequence_events.ml | 10 +- src/lib/zkapps_examples/zkapps_examples.ml | 120 +-- ...uilder.opam => zkapp_command_builder.opam} | 0 151 files changed, 4401 insertions(+), 3692 deletions(-) rename src/app/cli/src/init/{coda_run.ml => mina_run.ml} (97%) rename src/app/cli/src/init/{coda_tracing.ml => mina_tracing.ml} (100%) rename src/lib/mina_base/{party.ml => account_update.ml} (96%) rename src/lib/mina_base/{parties.ml => zkapp_command.ml} (55%) rename src/lib/mina_generators/{parties_generators.ml => zkapp_command_generators.ml} (83%) rename src/lib/mina_generators/{parties_generators.mli => zkapp_command_generators.mli} (70%) rename src/lib/mina_wire_types/mina_base/{mina_base_party.ml => mina_base_account_update.ml} (100%) rename src/lib/mina_wire_types/mina_base/{mina_base_parties.ml => mina_base_zkapp_command.ml} (71%) rename src/lib/mina_wire_types/mina_base/{mina_base_parties.mli => mina_base_zkapp_command.mli} (70%) rename src/lib/transaction_logic/{parties_logic.ml => zkapp_command_logic.ml} (83%) rename src/lib/{parties_builder => zkapp_command_builder}/dune (80%) rename src/lib/{parties_builder/parties_builder.ml => zkapp_command_builder/zkapp_command_builder.ml} (57%) rename src/{parties_builder.opam => zkapp_command_builder.opam} (100%) diff --git a/frontend/mina-signer/src/MinaSigner.ts b/frontend/mina-signer/src/MinaSigner.ts index 71777d09395..1b32e4359b4 100644 --- a/frontend/mina-signer/src/MinaSigner.ts +++ b/frontend/mina-signer/src/MinaSigner.ts @@ -11,12 +11,12 @@ import type { Payment, StakeDelegation, Message, - Party, - OtherParties, + AccountUpdate, + OtherZkapp_command, SignableData, } from "./TSTypes"; -import { isPayment, isMessage, isStakeDelegation, isParty } from "./Utils"; +import { isPayment, isMessage, isStakeDelegation, isAccountUpdate } from "./Utils"; const defaultValidUntil = "4294967295"; @@ -330,31 +330,31 @@ class Client { } /** - * Sign a parties transaction using a private key. + * Sign a zkapp_command transaction using a private key. * * This type of transaction allows a user to update state on a given * Smart Contract running on Mina. * - * @param party A object representing a Parties tx + * @param accountUpdate A object representing a Zkapp_command tx * @param privateKey The fee payer private key - * @returns Signed parties + * @returns Signed zkapp_command */ - public signParty(party: Party, privateKey: PrivateKey): Signed { - const parties = JSON.stringify(party.parties.otherParties); + public signAccountUpdate(accountUpdate: AccountUpdate, privateKey: PrivateKey): Signed { + const zkapp_command = JSON.stringify(accountUpdate.zkapp_command.accountUpdates); if ( - party.feePayer.fee === undefined || - party.feePayer.fee < this.getPartyMinimumFee(party.parties.otherParties) + accountUpdate.feePayer.fee === undefined || + accountUpdate.feePayer.fee < this.getAccountUpdateMinimumFee(accountUpdate.zkapp_command.accountUpdates) ) { - throw `Fee must be greater than ${this.getPartyMinimumFee( - party.parties.otherParties + throw `Fee must be greater than ${this.getAccountUpdateMinimumFee( + accountUpdate.zkapp_command.accountUpdates )}`; } - const memo = party.feePayer.memo ?? ""; - const fee = String(party.feePayer.fee); - const nonce = String(party.feePayer.nonce); - const feePayer = String(party.feePayer.feePayer); - const signedParties = minaSDK.signParty( - parties, + const memo = accountUpdate.feePayer.memo ?? ""; + const fee = String(accountUpdate.feePayer.fee); + const nonce = String(accountUpdate.feePayer.nonce); + const feePayer = String(accountUpdate.feePayer.feePayer); + const signedZkapp_command = minaSDK.signAccountUpdate( + zkapp_command, { feePayer, fee, @@ -364,9 +364,9 @@ class Client { privateKey ); return { - signature: JSON.parse(signedParties).feePayer.authorization, + signature: JSON.parse(signedZkapp_command).feePayer.authorization, data: { - parties: signedParties, + zkapp_command: signedZkapp_command, feePayer: { feePayer, fee, @@ -404,7 +404,7 @@ class Client { /** * Signs an arbitrary payload using a private key. This function can sign messages, - * payments, stake delegations, and parties. If the payload is unrecognized, an Error + * payments, stake delegations, and zkapp_command. If the payload is unrecognized, an Error * is thrown. * * @param payload A signable payload @@ -427,22 +427,22 @@ class Client { if (isStakeDelegation(payload)) { return this.signStakeDelegation(payload, privateKey); } - if (isParty(payload)) { - return this.signParty(payload, privateKey); + if (isAccountUpdate(payload)) { + return this.signAccountUpdate(payload, privateKey); } else { throw new Error(`Expected signable payload, got '${payload}'.`); } } /** - * Calculates the minimum fee of a party transaction. A fee for a party transaction is - * the sum of all parties plus the specified fee amount. If no fee is passed in, `0.001` + * Calculates the minimum fee of an accountUpdate transaction. A fee for a accountUpdate transaction is + * the sum of all zkapp_command plus the specified fee amount. If no fee is passed in, `0.001` * is used (according to the Mina spec) by default. - * @param p A party object - * @param fee The fee per party amount - * @returns The fee to be paid by the fee payer party + * @param p An accountUpdate object + * @param fee The fee per accountUpdate amount + * @returns The fee to be paid by the fee payer accountUpdate */ - public getPartyMinimumFee(p: OtherParties, fee: number = 0.001) { + public getAccountUpdateMinimumFee(p: OtherZkapp_command, fee: number = 0.001) { return p.reduce((accumulatedFee, _) => accumulatedFee + fee, 0); } } diff --git a/frontend/mina-signer/src/TSTypes.ts b/frontend/mina-signer/src/TSTypes.ts index e123d9609fc..ce8e573fbc9 100644 --- a/frontend/mina-signer/src/TSTypes.ts +++ b/frontend/mina-signer/src/TSTypes.ts @@ -40,14 +40,14 @@ export type Payment = { readonly validUntil?: UInt32; }; -export type OtherParties = { +export type OtherZkapp_command = { body: any; authorization: any; }[]; -export type Party = { - readonly parties: { - otherParties: OtherParties; +export type AccountUpdate = { + readonly zkapp_command: { + accountUpdates: OtherZkapp_command; }; readonly feePayer: { @@ -58,7 +58,7 @@ export type Party = { }; }; -export type SignableData = Message | StakeDelegation | Payment | Party; +export type SignableData = Message | StakeDelegation | Payment | AccountUpdate; export type Signed = { readonly signature: Signature; diff --git a/frontend/mina-signer/src/Utils.ts b/frontend/mina-signer/src/Utils.ts index f1ae587301d..13246aa836e 100644 --- a/frontend/mina-signer/src/Utils.ts +++ b/frontend/mina-signer/src/Utils.ts @@ -2,7 +2,7 @@ import type { Payment, StakeDelegation, Message, - Party, + AccountUpdate, SignableData, } from "./TSTypes"; @@ -15,8 +15,8 @@ function hasCommonProperties(data: SignableData) { ); } -export function isParty(p: Party): p is Party { - return p.hasOwnProperty("parties") && p.hasOwnProperty("feePayer"); +export function isAccountUpdate(p: AccountUpdate): p is AccountUpdate { + return p.hasOwnProperty("zkapp_command") && p.hasOwnProperty("feePayer"); } export function isPayment(p: SignableData): p is Payment { diff --git a/frontend/mina-signer/tests/party.test.ts b/frontend/mina-signer/tests/party.test.ts index 20e44f57fbd..eb07d2a21c8 100644 --- a/frontend/mina-signer/tests/party.test.ts +++ b/frontend/mina-signer/tests/party.test.ts @@ -1,15 +1,15 @@ import Client from "../src/MinaSigner"; -import type { Party, Signed } from "../src/TSTypes"; +import type { AccountUpdate, Signed } from "../src/TSTypes"; /** - * This is an example of a Parties transaction. This can be generated by + * This is an example of a Zkapp_command transaction. This can be generated by * creating a transaction in SnarkyJS and printing it out as JSON. * * TODO: When there is an example of how to do this in the SnarkyJS repo, * use that example instead. */ -let mockedParties = { - otherParties: [ +let mockedZkapp_command = { + accountUpdates: [ { body: { publicKey: "B62qieh9a3U8Z4s8c3DHhCyDECqyZLyRtGA5GBDMqqi6Lf1gaHX4hLt", @@ -100,18 +100,18 @@ let mockedParties = { ], memo: "E4YM2vTHhWEg66xpj52JErHUBU4pZ1yageL4TVDDpTTSsv8mK6YaH", }; -describe("Party", () => { +describe("AccountUpdate", () => { let client: Client; beforeAll(async () => { client = new Client({ network: "mainnet" }); }); - it("generates a signed party", () => { + it("generates a signed accountUpdate", () => { const keypair = client.genKeys(); - const parties = client.signParty( + const zkapp_command = client.signAccountUpdate( { - parties: mockedParties, + zkapp_command: mockedZkapp_command, feePayer: { feePayer: keypair.publicKey, fee: "1", @@ -121,15 +121,15 @@ describe("Party", () => { }, keypair.privateKey ); - expect(parties.data).toBeDefined(); - expect(parties.signature).toBeDefined(); + expect(zkapp_command.data).toBeDefined(); + expect(zkapp_command.signature).toBeDefined(); }); - it("generates a signed party by using signTransaction", () => { + it("generates a signed accountUpdate by using signTransaction", () => { const keypair = client.genKeys(); - const parties = client.signTransaction( + const zkapp_command = client.signTransaction( { - parties: mockedParties, + zkapp_command: mockedZkapp_command, feePayer: { feePayer: keypair.publicKey, fee: "1", @@ -138,17 +138,17 @@ describe("Party", () => { }, }, keypair.privateKey - ) as Signed; - expect(parties.data).toBeDefined(); - expect(parties.signature).toBeDefined(); + ) as Signed; + expect(zkapp_command.data).toBeDefined(); + expect(zkapp_command.signature).toBeDefined(); }); it("should throw an error if no fee is passed to the feePayer", () => { const keypair = client.genKeys(); expect(() => { - client.signParty( + client.signAccountUpdate( { - parties: mockedParties, + zkapp_command: mockedZkapp_command, // @ts-ignore - fee is not defined feePayer: { feePayer: keypair.publicKey, @@ -162,6 +162,6 @@ describe("Party", () => { }); it("should calculate a correct minimum fee", () => { - expect(client.getPartyMinimumFee(mockedParties.otherParties, 1)).toBe(1); + expect(client.getAccountUpdateMinimumFee(mockedZkapp_command.accountUpdates, 1)).toBe(1); }); }); diff --git a/graphql_schema.json b/graphql_schema.json index b97af2ffc0a..b4a769d6bee 100644 --- a/graphql_schema.json +++ b/graphql_schema.json @@ -667,7 +667,7 @@ { "kind": "SCALAR", "name": "SendTestZkappInput", - "description": "Parties for a test zkApp", + "description": "Zkapp_command for a test zkApp", "fields": null, "inputFields": null, "interfaces": null, @@ -676,7 +676,7 @@ }, { "kind": "INPUT_OBJECT", - "name": "FeePayerPartyBodyInput", + "name": "FeePayerAccountUpdateBodyInput", "description": null, "fields": [ { @@ -784,7 +784,7 @@ }, { "kind": "INPUT_OBJECT", - "name": "ZkappPartyFeePayerInput", + "name": "ZkappAccountUpdateFeePayerInput", "description": null, "fields": [ { @@ -796,7 +796,7 @@ "name": null, "ofType": { "kind": "INPUT_OBJECT", - "name": "FeePayerPartyBodyInput", + "name": "FeePayerAccountUpdateBodyInput", "ofType": null } }, @@ -829,7 +829,7 @@ "name": null, "ofType": { "kind": "INPUT_OBJECT", - "name": "FeePayerPartyBodyInput", + "name": "FeePayerAccountUpdateBodyInput", "ofType": null } }, @@ -1432,7 +1432,7 @@ }, { "kind": "INPUT_OBJECT", - "name": "PartyUpdateInput", + "name": "AccountUpdateUpdateInput", "description": null, "fields": [ { @@ -2740,7 +2740,7 @@ }, { "kind": "INPUT_OBJECT", - "name": "PartyBodyInput", + "name": "AccountUpdateBodyInput", "description": null, "fields": [ { @@ -2784,7 +2784,7 @@ "name": null, "ofType": { "kind": "INPUT_OBJECT", - "name": "PartyUpdateInput", + "name": "AccountUpdateUpdateInput", "ofType": null } }, @@ -3001,7 +3001,7 @@ "name": null, "ofType": { "kind": "INPUT_OBJECT", - "name": "PartyUpdateInput", + "name": "AccountUpdateUpdateInput", "ofType": null } }, @@ -3224,8 +3224,8 @@ }, { "kind": "INPUT_OBJECT", - "name": "ZkappPartyInput", - "description": "A party to a zkApp transaction", + "name": "ZkappAccountUpdateInput", + "description": "A account_update to a zkApp transaction", "fields": [ { "name": "body", @@ -3236,7 +3236,7 @@ "name": null, "ofType": { "kind": "INPUT_OBJECT", - "name": "PartyBodyInput", + "name": "AccountUpdateBodyInput", "ofType": null } }, @@ -3269,7 +3269,7 @@ "name": null, "ofType": { "kind": "INPUT_OBJECT", - "name": "PartyBodyInput", + "name": "AccountUpdateBodyInput", "ofType": null } }, @@ -3296,7 +3296,7 @@ }, { "kind": "INPUT_OBJECT", - "name": "PartiesInput", + "name": "Zkapp_commandInput", "description": null, "fields": [ { @@ -3308,7 +3308,7 @@ "name": null, "ofType": { "kind": "INPUT_OBJECT", - "name": "ZkappPartyFeePayerInput", + "name": "ZkappAccountUpdateFeePayerInput", "ofType": null } }, @@ -3316,7 +3316,7 @@ "deprecationReason": null }, { - "name": "otherParties", + "name": "accountUpdates", "description": null, "args": [], "type": { @@ -3330,7 +3330,7 @@ "name": null, "ofType": { "kind": "INPUT_OBJECT", - "name": "ZkappPartyInput", + "name": "ZkappAccountUpdateInput", "ofType": null } } @@ -3365,14 +3365,14 @@ "name": null, "ofType": { "kind": "INPUT_OBJECT", - "name": "ZkappPartyFeePayerInput", + "name": "ZkappAccountUpdateFeePayerInput", "ofType": null } }, "defaultValue": null }, { - "name": "otherParties", + "name": "accountUpdates", "description": null, "type": { "kind": "NON_NULL", @@ -3385,7 +3385,7 @@ "name": null, "ofType": { "kind": "INPUT_OBJECT", - "name": "ZkappPartyInput", + "name": "ZkappAccountUpdateInput", "ofType": null } } @@ -3418,15 +3418,16 @@ "description": null, "fields": [ { - "name": "parties", - "description": "Parties structure representing the transaction", + "name": "zkapp_command", + "description": + "Zkapp_command structure representing the transaction", "args": [], "type": { "kind": "NON_NULL", "name": null, "ofType": { "kind": "INPUT_OBJECT", - "name": "PartiesInput", + "name": "Zkapp_commandInput", "ofType": null } }, @@ -3436,14 +3437,15 @@ ], "inputFields": [ { - "name": "parties", - "description": "Parties structure representing the transaction", + "name": "zkapp_command", + "description": + "Zkapp_command structure representing the transaction", "type": { "kind": "NON_NULL", "name": null, "ofType": { "kind": "INPUT_OBJECT", - "name": "PartiesInput", + "name": "Zkapp_commandInput", "ofType": null } }, @@ -4806,7 +4808,7 @@ "description": "Send a zkApp (for internal testing purposes)", "args": [ { - "name": "parties", + "name": "zkapp_command", "description": null, "type": { "kind": "NON_NULL", @@ -6529,12 +6531,12 @@ }, { "kind": "OBJECT", - "name": "PartiesFailureReason", + "name": "ZkappCommandFailureReason", "description": null, "fields": [ { "name": "index", - "description": "List index of the party that failed", + "description": "List index of the account update that failed", "args": [], "type": { "kind": "SCALAR", "name": "Index", "ofType": null }, "isDeprecated": false, @@ -6543,7 +6545,7 @@ { "name": "failures", "description": - "Failure reason for the party or any nested parties", + "Failure reason for the account update or any nested zkapp command", "args": [], "type": { "kind": "NON_NULL", @@ -7659,7 +7661,7 @@ }, { "kind": "OBJECT", - "name": "PartyUpdate", + "name": "AccountUpdateUpdate", "description": null, "fields": [ { @@ -7762,7 +7764,7 @@ }, { "kind": "OBJECT", - "name": "PartyBody", + "name": "AccountUpdateBody", "description": null, "fields": [ { @@ -7806,7 +7808,7 @@ "name": null, "ofType": { "kind": "OBJECT", - "name": "PartyUpdate", + "name": "AccountUpdateUpdate", "ofType": null } }, @@ -7993,8 +7995,8 @@ }, { "kind": "OBJECT", - "name": "ZkappParty", - "description": "A party to a zkApp transaction", + "name": "ZkappAccountUpdate", + "description": "A account_update to a zkApp transaction", "fields": [ { "name": "body", @@ -8005,7 +8007,7 @@ "name": null, "ofType": { "kind": "OBJECT", - "name": "PartyBody", + "name": "AccountUpdateBody", "ofType": null } }, @@ -8046,7 +8048,7 @@ }, { "kind": "OBJECT", - "name": "FeePayerPartyBody", + "name": "FeePayerAccountUpdateBody", "description": null, "fields": [ { @@ -8109,7 +8111,7 @@ }, { "kind": "OBJECT", - "name": "ZkappPartyFeePayer", + "name": "ZkappAccountUpdateFeePayer", "description": null, "fields": [ { @@ -8121,7 +8123,7 @@ "name": null, "ofType": { "kind": "OBJECT", - "name": "FeePayerPartyBody", + "name": "FeePayerAccountUpdateBody", "ofType": null } }, @@ -8152,7 +8154,7 @@ }, { "kind": "OBJECT", - "name": "Parties", + "name": "Zkapp_command", "description": null, "fields": [ { @@ -8164,7 +8166,7 @@ "name": null, "ofType": { "kind": "OBJECT", - "name": "ZkappPartyFeePayer", + "name": "ZkappAccountUpdateFeePayer", "ofType": null } }, @@ -8172,7 +8174,7 @@ "deprecationReason": null }, { - "name": "otherParties", + "name": "accountUpdates", "description": null, "args": [], "type": { @@ -8186,7 +8188,7 @@ "name": null, "ofType": { "kind": "OBJECT", - "name": "ZkappParty", + "name": "ZkappAccountUpdate", "ofType": null } } @@ -8219,7 +8221,7 @@ }, { "kind": "SCALAR", - "name": "PartiesBase58", + "name": "ZkappCommandBase58", "description": "A Base58Check string representing the command", "fields": null, "inputFields": null, @@ -8241,7 +8243,7 @@ "name": null, "ofType": { "kind": "SCALAR", - "name": "PartiesBase58", + "name": "ZkappCommandBase58", "ofType": null } }, @@ -8265,15 +8267,15 @@ "deprecationReason": null }, { - "name": "parties", - "description": "Parties representing the transaction", + "name": "zkappCommand", + "description": "zkApp command representing the transaction", "args": [], "type": { "kind": "NON_NULL", "name": null, "ofType": { "kind": "OBJECT", - "name": "Parties", + "name": "Zkapp_command", "ofType": null } }, @@ -8290,7 +8292,7 @@ "name": null, "ofType": { "kind": "OBJECT", - "name": "PartiesFailureReason", + "name": "ZkappCommandFailureReason", "ofType": null } }, diff --git a/scripts/mina-local-network/README.md b/scripts/mina-local-network/README.md index f72bf81092c..f7b6e184995 100644 --- a/scripts/mina-local-network/README.md +++ b/scripts/mina-local-network/README.md @@ -82,7 +82,7 @@ - [http://localhost:4001/graphql](http://localhost:4001/graphql) - [http://localhost:4006/graphql](http://localhost:4006/graphql) - Etc. - - Depending on you environment configuration (amount of parties, starting port of ranges, etc.) + - Depending on you environment configuration (amount of zkapp_command, starting port of ranges, etc.) - You might want to get `encoded private key` instead of the raw data generated for you. You can do this using the following command: ```shell diff --git a/scripts/send-parties-transaction.sh b/scripts/send-parties-transaction.sh index 743b2dc56ce..9960e9624c6 100755 --- a/scripts/send-parties-transaction.sh +++ b/scripts/send-parties-transaction.sh @@ -1,7 +1,7 @@ #!/bin/bash -# Argument 1: is the query selector for the parties -# Argument 2: is the parties json +# Argument 1: is the query selector for the zkapp_command +# Argument 2: is the zkapp_command json # Argument 3: is the GraphQL URI set -x @@ -9,4 +9,4 @@ set -x curl \ -X POST \ -H "Content-Type: application/json" \ - -d "$(printf '{ "query": "mutation($input: SendZkappInput!) { sendZkapp(input: $input) %s }" , "variables": { "input": { "parties": %s } } }' "$1" "$2")" $3 + -d "$(printf '{ "query": "mutation($input: SendZkappInput!) { sendZkapp(input: $input) %s }" , "variables": { "input": { "zkapp_command": %s } } }' "$1" "$2")" $3 diff --git a/src/app/archive/archive_lib/extensional.ml b/src/app/archive/archive_lib/extensional.ml index 36394e58b0a..5743c7ae15c 100644 --- a/src/app/archive/archive_lib/extensional.ml +++ b/src/app/archive/archive_lib/extensional.ml @@ -72,15 +72,15 @@ module Internal_command = struct end] end -(* for fee payer, other parties, authorizations are omitted; signatures, proofs not in archive db *) +(* for fee payer, other zkapp_command, authorizations are omitted; signatures, proofs not in archive db *) module Zkapp_command = struct [%%versioned module Stable = struct module V1 = struct type t = { sequence_no : int - ; fee_payer : Party.Body.Fee_payer.Stable.V1.t - ; other_parties : Party.Body.Simple.Stable.V1.t list + ; fee_payer : Account_update.Body.Fee_payer.Stable.V1.t + ; account_updates : Account_update.Body.Simple.Stable.V1.t list ; memo : Signed_command_memo.Stable.V1.t ; hash : Transaction_hash.Stable.V1.t [@to_yojson Transaction_hash.to_yojson] diff --git a/src/app/archive/archive_lib/load_data.ml b/src/app/archive/archive_lib/load_data.ml index cbc2a280ec8..8636b22526e 100644 --- a/src/app/archive/archive_lib/load_data.ml +++ b/src/app/archive/archive_lib/load_data.ml @@ -247,7 +247,7 @@ let update_of_id pool update_id = ; vesting_period ; vesting_increment } - : Party.Update.Timing_info.t ) ) + : Account_update.Update.Timing_info.t ) ) in Set_or_keep.of_option tm_opt in @@ -270,7 +270,7 @@ let update_of_id pool update_id = ; timing ; voting_for } - : Party.Update.t ) + : Account_update.Update.t ) let staking_data_of_id pool id = let open Zkapp_basic in @@ -426,9 +426,10 @@ let get_fee_payer_body ~pool body_id = let nonce = nonce |> Unsigned.UInt32.of_int64 |> Mina_numbers.Account_nonce.of_uint32 in - return ({ public_key; fee; valid_until; nonce } : Party.Body.Fee_payer.t) + return + ({ public_key; fee; valid_until; nonce } : Account_update.Body.Fee_payer.t) -let get_other_party_body ~pool body_id = +let get_account_update_body ~pool body_id = let open Zkapp_basic in let query_db = Mina_caqti.query pool in let pk_of_id = pk_of_id pool in @@ -445,7 +446,7 @@ let get_other_party_body ~pool body_id = ; use_full_commitment ; caller } = - query_db ~f:(fun db -> Processor.Zkapp_other_party_body.load db body_id) + query_db ~f:(fun db -> Processor.Zkapp_account_update_body.load db body_id) in let%bind account_id = account_identifier_of_id pool account_identifier_id in let public_key = Account_id.public_key account_id in @@ -488,9 +489,9 @@ let get_other_party_body ~pool body_id = Option.value_exn nonce |> Unsigned.UInt32.of_int64 |> Mina_numbers.Account_nonce.of_uint32 in - return @@ Party.Account_precondition.Nonce nonce + return @@ Account_update.Account_precondition.Nonce nonce | Accept -> - return Party.Account_precondition.Accept + return Account_update.Account_precondition.Accept | Full -> assert (Option.is_some precondition_account_id) ; let%bind { balance_id @@ -599,7 +600,7 @@ let get_other_party_body ~pool body_id = let proved_state = Or_ignore.of_option proved_state in let is_new = Or_ignore.of_option is_new in return - (Party.Account_precondition.Full + (Account_update.Account_precondition.Full { balance ; nonce ; receipt_chain_hash @@ -610,7 +611,7 @@ let get_other_party_body ~pool body_id = ; is_new } ) in - let caller = Party.Call_type.of_string caller in + let caller = Account_update.Call_type.of_string caller in return ( { public_key ; token_id @@ -622,13 +623,13 @@ let get_other_party_body ~pool body_id = ; call_data ; call_depth ; preconditions = - { Party.Preconditions.network = protocol_state_precondition + { Account_update.Preconditions.network = protocol_state_precondition ; account = account_precondition } ; use_full_commitment ; caller } - : Party.Body.Simple.t ) + : Account_update.Body.Simple.t ) let get_account_accessed ~pool (account : Processor.Accounts_accessed.t) : (int * Account.t) Deferred.t = diff --git a/src/app/archive/archive_lib/processor.ml b/src/app/archive/archive_lib/processor.ml index 0068238f811..ab089ebb022 100644 --- a/src/app/archive/archive_lib/processor.ml +++ b/src/app/archive/archive_lib/processor.ml @@ -589,7 +589,7 @@ module Zkapp_timing_info = struct let table_name = "zkapp_timing_info" let add_if_doesn't_exist (module Conn : CONNECTION) - (timing_info : Party.Update.Timing_info.t) = + (timing_info : Account_update.Update.Timing_info.t) = let initial_minimum_balance = Currency.Balance.to_string timing_info.initial_minimum_balance in @@ -670,8 +670,8 @@ module Zkapp_updates = struct let table_name = "zkapp_updates" - let add_if_doesn't_exist (module Conn : CONNECTION) (update : Party.Update.t) - = + let add_if_doesn't_exist (module Conn : CONNECTION) + (update : Account_update.Update.t) = let open Deferred.Result.Let_syntax in let%bind app_state_id = Vector.map ~f:Zkapp_basic.Set_or_keep.to_option update.app_state @@ -878,7 +878,7 @@ end module Zkapp_account_precondition = struct type t = - { kind : Party.Account_precondition.Tag.t + { kind : Account_update.Account_precondition.Tag.t ; precondition_account_id : int option ; nonce : int64 option } @@ -886,7 +886,7 @@ module Zkapp_account_precondition = struct let zkapp_account_precondition_kind_typ = let encode = function - | Party.Account_precondition.Tag.Full -> + | Account_update.Account_precondition.Tag.Full -> "full" | Nonce -> "nonce" @@ -895,11 +895,11 @@ module Zkapp_account_precondition = struct in let decode = function | "full" -> - Result.return Party.Account_precondition.Tag.Full + Result.return Account_update.Account_precondition.Tag.Full | "nonce" -> - Result.return Party.Account_precondition.Tag.Nonce + Result.return Account_update.Account_precondition.Tag.Nonce | "accept" -> - Result.return Party.Account_precondition.Tag.Accept + Result.return Account_update.Account_precondition.Tag.Accept | _ -> Result.failf "Failed to decode zkapp_account_precondition_kind_typ" in @@ -913,20 +913,20 @@ module Zkapp_account_precondition = struct let table_name = "zkapp_account_precondition" let add_if_doesn't_exist (module Conn : CONNECTION) - (account_precondition : Party.Account_precondition.t) = + (account_precondition : Account_update.Account_precondition.t) = let open Deferred.Result.Let_syntax in let%bind precondition_account_id = match account_precondition with - | Party.Account_precondition.Full acct -> + | Account_update.Account_precondition.Full acct -> Zkapp_precondition_account.add_if_doesn't_exist (module Conn) acct >>| Option.some | _ -> return None in - let kind = Party.Account_precondition.tag account_precondition in + let kind = Account_update.Account_precondition.tag account_precondition in let nonce = match account_precondition with - | Party.Account_precondition.Nonce nonce -> + | Account_update.Account_precondition.Nonce nonce -> Option.some @@ Unsigned.UInt32.to_int64 nonce | _ -> None @@ -1440,7 +1440,7 @@ module Zkapp_events = struct let table_name = "zkapp_events" let add_if_doesn't_exist (module Conn : CONNECTION) - (events : Party.Body.Events'.t) = + (events : Account_update.Body.Events'.t) = let open Deferred.Result.Let_syntax in let%bind (element_ids : int array) = Mina_caqti.deferred_result_list_map events @@ -1461,7 +1461,7 @@ module Zkapp_events = struct id end -module Zkapp_other_party_body = struct +module Zkapp_account_update_body = struct type t = { account_identifier_id : int ; update_id : int @@ -1483,10 +1483,10 @@ module Zkapp_other_party_body = struct Caqti_type. [ int; int; string; bool; int; int; int; int; int; int; bool; string ] - let table_name = "zkapp_other_party_body" + let table_name = "zkapp_account_update_body" let add_if_doesn't_exist (module Conn : CONNECTION) - (body : Party.Body.Simple.t) = + (body : Account_update.Body.Simple.t) = let open Deferred.Result.Let_syntax in let account_identifier = Account_id.create body.public_key body.token_id in let%bind account_identifier_id = @@ -1525,7 +1525,7 @@ module Zkapp_other_party_body = struct in let call_depth = body.call_depth in let use_full_commitment = body.use_full_commitment in - let caller = Party.Call_type.to_string body.caller in + let caller = Account_update.Call_type.to_string body.caller in let value = { account_identifier_id ; update_id @@ -1560,7 +1560,7 @@ module Zkapp_other_party_body = struct id end -module Zkapp_other_party = struct +module Zkapp_account_update = struct type t = { body_id : int; authorization_kind : Control.Tag.t } [@@deriving fields, hlist] @@ -1589,14 +1589,17 @@ module Zkapp_other_party = struct Mina_caqti.Type_spec.custom_type ~to_hlist ~of_hlist Caqti_type.[ int; authorization_kind_typ ] - let table_name = "zkapp_other_party" + let table_name = "zkapp_account_update" - let add_if_doesn't_exist (module Conn : CONNECTION) (party : Party.Simple.t) = + let add_if_doesn't_exist (module Conn : CONNECTION) + (account_update : Account_update.Simple.t) = let open Deferred.Result.Let_syntax in let%bind body_id = - Zkapp_other_party_body.add_if_doesn't_exist (module Conn) party.body + Zkapp_account_update_body.add_if_doesn't_exist + (module Conn) + account_update.body in - let authorization_kind = Control.tag party.authorization in + let authorization_kind = Control.tag account_update.authorization in let value = { body_id; authorization_kind } in Mina_caqti.select_insert_into_cols ~select:("id", Caqti_type.int) ~table_name ~cols:(Fields.names, typ) @@ -1626,7 +1629,7 @@ module Zkapp_fee_payer_body = struct let table_name = "zkapp_fee_payer_body" let add_if_doesn't_exist (module Conn : CONNECTION) - (body : Party.Body.Fee_payer.t) = + (body : Account_update.Body.Fee_payer.t) = let open Deferred.Result.Let_syntax in let account_identifier = Account_id.create body.public_key Token_id.default @@ -1815,7 +1818,7 @@ module User_command = struct ( match via with | `Ident -> Signed_command.tag_string t - | `Parties -> + | `Zkapp_command -> "zkapp" ) ; fee_payer_id ; source_id @@ -1880,7 +1883,7 @@ module User_command = struct module Zkapp_command = struct type t = { zkapp_fee_payer_body_id : int - ; zkapp_other_parties_ids : int array + ; zkapp_account_updates_ids : int array ; memo : string ; hash : string } @@ -1906,40 +1909,44 @@ module User_command = struct @@ Mina_caqti.select_cols_from_id ~table_name ~cols:Fields.names ) id - let add_if_doesn't_exist (module Conn : CONNECTION) (ps : Parties.t) = + let add_if_doesn't_exist (module Conn : CONNECTION) (ps : Zkapp_command.t) = let open Deferred.Result.Let_syntax in - let parties = Parties.to_simple ps in + let zkapp_command = Zkapp_command.to_simple ps in let%bind zkapp_fee_payer_body_id = Zkapp_fee_payer_body.add_if_doesn't_exist (module Conn) - parties.fee_payer.body + zkapp_command.fee_payer.body in - let%bind zkapp_other_parties_ids = - Mina_caqti.deferred_result_list_map parties.other_parties - ~f:(Zkapp_other_party.add_if_doesn't_exist (module Conn)) + let%bind zkapp_account_updates_ids = + Mina_caqti.deferred_result_list_map zkapp_command.account_updates + ~f:(Zkapp_account_update.add_if_doesn't_exist (module Conn)) >>| Array.of_list in let memo = ps.memo |> Signed_command_memo.to_base58_check in let hash = - Transaction_hash.hash_command (Parties ps) + Transaction_hash.hash_command (Zkapp_command ps) |> Transaction_hash.to_base58_check in Mina_caqti.select_insert_into_cols ~select:("id", Caqti_type.int) ~table_name:"zkapp_commands" ~cols:(Fields.names, typ) ~tannot:(function - | "zkapp_other_parties_ids" -> Some "int[]" | _ -> None ) + | "zkapp_account_updates_ids" -> Some "int[]" | _ -> None ) (module Conn) - { zkapp_fee_payer_body_id; zkapp_other_parties_ids; memo; hash } + { zkapp_fee_payer_body_id; zkapp_account_updates_ids; memo; hash } end - let via (t : User_command.t) : [ `Parties | `Ident ] = - match t with Signed_command _ -> `Ident | Parties _ -> `Parties + let via (t : User_command.t) : [ `Zkapp_command | `Ident ] = + match t with + | Signed_command _ -> + `Ident + | Zkapp_command _ -> + `Zkapp_command let add_if_doesn't_exist conn (t : User_command.t) = match t with | Signed_command sc -> Signed_command.add_if_doesn't_exist conn ~via:(via t) sc - | Parties ps -> + | Zkapp_command ps -> Zkapp_command.add_if_doesn't_exist conn ps let find conn ~(transaction_hash : Transaction_hash.t) = @@ -2301,14 +2308,14 @@ module Block_and_signed_command = struct (block_id, user_command_id, sequence_no) end -module Zkapp_party_failures = struct +module Zkapp_account_update_failures = struct type t = { index : int; failures : string array } [@@deriving fields, hlist] let typ = Mina_caqti.Type_spec.custom_type ~to_hlist ~of_hlist Caqti_type.[ int; Mina_caqti.array_string_typ ] - let table_name = "zkapp_party_failures" + let table_name = "zkapp_account_update_failures" let add_if_doesn't_exist (module Conn : CONNECTION) index failures = let failures = @@ -2358,7 +2365,7 @@ module Block_and_zkapp_command = struct let%map failure_reasons_ids_list = Mina_caqti.deferred_result_list_map reasons ~f:(fun (ndx, failure_reasons) -> - Zkapp_party_failures.add_if_doesn't_exist + Zkapp_account_update_failures.add_if_doesn't_exist (module Conn) ndx failure_reasons ) in @@ -2858,7 +2865,7 @@ module Block = struct ~block_id ~user_command_id:id ~sequence_no ~status:user_command.status >>| ignore - | Parties _ -> + | Zkapp_command _ -> let status, failure_reasons = failure_reasons user_command.status in @@ -3205,20 +3212,23 @@ module Block = struct let%bind zkapp_cmds_ids_and_seq_nos = let%map zkapp_cmds_and_ids_rev = Mina_caqti.deferred_result_list_fold block.zkapp_cmds ~init:[] - ~f:(fun acc ({ fee_payer; other_parties; memo; _ } as zkapp_cmd) -> + ~f:(fun acc ({ fee_payer; account_updates; memo; _ } as zkapp_cmd) -> (* add authorizations, not stored in the db *) - let (fee_payer : Party.Fee_payer.t) = + let (fee_payer : Account_update.Fee_payer.t) = { body = fee_payer; authorization = Signature.dummy } in - let (other_parties : Party.Simple.t list) = - List.map other_parties - ~f:(fun (body : Party.Body.Simple.t) : Party.Simple.t -> - { body; authorization = None_given } ) + let (account_updates : Account_update.Simple.t list) = + List.map account_updates + ~f:(fun + (body : Account_update.Body.Simple.t) + : + Account_update.Simple.t + -> { body; authorization = None_given } ) in let%map cmd_id = User_command.Zkapp_command.add_if_doesn't_exist (module Conn) - (Parties.of_simple { fee_payer; other_parties; memo }) + (Zkapp_command.of_simple { fee_payer; account_updates; memo }) in (zkapp_cmd, cmd_id) :: acc ) in diff --git a/src/app/archive/archive_lib/test.ml b/src/app/archive/archive_lib/test.ml index c867f5605d4..b19b06cb1c6 100644 --- a/src/app/archive/archive_lib/test.ml +++ b/src/app/archive/archive_lib/test.ml @@ -61,7 +61,7 @@ let%test_module "Archive node unit tests" = Mina_state.Protocol_state.Body.view genesis_state_body let user_command_zkapp_gen : - ('a, Parties.t) User_command.t_ Base_quickcheck.Generator.t = + ('a, Zkapp_command.t) User_command.t_ Base_quickcheck.Generator.t = let open Base_quickcheck.Generator.Let_syntax in let%bind initial_balance = Base_quickcheck.Generator.int64_uniform_inclusive 200_000_000_000_000L @@ -108,11 +108,12 @@ let%test_module "Archive node unit tests" = Mina_ledger.Ledger.get_or_create_account ledger account_id account |> Or_error.ok_exn ) |> fun _ -> - let%map (parties : Parties.t) = - Mina_generators.Parties_generators.gen_parties_from ~fee_payer_keypair - ~keymap ~ledger ~protocol_state_view:genesis_state_view () + let%map (zkapp_command : Zkapp_command.t) = + Mina_generators.Zkapp_command_generators.gen_zkapp_command_from + ~fee_payer_keypair ~keymap ~ledger + ~protocol_state_view:genesis_state_view () in - User_command.Parties parties + User_command.Zkapp_command zkapp_command let fee_transfer_gen = Fee_transfer.Single.Gen.with_random_receivers ~keys ~min_fee:0 ~max_fee:10 diff --git a/src/app/archive/create_schema.sql b/src/app/archive/create_schema.sql index 9adcef3cc1f..7e8e81151cd 100644 --- a/src/app/archive/create_schema.sql +++ b/src/app/archive/create_schema.sql @@ -107,14 +107,14 @@ CREATE INDEX idx_voting_for_value ON voting_for(value); we don't store a signature, the fee payer here refers directly to the fee payer body. - zkapp_other_parties_ids refers to a list of ids in zkapp_party. - The values in zkapp_other_parties_ids are unenforced foreign keys - that reference zkapp_party_body(id), and not NULL. + zkapp_account_updates_ids refers to a list of ids in zkapp_account_update. + The values in zkapp_account_updates_ids are unenforced foreign keys + that reference zkapp_account_update_body(id), and not NULL. */ CREATE TABLE zkapp_commands ( id serial PRIMARY KEY , zkapp_fee_payer_body_id int NOT NULL REFERENCES zkapp_fee_payer_body(id) -, zkapp_other_parties_ids int[] NOT NULL +, zkapp_account_updates_ids int[] NOT NULL , memo text NOT NULL , hash text NOT NULL UNIQUE ); @@ -226,8 +226,8 @@ CREATE INDEX idx_blocks_internal_commands_secondary_sequence_no ON blocks_intern sequence_no gives the order within all transactions in the block The `failure_reasons` column is not NULL iff `status` is `failed`. The - entries in the array are unenforced foreign key references to `zkapp_party_failures(id)`. - Each element of the array refers to the failures for a party in `other_parties`, and + entries in the array are unenforced foreign key references to `zkapp_account_update_failures(id)`. + Each element of the array refers to the failures for an account update in `account_updates`, and is not NULL. Blocks command convention @@ -237,7 +237,7 @@ CREATE TABLE blocks_zkapp_commands ( block_id int NOT NULL REFERENCES blocks(id) ON DELETE CASCADE , zkapp_command_id int NOT NULL REFERENCES zkapp_commands(id) ON DELETE CASCADE , sequence_no int NOT NULL -, status transaction_status NOT NULL +, status transaction_status NOT NULL , failure_reasons_ids int[] , PRIMARY KEY (block_id, zkapp_command_id, sequence_no) ); diff --git a/src/app/archive/drop_tables.sql b/src/app/archive/drop_tables.sql index f6b6338dd25..98182165903 100644 --- a/src/app/archive/drop_tables.sql +++ b/src/app/archive/drop_tables.sql @@ -10,7 +10,7 @@ DROP TABLE blocks_user_commands; DROP TABLE blocks_zkapp_commands; -DROP TABLE zkapp_party_failures; +DROP TABLE zkapp_account_update_failures; DROP TABLE accounts_accessed; @@ -36,9 +36,9 @@ DROP TABLE zkapp_commands; DROP TABLE zkapp_fee_payer_body; -DROP TABLE zkapp_other_party; +DROP TABLE zkapp_account_update; -DROP TABLE zkapp_other_party_body; +DROP TABLE zkapp_account_update_body; DROP TYPE call_type_type; diff --git a/src/app/archive/zkapp_tables.sql b/src/app/archive/zkapp_tables.sql index 66d6393ced5..e45f54e5238 100644 --- a/src/app/archive/zkapp_tables.sql +++ b/src/app/archive/zkapp_tables.sql @@ -259,7 +259,7 @@ CREATE TYPE call_type_type AS ENUM ('call', 'delegate_call'); /* events_ids and sequence_events_ids indicate a list of ids in zkapp_state_data_array. */ -CREATE TABLE zkapp_other_party_body +CREATE TABLE zkapp_account_update_body ( id serial PRIMARY KEY , account_identifier_id int NOT NULL REFERENCES account_identifiers(id) , update_id int NOT NULL REFERENCES zkapp_updates(id) @@ -275,16 +275,16 @@ CREATE TABLE zkapp_other_party_body , caller call_type_type NOT NULL ); -CREATE TABLE zkapp_other_party +CREATE TABLE zkapp_account_update ( id serial PRIMARY KEY -, body_id int NOT NULL REFERENCES zkapp_other_party_body(id) +, body_id int NOT NULL REFERENCES zkapp_account_update_body(id) , authorization_kind zkapp_authorization_kind_type NOT NULL ); -/* a list of of failures for a party in a zkApp - the index is the index into the `other_parties` +/* a list of of failures for an account update in a zkApp + the index is the index into the `account_updates` */ -CREATE TABLE zkapp_party_failures +CREATE TABLE zkapp_account_update_failures ( id serial PRIMARY KEY , index int NOT NULL , failures text[] NOT NULL diff --git a/src/app/cli/src/cli_entrypoint/mina_cli_entrypoint.ml b/src/app/cli/src/cli_entrypoint/mina_cli_entrypoint.ml index 30cc18e07d8..baff9f524cd 100644 --- a/src/app/cli/src/cli_entrypoint/mina_cli_entrypoint.ml +++ b/src/app/cli/src/cli_entrypoint/mina_cli_entrypoint.ml @@ -1128,7 +1128,7 @@ let setup_daemon logger = or_from_config YJ.Util.to_int_option "stop-time" ~default:Cli_lib.Default.stop_time stop_time in - if enable_tracing then Coda_tracing.start conf_dir |> don't_wait_for ; + if enable_tracing then Mina_tracing.start conf_dir |> don't_wait_for ; let seed_peer_list_url = Option.value_map seed_peer_list_url ~f:Option.some ~default: @@ -1209,12 +1209,12 @@ Pass one of -peer, -peer-list-file, -seed, -peer-list-url.|} ; ~f:(fun pk -> `Other pk) in let current_protocol_version = - Coda_run.get_current_protocol_version + Mina_run.get_current_protocol_version ~compile_time_current_protocol_version ~conf_dir ~logger curr_protocol_version in let proposed_protocol_version_opt = - Coda_run.get_proposed_protocol_version_opt ~conf_dir ~logger + Mina_run.get_proposed_protocol_version_opt ~conf_dir ~logger proposed_protocol_version in ( match @@ -1320,7 +1320,7 @@ Pass one of -peer, -peer-list-file, -seed, -peer-list-url.|} ; in Node_error_service.set_config ~get_node_state ~node_error_url:(Uri.of_string url) ~contact_info ) ; - Coda_run.handle_shutdown ~monitor ~time_controller ~conf_dir + Mina_run.handle_shutdown ~monitor ~time_controller ~conf_dir ~child_pids:pids ~top_logger:logger mina_ref ; Async.Scheduler.within' ~monitor @@ fun () -> @@ -1337,7 +1337,7 @@ Pass one of -peer, -peer-list-file, -seed, -peer-list-url.|} ; (Pipe_lib.Strict_pipe.Reader.iter_without_pushback (Mina_lib.validated_transitions mina) ~f:ignore ) ; - Coda_run.setup_local_server ?client_trustlist ~rest_server_port + Mina_run.setup_local_server ?client_trustlist ~rest_server_port ~insecure_rest_server ~open_limited_graphql_port ?limited_graphql_port mina ; let%bind () = diff --git a/src/app/cli/src/init/dune b/src/app/cli/src/init/dune index 932f54b4166..207febd09a8 100644 --- a/src/app/cli/src/init/dune +++ b/src/app/cli/src/init/dune @@ -109,7 +109,7 @@ pickles pickles.backend snark_params - parties_builder + zkapp_command_builder ) (instrumentation (backend bisect_ppx)) (preprocessor_deps ../../../../config.mlh diff --git a/src/app/cli/src/init/coda_run.ml b/src/app/cli/src/init/mina_run.ml similarity index 97% rename from src/app/cli/src/init/coda_run.ml rename to src/app/cli/src/init/mina_run.ml index 55b5d9f5b2b..c4ec5aff8d4 100644 --- a/src/app/cli/src/init/coda_run.ml +++ b/src/app/cli/src/init/mina_run.ml @@ -373,9 +373,9 @@ let setup_local_server ?(client_trustlist = []) ?rest_server_port return (snark_pool_list coda) ) ; implement Daemon_rpcs.Start_tracing.rpc (fun () () -> let open Mina_lib.Config in - Coda_tracing.start (Mina_lib.config coda).conf_dir ) + Mina_tracing.start (Mina_lib.config coda).conf_dir ) ; implement Daemon_rpcs.Stop_tracing.rpc (fun () () -> - Coda_tracing.stop () ; Deferred.unit ) + Mina_tracing.stop () ; Deferred.unit ) ; implement Daemon_rpcs.Visualization.Frontier.rpc (fun () filename -> return (Mina_lib.visualize_frontier ~filename coda) ) ; implement Daemon_rpcs.Visualization.Registered_masks.rpc @@ -419,20 +419,23 @@ let setup_local_server ?(client_trustlist = []) ?rest_server_port Cryptography.Snark_work_histogram.observe Cryptography.snark_work_merge_time_sec (Time.Span.to_sec total)) | `Transition -> - let parties_count, proof_parties_count = + let zkapp_command_count, proof_zkapp_command_count = (*should be Some in the case of `Transition*) match Option.value_exn transaction_opt with | Mina_transaction.Transaction.Command - (Mina_base.User_command.Parties parties) -> - Mina_base.Parties.Call_forest.fold parties.other_parties - ~init:(1, 0) ~f:(fun (count, proof_parties_count) party -> + (Mina_base.User_command.Zkapp_command zkapp_command) -> + Mina_base.Zkapp_command.Call_forest.fold + zkapp_command.account_updates ~init:(1, 0) + ~f:(fun (count, proof_zkapp_command_count) account_update -> ( count + 1 , if Mina_base.Control.( Tag.equal Proof - (tag (Mina_base.Party.authorization party))) - then proof_parties_count + 1 - else proof_parties_count ) ) + (tag + (Mina_base.Account_update.authorization + account_update ) )) + then proof_zkapp_command_count + 1 + else proof_zkapp_command_count ) ) | _ -> (1, 0) in @@ -441,8 +444,9 @@ let setup_local_server ?(client_trustlist = []) ?rest_server_port Cryptography.( Snark_work_histogram.observe snark_work_base_time_sec (Time.Span.to_sec total) ; - Gauge.set transaction_length (Float.of_int parties_count) ; - Gauge.set proof_parties (Float.of_int proof_parties_count))) ) + Gauge.set transaction_length (Float.of_int zkapp_command_count) ; + Gauge.set proof_zkapp_command + (Float.of_int proof_zkapp_command_count))) ) in let snark_worker_impls = [ implement Snark_worker.Rpcs_versioned.Get_work.Latest.rpc (fun () () -> diff --git a/src/app/cli/src/init/coda_tracing.ml b/src/app/cli/src/init/mina_tracing.ml similarity index 100% rename from src/app/cli/src/init/coda_tracing.ml rename to src/app/cli/src/init/mina_tracing.ml diff --git a/src/app/cli/src/init/transaction_snark_profiler.ml b/src/app/cli/src/init/transaction_snark_profiler.ml index 52bcf7706ec..c41b04a1e1a 100644 --- a/src/app/cli/src/init/transaction_snark_profiler.ml +++ b/src/app/cli/src/init/transaction_snark_profiler.ml @@ -107,7 +107,7 @@ let create_ledger_and_transactions num_transactions : (ledger, [ Command (Signed_command a); Command (Signed_command b) ]) let create_ledger_and_zkapps num_transactions : - Mina_ledger.Ledger.t * Parties.t list = + Mina_ledger.Ledger.t * Zkapp_command.t list = let length = match num_transactions with | `Count length -> @@ -115,8 +115,10 @@ let create_ledger_and_zkapps num_transactions : | `Two_from_same -> failwith "Must provide a count when profiling with snapps" in - let max_other_parties = - let min_max = Mina_generators.Parties_generators.max_other_parties in + let max_account_updates = + let min_max = + Mina_generators.Zkapp_command_generators.max_account_updates + in Quickcheck.random_value (Int.gen_incl min_max 20) in let `VK vk, `Prover prover = @@ -124,18 +126,18 @@ let create_ledger_and_zkapps num_transactions : in let cmd_infos, ledger = Quickcheck.random_value - (Mina_generators.User_command_generators.sequence_parties_with_ledger - ~max_other_parties ~length ~vk () ) + (Mina_generators.User_command_generators + .sequence_zkapp_command_with_ledger ~max_account_updates ~length ~vk () ) in let zkapps = List.map cmd_infos ~f:(fun (user_cmd, _keypair, keymap) -> match user_cmd with - | User_command.Parties parties_valid -> + | User_command.Zkapp_command zkapp_command_valid -> Async.Thread_safe.block_on_async_exn (fun () -> - Parties_builder.replace_authorizations ~prover ~keymap - (Parties.Valid.forget parties_valid) ) + Zkapp_command_builder.replace_authorizations ~prover ~keymap + (Zkapp_command.Valid.forget zkapp_command_valid) ) | User_command.Signed_command _ -> - failwith "Expected Parties user command" ) + failwith "Expected Zkapp_command user command" ) in (ledger, zkapps) @@ -202,7 +204,7 @@ let profile_user_command (module T : Transaction_snark.S) sparse_ledger0 in let tm0 = Core.Unix.gettimeofday () in let%map proof = - T.of_non_parties_transaction + T.of_non_zkapp_command_transaction ~statement: { sok_digest = Sok_message.Digest.default ; source = @@ -265,20 +267,20 @@ let profile_user_command (module T : Transaction_snark.S) sparse_ledger0 let%map total_time = merge_all base_proof_time (List.rev base_proofs_rev) in format_time_span total_time -let profile_zkapps ~verifier ledger partiess = +let profile_zkapps ~verifier ledger zkapp_commands = let open Async.Deferred.Let_syntax in let tm0 = Core.Unix.gettimeofday () in let%map () = - let num_partiess = List.length partiess in - Async.Deferred.List.iteri partiess ~f:(fun ndx parties -> - printf "Processing zkApp %d of %d, other_parties length: %d\n" (ndx + 1) - num_partiess - (List.length @@ Parties.other_parties_list parties) ; + let num_zkapp_commands = List.length zkapp_commands in + Async.Deferred.List.iteri zkapp_commands ~f:(fun ndx zkapp_command -> + printf "Processing zkApp %d of %d, account_updates length: %d\n" + (ndx + 1) num_zkapp_commands + (List.length @@ Zkapp_command.account_updates_list zkapp_command) ; let%bind res = Verifier.verify_commands verifier [ User_command.to_verifiable ~ledger ~get:Mina_ledger.Ledger.get ~location_of_account:Mina_ledger.Ledger.location_of_account - (Parties parties) + (Zkapp_command zkapp_command) ] in let _a = Or_error.ok_exn res in @@ -287,8 +289,8 @@ let profile_zkapps ~verifier ledger partiess = let%map () = match%map Async_kernel.Monitor.try_with (fun () -> - Transaction_snark_tests.Util.check_parties_with_merges_exn - ledger [ parties ] ) + Transaction_snark_tests.Util.check_zkapp_command_with_merges_exn + ledger [ zkapp_command ] ) with | Ok () -> () diff --git a/src/app/cli/src/tests/coda_worker.ml b/src/app/cli/src/tests/coda_worker.ml index c0c4206b734..15750803287 100644 --- a/src/app/cli/src/tests/coda_worker.ml +++ b/src/app/cli/src/tests/coda_worker.ml @@ -376,7 +376,7 @@ module T = struct Option.value_map trace_dir ~f:(fun d -> let%bind () = Async.Unix.mkdir ~p:() d in - Coda_tracing.start d ) + Mina_tracing.start d ) ~default:Deferred.unit in let%bind () = File_system.create_dir conf_dir in @@ -506,7 +506,7 @@ module T = struct ~log_precomputed_blocks:false ~stop_time:48 () ) in let coda_ref : Mina_lib.t option ref = ref None in - Coda_run.handle_shutdown ~monitor ~time_controller ~conf_dir + Mina_run.handle_shutdown ~monitor ~time_controller ~conf_dir ~child_pids:pids ~top_logger:logger coda_ref ; let%map coda = with_monitor @@ -514,7 +514,7 @@ module T = struct let%map coda = coda_deferred () in coda_ref := Some coda ; [%log info] "Setting up snark worker " ; - Coda_run.setup_local_server coda ; + Mina_run.setup_local_server coda ; coda ) () in diff --git a/src/app/client_sdk/client_sdk.ml b/src/app/client_sdk/client_sdk.ml index ba74391e700..edf3af64b04 100644 --- a/src/app/client_sdk/client_sdk.ml +++ b/src/app/client_sdk/client_sdk.ml @@ -33,36 +33,42 @@ let _ = val publicKey = pk_str_js end - (** generate a parties fee payer and sign other parties with the fee payer account *) - method signParty (parties_js : string_js) - (fee_payer_party_js : payload_fee_payer_party_js) - (sk_base58_check_js : string_js) = - let other_parties_json = - parties_js |> Js.to_string |> Yojson.Safe.from_string - in - let other_parties = Parties.other_parties_of_json other_parties_json in - let other_parties = - Parties.Call_forest.of_parties_list - ~party_depth:(fun (p : Party.Graphql_repr.t) -> p.body.call_depth) - other_parties - |> Parties.Call_forest.map ~f:Party.of_graphql_repr - |> Parties.Call_forest.accumulate_hashes - ~hash_party:(fun (p : Party.t) -> Parties.Digest.Party.create p) - in - let other_parties_hash = Parties.Call_forest.hash other_parties in + (** generate a zkapp_command fee payer and sign other zkapp_command with the fee payer account *) + method signAccountUpdate (zkapp_command_js : string_js) + (fee_payer_js : payload_fee_payer_js) (sk_base58_check_js : string_js) + = + let account_updates_json = + zkapp_command_js |> Js.to_string |> Yojson.Safe.from_string + in + let account_updates = + Zkapp_command.account_updates_of_json account_updates_json + in + let account_updates = + Zkapp_command.Call_forest.of_zkapp_command_list + ~account_update_depth:(fun (p : Account_update.Graphql_repr.t) -> + p.body.call_depth ) + account_updates + |> Zkapp_command.Call_forest.map ~f:Account_update.of_graphql_repr + |> Zkapp_command.Call_forest.accumulate_hashes + ~hash_account_update:(fun (p : Account_update.t) -> + Zkapp_command.Digest.Account_update.create p ) + in + let account_updates_hash = + Zkapp_command.Call_forest.hash account_updates + in let memo = - fee_payer_party_js##.memo |> Js.to_string - |> Memo.create_from_string_exn + fee_payer_js##.memo |> Js.to_string |> Memo.create_from_string_exn in - let commitment : Parties.Transaction_commitment.t = - Parties.Transaction_commitment.create ~other_parties_hash + let commitment : Zkapp_command.Transaction_commitment.t = + Zkapp_command.Transaction_commitment.create ~account_updates_hash in - let fee_payer = payload_of_fee_payer_party_js fee_payer_party_js in + let fee_payer = payload_of_fee_payer_js fee_payer_js in let full_commitment = - Parties.Transaction_commitment.create_complete commitment + Zkapp_command.Transaction_commitment.create_complete commitment ~memo_hash:(Signed_command_memo.hash memo) ~fee_payer_hash: - (Parties.Digest.Party.create (Party.of_fee_payer fee_payer)) + (Zkapp_command.Digest.Account_update.create + (Account_update.of_fee_payer fee_payer) ) in let sk = Js.to_string sk_base58_check_js |> Private_key.of_base58_check_exn @@ -74,8 +80,9 @@ let _ = in { fee_payer with authorization = fee_payer_signature_auth } in - { Parties.fee_payer; other_parties; memo } - |> Parties.parties_to_json |> Yojson.Safe.to_string |> Js.string + { Zkapp_command.fee_payer; account_updates; memo } + |> Zkapp_command.zkapp_command_to_json |> Yojson.Safe.to_string + |> Js.string (** return public key associated with private key in raw hex format for Rosetta *) method rawPublicKeyOfPrivateKey (sk_base58_check_js : string_js) = diff --git a/src/app/client_sdk/js_util.ml b/src/app/client_sdk/js_util.ml index 28e9ff34f9f..83656796a2b 100644 --- a/src/app/client_sdk/js_util.ml +++ b/src/app/client_sdk/js_util.ml @@ -24,27 +24,24 @@ type payload_common_js = ; memo : string_js Js.prop > Js.t -type payload_fee_payer_party_js = +type payload_fee_payer_js = < fee : string_js Js.prop ; feePayer : string_js Js.prop ; nonce : string_js Js.prop ; memo : string_js Js.prop > Js.t -let payload_of_fee_payer_party_js - (fee_payer_party_js : payload_fee_payer_party_js) : Party.Fee_payer.t = +let payload_of_fee_payer_js (fee_payer_js : payload_fee_payer_js) : + Account_update.Fee_payer.t = let fee_payer_pk = - fee_payer_party_js##.feePayer - |> Js.to_string |> Signature_lib.Public_key.of_base58_check_decompress_exn - in - let fee = - fee_payer_party_js##.fee |> Js.to_string |> Currency.Fee.of_string + fee_payer_js##.feePayer |> Js.to_string + |> Signature_lib.Public_key.of_base58_check_decompress_exn in + let fee = fee_payer_js##.fee |> Js.to_string |> Currency.Fee.of_string in let nonce = - fee_payer_party_js##.nonce |> Js.to_string - |> Mina_numbers.Account_nonce.of_string + fee_payer_js##.nonce |> Js.to_string |> Mina_numbers.Account_nonce.of_string in - { Party.Fee_payer.body = + { Account_update.Fee_payer.body = { public_key = fee_payer_pk; fee; valid_until = None; nonce } ; authorization = Signature.dummy } diff --git a/src/app/extract_blocks/extract_blocks.ml b/src/app/extract_blocks/extract_blocks.ml index 84624f870a8..f7fcda64b4d 100644 --- a/src/app/extract_blocks/extract_blocks.ml +++ b/src/app/extract_blocks/extract_blocks.ml @@ -224,19 +224,19 @@ let fill_in_tokens_used pool block_state_hash = in query_db ~f:(fun db -> Processor.Token.find_by_id db default_id) in - let%map other_parties_tokenss = - Deferred.List.map zkapp_cmds ~f:(fun { zkapp_other_parties_ids; _ } -> - let%bind other_party_bodies = - Deferred.List.map (Array.to_list zkapp_other_parties_ids) - ~f:(fun other_party_id -> + let%map account_updates_tokenss = + Deferred.List.map zkapp_cmds ~f:(fun { zkapp_account_updates_ids; _ } -> + let%bind account_update_bodies = + Deferred.List.map (Array.to_list zkapp_account_updates_ids) + ~f:(fun account_update_id -> let%bind { body_id; _ } = query_db ~f:(fun db -> - Processor.Zkapp_other_party.load db other_party_id ) + Processor.Zkapp_account_update.load db account_update_id ) in query_db ~f:(fun db -> - Processor.Zkapp_other_party_body.load db body_id ) ) + Processor.Zkapp_account_update_body.load db body_id ) ) in - Deferred.List.map other_party_bodies + Deferred.List.map account_update_bodies ~f:(fun { account_identifier_id; _ } -> let%bind { token_id; _ } = query_db ~f:(fun db -> @@ -244,7 +244,7 @@ let fill_in_tokens_used pool block_state_hash = in query_db ~f:(fun db -> Processor.Token.find_by_id db token_id) ) ) in - fee_payer_token :: List.concat other_parties_tokenss + fee_payer_token :: List.concat account_updates_tokenss in let%bind zkapp_cmd_tokens_used = Deferred.List.map zkapp_cmd_tokens ~f:get_token_owner @@ -386,10 +386,10 @@ let fill_in_zkapp_commands pool block_state_hash = let%bind fee_payer = Load_data.get_fee_payer_body ~pool zkapp_cmd.zkapp_fee_payer_body_id in - let%bind other_parties = + let%bind account_updates = Deferred.List.map - (Array.to_list zkapp_cmd.zkapp_other_parties_ids) - ~f:(Load_data.get_other_party_body ~pool) + (Array.to_list zkapp_cmd.zkapp_account_updates_ids) + ~f:(Load_data.get_account_update_body ~pool) in let memo = zkapp_cmd.memo |> Signed_command_memo.of_base58_check_exn in let hash = zkapp_cmd.hash |> Transaction_hash.of_base58_check_exn in @@ -407,7 +407,7 @@ let fill_in_zkapp_commands pool block_state_hash = Deferred.List.map (Array.to_list ids) ~f:(fun id -> let%map { index; failures } = query_db ~f:(fun db -> - Processor.Zkapp_party_failures.load db id ) + Processor.Zkapp_account_update_failures.load db id ) in ( index , List.map (Array.to_list failures) ~f:(fun s -> @@ -416,8 +416,9 @@ let fill_in_zkapp_commands pool block_state_hash = failure | Error err -> failwithf - "Invalid party transaction status, error: %s" err - () ) ) ) + "Invalid account update transaction status, \ + error: %s" + err () ) ) ) in Some display ) in @@ -425,7 +426,7 @@ let fill_in_zkapp_commands pool block_state_hash = return { Extensional.Zkapp_command.sequence_no ; fee_payer - ; other_parties + ; account_updates ; memo ; hash ; status diff --git a/src/app/replayer/replayer.ml b/src/app/replayer/replayer.ml index a29341a06d4..aeba4682823 100644 --- a/src/app/replayer/replayer.ml +++ b/src/app/replayer/replayer.ml @@ -627,23 +627,24 @@ module Zkapp_helpers = struct return state_view end -let parties_of_zkapp_command ~pool (cmd : Sql.Zkapp_command.t) : - Parties.t Deferred.t = +let zkapp_command_of_zkapp_command ~pool (cmd : Sql.Zkapp_command.t) : + Zkapp_command.t Deferred.t = let query_db = Mina_caqti.query pool in (* use dummy authorizations *) - let%bind (fee_payer : Party.Fee_payer.t) = - let%map (body : Party.Body.Fee_payer.t) = + let%bind (fee_payer : Account_update.Fee_payer.t) = + let%map (body : Account_update.Body.Fee_payer.t) = Archive_lib.Load_data.get_fee_payer_body ~pool cmd.zkapp_fee_payer_body_id in - ({ body; authorization = Signature.dummy } : Party.Fee_payer.t) + ({ body; authorization = Signature.dummy } : Account_update.Fee_payer.t) in - let%bind (other_parties : Party.Simple.t list) = - Deferred.List.map (Array.to_list cmd.zkapp_other_parties_ids) ~f:(fun id -> + let%bind (account_updates : Account_update.Simple.t list) = + Deferred.List.map (Array.to_list cmd.zkapp_account_updates_ids) + ~f:(fun id -> let%bind { body_id; authorization_kind } = - query_db ~f:(fun db -> Processor.Zkapp_other_party.load db id) + query_db ~f:(fun db -> Processor.Zkapp_account_update.load db id) in let%map body = - Archive_lib.Load_data.get_other_party_body ~pool body_id + Archive_lib.Load_data.get_account_update_body ~pool body_id in let (authorization : Control.t) = match authorization_kind with @@ -654,11 +655,13 @@ let parties_of_zkapp_command ~pool (cmd : Sql.Zkapp_command.t) : | None_given -> None_given in - ({ body; authorization } : Party.Simple.t) ) + ({ body; authorization } : Account_update.Simple.t) ) in let memo = Signed_command_memo.of_base58_check_exn cmd.memo in - let parties = Parties.of_simple { fee_payer; other_parties; memo } in - return (parties : Parties.t) + let zkapp_command = + Zkapp_command.of_simple { fee_payer; account_updates; memo } + in + return (zkapp_command : Zkapp_command.t) let run_zkapp_command ~logger ~pool ~ledger (cmd : Sql.Zkapp_command.t) = [%log info] @@ -668,10 +671,10 @@ let run_zkapp_command ~logger ~pool ~ledger (cmd : Sql.Zkapp_command.t) = let%bind state_view = Zkapp_helpers.get_parent_state_view ~pool cmd.block_id in - let%bind parties = parties_of_zkapp_command ~pool cmd in + let%bind zkapp_command = zkapp_command_of_zkapp_command ~pool cmd in match - Ledger.apply_parties_unchecked ~constraint_constants ~state_view ledger - parties + Ledger.apply_zkapp_command_unchecked ~constraint_constants ~state_view + ledger zkapp_command with | Ok _ -> Deferred.unit diff --git a/src/app/replayer/sql.ml b/src/app/replayer/sql.ml index 61e94ddd88c..33b26021224 100644 --- a/src/app/replayer/sql.ml +++ b/src/app/replayer/sql.ml @@ -247,7 +247,7 @@ end module Zkapp_command = struct type t = { zkapp_fee_payer_body_id : int - ; zkapp_other_parties_ids : int array + ; zkapp_account_updates_ids : int array ; memo : string ; block_id : int ; global_slot_since_genesis : int64 @@ -272,7 +272,7 @@ module Zkapp_command = struct let query = Caqti_request.collect Caqti_type.int typ - {sql| SELECT zkapp_fee_payer_body_id,zkapp_other_parties_ids,memo, + {sql| SELECT zkapp_fee_payer_body_id,zkapp_account_updates_ids,memo, blocks.id,blocks.global_slot_since_genesis, parent.global_slot_since_genesis, sequence_no,hash diff --git a/src/app/replayer/test/archive_db.sql b/src/app/replayer/test/archive_db.sql index 84f19072a3d..972d53d61dc 100644 --- a/src/app/replayer/test/archive_db.sql +++ b/src/app/replayer/test/archive_db.sql @@ -791,7 +791,7 @@ ALTER SEQUENCE public.zkapp_balance_bounds_id_seq OWNED BY public.zkapp_balance_ CREATE TABLE public.zkapp_commands ( id integer NOT NULL, zkapp_fee_payer_body_id integer NOT NULL, - zkapp_other_parties_ids integer[] NOT NULL, + zkapp_account_updates_ids integer[] NOT NULL, memo text NOT NULL, hash text NOT NULL ); @@ -1113,10 +1113,10 @@ ALTER SEQUENCE public.zkapp_nonce_bounds_id_seq OWNED BY public.zkapp_nonce_boun -- --- Name: zkapp_other_party; Type: TABLE; Schema: public; +-- Name: zkapp_account_update; Type: TABLE; Schema: public; -- -CREATE TABLE public.zkapp_other_party ( +CREATE TABLE public.zkapp_account_update ( id integer NOT NULL, body_id integer NOT NULL, authorization_kind public.zkapp_authorization_kind_type NOT NULL @@ -1126,10 +1126,10 @@ CREATE TABLE public.zkapp_other_party ( -- --- Name: zkapp_other_party_body; Type: TABLE; Schema: public; +-- Name: zkapp_account_update_body; Type: TABLE; Schema: public; -- -CREATE TABLE public.zkapp_other_party_body ( +CREATE TABLE public.zkapp_account_update_body ( id integer NOT NULL, account_identifier_id integer NOT NULL, update_id integer NOT NULL, @@ -1149,10 +1149,10 @@ CREATE TABLE public.zkapp_other_party_body ( -- --- Name: zkapp_other_party_body_id_seq; Type: SEQUENCE; Schema: public; +-- Name: zkapp_account_update_body_id_seq; Type: SEQUENCE; Schema: public; -- -CREATE SEQUENCE public.zkapp_other_party_body_id_seq +CREATE SEQUENCE public.zkapp_account_update_body_id_seq AS integer START WITH 1 INCREMENT BY 1 @@ -1164,17 +1164,17 @@ CREATE SEQUENCE public.zkapp_other_party_body_id_seq -- --- Name: zkapp_other_party_body_id_seq; Type: SEQUENCE OWNED BY; Schema: public; +-- Name: zkapp_account_update_body_id_seq; Type: SEQUENCE OWNED BY; Schema: public; -- -ALTER SEQUENCE public.zkapp_other_party_body_id_seq OWNED BY public.zkapp_other_party_body.id; +ALTER SEQUENCE public.zkapp_account_update_body_id_seq OWNED BY public.zkapp_account_update_body.id; -- --- Name: zkapp_other_party_id_seq; Type: SEQUENCE; Schema: public; +-- Name: zkapp_account_update_id_seq; Type: SEQUENCE; Schema: public; -- -CREATE SEQUENCE public.zkapp_other_party_id_seq +CREATE SEQUENCE public.zkapp_account_update_id_seq AS integer START WITH 1 INCREMENT BY 1 @@ -1186,17 +1186,17 @@ CREATE SEQUENCE public.zkapp_other_party_id_seq -- --- Name: zkapp_other_party_id_seq; Type: SEQUENCE OWNED BY; Schema: public; +-- Name: zkapp_account_update_id_seq; Type: SEQUENCE OWNED BY; Schema: public; -- -ALTER SEQUENCE public.zkapp_other_party_id_seq OWNED BY public.zkapp_other_party.id; +ALTER SEQUENCE public.zkapp_account_update_id_seq OWNED BY public.zkapp_account_update.id; -- --- Name: zkapp_party_failures; Type: TABLE; Schema: public; +-- Name: zkapp_account_update_failures; Type: TABLE; Schema: public; -- -CREATE TABLE public.zkapp_party_failures ( +CREATE TABLE public.zkapp_account_update_failures ( id integer NOT NULL, index integer NOT NULL, failures text[] NOT NULL @@ -1206,10 +1206,10 @@ CREATE TABLE public.zkapp_party_failures ( -- --- Name: zkapp_party_failures_id_seq; Type: SEQUENCE; Schema: public; +-- Name: zkapp_account_update_failures_id_seq; Type: SEQUENCE; Schema: public; -- -CREATE SEQUENCE public.zkapp_party_failures_id_seq +CREATE SEQUENCE public.zkapp_account_update_failures_id_seq AS integer START WITH 1 INCREMENT BY 1 @@ -1221,10 +1221,10 @@ CREATE SEQUENCE public.zkapp_party_failures_id_seq -- --- Name: zkapp_party_failures_id_seq; Type: SEQUENCE OWNED BY; Schema: public; +-- Name: zkapp_account_update_failures_id_seq; Type: SEQUENCE OWNED BY; Schema: public; -- -ALTER SEQUENCE public.zkapp_party_failures_id_seq OWNED BY public.zkapp_party_failures.id; +ALTER SEQUENCE public.zkapp_account_update_failures_id_seq OWNED BY public.zkapp_account_update_failures.id; -- @@ -1886,24 +1886,24 @@ ALTER TABLE ONLY public.zkapp_nonce_bounds ALTER COLUMN id SET DEFAULT nextval(' -- --- Name: zkapp_other_party id; Type: DEFAULT; Schema: public; +-- Name: zkapp_account_update id; Type: DEFAULT; Schema: public; -- -ALTER TABLE ONLY public.zkapp_other_party ALTER COLUMN id SET DEFAULT nextval('public.zkapp_other_party_id_seq'::regclass); +ALTER TABLE ONLY public.zkapp_account_update ALTER COLUMN id SET DEFAULT nextval('public.zkapp_account_update_id_seq'::regclass); -- --- Name: zkapp_other_party_body id; Type: DEFAULT; Schema: public; +-- Name: zkapp_account_update_body id; Type: DEFAULT; Schema: public; -- -ALTER TABLE ONLY public.zkapp_other_party_body ALTER COLUMN id SET DEFAULT nextval('public.zkapp_other_party_body_id_seq'::regclass); +ALTER TABLE ONLY public.zkapp_account_update_body ALTER COLUMN id SET DEFAULT nextval('public.zkapp_account_update_body_id_seq'::regclass); -- --- Name: zkapp_party_failures id; Type: DEFAULT; Schema: public; +-- Name: zkapp_account_update_failures id; Type: DEFAULT; Schema: public; -- -ALTER TABLE ONLY public.zkapp_party_failures ALTER COLUMN id SET DEFAULT nextval('public.zkapp_party_failures_id_seq'::regclass); +ALTER TABLE ONLY public.zkapp_account_update_failures ALTER COLUMN id SET DEFAULT nextval('public.zkapp_account_update_failures_id_seq'::regclass); -- @@ -2063,11 +2063,11 @@ COPY public.accounts_created (block_id, account_identifier_id, creation_fee) FRO -- COPY public.blocks (id, state_hash, parent_id, parent_hash, creator_id, block_winner_id, snarked_ledger_hash_id, staking_epoch_data_id, next_epoch_data_id, min_window_density, total_currency, ledger_hash, height, global_slot_since_hard_fork, global_slot_since_genesis, "timestamp", chain_status) FROM stdin; -1 3NLt1r77r7z7VEX4tACzHc9qC9Rz5GqYSXtufFhpE85tWVoYrx8z \N 3NLeQxhRU3qHv34vHNUwD2ht9gzW3ioAGqBmVwXjYhsSDHPuBDQn 1 1 1 1 2 77 3100000000000000000 jwygs7rxLrSg7hHkMcHzG66R6c1Ve9vJRyrvrVpS9bKcT4iC7Qy 1 0 0 1659993000000 canonical -2 3NLPC2srDPVxrf4TqpsznL7CTeT6B8pPZYwNCHyizxaSznu6XoUA 1 3NLt1r77r7z7VEX4tACzHc9qC9Rz5GqYSXtufFhpE85tWVoYrx8z 3 3 1 1 3 77 3100000000000000000 jxbGLVXL4TKg44kSzwyXocsTNRdSCiFrPjV9zCnDtnmiXh3W2aQ 2 22 22 1659993660000 pending -3 3NLxg96L88SBKKVgWgxcDLpTbCFfftbzCMepbhTBrHxLAcTiv4An 2 3NLPC2srDPVxrf4TqpsznL7CTeT6B8pPZYwNCHyizxaSznu6XoUA 3 3 1 1 4 77 3100000000000000000 jx3EPWuSmaoMGYbtEoMYHVkhbBNDr2cFuGqY1dAYrcuukQket64 3 24 24 1659993720000 pending -4 3NKAwzwaGhdXYs2iEJPj7cnfgfcRkHmRo9kFfB2DRdUM4NsmNnk8 3 3NLxg96L88SBKKVgWgxcDLpTbCFfftbzCMepbhTBrHxLAcTiv4An 3 3 1 1 5 77 3100000000000000000 jwj33aFA7iunt1GuDzDBVd4tzLkHsXWXUQsq7KgNWL2GZovkaCv 4 26 26 1659993780000 pending -5 3NKPsYafv3sqCRymAw3hyYbdnpR1rkz5uESW46gA1pme1isBQ8z9 4 3NKAwzwaGhdXYs2iEJPj7cnfgfcRkHmRo9kFfB2DRdUM4NsmNnk8 3 3 1 1 6 77 3100000000000000000 jxHvVw6rNcY4DoYutEGkwBH78XqDUce4NuEzfWZxKiE7QKjfWug 5 28 28 1659993840000 pending +1 3NLt1r77r7z7VEX4tACzHc9qC9Rz5GqYSXtufFhpE85tWVoYrx8z \N 3NLeQxhRU3qHv34vHNUwD2ht9gzW3ioAGqBmVwXjYhsSDHPuBDQn 1 1 1 1 2 77 3100000000000000000 jwS4u5UYaySzEDNDhCT4HnWBcUvARBYjWLGKArheFrzRbvhr8Pd 1 0 0 1659993000000 canonical +2 3NLPC2srDPVxrf4TqpsznL7CTeT6B8pPZYwNCHyizxaSznu6XoUA 1 3NLt1r77r7z7VEX4tACzHc9qC9Rz5GqYSXtufFhpE85tWVoYrx8z 3 3 1 1 3 77 3100000000000000000 jxoAHY24uyTC9qSVBwSh9vtFcJkRroXpQjtvQJr4p3D1T8xRrV6 2 22 22 1659993660000 pending +3 3NLxg96L88SBKKVgWgxcDLpTbCFfftbzCMepbhTBrHxLAcTiv4An 2 3NLPC2srDPVxrf4TqpsznL7CTeT6B8pPZYwNCHyizxaSznu6XoUA 3 3 1 1 4 77 3100000000000000000 jwR1YaaEjgdegXHuX9mAiFPcAUJD8aWPDbZJcyV2WTEkCHJ3G2W 3 24 24 1659993720000 pending +4 3NKAwzwaGhdXYs2iEJPj7cnfgfcRkHmRo9kFfB2DRdUM4NsmNnk8 3 3NLxg96L88SBKKVgWgxcDLpTbCFfftbzCMepbhTBrHxLAcTiv4An 3 3 1 1 5 77 3100000000000000000 jwVvbHXxwuBXNVzwoz8YJoo9DvEoRJCsYS1f5tosoJyvkWxjEAM 4 26 26 1659993780000 pending +5 3NKPsYafv3sqCRymAw3hyYbdnpR1rkz5uESW46gA1pme1isBQ8z9 4 3NKAwzwaGhdXYs2iEJPj7cnfgfcRkHmRo9kFfB2DRdUM4NsmNnk8 3 3 1 1 6 77 3100000000000000000 jxWhYJGQ1jzvyUJ2h5X6y8r1avFiEnPyeCr7qAdGxEGjCJDuWug 5 28 28 1659993840000 pending 6 3NLr8y5CxQST5f5QK7LdfL9J1Bnuu5c5iZJ4YPTCfDyWmCKbEX4b 5 3NKPsYafv3sqCRymAw3hyYbdnpR1rkz5uESW46gA1pme1isBQ8z9 3 3 1 1 7 77 3100000000000000000 jwWs7Mg1i63LEAYRUnkjzsqJvnUMmtWW9SC88jcM55k3PZ4A7c7 6 31 31 1659993930000 pending 7 3NKvv85heSwz5rwAbT7KFxrHZoGGnmwZHhBW952t5Waq1yM3YtS5 6 3NLr8y5CxQST5f5QK7LdfL9J1Bnuu5c5iZJ4YPTCfDyWmCKbEX4b 3 3 1 1 8 77 3100000000000000000 jwWs7Mg1i63LEAYRUnkjzsqJvnUMmtWW9SC88jcM55k3PZ4A7c7 7 33 33 1659993990000 pending 8 3NLAtWGLyAsD9biM2tx6djxKGaUR8FwWm3VCFSmSZNxej2mWu4ck 7 3NKvv85heSwz5rwAbT7KFxrHZoGGnmwZHhBW952t5Waq1yM3YtS5 3 3 1 1 9 77 3100000000000000000 jwWs7Mg1i63LEAYRUnkjzsqJvnUMmtWW9SC88jcM55k3PZ4A7c7 8 36 36 1659994080000 pending @@ -2079,11 +2079,11 @@ COPY public.blocks (id, state_hash, parent_id, parent_hash, creator_id, block_wi 14 3NKUXRQ1G7XeZ9itcp766STsZD9EjDcf3mpYT3X7AsMrgArSq4s8 13 3NKvChb8G72hQBHzr7nn7AHrafGopf4xkzNk3bzZPjd1cDgS1LF6 3 3 1 1 15 77 3100000000000000000 jwWs7Mg1i63LEAYRUnkjzsqJvnUMmtWW9SC88jcM55k3PZ4A7c7 14 48 48 1659994440000 pending 15 3NLVZy6T83Jn1pfdcwz6GSmirP8SQYSV6Fwv2gCuKpLDcyQP13mH 14 3NKUXRQ1G7XeZ9itcp766STsZD9EjDcf3mpYT3X7AsMrgArSq4s8 3 3 1 1 16 77 3100000000000000000 jwWs7Mg1i63LEAYRUnkjzsqJvnUMmtWW9SC88jcM55k3PZ4A7c7 15 49 49 1659994470000 pending 16 3NLCqsJpwVxSC7gKUVEkCb3PmCvf3CcX52CtSG3xjhcSzopg5NZJ 15 3NLVZy6T83Jn1pfdcwz6GSmirP8SQYSV6Fwv2gCuKpLDcyQP13mH 3 3 1 1 17 77 3100000000000000000 jwWs7Mg1i63LEAYRUnkjzsqJvnUMmtWW9SC88jcM55k3PZ4A7c7 16 50 50 1659994500000 pending -17 3NLjjx7dm6Bc3D5bc2cNAecuPyhYum9PoX7DYUHGYvS3qc551j1M 16 3NLCqsJpwVxSC7gKUVEkCb3PmCvf3CcX52CtSG3xjhcSzopg5NZJ 3 3 1 1 18 77 3100000000000000000 jxTEKWT4TzqfwTM1GVPQQstzspM79jQDh6kr4h4yh7nxF2XUKeg 17 56 56 1659994680000 pending -18 3NKmDH5RAujPGiX76vwhV6HFsAjN2vvkHjkQcveExvDywyykLeaL 17 3NLjjx7dm6Bc3D5bc2cNAecuPyhYum9PoX7DYUHGYvS3qc551j1M 3 3 1 1 19 77 3100000000000000000 jwE7UX5hnkdU3ixaT9qMp8nNbpQMVoF3JTcFfYC3zDx5eDhSUYa 18 57 57 1659994710000 pending -19 3NLJ3QfoaRBs2sMj2dpx1dYAgQoe9tLAFNb19ijBnyzAWafF1KBm 18 3NKmDH5RAujPGiX76vwhV6HFsAjN2vvkHjkQcveExvDywyykLeaL 3 3 1 1 20 77 3100000000000000000 jwE7UX5hnkdU3ixaT9qMp8nNbpQMVoF3JTcFfYC3zDx5eDhSUYa 19 60 60 1659994800000 pending -20 3NL1XVgg2DAjSjVStzXmeQnRunV7Pp1B4cYQ27VtN3Q6esAZ5ufp 19 3NLJ3QfoaRBs2sMj2dpx1dYAgQoe9tLAFNb19ijBnyzAWafF1KBm 3 3 1 1 21 77 3100000000000000000 jxPGrPkYKZdZR37z9R3tQ41YNtME7NNH6A3Gc1pPs7NJPBapE7Y 20 65 65 1659994950000 pending -21 3NKKXz5f8zUEb5PyoW1faVfJqsHnBvzrK58XJdxoNGaMenfWcw5w 20 3NL1XVgg2DAjSjVStzXmeQnRunV7Pp1B4cYQ27VtN3Q6esAZ5ufp 3 3 1 1 22 77 3100000000000000000 jxB6TZLAwf3QetUjojQSR71U7fJNWPMgi5NccspAdJoPkFgJL7i 21 68 68 1659995040000 pending +17 3NLjjx7dm6Bc3D5bc2cNAecuPyhYum9PoX7DYUHGYvS3qc551j1M 16 3NLCqsJpwVxSC7gKUVEkCb3PmCvf3CcX52CtSG3xjhcSzopg5NZJ 3 3 1 1 18 77 3100000000000000000 jwVkVSdQTtSNRi698eFeiDeJJrAY1MeW4ZZxadpXEbLtNzRyDb6 17 56 56 1659994680000 pending +18 3NKmDH5RAujPGiX76vwhV6HFsAjN2vvkHjkQcveExvDywyykLeaL 17 3NLjjx7dm6Bc3D5bc2cNAecuPyhYum9PoX7DYUHGYvS3qc551j1M 3 3 1 1 19 77 3100000000000000000 jx2K8PqoKxRSsTqhpAkeAgJ1dxBuYfGvHF2t4qbv6BwyYhFoc9K 18 57 57 1659994710000 pending +19 3NLJ3QfoaRBs2sMj2dpx1dYAgQoe9tLAFNb19ijBnyzAWafF1KBm 18 3NKmDH5RAujPGiX76vwhV6HFsAjN2vvkHjkQcveExvDywyykLeaL 3 3 1 1 20 77 3100000000000000000 jx2K8PqoKxRSsTqhpAkeAgJ1dxBuYfGvHF2t4qbv6BwyYhFoc9K 19 60 60 1659994800000 pending +20 3NL1XVgg2DAjSjVStzXmeQnRunV7Pp1B4cYQ27VtN3Q6esAZ5ufp 19 3NLJ3QfoaRBs2sMj2dpx1dYAgQoe9tLAFNb19ijBnyzAWafF1KBm 3 3 1 1 21 77 3100000000000000000 jwedHhoVL6VZfty46JNEqwupysxuA2mL425c9d9JQr4kWsar8Ch 20 65 65 1659994950000 pending +21 3NKKXz5f8zUEb5PyoW1faVfJqsHnBvzrK58XJdxoNGaMenfWcw5w 20 3NL1XVgg2DAjSjVStzXmeQnRunV7Pp1B4cYQ27VtN3Q6esAZ5ufp 3 3 1 1 22 77 3100000000000000000 jwwBNTMAo3n4A8kL88FTp2vxh4VqEV1owT3Cyx1jek9YdAqC1Qw 21 68 68 1659995040000 pending \. @@ -2489,7 +2489,7 @@ COPY public.zkapp_balance_bounds (id, balance_lower_bound, balance_upper_bound) -- Data for Name: zkapp_commands; Type: TABLE DATA; Schema: public; -- -COPY public.zkapp_commands (id, zkapp_fee_payer_body_id, zkapp_other_parties_ids, memo, hash) FROM stdin; +COPY public.zkapp_commands (id, zkapp_fee_payer_body_id, zkapp_account_updates_ids, memo, hash) FROM stdin; 1 1 {1,2} E4YM2vTHhWEg66xpj52JErHUBU4pZ1yageL4TVDDpTTSsv8mK6YaH CkpYRd1tx6mK7EESUupbre4dZC2md4Kek83bGTkMUemj7BZYpopN3 2 2 {3} E4YM2vTHhWEg66xpj52JErHUBU4pZ1yageL4TVDDpTTSsv8mK6YaH CkpZ7bYXtifVFfuDoEZVtPpFq9MgNwmhBnR3jqNMknRRMD5Qdy8EC \. @@ -2566,10 +2566,10 @@ COPY public.zkapp_nonce_bounds (id, nonce_lower_bound, nonce_upper_bound) FROM s -- --- Data for Name: zkapp_other_party; Type: TABLE DATA; Schema: public; +-- Data for Name: zkapp_account_update; Type: TABLE DATA; Schema: public; -- -COPY public.zkapp_other_party (id, body_id, authorization_kind) FROM stdin; +COPY public.zkapp_account_update (id, body_id, authorization_kind) FROM stdin; 1 1 signature 2 2 signature 3 3 proof @@ -2577,10 +2577,10 @@ COPY public.zkapp_other_party (id, body_id, authorization_kind) FROM stdin; -- --- Data for Name: zkapp_other_party_body; Type: TABLE DATA; Schema: public; +-- Data for Name: zkapp_account_update_body; Type: TABLE DATA; Schema: public; -- -COPY public.zkapp_other_party_body (id, account_identifier_id, update_id, balance_change, increment_nonce, events_id, sequence_events_id, call_data_id, call_depth, zkapp_network_precondition_id, zkapp_account_precondition_id, use_full_commitment, caller) FROM stdin; +COPY public.zkapp_account_update_body (id, account_identifier_id, update_id, balance_change, increment_nonce, events_id, sequence_events_id, call_data_id, call_depth, zkapp_network_precondition_id, zkapp_account_precondition_id, use_full_commitment, caller) FROM stdin; 1 5 1 -10000000000 t 1 1 1 0 1 1 f call 2 7 2 9000000000 f 1 1 1 0 1 2 t call 3 7 3 0 f 1 1 1 0 1 2 t call @@ -2588,10 +2588,10 @@ COPY public.zkapp_other_party_body (id, account_identifier_id, update_id, balanc -- --- Data for Name: zkapp_party_failures; Type: TABLE DATA; Schema: public; +-- Data for Name: zkapp_account_update_failures; Type: TABLE DATA; Schema: public; -- -COPY public.zkapp_party_failures (id, index, failures) FROM stdin; +COPY public.zkapp_account_update_failures (id, index, failures) FROM stdin; \. @@ -2894,24 +2894,24 @@ SELECT pg_catalog.setval('public.zkapp_nonce_bounds_id_seq', 1, false); -- --- Name: zkapp_other_party_body_id_seq; Type: SEQUENCE SET; Schema: public; +-- Name: zkapp_account_update_body_id_seq; Type: SEQUENCE SET; Schema: public; -- -SELECT pg_catalog.setval('public.zkapp_other_party_body_id_seq', 3, true); +SELECT pg_catalog.setval('public.zkapp_account_update_body_id_seq', 3, true); -- --- Name: zkapp_other_party_id_seq; Type: SEQUENCE SET; Schema: public; +-- Name: zkapp_account_update_id_seq; Type: SEQUENCE SET; Schema: public; -- -SELECT pg_catalog.setval('public.zkapp_other_party_id_seq', 3, true); +SELECT pg_catalog.setval('public.zkapp_account_update_id_seq', 3, true); -- --- Name: zkapp_party_failures_id_seq; Type: SEQUENCE SET; Schema: public; +-- Name: zkapp_account_update_failures_id_seq; Type: SEQUENCE SET; Schema: public; -- -SELECT pg_catalog.setval('public.zkapp_party_failures_id_seq', 1, false); +SELECT pg_catalog.setval('public.zkapp_account_update_failures_id_seq', 1, false); -- @@ -3310,27 +3310,27 @@ ALTER TABLE ONLY public.zkapp_nonce_bounds -- --- Name: zkapp_other_party_body zkapp_other_party_body_pkey; Type: CONSTRAINT; Schema: public; +-- Name: zkapp_account_update_body zkapp_account_update_body_pkey; Type: CONSTRAINT; Schema: public; -- -ALTER TABLE ONLY public.zkapp_other_party_body - ADD CONSTRAINT zkapp_other_party_body_pkey PRIMARY KEY (id); +ALTER TABLE ONLY public.zkapp_account_update_body + ADD CONSTRAINT zkapp_account_update_body_pkey PRIMARY KEY (id); -- --- Name: zkapp_other_party zkapp_other_party_pkey; Type: CONSTRAINT; Schema: public; +-- Name: zkapp_account_update zkapp_account_update_pkey; Type: CONSTRAINT; Schema: public; -- -ALTER TABLE ONLY public.zkapp_other_party - ADD CONSTRAINT zkapp_other_party_pkey PRIMARY KEY (id); +ALTER TABLE ONLY public.zkapp_account_update + ADD CONSTRAINT zkapp_account_update_pkey PRIMARY KEY (id); -- --- Name: zkapp_party_failures zkapp_party_failures_pkey; Type: CONSTRAINT; Schema: public; +-- Name: zkapp_account_update_failures zkapp_account_update_failures_pkey; Type: CONSTRAINT; Schema: public; -- -ALTER TABLE ONLY public.zkapp_party_failures - ADD CONSTRAINT zkapp_party_failures_pkey PRIMARY KEY (id); +ALTER TABLE ONLY public.zkapp_account_update_failures + ADD CONSTRAINT zkapp_account_update_failures_pkey PRIMARY KEY (id); -- @@ -4026,67 +4026,67 @@ ALTER TABLE ONLY public.zkapp_network_precondition -- --- Name: zkapp_other_party_body zkapp_other_party_body_account_identifier_id_fkey; Type: FK CONSTRAINT; Schema: public; +-- Name: zkapp_account_update_body zkapp_account_update_body_account_identifier_id_fkey; Type: FK CONSTRAINT; Schema: public; -- -ALTER TABLE ONLY public.zkapp_other_party_body - ADD CONSTRAINT zkapp_other_party_body_account_identifier_id_fkey FOREIGN KEY (account_identifier_id) REFERENCES public.account_identifiers(id); +ALTER TABLE ONLY public.zkapp_account_update_body + ADD CONSTRAINT zkapp_account_update_body_account_identifier_id_fkey FOREIGN KEY (account_identifier_id) REFERENCES public.account_identifiers(id); -- --- Name: zkapp_other_party_body zkapp_other_party_body_call_data_id_fkey; Type: FK CONSTRAINT; Schema: public; +-- Name: zkapp_account_update_body zkapp_account_update_body_call_data_id_fkey; Type: FK CONSTRAINT; Schema: public; -- -ALTER TABLE ONLY public.zkapp_other_party_body - ADD CONSTRAINT zkapp_other_party_body_call_data_id_fkey FOREIGN KEY (call_data_id) REFERENCES public.zkapp_state_data(id); +ALTER TABLE ONLY public.zkapp_account_update_body + ADD CONSTRAINT zkapp_account_update_body_call_data_id_fkey FOREIGN KEY (call_data_id) REFERENCES public.zkapp_state_data(id); -- --- Name: zkapp_other_party_body zkapp_other_party_body_events_id_fkey; Type: FK CONSTRAINT; Schema: public; +-- Name: zkapp_account_update_body zkapp_account_update_body_events_id_fkey; Type: FK CONSTRAINT; Schema: public; -- -ALTER TABLE ONLY public.zkapp_other_party_body - ADD CONSTRAINT zkapp_other_party_body_events_id_fkey FOREIGN KEY (events_id) REFERENCES public.zkapp_events(id); +ALTER TABLE ONLY public.zkapp_account_update_body + ADD CONSTRAINT zkapp_account_update_body_events_id_fkey FOREIGN KEY (events_id) REFERENCES public.zkapp_events(id); -- --- Name: zkapp_other_party zkapp_other_party_body_id_fkey; Type: FK CONSTRAINT; Schema: public; +-- Name: zkapp_account_update zkapp_account_update_body_id_fkey; Type: FK CONSTRAINT; Schema: public; -- -ALTER TABLE ONLY public.zkapp_other_party - ADD CONSTRAINT zkapp_other_party_body_id_fkey FOREIGN KEY (body_id) REFERENCES public.zkapp_other_party_body(id); +ALTER TABLE ONLY public.zkapp_account_update + ADD CONSTRAINT zkapp_account_update_body_id_fkey FOREIGN KEY (body_id) REFERENCES public.zkapp_account_update_body(id); -- --- Name: zkapp_other_party_body zkapp_other_party_body_sequence_events_id_fkey; Type: FK CONSTRAINT; Schema: public; +-- Name: zkapp_account_update_body zkapp_account_update_body_sequence_events_id_fkey; Type: FK CONSTRAINT; Schema: public; -- -ALTER TABLE ONLY public.zkapp_other_party_body - ADD CONSTRAINT zkapp_other_party_body_sequence_events_id_fkey FOREIGN KEY (sequence_events_id) REFERENCES public.zkapp_events(id); +ALTER TABLE ONLY public.zkapp_account_update_body + ADD CONSTRAINT zkapp_account_update_body_sequence_events_id_fkey FOREIGN KEY (sequence_events_id) REFERENCES public.zkapp_events(id); -- --- Name: zkapp_other_party_body zkapp_other_party_body_update_id_fkey; Type: FK CONSTRAINT; Schema: public; +-- Name: zkapp_account_update_body zkapp_account_update_body_update_id_fkey; Type: FK CONSTRAINT; Schema: public; -- -ALTER TABLE ONLY public.zkapp_other_party_body - ADD CONSTRAINT zkapp_other_party_body_update_id_fkey FOREIGN KEY (update_id) REFERENCES public.zkapp_updates(id); +ALTER TABLE ONLY public.zkapp_account_update_body + ADD CONSTRAINT zkapp_account_update_body_update_id_fkey FOREIGN KEY (update_id) REFERENCES public.zkapp_updates(id); -- --- Name: zkapp_other_party_body zkapp_other_party_body_zkapp_account_precondition_id_fkey; Type: FK CONSTRAINT; Schema: public; +-- Name: zkapp_account_update_body zkapp_account_update_body_zkapp_account_precondition_id_fkey; Type: FK CONSTRAINT; Schema: public; -- -ALTER TABLE ONLY public.zkapp_other_party_body - ADD CONSTRAINT zkapp_other_party_body_zkapp_account_precondition_id_fkey FOREIGN KEY (zkapp_account_precondition_id) REFERENCES public.zkapp_account_precondition(id); +ALTER TABLE ONLY public.zkapp_account_update_body + ADD CONSTRAINT zkapp_account_update_body_zkapp_account_precondition_id_fkey FOREIGN KEY (zkapp_account_precondition_id) REFERENCES public.zkapp_account_precondition(id); -- --- Name: zkapp_other_party_body zkapp_other_party_body_zkapp_network_precondition_id_fkey; Type: FK CONSTRAINT; Schema: public; +-- Name: zkapp_account_update_body zkapp_account_update_body_zkapp_network_precondition_id_fkey; Type: FK CONSTRAINT; Schema: public; -- -ALTER TABLE ONLY public.zkapp_other_party_body - ADD CONSTRAINT zkapp_other_party_body_zkapp_network_precondition_id_fkey FOREIGN KEY (zkapp_network_precondition_id) REFERENCES public.zkapp_network_precondition(id); +ALTER TABLE ONLY public.zkapp_account_update_body + ADD CONSTRAINT zkapp_account_update_body_zkapp_network_precondition_id_fkey FOREIGN KEY (zkapp_network_precondition_id) REFERENCES public.zkapp_network_precondition(id); -- diff --git a/src/app/test_executive/dune b/src/app/test_executive/dune index b5e98d1680d..bf5b6be55d6 100644 --- a/src/app/test_executive/dune +++ b/src/app/test_executive/dune @@ -44,7 +44,7 @@ user_command_input participating_state sgn - parties_builder + zkapp_command_builder network_pool ) (instrumentation (backend bisect_ppx)) diff --git a/src/app/test_executive/snarkyjs.ml b/src/app/test_executive/snarkyjs.ml index c57535f19fb..52c9e8d749d 100644 --- a/src/app/test_executive/snarkyjs.ml +++ b/src/app/test_executive/snarkyjs.ml @@ -47,7 +47,7 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct let run network t = let open Malleable_error.Let_syntax in let logger = Logger.create () in - let wait_for_zkapp parties = + let wait_for_zkapp zkapp_command = let with_timeout = let soft_timeout = Network_time_span.Slots 3 in let hard_timeout = Network_time_span.Slots 4 in @@ -56,7 +56,7 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct let%map () = wait_for t @@ with_timeout @@ Wait_condition.zkapp_to_be_included_in_frontier ~has_failures:false - ~parties + ~zkapp_command in [%log info] "zkApp transaction included in transition frontier" in @@ -86,7 +86,7 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct (* concurrently make/sign the deploy transaction and wait for the node to be ready *) [%log info] "Running JS script with command $jscommand" ~metadata:[ ("jscommand", `String which_str) ] ; - let%bind.Deferred parties_contract_str, unit_with_error = + let%bind.Deferred zkapp_command_contract_str, unit_with_error = Deferred.both (let%bind.Deferred process = Async_unix.Process.create_exn @@ -103,27 +103,28 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct wait_and_stdout ~logger process ) (wait_for t (Wait_condition.node_to_initialize node)) in - let parties_contract = - Mina_base.Parties.of_json (Yojson.Safe.from_string parties_contract_str) + let zkapp_command_contract = + Mina_base.Zkapp_command.of_json + (Yojson.Safe.from_string zkapp_command_contract_str) in let%bind () = Deferred.return unit_with_error in (* TODO: switch to external sending script once the rest is working *) - let%bind () = send_zkapp ~logger node parties_contract in - return parties_contract + let%bind () = send_zkapp ~logger node zkapp_command_contract in + return zkapp_command_contract in - let%bind parties_deploy_contract = make_sign_and_send `Deploy in + let%bind zkapp_command_deploy_contract = make_sign_and_send `Deploy in let%bind () = section "Wait for deploy contract transaction to be included in transition \ frontier" - (wait_for_zkapp parties_deploy_contract) + (wait_for_zkapp zkapp_command_deploy_contract) in - let%bind parties_update_contract = make_sign_and_send `Update in + let%bind zkapp_command_update_contract = make_sign_and_send `Update in let%bind () = section "Wait for update contract transaction to be included in transition \ frontier" - (wait_for_zkapp parties_update_contract) + (wait_for_zkapp zkapp_command_update_contract) in let%bind () = section "Verify that the update transaction did update the ledger" diff --git a/src/app/test_executive/test_common.ml b/src/app/test_executive/test_common.ml index 62e295eab65..fb7f84fee14 100644 --- a/src/app/test_executive/test_common.ml +++ b/src/app/test_executive/test_common.ml @@ -7,15 +7,16 @@ open Integration_test_lib module Make (Inputs : Intf.Test.Inputs_intf) = struct open Inputs.Engine - let send_zkapp ~logger node parties = + let send_zkapp ~logger node zkapp_command = [%log info] "Sending zkApp" ~metadata: - [ ("parties", Mina_base.Parties.to_yojson parties) + [ ("zkapp_command", Mina_base.Zkapp_command.to_yojson zkapp_command) ; ( "memo" - , `String (Mina_base.Signed_command_memo.to_string_hum parties.memo) + , `String + (Mina_base.Signed_command_memo.to_string_hum zkapp_command.memo) ) ] ; - match%bind.Deferred Network.Node.send_zkapp ~logger node ~parties with + match%bind.Deferred Network.Node.send_zkapp ~logger node ~zkapp_command with | Ok _zkapp_id -> [%log info] "ZkApp transaction sent" ; Malleable_error.return () @@ -25,9 +26,9 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct ~metadata:[ ("error", `String err_str) ] ; Malleable_error.hard_error_format "Error sending zkApp: %s" err_str - let send_invalid_zkapp ~logger node parties substring = + let send_invalid_zkapp ~logger node zkapp_command substring = [%log info] "Sending zkApp, expected to fail" ; - match%bind.Deferred Network.Node.send_zkapp ~logger node ~parties with + match%bind.Deferred Network.Node.send_zkapp ~logger node ~zkapp_command with | Ok _zkapp_id -> [%log error] "ZkApp transaction succeeded, expected error \"%s\"" substring ; @@ -115,8 +116,8 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct | Set _, Keep -> false - let compatible_updates ~(ledger_update : Mina_base.Party.Update.t) - ~(requested_update : Mina_base.Party.Update.t) : bool = + let compatible_updates ~(ledger_update : Mina_base.Account_update.Update.t) + ~(requested_update : Mina_base.Account_update.Update.t) : bool = (* the "update" in the ledger is derived from the account if the requested update has `Set` for a field, we @@ -164,7 +165,7 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct in let timings_compat = compatible_item requested_update.timing ledger_update.timing - ~equal:Mina_base.Party.Update.Timing_info.equal + ~equal:Mina_base.Account_update.Update.Timing_info.equal in let voting_fors_compat = compatible_item requested_update.voting_for ledger_update.voting_for diff --git a/src/app/test_executive/zkapps.ml b/src/app/test_executive/zkapps.ml index 54472702d8d..8fcf8489c79 100644 --- a/src/app/test_executive/zkapps.ml +++ b/src/app/test_executive/zkapps.ml @@ -41,9 +41,9 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct let transactions_sent = ref 0 - let send_zkapp ~logger node parties = + let send_zkapp ~logger node zkapp_command = incr transactions_sent ; - send_zkapp ~logger node parties + send_zkapp ~logger node zkapp_command (* Call [f] [n] times in sequence *) let repeat_seq ~n ~f = @@ -139,15 +139,15 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct (zkapp_keypair.public_key |> Signature_lib.Public_key.compress) Token_id.default ) in - let%bind parties_create_accounts = - (* construct a Parties.t, similar to zkapp_test_transaction create-zkapp-account *) + let%bind zkapp_command_create_accounts = + (* construct a Zkapp_command.t, similar to zkapp_test_transaction create-zkapp-account *) let amount = Currency.Amount.of_int 10_000_000_000 in let nonce = Account.Nonce.zero in let memo = Signed_command_memo.create_from_string_exn "Zkapp create account" in let fee = Currency.Fee.of_int 20_000_000 in - let (parties_spec : Transaction_snark.For_tests.Spec.t) = + let (zkapp_command_spec : Transaction_snark.For_tests.Spec.t) = { sender = (fish1_kp, nonce) ; fee ; fee_payer = None @@ -156,7 +156,7 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct ; zkapp_account_keypairs = zkapp_keypairs ; memo ; new_zkapp_account = true - ; snapp_update = Party.Update.dummy + ; snapp_update = Account_update.Update.dummy ; current_auth = Permissions.Auth_required.Signature ; call_data = Snark_params.Tick.Field.zero ; events = [] @@ -166,15 +166,15 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct in return @@ Transaction_snark.For_tests.deploy_snapp ~constraint_constants - parties_spec + zkapp_command_spec in - let%bind.Deferred parties_update_permissions, permissions_updated = - (* construct a Parties.t, similar to zkapp_test_transaction update-permissions *) + let%bind.Deferred zkapp_command_update_permissions, permissions_updated = + (* construct a Zkapp_command.t, similar to zkapp_test_transaction update-permissions *) let nonce = Account.Nonce.zero in let memo = Signed_command_memo.create_from_string_exn "Zkapp update permissions" in - (* Lower fee so that parties_create_accounts gets applied first *) + (* Lower fee so that zkapp_command_create_accounts gets applied first *) let fee = Currency.Fee.of_int 10_000_000 in let new_permissions : Permissions.t = { Permissions.user_default with @@ -189,7 +189,7 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct ; send = Proof } in - let (parties_spec : Transaction_snark.For_tests.Spec.t) = + let (zkapp_command_spec : Transaction_snark.For_tests.Spec.t) = { sender = (fish2_kp, nonce) ; fee ; fee_payer = None @@ -199,7 +199,9 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct ; memo ; new_zkapp_account = false ; snapp_update = - { Party.Update.dummy with permissions = Set new_permissions } + { Account_update.Update.dummy with + permissions = Set new_permissions + } ; current_auth = (* current set_permissions permission requires Signature *) Permissions.Auth_required.Signature @@ -209,18 +211,18 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct ; preconditions = None } in - let%map.Deferred parties = + let%map.Deferred zkapp_command = Transaction_snark.For_tests.update_states ~constraint_constants - parties_spec + zkapp_command_spec in - (parties, new_permissions) + (zkapp_command, new_permissions) in let%bind.Deferred ( zkapp_update_all - , parties_update_all - , parties_invalid_nonce - , parties_insufficient_funds - , parties_insufficient_replace_fee - , parties_insufficient_fee ) = + , zkapp_command_update_all + , zkapp_command_invalid_nonce + , zkapp_command_insufficient_funds + , zkapp_command_insufficient_replace_fee + , zkapp_command_insufficient_fee ) = let amount = Currency.Amount.zero in let nonce = Account.Nonce.of_int 1 in let memo = @@ -251,7 +253,7 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct let new_zkapp_uri = "https://www.minaprotocol.com" in let new_token_symbol = "SHEKEL" in let new_voting_for = Quickcheck.random_value State_hash.gen in - let snapp_update : Party.Update.t = + let snapp_update : Account_update.Update.t = { app_state ; delegate = Set new_delegate ; verification_key = Set new_verification_key @@ -263,7 +265,7 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct ; voting_for = Set new_voting_for } in - let (parties_spec : Transaction_snark.For_tests.Spec.t) = + let (zkapp_command_spec : Transaction_snark.For_tests.Spec.t) = { sender = (fish2_kp, nonce) ; fee ; fee_payer = None @@ -280,41 +282,43 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct ; preconditions = None } in - let%bind.Deferred parties_update_all = + let%bind.Deferred zkapp_command_update_all = Transaction_snark.For_tests.update_states ~constraint_constants - parties_spec + zkapp_command_spec in - let%bind.Deferred parties_invalid_nonce = + let%bind.Deferred zkapp_command_invalid_nonce = Transaction_snark.For_tests.update_states ~constraint_constants - { parties_spec with sender = (fish2_kp, Account.Nonce.max_value) } + { zkapp_command_spec with + sender = (fish2_kp, Account.Nonce.max_value) + } in - let%bind.Deferred parties_insufficient_funds = + let%bind.Deferred zkapp_command_insufficient_funds = Transaction_snark.For_tests.update_states ~constraint_constants - { parties_spec with fee = Currency.Fee.max_int } + { zkapp_command_spec with fee = Currency.Fee.max_int } in - let%bind.Deferred parties_insufficient_replace_fee = + let%bind.Deferred zkapp_command_insufficient_replace_fee = let spec_insufficient_replace_fee : Transaction_snark.For_tests.Spec.t = - { parties_spec with fee = Currency.Fee.of_int 5_000_000 } + { zkapp_command_spec with fee = Currency.Fee.of_int 5_000_000 } in Transaction_snark.For_tests.update_states ~constraint_constants spec_insufficient_replace_fee in - let%map.Deferred parties_insufficient_fee = + let%map.Deferred zkapp_command_insufficient_fee = let spec_insufficient_fee : Transaction_snark.For_tests.Spec.t = - { parties_spec with fee = Currency.Fee.of_int 1000 } + { zkapp_command_spec with fee = Currency.Fee.of_int 1000 } in Transaction_snark.For_tests.update_states ~constraint_constants spec_insufficient_fee in ( snapp_update - , parties_update_all - , parties_invalid_nonce - , parties_insufficient_funds - , parties_insufficient_replace_fee - , parties_insufficient_fee ) - in - let parties_invalid_signature = - let p = parties_update_all in + , zkapp_command_update_all + , zkapp_command_invalid_nonce + , zkapp_command_insufficient_funds + , zkapp_command_insufficient_replace_fee + , zkapp_command_insufficient_fee ) + in + let zkapp_command_invalid_signature = + let p = zkapp_command_update_all in { p with fee_payer = { body = { p.fee_payer.body with nonce = Account.Nonce.of_int 2 } @@ -322,13 +326,13 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct } } in - let parties_invalid_proof = - let p = parties_update_all in - Parties. + let zkapp_command_invalid_proof = + let p = zkapp_command_update_all in + Zkapp_command. { p with - other_parties = - Call_forest.map p.other_parties ~f:(fun other_p -> - match other_p.Party.authorization with + account_updates = + Call_forest.map p.account_updates ~f:(fun other_p -> + match other_p.Account_update.authorization with | Proof _ -> { other_p with authorization = @@ -338,7 +342,7 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct other_p ) } in - let%bind.Deferred parties_nonexistent_fee_payer = + let%bind.Deferred zkapp_command_nonexistent_fee_payer = let new_kp = Signature_lib.Keypair.create () in let memo = Signed_command_memo.create_from_string_exn "Non-existent account" @@ -353,7 +357,7 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct ; zkapp_account_keypairs = zkapp_keypairs ; memo ; new_zkapp_account = false - ; snapp_update = Party.Update.dummy + ; snapp_update = Account_update.Update.dummy ; current_auth = Permissions.Auth_required.None ; call_data = Snark_params.Tick.Field.zero ; events = [] @@ -363,10 +367,10 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct in Transaction_snark.For_tests.update_states ~constraint_constants spec in - let%bind.Deferred ( parties_mint_token - , parties_mint_token2 - , parties_token_transfer - , parties_token_transfer2 ) = + let%bind.Deferred ( zkapp_command_mint_token + , zkapp_command_mint_token2 + , zkapp_command_token_transfer + , zkapp_command_token_transfer2 ) = (* similar to tokens tests in transaction_snark/tests/zkapp_tokens.ml and `Mina_ledger.Ledger` @@ -407,109 +411,115 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct let fee_payer_pk = Signature_lib.Public_key.compress token_funder.public_key in - let%bind.Deferred parties_mint_token = - let open Parties_builder in + let%bind.Deferred zkapp_command_mint_token = + let open Zkapp_command_builder in let with_dummy_signatures = mk_forest [ mk_node - (mk_party_body Call token_owner Token_id.default + (mk_account_update_body Call token_owner Token_id.default (-account_creation_fee_int) ) [ mk_node - (mk_party_body Call token_accounts.(0) custom_token_id 10000) + (mk_account_update_body Call token_accounts.(0) + custom_token_id 10000 ) [] ] ] - |> mk_parties_transaction ~memo:"mint token" ~fee:12_000_000 - ~fee_payer_pk ~fee_payer_nonce:(Account.Nonce.of_int 2) + |> mk_zkapp_command ~memo:"mint token" ~fee:12_000_000 ~fee_payer_pk + ~fee_payer_nonce:(Account.Nonce.of_int 2) in replace_authorizations ~keymap with_dummy_signatures in - let%bind.Deferred parties_mint_token2 = - let open Parties_builder in + let%bind.Deferred zkapp_command_mint_token2 = + let open Zkapp_command_builder in let with_dummy_signatures = mk_forest [ mk_node - (mk_party_body Call token_owner Token_id.default + (mk_account_update_body Call token_owner Token_id.default (-2 * account_creation_fee_int) ) [ mk_node - (mk_party_body Call token_owner custom_token_id 0) + (mk_account_update_body Call token_owner custom_token_id 0) [ mk_node - (mk_party_body Call token_accounts.(2) custom_token_id2 - 500 ) + (mk_account_update_body Call token_accounts.(2) + custom_token_id2 500 ) [] ] ] ] - |> mk_parties_transaction ~memo:"zkapp to mint token2" ~fee:11_500_000 + |> mk_zkapp_command ~memo:"zkapp to mint token2" ~fee:11_500_000 ~fee_payer_pk ~fee_payer_nonce:(Account.Nonce.of_int 3) in replace_authorizations ~keymap with_dummy_signatures in - let%bind.Deferred parties_token_transfer = - let open Parties_builder in - (* lower fee than minting Parties.t *) + let%bind.Deferred zkapp_command_token_transfer = + let open Zkapp_command_builder in + (* lower fee than minting Zkapp_command.t *) let with_dummy_signatures = mk_forest [ mk_node - (mk_party_body Call token_owner Token_id.default + (mk_account_update_body Call token_owner Token_id.default (-account_creation_fee_int) ) [ mk_node - (mk_party_body Call token_accounts.(0) custom_token_id (-30)) + (mk_account_update_body Call token_accounts.(0) + custom_token_id (-30) ) [] ; mk_node - (mk_party_body Call token_accounts.(1) custom_token_id 30) + (mk_account_update_body Call token_accounts.(1) + custom_token_id 30 ) [] ; mk_node - (mk_party_body Call token_funder Token_id.default (-50)) + (mk_account_update_body Call token_funder Token_id.default + (-50) ) [] ; mk_node - (mk_party_body Call token_funder Token_id.default 50) + (mk_account_update_body Call token_funder Token_id.default + 50 ) [] ] ] - |> mk_parties_transaction ~memo:"zkapp for tokens transfer" - ~fee:11_000_000 ~fee_payer_pk - ~fee_payer_nonce:(Account.Nonce.of_int 4) + |> mk_zkapp_command ~memo:"zkapp for tokens transfer" ~fee:11_000_000 + ~fee_payer_pk ~fee_payer_nonce:(Account.Nonce.of_int 4) in replace_authorizations ~keymap with_dummy_signatures in - let%map.Deferred parties_token_transfer2 = - let open Parties_builder in + let%map.Deferred zkapp_command_token_transfer2 = + let open Zkapp_command_builder in (* lower fee than first tokens transfer *) let with_dummy_signatures = mk_forest [ mk_node - (mk_party_body Call token_owner Token_id.default + (mk_account_update_body Call token_owner Token_id.default (-account_creation_fee_int) ) [ mk_node - (mk_party_body Call token_accounts.(1) custom_token_id (-5)) + (mk_account_update_body Call token_accounts.(1) + custom_token_id (-5) ) [] ; mk_node - (mk_party_body Call token_accounts.(0) custom_token_id 5) + (mk_account_update_body Call token_accounts.(0) + custom_token_id 5 ) [] ; mk_node - (mk_party_body Call token_owner custom_token_id 0) + (mk_account_update_body Call token_owner custom_token_id 0) [ mk_node - (mk_party_body Call token_accounts.(2) custom_token_id2 - (-210) ) + (mk_account_update_body Call token_accounts.(2) + custom_token_id2 (-210) ) [] ; mk_node - (mk_party_body Call token_accounts.(3) custom_token_id2 - 210 ) + (mk_account_update_body Call token_accounts.(3) + custom_token_id2 210 ) [] ] ] ] - |> mk_parties_transaction ~memo:"zkapp for tokens transfer 2" + |> mk_zkapp_command ~memo:"zkapp for tokens transfer 2" ~fee:10_000_000 ~fee_payer_pk ~fee_payer_nonce:(Account.Nonce.of_int 5) in replace_authorizations ~keymap with_dummy_signatures in - ( parties_mint_token - , parties_mint_token2 - , parties_token_transfer - , parties_token_transfer2 ) + ( zkapp_command_mint_token + , zkapp_command_mint_token2 + , zkapp_command_token_transfer + , zkapp_command_token_transfer2 ) in let with_timeout = let soft_slots = 4 in @@ -517,11 +527,11 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct let hard_timeout = Network_time_span.Slots (soft_slots * 2) in Wait_condition.with_timeouts ~soft_timeout ~hard_timeout in - let wait_for_zkapp parties = + let wait_for_zkapp zkapp_command = let%map () = wait_for t @@ with_timeout @@ Wait_condition.zkapp_to_be_included_in_frontier ~has_failures:false - ~parties + ~zkapp_command in [%log info] "ZkApp transactions included in transition frontier" in @@ -534,8 +544,8 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct | Set _, Keep -> false in - let compatible_updates ~(ledger_update : Party.Update.t) - ~(requested_update : Party.Update.t) : bool = + let compatible_updates ~(ledger_update : Account_update.Update.t) + ~(requested_update : Account_update.Update.t) : bool = (* the "update" in the ledger is derived from the account if the requested update has `Set` for a field, we @@ -583,7 +593,7 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct in let timings_compat = compatible requested_update.timing ledger_update.timing - ~equal:Party.Update.Timing_info.equal + ~equal:Account_update.Update.Timing_info.equal in let voting_fors_compat = compatible requested_update.voting_for ledger_update.voting_for @@ -614,13 +624,13 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct in let%bind () = section_hard "Send a zkApp transaction to create zkApp accounts" - (send_zkapp ~logger node parties_create_accounts) + (send_zkapp ~logger node zkapp_command_create_accounts) in let%bind () = section_hard "Wait for zkapp to create accounts to be included in transition \ frontier" - (wait_for_zkapp parties_create_accounts) + (wait_for_zkapp zkapp_command_create_accounts) in let%bind () = let sender = List.hd_exn zkapp_keypairs in @@ -631,13 +641,13 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct in let%bind () = section_hard "Send a zkApp transaction to update permissions" - (send_zkapp ~logger node parties_update_permissions) + (send_zkapp ~logger node zkapp_command_update_permissions) in let%bind () = section_hard "Wait for zkApp transaction to update permissions to be included in \ transition frontier" - (wait_for_zkapp parties_update_permissions) + (wait_for_zkapp zkapp_command_update_permissions) in let%bind () = let sender = List.hd_exn zkapp_keypairs in @@ -675,81 +685,82 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct in let%bind () = section_hard "Send a zkapp with an insufficient fee" - (send_invalid_zkapp ~logger node parties_insufficient_fee + (send_invalid_zkapp ~logger node zkapp_command_insufficient_fee "Some commands have an insufficient fee" ) in (* Won't be accepted until the previous transactions are applied *) let%bind () = section_hard "Send a zkApp transaction to update all fields" - (send_zkapp ~logger node parties_update_all) + (send_zkapp ~logger node zkapp_command_update_all) in let%bind () = section_hard "Send a zkapp with an invalid proof" - (send_invalid_zkapp ~logger node parties_invalid_proof + (send_invalid_zkapp ~logger node zkapp_command_invalid_proof "Verification_failed" ) in let%bind () = section_hard "Send a zkapp with an insufficient replace fee" - (send_invalid_zkapp ~logger node parties_insufficient_replace_fee + (send_invalid_zkapp ~logger node zkapp_command_insufficient_replace_fee "Insufficient_replace_fee" ) in let%bind () = section_hard "Send a zkApp transaction with an invalid nonce" - (send_invalid_zkapp ~logger node parties_invalid_nonce "Invalid_nonce") + (send_invalid_zkapp ~logger node zkapp_command_invalid_nonce + "Invalid_nonce" ) in let%bind () = section_hard "Send a zkApp transaction with insufficient_funds, fee too high" - (send_invalid_zkapp ~logger node parties_insufficient_funds + (send_invalid_zkapp ~logger node zkapp_command_insufficient_funds "Insufficient_funds" ) in let%bind () = section_hard "Send a zkApp transaction with an invalid signature" - (send_invalid_zkapp ~logger node parties_invalid_signature + (send_invalid_zkapp ~logger node zkapp_command_invalid_signature "Verification_failed" ) in let%bind () = section_hard "Send a zkApp transaction with a nonexistent fee payer" - (send_invalid_zkapp ~logger node parties_nonexistent_fee_payer + (send_invalid_zkapp ~logger node zkapp_command_nonexistent_fee_payer "Fee_payer_account_not_found" ) in let%bind () = section_hard "Wait for zkApp transaction to update all fields to be included in \ transition frontier" - (wait_for_zkapp parties_update_all) + (wait_for_zkapp zkapp_command_update_all) in let%bind () = section_hard "Send a zkApp transaction to mint token" - (send_zkapp ~logger node parties_mint_token) + (send_zkapp ~logger node zkapp_command_mint_token) in let%bind () = section_hard "Send a zkApp transaction to mint 2nd token" - (send_zkapp ~logger node parties_mint_token2) + (send_zkapp ~logger node zkapp_command_mint_token2) in let%bind () = section_hard "Send a zkApp transaction to transfer tokens" - (send_zkapp ~logger node parties_token_transfer) + (send_zkapp ~logger node zkapp_command_token_transfer) in let%bind () = section_hard "Send a zkApp transaction to transfer tokens (2)" - (send_zkapp ~logger node parties_token_transfer2) + (send_zkapp ~logger node zkapp_command_token_transfer2) in let%bind () = section_hard "Wait for zkApp transaction to mint token" - (wait_for_zkapp parties_mint_token) + (wait_for_zkapp zkapp_command_mint_token) in let%bind () = section_hard "Wait for zkApp transaction to mint 2nd token" - (wait_for_zkapp parties_mint_token2) + (wait_for_zkapp zkapp_command_mint_token2) in let%bind () = section_hard "Wait for zkApp transaction to transfer tokens" - (wait_for_zkapp parties_token_transfer) + (wait_for_zkapp zkapp_command_token_transfer) in let%bind () = section_hard "Wait for zkApp transaction to transfer tokens (2)" - (wait_for_zkapp parties_token_transfer2) + (wait_for_zkapp zkapp_command_token_transfer2) in let%bind () = section_hard "Verify zkApp transaction updates in ledger" @@ -769,9 +780,10 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct [%log error] "Ledger update and requested update are incompatible" ~metadata: - [ ("ledger_update", Party.Update.to_yojson ledger_update) + [ ( "ledger_update" + , Account_update.Update.to_yojson ledger_update ) ; ( "requested_update" - , Party.Update.to_yojson zkapp_update_all ) + , Account_update.Update.to_yojson zkapp_update_all ) ] ; Malleable_error.hard_error (Error.of_string diff --git a/src/app/test_executive/zkapps_timing.ml b/src/app/test_executive/zkapps_timing.ml index 50440bb19dc..481d3fd48aa 100644 --- a/src/app/test_executive/zkapps_timing.ml +++ b/src/app/test_executive/zkapps_timing.ml @@ -47,7 +47,7 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct ; private_key = fee_payer_sk } in - let%bind ( parties_create_account_with_timing + let%bind ( zkapp_command_create_account_with_timing , timing_account_id , timing_update , timed_account_keypair ) = @@ -60,7 +60,7 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct "zkApp create account with timing" in let zkapp_keypair = Signature_lib.Keypair.create () in - let (parties_spec : Transaction_snark.For_tests.Spec.t) = + let (zkapp_command_spec : Transaction_snark.For_tests.Spec.t) = { sender = (keypair, nonce) ; fee ; fee_payer = None @@ -79,9 +79,9 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct ; vesting_period = Mina_numbers.Global_slot.of_int 2 ; vesting_increment = Currency.Amount.of_int 1_000 } - : Party.Update.Timing_info.value ) + : Account_update.Update.Timing_info.value ) in - { Party.Update.dummy with timing } ) + { Account_update.Update.dummy with timing } ) ; current_auth = Permissions.Auth_required.Signature ; call_data = Snark_params.Tick.Field.zero ; events = [] @@ -96,12 +96,12 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct in return ( Transaction_snark.For_tests.deploy_snapp ~constraint_constants - parties_spec + zkapp_command_spec , timing_account_id - , parties_spec.snapp_update + , zkapp_command_spec.snapp_update , zkapp_keypair ) in - let%bind parties_create_second_account_with_timing = + let%bind zkapp_command_create_second_account_with_timing = let open Mina_base in let fee = Currency.Fee.of_int 1_000_000 in let amount = Currency.Amount.of_int 10_000_000_000 in @@ -111,7 +111,7 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct "zkApp, 2nd account with timing" in let zkapp_keypair = Signature_lib.Keypair.create () in - let (parties_spec : Transaction_snark.For_tests.Spec.t) = + let (zkapp_command_spec : Transaction_snark.For_tests.Spec.t) = { sender = (keypair, nonce) ; fee ; fee_payer = None @@ -131,9 +131,9 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct ; vesting_period = Mina_numbers.Global_slot.of_int 2 ; vesting_increment = Currency.Amount.of_int 1_000 } - : Party.Update.Timing_info.value ) + : Account_update.Update.Timing_info.value ) in - { Party.Update.dummy with timing } ) + { Account_update.Update.dummy with timing } ) ; current_auth = Permissions.Auth_required.Signature ; sequence_events = [] ; events = [] @@ -143,9 +143,9 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct in return @@ Transaction_snark.For_tests.deploy_snapp ~constraint_constants - parties_spec + zkapp_command_spec in - let%bind parties_transfer_from_timed_account = + let%bind zkapp_command_transfer_from_timed_account = let open Mina_base in let fee = Currency.Fee.of_int 1_000_000 in let amount = Currency.Amount.of_int 1_500_000 in @@ -158,7 +158,7 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct let receiver_key = keypair.public_key |> Signature_lib.Public_key.compress in - let (parties_spec : Transaction_snark.For_tests.Spec.t) = + let (zkapp_command_spec : Transaction_snark.For_tests.Spec.t) = { sender = (sender_keypair, nonce) ; fee ; fee_payer = None @@ -167,7 +167,7 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct ; zkapp_account_keypairs = [] ; memo ; new_zkapp_account = false - ; snapp_update = Party.Update.dummy + ; snapp_update = Account_update.Update.dummy ; current_auth = Permissions.Auth_required.Signature ; call_data = Snark_params.Tick.Field.zero ; events = [] @@ -175,9 +175,10 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct ; preconditions = None } in - return @@ Transaction_snark.For_tests.multiple_transfers parties_spec + return + @@ Transaction_snark.For_tests.multiple_transfers zkapp_command_spec in - let%bind parties_invalid_transfer_from_timed_account = + let%bind zkapp_command_invalid_transfer_from_timed_account = let open Mina_base in let fee = Currency.Fee.of_int 1_000_000 in let amount = Currency.Amount.of_int 7_000_000_000 in @@ -190,7 +191,7 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct let receiver_key = keypair.public_key |> Signature_lib.Public_key.compress in - let (parties_spec : Transaction_snark.For_tests.Spec.t) = + let (zkapp_command_spec : Transaction_snark.For_tests.Spec.t) = { sender = (sender_keypair, nonce) ; fee ; fee_payer = None @@ -199,7 +200,7 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct ; zkapp_account_keypairs = [] ; memo ; new_zkapp_account = false - ; snapp_update = Party.Update.dummy + ; snapp_update = Account_update.Update.dummy ; current_auth = Permissions.Auth_required.Signature ; call_data = Snark_params.Tick.Field.zero ; events = [] @@ -207,9 +208,10 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct ; preconditions = None } in - return @@ Transaction_snark.For_tests.multiple_transfers parties_spec + return + @@ Transaction_snark.For_tests.multiple_transfers zkapp_command_spec in - let%bind.Deferred parties_update_timing = + let%bind.Deferred zkapp_command_update_timing = let open Mina_base in let fee = Currency.Fee.of_int 1_000_000 in let amount = Currency.Amount.zero in @@ -218,8 +220,8 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct Signed_command_memo.create_from_string_exn "zkApp, invalid update timing" in - let snapp_update : Party.Update.t = - { Party.Update.dummy with + let snapp_update : Account_update.Update.t = + { Account_update.Update.dummy with timing = Zkapp_basic.Set_or_keep.Set { initial_minimum_balance = Currency.Balance.of_int 9_000_000_000 @@ -230,7 +232,7 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct } } in - let (parties_spec : Transaction_snark.For_tests.Spec.t) = + let (zkapp_command_spec : Transaction_snark.For_tests.Spec.t) = { sender = (keypair, nonce) ; fee ; fee_payer = None @@ -248,7 +250,7 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct } in Transaction_snark.For_tests.update_states ~constraint_constants - parties_spec + zkapp_command_spec in let with_timeout = let soft_slots = 3 in @@ -256,34 +258,35 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct let hard_timeout = Network_time_span.Slots (soft_slots * 2) in Wait_condition.with_timeouts ~soft_timeout ~hard_timeout in - let wait_for_zkapp ~has_failures parties = + let wait_for_zkapp ~has_failures zkapp_command = let%map () = wait_for t @@ with_timeout @@ Wait_condition.zkapp_to_be_included_in_frontier ~has_failures - ~parties + ~zkapp_command in [%log info] "zkApp transaction included in transition frontier" in let%bind () = section "Send a zkApp to create a zkApp account with timing" - (send_zkapp ~logger node parties_create_account_with_timing) + (send_zkapp ~logger node zkapp_command_create_account_with_timing) in let%bind () = section "Wait for snapp to create account with timing to be included in \ transition frontier" - (wait_for_zkapp ~has_failures:false parties_create_account_with_timing) + (wait_for_zkapp ~has_failures:false + zkapp_command_create_account_with_timing ) in let%bind () = section "Send zkApp to create a 2nd zkApp account with timing" - (send_zkapp ~logger node parties_create_second_account_with_timing) + (send_zkapp ~logger node zkapp_command_create_second_account_with_timing) in let%bind () = section "Wait for snapp to create second account with timing to be included in \ transition frontier" (wait_for_zkapp ~has_failures:false - parties_create_second_account_with_timing ) + zkapp_command_create_second_account_with_timing ) in let%bind () = section "Verify zkApp timing in ledger" @@ -301,9 +304,9 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct because of the timing" ~metadata: [ ( "ledger_update" - , Mina_base.Party.Update.to_yojson ledger_update ) + , Mina_base.Account_update.Update.to_yojson ledger_update ) ; ( "requested_update" - , Mina_base.Party.Update.to_yojson timing_update ) + , Mina_base.Account_update.Update.to_yojson timing_update ) ] ; Malleable_error.hard_error @@ -320,11 +323,12 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct in *) let%bind () = section "Send a zkApp with transfer from timed account that succeeds" - (send_zkapp ~logger node parties_transfer_from_timed_account) + (send_zkapp ~logger node zkapp_command_transfer_from_timed_account) in let%bind () = section "Waiting for zkApp with transfer from timed account that succeeds" - (wait_for_zkapp ~has_failures:false parties_transfer_from_timed_account) + (wait_for_zkapp ~has_failures:false + zkapp_command_transfer_from_timed_account ) in (* let%bind after_balance = get_account_balance ~logger node timing_account_id @@ -345,18 +349,20 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct (Error.of_string "Unexpected underflow when taking balance difference" ) | Some diff -> - let sender_party = - (List.hd_exn parties_transfer_from_timed_account.other_parties) + let sender_account_update = + (List.hd_exn + zkapp_command_transfer_from_timed_account.account_updates ) .elt - .party + .account_update in let amount_to_send = Currency.Amount.Signed.magnitude - (Mina_base.Party.balance_change sender_party) + (Mina_base.Account_update.balance_change sender_account_update) in let fee = Currency.Amount.of_fee - (Mina_base.Parties.fee parties_transfer_from_timed_account) + (Mina_base.Zkapp_command.fee + zkapp_command_transfer_from_timed_account ) in let total_debited = Option.value_exn (Currency.Amount.( + ) amount_to_send fee) @@ -378,19 +384,20 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct section "Send a zkApp with transfer from timed account that fails due to min \ balance" - (let sender_party = + (let sender_account_update = (List.hd_exn - parties_invalid_transfer_from_timed_account.other_parties ) + zkapp_command_invalid_transfer_from_timed_account.account_updates ) .elt - .party + .account_update in let amount_to_send = Currency.Amount.Signed.magnitude - (Mina_base.Party.balance_change sender_party) + (Mina_base.Account_update.balance_change sender_account_update) in let fee = Currency.Amount.of_fee - (Mina_base.Parties.fee parties_invalid_transfer_from_timed_account) + (Mina_base.Zkapp_command.fee + zkapp_command_invalid_transfer_from_timed_account ) in let total_to_debit = Option.value_exn (Currency.Amount.( + ) amount_to_send fee) @@ -418,14 +425,15 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct assert ( Currency.Amount.( < ) proposed_balance (Option.value_exn locked_balance |> Currency.Balance.to_amount) ) ; - send_zkapp ~logger node parties_invalid_transfer_from_timed_account ) + send_zkapp ~logger node + zkapp_command_invalid_transfer_from_timed_account ) in let%bind () = section "Waiting for zkApp with transfer from timed account that fails due to \ min balance" (wait_for_zkapp ~has_failures:true - parties_invalid_transfer_from_timed_account ) + zkapp_command_invalid_transfer_from_timed_account ) in (* TODO: use transaction status to see that the transaction failed as things are, we examine the balance of the sender to see that no funds were transferred @@ -446,8 +454,8 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct Currency.Amount.( - ) (Currency.Balance.to_amount after_balance) (Currency.Amount.of_fee - (Mina_base.Parties.fee - parties_invalid_transfer_from_timed_account ) ) + (Mina_base.Zkapp_command.fee + zkapp_command_invalid_transfer_from_timed_account ) ) |> Option.value_exn in (* the invalid transfer should result in a fee deduction only *) @@ -467,11 +475,11 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct in let%bind () = section "Send a zkApp with invalid timing update" - (send_zkapp ~logger node parties_update_timing) + (send_zkapp ~logger node zkapp_command_update_timing) in let%bind () = section "Wait for snapp with invalid timing update" - (wait_for_zkapp ~has_failures:true parties_update_timing) + (wait_for_zkapp ~has_failures:true zkapp_command_update_timing) in let%bind () = section "Verify timing has not changed" @@ -480,7 +488,7 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct in if compatible_item ledger_update.timing timing_update.timing - ~equal:Mina_base.Party.Update.Timing_info.equal + ~equal:Mina_base.Account_update.Update.Timing_info.equal then ( [%log info] "Ledger update contains original timing, updated timing was not \ diff --git a/src/app/zkapp_test_transaction/lib/commands.ml b/src/app/zkapp_test_transaction/lib/commands.ml index 46df900a91e..9ad17896848 100644 --- a/src/app/zkapp_test_transaction/lib/commands.ml +++ b/src/app/zkapp_test_transaction/lib/commands.ml @@ -9,15 +9,15 @@ let proof_level = Genesis_constants.Proof_level.Full let underToCamel s = String.lowercase s |> Mina_graphql.Reflection.underToCamel -let graphql_zkapp_command (parties : Parties.t) = +let graphql_zkapp_command (zkapp_command : Zkapp_command.t) = sprintf {| mutation MyMutation { __typename - sendZkapp(input: { parties: %s }) + sendZkapp(input: { zkapp_command: %s }) } |} - (Parties.arg_query_string parties) + (Zkapp_command.arg_query_string zkapp_command) let parse_field_element_or_hash_string s ~f = match Or_error.try_with (fun () -> Snark_params.Tick.Field.of_string s) with @@ -29,11 +29,11 @@ let parse_field_element_or_hash_string s ~f = let `VK vk, `Prover zkapp_prover = Transaction_snark.For_tests.create_trivial_snapp ~constraint_constants () -let gen_proof ?(zkapp_account = None) (parties : Parties.t) = +let gen_proof ?(zkapp_account = None) (zkapp_command : Zkapp_command.t) = let ledger = Ledger.create ~depth:constraint_constants.ledger_depth () in let _v = let id = - parties.fee_payer.body.public_key + zkapp_command.fee_payer.body.public_key |> fun pk -> Account_id.create pk Token_id.default in Ledger.get_or_create_account ledger id @@ -83,11 +83,11 @@ let gen_proof ?(zkapp_account = None) (parties : Parties.t) = } in let witnesses, _final_ledger = - Transaction_snark.parties_witnesses_exn ~constraint_constants ~state_body - ~fee_excess:Currency.Amount.Signed.zero (`Ledger ledger) + Transaction_snark.zkapp_command_witnesses_exn ~constraint_constants + ~state_body ~fee_excess:Currency.Amount.Signed.zero (`Ledger ledger) [ ( `Pending_coinbase_init_stack pending_coinbase_init_stack , `Pending_coinbase_of_statement pending_coinbase_state_stack - , parties ) + , zkapp_command ) ] in let open Async.Deferred.Let_syntax in @@ -102,11 +102,11 @@ let gen_proof ?(zkapp_account = None) (parties : Parties.t) = printf "%s" (sprintf !"current witness \ - %{sexp:(Transaction_witness.Parties_segment_witness.t * \ - Transaction_snark.Parties_segment.Basic.t * \ + %{sexp:(Transaction_witness.Zkapp_command_segment_witness.t * \ + Transaction_snark.Zkapp_command_segment.Basic.t * \ Transaction_snark.Statement.With_sok.t) }%!" w ) ; - let%map _ = T.of_parties_segment_exn ~statement ~witness ~spec in + let%map _ = T.of_zkapp_command_segment_exn ~statement ~witness ~spec in ((), ()) ) in () @@ -142,20 +142,20 @@ let generate_zkapp_txn (keypair : Signature_lib.Keypair.t) (ledger : Ledger.t) let protocol_state_predicate_view = Mina_state.Protocol_state.Body.view compile_time_genesis.data.body in - Mina_generators.Parties_generators.gen_protocol_state_precondition + Mina_generators.Zkapp_command_generators.gen_protocol_state_precondition protocol_state_predicate_view |> Base_quickcheck.Generator.generate ~size:1 ~random:(Splittable_random.State.create Random.State.default) in - let%bind parties = + let%bind zkapp_command = Transaction_snark.For_tests.create_trivial_predicate_snapp ~constraint_constants ~protocol_state_predicate spec ledger ~snapp_kp:zkapp_kp in printf "ZkApp transaction yojson: %s\n\n%!" - (Parties.to_yojson parties |> Yojson.Safe.to_string) ; + (Zkapp_command.to_yojson zkapp_command |> Yojson.Safe.to_string) ; printf "(ZkApp transaction graphQL input %s\n\n%!" - (graphql_zkapp_command parties) ; + (graphql_zkapp_command zkapp_command) ; printf "Updated accounts\n" ; List.iter (Ledger.to_list ledger) ~f:(fun acc -> printf "Account: %s\n%!" @@ -175,11 +175,11 @@ let generate_zkapp_txn (keypair : Signature_lib.Keypair.t) (ledger : Ledger.t) } in let witnesses, _final_ledger = - Transaction_snark.parties_witnesses_exn ~constraint_constants ~state_body - ~fee_excess:Currency.Amount.Signed.zero (`Ledger ledger) + Transaction_snark.zkapp_command_witnesses_exn ~constraint_constants + ~state_body ~fee_excess:Currency.Amount.Signed.zero (`Ledger ledger) [ ( `Pending_coinbase_init_stack pending_coinbase_init_stack , `Pending_coinbase_of_statement pending_coinbase_state_stack - , parties ) + , zkapp_command ) ] in let open Async.Deferred.Let_syntax in @@ -194,11 +194,11 @@ let generate_zkapp_txn (keypair : Signature_lib.Keypair.t) (ledger : Ledger.t) printf "%s" (sprintf !"current witness \ - %{sexp:(Transaction_witness.Parties_segment_witness.t * \ - Transaction_snark.Parties_segment.Basic.t * \ + %{sexp:(Transaction_witness.Zkapp_command_segment_witness.t * \ + Transaction_snark.Zkapp_command_segment.Basic.t * \ Transaction_snark.Statement.With_sok.t) }%!" w ) ; - let%map _ = T.of_parties_segment_exn ~statement ~witness ~spec in + let%map _ = T.of_zkapp_command_segment_exn ~statement ~witness ~spec in ((), ()) ) in () @@ -234,12 +234,12 @@ module Util = struct let snapp_keypair_of_file = keypair_of_file ~which:"Zkapp Account" - let print_snapp_transaction parties = - printf !"Parties sexp:\n %{sexp: Parties.t}\n\n%!" parties ; + let print_snapp_transaction zkapp_command = + printf !"Zkapp_command sexp:\n %{sexp: Zkapp_command.t}\n\n%!" zkapp_command ; printf "Zkapp transaction yojson:\n %s\n\n%!" - (Parties.to_yojson parties |> Yojson.Safe.to_string) ; + (Zkapp_command.to_yojson zkapp_command |> Yojson.Safe.to_string) ; printf "Zkapp transaction graphQL input %s\n\n%!" - (graphql_zkapp_command parties) + (graphql_zkapp_command zkapp_command) let memo = Option.value_map ~default:Signed_command_memo.empty ~f:(fun m -> @@ -312,7 +312,7 @@ let create_zkapp_account ~debug ~keyfile ~fee ~zkapp_keyfile ~amount ~nonce ; zkapp_account_keypairs = [ zkapp_keypair ] ; memo = Util.memo memo ; new_zkapp_account = true - ; snapp_update = Party.Update.dummy + ; snapp_update = Account_update.Update.dummy ; current_auth = Permissions.Auth_required.Signature ; call_data = Snark_params.Tick.Field.zero ; events = [] @@ -320,11 +320,11 @@ let create_zkapp_account ~debug ~keyfile ~fee ~zkapp_keyfile ~amount ~nonce ; preconditions = None } in - let parties = + let zkapp_command = Transaction_snark.For_tests.deploy_snapp ~constraint_constants spec in - let%map () = if debug then gen_proof parties else return () in - parties + let%map () = if debug then gen_proof zkapp_command else return () in + zkapp_command let upgrade_zkapp ~debug ~keyfile ~fee ~nonce ~memo ~zkapp_keyfile ~verification_key ~zkapp_uri ~auth = @@ -347,7 +347,8 @@ let upgrade_zkapp ~debug ~keyfile ~fee ~nonce ~memo ~zkapp_keyfile ; zkapp_account_keypairs = [ zkapp_account_keypair ] ; memo = Util.memo memo ; new_zkapp_account = false - ; snapp_update = { Party.Update.dummy with verification_key; zkapp_uri } + ; snapp_update = + { Account_update.Update.dummy with verification_key; zkapp_uri } ; current_auth = auth ; call_data = Snark_params.Tick.Field.zero ; events = [] @@ -355,20 +356,20 @@ let upgrade_zkapp ~debug ~keyfile ~fee ~nonce ~memo ~zkapp_keyfile ; preconditions = None } in - let%bind parties = + let%bind zkapp_command = Transaction_snark.For_tests.update_states ~zkapp_prover ~constraint_constants spec in let%map () = if debug then - gen_proof parties + gen_proof zkapp_command ~zkapp_account: (Some (Signature_lib.Public_key.compress zkapp_account_keypair.public_key) ) else return () in - parties + zkapp_command let transfer_funds ~debug ~keyfile ~fee ~nonce ~memo ~receivers = let open Deferred.Let_syntax in @@ -387,7 +388,7 @@ let transfer_funds ~debug ~keyfile ~fee ~nonce ~memo ~receivers = ; zkapp_account_keypairs = [] ; memo = Util.memo memo ; new_zkapp_account = false - ; snapp_update = Party.Update.dummy + ; snapp_update = Account_update.Update.dummy ; current_auth = Permissions.Auth_required.Proof ; call_data = Snark_params.Tick.Field.zero ; events = [] @@ -395,11 +396,11 @@ let transfer_funds ~debug ~keyfile ~fee ~nonce ~memo ~receivers = ; preconditions = None } in - let parties = Transaction_snark.For_tests.multiple_transfers spec in + let zkapp_command = Transaction_snark.For_tests.multiple_transfers spec in let%map () = - if debug then gen_proof parties ~zkapp_account:None else return () + if debug then gen_proof zkapp_command ~zkapp_account:None else return () in - parties + zkapp_command let update_state ~debug ~keyfile ~fee ~nonce ~memo ~zkapp_keyfile ~app_state = let open Deferred.Let_syntax in @@ -415,7 +416,7 @@ let update_state ~debug ~keyfile ~fee ~nonce ~memo ~zkapp_keyfile ~app_state = ; zkapp_account_keypairs = [ zkapp_keypair ] ; memo = Util.memo memo ; new_zkapp_account = false - ; snapp_update = { Party.Update.dummy with app_state } + ; snapp_update = { Account_update.Update.dummy with app_state } ; current_auth = Permissions.Auth_required.Proof ; call_data = Snark_params.Tick.Field.zero ; events = [] @@ -423,18 +424,18 @@ let update_state ~debug ~keyfile ~fee ~nonce ~memo ~zkapp_keyfile ~app_state = ; preconditions = None } in - let%bind parties = + let%bind zkapp_command = Transaction_snark.For_tests.update_states ~zkapp_prover ~constraint_constants spec in let%map () = if debug then - gen_proof parties + gen_proof zkapp_command ~zkapp_account: (Some (Signature_lib.Public_key.compress zkapp_keypair.public_key)) else return () in - parties + zkapp_command let update_zkapp_uri ~debug ~keyfile ~fee ~nonce ~memo ~snapp_keyfile ~zkapp_uri ~auth = @@ -451,7 +452,7 @@ let update_zkapp_uri ~debug ~keyfile ~fee ~nonce ~memo ~snapp_keyfile ~zkapp_uri ; zkapp_account_keypairs = [ zkapp_account_keypair ] ; memo = Util.memo memo ; new_zkapp_account = false - ; snapp_update = { Party.Update.dummy with zkapp_uri } + ; snapp_update = { Account_update.Update.dummy with zkapp_uri } ; current_auth = auth ; call_data = Snark_params.Tick.Field.zero ; events = [] @@ -459,20 +460,20 @@ let update_zkapp_uri ~debug ~keyfile ~fee ~nonce ~memo ~snapp_keyfile ~zkapp_uri ; preconditions = None } in - let%bind parties = + let%bind zkapp_command = Transaction_snark.For_tests.update_states ~zkapp_prover ~constraint_constants spec in let%map () = if debug then - gen_proof parties + gen_proof zkapp_command ~zkapp_account: (Some (Signature_lib.Public_key.compress zkapp_account_keypair.public_key) ) else return () in - parties + zkapp_command let update_sequence_state ~debug ~keyfile ~fee ~nonce ~memo ~zkapp_keyfile ~sequence_state = @@ -489,7 +490,7 @@ let update_sequence_state ~debug ~keyfile ~fee ~nonce ~memo ~zkapp_keyfile ; zkapp_account_keypairs = [ zkapp_keypair ] ; memo = Util.memo memo ; new_zkapp_account = false - ; snapp_update = Party.Update.dummy + ; snapp_update = Account_update.Update.dummy ; current_auth = Permissions.Auth_required.Proof ; call_data = Snark_params.Tick.Field.zero ; events = [] @@ -497,18 +498,18 @@ let update_sequence_state ~debug ~keyfile ~fee ~nonce ~memo ~zkapp_keyfile ; preconditions = None } in - let%bind parties = + let%bind zkapp_command = Transaction_snark.For_tests.update_states ~zkapp_prover ~constraint_constants spec in let%map () = if debug then - gen_proof parties + gen_proof zkapp_command ~zkapp_account: (Some (Signature_lib.Public_key.compress zkapp_keypair.public_key)) else return () in - parties + zkapp_command let update_token_symbol ~debug ~keyfile ~fee ~nonce ~memo ~snapp_keyfile ~token_symbol ~auth = @@ -525,7 +526,7 @@ let update_token_symbol ~debug ~keyfile ~fee ~nonce ~memo ~snapp_keyfile ; zkapp_account_keypairs = [ zkapp_account_keypair ] ; memo = Util.memo memo ; new_zkapp_account = false - ; snapp_update = { Party.Update.dummy with token_symbol } + ; snapp_update = { Account_update.Update.dummy with token_symbol } ; current_auth = auth ; call_data = Snark_params.Tick.Field.zero ; events = [] @@ -533,20 +534,20 @@ let update_token_symbol ~debug ~keyfile ~fee ~nonce ~memo ~snapp_keyfile ; preconditions = None } in - let%bind parties = + let%bind zkapp_command = Transaction_snark.For_tests.update_states ~zkapp_prover ~constraint_constants spec in let%map () = if debug then - gen_proof parties + gen_proof zkapp_command ~zkapp_account: (Some (Signature_lib.Public_key.compress zkapp_account_keypair.public_key) ) else return () in - parties + zkapp_command let update_permissions ~debug ~keyfile ~fee ~nonce ~memo ~zkapp_keyfile ~permissions ~current_auth = @@ -562,7 +563,7 @@ let update_permissions ~debug ~keyfile ~fee ~nonce ~memo ~zkapp_keyfile ; zkapp_account_keypairs = [ zkapp_keypair ] ; memo = Util.memo memo ; new_zkapp_account = false - ; snapp_update = { Party.Update.dummy with permissions } + ; snapp_update = { Account_update.Update.dummy with permissions } ; current_auth ; call_data = Snark_params.Tick.Field.zero ; events = [] @@ -570,19 +571,19 @@ let update_permissions ~debug ~keyfile ~fee ~nonce ~memo ~zkapp_keyfile ; preconditions = None } in - let%bind parties = + let%bind zkapp_command = Transaction_snark.For_tests.update_states ~zkapp_prover ~constraint_constants spec in - (*Util.print_snapp_transaction parties ;*) + (*Util.print_snapp_transaction zkapp_command ;*) let%map () = if debug then - gen_proof parties + gen_proof zkapp_command ~zkapp_account: (Some (Signature_lib.Public_key.compress zkapp_keypair.public_key)) else return () in - parties + zkapp_command let%test_module "ZkApps test transaction" = ( module struct @@ -669,30 +670,31 @@ let%test_module "ZkApps test transaction" = in go path expected got ; !success - let hit_server (parties : Parties.t) query = + let hit_server (zkapp_command : Zkapp_command.t) query = let typ = Mina_graphql.Types.Input.SendZkappInput.arg_typ.arg_typ in let query_top_level = Graphql_async.Schema.( io_field "sendZkapp" ~typ:(non_null string) ~args:Arg.[ arg "input" ~typ:(non_null typ) ] ~doc:"sample query" - ~resolve:(fun _ () (parties' : Parties.t) -> + ~resolve:(fun _ () (zkapp_command' : Zkapp_command.t) -> let ok_fee_payer = print_diff_yojson ~path:[ "fee_payer" ] - (Party.Fee_payer.to_yojson parties.fee_payer) - (Party.Fee_payer.to_yojson parties'.fee_payer) + (Account_update.Fee_payer.to_yojson zkapp_command.fee_payer) + (Account_update.Fee_payer.to_yojson zkapp_command'.fee_payer) in - let _, ok_other_parties = - Parties.Call_forest.Tree.fold_forest2_exn ~init:(0, true) - parties.other_parties parties.other_parties + let _, ok_account_updates = + Zkapp_command.Call_forest.Tree.fold_forest2_exn ~init:(0, true) + zkapp_command.account_updates zkapp_command.account_updates ~f:(fun (i, ok) expected got -> ( i + 1 , print_diff_yojson - ~path:[ string_of_int i; "other_parties" ] - (Party.to_yojson expected) (Party.to_yojson got) + ~path:[ string_of_int i; "account_updates" ] + (Account_update.to_yojson expected) + (Account_update.to_yojson got) && ok ) ) in - if ok_fee_payer && ok_other_parties then return (Ok "Passed") + if ok_fee_payer && ok_account_updates then return (Ok "Passed") else return (Error "invalid snapp transaction generated") )) in let schema = @@ -714,11 +716,11 @@ let%test_module "ZkApps test transaction" = let%test_unit "zkapps transaction graphql round trip" = Quickcheck.test ~trials:20 - (Mina_generators.User_command_generators.parties_with_ledger ()) + (Mina_generators.User_command_generators.zkapp_command_with_ledger ()) ~f:(fun (user_cmd, _, _, _) -> match user_cmd with - | Parties p -> - let p = Parties.Valid.forget p in + | Zkapp_command p -> + let p = Zkapp_command.Valid.forget p in let q = graphql_zkapp_command p in Async.Thread_safe.block_on_async_exn (fun () -> match%map hit_server p q with @@ -726,12 +728,12 @@ let%test_module "ZkApps test transaction" = () | Error e -> printf - "Invalid graphql query %s for parties transaction %s. \ - Error %s" + "Invalid graphql query %s for zkapp_command \ + transaction %s. Error %s" q - (Parties.to_yojson p |> Yojson.Safe.to_string) + (Zkapp_command.to_yojson p |> Yojson.Safe.to_string) e ; failwith "Invalid graphql query" ) | Signed_command _ -> - failwith "Expected a Parties command" ) + failwith "Expected a Zkapp_command command" ) end ) diff --git a/src/app/zkapp_test_transaction/zkapp_test_transaction.ml b/src/app/zkapp_test_transaction/zkapp_test_transaction.ml index 7f627e512d2..77894902f01 100644 --- a/src/app/zkapp_test_transaction/zkapp_test_transaction.ml +++ b/src/app/zkapp_test_transaction/zkapp_test_transaction.ml @@ -56,11 +56,11 @@ let create_zkapp_account = let create_command ~debug ~keyfile ~fee ~zkapp_keyfile ~amount ~nonce ~memo () = let open Deferred.Let_syntax in - let%map parties = + let%map zkapp_command = create_zkapp_account ~debug ~keyfile ~fee ~zkapp_keyfile ~amount ~nonce ~memo in - Util.print_snapp_transaction parties ; + Util.print_snapp_transaction zkapp_command ; () in Command.( @@ -85,11 +85,11 @@ let upgrade_zkapp = let create_command ~debug ~keyfile ~fee ~nonce ~memo ~zkapp_keyfile ~verification_key ~zkapp_uri ~auth () = let open Deferred.Let_syntax in - let%map parties = + let%map zkapp_command = upgrade_zkapp ~debug ~keyfile ~fee ~nonce ~memo ~zkapp_keyfile ~verification_key ~zkapp_uri ~auth in - Util.print_snapp_transaction parties ; + Util.print_snapp_transaction zkapp_command ; () in Command.( @@ -128,10 +128,10 @@ let upgrade_zkapp = let transfer_funds = let create_command ~debug ~keyfile ~fee ~nonce ~memo ~receivers () = let open Deferred.Let_syntax in - let%map parties = + let%map zkapp_command = transfer_funds ~debug ~keyfile ~fee ~nonce ~memo ~receivers in - Util.print_snapp_transaction parties ; + Util.print_snapp_transaction zkapp_command ; () in let read_key_and_amount count = @@ -194,10 +194,10 @@ let update_state = let create_command ~debug ~keyfile ~fee ~nonce ~memo ~zkapp_keyfile ~app_state () = let open Deferred.Let_syntax in - let%map parties = + let%map zkapp_command = update_state ~debug ~keyfile ~fee ~nonce ~memo ~zkapp_keyfile ~app_state in - Util.print_snapp_transaction parties ; + Util.print_snapp_transaction zkapp_command ; () in Command.( @@ -228,11 +228,11 @@ let update_zkapp_uri = let create_command ~debug ~keyfile ~fee ~nonce ~memo ~snapp_keyfile ~zkapp_uri ~auth () = let open Deferred.Let_syntax in - let%map parties = + let%map zkapp_command = update_zkapp_uri ~debug ~keyfile ~fee ~nonce ~memo ~snapp_keyfile ~zkapp_uri ~auth in - Util.print_snapp_transaction parties ; + Util.print_snapp_transaction zkapp_command ; () in Command.( @@ -268,11 +268,11 @@ let update_sequence_state = let create_command ~debug ~keyfile ~fee ~nonce ~memo ~zkapp_keyfile ~sequence_state () = let open Deferred.Let_syntax in - let%map parties = + let%map zkapp_command = update_sequence_state ~debug ~keyfile ~fee ~nonce ~memo ~zkapp_keyfile ~sequence_state in - Util.print_snapp_transaction parties ; + Util.print_snapp_transaction zkapp_command ; () in Command.( @@ -334,11 +334,11 @@ let update_token_symbol = let create_command ~debug ~keyfile ~fee ~nonce ~memo ~snapp_keyfile ~token_symbol ~auth () = let open Deferred.Let_syntax in - let%map parties = + let%map zkapp_command = update_token_symbol ~debug ~keyfile ~fee ~nonce ~memo ~snapp_keyfile ~token_symbol ~auth in - Util.print_snapp_transaction parties ; + Util.print_snapp_transaction zkapp_command ; () in Command.( @@ -374,11 +374,11 @@ let update_permissions = let create_command ~debug ~keyfile ~fee ~nonce ~memo ~zkapp_keyfile ~permissions ~current_auth () = let open Deferred.Let_syntax in - let%map parties = + let%map zkapp_command = update_permissions ~debug ~keyfile ~fee ~nonce ~memo ~zkapp_keyfile ~permissions ~current_auth in - Util.print_snapp_transaction parties ; + Util.print_snapp_transaction zkapp_command ; () in Command.( diff --git a/src/external/ocaml-sodium/lib_test/test_scalar_mult.ml b/src/external/ocaml-sodium/lib_test/test_scalar_mult.ml index 0614bc988f6..d8e149c5abd 100644 --- a/src/external/ocaml-sodium/lib_test/test_scalar_mult.ml +++ b/src/external/ocaml-sodium/lib_test/test_scalar_mult.ml @@ -35,64 +35,96 @@ open OUnit2 open Sodium -(* Test that the basic shared key exchange identity holds: that both parties end +(* Test that the basic shared key exchange identity holds: that both zkapp_command end up with the same shared key. This test starts with a fixed private key for - two parties: alice and bob. Runs ScalarBaseMult and ScalarMult to compute + two zkapp_command: alice and bob. Runs ScalarBaseMult and ScalarMult to compute public key and shared key for alice and bob. It asserts that alice and bob have the same shared key. *) let test_scalarmult ctxt = - assert (Scalar_mult.primitive = "curve25519"); + assert (Scalar_mult.primitive = "curve25519") ; - let sk = "\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"^ - "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"^ - "\x00\x00\x00\x00\x00\x00\x00\x00" in - let sk = Scalar_mult.Bytes.to_integer (Bytes.of_string sk) in - let sk' = "\x05\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"^ - "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"^ - "\x00\x00\x00\x00\x00\x00\x00\x00" in + let sk = + "\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" + ^ "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" + ^ "\x00\x00\x00\x00\x00\x00\x00\x00" + in + let sk = Scalar_mult.Bytes.to_integer (Bytes.of_string sk) in + let sk' = + "\x05\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" + ^ "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" + ^ "\x00\x00\x00\x00\x00\x00\x00\x00" + in let sk' = Scalar_mult.Bytes.to_integer (Bytes.of_string sk') in (* Get public key for alice and bob. *) - let pk = Scalar_mult.base sk in + let pk = Scalar_mult.base sk in let pk' = Scalar_mult.base sk' in (* Get the shared key for alice, by using alice's private key and bob's public key. *) - let ck = Scalar_mult.mult sk' pk in + let ck = Scalar_mult.mult sk' pk in (* Get the shared key for bob, by using bob's private key and alice's public key. *) let ck' = Scalar_mult.mult sk pk' in (* Computed shared key of alice and bob should be the same. *) - assert_equal ~printer:(fun g -> Printf.sprintf "%S" - (Bytes.to_string (Scalar_mult.Bytes.of_group_elt g))) ck ck'; + assert_equal + ~printer:(fun g -> + Printf.sprintf "%S" (Bytes.to_string (Scalar_mult.Bytes.of_group_elt g)) + ) + ck ck' ; () let test_permute ctxt = - assert_raises (Size_mismatch "Scalar_mult.to_integer") - (fun () -> Scalar_mult.Bytes.to_integer (Bytes.of_string "\x03")); - assert_raises (Size_mismatch "Scalar_mult.to_group_elt") - (fun () -> Scalar_mult.Bytes.to_group_elt (Bytes.of_string "\x03")) + assert_raises (Size_mismatch "Scalar_mult.to_integer") (fun () -> + Scalar_mult.Bytes.to_integer (Bytes.of_string "\x03") ) ; + assert_raises (Size_mismatch "Scalar_mult.to_group_elt") (fun () -> + Scalar_mult.Bytes.to_group_elt (Bytes.of_string "\x03") ) let test_equal ctxt = - let sk = Bytes.of_string (String.make (Scalar_mult.integer_size) 'A') in - let sk' = Bytes.of_string ("B" ^ (String.make (Scalar_mult.integer_size - 1) 'A')) in - let sk'' = Bytes.of_string ((String.make (Scalar_mult.integer_size - 1) 'A') ^ "B") in - assert_bool "=" (Scalar_mult.equal_integer (Scalar_mult.Bytes.to_integer sk) - (Scalar_mult.Bytes.to_integer sk)); - assert_bool "<>" (not (Scalar_mult.equal_integer (Scalar_mult.Bytes.to_integer sk) - (Scalar_mult.Bytes.to_integer sk'))); - assert_bool "<>" (not (Scalar_mult.equal_integer (Scalar_mult.Bytes.to_integer sk) - (Scalar_mult.Bytes.to_integer sk''))); - let pk = Bytes.of_string (String.make (Scalar_mult.group_elt_size) 'A') in - let pk' = Bytes.of_string ("B" ^ (String.make (Scalar_mult.group_elt_size - 1) 'A')) in - let pk'' = Bytes.of_string ((String.make (Scalar_mult.group_elt_size - 1) 'A') ^ "B") in - assert_bool "=" (Scalar_mult.equal_group_elt (Scalar_mult.Bytes.to_group_elt pk) - (Scalar_mult.Bytes.to_group_elt pk)); - assert_bool "<>" (not (Scalar_mult.equal_group_elt (Scalar_mult.Bytes.to_group_elt pk) - (Scalar_mult.Bytes.to_group_elt pk'))); - assert_bool "<>" (not (Scalar_mult.equal_group_elt (Scalar_mult.Bytes.to_group_elt pk) - (Scalar_mult.Bytes.to_group_elt pk''))) + let sk = Bytes.of_string (String.make Scalar_mult.integer_size 'A') in + let sk' = + Bytes.of_string ("B" ^ String.make (Scalar_mult.integer_size - 1) 'A') + in + let sk'' = + Bytes.of_string (String.make (Scalar_mult.integer_size - 1) 'A' ^ "B") + in + assert_bool "=" + (Scalar_mult.equal_integer + (Scalar_mult.Bytes.to_integer sk) + (Scalar_mult.Bytes.to_integer sk) ) ; + assert_bool "<>" + (not + (Scalar_mult.equal_integer + (Scalar_mult.Bytes.to_integer sk) + (Scalar_mult.Bytes.to_integer sk') ) ) ; + assert_bool "<>" + (not + (Scalar_mult.equal_integer + (Scalar_mult.Bytes.to_integer sk) + (Scalar_mult.Bytes.to_integer sk'') ) ) ; + let pk = Bytes.of_string (String.make Scalar_mult.group_elt_size 'A') in + let pk' = + Bytes.of_string ("B" ^ String.make (Scalar_mult.group_elt_size - 1) 'A') + in + let pk'' = + Bytes.of_string (String.make (Scalar_mult.group_elt_size - 1) 'A' ^ "B") + in + assert_bool "=" + (Scalar_mult.equal_group_elt + (Scalar_mult.Bytes.to_group_elt pk) + (Scalar_mult.Bytes.to_group_elt pk) ) ; + assert_bool "<>" + (not + (Scalar_mult.equal_group_elt + (Scalar_mult.Bytes.to_group_elt pk) + (Scalar_mult.Bytes.to_group_elt pk') ) ) ; + assert_bool "<>" + (not + (Scalar_mult.equal_group_elt + (Scalar_mult.Bytes.to_group_elt pk) + (Scalar_mult.Bytes.to_group_elt pk'') ) ) -let suite = "Scalarmult" >::: [ - "test_scalarmult" >:: test_scalarmult; - "test_permute" >:: test_permute; - "test_equal" >:: test_equal; - ] +let suite = + "Scalarmult" + >::: [ "test_scalarmult" >:: test_scalarmult + ; "test_permute" >:: test_permute + ; "test_equal" >:: test_equal + ] diff --git a/src/graphql-ppx-config.inc b/src/graphql-ppx-config.inc index c49362ea7fa..181231a5e8d 100644 --- a/src/graphql-ppx-config.inc +++ b/src/graphql-ppx-config.inc @@ -68,8 +68,8 @@ Graphql_lib.Scalars.SequenceEvent StateHashAsDecimal Graphql_lib.Scalars.StateHashAsDecimal -custom-field -PartiesBase58 -Graphql_lib.Scalars.PartiesBase58 +ZkappCommandBase58 +Graphql_lib.Scalars.ZkappCommandBase58 -custom-field TransactionStatusFailure Graphql_lib.Scalars.TransactionStatusFailure diff --git a/src/lib/cli_lib/commands.ml b/src/lib/cli_lib/commands.ml index 1bf616eea55..30629a1e681 100644 --- a/src/lib/cli_lib/commands.ml +++ b/src/lib/cli_lib/commands.ml @@ -148,7 +148,7 @@ module Vrf = struct "Generate a vrf evaluation witness. This may be used to calculate \ whether a given private key will win a given slot (by checking \ threshold_met = true in the JSON output), or to generate a witness \ - that a 3rd party can use to verify a vrf evaluation." + that a 3rd account_update can use to verify a vrf evaluation." (let open Command.Let_syntax in let%map_open privkey_path = Flag.privkey_write_path and global_slot = diff --git a/src/lib/consensus/intf.ml b/src/lib/consensus/intf.ml index 11bd2204938..b7c8d65fb9c 100644 --- a/src/lib/consensus/intf.ml +++ b/src/lib/consensus/intf.ml @@ -47,7 +47,7 @@ module type Blockchain_state = sig type t = ( Staged_ledger_hash.t , Frozen_ledger_hash.t - , Mina_transaction_logic.Parties_logic.Local_state.Value.t + , Mina_transaction_logic.Zkapp_command_logic.Local_state.Value.t , Block_time.t , Body_reference.t ) Poly.t @@ -57,7 +57,7 @@ module type Blockchain_state = sig type var = ( Staged_ledger_hash.var , Frozen_ledger_hash.var - , Mina_transaction_logic.Parties_logic.Local_state.Checked.t + , Mina_transaction_logic.Zkapp_command_logic.Local_state.Checked.t , Block_time.Checked.t , Body_reference.var ) Poly.t diff --git a/src/lib/generated_graphql_queries/gen/gen.ml b/src/lib/generated_graphql_queries/gen/gen.ml index edb622bb178..689a247a846 100644 --- a/src/lib/generated_graphql_queries/gen/gen.ml +++ b/src/lib/generated_graphql_queries/gen/gen.ml @@ -1,7 +1,7 @@ open Ppxlib open Core_kernel -module Parties_templates = struct +module Zkapp_command_templates = struct let pooled_zkapp_commands = Printf.sprintf {graphql| @@ -13,34 +13,34 @@ module Parties_templates = struct index failures } - parties %s + zkappCommand %s } }|graphql} let internal_send_zkapp = Printf.sprintf {| - mutation ($parties: SendTestZkappInput!) { - internalSendZkapp(parties: $parties) { + mutation ($zkapp_command: SendTestZkappInput!) { + internalSendZkapp(zkapp_command: $zkapp_command) { zkapp { id hash failureReason { index failures } - parties %s + zkappCommand %s } } } |} end -let party_query_expr template ~loc = +let account_update_query_expr template ~loc = let module E = Ppxlib.Ast_builder.Make (struct let loc = loc end) in let open E in - estring @@ template (Lazy.force Mina_base.Parties.inner_query) + estring @@ template (Lazy.force Mina_base.Zkapp_command.inner_query) let structure ~loc = let module E = Ppxlib.Ast_builder.Make (struct @@ -48,12 +48,12 @@ let structure ~loc = end) in let open E in let node_builder f = - let exp = party_query_expr f ~loc in + let exp = account_update_query_expr f ~loc in let str = [ E.pstr_eval exp [] ] in E.pmod_extension (E.Located.mk "graphql", PStr str) in - let m1_node = node_builder Parties_templates.pooled_zkapp_commands in - let m2_node = node_builder Parties_templates.internal_send_zkapp in + let m1_node = node_builder Zkapp_command_templates.pooled_zkapp_commands in + let m2_node = node_builder Zkapp_command_templates.internal_send_zkapp in let modname s = E.Located.mk (Some s) in E. [ module_binding ~name:(modname "Pooled_zkapp_commands") ~expr:m1_node diff --git a/src/lib/genesis_constants/genesis_constants.ml b/src/lib/genesis_constants/genesis_constants.ml index b1c07f68002..f8c9d09e57c 100644 --- a/src/lib/genesis_constants/genesis_constants.ml +++ b/src/lib/genesis_constants/genesis_constants.ml @@ -325,8 +325,8 @@ module T = struct ; txpool_max_size : int ; num_accounts : int option ; transaction_expiry_hr : int - ; max_proof_parties : int - ; max_parties : int + ; max_proof_zkapp_command : int + ; max_zkapp_command : int ; max_event_elements : int ; max_sequence_event_elements : int } @@ -381,8 +381,8 @@ let compiled : t = ; txpool_max_size = pool_max_size ; num_accounts = None ; transaction_expiry_hr = Mina_compile_config.transaction_expiry_hr - ; max_proof_parties = Mina_compile_config.max_proof_parties - ; max_parties = Mina_compile_config.max_parties + ; max_proof_zkapp_command = Mina_compile_config.max_proof_zkapp_command + ; max_zkapp_command = Mina_compile_config.max_zkapp_command ; max_event_elements = Mina_compile_config.max_event_elements ; max_sequence_event_elements = Mina_compile_config.max_sequence_event_elements diff --git a/src/lib/genesis_ledger_helper/lib/genesis_ledger_helper_lib.ml b/src/lib/genesis_ledger_helper/lib/genesis_ledger_helper_lib.ml index 6622024519b..79cc6ab8d90 100644 --- a/src/lib/genesis_ledger_helper/lib/genesis_ledger_helper_lib.ml +++ b/src/lib/genesis_ledger_helper/lib/genesis_ledger_helper_lib.ml @@ -576,12 +576,12 @@ let make_genesis_constants ~logger ~(default : Genesis_constants.t) ; transaction_expiry_hr = Option.value ~default:default.transaction_expiry_hr (config.daemon >>= fun cfg -> cfg.transaction_expiry_hr) - ; max_proof_parties = - Option.value ~default:default.max_proof_parties - (config.daemon >>= fun cfg -> cfg.max_proof_parties) - ; max_parties = - Option.value ~default:default.max_parties - (config.daemon >>= fun cfg -> cfg.max_parties) + ; max_proof_zkapp_command = + Option.value ~default:default.max_proof_zkapp_command + (config.daemon >>= fun cfg -> cfg.max_proof_zkapp_command) + ; max_zkapp_command = + Option.value ~default:default.max_zkapp_command + (config.daemon >>= fun cfg -> cfg.max_zkapp_command) ; max_event_elements = Option.value ~default:default.max_event_elements (config.daemon >>= fun cfg -> cfg.max_event_elements) @@ -616,9 +616,10 @@ let runtime_config_of_precomputed_values (precomputed_values : Genesis_proof.t) ; peer_list_url = None ; transaction_expiry_hr = Some precomputed_values.genesis_constants.transaction_expiry_hr - ; max_proof_parties = - Some precomputed_values.genesis_constants.max_proof_parties - ; max_parties = Some precomputed_values.genesis_constants.max_parties + ; max_proof_zkapp_command = + Some precomputed_values.genesis_constants.max_proof_zkapp_command + ; max_zkapp_command = + Some precomputed_values.genesis_constants.max_zkapp_command ; max_event_elements = Some precomputed_values.genesis_constants.max_event_elements ; max_sequence_event_elements = diff --git a/src/lib/hash_prefix_states/hash_prefix_states.ml b/src/lib/hash_prefix_states/hash_prefix_states.ml index 72fc4c0f9da..046b4c1005e 100644 --- a/src/lib/hash_prefix_states/hash_prefix_states.ml +++ b/src/lib/hash_prefix_states/hash_prefix_states.ml @@ -7,7 +7,7 @@ let salt_legacy (s : Hash_prefixes.t) = Random_oracle.Legacy.salt (s :> string) let receipt_chain_signed_command = salt_legacy receipt_chain_user_command -let receipt_chain_parties = salt receipt_chain_user_command +let receipt_chain_zkapp_command = salt receipt_chain_user_command let receipt_chain_zkapp = salt receipt_chain_zkapp @@ -102,17 +102,18 @@ let zkapp_precondition_account = salt zkapp_precondition_account let zkapp_precondition_protocol_state = salt zkapp_precondition_protocol_state -let party = salt party +let account_update = salt account_update -let party_account_precondition = salt party_account_precondition +let account_update_account_precondition = + salt account_update_account_precondition -let party_cons = salt party_cons +let account_update_cons = salt account_update_cons -let party_node = salt party_node +let account_update_node = salt account_update_node -let party_stack_frame = salt party_stack_frame +let account_update_stack_frame = salt account_update_stack_frame -let party_stack_frame_cons = salt party_stack_frame_cons +let account_update_stack_frame_cons = salt account_update_stack_frame_cons let zkapp_uri = salt zkapp_uri diff --git a/src/lib/hash_prefix_states/hash_prefix_states.mli b/src/lib/hash_prefix_states/hash_prefix_states.mli index 391b969c457..6d4d04c57f0 100644 --- a/src/lib/hash_prefix_states/hash_prefix_states.mli +++ b/src/lib/hash_prefix_states/hash_prefix_states.mli @@ -53,21 +53,21 @@ val zkapp_precondition_account : Field.t State.t val zkapp_precondition_protocol_state : Field.t State.t -val party_account_precondition : Field.t State.t +val account_update_account_precondition : Field.t State.t -val party : Field.t State.t +val account_update : Field.t State.t -val party_cons : Field.t State.t +val account_update_cons : Field.t State.t -val party_node : Field.t State.t +val account_update_node : Field.t State.t -val party_stack_frame : Field.t State.t +val account_update_stack_frame : Field.t State.t -val party_stack_frame_cons : Field.t State.t +val account_update_stack_frame_cons : Field.t State.t val receipt_chain_signed_command : Field.t Legacy.State.t -val receipt_chain_parties : Field.t State.t +val receipt_chain_zkapp_command : Field.t State.t val receipt_chain_zkapp : Field.t State.t diff --git a/src/lib/hash_prefixes/hash_prefixes.ml b/src/lib/hash_prefixes/hash_prefixes.ml index f3ac48062d6..353719923c7 100644 --- a/src/lib/hash_prefixes/hash_prefixes.ml +++ b/src/lib/hash_prefixes/hash_prefixes.ml @@ -20,43 +20,43 @@ end include T -let protocol_state = create "CodaProtoState" +let protocol_state = create "MinaProtoState" -let protocol_state_body = create "CodaProtoStateBody" +let protocol_state_body = create "MinaProtoStateBody" -let account = create "CodaAccount" +let account = create "MinaAccount" -let side_loaded_vk = create "CodaSideLoadedVk" +let side_loaded_vk = create "MinaSideLoadedVk" -let zkapp_account = create "CodaZkappAccount" +let zkapp_account = create "MinaZkappAccount" -let zkapp_payload = create "CodaZkappPayload" +let zkapp_payload = create "MinaZkappPayload" -let zkapp_body = create "CodaZkappBody" +let zkapp_body = create "MinaZkappBody" -let merkle_tree i = create (Printf.sprintf "CodaMklTree%03d" i) +let merkle_tree i = create (Printf.sprintf "MinaMklTree%03d" i) -let coinbase_merkle_tree i = create (Printf.sprintf "CodaCbMklTree%03d" i) +let coinbase_merkle_tree i = create (Printf.sprintf "MinaCbMklTree%03d" i) -let merge_snark = create "CodaMergeSnark" +let merge_snark = create "MinaMergeSnark" -let base_snark = create "CodaBaseSnark" +let base_snark = create "MinaBaseSnark" -let transition_system_snark = create "CodaTransitionSnark" +let transition_system_snark = create "MinaTransitionSnark" -let signature_testnet = create "CodaSignature" +let signature_testnet = create "MinaSignature" let signature_mainnet = create "MinaSignatureMainnet" -let receipt_chain_user_command = create "CodaReceiptUC" +let receipt_chain_user_command = create "MinaReceiptUC" -let receipt_chain_zkapp = create "CodaReceiptZkapp" +let receipt_chain_zkapp = create "MinaReceiptZkapp" -let epoch_seed = create "CodaEpochSeed" +let epoch_seed = create "MinaEpochSeed" -let vrf_message = create "CodaVrfMessage" +let vrf_message = create "MinaVrfMessage" -let vrf_output = create "CodaVrfOutput" +let vrf_output = create "MinaVrfOutput" let vrf_evaluation = create "MinaVrfEvaluation" @@ -71,29 +71,29 @@ let coinbase_stack = create "CoinbaseStack" let coinbase = create "Coinbase" -let checkpoint_list = create "CodaCheckpoints" +let checkpoint_list = create "MinaCheckpoints" -let bowe_gabizon_hash = create "CodaTockBGHash" +let bowe_gabizon_hash = create "MinaTockBGHash" -let zkapp_precondition = create "CodaZkappPred" +let zkapp_precondition = create "MinaZkappPred" (*for Zkapp_precondition.Account.t*) -let zkapp_precondition_account = create "CodaZkappPredAcct" +let zkapp_precondition_account = create "MinaZkappPredAcct" -let zkapp_precondition_protocol_state = create "CodaZkappPredPS" +let zkapp_precondition_protocol_state = create "MinaZkappPredPS" -(*for Party.Account_precondition.t*) -let party_account_precondition = create "MinaPartyAccountPred" +(*for Account_update.Account_precondition.t*) +let account_update_account_precondition = create "MinaAcctUpdAcctPred" -let party = create "MinaParty" +let account_update = create "MinaAcctUpdate" -let party_cons = create "MinaPartyCons" +let account_update_cons = create "MinaAcctUpdateCons" -let party_node = create "MinaPartyNode" +let account_update_node = create "MinaAcctUpdateNode" -let party_stack_frame = create "MinaPartyStckFrm" +let account_update_stack_frame = create "MinaAcctUpdStckFrm" -let party_stack_frame_cons = create "MinaPartyStckFrmCons" +let account_update_stack_frame_cons = create "MinaActUpStckFrmCons" let zkapp_uri = create "MinaZkappUri" diff --git a/src/lib/integration_test_cloud_engine/kubernetes_network.ml b/src/lib/integration_test_cloud_engine/kubernetes_network.ml index 4773d9ecec8..932004c08b3 100644 --- a/src/lib/integration_test_cloud_engine/kubernetes_network.ml +++ b/src/lib/integration_test_cloud_engine/kubernetes_network.ml @@ -498,7 +498,7 @@ module Node = struct | None -> fail (Error.of_string "Could not get account from ledger") - (* return a Party.Update.t with all fields `Set` to the + (* return a Account_update.Update.t with all fields `Set` to the value in the account, or `Keep` if value unavailable, as if this update had been applied to the account *) @@ -614,7 +614,7 @@ module Node = struct ; vesting_period ; vesting_increment } - : Mina_base.Party.Update.Timing_info.t ) ) + : Mina_base.Account_update.Update.Timing_info.t ) ) | _ -> fail (Error.of_string "Some pieces of account timing are missing") in @@ -635,7 +635,7 @@ module Node = struct ; timing ; voting_for } - : Mina_base.Party.Update.t ) + : Mina_base.Account_update.Update.t ) | None -> fail (Error.of_string "Could not get account from ledger") @@ -696,19 +696,20 @@ module Node = struct send_payment ~logger t ~sender_pub_key ~receiver_pub_key ~amount ~fee |> Deferred.bind ~f:Malleable_error.or_hard_error - let send_zkapp ~logger (t : t) ~(parties : Mina_base.Parties.t) = + let send_zkapp ~logger (t : t) ~(zkapp_command : Mina_base.Zkapp_command.t) = [%log info] "Sending a zkapp" ~metadata: [ ("namespace", `String t.config.namespace) ; ("pod_id", `String (id t)) ] ; let open Deferred.Or_error.Let_syntax in - let parties_json = - Mina_base.Parties.to_json parties |> Yojson.Safe.to_basic + let zkapp_command_json = + Mina_base.Zkapp_command.to_json zkapp_command |> Yojson.Safe.to_basic in let send_zkapp_graphql () = let send_zkapp_obj = - Graphql.Send_test_zkapp.(make @@ makeVariables ~parties:parties_json ()) + Graphql.Send_test_zkapp.( + make @@ makeVariables ~zkapp_command:zkapp_command_json ()) in exec_graphql_request ~logger ~node:t ~query_name:"send_zkapp_graphql" send_zkapp_obj diff --git a/src/lib/integration_test_cloud_engine/mina_automation.ml b/src/lib/integration_test_cloud_engine/mina_automation.ml index f9e4cb9e5b4..b51059a8508 100644 --- a/src/lib/integration_test_cloud_engine/mina_automation.ml +++ b/src/lib/integration_test_cloud_engine/mina_automation.ml @@ -219,8 +219,8 @@ module Network_config = struct { txpool_max_size = Some txpool_max_size ; peer_list_url = None ; transaction_expiry_hr = None - ; max_proof_parties = None - ; max_parties = None + ; max_proof_zkapp_command = None + ; max_zkapp_command = None ; max_event_elements = None ; max_sequence_event_elements = None } diff --git a/src/lib/integration_test_lib/intf.ml b/src/lib/integration_test_lib/intf.ml index 28128cce4e3..dfd12e44cc4 100644 --- a/src/lib/integration_test_lib/intf.ml +++ b/src/lib/integration_test_lib/intf.ml @@ -121,7 +121,7 @@ module Engine = struct val send_zkapp : logger:Logger.t -> t - -> parties:Mina_base.Parties.t + -> zkapp_command:Mina_base.Zkapp_command.t -> string Deferred.Or_error.t val must_send_test_payments : @@ -167,7 +167,7 @@ module Engine = struct logger:Logger.t -> t -> account_id:Mina_base.Account_id.t - -> Mina_base.Party.Update.t Deferred.Or_error.t + -> Mina_base.Account_update.Update.t Deferred.Or_error.t val get_peer_id : logger:Logger.t -> t -> (string * string list) Deferred.Or_error.t @@ -382,7 +382,7 @@ module Dsl = struct val ledger_proofs_emitted_since_genesis : num_proofs:int -> t val zkapp_to_be_included_in_frontier : - has_failures:bool -> parties:Mina_base.Parties.t -> t + has_failures:bool -> zkapp_command:Mina_base.Zkapp_command.t -> t end module type Util_intf = sig diff --git a/src/lib/integration_test_lib/wait_condition.ml b/src/lib/integration_test_lib/wait_condition.ml index 424f68cd18f..dce6a4eaa05 100644 --- a/src/lib/integration_test_lib/wait_condition.ml +++ b/src/lib/integration_test_lib/wait_condition.ml @@ -209,12 +209,12 @@ struct ; hard_timeout = Slots 20 } - let zkapp_to_be_included_in_frontier ~has_failures ~parties = - let command_matches_parties cmd = + let zkapp_to_be_included_in_frontier ~has_failures ~zkapp_command = + let command_matches_zkapp_command cmd = let open User_command in match cmd with - | Parties p -> - Parties.equal p parties + | Zkapp_command p -> + Zkapp_command.equal p zkapp_command | Signed_command _ -> false in @@ -222,7 +222,7 @@ struct let zkapp_opt = List.find breadcrumb_added.user_commands ~f:(fun cmd_with_status -> cmd_with_status.With_status.data |> User_command.forget_check - |> command_matches_parties ) + |> command_matches_zkapp_command ) in match zkapp_opt with | Some cmd_with_status -> @@ -247,20 +247,20 @@ struct let is_first = ref true in { id = Zkapp_to_be_included_in_frontier ; description = - sprintf "zkApp with fee payer %s and other parties (%s), memo: %s" + sprintf "zkApp with fee payer %s and other zkapp_command (%s), memo: %s" (Signature_lib.Public_key.Compressed.to_base58_check - parties.fee_payer.body.public_key ) - (Parties.Call_forest.Tree.fold_forest ~init:"" parties.other_parties - ~f:(fun acc party -> + zkapp_command.fee_payer.body.public_key ) + (Zkapp_command.Call_forest.Tree.fold_forest ~init:"" + zkapp_command.account_updates ~f:(fun acc account_update -> let str = Signature_lib.Public_key.Compressed.to_base58_check - party.body.public_key + account_update.body.public_key in if !is_first then ( is_first := false ; str ) else acc ^ ", " ^ str ) ) - (Signed_command_memo.to_string_hum parties.memo) + (Signed_command_memo.to_string_hum zkapp_command.memo) ; predicate = Event_predicate (Event_type.Breadcrumb_added, (), check) ; soft_timeout = Slots soft_timeout_in_slots ; hard_timeout = Slots (soft_timeout_in_slots * 2) diff --git a/src/lib/mina_base/party.ml b/src/lib/mina_base/account_update.ml similarity index 96% rename from src/lib/mina_base/party.ml rename to src/lib/mina_base/account_update.ml index fc07d0ce586..c505a6c9328 100644 --- a/src/lib/mina_base/party.ml +++ b/src/lib/mina_base/account_update.ml @@ -61,7 +61,8 @@ module Update = struct [%%versioned module Stable = struct module V1 = struct - type t = Mina_wire_types.Mina_base.Party.Update.Timing_info.V1.t = + type t = + Mina_wire_types.Mina_base.Account_update.Update.Timing_info.V1.t = { initial_minimum_balance : Balance.Stable.V1.t ; cliff_time : Global_slot.Stable.V1.t ; cliff_amount : Amount.Stable.V1.t @@ -216,7 +217,7 @@ module Update = struct module Stable = struct module V1 = struct (* TODO: Have to check that the public key is not = Public_key.Compressed.empty here. *) - type t = Mina_wire_types.Mina_base.Party.Update.V1.t = + type t = Mina_wire_types.Mina_base.Account_update.Update.V1.t = { app_state : F.Stable.V1.t Set_or_keep.Stable.V1.t Zkapp_state.V.Stable.V1.t ; delegate : Public_key.Compressed.Stable.V1.t Set_or_keep.Stable.V1.t @@ -287,7 +288,7 @@ module Update = struct Set_or_keep.gen token_gen in let%bind voting_for = Set_or_keep.gen Field.gen in - (* a new account for the Party.t is in the ledger when we use + (* a new account for the Account_update.t is in the ledger when we use this generated update in tests, so the timing must be Keep *) let timing = Set_or_keep.Keep in @@ -457,7 +458,7 @@ module Update = struct ~checked:(js_only (Js_layout.leaf_type (Custom "TokenSymbol"))) ~name:"TokenSymbol" string in - finish "PartyUpdate" ~t_toplevel_annots + finish "AccountUpdateUpdate" ~t_toplevel_annots @@ Fields.make_creator ~app_state:!.(Zkapp_state.deriver @@ Set_or_keep.deriver field) ~delegate:!.(Set_or_keep.deriver public_key) @@ -507,7 +508,8 @@ module Account_precondition = struct [%%versioned module Stable = struct module V1 = struct - type t = Mina_wire_types.Mina_base.Party.Account_precondition.V1.t = + type t = + Mina_wire_types.Mina_base.Account_update.Account_precondition.V1.t = | Full of Zkapp_precondition.Account.Stable.V2.t | Nonce of Account.Nonce.Stable.V1.t | Accept @@ -615,7 +617,8 @@ module Account_precondition = struct let digest (t : t) = let digest x = Random_oracle.( - hash ~init:Hash_prefix_states.party_account_precondition (pack_input x)) + hash ~init:Hash_prefix_states.account_update_account_precondition + (pack_input x)) in to_full t |> Zkapp_precondition.Account.to_input |> digest @@ -625,7 +628,7 @@ module Account_precondition = struct let digest (t : t) = let digest x = Random_oracle.Checked.( - hash ~init:Hash_prefix_states.party_account_precondition + hash ~init:Hash_prefix_states.account_update_account_precondition (pack_input x)) in Zkapp_precondition.Account.Checked.to_input t |> digest @@ -650,7 +653,7 @@ module Preconditions = struct [%%versioned module Stable = struct module V1 = struct - type t = Mina_wire_types.Mina_base.Party.Preconditions.V1.t = + type t = Mina_wire_types.Mina_base.Account_update.Preconditions.V1.t = { network : Zkapp_precondition.Protocol_state.Stable.V1.t ; account : Account_precondition.Stable.V1.t } @@ -819,7 +822,7 @@ module Body = struct ~sequence_events:!.Sequence_events.deriver ~call_data:!.field ~preconditions:!.Preconditions.deriver ~use_full_commitment:!.bool ~caller:!.Token_id.deriver ~call_depth:!.int - |> finish "PartyBody" ~t_toplevel_annots + |> finish "AccountUpdateBody" ~t_toplevel_annots let dummy : t = { public_key = Public_key.Compressed.empty @@ -866,7 +869,7 @@ module Body = struct [%%versioned module Stable = struct module V1 = struct - type t = Mina_wire_types.Mina_base.Party.Body.V1.t = + type t = Mina_wire_types.Mina_base.Account_update.Body.V1.t = { public_key : Public_key.Compressed.Stable.V1.t ; token_id : Token_id.Stable.V1.t ; update : Update.Stable.V1.t @@ -960,7 +963,7 @@ module Body = struct [%%versioned module Stable = struct module V1 = struct - type t = Mina_wire_types.Mina_base.Party.Body.Fee_payer.V1.t = + type t = Mina_wire_types.Mina_base.Account_update.Body.Fee_payer.V1.t = { public_key : Public_key.Compressed.Stable.V1.t ; fee : Fee.Stable.V1.t ; valid_until : Global_slot.Stable.V1.t option [@name "validUntil"] @@ -999,7 +1002,7 @@ module Body = struct !.Fields_derivers_zkapps.Derivers.( option ~js_type:`Or_undefined @@ uint32 @@ o ()) ~nonce:!.uint32 - |> finish "FeePayerPartyBody" ~t_toplevel_annots + |> finish "FeePayerAccountUpdateBody" ~t_toplevel_annots let%test_unit "json roundtrip" = let open Fields_derivers_zkapps.Derivers in @@ -1239,7 +1242,7 @@ module T = struct [%%versioned module Stable = struct module V1 = struct - (** A party to a zkApp transaction *) + (** A account_update to a zkApp transaction *) type t = { body : Body.Graphql_repr.Stable.V1.t ; authorization : Control.Stable.V2.t @@ -1256,7 +1259,7 @@ module T = struct Fields.make_creator obj ~body:!.Body.Graphql_repr.deriver ~authorization:!.Control.deriver - |> finish "ZkappParty" ~t_toplevel_annots + |> finish "ZkappAccountUpdate" ~t_toplevel_annots end module Simple = struct @@ -1304,8 +1307,8 @@ module T = struct [%%versioned module Stable = struct module V1 = struct - (** A party to a zkApp transaction *) - type t = Mina_wire_types.Mina_base.Party.V1.t = + (** A account_update to a zkApp transaction *) + type t = Mina_wire_types.Mina_base.Account_update.V1.t = { body : Body.Stable.V1.t; authorization : Control.Stable.V2.t } [@@deriving annot, sexp, equal, yojson, hash, compare, fields] @@ -1352,7 +1355,7 @@ module Fee_payer = struct [%%versioned module Stable = struct module V1 = struct - type t = Mina_wire_types.Mina_base.Party.Fee_payer.V1.t = + type t = Mina_wire_types.Mina_base.Account_update.Fee_payer.V1.t = { body : Body.Fee_payer.Stable.V1.t ; authorization : Signature.Stable.V1.t } @@ -1379,7 +1382,7 @@ module Fee_payer = struct let account_id (t : t) : Account_id.t = Account_id.create t.body.public_key Token_id.default - let to_party (t : t) : T.t = + let to_account_update (t : t) : T.t = { authorization = Control.Signature t.authorization ; body = Body.of_fee_payer t.body } @@ -1389,7 +1392,7 @@ module Fee_payer = struct let ( !. ) = ( !. ) ~t_fields_annots in Fields.make_creator obj ~body:!.Body.Fee_payer.deriver ~authorization:!.Control.signature_deriver - |> finish "ZkappPartyFeePayer" ~t_toplevel_annots + |> finish "ZkappAccountUpdateFeePayer" ~t_toplevel_annots let%test_unit "json roundtrip" = let dummy : t = @@ -1409,11 +1412,11 @@ let account_id (t : t) : Account_id.t = let of_fee_payer ({ body; authorization } : Fee_payer.t) : t = { authorization = Signature authorization; body = Body.of_fee_payer body } -(** The change in balance to apply to the target account of this party. +(** The change in balance to apply to the target account of this account_update. When this is negative, the amount will be withdrawn from the account and - made available to later parties in the same transaction. + made available to later zkapp_command in the same transaction. When this is positive, the amount will be deposited into the account from - the funds made available by previous parties in the same transaction. + the funds made available by previous zkapp_command in the same transaction. *) let balance_change (t : t) : Amount.Signed.t = t.body.balance_change diff --git a/src/lib/mina_base/call_stack_digest.ml b/src/lib/mina_base/call_stack_digest.ml index bf77b07b644..4c6a370a1bc 100644 --- a/src/lib/mina_base/call_stack_digest.ml +++ b/src/lib/mina_base/call_stack_digest.ml @@ -13,7 +13,7 @@ end] open Pickles.Impls.Step let cons (h : Stack_frame.Digest.t) (t : t) : t = - Random_oracle.hash ~init:Hash_prefix_states.party_stack_frame_cons + Random_oracle.hash ~init:Hash_prefix_states.account_update_stack_frame_cons [| (h :> Field.Constant.t); t |] let empty = Field.Constant.zero @@ -24,7 +24,8 @@ module Checked = struct include Field let cons (h : Stack_frame.Digest.Checked.t) (t : t) : t = - Random_oracle.Checked.hash ~init:Hash_prefix_states.party_stack_frame_cons + Random_oracle.Checked.hash + ~init:Hash_prefix_states.account_update_stack_frame_cons [| (h :> Field.t); t |] end diff --git a/src/lib/mina_base/mina_base.ml b/src/lib/mina_base/mina_base.ml index 311126b7307..970343245ae 100644 --- a/src/lib/mina_base/mina_base.ml +++ b/src/lib/mina_base/mina_base.ml @@ -25,8 +25,7 @@ module Ledger_hash0 = Ledger_hash0 module Ledger_hash_intf = Ledger_hash_intf module Ledger_hash_intf0 = Ledger_hash_intf0 module Ledger_intf = Ledger_intf -module Parties = Parties -module Party = Party +module Account_update = Account_update module Payment_payload = Payment_payload module Pending_coinbase = Pending_coinbase module Pending_coinbase_intf = Pending_coinbase_intf @@ -46,6 +45,7 @@ module Signed_command_payload = Signed_command_payload module Zkapp_account = Zkapp_account module Zkapp_basic = Zkapp_basic module Zkapp_call_forest = Zkapp_call_forest +module Zkapp_command = Zkapp_command module Zkapp_precondition = Zkapp_precondition module Zkapp_state = Zkapp_state module Zkapp_statement = Zkapp_statement diff --git a/src/lib/mina_base/receipt.ml b/src/lib/mina_base/receipt.ml index 8668cd96280..83ce2c79589 100644 --- a/src/lib/mina_base/receipt.ml +++ b/src/lib/mina_base/receipt.ml @@ -10,8 +10,8 @@ module Signed_command_elt = struct type t = Signed_command_payload of Signed_command.Payload.t end -module Parties_elt = struct - type t = Parties_commitment of Random_oracle.Digest.t +module Zkapp_command_elt = struct + type t = Zkapp_command_commitment of Random_oracle.Digest.t end module Chain_hash = struct @@ -62,15 +62,17 @@ module Chain_hash = struct |> hash ~init:Hash_prefix.receipt_chain_signed_command |> of_hash - (* prepend party index computed by Parties_logic.apply *) - let cons_parties_commitment (index : Mina_numbers.Index.t) (e : Parties_elt.t) - (t : t) = + (* prepend account_update index computed by Zkapp_command_logic.apply *) + let cons_zkapp_command_commitment (index : Mina_numbers.Index.t) + (e : Zkapp_command_elt.t) (t : t) = let open Random_oracle in - let x = match e with Parties_commitment s -> Input.Chunked.field s in + let x = + match e with Zkapp_command_commitment s -> Input.Chunked.field s + in let index_input = Mina_numbers.Index.to_input index in Input.Chunked.(append index_input (append x (field (t :> Field.t)))) |> pack_input - |> hash ~init:Hash_prefix.receipt_chain_parties + |> hash ~init:Hash_prefix.receipt_chain_zkapp_command |> of_hash [%%if defined consensus_mechanism] @@ -80,8 +82,8 @@ module Chain_hash = struct type t = Signed_command_payload of Transaction_union_payload.var end - module Parties_elt = struct - type t = Parties_commitment of Random_oracle.Checked.Digest.t + module Zkapp_command_elt = struct + type t = Zkapp_command_commitment of Random_oracle.Checked.Digest.t end let constant (t : t) = @@ -108,18 +110,18 @@ module Chain_hash = struct (Checked.pack_input Input.(append x (field (var_to_hash_packed t)))) |> var_of_hash_packed ) - (* prepend party index *) - let cons_parties_commitment (index : Mina_numbers.Index.Checked.t) - (e : Parties_elt.t) (t : t) = + (* prepend account_update index *) + let cons_zkapp_command_commitment (index : Mina_numbers.Index.Checked.t) + (e : Zkapp_command_elt.t) (t : t) = let open Random_oracle in let%bind x = match e with - | Parties_commitment s -> + | Zkapp_command_commitment s -> Let_syntax.return (Input.Chunked.field s) in let index_input = Mina_numbers.Index.Checked.to_input index in make_checked (fun () -> - Checked.hash ~init:Hash_prefix.receipt_chain_parties + Checked.hash ~init:Hash_prefix.receipt_chain_zkapp_command (Checked.pack_input Input.Chunked.( append index_input (append x (field (var_to_hash_packed t)))) ) @@ -150,14 +152,15 @@ module Chain_hash = struct in assert (equal unchecked checked) ) - let%test_unit "checked-unchecked equivalence (parties)" = + let%test_unit "checked-unchecked equivalence (zkapp_command)" = let open Quickcheck in test ~trials:20 (Generator.tuple2 gen Field.gen) ~f:(fun (base, commitment) -> let index_int = 17 in let unchecked = let index = Mina_numbers.Index.of_int index_int in - cons_parties_commitment index (Parties_commitment commitment) base + cons_zkapp_command_commitment index + (Zkapp_command_commitment commitment) base in let checked = let open Snark_params.Tick.Checked.Let_syntax in @@ -174,8 +177,8 @@ module Chain_hash = struct in let commitment = Field.Var.constant commitment in let%map res = - Checked.cons_parties_commitment index - (Parties_commitment commitment) (var_of_t base) + Checked.cons_zkapp_command_commitment index + (Zkapp_command_commitment commitment) (var_of_t base) in As_prover.read typ res in diff --git a/src/lib/mina_base/receipt.mli b/src/lib/mina_base/receipt.mli index d6ead65d33f..60366a34d51 100644 --- a/src/lib/mina_base/receipt.mli +++ b/src/lib/mina_base/receipt.mli @@ -9,8 +9,8 @@ module Signed_command_elt : sig type t = Signed_command_payload of Signed_command.Payload.t end -module Parties_elt : sig - type t = Parties_commitment of Random_oracle.Digest.t +module Zkapp_command_elt : sig + type t = Zkapp_command_commitment of Random_oracle.Digest.t end module Chain_hash : sig @@ -28,7 +28,8 @@ module Chain_hash : sig val cons_signed_command_payload : Signed_command_elt.t -> t -> t - val cons_parties_commitment : Mina_numbers.Index.t -> Parties_elt.t -> t -> t + val cons_zkapp_command_commitment : + Mina_numbers.Index.t -> Zkapp_command_elt.t -> t -> t [%%ifdef consensus_mechanism] @@ -39,8 +40,8 @@ module Chain_hash : sig type t = Signed_command_payload of Transaction_union_payload.var end - module Parties_elt : sig - type t = Parties_commitment of Random_oracle.Checked.Digest.t + module Zkapp_command_elt : sig + type t = Zkapp_command_commitment of Random_oracle.Checked.Digest.t end val constant : t -> var @@ -53,8 +54,8 @@ module Chain_hash : sig val cons_signed_command_payload : Signed_command_elt.t -> t -> t Checked.t - val cons_parties_commitment : - Mina_numbers.Index.Checked.t -> Parties_elt.t -> t -> t Checked.t + val cons_zkapp_command_commitment : + Mina_numbers.Index.Checked.t -> Zkapp_command_elt.t -> t -> t Checked.t end [%%endif] diff --git a/src/lib/mina_base/stack_frame.ml b/src/lib/mina_base/stack_frame.ml index 7b737012027..b47a0a237ee 100644 --- a/src/lib/mina_base/stack_frame.ml +++ b/src/lib/mina_base/stack_frame.ml @@ -3,21 +3,21 @@ open Core_kernel [%%versioned module Stable = struct module V1 = struct - type ('caller, 'parties) t = - { caller : 'caller; caller_caller : 'caller; calls : 'parties } + type ('caller, 'zkapp_command) t = + { caller : 'caller; caller_caller : 'caller; calls : 'zkapp_command } [@@deriving make, fields, sexp, yojson] end end] type value = ( Token_id.t - , ( Party.t - , Parties.Digest.Party.t - , Parties.Digest.Forest.t ) - Parties.Call_forest.t ) + , ( Account_update.t + , Zkapp_command.Digest.Account_update.t + , Zkapp_command.Digest.Forest.t ) + Zkapp_command.Call_forest.t ) t -type ('caller, 'parties) frame = ('caller, 'parties) t +type ('caller, 'zkapp_command) frame = ('caller, 'zkapp_command) t let empty : value = { caller = Token_id.default; caller_caller = Token_id.default; calls = [] } @@ -28,9 +28,9 @@ module Digest : sig val create : ( Token_id.t , ( 'p - , Parties.Digest.Party.t - , Parties.Digest.Forest.t ) - Parties.Call_forest.t ) + , Zkapp_command.Digest.Account_update.t + , Zkapp_command.Digest.Forest.t ) + Zkapp_command.Call_forest.t ) frame -> t @@ -42,8 +42,9 @@ module Digest : sig include Digest_intf.S_checked val create : - hash_parties:('parties -> Parties.Digest.Forest.Checked.t) - -> (Token_id.Checked.t, 'parties) frame + hash_zkapp_command: + ('zkapp_command -> Zkapp_command.Digest.Forest.Checked.t) + -> (Token_id.Checked.t, 'zkapp_command) frame -> t end @@ -67,43 +68,45 @@ end = struct ({ caller; caller_caller; calls } : ( Token_id.t , ( p - , Parties.Digest.Party.t - , Parties.Digest.Forest.t ) - Parties.Call_forest.t ) + , Zkapp_command.Digest.Account_update.t + , Zkapp_command.Digest.Forest.t ) + Zkapp_command.Call_forest.t ) frame ) = List.reduce_exn ~f:Random_oracle.Input.Chunked.append [ Token_id.to_input caller ; Token_id.to_input caller_caller ; Random_oracle.Input.Chunked.field - (Parties.Call_forest.hash calls :> Field.Constant.t) + (Zkapp_command.Call_forest.hash calls :> Field.Constant.t) ] let create frame = - Random_oracle.hash ~init:Hash_prefix_states.party_stack_frame + Random_oracle.hash ~init:Hash_prefix_states.account_update_stack_frame (Random_oracle.pack_input (to_input frame)) module Checked = struct include Field - let to_input (type parties) - ~(hash_parties : parties -> Parties.Digest.Forest.Checked.t) + let to_input (type zkapp_command) + ~(hash_zkapp_command : + zkapp_command -> Zkapp_command.Digest.Forest.Checked.t ) ({ caller; caller_caller; calls } : _ frame) = List.reduce_exn ~f:Random_oracle.Input.Chunked.append [ Token_id.Checked.to_input caller ; Token_id.Checked.to_input caller_caller - ; Random_oracle.Input.Chunked.field (hash_parties calls :> Field.t) + ; Random_oracle.Input.Chunked.field (hash_zkapp_command calls :> Field.t) ] - let create ~hash_parties frame = - Random_oracle.Checked.hash ~init:Hash_prefix_states.party_stack_frame - (Random_oracle.Checked.pack_input (to_input ~hash_parties frame)) + let create ~hash_zkapp_command frame = + Random_oracle.Checked.hash + ~init:Hash_prefix_states.account_update_stack_frame + (Random_oracle.Checked.pack_input (to_input ~hash_zkapp_command frame)) end let typ = Field.typ end module Checked = struct - type nonrec 'parties t = (Token_id.Checked.t, 'parties) t + type nonrec 'zkapp_command t = (Token_id.Checked.t, 'zkapp_command) t let if_ f b ~then_ ~else_ : _ t = { caller = Token_id.Checked.if_ b ~then_:then_.caller ~else_:else_.caller diff --git a/src/lib/mina_base/transaction_status.ml b/src/lib/mina_base/transaction_status.ml index 0c482880a02..24e8f19fc5a 100644 --- a/src/lib/mina_base/transaction_status.ml +++ b/src/lib/mina_base/transaction_status.ml @@ -32,7 +32,7 @@ module Failure = struct | Update_not_permitted_permissions | Update_not_permitted_nonce | Update_not_permitted_voting_for - | Parties_replay_check_failed + | Zkapp_command_replay_check_failed | Fee_payer_nonce_must_increase | Fee_payer_must_be_signed | Account_balance_precondition_unsatisfied @@ -111,8 +111,9 @@ module Failure = struct ~update_not_permitted_sequence_state:add ~update_not_permitted_zkapp_uri:add ~update_not_permitted_token_symbol:add ~update_not_permitted_permissions:add ~update_not_permitted_nonce:add - ~update_not_permitted_voting_for:add ~parties_replay_check_failed:add - ~fee_payer_nonce_must_increase:add ~fee_payer_must_be_signed:add + ~update_not_permitted_voting_for:add + ~zkapp_command_replay_check_failed:add ~fee_payer_nonce_must_increase:add + ~fee_payer_must_be_signed:add ~account_balance_precondition_unsatisfied:add ~account_nonce_precondition_unsatisfied:add ~account_receipt_chain_hash_precondition_unsatisfied:add @@ -178,8 +179,8 @@ module Failure = struct "Update_not_permitted_nonce" | Update_not_permitted_voting_for -> "Update_not_permitted_voting_for" - | Parties_replay_check_failed -> - "Parties_replay_check_failed" + | Zkapp_command_replay_check_failed -> + "Zkapp_command_replay_check_failed" | Fee_payer_nonce_must_increase -> "Fee_payer_nonce_must_increase" | Fee_payer_must_be_signed -> @@ -258,8 +259,8 @@ module Failure = struct Ok Update_not_permitted_nonce | "Update_not_permitted_voting_for" -> Ok Update_not_permitted_voting_for - | "Parties_replay_check_failed" -> - Ok Parties_replay_check_failed + | "Zkapp_command_replay_check_failed" -> + Ok Zkapp_command_replay_check_failed | "Fee_payer_nonce_must_increase" -> Ok Fee_payer_nonce_must_increase | "Fee_payer_must_be_signed" -> @@ -341,8 +342,8 @@ module Failure = struct | Receiver_already_exists -> "Attempted to create an account that already exists" | Token_owner_not_caller -> - "A party used a non-default token but its caller was not the token \ - owner" + "An account update used a non-default token but its caller was not the \ + token owner" | Overflow -> "The resulting balance is too large to store" | Global_excess_overflow -> @@ -352,7 +353,7 @@ module Failure = struct | Signed_command_on_zkapp_account -> "The source of a signed command cannot be a snapp account" | Zkapp_account_not_present -> - "A snapp account does not exist" + "A zkApp account does not exist" | Update_not_permitted_balance -> "The authentication for an account didn't allow the requested update \ to its balance" @@ -385,36 +386,41 @@ module Failure = struct | Update_not_permitted_voting_for -> "The authentication for an account didn't allow the requested update \ to its voted-for state hash" - | Parties_replay_check_failed -> - "Check to avoid replays failed. The party must increment nonce or use \ - full commitment if the authorization is a signature" + | Zkapp_command_replay_check_failed -> + "Check to avoid replays failed. The account update must increment \ + nonce or use full commitment if the authorization is a signature" | Fee_payer_nonce_must_increase -> - "Fee payer party must increment its nonce" + "Fee payer account update must increment its nonce" | Fee_payer_must_be_signed -> - "Fee payer party must have a valid signature" + "Fee payer account update must have a valid signature" | Account_balance_precondition_unsatisfied -> - "The party's account balance precondition was unsatisfied" + "The account update's account balance precondition was unsatisfied" | Account_nonce_precondition_unsatisfied -> - "The party's account nonce precondition was unsatisfied" + "The account update's account nonce precondition was unsatisfied" | Account_receipt_chain_hash_precondition_unsatisfied -> - "The party's account receipt-chain hash precondition was unsatisfied" + "The account update's account receipt-chain hash precondition was \ + unsatisfied" | Account_delegate_precondition_unsatisfied -> - "The party's account delegate precondition was unsatisfied" + "The account update's account delegate precondition was unsatisfied" | Account_sequence_state_precondition_unsatisfied -> - "The party's account sequence state precondition was unsatisfied" + "The account update's account sequence state precondition was \ + unsatisfied" | Account_app_state_precondition_unsatisfied i -> sprintf - "The party's account app state (%i) precondition was unsatisfied" i + "The account update's account app state (%i) precondition was \ + unsatisfied" + i | Account_proved_state_precondition_unsatisfied -> - "The party's account proved state precondition was unsatisfied" + "The account update's account proved state precondition was unsatisfied" | Account_is_new_precondition_unsatisfied -> - "The party's account is-new state precondition was unsatisfied" + "The account update's account is-new state precondition was unsatisfied" | Protocol_state_precondition_unsatisfied -> - "The party's protocol state precondition unsatisfied" + "The account update's protocol state precondition unsatisfied" | Incorrect_nonce -> "Incorrect nonce" | Invalid_fee_excess -> - "Fee excess from parties transaction more than the transaction fees" + "Fee excess from zkapp_command transaction more than the transaction \ + fees" end [%%versioned diff --git a/src/lib/mina_base/unix/graphql_scalars.ml b/src/lib/mina_base/unix/graphql_scalars.ml index 8a3d904ca3f..8eaaf7aaefa 100644 --- a/src/lib/mina_base/unix/graphql_scalars.ml +++ b/src/lib/mina_base/unix/graphql_scalars.ml @@ -89,11 +89,11 @@ module TransactionStatusFailure : ~doc:"transaction status failure" ~coerce:serialize end -module PartiesBase58 = +module ZkappCommandBase58 = Make_scalar_using_base58_check - (Mina_base.Parties) + (Mina_base.Zkapp_command) (struct - let name = "PartiesBase58" + let name = "ZkappCommandBase58" let doc = "A Base58Check string representing the command" end) diff --git a/src/lib/mina_base/user_command.ml b/src/lib/mina_base/user_command.ml index be2a1d62be8..14bebcde77a 100644 --- a/src/lib/mina_base/user_command.ml +++ b/src/lib/mina_base/user_command.ml @@ -7,7 +7,7 @@ module Poly = struct type ('u, 's) t = ('u, 's) Mina_wire_types.Mina_base.User_command.Poly.V2.t = | Signed_command of 'u - | Parties of 's + | Zkapp_command of 's [@@deriving sexp, compare, equal, hash, yojson] let to_latest = Fn.id @@ -28,7 +28,7 @@ end type ('u, 's) t_ = ('u, 's) Poly.Stable.Latest.t = | Signed_command of 'u - | Parties of 's + | Zkapp_command of 's module Gen_make (C : Signed_command_intf.Gen_intf) = struct let to_signed_command f = @@ -64,7 +64,8 @@ module Gen = Gen_make (Signed_command) [%%versioned module Stable = struct module V2 = struct - type t = (Signed_command.Stable.V2.t, Parties.Stable.V1.t) Poly.Stable.V2.t + type t = + (Signed_command.Stable.V2.t, Zkapp_command.Stable.V1.t) Poly.Stable.V2.t [@@deriving sexp, compare, equal, hash, yojson] let to_latest = Fn.id @@ -108,7 +109,7 @@ module Verifiable = struct module V2 = struct type t = ( Signed_command.Stable.V2.t - , Parties.Verifiable.Stable.V1.t ) + , Zkapp_command.Verifiable.Stable.V1.t ) Poly.Stable.V2.t [@@deriving sexp, compare, equal, hash, yojson] @@ -120,14 +121,14 @@ module Verifiable = struct match t with | Signed_command x -> Signed_command.fee_payer x - | Parties p -> - Party.Fee_payer.account_id p.fee_payer + | Zkapp_command p -> + Account_update.Fee_payer.account_id p.fee_payer end let to_verifiable (t : t) ~ledger ~get ~location_of_account : Verifiable.t = - let find_vk (p : Party.t) = + let find_vk (p : Account_update.t) = let ( ! ) x = Option.value_exn x in - let id = Party.account_id p in + let id = Account_update.account_id p in Option.try_with (fun () -> let account : Account.t = !(get ledger !(location_of_account ledger id)) @@ -137,12 +138,13 @@ let to_verifiable (t : t) ~ledger ~get ~location_of_account : Verifiable.t = match t with | Signed_command c -> Signed_command c - | Parties { fee_payer; other_parties; memo } -> - Parties + | Zkapp_command { fee_payer; account_updates; memo } -> + Zkapp_command { fee_payer - ; other_parties = - other_parties - |> Parties.Call_forest.map ~f:(fun party -> (party, find_vk party)) + ; account_updates = + account_updates + |> Zkapp_command.Call_forest.map ~f:(fun account_update -> + (account_update, find_vk account_update) ) ; memo } @@ -150,14 +152,14 @@ let of_verifiable (t : Verifiable.t) : t = match t with | Signed_command x -> Signed_command x - | Parties p -> - Parties (Parties.of_verifiable p) + | Zkapp_command p -> + Zkapp_command (Zkapp_command.of_verifiable p) let fee : t -> Currency.Fee.t = function | Signed_command x -> Signed_command.fee x - | Parties p -> - Parties.fee p + | Zkapp_command p -> + Zkapp_command.fee p (* for filtering *) let minimum_fee = Mina_compile_config.minimum_user_command_fee @@ -168,30 +170,30 @@ let accounts_accessed (t : t) = match t with | Signed_command x -> Signed_command.accounts_accessed x - | Parties ps -> - Parties.accounts_accessed ps + | Zkapp_command ps -> + Zkapp_command.accounts_accessed ps let to_base58_check (t : t) = match t with | Signed_command x -> Signed_command.to_base58_check x - | Parties ps -> - Parties.to_base58_check ps + | Zkapp_command ps -> + Zkapp_command.to_base58_check ps let fee_payer (t : t) = match t with | Signed_command x -> Signed_command.fee_payer x - | Parties p -> - Parties.fee_payer p + | Zkapp_command p -> + Zkapp_command.fee_payer p (** The application nonce is the nonce of the fee payer at which a user command can be applied. *) let applicable_at_nonce (t : t) = match t with | Signed_command x -> Signed_command.nonce x - | Parties p -> - Parties.applicable_at_nonce p + | Zkapp_command p -> + Zkapp_command.applicable_at_nonce p let expected_target_nonce t = Account.Nonce.succ (applicable_at_nonce t) @@ -200,21 +202,21 @@ let target_nonce_on_success (t : t) = match t with | Signed_command x -> Account.Nonce.succ (Signed_command.nonce x) - | Parties p -> - Parties.target_nonce_on_success p + | Zkapp_command p -> + Zkapp_command.target_nonce_on_success p let fee_token (t : t) = match t with | Signed_command x -> Signed_command.fee_token x - | Parties x -> - Parties.fee_token x + | Zkapp_command x -> + Zkapp_command.fee_token x let valid_until (t : t) = match t with | Signed_command x -> Signed_command.valid_until x - | Parties _ -> + | Zkapp_command _ -> Mina_numbers.Global_slot.max_value module Valid = struct @@ -223,7 +225,7 @@ module Valid = struct module V2 = struct type t = ( Signed_command.With_valid_signature.Stable.V2.t - , Parties.Valid.Stable.V1.t ) + , Zkapp_command.Valid.Stable.V1.t ) Poly.Stable.V2.t [@@deriving sexp, compare, equal, hash, yojson] @@ -238,25 +240,26 @@ let check ~ledger ~get ~location_of_account (t : t) : Valid.t option = match t with | Signed_command x -> Option.map (Signed_command.check x) ~f:(fun c -> Signed_command c) - | Parties p -> - Option.map (Parties.Valid.to_valid ~ledger ~get ~location_of_account p) - ~f:(fun p -> Parties p) + | Zkapp_command p -> + Option.map + (Zkapp_command.Valid.to_valid ~ledger ~get ~location_of_account p) + ~f:(fun p -> Zkapp_command p) let forget_check (t : Valid.t) : t = match t with - | Parties x -> - Parties (Parties.Valid.forget x) + | Zkapp_command x -> + Zkapp_command (Zkapp_command.Valid.forget x) | Signed_command c -> Signed_command (c :> Signed_command.t) let to_valid_unsafe (t : t) = `If_this_is_used_it_should_have_a_comment_justifying_it ( match t with - | Parties x -> + | Zkapp_command x -> let (`If_this_is_used_it_should_have_a_comment_justifying_it x) = - Parties.Valid.to_valid_unsafe x + Zkapp_command.Valid.to_valid_unsafe x in - Parties x + Zkapp_command x | Signed_command x -> (* This is safe due to being immediately wrapped again. *) let (`If_this_is_used_it_should_have_a_comment_justifying_it x) = @@ -278,8 +281,8 @@ let filter_by_participant (commands : t list) public_key = let weight : t -> int = function | Signed_command signed_command -> Signed_command.payload signed_command |> Signed_command_payload.weight - | Parties parties -> - Parties.weight parties + | Zkapp_command zkapp_command -> + Zkapp_command.weight zkapp_command (* Fee per weight unit *) let fee_per_wu (user_command : Stable.Latest.t) : Currency.Fee_rate.t = @@ -289,5 +292,5 @@ let fee_per_wu (user_command : Stable.Latest.t) : Currency.Fee_rate.t = let valid_size ~genesis_constants = function | Signed_command _ -> Ok () - | Parties parties -> - Parties.valid_size ~genesis_constants parties + | Zkapp_command zkapp_command -> + Zkapp_command.valid_size ~genesis_constants zkapp_command diff --git a/src/lib/mina_base/zkapp_call_forest.ml b/src/lib/mina_base/zkapp_call_forest.ml index 5ad73daa6ec..fff7e6d2c14 100644 --- a/src/lib/mina_base/zkapp_call_forest.ml +++ b/src/lib/mina_base/zkapp_call_forest.ml @@ -1,58 +1,72 @@ open Core_kernel -(* Same as the type of the field other_parties in Mina_base.Parties.t *) +(* Same as the type of the field account_updates in Mina_base.Zkapp_command.t *) type t = - ( Party.t - , Parties.Digest.Party.t - , Parties.Digest.Forest.t ) - Parties.Call_forest.t + ( Account_update.t + , Zkapp_command.Digest.Account_update.t + , Zkapp_command.Digest.Forest.t ) + Zkapp_command.Call_forest.t let empty () = [] -let if_ = Parties.value_if +let if_ = Zkapp_command.value_if let is_empty = List.is_empty -let pop_exn : t -> (Party.t * t) * t = function - | { stack_hash = _; elt = { party; calls; party_digest = _ } } :: xs -> - ((party, calls), xs) +let pop_exn : t -> (Account_update.t * t) * t = function + | { stack_hash = _ + ; elt = { account_update; calls; account_update_digest = _ } + } + :: xs -> + ((account_update, calls), xs) | _ -> failwith "pop_exn" -let push ~party ~calls t = Parties.Call_forest.cons ~calls party t +let push ~account_update ~calls t = + Zkapp_command.Call_forest.cons ~calls account_update t -let hash (t : t) = Parties.Call_forest.hash t +let hash (t : t) = Zkapp_command.Call_forest.hash t open Snark_params.Tick.Run module Checked = struct - module F = Parties.Digest.Forest.Checked + module F = Zkapp_command.Digest.Forest.Checked module V = Prover_value - type party = - { party : (Party.Body.Checked.t, Parties.Digest.Party.Checked.t) With_hash.t + type account_update = + { account_update : + ( Account_update.Body.Checked.t + , Zkapp_command.Digest.Account_update.Checked.t ) + With_hash.t ; control : Control.t Prover_value.t } - let party_typ () : - (party, (Party.t, Parties.Digest.Party.t) With_hash.t) Typ.t = - Typ.(Party.Body.typ () * Prover_value.typ () * Parties.Digest.Party.typ) + let account_update_typ () : + ( account_update + , (Account_update.t, Zkapp_command.Digest.Account_update.t) With_hash.t + ) + Typ.t = + Typ.( + Account_update.Body.typ () * Prover_value.typ () + * Zkapp_command.Digest.Account_update.typ) |> Typ.transport ~back:(fun ((body, authorization), hash) -> - { With_hash.data = { Party.body; authorization }; hash } ) - ~there:(fun { With_hash.data = { Party.body; authorization }; hash } -> - ((body, authorization), hash) ) + { With_hash.data = { Account_update.body; authorization }; hash } ) + ~there:(fun { With_hash.data = { Account_update.body; authorization } + ; hash + } -> ((body, authorization), hash) ) |> Typ.transport_var - ~back:(fun ((party, control), hash) -> - { party = { hash; data = party }; control } ) - ~there:(fun { party = { hash; data = party }; control } -> - ((party, control), hash) ) + ~back:(fun ((account_update, control), hash) -> + { account_update = { hash; data = account_update }; control } ) + ~there:(fun { account_update = { hash; data = account_update } + ; control + } -> ((account_update, control), hash) ) type t = - ( ( Party.t - , Parties.Digest.Party.t - , Parties.Digest.Forest.t ) - Parties.Call_forest.t + ( ( Account_update.t + , Zkapp_command.Digest.Account_update.t + , Zkapp_command.Digest.Forest.t ) + Zkapp_command.Call_forest.t V.t , F.t ) With_hash.t @@ -63,74 +77,90 @@ module Checked = struct } let empty = - Parties.Digest.Forest.constant Parties.Call_forest.With_hashes.empty + Zkapp_command.Digest.Forest.constant + Zkapp_command.Call_forest.With_hashes.empty let is_empty ({ hash = x; _ } : t) = F.equal empty x let empty () : t = { hash = empty; data = V.create (fun () -> []) } - let pop_exn ({ hash = h; data = r } : t) : (party * t) * t = + let pop_exn ({ hash = h; data = r } : t) : (account_update * t) * t = with_label "Zkapp_call_forest.pop_exn" (fun () -> let hd_r = V.create (fun () -> V.get r |> List.hd_exn |> With_stack_hash.elt) in - let party = V.create (fun () -> (V.get hd_r).party) in - let auth = V.(create (fun () -> (V.get party).authorization)) in - let party = - exists (Party.Body.typ ()) ~compute:(fun () -> (V.get party).body) + let account_update = V.create (fun () -> (V.get hd_r).account_update) in + let auth = + V.(create (fun () -> (V.get account_update).authorization)) + in + let account_update = + exists (Account_update.Body.typ ()) ~compute:(fun () -> + (V.get account_update).body ) in - let party = - With_hash.of_data party ~hash_data:Parties.Digest.Party.Checked.create + let account_update = + With_hash.of_data account_update + ~hash_data:Zkapp_command.Digest.Account_update.Checked.create in let subforest : t = let subforest = V.create (fun () -> (V.get hd_r).calls) in let subforest_hash = - exists Parties.Digest.Forest.typ ~compute:(fun () -> - Parties.Call_forest.hash (V.get subforest) ) + exists Zkapp_command.Digest.Forest.typ ~compute:(fun () -> + Zkapp_command.Call_forest.hash (V.get subforest) ) in { hash = subforest_hash; data = subforest } in let tl_hash = - exists Parties.Digest.Forest.typ ~compute:(fun () -> - V.get r |> List.tl_exn |> Parties.Call_forest.hash ) + exists Zkapp_command.Digest.Forest.typ ~compute:(fun () -> + V.get r |> List.tl_exn |> Zkapp_command.Call_forest.hash ) in let tree_hash = - Parties.Digest.Tree.Checked.create ~party:party.hash - ~calls:subforest.hash + Zkapp_command.Digest.Tree.Checked.create + ~account_update:account_update.hash ~calls:subforest.hash + in + let hash_cons = + Zkapp_command.Digest.Forest.Checked.cons tree_hash tl_hash in - let hash_cons = Parties.Digest.Forest.Checked.cons tree_hash tl_hash in F.Assert.equal hash_cons h ; - ( ( ({ party; control = auth }, subforest) + ( ( ({ account_update; control = auth }, subforest) , { hash = tl_hash ; data = V.(create (fun () -> List.tl_exn (get r))) } ) - : (party * t) * t ) ) + : (account_update * t) * t ) ) let push - ~party:{ party = { hash = party_hash; data = party }; control = auth } - ~calls:({ hash = calls_hash; data = calls } : t) + ~account_update: + { account_update = { hash = account_update_hash; data = account_update } + ; control = auth + } ~calls:({ hash = calls_hash; data = calls } : t) ({ hash = tl_hash; data = tl_data } : t) : t = with_label "Zkapp_call_forest.push" (fun () -> let tree_hash = - Parties.Digest.Tree.Checked.create ~party:party_hash ~calls:calls_hash + Zkapp_command.Digest.Tree.Checked.create + ~account_update:account_update_hash ~calls:calls_hash + in + let hash_cons = + Zkapp_command.Digest.Forest.Checked.cons tree_hash tl_hash in - let hash_cons = Parties.Digest.Forest.Checked.cons tree_hash tl_hash in let data = V.create (fun () -> - let body = As_prover.read (Party.Body.typ ()) party in + let body = + As_prover.read (Account_update.Body.typ ()) account_update + in let authorization = V.get auth in let tl = V.get tl_data in - let party : Party.t = { body; authorization } in + let account_update : Account_update.t = { body; authorization } in let calls = V.get calls in - let res = Parties.Call_forest.cons ~calls party tl in + let res = + Zkapp_command.Call_forest.cons ~calls account_update tl + in (* Sanity check; we're re-hashing anyway, might as well make sure it's consistent. *) assert ( - Parties.Digest.Forest.( + Zkapp_command.Digest.Forest.( equal (As_prover.read typ hash_cons) - (Parties.Call_forest.hash res)) ) ; + (Zkapp_command.Call_forest.hash res)) ) ; res ) in ({ hash = hash_cons; data } : t) ) @@ -139,13 +169,17 @@ module Checked = struct end let typ : (Checked.t, t) Typ.t = - Typ.(Parties.Digest.Forest.typ * Prover_value.typ ()) + Typ.(Zkapp_command.Digest.Forest.typ * Prover_value.typ ()) |> Typ.transport ~back:(fun (_digest, forest) -> - Parties.Call_forest.map ~f:(fun party -> party) forest ) + Zkapp_command.Call_forest.map + ~f:(fun account_update -> account_update) + forest ) ~there:(fun forest -> - ( Parties.Call_forest.hash forest - , Parties.Call_forest.map ~f:(fun party -> party) forest ) ) + ( Zkapp_command.Call_forest.hash forest + , Zkapp_command.Call_forest.map + ~f:(fun account_update -> account_update) + forest ) ) |> Typ.transport_var ~back:(fun (digest, forest) -> { With_hash.hash = digest; data = forest }) ~there:(fun { With_hash.hash = digest; data = forest } -> diff --git a/src/lib/mina_base/parties.ml b/src/lib/mina_base/zkapp_command.ml similarity index 55% rename from src/lib/mina_base/parties.ml rename to src/lib/mina_base/zkapp_command.ml index 4313a046e07..78d6294f5f7 100644 --- a/src/lib/mina_base/parties.ml +++ b/src/lib/mina_base/zkapp_command.ml @@ -1,8 +1,9 @@ open Core_kernel open Signature_lib -let add_caller (p : Party.Wire.t) caller : Party.t = - let add_caller_body (p : Party.Body.Wire.t) caller : Party.Body.t = +let add_caller (p : Account_update.Wire.t) caller : Account_update.t = + let add_caller_body (p : Account_update.Body.Wire.t) caller : + Account_update.Body.t = { public_key = p.public_key ; token_id = p.token_id ; update = p.update @@ -18,8 +19,9 @@ let add_caller (p : Party.Wire.t) caller : Party.t = in { body = add_caller_body p.body caller; authorization = p.authorization } -let add_caller_simple (p : Party.Simple.t) caller : Party.t = - let add_caller_body (p : Party.Body.Simple.t) caller : Party.Body.t = +let add_caller_simple (p : Account_update.Simple.t) caller : Account_update.t = + let add_caller_body (p : Account_update.Body.Simple.t) caller : + Account_update.Body.t = { public_key = p.public_key ; token_id = p.token_id ; update = p.update @@ -42,15 +44,15 @@ module Call_forest = struct [%%versioned module Stable = struct module V1 = struct - type ('party, 'party_digest, 'digest) t = - ( 'party - , 'party_digest + type ('account_update, 'account_update_digest, 'digest) t = + ( 'account_update + , 'account_update_digest , 'digest ) - Mina_wire_types.Mina_base.Parties.Call_forest.Tree.V1.t = - { party : 'party - ; party_digest : 'party_digest + Mina_wire_types.Mina_base.Zkapp_command.Call_forest.Tree.V1.t = + { account_update : 'account_update + ; account_update_digest : 'account_update_digest ; calls : - ( ('party, 'party_digest, 'digest) t + ( ('account_update, 'account_update_digest, 'digest) t , 'digest ) With_stack_hash.Stable.V1.t list @@ -65,8 +67,8 @@ module Call_forest = struct List.fold ts ~init ~f:(fun acc { elt; stack_hash = _ } -> fold elt ~init:acc ~f ) - and fold { party; calls; party_digest = _ } ~f ~init = - fold_forest calls ~f ~init:(f init party) + and fold { account_update; calls; account_update_digest = _ } ~f ~init = + fold_forest calls ~f ~init:(f init account_update) let rec fold_forest2_exn (ts1 : (_ t, _) With_stack_hash.t list) (ts2 : (_ t, _) With_stack_hash.t list) ~f ~init = @@ -77,9 +79,17 @@ module Call_forest = struct { elt = elt2; stack_hash = _ } -> fold2_exn elt1 elt2 ~init:acc ~f ) - and fold2_exn { party = party1; calls = calls1; party_digest = _ } - { party = party2; calls = calls2; party_digest = _ } ~f ~init = - fold_forest2_exn calls1 calls2 ~f ~init:(f init party1 party2) + and fold2_exn + { account_update = account_update1 + ; calls = calls1 + ; account_update_digest = _ + } + { account_update = account_update2 + ; calls = calls2 + ; account_update_digest = _ + } ~f ~init = + fold_forest2_exn calls1 calls2 ~f + ~init:(f init account_update1 account_update2) let iter_forest2_exn ts1 ts2 ~f = fold_forest2_exn ts1 ts2 ~init:() ~f:(fun () p1 p2 -> f p1 p2) @@ -89,7 +99,11 @@ module Call_forest = struct let rec mapi_with_trees' ~i (t : _ t) ~f = let l, calls = mapi_forest_with_trees' ~i:(i + 1) t.calls ~f in - (l, { calls; party = f i t.party t; party_digest = t.party_digest }) + ( l + , { calls + ; account_update = f i t.account_update t + ; account_update_digest = t.account_update_digest + } ) and mapi_forest_with_trees' ~i x ~f = let rec go i acc = function @@ -105,18 +119,24 @@ module Call_forest = struct let mapi_forest_with_trees t ~f = mapi_forest_with_trees' ~i:0 t ~f |> snd - let mapi' ~i t ~f = mapi_with_trees' ~i t ~f:(fun i party _ -> f i party) + let mapi' ~i t ~f = + mapi_with_trees' ~i t ~f:(fun i account_update _ -> f i account_update) let mapi_forest' ~i t ~f = - mapi_forest_with_trees' ~i t ~f:(fun i party _ -> f i party) + mapi_forest_with_trees' ~i t ~f:(fun i account_update _ -> + f i account_update ) let rec deferred_mapi_with_trees' ~i (t : _ t) ~f = let open Async_kernel.Deferred.Let_syntax in let%bind l, calls = deferred_mapi_forest_with_trees' ~i:(i + 1) t.calls ~f in - let%map party = f i t.party t in - (l, { calls; party; party_digest = t.party_digest }) + let%map account_update = f i t.account_update t in + ( l + , { calls + ; account_update + ; account_update_digest = t.account_update_digest + } ) and deferred_mapi_forest_with_trees' ~i x ~f = let open Async_kernel.Deferred.Let_syntax in @@ -143,29 +163,29 @@ module Call_forest = struct let open Async_kernel.Deferred in deferred_mapi_forest_with_trees' ~i:0 ~f t >>| snd - let hash { party = _; calls; party_digest } = + let hash { account_update = _; calls; account_update_digest } = let stack_hash = match calls with [] -> empty | e :: _ -> e.stack_hash in - Random_oracle.hash ~init:Hash_prefix_states.party_node - [| party_digest; stack_hash |] + Random_oracle.hash ~init:Hash_prefix_states.account_update_node + [| account_update_digest; stack_hash |] end type ('a, 'b, 'c) tree = ('a, 'b, 'c) Tree.t module type Digest_intf = sig - module Party : sig + module Account_update : sig include Digest_intf.S module Checked : sig include Digest_intf.S_checked - val create : Party.Checked.t -> t + val create : Account_update.Checked.t -> t end include Digest_intf.S_aux with type t := t and type checked := Checked.t - val create : Party.t -> t + val create : Account_update.t -> t end module rec Forest : sig @@ -191,24 +211,28 @@ module Call_forest = struct include Digest_intf.S_checked val create : - party:Party.Checked.t -> calls:Forest.Checked.t -> Tree.Checked.t + account_update:Account_update.Checked.t + -> calls:Forest.Checked.t + -> Tree.Checked.t end include Digest_intf.S_aux with type t := t and type checked := Checked.t - val create : (_, Party.t, Forest.t) tree -> Tree.t + val create : (_, Account_update.t, Forest.t) tree -> Tree.t end end - module Make_digest_sig (T : Mina_wire_types.Mina_base.Parties.Digest_types.S) = + module Make_digest_sig + (T : Mina_wire_types.Mina_base.Zkapp_command.Digest_types.S) = struct module type S = Digest_intf - with type Party.Stable.V1.t = T.Party.V1.t + with type Account_update.Stable.V1.t = T.Account_update.V1.t and type Forest.Stable.V1.t = T.Forest.V1.t end - module Make_digest_str (T : Mina_wire_types.Mina_base.Parties.Digest_concrete) : + module Make_digest_str + (T : Mina_wire_types.Mina_base.Zkapp_command.Digest_concrete) : Make_digest_sig(T).S = struct module M = struct open Pickles.Impls.Step.Field @@ -219,7 +243,7 @@ module Call_forest = struct let constant = constant end - module Party = struct + module Account_update = struct [%%versioned module Stable = struct module V1 = struct @@ -235,10 +259,10 @@ module Call_forest = struct module Checked = struct include Checked - let create = Party.Checked.digest + let create = Account_update.Checked.digest end - let create : Party.t -> t = Party.digest + let create : Account_update.t -> t = Account_update.digest end module Forest = struct @@ -258,14 +282,15 @@ module Call_forest = struct include Checked let cons hash h_tl = - Random_oracle.Checked.hash ~init:Hash_prefix_states.party_cons - [| hash; h_tl |] + Random_oracle.Checked.hash + ~init:Hash_prefix_states.account_update_cons [| hash; h_tl |] end let empty = empty let cons hash h_tl = - Random_oracle.hash ~init:Hash_prefix_states.party_cons [| hash; h_tl |] + Random_oracle.hash ~init:Hash_prefix_states.account_update_cons + [| hash; h_tl |] end module Tree = struct @@ -284,22 +309,25 @@ module Call_forest = struct module Checked = struct include Checked - let create ~(party : Party.Checked.t) ~(calls : Forest.Checked.t) = - Random_oracle.Checked.hash ~init:Hash_prefix_states.party_node - [| (party :> t); (calls :> t) |] + let create ~(account_update : Account_update.Checked.t) + ~(calls : Forest.Checked.t) = + Random_oracle.Checked.hash + ~init:Hash_prefix_states.account_update_node + [| (account_update :> t); (calls :> t) |] end - let create ({ party = _; calls; party_digest } : _ tree) = + let create ({ account_update = _; calls; account_update_digest } : _ tree) + = let stack_hash = match calls with [] -> empty | e :: _ -> e.stack_hash in - Random_oracle.hash ~init:Hash_prefix_states.party_node - [| party_digest; stack_hash |] + Random_oracle.hash ~init:Hash_prefix_states.account_update_node + [| account_update_digest; stack_hash |] end end module Digest = - Mina_wire_types.Mina_base.Parties.Digest_make + Mina_wire_types.Mina_base.Zkapp_command.Digest_make (Make_digest_sig) (Make_digest_str) @@ -312,8 +340,8 @@ module Call_forest = struct [%%versioned module Stable = struct module V1 = struct - type ('party, 'party_digest, 'digest) t = - ( ('party, 'party_digest, 'digest) Tree.Stable.V1.t + type ('account_update, 'account_update_digest, 'digest) t = + ( ('account_update, 'account_update_digest, 'digest) Tree.Stable.V1.t , 'digest ) With_stack_hash.Stable.V1.t list @@ -365,47 +393,59 @@ module Call_forest = struct ; stack_hash = () } ) - let rec of_parties_list_map ~(f : 'p1 -> 'p2) ~(party_depth : 'p1 -> int) - (parties : 'p1 list) : ('p2, unit, unit) t = - match parties with + let rec of_zkapp_command_list_map ~(f : 'p1 -> 'p2) + ~(account_update_depth : 'p1 -> int) (zkapp_command : 'p1 list) : + ('p2, unit, unit) t = + match zkapp_command with | [] -> [] | p :: ps -> - let depth = party_depth p in + let depth = account_update_depth p in let children, siblings = - List.split_while ps ~f:(fun p' -> party_depth p' > depth) + List.split_while ps ~f:(fun p' -> account_update_depth p' > depth) in { With_stack_hash.elt = - { Tree.party = f p - ; party_digest = () - ; calls = of_parties_list_map ~f ~party_depth children + { Tree.account_update = f p + ; account_update_digest = () + ; calls = + of_zkapp_command_list_map ~f ~account_update_depth children } ; stack_hash = () } - :: of_parties_list_map ~f ~party_depth siblings + :: of_zkapp_command_list_map ~f ~account_update_depth siblings - let of_parties_list ~party_depth parties = - of_parties_list_map ~f:Fn.id ~party_depth parties + let of_zkapp_command_list ~account_update_depth zkapp_command = + of_zkapp_command_list_map ~f:Fn.id ~account_update_depth zkapp_command - let to_parties_list_map ~f (xs : _ t) = + let to_zkapp_command_list_map ~f (xs : _ t) = let rec collect depth (xs : _ t) acc = match xs with | [] -> acc - | { elt = { party; calls; party_digest = _ }; stack_hash = _ } :: xs -> - f ~depth party :: acc |> collect (depth + 1) calls |> collect depth xs + | { elt = { account_update; calls; account_update_digest = _ } + ; stack_hash = _ + } + :: xs -> + f ~depth account_update :: acc + |> collect (depth + 1) calls + |> collect depth xs in List.rev (collect 0 xs []) - let to_parties_list xs = - to_parties_list_map ~f:(fun ~depth:_ party -> party) xs + let to_zkapp_command_list xs = + to_zkapp_command_list_map + ~f:(fun ~depth:_ account_update -> account_update) + xs - let hd_party (xs : _ t) = + let hd_account_update (xs : _ t) = match xs with | [] -> None - | { elt = { party; calls = _; party_digest = _ }; stack_hash = _ } :: _ -> - Some party + | { elt = { account_update; calls = _; account_update_digest = _ } + ; stack_hash = _ + } + :: _ -> + Some account_update let map = Tree.map_forest @@ -415,88 +455,109 @@ module Call_forest = struct let deferred_mapi = Tree.deferred_mapi_forest - let%test_unit "Party_or_stack.of_parties_list" = - let parties_list_1 = [ 0; 0; 0; 0 ] in + let%test_unit "Account_update_or_stack.of_zkapp_command_list" = + let zkapp_command_list_1 = [ 0; 0; 0; 0 ] in let node i calls = - { With_stack_hash.elt = { Tree.calls; party = i; party_digest = () } + { With_stack_hash.elt = + { Tree.calls; account_update = i; account_update_digest = () } ; stack_hash = () } in - let parties_list_1_res : (int, unit, unit) t = + let zkapp_command_list_1_res : (int, unit, unit) t = let n0 = node 0 [] in [ n0; n0; n0; n0 ] in let f_index = mapi ~f:(fun i _p -> i) in [%test_eq: (int, unit, unit) t] - (of_parties_list ~party_depth:Fn.id parties_list_1) - parties_list_1_res ; - let parties_list1_index : (int, unit, unit) t = + (of_zkapp_command_list ~account_update_depth:Fn.id zkapp_command_list_1) + zkapp_command_list_1_res ; + let zkapp_command_list1_index : (int, unit, unit) t = let n i = node i [] in [ n 0; n 1; n 2; n 3 ] in [%test_eq: (int, unit, unit) t] - (of_parties_list ~party_depth:Fn.id parties_list_1 |> f_index) - parties_list1_index ; + ( of_zkapp_command_list ~account_update_depth:Fn.id zkapp_command_list_1 + |> f_index ) + zkapp_command_list1_index ; [%test_eq: int list] - (to_parties_list (of_parties_list ~party_depth:Fn.id parties_list_1)) - parties_list_1 ; - let parties_list_2 = [ 0; 0; 1; 1 ] in - let parties_list_2_res = [ node 0 []; node 0 [ node 1 []; node 1 [] ] ] in - let parties_list_2_index = [ node 0 []; node 1 [ node 2 []; node 3 [] ] ] in + (to_zkapp_command_list + (of_zkapp_command_list ~account_update_depth:Fn.id zkapp_command_list_1) ) + zkapp_command_list_1 ; + let zkapp_command_list_2 = [ 0; 0; 1; 1 ] in + let zkapp_command_list_2_res = + [ node 0 []; node 0 [ node 1 []; node 1 [] ] ] + in + let zkapp_command_list_2_index = + [ node 0 []; node 1 [ node 2 []; node 3 [] ] ] + in [%test_eq: (int, unit, unit) t] - (of_parties_list ~party_depth:Fn.id parties_list_2) - parties_list_2_res ; + (of_zkapp_command_list ~account_update_depth:Fn.id zkapp_command_list_2) + zkapp_command_list_2_res ; [%test_eq: (int, unit, unit) t] - (of_parties_list ~party_depth:Fn.id parties_list_2 |> f_index) - parties_list_2_index ; + ( of_zkapp_command_list ~account_update_depth:Fn.id zkapp_command_list_2 + |> f_index ) + zkapp_command_list_2_index ; [%test_eq: int list] - (to_parties_list (of_parties_list ~party_depth:Fn.id parties_list_2)) - parties_list_2 ; - let parties_list_3 = [ 0; 0; 1; 0 ] in - let parties_list_3_res = [ node 0 []; node 0 [ node 1 [] ]; node 0 [] ] in - let parties_list_3_index = [ node 0 []; node 1 [ node 2 [] ]; node 3 [] ] in + (to_zkapp_command_list + (of_zkapp_command_list ~account_update_depth:Fn.id zkapp_command_list_2) ) + zkapp_command_list_2 ; + let zkapp_command_list_3 = [ 0; 0; 1; 0 ] in + let zkapp_command_list_3_res = + [ node 0 []; node 0 [ node 1 [] ]; node 0 [] ] + in + let zkapp_command_list_3_index = + [ node 0 []; node 1 [ node 2 [] ]; node 3 [] ] + in [%test_eq: (int, unit, unit) t] - (of_parties_list ~party_depth:Fn.id parties_list_3) - parties_list_3_res ; + (of_zkapp_command_list ~account_update_depth:Fn.id zkapp_command_list_3) + zkapp_command_list_3_res ; [%test_eq: (int, unit, unit) t] - (of_parties_list ~party_depth:Fn.id parties_list_3 |> f_index) - parties_list_3_index ; + ( of_zkapp_command_list ~account_update_depth:Fn.id zkapp_command_list_3 + |> f_index ) + zkapp_command_list_3_index ; [%test_eq: int list] - (to_parties_list (of_parties_list ~party_depth:Fn.id parties_list_3)) - parties_list_3 ; - let parties_list_4 = [ 0; 1; 2; 3; 2; 1; 0 ] in - let parties_list_4_res = + (to_zkapp_command_list + (of_zkapp_command_list ~account_update_depth:Fn.id zkapp_command_list_3) ) + zkapp_command_list_3 ; + let zkapp_command_list_4 = [ 0; 1; 2; 3; 2; 1; 0 ] in + let zkapp_command_list_4_res = [ node 0 [ node 1 [ node 2 [ node 3 [] ]; node 2 [] ]; node 1 [] ] ; node 0 [] ] in - let parties_list_4_index = + let zkapp_command_list_4_index = [ node 0 [ node 1 [ node 2 [ node 3 [] ]; node 4 [] ]; node 5 [] ] ; node 6 [] ] in [%test_eq: (int, unit, unit) t] - (of_parties_list ~party_depth:Fn.id parties_list_4) - parties_list_4_res ; + (of_zkapp_command_list ~account_update_depth:Fn.id zkapp_command_list_4) + zkapp_command_list_4_res ; [%test_eq: (int, unit, unit) t] - (of_parties_list ~party_depth:Fn.id parties_list_4 |> f_index) - parties_list_4_index ; + ( of_zkapp_command_list ~account_update_depth:Fn.id zkapp_command_list_4 + |> f_index ) + zkapp_command_list_4_index ; [%test_eq: int list] - (to_parties_list (of_parties_list ~party_depth:Fn.id parties_list_4)) - parties_list_4 + (to_zkapp_command_list + (of_zkapp_command_list ~account_update_depth:Fn.id zkapp_command_list_4) ) + zkapp_command_list_4 - let to_parties_with_hashes_list (xs : _ t) = + let to_zkapp_command_with_hashes_list (xs : _ t) = let rec collect (xs : _ t) acc = match xs with | [] -> acc - | { elt = { party; calls; party_digest = _ }; stack_hash } :: xs -> - (party, stack_hash) :: acc |> collect calls |> collect xs + | { elt = { account_update; calls; account_update_digest = _ } + ; stack_hash + } + :: xs -> + (account_update, stack_hash) :: acc |> collect calls |> collect xs in List.rev (collect xs []) let hash_cons hash h_tl = - Random_oracle.hash ~init:Hash_prefix_states.party_cons [| hash; h_tl |] + Random_oracle.hash ~init:Hash_prefix_states.account_update_cons + [| hash; h_tl |] let hash = function | [] -> @@ -510,50 +571,64 @@ module Call_forest = struct } :: forest - let cons_aux (type p) ~(digest_party : p -> _) ?(calls = []) (party : p) - (xs : _ t) : _ t = - let party_digest = digest_party party in - let tree : _ Tree.t = { party; party_digest; calls } in + let cons_aux (type p) ~(digest_account_update : p -> _) ?(calls = []) + (account_update : p) (xs : _ t) : _ t = + let account_update_digest = digest_account_update account_update in + let tree : _ Tree.t = { account_update; account_update_digest; calls } in cons_tree tree xs - let cons ?calls (party : Party.t) xs = - cons_aux ~digest_party:Digest.Party.create ?calls party xs + let cons ?calls (account_update : Account_update.t) xs = + cons_aux ~digest_account_update:Digest.Account_update.create ?calls + account_update xs - let rec accumulate_hashes ~hash_party (xs : _ t) = - let go = accumulate_hashes ~hash_party in + let rec accumulate_hashes ~hash_account_update (xs : _ t) = + let go = accumulate_hashes ~hash_account_update in match xs with | [] -> [] - | { elt = { party; calls; party_digest = _ }; stack_hash = _ } :: xs -> + | { elt = { account_update; calls; account_update_digest = _ } + ; stack_hash = _ + } + :: xs -> let calls = go calls in let xs = go xs in - let node = { Tree.party; calls; party_digest = hash_party party } in + let node = + { Tree.account_update + ; calls + ; account_update_digest = hash_account_update account_update + } + in let node_hash = Digest.Tree.create node in { elt = node; stack_hash = Digest.Forest.cons node_hash (hash xs) } :: xs - let accumulate_hashes' (type a b) (xs : (Party.t, a, b) t) : - (Party.t, Digest.Party.t, Digest.Forest.t) t = - let hash_party (p : Party.t) = Digest.Party.create p in - accumulate_hashes ~hash_party xs + let accumulate_hashes' (type a b) (xs : (Account_update.t, a, b) t) : + (Account_update.t, Digest.Account_update.t, Digest.Forest.t) t = + let hash_account_update (p : Account_update.t) = + Digest.Account_update.create p + in + accumulate_hashes ~hash_account_update xs let accumulate_hashes_predicated xs = - accumulate_hashes ~hash_party:Digest.Party.create xs + accumulate_hashes ~hash_account_update:Digest.Account_update.create xs (* Delegate_call means, preserve the current caller. *) - let add_callers (type party party_with_caller party_digest digest id) - (ps : (party, party_digest, digest) t) - ~(call_type : party -> Party.Call_type.t) - ~(add_caller : party -> id -> party_with_caller) ~(null_id : id) - ~(party_id : party -> id) : (party_with_caller, party_digest, digest) t = + let add_callers + (type account_update account_update_with_caller account_update_digest + digest id ) (ps : (account_update, account_update_digest, digest) t) + ~(call_type : account_update -> Account_update.Call_type.t) + ~(add_caller : account_update -> id -> account_update_with_caller) + ~(null_id : id) ~(account_update_id : account_update -> id) : + (account_update_with_caller, account_update_digest, digest) t = let module Context = struct type t = { caller : id; self : id } end in let open Context in let rec go curr_context ps = match ps with - | { With_stack_hash.elt = { Tree.party = p; party_digest; calls } + | { With_stack_hash.elt = + { Tree.account_update = p; account_update_digest; calls } ; stack_hash } :: ps -> @@ -563,11 +638,11 @@ module Call_forest = struct | Delegate_call -> curr_context | Call -> - { caller = curr_context.self; self = party_id p } + { caller = curr_context.self; self = account_update_id p } in - let party_caller = child_context.caller in - { Tree.party = add_caller p party_caller - ; party_digest + let account_update_caller = child_context.caller in + { Tree.account_update = add_caller p account_update_caller + ; account_update_digest ; calls = go child_context calls } in @@ -577,63 +652,72 @@ module Call_forest = struct in go { self = null_id; caller = null_id } ps - let add_callers' (type h1 h2) (ps : (Party.Wire.t, h1, h2) t) : - (Party.t, h1, h2) t = + let add_callers' (type h1 h2) (ps : (Account_update.Wire.t, h1, h2) t) : + (Account_update.t, h1, h2) t = add_callers ps ~call_type:(fun p -> p.body.caller) ~add_caller ~null_id:Token_id.default - ~party_id:(fun p -> + ~account_update_id:(fun p -> Account_id.( derive_token_id ~owner:(create p.body.public_key p.body.token_id)) ) - let add_callers_simple (type h1 h2) (ps : (Party.Simple.t, h1, h2) t) : - (Party.t, h1, h2) t = + let add_callers_simple (type h1 h2) (ps : (Account_update.Simple.t, h1, h2) t) + : (Account_update.t, h1, h2) t = add_callers ps ~call_type:(fun p -> p.body.caller) ~add_caller:add_caller_simple ~null_id:Token_id.default - ~party_id:(fun p -> + ~account_update_id:(fun p -> Account_id.( derive_token_id ~owner:(create p.body.public_key p.body.token_id)) ) let remove_callers - (type party_with_caller party_without_sender h1 h2 h1' h2' id) - ~(map_party_digest : h1 -> h1') ~(map_stack_hash : h2 -> h2') - (ps : (party_with_caller, h1, h2) t) ~(equal_id : id -> id -> bool) + (type account_update_with_caller account_update_without_sender h1 h2 h1' + h2' id ) ~(map_account_update_digest : h1 -> h1') + ~(map_stack_hash : h2 -> h2') + (ps : (account_update_with_caller, h1, h2) t) + ~(equal_id : id -> id -> bool) ~(add_call_type : - party_with_caller -> Party.Call_type.t -> party_without_sender ) - ~(null_id : id) ~(party_caller : party_with_caller -> id) : - (party_without_sender, h1', h2') t = - let rec go ~top_level_party parent_caller ps = - let call_type_for_party p : Party.Call_type.t = - if top_level_party then Call - else if equal_id parent_caller (party_caller p) then Delegate_call + account_update_with_caller + -> Account_update.Call_type.t + -> account_update_without_sender ) ~(null_id : id) + ~(account_update_caller : account_update_with_caller -> id) : + (account_update_without_sender, h1', h2') t = + let rec go ~top_level_account_update parent_caller ps = + let call_type_for_account_update p : Account_update.Call_type.t = + if top_level_account_update then Call + else if equal_id parent_caller (account_update_caller p) then + Delegate_call else Call in match ps with - | { With_stack_hash.elt = { Tree.party = p; party_digest; calls } + | { With_stack_hash.elt = + { Tree.account_update = p; account_update_digest; calls } ; stack_hash } :: ps -> - let ty = call_type_for_party p in + let ty = call_type_for_account_update p in { With_stack_hash.elt = - { Tree.party = add_call_type p ty - ; party_digest = map_party_digest party_digest - ; calls = go ~top_level_party:false (party_caller p) calls + { Tree.account_update = add_call_type p ty + ; account_update_digest = + map_account_update_digest account_update_digest + ; calls = + go ~top_level_account_update:false (account_update_caller p) + calls } ; stack_hash = map_stack_hash stack_hash } - :: go ~top_level_party parent_caller ps + :: go ~top_level_account_update parent_caller ps | [] -> [] in - go ~top_level_party:true null_id ps + go ~top_level_account_update:true null_id ps let%test_unit "add_callers and remove_callers" = let module P = struct type 'a t = { id : int; caller : 'a } [@@deriving compare, sexp] end in let module With_call_type = struct - type tmp = (Party.Call_type.t P.t, unit, unit) t + type tmp = (Account_update.Call_type.t P.t, unit, unit) t [@@deriving compare, sexp] type t = tmp [@@deriving compare, sexp] @@ -648,15 +732,15 @@ module Call_forest = struct [ { With_stack_hash.elt = tree; stack_hash = () } ] in let node id caller calls = - { Tree.party = { P.id; caller } - ; party_digest = () + { Tree.account_update = { P.id; caller } + ; account_update_digest = () ; calls = List.map calls ~f:(fun elt -> { With_stack_hash.elt; stack_hash = () } ) } in let t : With_call_type.t = - let open Party.Call_type in + let open Account_update.Call_type in node 0 Call [ node 1 Call [ node 11 Call [ node 111 Call []; node 112 Delegate_call [] ] @@ -690,14 +774,14 @@ module Call_forest = struct ~call_type:(fun p -> p.caller) ~add_caller:(fun p caller : int P.t -> { p with caller }) ~null_id - ~party_id:(fun p -> p.id) ) + ~account_update_id:(fun p -> p.id) ) expected_output ; [%test_eq: With_call_type.t] (remove_callers expected_output ~equal_id:Int.equal - ~map_party_digest:Fn.id ~map_stack_hash:Fn.id + ~map_account_update_digest:Fn.id ~map_stack_hash:Fn.id ~add_call_type:(fun p call_type -> { p with caller = call_type }) ~null_id - ~party_caller:(fun p -> p.caller) ) + ~account_update_caller:(fun p -> p.caller) ) t module With_hashes_and_data = struct @@ -705,8 +789,8 @@ module Call_forest = struct module Stable = struct module V1 = struct type 'data t = - ( Party.Stable.V1.t * 'data - , Digest.Party.Stable.V1.t + ( Account_update.Stable.V1.t * 'data + , Digest.Account_update.Stable.V1.t , Digest.Forest.Stable.V1.t ) Stable.V1.t [@@deriving sexp, compare, equal, hash, yojson] @@ -717,38 +801,44 @@ module Call_forest = struct let empty = Digest.Forest.empty - let hash_party ((p : Party.t), _) = Digest.Party.create p + let hash_account_update ((p : Account_update.t), _) = + Digest.Account_update.create p - let accumulate_hashes xs : _ t = accumulate_hashes ~hash_party xs + let accumulate_hashes xs : _ t = accumulate_hashes ~hash_account_update xs - let of_parties_simple_list (xs : (Party.Simple.t * 'a) list) : _ t = - of_parties_list xs ~party_depth:(fun ((p : Party.Simple.t), _) -> + let of_zkapp_command_simple_list (xs : (Account_update.Simple.t * 'a) list) + : _ t = + of_zkapp_command_list xs + ~account_update_depth:(fun ((p : Account_update.Simple.t), _) -> p.body.call_depth ) |> add_callers - ~call_type:(fun ((p : Party.Simple.t), _) -> p.body.caller) + ~call_type:(fun ((p : Account_update.Simple.t), _) -> p.body.caller) ~add_caller:(fun (p, x) id -> (add_caller_simple p id, x)) ~null_id:Token_id.default - ~party_id:(fun ((p : Party.Simple.t), _) -> + ~account_update_id:(fun ((p : Account_update.Simple.t), _) -> Account_id.( derive_token_id ~owner:(create p.body.public_key p.body.token_id)) ) |> accumulate_hashes - let of_parties_list (xs : (Party.Graphql_repr.t * 'a) list) : _ t = - of_parties_list_map - ~party_depth:(fun ((p : Party.Graphql_repr.t), _) -> p.body.call_depth) - ~f:(fun (p, x) -> (Party.of_graphql_repr p, x)) + let of_zkapp_command_list (xs : (Account_update.Graphql_repr.t * 'a) list) : + _ t = + of_zkapp_command_list_map + ~account_update_depth:(fun ((p : Account_update.Graphql_repr.t), _) -> + p.body.call_depth ) + ~f:(fun (p, x) -> (Account_update.of_graphql_repr p, x)) xs |> accumulate_hashes - let to_parties_list (x : _ t) = to_parties_list x + let to_zkapp_command_list (x : _ t) = to_zkapp_command_list x - let to_parties_with_hashes_list (x : _ t) = to_parties_with_hashes_list x + let to_zkapp_command_with_hashes_list (x : _ t) = + to_zkapp_command_with_hashes_list x - let other_parties_hash' xs = of_parties_list xs |> hash + let account_updates_hash' xs = of_zkapp_command_list xs |> hash - let other_parties_hash xs = - List.map ~f:(fun x -> (x, ())) xs |> other_parties_hash' + let account_updates_hash xs = + List.map ~f:(fun x -> (x, ())) xs |> account_updates_hash' end module With_hashes = struct @@ -756,8 +846,8 @@ module Call_forest = struct module Stable = struct module V1 = struct type t = - ( Party.Stable.V1.t - , Digest.Party.Stable.V1.t + ( Account_update.Stable.V1.t + , Digest.Account_update.Stable.V1.t , Digest.Forest.Stable.V1.t ) Stable.V1.t [@@deriving sexp, compare, equal, hash, yojson] @@ -768,38 +858,42 @@ module Call_forest = struct let empty = Digest.Forest.empty - let hash_party (p : Party.t) = Digest.Party.create p + let hash_account_update (p : Account_update.t) = + Digest.Account_update.create p - let accumulate_hashes xs : t = accumulate_hashes ~hash_party xs + let accumulate_hashes xs : t = accumulate_hashes ~hash_account_update xs - let of_parties_simple_list (xs : Party.Simple.t list) : t = - of_parties_list xs ~party_depth:(fun (p : Party.Simple.t) -> + let of_zkapp_command_simple_list (xs : Account_update.Simple.t list) : t = + of_zkapp_command_list xs + ~account_update_depth:(fun (p : Account_update.Simple.t) -> p.body.call_depth ) |> add_callers - ~call_type:(fun (p : Party.Simple.t) -> p.body.caller) + ~call_type:(fun (p : Account_update.Simple.t) -> p.body.caller) ~add_caller:(fun p id -> add_caller_simple p id) ~null_id:Token_id.default - ~party_id:(fun (p : Party.Simple.t) -> + ~account_update_id:(fun (p : Account_update.Simple.t) -> Account_id.( derive_token_id ~owner:(create p.body.public_key p.body.token_id)) ) |> accumulate_hashes - let of_parties_list (xs : Party.Graphql_repr.t list) : t = - of_parties_list_map - ~party_depth:(fun (p : Party.Graphql_repr.t) -> p.body.call_depth) - ~f:(fun p -> Party.of_graphql_repr p) + let of_zkapp_command_list (xs : Account_update.Graphql_repr.t list) : t = + of_zkapp_command_list_map + ~account_update_depth:(fun (p : Account_update.Graphql_repr.t) -> + p.body.call_depth ) + ~f:(fun p -> Account_update.of_graphql_repr p) xs |> accumulate_hashes - let to_parties_list (x : t) = to_parties_list x + let to_zkapp_command_list (x : t) = to_zkapp_command_list x - let to_parties_with_hashes_list (x : t) = to_parties_with_hashes_list x + let to_zkapp_command_with_hashes_list (x : t) = + to_zkapp_command_with_hashes_list x - let other_parties_hash' xs = of_parties_list xs |> hash + let account_updates_hash' xs = of_zkapp_command_list xs |> hash - let other_parties_hash xs = - List.map ~f:(fun x -> x) xs |> other_parties_hash' + let account_updates_hash xs = + List.map ~f:(fun x -> x) xs |> account_updates_hash' end let is_empty : _ t -> bool = List.is_empty @@ -818,8 +912,8 @@ module Graphql_repr = struct module Stable = struct module V1 = struct type t = - { fee_payer : Party.Fee_payer.Stable.V1.t - ; other_parties : Party.Graphql_repr.Stable.V1.t list + { fee_payer : Account_update.Fee_payer.Stable.V1.t + ; account_updates : Account_update.Graphql_repr.Stable.V1.t list ; memo : Signed_command_memo.Stable.V1.t } [@@deriving sexp, compare, equal, hash, yojson] @@ -835,8 +929,8 @@ module Simple = struct module Stable = struct module V1 = struct type t = - { fee_payer : Party.Fee_payer.Stable.V1.t - ; other_parties : Party.Simple.Stable.V1.t list + { fee_payer : Account_update.Fee_payer.Stable.V1.t + ; account_updates : Account_update.Simple.Stable.V1.t list ; memo : Signed_command_memo.Stable.V1.t } [@@deriving sexp, compare, equal, hash, yojson] @@ -852,11 +946,11 @@ module T = struct [%%versioned_binable module Stable = struct module V1 = struct - type t = Mina_wire_types.Mina_base.Parties.V1.t = - { fee_payer : Party.Fee_payer.Stable.V1.t - ; other_parties : - ( Party.Stable.V1.t - , Digest.Party.Stable.V1.t + type t = Mina_wire_types.Mina_base.Zkapp_command.V1.t = + { fee_payer : Account_update.Fee_payer.Stable.V1.t + ; account_updates : + ( Account_update.Stable.V1.t + , Digest.Account_update.Stable.V1.t , Digest.Forest.Stable.V1.t ) Call_forest.Stable.V1.t ; memo : Signed_command_memo.Stable.V1.t @@ -867,16 +961,19 @@ module T = struct let version_byte = Base58_check.Version_bytes.zkapp_command - let description = "Parties" + let description = "Zkapp_command" module Wire = struct [%%versioned module Stable = struct module V1 = struct type t = - { fee_payer : Party.Fee_payer.Stable.V1.t - ; other_parties : - (Party.Wire.Stable.V1.t, unit, unit) Call_forest.Stable.V1.t + { fee_payer : Account_update.Fee_payer.Stable.V1.t + ; account_updates : + ( Account_update.Wire.Stable.V1.t + , unit + , unit ) + Call_forest.Stable.V1.t ; memo : Signed_command_memo.Stable.V1.t } [@@deriving sexp, compare, equal, hash, yojson] @@ -886,37 +983,42 @@ module T = struct end] let check (t : t) : unit = - List.iter t.other_parties ~f:(fun p -> - assert (Party.Call_type.equal p.elt.party.body.caller Call) ) + List.iter t.account_updates ~f:(fun p -> + assert ( + Account_update.Call_type.equal p.elt.account_update.body.caller + Call ) ) let of_graphql_repr (t : Graphql_repr.t) : t = { fee_payer = t.fee_payer ; memo = t.memo - ; other_parties = - Call_forest.of_parties_list_map t.other_parties - ~f:Party.of_graphql_repr - ~party_depth:(fun (p : Party.Graphql_repr.t) -> - p.body.call_depth ) + ; account_updates = + Call_forest.of_zkapp_command_list_map t.account_updates + ~f:Account_update.of_graphql_repr + ~account_update_depth:(fun (p : Account_update.Graphql_repr.t) + -> p.body.call_depth ) |> Call_forest.remove_callers ~equal_id:Token_id.equal - ~map_party_digest:ignore ~map_stack_hash:ignore - ~add_call_type:Party.to_wire ~null_id:Token_id.default - ~party_caller:(fun p -> p.body.caller) + ~map_account_update_digest:ignore ~map_stack_hash:ignore + ~add_call_type:Account_update.to_wire + ~null_id:Token_id.default ~account_update_caller:(fun p -> + p.body.caller ) } let to_graphql_repr (t : t) : Graphql_repr.t = { fee_payer = t.fee_payer ; memo = t.memo - ; other_parties = - t.other_parties + ; account_updates = + t.account_updates |> Call_forest.add_callers - ~call_type:(fun (p : Party.Wire.t) -> p.body.caller) + ~call_type:(fun (p : Account_update.Wire.t) -> p.body.caller) ~add_caller ~null_id:Token_id.default - ~party_id:(fun (p : Party.Wire.t) -> + ~account_update_id:(fun (p : Account_update.Wire.t) -> Account_id.( derive_token_id ~owner:(create p.body.public_key p.body.token_id)) ) - |> Call_forest.to_parties_list_map ~f:(fun ~depth party -> - Party.to_graphql_repr party ~call_depth:depth ) + |> Call_forest.to_zkapp_command_list_map + ~f:(fun ~depth account_update -> + Account_update.to_graphql_repr account_update + ~call_depth:depth ) } let gen = @@ -927,67 +1029,73 @@ module T = struct fixed_point (fun self -> let%bind calls_length = small_non_negative_int in list_with_length calls_length - (let%map party = Party.Wire.gen and calls = self in + (let%map account_update = Account_update.Wire.gen + and calls = self in { With_stack_hash.stack_hash = () ; elt = - { Call_forest.Tree.party; party_digest = (); calls } + { Call_forest.Tree.account_update + ; account_update_digest = () + ; calls + } } ) ) in - (* All top level parties should be "Call" not "Delegate_call" *) + (* All top level zkapp_command should be "Call" not "Delegate_call" *) List.map xs ~f: (With_stack_hash.map - ~f:(fun (t : (Party.Wire.t, _, _) Call_forest.Tree.t) -> + ~f:(fun (t : (Account_update.Wire.t, _, _) Call_forest.Tree.t) + -> { t with - party = - { t.party with - body = { t.party.body with caller = Call } + account_update = + { t.account_update with + body = { t.account_update.body with caller = Call } } } ) ) in let open Quickcheck.Let_syntax in - let%map fee_payer = Party.Fee_payer.gen - and other_parties = gen_call_forest + let%map fee_payer = Account_update.Fee_payer.gen + and account_updates = gen_call_forest and memo = Signed_command_memo.gen in - { fee_payer; other_parties; memo } + { fee_payer; account_updates; memo } let shrinker : t Quickcheck.Shrinker.t = Quickcheck.Shrinker.create (fun t -> - let shape = Call_forest.shape t.other_parties in + let shape = Call_forest.shape t.account_updates in Sequence.map (Quickcheck.Shrinker.shrink Call_forest.Shape.quickcheck_shrinker shape ) ~f:(fun shape' -> { t with - other_parties = Call_forest.mask t.other_parties shape' + account_updates = Call_forest.mask t.account_updates shape' } ) ) end let of_wire (w : Wire.t) : t = { fee_payer = w.fee_payer ; memo = w.memo - ; other_parties = - w.other_parties + ; account_updates = + w.account_updates |> Call_forest.add_callers - ~call_type:(fun (p : Party.Wire.t) -> p.body.caller) + ~call_type:(fun (p : Account_update.Wire.t) -> p.body.caller) ~add_caller ~null_id:Token_id.default - ~party_id:(fun (p : Party.Wire.t) -> + ~account_update_id:(fun (p : Account_update.Wire.t) -> Account_id.( derive_token_id ~owner:(create p.body.public_key p.body.token_id)) ) - |> Call_forest.accumulate_hashes ~hash_party:(fun (p : Party.t) -> - Digest.Party.create p ) + |> Call_forest.accumulate_hashes + ~hash_account_update:(fun (p : Account_update.t) -> + Digest.Account_update.create p ) } let to_wire (t : t) : Wire.t = { fee_payer = t.fee_payer ; memo = t.memo - ; other_parties = + ; account_updates = Call_forest.remove_callers ~equal_id:Token_id.equal - ~map_party_digest:ignore ~map_stack_hash:ignore - ~add_call_type:Party.to_wire ~null_id:Token_id.default - ~party_caller:(fun p -> p.body.caller) - t.other_parties + ~map_account_update_digest:ignore ~map_stack_hash:ignore + ~add_call_type:Account_update.to_wire ~null_id:Token_id.default + ~account_update_caller:(fun p -> p.body.caller) + t.account_updates } include @@ -1011,28 +1119,30 @@ include T let of_simple (w : Simple.t) : t = { fee_payer = w.fee_payer ; memo = w.memo - ; other_parties = - Call_forest.of_parties_list w.other_parties - ~party_depth:(fun (p : Party.Simple.t) -> p.body.call_depth) + ; account_updates = + Call_forest.of_zkapp_command_list w.account_updates + ~account_update_depth:(fun (p : Account_update.Simple.t) -> + p.body.call_depth ) |> Call_forest.add_callers - ~call_type:(fun (p : Party.Simple.t) -> p.body.caller) + ~call_type:(fun (p : Account_update.Simple.t) -> p.body.caller) ~add_caller:add_caller_simple ~null_id:Token_id.default - ~party_id:(fun (p : Party.Simple.t) -> + ~account_update_id:(fun (p : Account_update.Simple.t) -> Account_id.( derive_token_id ~owner:(create p.body.public_key p.body.token_id)) ) - |> Call_forest.accumulate_hashes ~hash_party:(fun (p : Party.t) -> - Digest.Party.create p ) + |> Call_forest.accumulate_hashes + ~hash_account_update:(fun (p : Account_update.t) -> + Digest.Account_update.create p ) } let to_simple (t : t) : Simple.t = { fee_payer = t.fee_payer ; memo = t.memo - ; other_parties = + ; account_updates = Call_forest.remove_callers ~equal_id:Token_id.equal - ~map_party_digest:ignore ~map_stack_hash:ignore + ~map_account_update_digest:ignore ~map_stack_hash:ignore ~add_call_type:(fun { body = b; authorization } call_type -> - { Party.Simple.authorization + { Account_update.Simple.authorization ; body = { public_key = b.public_key ; token_id = b.token_id @@ -1049,9 +1159,10 @@ let to_simple (t : t) : Simple.t = } } ) ~null_id:Token_id.default - ~party_caller:(fun (p : Party.t) -> p.body.caller) - t.other_parties - |> Call_forest.to_parties_list_map ~f:(fun ~depth (p : Party.Simple.t) -> + ~account_update_caller:(fun (p : Account_update.t) -> p.body.caller) + t.account_updates + |> Call_forest.to_zkapp_command_list_map + ~f:(fun ~depth (p : Account_update.Simple.t) -> { p with body = { p.body with call_depth = depth } } ) } @@ -1065,40 +1176,41 @@ let%test_unit "wire embedded in graphql" = Quickcheck.test ~shrinker:Wire.shrinker Wire.gen ~f:(fun w -> [%test_eq: Wire.t] (Wire.of_graphql_repr (Wire.to_graphql_repr w)) w ) -let parties (t : t) : _ Call_forest.t = +let zkapp_command (t : t) : _ Call_forest.t = let p = t.fee_payer in - let body = Party.Body.of_fee_payer p.body in - let fee_payer : Party.t = + let body = Account_update.Body.of_fee_payer p.body in + let fee_payer : Account_update.t = let p = t.fee_payer in { authorization = Control.Signature p.authorization; body } in - Call_forest.cons fee_payer t.other_parties + Call_forest.cons fee_payer t.account_updates let fee (t : t) : Currency.Fee.t = t.fee_payer.body.fee -let fee_payer_party ({ fee_payer; _ } : t) = fee_payer +let fee_payer_account_update ({ fee_payer; _ } : t) = fee_payer let applicable_at_nonce (t : t) : Account.Nonce.t = - (fee_payer_party t).body.nonce + (fee_payer_account_update t).body.nonce let target_nonce_on_success (t : t) : Account.Nonce.t = let base_nonce = Account.Nonce.succ (applicable_at_nonce t) in let fee_payer_pubkey = t.fee_payer.body.public_key in - let fee_payer_party_increments = - List.count (Call_forest.to_list t.other_parties) ~f:(fun p -> + let fee_payer_account_update_increments = + List.count (Call_forest.to_list t.account_updates) ~f:(fun p -> Public_key.Compressed.equal p.body.public_key fee_payer_pubkey && p.body.increment_nonce ) in - Account.Nonce.add base_nonce (Account.Nonce.of_int fee_payer_party_increments) + Account.Nonce.add base_nonce + (Account.Nonce.of_int fee_payer_account_update_increments) let nonce_increments (t : t) : int Public_key.Compressed.Map.t = let base_increments = Public_key.Compressed.Map.of_alist_exn [ (t.fee_payer.body.public_key, 1) ] in - List.fold_left (Call_forest.to_list t.other_parties) ~init:base_increments - ~f:(fun incr_map party -> - if party.body.increment_nonce then - Map.update incr_map party.body.public_key + List.fold_left (Call_forest.to_list t.account_updates) ~init:base_increments + ~f:(fun incr_map account_update -> + if account_update.body.increment_nonce then + Map.update incr_map account_update.body.public_key ~f:(Option.value_map ~default:1 ~f:(( + ) 1)) else incr_map ) @@ -1107,12 +1219,12 @@ let fee_token (_t : t) = Token_id.default let fee_payer (t : t) = Account_id.create t.fee_payer.body.public_key (fee_token t) -let other_parties_list (t : t) : Party.t list = - Call_forest.fold t.other_parties ~init:[] ~f:(Fn.flip List.cons) |> List.rev +let account_updates_list (t : t) : Account_update.t list = + Call_forest.fold t.account_updates ~init:[] ~f:(Fn.flip List.cons) |> List.rev -let parties_list (t : t) : Party.t list = - Call_forest.fold t.other_parties - ~init:[ Party.of_fee_payer (fee_payer_party t) ] +let zkapp_command_list (t : t) : Account_update.t list = + Call_forest.fold t.account_updates + ~init:[ Account_update.of_fee_payer (fee_payer_account_update t) ] ~f:(Fn.flip List.cons) |> List.rev @@ -1120,9 +1232,9 @@ let fee_excess (t : t) = Fee_excess.of_single (fee_token t, Currency.Fee.Signed.of_unsigned (fee t)) let accounts_accessed (t : t) = - Call_forest.fold t.other_parties + Call_forest.fold t.account_updates ~init:[ fee_payer t ] - ~f:(fun acc p -> Party.account_id p :: acc) + ~f:(fun acc p -> Account_update.account_id p :: acc) |> List.rev |> List.stable_dedup let fee_payer_pk (t : t) = t.fee_payer.body.public_key @@ -1182,12 +1294,12 @@ module Virtual = struct let if_ = value_if end - module Parties = struct - type t = Party.t list + module Zkapp_command = struct + type t = Account_update.t list let if_ = value_if - type party = Party.t + type account_update = Account_update.t let empty = [] @@ -1202,8 +1314,8 @@ module Verifiable = struct module Stable = struct module V1 = struct type t = - { fee_payer : Party.Fee_payer.Stable.V1.t - ; other_parties : + { fee_payer : Account_update.Fee_payer.Stable.V1.t + ; account_updates : ( Side_loaded_verification_key.Stable.V2.t , Zkapp_basic.F.Stable.V1.t ) With_hash.Stable.V1.t @@ -1220,7 +1332,7 @@ end let of_verifiable (t : Verifiable.t) : t = { fee_payer = t.fee_payer - ; other_parties = Call_forest.map t.other_parties ~f:fst + ; account_updates = Call_forest.map t.account_updates ~f:fst ; memo = t.memo } @@ -1237,50 +1349,51 @@ module Transaction_commitment = struct let typ = Snark_params.Tick.Field.typ - let create ~(other_parties_hash : Digest.Forest.t) : t = - (other_parties_hash :> t) + let create ~(account_updates_hash : Digest.Forest.t) : t = + (account_updates_hash :> t) - let create_complete (t : t) ~memo_hash ~(fee_payer_hash : Digest.Party.t) = - Random_oracle.hash ~init:Hash_prefix.party_cons + let create_complete (t : t) ~memo_hash + ~(fee_payer_hash : Digest.Account_update.t) = + Random_oracle.hash ~init:Hash_prefix.account_update_cons [| memo_hash; (fee_payer_hash :> t); t |] module Checked = struct type t = Pickles.Impls.Step.Field.t - let create ~(other_parties_hash : Digest.Forest.Checked.t) = - (other_parties_hash :> t) + let create ~(account_updates_hash : Digest.Forest.Checked.t) = + (account_updates_hash :> t) let create_complete (t : t) ~memo_hash - ~(fee_payer_hash : Digest.Party.Checked.t) = - Random_oracle.Checked.hash ~init:Hash_prefix.party_cons + ~(fee_payer_hash : Digest.Account_update.Checked.t) = + Random_oracle.Checked.hash ~init:Hash_prefix.account_update_cons [| memo_hash; (fee_payer_hash :> t); t |] end end -let other_parties_hash (t : t) = Call_forest.hash t.other_parties +let account_updates_hash (t : t) = Call_forest.hash t.account_updates let commitment (t : t) : Transaction_commitment.t = - Transaction_commitment.create ~other_parties_hash:(other_parties_hash t) + Transaction_commitment.create ~account_updates_hash:(account_updates_hash t) -(** This module defines weights for each component of a `Parties.t` element. *) +(** This module defines weights for each component of a `Zkapp_command.t` element. *) module Weight = struct - let party : Party.t -> int = fun _ -> 1 + let account_update : Account_update.t -> int = fun _ -> 1 - let fee_payer (_fp : Party.Fee_payer.t) : int = 1 + let fee_payer (_fp : Account_update.Fee_payer.t) : int = 1 - let other_parties : (Party.t, _, _) Call_forest.t -> int = - Call_forest.fold ~init:0 ~f:(fun acc p -> acc + party p) + let account_updates : (Account_update.t, _, _) Call_forest.t -> int = + Call_forest.fold ~init:0 ~f:(fun acc p -> acc + account_update p) let memo : Signed_command_memo.t -> int = fun _ -> 0 end -let weight (parties : t) : int = - let { fee_payer; other_parties; memo } = parties in +let weight (zkapp_command : t) : int = + let { fee_payer; account_updates; memo } = zkapp_command in List.sum (module Int) ~f:Fn.id [ Weight.fee_payer fee_payer - ; Weight.other_parties other_parties + ; Weight.account_updates account_updates ; Weight.memo memo ] @@ -1299,7 +1412,7 @@ module type Valid_intf = sig module Stable : sig module V1 : sig type t = private - { parties : T.Stable.V1.t + { zkapp_command : T.Stable.V1.t ; verification_keys : (Account_id.Stable.V2.t * Verification_key_hash.Stable.V1.t) list } @@ -1324,7 +1437,7 @@ end module Valid : Valid_intf - with type Stable.V1.t = Mina_wire_types.Mina_base.Parties.Valid.V1.t = + with type Stable.V1.t = Mina_wire_types.Mina_base.Zkapp_command.Valid.V1.t = struct module S = Stable @@ -1343,8 +1456,8 @@ struct [%%versioned module Stable = struct module V1 = struct - type t = Mina_wire_types.Mina_base.Parties.Valid.V1.t = - { parties : S.V1.t + type t = Mina_wire_types.Mina_base.Zkapp_command.Valid.V1.t = + { zkapp_command : S.V1.t ; verification_keys : (Account_id.Stable.V2.t * Verification_key_hash.Stable.V1.t) list } @@ -1354,22 +1467,23 @@ struct end end] - let create ~verification_keys parties : t = { parties; verification_keys } + let create ~verification_keys zkapp_command : t = + { zkapp_command; verification_keys } let of_verifiable (t : Verifiable.t) : t option = let open Option.Let_syntax in let tbl = Account_id.Table.create () in let%map () = - Call_forest.fold t.other_parties ~init:(Some ()) + Call_forest.fold t.account_updates ~init:(Some ()) ~f:(fun acc (p, vk_opt) -> let%bind _ok = acc in - let account_id = Party.account_id p in + let account_id = Account_update.account_id p in if Control.(Tag.equal Tag.Proof (Control.tag p.authorization)) then let%map { With_hash.hash; _ } = vk_opt in Account_id.Table.update tbl account_id ~f:(fun _ -> hash) else acc ) in - { parties = of_verifiable t + { zkapp_command = of_verifiable t ; verification_keys = Account_id.Table.to_alist tbl } @@ -1378,7 +1492,7 @@ struct `If_this_is_used_it_should_have_a_comment_justifying_it (create t ~verification_keys:[]) - let forget (t : t) : T.t = t.parties + let forget (t : t) : T.t = t.zkapp_command let to_valid (t : T.t) ~ledger ~get ~location_of_account : t option = let open Option.Let_syntax in @@ -1390,9 +1504,9 @@ struct in let tbl = Account_id.Table.create () in let%map () = - Call_forest.fold t.other_parties ~init:(Some ()) ~f:(fun acc p -> + Call_forest.fold t.account_updates ~init:(Some ()) ~f:(fun acc p -> let%bind _ok = acc in - let account_id = Party.account_id p in + let account_id = Account_update.account_id p in if Control.(Tag.equal Tag.Proof (Control.tag p.authorization)) then Option.map (find_vk account_id) ~f:(fun vk -> Account_id.Table.update tbl account_id ~f:(fun _ -> @@ -1407,30 +1521,36 @@ include Codable.Make_base58_check (Stable.Latest) (* shadow the definitions from Make_base58_check *) [%%define_locally Stable.Latest.(of_yojson, to_yojson)] -type other_parties = (Party.t, Digest.Party.t, Digest.Forest.t) Call_forest.t +type account_updates = + (Account_update.t, Digest.Account_update.t, Digest.Forest.t) Call_forest.t -let other_parties_deriver obj = - let of_parties_with_depth (ps : Party.Graphql_repr.t list) : other_parties = - Call_forest.of_parties_list ps - ~party_depth:(fun (p : Party.Graphql_repr.t) -> p.body.call_depth) - |> Call_forest.map ~f:Party.of_graphql_repr +let account_updates_deriver obj = + let of_zkapp_command_with_depth (ps : Account_update.Graphql_repr.t list) : + account_updates = + Call_forest.of_zkapp_command_list ps + ~account_update_depth:(fun (p : Account_update.Graphql_repr.t) -> + p.body.call_depth ) + |> Call_forest.map ~f:Account_update.of_graphql_repr |> Call_forest.accumulate_hashes' - and to_parties_with_depth (ps : other_parties) : Party.Graphql_repr.t list = + and to_zkapp_command_with_depth (ps : account_updates) : + Account_update.Graphql_repr.t list = ps - |> Call_forest.to_parties_list_map ~f:(fun ~depth p -> - Party.to_graphql_repr ~call_depth:depth p ) + |> Call_forest.to_zkapp_command_list_map ~f:(fun ~depth p -> + Account_update.to_graphql_repr ~call_depth:depth p ) in let open Fields_derivers_zkapps.Derivers in - let inner = (list @@ Party.Graphql_repr.deriver @@ o ()) @@ o () in - iso ~map:of_parties_with_depth ~contramap:to_parties_with_depth inner obj + let inner = (list @@ Account_update.Graphql_repr.deriver @@ o ()) @@ o () in + iso ~map:of_zkapp_command_with_depth ~contramap:to_zkapp_command_with_depth + inner obj let deriver obj = let open Fields_derivers_zkapps.Derivers in let ( !. ) = ( !. ) ~t_fields_annots in - Fields.make_creator obj ~fee_payer:!.Party.Fee_payer.deriver - ~other_parties:!.other_parties_deriver + Fields.make_creator obj + ~fee_payer:!.Account_update.Fee_payer.deriver + ~account_updates:!.account_updates_deriver ~memo:!.Signed_command_memo.deriver - |> finish "Parties" ~t_toplevel_annots + |> finish "Zkapp_command" ~t_toplevel_annots let arg_typ () = Fields_derivers_zkapps.(arg_typ (deriver @@ Derivers.o ())) @@ -1440,30 +1560,35 @@ let to_json x = Fields_derivers_zkapps.(to_json (deriver @@ Derivers.o ())) x let of_json x = Fields_derivers_zkapps.(of_json (deriver @@ Derivers.o ())) x -let other_parties_of_json x = +let account_updates_of_json x = Fields_derivers_zkapps.( - of_json ((list @@ Party.Graphql_repr.deriver @@ o ()) @@ derivers ())) + of_json + ((list @@ Account_update.Graphql_repr.deriver @@ o ()) @@ derivers ())) x -let parties_to_json x = +let zkapp_command_to_json x = Fields_derivers_zkapps.(to_json (deriver @@ derivers ())) x let arg_query_string x = Fields_derivers_zkapps.Test.Loop.json_to_string_gql @@ to_json x let dummy = - let party : Party.t = - { body = Party.Body.dummy; authorization = Control.dummy_of_tag Signature } + let account_update : Account_update.t = + { body = Account_update.Body.dummy + ; authorization = Control.dummy_of_tag Signature + } in - let fee_payer : Party.Fee_payer.t = - { body = Party.Body.Fee_payer.dummy; authorization = Signature.dummy } + let fee_payer : Account_update.Fee_payer.t = + { body = Account_update.Body.Fee_payer.dummy + ; authorization = Signature.dummy + } in { fee_payer - ; other_parties = Call_forest.cons party [] + ; account_updates = Call_forest.cons account_update [] ; memo = Signed_command_memo.empty } -(* Parties transactions are filtered using this predicate +(* Zkapp_command transactions are filtered using this predicate - when adding to the transaction pool - in incoming blocks *) @@ -1471,56 +1596,63 @@ let valid_size ~(genesis_constants : Genesis_constants.t) t : unit Or_error.t = let events_elements events = List.fold events ~init:0 ~f:(fun acc event -> acc + Array.length event) in - let ( num_proof_parties - , num_parties + let ( num_proof_zkapp_command + , num_zkapp_command , num_event_elements , num_sequence_event_elements ) = - Call_forest.fold t.other_parties ~init:(0, 0, 0, 0) - ~f:(fun (num_proof_parties, num_parties, evs_size, seq_evs_size) party -> - let num_proof_parties' = - if Control.(Tag.equal (tag party.authorization) Tag.Proof) then - num_proof_parties + 1 - else num_proof_parties + Call_forest.fold t.account_updates ~init:(0, 0, 0, 0) + ~f:(fun + (num_proof_zkapp_command, num_zkapp_command, evs_size, seq_evs_size) + account_update + -> + let num_proof_zkapp_command' = + if Control.(Tag.equal (tag account_update.authorization) Tag.Proof) + then num_proof_zkapp_command + 1 + else num_proof_zkapp_command in - let party_evs_elements = events_elements party.body.events in - let party_seq_evs_elements = - events_elements party.body.sequence_events + let account_update_evs_elements = + events_elements account_update.body.events in - ( num_proof_parties' - , num_parties + 1 - , evs_size + party_evs_elements - , seq_evs_size + party_seq_evs_elements ) ) + let account_update_seq_evs_elements = + events_elements account_update.body.sequence_events + in + ( num_proof_zkapp_command' + , num_zkapp_command + 1 + , evs_size + account_update_evs_elements + , seq_evs_size + account_update_seq_evs_elements ) ) in - let max_proof_parties = genesis_constants.max_proof_parties in - let max_parties = genesis_constants.max_parties in + let max_proof_zkapp_command = genesis_constants.max_proof_zkapp_command in + let max_zkapp_command = genesis_constants.max_zkapp_command in let max_event_elements = genesis_constants.max_event_elements in let max_sequence_event_elements = genesis_constants.max_sequence_event_elements in - let valid_proof_parties = num_proof_parties <= max_proof_parties in - let valid_parties = num_parties <= max_parties in + let valid_proof_zkapp_command = + num_proof_zkapp_command <= max_proof_zkapp_command + in + let valid_zkapp_command = num_zkapp_command <= max_zkapp_command in let valid_event_elements = num_event_elements <= max_event_elements in let valid_sequence_event_elements = num_sequence_event_elements <= max_sequence_event_elements in if - valid_proof_parties && valid_parties && valid_event_elements + valid_proof_zkapp_command && valid_zkapp_command && valid_event_elements && valid_sequence_event_elements then Ok () else - let proof_parties_err = - if valid_proof_parties then None + let proof_zkapp_command_err = + if valid_proof_zkapp_command then None else Some - (sprintf "too many proof parties (%d, max allowed is %d)" - num_proof_parties max_proof_parties ) + (sprintf "too many proof zkapp_command (%d, max allowed is %d)" + num_proof_zkapp_command max_proof_zkapp_command ) in - let parties_err = - if valid_parties then None + let zkapp_command_err = + if valid_zkapp_command then None else Some - (sprintf "too many parties (%d, max allowed is %d)" num_parties - max_parties ) + (sprintf "too many zkapp_command (%d, max allowed is %d)" + num_zkapp_command max_zkapp_command ) in let events_err = if valid_event_elements then None @@ -1538,7 +1670,11 @@ let valid_size ~(genesis_constants : Genesis_constants.t) t : unit Or_error.t = in let err_msg = List.filter - [ proof_parties_err; parties_err; events_err; sequence_events_err ] + [ proof_zkapp_command_err + ; zkapp_command_err + ; events_err + ; sequence_events_err + ] ~f:Option.is_some |> List.map ~f:(fun opt -> Option.value_exn opt) |> String.concat ~sep:"; " diff --git a/src/lib/mina_base/zkapp_statement.ml b/src/lib/mina_base/zkapp_statement.ml index f5c2080982c..84b9aff2d34 100644 --- a/src/lib/mina_base/zkapp_statement.ml +++ b/src/lib/mina_base/zkapp_statement.ml @@ -12,7 +12,7 @@ module Poly = struct [%%versioned module Stable = struct module V1 = struct - type 'comm t = { party : 'comm; calls : 'comm } + type 'comm t = { account_update : 'comm; calls : 'comm } [@@deriving hlist, sexp, yojson] end end] @@ -25,7 +25,7 @@ end [%%versioned module Stable = struct module V2 = struct - type t = Parties.Transaction_commitment.Stable.V1.t Poly.Stable.V1.t + type t = Zkapp_command.Transaction_commitment.Stable.V1.t Poly.Stable.V1.t [@@deriving sexp, yojson] let to_latest = Fn.id @@ -34,32 +34,36 @@ end] let to_field_elements : t -> _ = Poly.to_field_elements -let of_tree (type party) - ({ party = _; party_digest; calls } : - ( party - , Parties.Digest.Party.t - , Parties.Digest.Forest.t ) - Parties.Call_forest.Tree.t ) : t = - { Poly.party = (party_digest :> Parties.Transaction_commitment.t) - ; calls = (Parties.Call_forest.hash calls :> Parties.Transaction_commitment.t) +let of_tree (type account_update) + ({ account_update = _; account_update_digest; calls } : + ( account_update + , Zkapp_command.Digest.Account_update.t + , Zkapp_command.Digest.Forest.t ) + Zkapp_command.Call_forest.Tree.t ) : t = + { account_update = + (account_update_digest :> Zkapp_command.Transaction_commitment.t) + ; calls = + ( Zkapp_command.Call_forest.hash calls + :> Zkapp_command.Transaction_commitment.t ) } let zkapp_statements_of_forest' (type data) - (forest : data Parties.Call_forest.With_hashes_and_data.t) : - (data * t) Parties.Call_forest.With_hashes_and_data.t = - Parties.Call_forest.mapi_with_trees forest ~f:(fun _i (party, data) tree -> - (party, (data, of_tree tree)) ) - -let zkapp_statements_of_forest (type party) - (forest : (party, _, _) Parties.Call_forest.t) : - (party * t, _, _) Parties.Call_forest.t = - Parties.Call_forest.mapi_with_trees forest ~f:(fun _i party tree -> - (party, of_tree tree) ) + (forest : data Zkapp_command.Call_forest.With_hashes_and_data.t) : + (data * t) Zkapp_command.Call_forest.With_hashes_and_data.t = + Zkapp_command.Call_forest.mapi_with_trees forest + ~f:(fun _i (account_update, data) tree -> + (account_update, (data, of_tree tree)) ) + +let zkapp_statements_of_forest (type account_update) + (forest : (account_update, _, _) Zkapp_command.Call_forest.t) : + (account_update * t, _, _) Zkapp_command.Call_forest.t = + Zkapp_command.Call_forest.mapi_with_trees forest + ~f:(fun _i account_update tree -> (account_update, of_tree tree)) [%%ifdef consensus_mechanism] module Checked = struct - type t = Parties.Transaction_commitment.Checked.t Poly.t + type t = Zkapp_command.Transaction_commitment.Checked.t Poly.t let to_field_elements : t -> _ = Poly.to_field_elements @@ -75,7 +79,7 @@ end let typ = let open Poly in Typ.of_hlistable - Parties.Transaction_commitment.[ typ; typ ] + Zkapp_command.Transaction_commitment.[ typ; typ ] ~var_to_hlist:to_hlist ~var_of_hlist:of_hlist ~value_to_hlist:to_hlist ~value_of_hlist:of_hlist diff --git a/src/lib/mina_block/sample_precomputed_block.ml b/src/lib/mina_block/sample_precomputed_block.ml index c0f684c23ff..2f4fd867819 100644 --- a/src/lib/mina_block/sample_precomputed_block.ml +++ b/src/lib/mina_block/sample_precomputed_block.ml @@ -42,7 +42,7 @@ let sample_block_sexp = (token_id 0x0000000000000000000000000000000000000000000000000000000000000001) (excess ((magnitude 0) (sgn Pos))) (ledger 0) (success true) - (party_index 0) + (account_update_index 0) (failure_status_tbl ()))))) (timestamp 1655382227041) (body_reference @@ -497,7 +497,7 @@ let sample_block_json = }, "ledger": "jw6bz2wud1N6itRUHZ5ypo3267stk4UgzkiuWtAMPRZo9g4Udyd", "success": true, - "party_index": "0", + "account_update_index": "0", "failure_status_tbl": [] } }, diff --git a/src/lib/mina_commands/mina_commands.ml b/src/lib/mina_commands/mina_commands.ml index a592bd78e71..9bb4266a496 100644 --- a/src/lib/mina_commands/mina_commands.ml +++ b/src/lib/mina_commands/mina_commands.ml @@ -119,12 +119,12 @@ let setup_and_submit_user_commands t user_command_list = [ ("mina_command", `String "scheduling a batch of user transactions") ] ; Mina_lib.add_transactions t user_command_list -let setup_and_submit_snapp_command t (parties : Parties.t) = +let setup_and_submit_snapp_command t (zkapp_command : Zkapp_command.t) = let open Participating_state.Let_syntax in (* hack to get types to work out *) let%map () = return () in let open Deferred.Let_syntax in - let%map result = Mina_lib.add_zkapp_transactions t [ parties ] in + let%map result = Mina_lib.add_zkapp_transactions t [ zkapp_command ] in txn_count := !txn_count + 1 ; match result with | Ok (_, [], [ failed_txn ]) -> @@ -134,9 +134,9 @@ let setup_and_submit_snapp_command t (parties : Parties.t) = ( Network_pool.Transaction_pool.Resource_pool.Diff.Diff_error .to_yojson (snd failed_txn) |> Yojson.Safe.to_string ) ) ) - | Ok (`Broadcasted, [ User_command.Parties txn ], []) -> + | Ok (`Broadcasted, [ User_command.Zkapp_command txn ], []) -> [%log' info (Mina_lib.top_level_logger t)] - ~metadata:[ ("zkapp_command", Parties.to_yojson txn) ] + ~metadata:[ ("zkapp_command", Zkapp_command.to_yojson txn) ] "Scheduled zkApp $zkapp_command" ; Ok txn | Ok (decision, valid_commands, invalid_commands) -> @@ -179,15 +179,15 @@ module Receipt_chain_verifier = Merkle_list_verifier.Make (struct (Signed_command.payload cmd) in Receipt.Chain_hash.cons_signed_command_payload elt parent_hash - | Parties _parties -> + | Zkapp_command _zkapp_command -> failwith "Not implemented for zkApps" - (* TODO: apply cons_parties_commitment operation for all occurrences of fee payer + (* TODO: apply cons_zkapp_command_commitment operation for all occurrences of fee payer issue #11495 - let elt = Receipt.Parties_elt.Parties_commitment (Parties.commitment parties) in + let elt = Receipt.Zkapp_command_elt.Zkapp_command_commitment (Zkapp_command.commitment zkapp_command) in let fee_payer_index = Mina_numbers.Index.zero in - Receipt.Chain_hash.cons_parties_commitment fee_payer_index elt parent_hash *) + Receipt.Chain_hash.cons_zkapp_command_commitment fee_payer_index elt parent_hash *) end) [%%inject "compile_time_current_protocol_version", current_protocol_version] diff --git a/src/lib/mina_compile_config/mina_compile_config.ml b/src/lib/mina_compile_config/mina_compile_config.ml index 68fbe732057..19dbac23eaa 100644 --- a/src/lib/mina_compile_config/mina_compile_config.ml +++ b/src/lib/mina_compile_config/mina_compile_config.ml @@ -51,11 +51,11 @@ let rpc_heartbeat_send_every_sec = 10.0 (*same as the default*) let transaction_expiry_hr = 2 -(* limits on Parties.t size *) +(* limits on Zkapp_command.t size *) -let max_proof_parties = 4 +let max_proof_zkapp_command = 4 -let max_parties = 8 +let max_zkapp_command = 8 let max_event_elements = 16 diff --git a/src/lib/mina_generators/dune b/src/lib/mina_generators/dune index 24a8883e81c..4300b051d38 100644 --- a/src/lib/mina_generators/dune +++ b/src/lib/mina_generators/dune @@ -23,7 +23,7 @@ kimchi_backend.pasta mina_numbers mina_compile_config - parties_builder + zkapp_command_builder signature_lib mina_ledger mina_base diff --git a/src/lib/mina_generators/user_command_generators.ml b/src/lib/mina_generators/user_command_generators.ml index 363efe074f6..2bb82e83720 100644 --- a/src/lib/mina_generators/user_command_generators.ml +++ b/src/lib/mina_generators/user_command_generators.ml @@ -1,7 +1,7 @@ (* user_command_generators.ml *) (* generate User_command.t's, that is, either Signed_commands or - Parties + Zkapp_command *) [%%import "/src/config.mlh"] @@ -14,22 +14,23 @@ include User_command.Gen (* using Precomputed_values depth introduces a cyclic dependency *) [%%inject "ledger_depth", ledger_depth] -let parties_with_ledger ?num_keypairs ?max_other_parties ?account_state_tbl ?vk - ?failure () = +let zkapp_command_with_ledger ?num_keypairs ?max_account_updates + ?account_state_tbl ?vk ?failure () = let open Quickcheck.Let_syntax in let open Signature_lib in (* Need a fee payer keypair, a keypair for the "balancing" account (so that the balance changes - sum to zero), and max_other_parties * 2 keypairs, because all the other parties + sum to zero), and max_account_updates * 2 keypairs, because all the other zkapp_command might be new and their accounts not in the ledger; or they might all be old and in the ledger - We'll put the fee payer account and max_other_parties accounts in the - ledger, and have max_other_parties keypairs available for new accounts + We'll put the fee payer account and max_account_updates accounts in the + ledger, and have max_account_updates keypairs available for new accounts *) - let max_other_parties = - Option.value max_other_parties ~default:Parties_generators.max_other_parties + let max_account_updates = + Option.value max_account_updates + ~default:Zkapp_command_generators.max_account_updates in let num_keypairs = - Option.value num_keypairs ~default:((max_other_parties * 2) + 2) + Option.value num_keypairs ~default:((max_account_updates * 2) + 2) in let keypairs = List.init num_keypairs ~f:(fun _ -> Keypair.create ()) in let keymap = @@ -69,7 +70,7 @@ let parties_with_ledger ?num_keypairs ?max_other_parties ?account_state_tbl ?vk (Currency.Balance.to_amount max_bal) with | None -> - failwith "parties_with_ledger: overflow for max_balance" + failwith "zkapp_command_with_ledger: overflow for max_balance" | Some _ -> max_bal in @@ -109,11 +110,12 @@ let parties_with_ledger ?num_keypairs ?max_other_parties ?account_state_tbl ?vk match Ledger.get_or_create_account ledger acct_id acct with | Error err -> failwithf - "parties: error adding account for account id: %s, error: %s@." + "zkapp_command: error adding account for account id: %s, error: \ + %s@." (Account_id.to_yojson acct_id |> Yojson.Safe.to_string) (Error.to_string_hum err) () | Ok (`Existed, _) -> - failwithf "parties: account for account id already exists: %s@." + failwithf "zkapp_command: account for account id already exists: %s@." (Account_id.to_yojson acct_id |> Yojson.Safe.to_string) () | Ok (`Added, _) -> @@ -122,19 +124,21 @@ let parties_with_ledger ?num_keypairs ?max_other_parties ?account_state_tbl ?vk let account_state_tbl = Option.value account_state_tbl ~default:(Account_id.Table.create ()) in - let%bind parties = - Parties_generators.gen_parties_from ~max_other_parties ~fee_payer_keypair - ~keymap ~ledger ~account_state_tbl ?vk ?failure () + let%bind zkapp_command = + Zkapp_command_generators.gen_zkapp_command_from ~max_account_updates + ~fee_payer_keypair ~keymap ~ledger ~account_state_tbl ?vk ?failure () in - let parties = + let zkapp_command = Option.value_exn - (Parties.Valid.to_valid ~ledger ~get:Ledger.get - ~location_of_account:Ledger.location_of_account parties ) + (Zkapp_command.Valid.to_valid ~ledger ~get:Ledger.get + ~location_of_account:Ledger.location_of_account zkapp_command ) in (* include generated ledger in result *) - return (User_command.Parties parties, fee_payer_keypair, keymap, ledger) + return + (User_command.Zkapp_command zkapp_command, fee_payer_keypair, keymap, ledger) -let sequence_parties_with_ledger ?max_other_parties ?length ?vk ?failure () = +let sequence_zkapp_command_with_ledger ?max_account_updates ?length ?vk ?failure + () = let open Quickcheck.Let_syntax in let%bind length = match length with @@ -143,36 +147,39 @@ let sequence_parties_with_ledger ?max_other_parties ?length ?vk ?failure () = | None -> Quickcheck.Generator.small_non_negative_int in - let max_other_parties = - Option.value max_other_parties ~default:Parties_generators.max_other_parties + let max_account_updates = + Option.value max_account_updates + ~default:Zkapp_command_generators.max_account_updates in - let num_keypairs = length * max_other_parties * 2 in - (* Keep track of account states across multiple parties transaction *) + let num_keypairs = length * max_account_updates * 2 in + (* Keep track of account states across multiple zkapp_command transaction *) let account_state_tbl = Account_id.Table.create () in - let%bind parties, fee_payer_keypair, keymap, ledger = - parties_with_ledger ~num_keypairs ~max_other_parties ~account_state_tbl ?vk - ?failure () + let%bind zkapp_command, fee_payer_keypair, keymap, ledger = + zkapp_command_with_ledger ~num_keypairs ~max_account_updates + ~account_state_tbl ?vk ?failure () in - let rec go parties_and_fee_payer_keypairs n = + let rec go zkapp_command_and_fee_payer_keypairs n = if n <= 1 then return - ( (parties, fee_payer_keypair, keymap) - :: List.rev parties_and_fee_payer_keypairs + ( (zkapp_command, fee_payer_keypair, keymap) + :: List.rev zkapp_command_and_fee_payer_keypairs , ledger ) else - let%bind parties = - Parties_generators.gen_parties_from ~max_other_parties + let%bind zkapp_command = + Zkapp_command_generators.gen_zkapp_command_from ~max_account_updates ~fee_payer_keypair ~keymap ~ledger ~account_state_tbl ?vk ?failure () in - let valid_parties = + let valid_zkapp_command = Option.value_exn - (Parties.Valid.to_valid ~ledger ~get:Ledger.get - ~location_of_account:Ledger.location_of_account parties ) + (Zkapp_command.Valid.to_valid ~ledger ~get:Ledger.get + ~location_of_account:Ledger.location_of_account zkapp_command ) in - let parties_and_fee_payer_keypairs' = - (User_command.Parties valid_parties, fee_payer_keypair, keymap) - :: parties_and_fee_payer_keypairs + let zkapp_command_and_fee_payer_keypairs' = + ( User_command.Zkapp_command valid_zkapp_command + , fee_payer_keypair + , keymap ) + :: zkapp_command_and_fee_payer_keypairs in - go parties_and_fee_payer_keypairs' (n - 1) + go zkapp_command_and_fee_payer_keypairs' (n - 1) in go [] length diff --git a/src/lib/mina_generators/parties_generators.ml b/src/lib/mina_generators/zkapp_command_generators.ml similarity index 83% rename from src/lib/mina_generators/parties_generators.ml rename to src/lib/mina_generators/zkapp_command_generators.ml index 2be0d922129..6f2c36862fe 100644 --- a/src/lib/mina_generators/parties_generators.ml +++ b/src/lib/mina_generators/zkapp_command_generators.ml @@ -1,4 +1,4 @@ -(* parties_generators -- Quickcheck generators for zkApp transactions *) +(* zkapp_command_generators -- Quickcheck generators for zkApp transactions *) open Core_kernel open Mina_base @@ -114,7 +114,7 @@ let gen_account_precondition_from_account ?failure ~first_use_of_account account in let proved_state = Or_ignore.Check proved_state in let is_new = - (* when we apply the generated Parties.t, the account is always in the ledger + (* when we apply the generated Zkapp_command.t, the account is always in the ledger *) Or_ignore.Check false in @@ -214,17 +214,19 @@ let gen_account_precondition_from_account ?failure ~first_use_of_account account in return { predicate_account with proved_state } in - return (Party.Account_precondition.Full faulty_predicate_account) + return + (Account_update.Account_precondition.Full faulty_predicate_account) | _ -> - return (Party.Account_precondition.Full predicate_account) + return (Account_update.Account_precondition.Full predicate_account) else (* Nonce *) let { Account.Poly.nonce; _ } = account in match failure with | Some Invalid_account_precondition -> - return (Party.Account_precondition.Nonce (Account.Nonce.succ nonce)) + return + (Account_update.Account_precondition.Nonce (Account.Nonce.succ nonce)) | _ -> - return (Party.Account_precondition.Nonce nonce) + return (Account_update.Account_precondition.Nonce nonce) let gen_fee (account : Account.t) = let balance = account.balance in @@ -262,7 +264,7 @@ let gen_balance_change ?permissions_auth (account : Account.t) ~new_account = *) let effective_balance = account.balance in let small_balance_change = - (*make small transfers to allow generating large number of parties without an overflow*) + (*make small transfers to allow generating large number of zkapp_command without an overflow*) let open Currency in if Balance.(effective_balance < of_formatted_string "1.0") && not new_account @@ -291,7 +293,7 @@ let gen_use_full_commitment ~increment_nonce ~account_precondition increment_nonce && Zkapp_precondition.Numeric.is_constant Zkapp_precondition.Numeric.Tc.nonce - (Party.Account_precondition.to_full account_precondition) + (Account_update.Account_precondition.to_full account_precondition) .Zkapp_precondition.Account.nonce in let does_not_use_a_signature = @@ -598,7 +600,7 @@ let gen_invalid_protocol_state_precondition Zkapp_basic.Or_ignore.Check global_slot_since_genesis } -module Party_body_components = struct +module Account_update_body_components = struct type ( 'pk , 'update , 'token_id @@ -626,7 +628,7 @@ module Party_body_components = struct ; caller : 'caller } - let to_fee_payer t : Party.Body.Fee_payer.t = + let to_fee_payer t : Account_update.Body.Fee_payer.t = { public_key = t.public_key ; fee = t.balance_change ; valid_until = @@ -642,7 +644,7 @@ module Party_body_components = struct ; nonce = t.account_precondition } - let to_typical_party t : Party.Body.Simple.t = + let to_typical_account_update t : Account_update.Body.Simple.t = { public_key = t.public_key ; update = t.update ; token_id = t.token_id @@ -653,7 +655,7 @@ module Party_body_components = struct ; call_data = t.call_data ; call_depth = t.call_depth ; preconditions = - { Party.Preconditions.network = t.protocol_state_precondition + { Account_update.Preconditions.network = t.protocol_state_precondition ; account = t.account_precondition } ; use_full_commitment = t.use_full_commitment @@ -662,30 +664,31 @@ module Party_body_components = struct end (* The type `a` is associated with the `delta` field, which is an unsigned fee - for the fee payer, and a signed amount for other parties. + for the fee payer, and a signed amount for other zkapp_command. The type `b` is associated with the `use_full_commitment` field, which is - `unit` for the fee payer, and `bool` for other parties. + `unit` for the fee payer, and `bool` for other zkapp_command. The type `c` is associated with the `token_id` field, which is `unit` for the - fee payer, and `Token_id.t` for other parties. + fee payer, and `Token_id.t` for other zkapp_command. The type `d` is associated with the `account_precondition` field, which is - a nonce for the fee payer, and `Account_precondition.t` for other parties + a nonce for the fee payer, and `Account_precondition.t` for other zkapp_command *) -let gen_party_body_components (type a b c d) ?(update = None) ?account_id - ?account_ids_seen ~account_state_tbl ?vk ?failure ?(new_account = false) - ?(zkapp_account = false) ?(is_fee_payer = false) ?available_public_keys - ?permissions_auth ?(required_balance_change : a option) ?protocol_state_view +let gen_account_update_body_components (type a b c d) ?(update = None) + ?account_id ?account_ids_seen ~account_state_tbl ?vk ?failure + ?(new_account = false) ?(zkapp_account = false) ?(is_fee_payer = false) + ?available_public_keys ?permissions_auth + ?(required_balance_change : a option) ?protocol_state_view ~zkapp_account_ids ~(gen_balance_change : Account.t -> a Quickcheck.Generator.t) ~(gen_use_full_commitment : - account_precondition:Party.Account_precondition.t + account_precondition:Account_update.Account_precondition.t -> b Quickcheck.Generator.t ) ~(f_balance_change : a -> Currency.Amount.Signed.t) ~(increment_nonce : b * bool) ~(f_token_id : Token_id.t -> c) ~(f_account_precondition : first_use_of_account:bool -> Account.t -> d Quickcheck.Generator.t ) - ~(f_party_account_precondition : d -> Party.Account_precondition.t) - ~authorization_tag () : - (_, _, _, a, _, _, _, b, _, d, _) Party_body_components.t + ~(f_account_update_account_precondition : + d -> Account_update.Account_precondition.t ) ~authorization_tag () : + (_, _, _, a, _, _, _, b, _, d, _) Account_update_body_components.t Quickcheck.Generator.t = let open Quickcheck.Let_syntax in (* fee payers have to be in the ledger *) @@ -693,12 +696,12 @@ let gen_party_body_components (type a b c d) ?(update = None) ?account_id let%bind update = match update with | None -> - Party.Update.gen ?permissions_auth ?vk ~zkapp_account () + Account_update.Update.gen ?permissions_auth ?vk ~zkapp_account () | Some update -> return update in - (* party_increment_nonce for fee payer is unit and increment_nonce is true *) - let party_increment_nonce, increment_nonce = increment_nonce in + (* account_update_increment_nonce for fee payer is unit and increment_nonce is true *) + let account_update_increment_nonce, increment_nonce = increment_nonce in let verification_key = Option.value vk ~default: @@ -711,20 +714,20 @@ let gen_party_body_components (type a b c d) ?(update = None) ?account_id if new_account then ( if Option.is_some account_id then failwith - "gen_party_body: new party is true, but an account id, presumably \ - from an existing account, was supplied" ; + "gen_account_update_body: new account_update is true, but an account \ + id, presumably from an existing account, was supplied" ; match available_public_keys with | None -> failwith - "gen_party_body: new_account is true, but available_public_keys \ - not provided" + "gen_account_update_body: new_account is true, but \ + available_public_keys not provided" | Some available_pks -> let available_pk = match Signature_lib.Public_key.Compressed.Table.choose available_pks with | None -> - failwith "gen_party_body: no available public keys" + failwith "gen_account_update_body: no available public keys" | Some (pk, ()) -> pk in @@ -756,11 +759,11 @@ let gen_party_body_components (type a b c d) ?(update = None) ?account_id in match Account_id.Table.find account_state_tbl zkapp_account_id with | None -> - failwith "gen_party_body: fail to find zkapp account" + failwith "gen_account_update_body: fail to find zkapp account" | Some (_, `Fee_payer) | Some (_, `New_account) -> failwith - "gen_party_body: all zkapp accounts were new accounts or \ - used as fee_payer accounts" + "gen_account_update_body: all zkapp accounts were new \ + accounts or used as fee_payer accounts" | Some (acct, `Ordinary_participant) -> acct else @@ -773,8 +776,8 @@ let gen_party_body_components (type a b c d) ?(update = None) ?account_id | Control.Tag.Proof, `New_account -> false | _, `New_account -> - (* `required_balance_change` is only for balancing party. Newly created account - should not be used in balancing party *) + (* `required_balance_change` is only for balancing account_update. Newly created account + should not be used in balancing account_update *) Option.is_none required_balance_change | _, `Ordinary_participant -> true ) @@ -787,7 +790,8 @@ let gen_party_body_components (type a b c d) ?(update = None) ?account_id Account_id.Table.find_exn account_state_tbl account_id |> fst in if zkapp_account && Option.is_none acct.zkapp then - failwith "gen_party_body: provided account has no zkapp field" ; + failwith + "gen_account_update_body: provided account has no zkapp field" ; return acct in let public_key = account.public_key in @@ -823,17 +827,17 @@ let gen_party_body_components (type a b c d) ?(update = None) ?account_id (* fee payer *) true | Some hash_set -> - (* other partys *) + (* other account_updates *) not @@ Hash_set.mem hash_set account_id in let%bind account_precondition = f_account_precondition ~first_use_of_account account in - (* update the depth when generating `other_parties` in Parties.t *) + (* update the depth when generating `account_updates` in Zkapp_command.t *) let call_depth = 0 in let%bind use_full_commitment = let full_account_precondition = - f_party_account_precondition account_precondition + f_account_update_account_precondition account_precondition in gen_use_full_commitment ~account_precondition:full_account_precondition in @@ -846,7 +850,7 @@ let gen_party_body_components (type a b c d) ?(update = None) ?account_id | _ -> gen_protocol_state_precondition ) ~default:(return Zkapp_precondition.Protocol_state.accept) - and caller = Party.Call_type.quickcheck_generator in + and caller = Account_update.Call_type.quickcheck_generator in let token_id = f_token_id token_id in (* update account state table with all the changes*) (let add_balance_and_balance_change balance @@ -953,7 +957,7 @@ let gen_party_body_components (type a b c d) ?(update = None) ?account_id ; zkapp = zkapp updated_account } , role ) ) ) ; - { Party_body_components.public_key + { Account_update_body_components.public_key ; update = ( if new_account then { update with @@ -962,7 +966,7 @@ let gen_party_body_components (type a b c d) ?(update = None) ?account_id else update ) ; token_id ; balance_change - ; increment_nonce = party_increment_nonce + ; increment_nonce = account_update_increment_nonce ; events ; sequence_events ; call_data @@ -973,7 +977,7 @@ let gen_party_body_components (type a b c d) ?(update = None) ?account_id ; caller } -let gen_party_from ?(update = None) ?failure ?(new_account = false) +let gen_account_update_from ?(update = None) ?failure ?(new_account = false) ?(zkapp_account = false) ?account_id ?permissions_auth ?required_balance_change ~zkapp_account_ids ~authorization ~account_ids_seen ~available_public_keys ~account_state_tbl ?protocol_state_view ?vk () = @@ -993,7 +997,8 @@ let gen_party_from ?(update = None) ?failure ?(new_account = false) false in let%bind body_components = - gen_party_body_components ~update ?failure ~new_account ~zkapp_account + gen_account_update_body_components ~update ?failure ~new_account + ~zkapp_account ~increment_nonce:(increment_nonce, increment_nonce) ?permissions_auth ?account_id ?protocol_state_view ?vk ~zkapp_account_ids ~account_ids_seen ~available_public_keys ?required_balance_change @@ -1002,27 +1007,29 @@ let gen_party_from ?(update = None) ?failure ?(new_account = false) ~f_balance_change:Fn.id () ~f_token_id:Fn.id ~f_account_precondition:(fun ~first_use_of_account acct -> gen_account_precondition_from_account ~first_use_of_account acct ) - ~f_party_account_precondition:Fn.id + ~f_account_update_account_precondition:Fn.id ~gen_use_full_commitment:(fun ~account_precondition -> gen_use_full_commitment ~increment_nonce ~account_precondition ~authorization () ) ~authorization_tag:(Control.tag authorization) in - let body = Party_body_components.to_typical_party body_components in + let body = + Account_update_body_components.to_typical_account_update body_components + in let account_id = Account_id.create body.public_key body.token_id in Hash_set.add account_ids_seen account_id ; - return { Party.Simple.body; authorization } + return { Account_update.Simple.body; authorization } (* takes an account id, if we want to sign this data *) -let gen_party_body_fee_payer ?failure ?permissions_auth ~account_id ?vk +let gen_account_update_body_fee_payer ?failure ?permissions_auth ~account_id ?vk ?protocol_state_view ~account_state_tbl () : - Party.Body.Fee_payer.t Quickcheck.Generator.t = + Account_update.Body.Fee_payer.t Quickcheck.Generator.t = let open Quickcheck.Let_syntax in let account_precondition_gen (account : Account.t) = Quickcheck.Generator.return account.nonce in let%map body_components = - gen_party_body_components ?failure ?permissions_auth ~account_id + gen_account_update_body_components ?failure ?permissions_auth ~account_id ~account_state_tbl ?vk ~zkapp_account_ids:[] ~is_fee_payer:true ~increment_nonce:((), true) ~gen_balance_change:gen_fee ~f_balance_change:fee_to_amt @@ -1034,36 +1041,37 @@ let gen_party_body_fee_payer ?failure ?permissions_auth ~account_id ?vk () ) ~f_account_precondition:(fun ~first_use_of_account:_ acct -> account_precondition_gen acct ) - ~f_party_account_precondition:(fun nonce -> Nonce nonce) + ~f_account_update_account_precondition:(fun nonce -> Nonce nonce) ~gen_use_full_commitment:(fun ~account_precondition:_ -> return ()) ?protocol_state_view ~authorization_tag:Control.Tag.Signature () in - Party_body_components.to_fee_payer body_components + Account_update_body_components.to_fee_payer body_components let gen_fee_payer ?failure ?permissions_auth ~account_id ?protocol_state_view - ?vk ~account_state_tbl () : Party.Fee_payer.t Quickcheck.Generator.t = + ?vk ~account_state_tbl () : + Account_update.Fee_payer.t Quickcheck.Generator.t = let open Quickcheck.Let_syntax in let%map body = - gen_party_body_fee_payer ?failure ?permissions_auth ~account_id ?vk + gen_account_update_body_fee_payer ?failure ?permissions_auth ~account_id ?vk ?protocol_state_view ~account_state_tbl () in - (* real signature to be added when this data inserted into a Parties.t *) + (* real signature to be added when this data inserted into a Zkapp_command.t *) let authorization = Signature.dummy in - ({ body; authorization } : Party.Fee_payer.t) + ({ body; authorization } : Account_update.Fee_payer.t) -(* keep max_other_parties small, so zkApp integration tests don't need lots +(* keep max_account_updates small, so zkApp integration tests don't need lots of block producers - because the other parties are split into a permissions-setter - and another party, the actual number of other parties is - twice this value, plus one, for the "balancing" party + because the other zkapp_command are split into a permissions-setter + and another account_update, the actual number of other zkapp_command is + twice this value, plus one, for the "balancing" account_update when we have separate transaction accounts in integration tests this number can be increased *) -let max_other_parties = 2 +let max_account_updates = 2 -let gen_parties_from ?failure ?(max_other_parties = max_other_parties) +let gen_zkapp_command_from ?failure ?(max_account_updates = max_account_updates) ~(fee_payer_keypair : Signature_lib.Keypair.t) ~(keymap : Signature_lib.Private_key.t Signature_lib.Public_key.Compressed.Map.t ) @@ -1074,7 +1082,7 @@ let gen_parties_from ?failure ?(max_other_parties = max_other_parties) in let fee_payer_acct_id = Account_id.create fee_payer_pk Token_id.default in let ledger_accounts = Ledger.to_list ledger in - (* table of public keys to accounts, updated when generating each party + (* table of public keys to accounts, updated when generating each account_update a Map would be more principled, but threading that map through the code adds complexity @@ -1095,11 +1103,12 @@ let gen_parties_from ?failure ?(max_other_parties = max_other_parties) a ) ; if Option.is_none (Signature_lib.Public_key.Compressed.Map.find keymap pk) then - failwithf "gen_parties_from: public key %s is in ledger, but not keymap" + failwithf + "gen_zkapp_command_from: public key %s is in ledger, but not keymap" (Signature_lib.Public_key.Compressed.to_base58_check pk) () ) ; - (* table of public keys not in the ledger, to be used for new parties - we have the corresponding private keys, so we can create signatures for those new parties + (* table of public keys not in the ledger, to be used for new zkapp_command + we have the corresponding private keys, so we can create signatures for those new zkapp_command *) let ledger_account_set = Account_id.Set.union_list @@ -1116,7 +1125,7 @@ let gen_parties_from ?failure ?(max_other_parties = max_other_parties) tbl in (* account ids seen, to generate receipt chain hash precondition only if - a party with a given account id has not been encountered before + a account_update with a given account id has not been encountered before *) let account_ids_seen = Account_id.Hash_set.create () in let%bind fee_payer = @@ -1133,7 +1142,8 @@ let gen_parties_from ?failure ?(max_other_parties = max_other_parties) |> Account_id.Table.keys in Hash_set.add account_ids_seen fee_payer_acct_id ; - let gen_parties_with_dynamic_balance ~new_parties num_parties = + let gen_zkapp_command_with_dynamic_balance ~new_zkapp_command + num_zkapp_command = let rec go acc n = let open Zkapp_basic in let open Permissions in @@ -1141,10 +1151,10 @@ let gen_parties_from ?failure ?(max_other_parties = max_other_parties) else (* choose a random authorization - first Party.t updates the permissions, using the Signature authorization, + first Account_update.t updates the permissions, using the Signature authorization, according the random authorization - second Party.t uses the random authorization + second Account_update.t uses the random authorization *) let%bind permissions_auth, update = match failure with @@ -1157,7 +1167,7 @@ let gen_parties_from ?failure ?(max_other_parties = max_other_parties) let update = match update_type with | `Delegate -> - { Party.Update.dummy with + { Account_update.Update.dummy with permissions = Set_or_keep.Set { perm with @@ -1165,7 +1175,7 @@ let gen_parties_from ?failure ?(max_other_parties = max_other_parties) } } | `App_state -> - { Party.Update.dummy with + { Account_update.Update.dummy with permissions = Set_or_keep.Set { perm with @@ -1173,7 +1183,7 @@ let gen_parties_from ?failure ?(max_other_parties = max_other_parties) } } | `Verification_key -> - { Party.Update.dummy with + { Account_update.Update.dummy with permissions = Set_or_keep.Set { perm with @@ -1181,7 +1191,7 @@ let gen_parties_from ?failure ?(max_other_parties = max_other_parties) } } | `Zkapp_uri -> - { Party.Update.dummy with + { Account_update.Update.dummy with permissions = Set_or_keep.Set { perm with @@ -1189,7 +1199,7 @@ let gen_parties_from ?failure ?(max_other_parties = max_other_parties) } } | `Token_symbol -> - { Party.Update.dummy with + { Account_update.Update.dummy with permissions = Set_or_keep.Set { perm with @@ -1197,7 +1207,7 @@ let gen_parties_from ?failure ?(max_other_parties = max_other_parties) } } | `Voting_for -> - { Party.Update.dummy with + { Account_update.Update.dummy with permissions = Set_or_keep.Set { perm with @@ -1205,7 +1215,7 @@ let gen_parties_from ?failure ?(max_other_parties = max_other_parties) } } | `Balance -> - { Party.Update.dummy with + { Account_update.Update.dummy with permissions = Set_or_keep.Set { perm with send = Auth_required.from ~auth_tag } @@ -1219,7 +1229,7 @@ let gen_parties_from ?failure ?(max_other_parties = max_other_parties) of zkapp account into the generator function *) let%map tag = - if new_parties then + if new_zkapp_command then Quickcheck.Generator.of_list [ Control.Tag.Signature; None_given ] else Control.Tag.gen @@ -1233,15 +1243,15 @@ let gen_parties_from ?failure ?(max_other_parties = max_other_parties) | Signature | None_given -> false in - let%bind party0 = + let%bind account_update0 = (* Signature authorization to start *) let authorization = Control.Signature Signature.dummy in - gen_party_from ~zkapp_account_ids ~account_ids_seen ~update ?failure - ~authorization ~new_account:new_parties ~permissions_auth - ~zkapp_account ~available_public_keys ~account_state_tbl - ?protocol_state_view ?vk () + gen_account_update_from ~zkapp_account_ids ~account_ids_seen ~update + ?failure ~authorization ~new_account:new_zkapp_command + ~permissions_auth ~zkapp_account ~available_public_keys + ~account_state_tbl ?protocol_state_view ?vk () in - let%bind party = + let%bind account_update = (* authorization according to chosen permissions auth *) let%bind authorization, update = match failure with @@ -1261,7 +1271,7 @@ let gen_parties_from ?failure ?(max_other_parties = max_other_parties) let%map delegate = Signature_lib.Public_key.Compressed.gen in - { Party.Update.dummy with + { Account_update.Update.dummy with delegate = Set_or_keep.Set delegate } | `App_state -> @@ -1275,26 +1285,27 @@ let gen_parties_from ?failure ?(max_other_parties = max_other_parties) in Zkapp_state.V.of_list_exn fields in - { Party.Update.dummy with app_state } + { Account_update.Update.dummy with app_state } | `Verification_key -> let data = Pickles.Side_loaded.Verification_key.dummy in let hash = Zkapp_account.digest_vk data in let verification_key = Set_or_keep.Set { With_hash.data; hash } in - return { Party.Update.dummy with verification_key } + return + { Account_update.Update.dummy with verification_key } | `Zkapp_uri -> let zkapp_uri = Set_or_keep.Set "https://o1labs.org" in - return { Party.Update.dummy with zkapp_uri } + return { Account_update.Update.dummy with zkapp_uri } | `Token_symbol -> let token_symbol = Set_or_keep.Set "CODA" in - return { Party.Update.dummy with token_symbol } + return { Account_update.Update.dummy with token_symbol } | `Voting_for -> let%map field = Snark_params.Tick.Field.gen in let voting_for = Set_or_keep.Set field in - { Party.Update.dummy with voting_for } + { Account_update.Update.dummy with voting_for } | `Balance -> - return Party.Update.dummy + return Account_update.Update.dummy in let%map new_perm = Permissions.gen ~auth_tag:Control.Tag.Signature @@ -1305,33 +1316,36 @@ let gen_parties_from ?failure ?(max_other_parties = max_other_parties) return (Control.dummy_of_tag permissions_auth, None) in let account_id = - Account_id.create party0.body.public_key party0.body.token_id + Account_id.create account_update0.body.public_key + account_update0.body.token_id in (* if we use this account again, it will have a Signature authorization *) let permissions_auth = Control.Tag.Signature in - gen_party_from ~update ?failure ~zkapp_account_ids ~account_ids_seen - ~account_id ~authorization ~permissions_auth ~zkapp_account - ~available_public_keys ~account_state_tbl ?protocol_state_view ?vk - () + gen_account_update_from ~update ?failure ~zkapp_account_ids + ~account_ids_seen ~account_id ~authorization ~permissions_auth + ~zkapp_account ~available_public_keys ~account_state_tbl + ?protocol_state_view ?vk () in - (* this list will be reversed, so `party0` will execute before `party` *) - go (party :: party0 :: acc) (n - 1) + (* this list will be reversed, so `account_update0` will execute before `account_update` *) + go (account_update :: account_update0 :: acc) (n - 1) in - go [] num_parties + go [] num_zkapp_command in - (* at least 1 party *) - let%bind num_parties = Int.gen_uniform_incl 1 max_other_parties in - let%bind num_new_accounts = Int.gen_uniform_incl 0 num_parties in - let num_old_parties = num_parties - num_new_accounts in - let%bind old_parties = - gen_parties_with_dynamic_balance ~new_parties:false num_old_parties + (* at least 1 account_update *) + let%bind num_zkapp_command = Int.gen_uniform_incl 1 max_account_updates in + let%bind num_new_accounts = Int.gen_uniform_incl 0 num_zkapp_command in + let num_old_zkapp_command = num_zkapp_command - num_new_accounts in + let%bind old_zkapp_command = + gen_zkapp_command_with_dynamic_balance ~new_zkapp_command:false + num_old_zkapp_command in - let%bind new_parties = - gen_parties_with_dynamic_balance ~new_parties:true num_new_accounts + let%bind new_zkapp_command = + gen_zkapp_command_with_dynamic_balance ~new_zkapp_command:true + num_new_accounts in - let other_parties0 = old_parties @ new_parties in + let account_updates0 = old_zkapp_command @ new_zkapp_command in let balance_change_sum = - List.fold other_parties0 + List.fold account_updates0 ~init: ( if num_new_accounts = 0 then Currency.Amount.Signed.zero else @@ -1343,77 +1357,85 @@ let gen_parties_from ?failure ?(max_other_parties = max_other_parties) .account_creation_fee ) num_new_accounts |> Option.value_exn )) ) - ~f:(fun acc party -> - match Currency.Amount.Signed.add acc party.body.balance_change with + ~f:(fun acc account_update -> + match + Currency.Amount.Signed.add acc account_update.body.balance_change + with | Some sum -> sum | None -> - failwith "Overflow adding other parties balances" ) + failwith "Overflow adding other zkapp_command balances" ) in - (* modify the balancing party with balance change to yield a zero sum + (* modify the balancing account_update with balance change to yield a zero sum - balancing party is created immediately after the fee payer - party is created. This is because the preconditions generation - is sensitive to the order of party generation. + balancing account_update is created immediately after the fee payer + account_update is created. This is because the preconditions generation + is sensitive to the order of account_update generation. *) let balance_change = Currency.Amount.Signed.negate balance_change_sum in - let%bind balancing_party = + let%bind balancing_account_update = let authorization = Control.Signature Signature.dummy in - gen_party_from ?failure ~permissions_auth:Control.Tag.Signature + gen_account_update_from ?failure ~permissions_auth:Control.Tag.Signature ~zkapp_account_ids ~account_ids_seen ~authorization ~new_account:false ~available_public_keys ~account_state_tbl ~required_balance_change:balance_change ?protocol_state_view ?vk () in - let other_parties = other_parties0 @ [ balancing_party ] in + let account_updates = account_updates0 @ [ balancing_account_update ] in let%map memo = Signed_command_memo.gen in - let parties_dummy_authorizations : Parties.t = - Parties.of_simple { fee_payer; other_parties; memo } + let zkapp_command_dummy_authorizations : Zkapp_command.t = + Zkapp_command.of_simple { fee_payer; account_updates; memo } in (* update receipt chain hashes in accounts table *) let receipt_elt = let _txn_commitment, full_txn_commitment = (* also computed in replace_authorizations, but easier just to re-compute here *) - Parties_builder.get_transaction_commitments parties_dummy_authorizations + Zkapp_command_builder.get_transaction_commitments + zkapp_command_dummy_authorizations in - Receipt.Parties_elt.Parties_commitment full_txn_commitment + Receipt.Zkapp_command_elt.Zkapp_command_commitment full_txn_commitment in Account_id.Table.update account_state_tbl fee_payer_acct_id ~f:(function | None -> failwith "Expected fee payer account id to be in table" | Some (account, _) -> let receipt_chain_hash = - Receipt.Chain_hash.cons_parties_commitment Mina_numbers.Index.zero - receipt_elt account.Account.Poly.receipt_chain_hash + Receipt.Chain_hash.cons_zkapp_command_commitment + Mina_numbers.Index.zero receipt_elt + account.Account.Poly.receipt_chain_hash in ({ account with receipt_chain_hash }, `Fee_payer) ) ; - let partys = - Parties.Call_forest.to_parties_list - parties_dummy_authorizations.other_parties + let account_updates = + Zkapp_command.Call_forest.to_zkapp_command_list + zkapp_command_dummy_authorizations.account_updates in - List.iteri partys ~f:(fun ndx party -> + List.iteri account_updates ~f:(fun ndx account_update -> (* update receipt chain hash only for signature, proof authorizations *) - match Party.authorization party with + match Account_update.authorization account_update with | Control.Proof _ | Control.Signature _ -> - let acct_id = Party.account_id party in + let acct_id = Account_update.account_id account_update in Account_id.Table.update account_state_tbl acct_id ~f:(function | None -> - failwith "Expected other party account id to be in table" + failwith + "Expected other account_update account id to be in table" | Some (account, role) -> let receipt_chain_hash = - let party_index = Mina_numbers.Index.of_int (ndx + 1) in - Receipt.Chain_hash.cons_parties_commitment party_index - receipt_elt account.Account.Poly.receipt_chain_hash + let account_update_index = + Mina_numbers.Index.of_int (ndx + 1) + in + Receipt.Chain_hash.cons_zkapp_command_commitment + account_update_index receipt_elt + account.Account.Poly.receipt_chain_hash in ({ account with receipt_chain_hash }, role) ) | Control.None_given -> () ) ; - parties_dummy_authorizations + zkapp_command_dummy_authorizations -let gen_list_of_parties_from ?failure ?max_other_parties +let gen_list_of_zkapp_command_from ?failure ?max_account_updates ~(fee_payer_keypairs : Signature_lib.Keypair.t list) ~keymap ?account_state_tbl ~ledger ?protocol_state_view ?vk ?length () = - (* Since when generating multiple parties the fee payer's nonce should only + (* Since when generating multiple zkapp_command the fee payer's nonce should only be incremented as the `Fee_payer` role, this is why we pre-computed the `account_state_tbl` here. *) @@ -1453,11 +1475,11 @@ let gen_list_of_parties_from ?failure ?max_other_parties let%bind fee_payer_keypair = Quickcheck.Generator.of_list fee_payer_keypairs in - let%bind new_parties = - gen_parties_from ?failure ?max_other_parties ~fee_payer_keypair ~keymap - ~account_state_tbl ~ledger ?protocol_state_view ?vk () + let%bind new_zkapp_command = + gen_zkapp_command_from ?failure ?max_account_updates ~fee_payer_keypair + ~keymap ~account_state_tbl ~ledger ?protocol_state_view ?vk () in - go (n - 1) (new_parties :: acc) + go (n - 1) (new_zkapp_command :: acc) else return (List.rev acc) in go length [] diff --git a/src/lib/mina_generators/parties_generators.mli b/src/lib/mina_generators/zkapp_command_generators.mli similarity index 70% rename from src/lib/mina_generators/parties_generators.mli rename to src/lib/mina_generators/zkapp_command_generators.mli index 43e59fa52f3..ea7a9e2ab95 100644 --- a/src/lib/mina_generators/parties_generators.mli +++ b/src/lib/mina_generators/zkapp_command_generators.mli @@ -15,32 +15,32 @@ type failure = type role = [ `Fee_payer | `New_account | `Ordinary_participant ] -val max_other_parties : int +val max_account_updates : int val gen_account_precondition_from_account : ?failure:failure -> first_use_of_account:bool -> Account.t - -> Party.Account_precondition.t Quickcheck.Generator.t + -> Account_update.Account_precondition.t Quickcheck.Generator.t val gen_protocol_state_precondition : Zkapp_precondition.Protocol_state.View.t -> Zkapp_precondition.Protocol_state.t Quickcheck.Generator.t -(** `gen_parties_from` generates a parties and record the change of accounts accordingly +(** `gen_zkapp_command_from` generates a zkapp_command and record the change of accounts accordingly in `account_state_tbl`. Note that `account_state_tbl` is optional. If it's not provided - then it would be computed from the ledger. If you plan to generate several parties, - then please manually pass `account_state_tbl` to `gen_parties_from` function. - If you are generating several parties, it's better to pre-compute the + then it would be computed from the ledger. If you plan to generate several zkapp_command, + then please manually pass `account_state_tbl` to `gen_zkapp_command_from` function. + If you are generating several zkapp_command, it's better to pre-compute the `account_state_tbl` before you call this function. This way you can manually set the role of fee payer accounts to be `Fee_payer` in `account_state_tbl` which would prevent - those accounts being used as ordinary participants in other parties. + those accounts being used as ordinary participants in other zkapp_command. - Generated parties uses dummy signatures and dummy proofs. + Generated zkapp_command uses dummy signatures and dummy proofs. *) -val gen_parties_from : +val gen_zkapp_command_from : ?failure:failure - -> ?max_other_parties:int + -> ?max_account_updates:int -> fee_payer_keypair:Signature_lib.Keypair.t -> keymap: Signature_lib.Private_key.t Signature_lib.Public_key.Compressed.Map.t @@ -49,13 +49,13 @@ val gen_parties_from : -> ?protocol_state_view:Zkapp_precondition.Protocol_state.View.t -> ?vk:(Side_loaded_verification_key.t, State_hash.t) With_hash.Stable.V1.t -> unit - -> Parties.t Quickcheck.Generator.t + -> Zkapp_command.t Quickcheck.Generator.t -(** Generate a list of parties, `fee_payer_keypairs` contains a list of possible fee payers +(** Generate a list of zkapp_command, `fee_payer_keypairs` contains a list of possible fee payers *) -val gen_list_of_parties_from : +val gen_list_of_zkapp_command_from : ?failure:failure - -> ?max_other_parties:int + -> ?max_account_updates:int -> fee_payer_keypairs:Signature_lib.Keypair.t list -> keymap: Signature_lib.Private_key.t Signature_lib.Public_key.Compressed.Map.t @@ -65,4 +65,4 @@ val gen_list_of_parties_from : -> ?vk:(Side_loaded_verification_key.t, State_hash.t) With_hash.Stable.V1.t -> ?length:int -> unit - -> Parties.t list Quickcheck.Generator.t + -> Zkapp_command.t list Quickcheck.Generator.t diff --git a/src/lib/mina_graphql/mina_graphql.ml b/src/lib/mina_graphql/mina_graphql.ml index c781b657651..5bd2d9e31a1 100644 --- a/src/lib/mina_graphql/mina_graphql.ml +++ b/src/lib/mina_graphql/mina_graphql.ml @@ -1458,16 +1458,19 @@ module Types = struct | Included_but_failed of Transaction_status.Failure.Collection.t let failure_reasons = - obj "PartiesFailureReason" ~fields:(fun _ -> + obj "ZkappCommandFailureReason" ~fields:(fun _ -> [ field "index" ~typ:(Graphql_basic_scalars.Index.typ ()) - ~args:[] ~doc:"List index of the party that failed" + ~args:[] ~doc:"List index of the account update that failed" ~resolve:(fun _ (index, _) -> Some index) ; field "failures" ~typ: ( non_null @@ list @@ non_null @@ Mina_base_unix.Graphql_scalars.TransactionStatusFailure.typ () ) - ~args:[] ~doc:"Failure reason for the party or any nested parties" + ~args:[] + ~doc: + "Failure reason for the account update or any nested zkapp \ + command" ~resolve:(fun _ (_, failures) -> failures) ] ) end @@ -1726,26 +1729,28 @@ module Types = struct resolve c cmd.With_status.data ) let zkapp_command = - let conv (x : (Mina_lib.t, Parties.t) Fields_derivers_graphql.Schema.typ) - : (Mina_lib.t, Parties.t) typ = + let conv + (x : (Mina_lib.t, Zkapp_command.t) Fields_derivers_graphql.Schema.typ) + : (Mina_lib.t, Zkapp_command.t) typ = Obj.magic x in obj "ZkappCommand" ~fields:(fun _ -> [ field_no_status "id" ~doc:"A Base58Check string representing the command" ~typ: - (non_null @@ Mina_base_unix.Graphql_scalars.PartiesBase58.typ ()) + ( non_null + @@ Mina_base_unix.Graphql_scalars.ZkappCommandBase58.typ () ) ~args:[] - ~resolve:(fun _ parties -> parties.With_hash.data) + ~resolve:(fun _ zkapp_command -> zkapp_command.With_hash.data) ; field_no_status "hash" ~doc:"A cryptographic hash of the zkApp command" ~typ:(non_null transaction_hash) ~args:[] - ~resolve:(fun _ parties -> parties.With_hash.hash) - ; field_no_status "parties" - ~typ:(Parties.typ () |> conv) + ~resolve:(fun _ zkapp_command -> zkapp_command.With_hash.hash) + ; field_no_status "zkappCommand" + ~typ:(Zkapp_command.typ () |> conv) ~args:Arg.[] - ~doc:"Parties representing the transaction" - ~resolve:(fun _ parties -> parties.With_hash.data) + ~doc:"zkApp command representing the transaction" + ~resolve:(fun _ zkapp_command -> zkapp_command.With_hash.data) ; field "failureReason" ~typ:(list @@ Command_status.failure_reasons) ~args:[] ~doc: @@ -1786,7 +1791,7 @@ module Types = struct Some (User_command.mk_user_command { status; data = { t.data with data = c } } ) - | Parties _ -> + | Zkapp_command _ -> None ) ) ; field "zkappCommands" ~doc:"List of zkApp commands included in this block" @@ -1797,7 +1802,7 @@ module Types = struct match t.data.data with | Signed_command _ -> None - | Parties parties -> + | Zkapp_command zkapp_command -> let status = match t.status with | Applied -> @@ -1807,7 +1812,7 @@ module Types = struct in Some { Zkapp_command.With_status.status - ; data = { t.data with data = parties } + ; data = { t.data with data = zkapp_command } } ) ) ; field "feeTransfer" ~doc:"List of fee transfers included in this block" @@ -2362,16 +2367,16 @@ module Types = struct end module SendTestZkappInput = struct - type input = Mina_base.Parties.t + type input = Mina_base.Zkapp_command.t let arg_typ = - scalar "SendTestZkappInput" ~doc:"Parties for a test zkApp" + scalar "SendTestZkappInput" ~doc:"Zkapp_command for a test zkApp" ~coerce:(fun json -> let json = to_yojson json in - Result.try_with (fun () -> Mina_base.Parties.of_json json) + Result.try_with (fun () -> Mina_base.Zkapp_command.of_json json) |> Result.map_error ~f:(fun ex -> Exn.to_string ex) ) ~to_json:(fun (x : input) -> - Yojson.Safe.to_basic @@ Mina_base.Parties.to_json x ) + Yojson.Safe.to_basic @@ Mina_base.Zkapp_command.to_json x ) end module PrecomputedBlock = struct @@ -2708,21 +2713,27 @@ module Types = struct type input = SendTestZkappInput.input let arg_typ = - let conv (x : Parties.t Fields_derivers_graphql.Schema.Arg.arg_typ) : - Parties.t Graphql_async.Schema.Arg.arg_typ = + let conv + (x : + Mina_base.Zkapp_command.t + Fields_derivers_graphql.Schema.Arg.arg_typ ) : + Mina_base.Zkapp_command.t Graphql_async.Schema.Arg.arg_typ = Obj.magic x in let arg_typ = - { arg_typ = Parties.arg_typ () |> conv + { arg_typ = Mina_base.Zkapp_command.arg_typ () |> conv ; to_json = - (function x -> Yojson.Safe.to_basic (Parties.parties_to_json x)) + (function + | x -> + Yojson.Safe.to_basic + (Mina_base.Zkapp_command.zkapp_command_to_json x) ) } in obj "SendZkappInput" ~coerce:Fn.id ~split:(fun f (x : input) -> f x) ~fields: - [ arg "parties" - ~doc:"Parties structure representing the transaction" + [ arg "zkapp_command" + ~doc:"Zkapp_command structure representing the transaction" ~typ:arg_typ ] end @@ -3356,20 +3367,20 @@ module Mutations = struct | `Bootstrapping -> return (Error "Daemon is bootstrapping") - let send_zkapp_command mina parties = - match Mina_commands.setup_and_submit_snapp_command mina parties with + let send_zkapp_command mina zkapp_command = + match Mina_commands.setup_and_submit_snapp_command mina zkapp_command with | `Active f -> ( match%map f with - | Ok parties -> + | Ok zkapp_command -> let cmd = - { Types.Zkapp_command.With_status.data = parties + { Types.Zkapp_command.With_status.data = zkapp_command ; status = Enqueued } in let cmd_with_hash = Types.Zkapp_command.With_status.map cmd ~f:(fun cmd -> { With_hash.data = cmd - ; hash = Transaction_hash.hash_command (Parties cmd) + ; hash = Transaction_hash.hash_command (Zkapp_command cmd) } ) in Ok cmd_with_hash @@ -3380,13 +3391,13 @@ module Mutations = struct | `Bootstrapping -> return (Error "Daemon is bootstrapping") - let mock_zkapp_command mina parties : - ( (Parties.t, Transaction_hash.t) With_hash.t + let mock_zkapp_command mina zkapp_command : + ( (Zkapp_command.t, Transaction_hash.t) With_hash.t Types.Zkapp_command.With_status.t , string ) result Io.t = - (* instead of adding the parties to the transaction pool, as we would for an actual zkapp, + (* instead of adding the zkapp_command to the transaction pool, as we would for an actual zkapp, apply the zkapp using an ephemeral ledger *) match Mina_lib.best_tip mina with @@ -3449,22 +3460,23 @@ module Mutations = struct |> Mina_state.Protocol_state.Body.view in let applied = - Ledger.apply_parties_unchecked ~constraint_constants - ~state_view ledger parties + Ledger.apply_zkapp_command_unchecked ~constraint_constants + ~state_view ledger zkapp_command in (* rearrange data to match result type of `send_zkapp_command` *) let applied_ok = Result.map applied - ~f:(fun (parties_applied, _local_state_and_amount) -> - let ({ data = parties; status } : Parties.t With_status.t) - = - parties_applied.command + ~f:(fun (zkapp_command_applied, _local_state_and_amount) -> + let ({ data = zkapp_command; status } + : Zkapp_command.t With_status.t ) = + zkapp_command_applied.command in let hash = - Transaction_hash.hash_command (Parties parties) + Transaction_hash.hash_command + (Zkapp_command zkapp_command) in let (with_hash : _ With_hash.t) = - { data = parties; hash } + { data = zkapp_command; hash } in let (status : Types.Command_status.t) = match status with @@ -3629,8 +3641,8 @@ module Mutations = struct ~typ:(non_null Types.Payload.send_zkapp) ~args: Arg.[ arg "input" ~typ:(non_null Types.Input.SendZkappInput.arg_typ) ] - ~resolve:(fun { ctx = coda; _ } () parties -> - f coda parties (* TODO: error handling? *) ) + ~resolve:(fun { ctx = coda; _ } () zkapp_command -> + f coda zkapp_command (* TODO: error handling? *) ) let send_zkapp = make_zkapp_endpoint ~name:"sendZkapp" ~doc:"Send a zkApp transaction" @@ -3646,11 +3658,12 @@ module Mutations = struct ~doc:"Send a zkApp (for internal testing purposes)" ~args: Arg. - [ arg "parties" ~typ:(non_null Types.Input.SendTestZkappInput.arg_typ) + [ arg "zkapp_command" + ~typ:(non_null Types.Input.SendTestZkappInput.arg_typ) ] ~typ:(non_null Types.Payload.send_zkapp) - ~resolve:(fun { ctx = mina; _ } () parties -> - send_zkapp_command mina parties ) + ~resolve:(fun { ctx = mina; _ } () zkapp_command -> + send_zkapp_command mina zkapp_command ) let send_test_payments = io_field "sendTestPayments" ~doc:"Send a series of test payments" @@ -4070,7 +4083,7 @@ module Queries = struct { status = Enqueued ; data = { cmd_with_hash with data = user_cmd } } ) - | Parties _ -> + | Zkapp_command _ -> None ) ) let pooled_zkapp_commands = @@ -4104,7 +4117,7 @@ module Queries = struct match cmd_with_hash.data with | Signed_command _ -> None - | Parties zkapp_cmd -> + | Zkapp_command zkapp_cmd -> Some { Types.Zkapp_command.With_status.status = Enqueued ; data = { cmd_with_hash with data = zkapp_cmd } @@ -4308,9 +4321,10 @@ module Queries = struct Or_error.( Signed_command.of_base58_check x >>| fun c -> User_command.Signed_command c) - | `Parties ps -> + | `Zkapp_command ps -> Or_error.( - Parties.of_base58_check ps >>| fun c -> User_command.Parties c) + Zkapp_command.of_base58_check ps + >>| fun c -> User_command.Zkapp_command c) in result_of_or_error res ~error:"Invalid transaction provided" |> Result.map ~f:(fun cmd -> @@ -4327,7 +4341,7 @@ module Queries = struct | Some payment, None -> deserialize_txn (`Signed_command payment) | None, Some zkapp_txn -> - deserialize_txn (`Parties zkapp_txn) + deserialize_txn (`Zkapp_command zkapp_txn) in let frontier_broadcast_pipe = Mina_lib.transition_frontier coda in let transaction_pool = Mina_lib.transaction_pool coda in diff --git a/src/lib/mina_ledger/dune b/src/lib/mina_ledger/dune index 68bdadbdfeb..a61c38f4eeb 100644 --- a/src/lib/mina_ledger/dune +++ b/src/lib/mina_ledger/dune @@ -24,7 +24,7 @@ sgn syncable_ledger snark_params - parties_builder + zkapp_command_builder pickles pickles.backend pickles_types diff --git a/src/lib/mina_ledger/ledger.ml b/src/lib/mina_ledger/ledger.ml index 3d3be79e32e..e3463b43918 100644 --- a/src/lib/mina_ledger/ledger.ml +++ b/src/lib/mina_ledger/ledger.ml @@ -369,15 +369,15 @@ let apply_transaction ~constraint_constants ~txn_state_view l t = apply_transaction ~constraint_constants ~txn_state_view l t ) (* use mask to restore ledger after application *) -let merkle_root_after_parties_exn ~constraint_constants ~txn_state_view ledger - parties = +let merkle_root_after_zkapp_command_exn ~constraint_constants ~txn_state_view + ledger zkapp_command = let mask = Mask.create ~depth:(depth ledger) () in let masked_ledger = register_mask ledger mask in let _applied = Or_error.ok_exn - (apply_parties_unchecked ~constraint_constants ~state_view:txn_state_view - masked_ledger - (Parties.Valid.forget parties) ) + (apply_zkapp_command_unchecked ~constraint_constants + ~state_view:txn_state_view masked_ledger + (Zkapp_command.Valid.forget zkapp_command) ) in let root = merkle_root masked_ledger in ignore (unregister_mask_exn ~loc:__LOC__ masked_ledger : unattached_mask) ; @@ -450,7 +450,7 @@ let apply_initial_ledger_state : t -> init_state -> unit = let%test_unit "tokens test" = let open Mina_transaction_logic.For_tests in - let open Parties_builder in + let open Zkapp_command_builder in let constraint_constants = Genesis_constants.Constraint_constants.for_unit_tests in @@ -470,18 +470,20 @@ let%test_unit "tokens test" = Public_key.compress kp.public_key in let main (ledger : t) = - let execute_parties_transaction - (parties : (Party.Body.Simple.t, unit, unit) Parties.Call_forest.t) : - unit = + let execute_zkapp_command_transaction + (zkapp_command : + (Account_update.Body.Simple.t, unit, unit) Zkapp_command.Call_forest.t + ) : unit = let _, ({ nonce; _ } : Account.t), _ = Ledger_inner.get_or_create ledger (Account_id.create pk Token_id.default) |> Or_error.ok_exn in match - apply_parties_unchecked ~constraint_constants ~state_view:view ledger - (mk_parties_transaction ~fee:7 ~fee_payer_pk:pk ~fee_payer_nonce:nonce - parties ) + apply_zkapp_command_unchecked ~constraint_constants ~state_view:view + ledger + (mk_zkapp_command ~fee:7 ~fee_payer_pk:pk ~fee_payer_nonce:nonce + zkapp_command ) with | Ok ({ command = { status; _ }; _ }, _) -> ( match status with @@ -511,14 +513,15 @@ let%test_unit "tokens test" = let account_creation_fee = Currency.Fee.to_int constraint_constants.account_creation_fee in - let create_token : (Party.Body.Simple.t, unit, unit) Parties.Call_forest.t = + let create_token : + (Account_update.Body.Simple.t, unit, unit) Zkapp_command.Call_forest.t = mk_forest [ mk_node - (mk_party_body Call token_funder Token_id.default + (mk_account_update_body Call token_funder Token_id.default (-(4 * account_creation_fee)) ) [] ; mk_node - (mk_party_body Call token_owner Token_id.default + (mk_account_update_body Call token_owner Token_id.default (3 * account_creation_fee) ) [] ] @@ -533,29 +536,37 @@ let%test_unit "tokens test" = let token_minting = mk_forest [ mk_node - (mk_party_body Call token_owner Token_id.default + (mk_account_update_body Call token_owner Token_id.default (-account_creation_fee) ) - [ mk_node (mk_party_body Call token_account1 custom_token_id 100) [] + [ mk_node + (mk_account_update_body Call token_account1 custom_token_id 100) + [] ] ] in let token_transfers = mk_forest [ mk_node - (mk_party_body Call token_owner Token_id.default + (mk_account_update_body Call token_owner Token_id.default (-account_creation_fee) ) [ mk_node - (mk_party_body Call token_account1 custom_token_id (-30)) + (mk_account_update_body Call token_account1 custom_token_id (-30)) [] - ; mk_node (mk_party_body Call token_account2 custom_token_id 30) [] ; mk_node - (mk_party_body Call token_account1 custom_token_id (-10)) + (mk_account_update_body Call token_account2 custom_token_id 30) [] - ; mk_node (mk_party_body Call token_account2 custom_token_id 10) [] ; mk_node - (mk_party_body Call token_account2 custom_token_id (-5)) + (mk_account_update_body Call token_account1 custom_token_id (-10)) + [] + ; mk_node + (mk_account_update_body Call token_account2 custom_token_id 10) + [] + ; mk_node + (mk_account_update_body Call token_account2 custom_token_id (-5)) + [] + ; mk_node + (mk_account_update_body Call token_account1 custom_token_id 5) [] - ; mk_node (mk_party_body Call token_account1 custom_token_id 5) [] ] ] in @@ -567,15 +578,15 @@ let%test_unit "tokens test" = .balance (Currency.Balance.of_int balance) in - execute_parties_transaction create_token ; + execute_zkapp_command_transaction create_token ; (* Check that token_owner exists *) ledger_get_exn ledger (Public_key.compress token_owner.public_key) Token_id.default |> ignore ; - execute_parties_transaction token_minting ; + execute_zkapp_command_transaction token_minting ; check_token_balance token_account1 100 ; - execute_parties_transaction token_transfers ; + execute_zkapp_command_transaction token_transfers ; check_token_balance token_account1 65 ; check_token_balance token_account2 35 in @@ -586,7 +597,7 @@ let%test_unit "tokens test" = ledger ; main ledger ) -let%test_unit "parties payment test" = +let%test_unit "zkapp_command payment test" = let open Mina_transaction_logic.For_tests in let module L = Ledger_inner in let constraint_constants = @@ -596,12 +607,12 @@ let%test_unit "parties payment test" = in Quickcheck.test ~trials:1 Test_spec.gen ~f:(fun { init_ledger; specs } -> let ts1 : Signed_command.t list = List.map specs ~f:command_send in - let ts2 : Parties.t list = + let ts2 : Zkapp_command.t list = List.map specs ~f:(fun s -> let use_full_commitment = Quickcheck.random_value Bool.quickcheck_generator in - party_send ~constraint_constants ~use_full_commitment s ) + account_update_send ~constraint_constants ~use_full_commitment s ) in L.with_ledger ~depth ~f:(fun l1 -> L.with_ledger ~depth ~f:(fun l2 -> @@ -615,13 +626,15 @@ let%test_unit "parties payment test" = in let%bind () = iter_err ts2 ~f:(fun t -> - apply_parties_unchecked l2 t ~constraint_constants + apply_zkapp_command_unchecked l2 t ~constraint_constants ~state_view:view ) in - let accounts = List.concat_map ~f:Parties.accounts_accessed ts2 in + let accounts = + List.concat_map ~f:Zkapp_command.accounts_accessed ts2 + in (* TODO: Hack. The nonces are inconsistent between the 2 versions. See the comment in - [Mina_transaction_logic.For_tests.party_send] for more info. + [Mina_transaction_logic.For_tests.account_update_send] for more info. *) L.iteri l1 ~f:(fun index account -> L.set_at_index_exn l1 index diff --git a/src/lib/mina_ledger/ledger.mli b/src/lib/mina_ledger/ledger.mli index 7100f2723ca..84c58213bf7 100644 --- a/src/lib/mina_ledger/ledger.mli +++ b/src/lib/mina_ledger/ledger.mli @@ -126,10 +126,10 @@ module Transaction_applied : sig [@@deriving sexp] end - module Parties_applied : sig - type t = Transaction_applied.Parties_applied.t = + module Zkapp_command_applied : sig + type t = Transaction_applied.Zkapp_command_applied.t = { accounts : (Account_id.t * Account.t option) list - ; command : Parties.t With_status.t + ; command : Zkapp_command.t With_status.t ; new_accounts : Account_id.t list } [@@deriving sexp] @@ -138,7 +138,7 @@ module Transaction_applied : sig module Command_applied : sig type t = Transaction_applied.Command_applied.t = | Signed_command of Signed_command_applied.t - | Parties of Parties_applied.t + | Zkapp_command of Zkapp_command_applied.t [@@deriving sexp] end @@ -215,7 +215,7 @@ val apply_transaction : -> Transaction_applied.t Or_error.t (** update sequence state, returned slot is new last sequence slot - made available here so we can use this logic in the Parties generators + made available here so we can use this logic in the Zkapp_command generators *) val update_sequence_state : Snark_params.Tick.Field.t Pickles_types.Vector.Vector_5.t @@ -225,22 +225,22 @@ val update_sequence_state : -> Snark_params.Tick.Field.t Pickles_types.Vector.Vector_5.t * Mina_numbers.Global_slot.t -val apply_parties_unchecked : +val apply_zkapp_command_unchecked : constraint_constants:Genesis_constants.Constraint_constants.t -> state_view:Zkapp_precondition.Protocol_state.View.t -> t - -> Parties.t - -> ( Transaction_applied.Parties_applied.t + -> Zkapp_command.t + -> ( Transaction_applied.Zkapp_command_applied.t * ( ( Stack_frame.value , Stack_frame.value list , Token_id.t , Currency.Amount.Signed.t , t , bool - , Parties.Transaction_commitment.t + , Zkapp_command.Transaction_commitment.t , Mina_numbers.Index.t , Transaction_status.Failure.Collection.t ) - Mina_transaction_logic.Parties_logic.Local_state.t + Mina_transaction_logic.Zkapp_command_logic.Local_state.t * Currency.Amount.Signed.t ) ) Or_error.t @@ -250,11 +250,11 @@ val has_locked_tokens : -> t -> bool Or_error.t -val merkle_root_after_parties_exn : +val merkle_root_after_zkapp_command_exn : constraint_constants:Genesis_constants.Constraint_constants.t -> txn_state_view:Zkapp_precondition.Protocol_state.View.t -> t - -> Parties.Valid.t + -> Zkapp_command.Valid.t -> Ledger_hash.t val merkle_root_after_user_command_exn : diff --git a/src/lib/mina_ledger/sparse_ledger.ml b/src/lib/mina_ledger/sparse_ledger.ml index 65e84728527..6336e99881e 100644 --- a/src/lib/mina_ledger/sparse_ledger.ml +++ b/src/lib/mina_ledger/sparse_ledger.ml @@ -81,20 +81,20 @@ let%test_unit "of_ledger_subset_exn with keys that don't exist works" = module T = Mina_transaction_logic.Make (L) -let apply_parties_unchecked_with_states ~constraint_constants ~state_view +let apply_zkapp_command_unchecked_with_states ~constraint_constants ~state_view ~fee_excess ledger c = let open T in - apply_parties_unchecked_aux ~constraint_constants ~state_view ~fee_excess - (ref ledger) c ~init:[] + apply_zkapp_command_unchecked_aux ~constraint_constants ~state_view + ~fee_excess (ref ledger) c ~init:[] ~f:(fun acc ({ ledger; fee_excess; protocol_state }, local_state) -> ( { GS.ledger = !ledger; fee_excess; protocol_state } , { local_state with ledger = !(local_state.ledger) } ) :: acc ) - |> Result.map ~f:(fun (party_applied, states) -> + |> Result.map ~f:(fun (account_update_applied, states) -> (* We perform a [List.rev] here to ensure that the states are in order - wrt. the parties that generated the states. + wrt. the zkapp_command that generated the states. *) - (party_applied, List.rev states) ) + (account_update_applied, List.rev states) ) let apply_transaction_logic f t x = let open Or_error.Let_syntax in diff --git a/src/lib/mina_lib/mina_lib.ml b/src/lib/mina_lib/mina_lib.ml index 64ae9361e43..f5563029198 100644 --- a/src/lib/mina_lib/mina_lib.ml +++ b/src/lib/mina_lib/mina_lib.ml @@ -72,7 +72,7 @@ type components = (* tag commands so they can share a common pipe, to ensure sequentiality of nonces *) type command_inputs = | Signed_command_inputs of User_command_input.t list - | Parties_command_inputs of Parties.t list + | Zkapp_command_command_inputs of Zkapp_command.t list type pipes = { validated_transitions_reader : Mina_block.Validated.t Strict_pipe.Reader.t @@ -973,21 +973,21 @@ let add_full_transactions t user_commands = | Some err -> Deferred.Result.fail err -let add_zkapp_transactions t (partiess : Parties.t list) = +let add_zkapp_transactions t (zkapp_commands : Zkapp_command.t list) = let add_all_txns () = let result_ivar = Ivar.create () in - let cmd_inputs = Parties_command_inputs partiess in + let cmd_inputs = Zkapp_command_command_inputs zkapp_commands in Strict_pipe.Writer.write t.pipes.user_command_input_writer (cmd_inputs, Ivar.fill result_ivar, get_current_nonce t, get_account t) |> Deferred.don't_wait_for ; Ivar.read result_ivar in let too_big_err = - List.find_map partiess ~f:(fun parties -> + List.find_map zkapp_commands ~f:(fun zkapp_command -> let size_validity = - Parties.valid_size + Zkapp_command.valid_size ~genesis_constants:t.config.precomputed_values.genesis_constants - parties + zkapp_command in match size_validity with Ok () -> None | Error err -> Some err ) in @@ -1884,15 +1884,15 @@ let create ?wallets (config : Config.t) = ~metadata:[ ("error", Error_json.error_to_yojson e) ] ; result_cb (Error e) ; Deferred.unit ) - | Parties_command_inputs partiess -> - (* TODO: here, submit a Parties.t, which includes a nonce + | Zkapp_command_command_inputs zkapp_commands -> + (* TODO: here, submit a Zkapp_command.t, which includes a nonce allow the nonce to be omitted, and infer it, as done for user command inputs *) - (* too-big Parties.t's were filtered when writing to the user command pipe *) + (* too-big Zkapp_command.t's were filtered when writing to the user command pipe *) Network_pool.Transaction_pool.Local_sink.push tx_local_sink - ( List.map partiess ~f:(fun parties -> - User_command.Parties parties ) + ( List.map zkapp_commands ~f:(fun zkapp_command -> + User_command.Zkapp_command zkapp_command ) , result_cb ) ) |> Deferred.don't_wait_for ; let ((most_recent_valid_block_reader, _) as most_recent_valid_block) = diff --git a/src/lib/mina_lib/mina_lib.mli b/src/lib/mina_lib/mina_lib.mli index ebca696b268..0967fde27ba 100644 --- a/src/lib/mina_lib/mina_lib.mli +++ b/src/lib/mina_lib/mina_lib.mli @@ -106,7 +106,7 @@ val add_full_transactions : val add_zkapp_transactions : t - -> Parties.t list + -> Zkapp_command.t list -> ( [ `Broadcasted | `Not_broadcasted ] * Network_pool.Transaction_pool.Resource_pool.Diff.t * Network_pool.Transaction_pool.Resource_pool.Diff.Rejected.t ) diff --git a/src/lib/mina_lib/mina_subscriptions.ml b/src/lib/mina_lib/mina_subscriptions.ml index 849bb02b0e5..f79d65f7f1e 100644 --- a/src/lib/mina_lib/mina_subscriptions.ml +++ b/src/lib/mina_lib/mina_subscriptions.ml @@ -66,7 +66,7 @@ let create ~logger ~constraint_constants ~wallets ~new_blocks |> List.filter_map ~f:(function | User_command.Signed_command c -> Some c - | Parties _ -> + | Zkapp_command _ -> None ) |> Fn.flip Signed_command.filter_by_participant participant in diff --git a/src/lib/mina_metrics/mina_metrics.mli b/src/lib/mina_metrics/mina_metrics.mli index 01345159b41..15f33c3ebe1 100644 --- a/src/lib/mina_metrics/mina_metrics.mli +++ b/src/lib/mina_metrics/mina_metrics.mli @@ -62,7 +62,7 @@ module Cryptography : sig val transaction_length : Gauge.t - val proof_parties : Gauge.t + val proof_zkapp_command : Gauge.t end module Bootstrap : sig @@ -84,9 +84,9 @@ module Transaction_pool : sig val transactions_added_to_pool : Counter.t - val parties_transaction_size : Gauge.t + val zkapp_command_transaction_size : Gauge.t - val parties_count : Gauge.t + val zkapp_command_count : Gauge.t end module Network : sig diff --git a/src/lib/mina_metrics/no_metrics/mina_metrics.ml b/src/lib/mina_metrics/no_metrics/mina_metrics.ml index fa89b71fdc4..9f74320acde 100644 --- a/src/lib/mina_metrics/no_metrics/mina_metrics.ml +++ b/src/lib/mina_metrics/no_metrics/mina_metrics.ml @@ -72,7 +72,7 @@ module Cryptography = struct let transaction_length : Gauge.t = () - let proof_parties : Gauge.t = () + let proof_zkapp_command : Gauge.t = () end module Bootstrap = struct @@ -94,9 +94,9 @@ module Transaction_pool = struct let transactions_added_to_pool : Counter.t = () - let parties_transaction_size : Gauge.t = () + let zkapp_command_transaction_size : Gauge.t = () - let parties_count : Gauge.t = () + let zkapp_command_count : Gauge.t = () end module Network = struct diff --git a/src/lib/mina_metrics/prometheus_metrics/mina_metrics.ml b/src/lib/mina_metrics/prometheus_metrics/mina_metrics.ml index e42e5435200..043b2f1645a 100644 --- a/src/lib/mina_metrics/prometheus_metrics/mina_metrics.ml +++ b/src/lib/mina_metrics/prometheus_metrics/mina_metrics.ml @@ -281,16 +281,17 @@ module Cryptography = struct let transaction_length = let help = - "Number of parties in a parties transaction (1 for simple transactions)" + "Number of zkapp_command in a zkapp_command transaction (1 for simple \ + transactions)" in Gauge.v "transaction_length" ~help ~namespace ~subsystem - let proof_parties = + let proof_zkapp_command = let help = - "Number of parties with proof authorization in a parties transaction (0 \ - for simple transactions)" + "Number of zkapp_command with proof authorization in a zkapp_command \ + transaction (0 for simple transactions)" in - Gauge.v "proof_parties" ~help ~namespace ~subsystem + Gauge.v "proof_zkapp_command" ~help ~namespace ~subsystem (* TODO: let transaction_proving_time_ms = @@ -344,13 +345,15 @@ module Transaction_pool = struct in Counter.v "transactions_added_to_pool" ~help ~namespace ~subsystem - let parties_transaction_size : Gauge.t = - let help = "Size of valid parties transaction received (bin_size_t)" in - Gauge.v "parties_transaction_size" ~help ~namespace ~subsystem + let zkapp_command_transaction_size : Gauge.t = + let help = + "Size of valid zkapp_command transaction received (bin_size_t)" + in + Gauge.v "zkapp_command_transaction_size" ~help ~namespace ~subsystem - let parties_count : Gauge.t = - let help = "Number of parties in a valid transaction received" in - Gauge.v "parties_count" ~help ~namespace ~subsystem + let zkapp_command_count : Gauge.t = + let help = "Number of zkapp_command in a valid transaction received" in + Gauge.v "zkapp_command_count" ~help ~namespace ~subsystem end module Metric_map (Metric : sig diff --git a/src/lib/mina_net2/libp2p_stream.ml b/src/lib/mina_net2/libp2p_stream.ml index dd44cf75b40..77e09f06cdf 100644 --- a/src/lib/mina_net2/libp2p_stream.ml +++ b/src/lib/mina_net2/libp2p_stream.ml @@ -15,7 +15,7 @@ type state = | HalfClosed of participant (** Streams move from [FullyOpen] to [HalfClosed `Us] when the write pipe is closed. Streams move from [FullyOpen] to [HalfClosed `Them] when [Stream.reset] is called or the remote host closes their write stream. *) | FullyClosed - (** Streams move from [HalfClosed peer] to FullyClosed once the party that isn't peer has their "close write" event. Once a stream is FullyClosed, its resources are released. *) + (** Streams move from [HalfClosed peer] to FullyClosed once the account_update that isn't peer has their "close write" event. Once a stream is FullyClosed, its resources are released. *) [@@deriving equal, show] type t = @@ -97,10 +97,10 @@ let stream_closed ~logger ~who_closed t = if equal_participant who_closed Them then Pipe.close t.incoming_w ; let new_state = let log_double_close () = - [%log error] "stream with index $index closed twice by $party" + [%log error] "stream with index $index closed twice by $account_update" ~metadata: [ ("index", `String (Libp2p_ipc.stream_id_to_string t.id)) - ; ("party", `String (name_of_participant who_closed)) + ; ("account_update", `String (name_of_participant who_closed)) ] in match t.state with diff --git a/src/lib/mina_state/local_state.ml b/src/lib/mina_state/local_state.ml index c7222e5a976..21011a54fea 100644 --- a/src/lib/mina_state/local_state.ml +++ b/src/lib/mina_state/local_state.ml @@ -3,7 +3,7 @@ open Currency open Mina_base module Impl = Pickles.Impls.Step -include Mina_transaction_logic.Parties_logic.Local_state.Value +include Mina_transaction_logic.Zkapp_command_logic.Local_state.Value type display = ( string @@ -15,7 +15,7 @@ type display = , string , int , string ) - Mina_transaction_logic.Parties_logic.Local_state.t + Mina_transaction_logic.Zkapp_command_logic.Local_state.t [@@deriving yojson] let display @@ -27,7 +27,7 @@ let display ; excess ; ledger ; success - ; party_index + ; account_update_index ; failure_status_tbl } : t ) : display = @@ -36,7 +36,7 @@ let display Visualization.display_prefix_of_string (Bigint256.to_hex_string (Fp.to_bigint x)) in - { Mina_transaction_logic.Parties_logic.Local_state.stack_frame = + { Mina_transaction_logic.Zkapp_command_logic.Local_state.stack_frame = f (stack_frame :> Fp.t) ; call_stack = f (call_stack :> Fp.t) ; transaction_commitment = f transaction_commitment @@ -49,7 +49,7 @@ let display Visualization.display_prefix_of_string @@ Frozen_ledger_hash.to_base58_check ledger ; success - ; party_index = Mina_numbers.Index.to_int party_index + ; account_update_index = Mina_numbers.Index.to_int account_update_index ; failure_status_tbl = Transaction_status.Failure.Collection.to_display failure_status_tbl |> Transaction_status.Failure.Collection.Display.to_yojson @@ -60,13 +60,13 @@ let dummy : unit -> t = Memo.unit (fun () : t -> { stack_frame = Stack_frame.Digest.create Stack_frame.empty ; call_stack = Call_stack_digest.empty - ; transaction_commitment = Parties.Transaction_commitment.empty - ; full_transaction_commitment = Parties.Transaction_commitment.empty + ; transaction_commitment = Zkapp_command.Transaction_commitment.empty + ; full_transaction_commitment = Zkapp_command.Transaction_commitment.empty ; token_id = Token_id.default ; excess = Amount.(Signed.of_unsigned zero) ; ledger = Frozen_ledger_hash.empty_hash ; success = true - ; party_index = Mina_numbers.Index.zero + ; account_update_index = Mina_numbers.Index.zero ; failure_status_tbl = [] } ) @@ -81,7 +81,7 @@ let gen : t Quickcheck.Generator.t = and call_stack = Call_stack_digest.gen and token_id = Token_id.gen and success = Bool.quickcheck_generator - and party_index = + and account_update_index = Mina_numbers.Index.gen (* and failure_status = @@ -89,7 +89,7 @@ let gen : t Quickcheck.Generator.t = Quickcheck.Generator.of_list [ None; Some failure ] *) in - { Mina_transaction_logic.Parties_logic.Local_state.stack_frame + { Mina_transaction_logic.Zkapp_command_logic.Local_state.stack_frame ; call_stack ; transaction_commitment ; full_transaction_commitment = transaction_commitment @@ -97,7 +97,7 @@ let gen : t Quickcheck.Generator.t = ; ledger ; excess ; success - ; party_index + ; account_update_index ; failure_status_tbl = [] } @@ -110,7 +110,7 @@ let to_input ; excess ; ledger ; success - ; party_index + ; account_update_index ; failure_status_tbl = _ } : t ) = @@ -124,14 +124,14 @@ let to_input ; Token_id.to_input token_id ; Amount.Signed.to_input excess ; Ledger_hash.to_input ledger - ; Mina_numbers.Index.to_input party_index + ; Mina_numbers.Index.to_input account_update_index ; packed (Mina_base.Util.field_of_bool success, 1) |] module Checked = struct open Impl - include Mina_transaction_logic.Parties_logic.Local_state.Checked + include Mina_transaction_logic.Zkapp_command_logic.Local_state.Checked let assert_equal (t1 : t) (t2 : t) = let ( ! ) f x y = Impl.run_checked (f x y) in @@ -139,7 +139,7 @@ module Checked = struct Impl.with_label (Core_kernel.Field.name f) (fun () -> Core_kernel.Field.(eq (get f t1) (get f t2)) ) in - Mina_transaction_logic.Parties_logic.Local_state.Fields.iter + Mina_transaction_logic.Zkapp_command_logic.Local_state.Fields.iter ~stack_frame:(f Stack_frame.Digest.Checked.Assert.equal) ~call_stack:(f Call_stack_digest.Checked.Assert.equal) ~transaction_commitment:(f Field.Assert.equal) @@ -148,13 +148,13 @@ module Checked = struct ~excess:(f !Currency.Amount.Signed.Checked.assert_equal) ~ledger:(f !Ledger_hash.assert_equal) ~success:(f Impl.Boolean.Assert.( = )) - ~party_index:(f !Mina_numbers.Index.Checked.Assert.equal) + ~account_update_index:(f !Mina_numbers.Index.Checked.Assert.equal) ~failure_status_tbl:(f (fun () () -> ())) let equal' (t1 : t) (t2 : t) = let ( ! ) f x y = Impl.run_checked (f x y) in let f eq acc f = Core_kernel.Field.(eq (get f t1) (get f t2)) :: acc in - Mina_transaction_logic.Parties_logic.Local_state.Fields.fold ~init:[] + Mina_transaction_logic.Zkapp_command_logic.Local_state.Fields.fold ~init:[] ~stack_frame:(f Stack_frame.Digest.Checked.equal) ~call_stack:(f Call_stack_digest.Checked.equal) ~transaction_commitment:(f Field.equal) @@ -162,7 +162,7 @@ module Checked = struct ~token_id:(f Token_id.Checked.equal) ~excess:(f !Currency.Amount.Signed.Checked.equal) ~ledger:(f !Ledger_hash.equal_var) ~success:(f Impl.Boolean.equal) - ~party_index:(f !Mina_numbers.Index.Checked.equal) + ~account_update_index:(f !Mina_numbers.Index.Checked.equal) ~failure_status_tbl:(f (fun () () -> Impl.Boolean.true_)) let to_input @@ -174,7 +174,7 @@ module Checked = struct ; excess ; ledger ; success - ; party_index + ; account_update_index ; failure_status_tbl = _ } : t ) = @@ -189,7 +189,7 @@ module Checked = struct ; Token_id.Checked.to_input token_id ; run_checked (Amount.Signed.Checked.to_input excess) ; Ledger_hash.var_to_input ledger - ; Mina_numbers.Index.Checked.to_input party_index + ; Mina_numbers.Index.Checked.to_input account_update_index ; packed ((success :> t), 1) |] end @@ -206,7 +206,7 @@ let failure_status_tbl_typ : ~back:(fun () -> []) let typ : (Checked.t, t) Impl.Typ.t = - let open Mina_transaction_logic.Parties_logic.Local_state in + let open Mina_transaction_logic.Zkapp_command_logic.Local_state in let open Impl in Typ.of_hlistable [ Stack_frame.Digest.typ diff --git a/src/lib/mina_wire_types/mina_base/mina_base.ml b/src/lib/mina_wire_types/mina_base/mina_base.ml index 82ce0b46176..f58759953ba 100644 --- a/src/lib/mina_wire_types/mina_base/mina_base.ml +++ b/src/lib/mina_wire_types/mina_base/mina_base.ml @@ -10,8 +10,8 @@ module Minting_payload = Mina_base_minting_payload module Signature = Mina_base_signature module Signed_command_memo = Mina_base_signed_command_memo module Token_id = Mina_base_token_id -module Party = Mina_base_party -module Parties = Mina_base_parties +module Account_update = Mina_base_account_update +module Zkapp_command = Mina_base_zkapp_command module Account_id = Mina_base_account_id module Zkapp_basic = Mina_base_zkapp_basic module Zkapp_state = Mina_base_zkapp_state diff --git a/src/lib/mina_wire_types/mina_base/mina_base_party.ml b/src/lib/mina_wire_types/mina_base/mina_base_account_update.ml similarity index 100% rename from src/lib/mina_wire_types/mina_base/mina_base_party.ml rename to src/lib/mina_wire_types/mina_base/mina_base_account_update.ml diff --git a/src/lib/mina_wire_types/mina_base/mina_base_user_command.ml b/src/lib/mina_wire_types/mina_base/mina_base_user_command.ml index f0eeef149d9..dbce5c0fe98 100644 --- a/src/lib/mina_wire_types/mina_base/mina_base_user_command.ml +++ b/src/lib/mina_wire_types/mina_base/mina_base_user_command.ml @@ -1,18 +1,19 @@ module Poly = struct module V2 = struct - type ('u, 's) t = Signed_command of 'u | Parties of 's + type ('u, 's) t = Signed_command of 'u | Zkapp_command of 's end end module V2 = struct - type t = (Mina_base_signed_command.V2.t, Mina_base_parties.V1.t) Poly.V2.t + type t = + (Mina_base_signed_command.V2.t, Mina_base_zkapp_command.V1.t) Poly.V2.t end module Valid = struct module V2 = struct type t = ( Mina_base_signed_command.With_valid_signature.V2.t - , Mina_base_parties.Valid.V1.t ) + , Mina_base_zkapp_command.Valid.V1.t ) Poly.V2.t end end diff --git a/src/lib/mina_wire_types/mina_base/mina_base_parties.ml b/src/lib/mina_wire_types/mina_base/mina_base_zkapp_command.ml similarity index 71% rename from src/lib/mina_wire_types/mina_base/mina_base_parties.ml rename to src/lib/mina_wire_types/mina_base/mina_base_zkapp_command.ml index 92e2f41fd4c..2b46f49e38c 100644 --- a/src/lib/mina_wire_types/mina_base/mina_base_parties.ml +++ b/src/lib/mina_wire_types/mina_base/mina_base_zkapp_command.ml @@ -2,7 +2,7 @@ open Utils module Digest_types = struct module type S = sig - module Party : sig + module Account_update : sig module V1 : sig type t = private Pasta_bindings.Fp.t end @@ -17,7 +17,7 @@ module Digest_types = struct end module Digest_M = struct - module Party = struct + module Account_update = struct module V1 = struct type t = Pasta_bindings.Fp.t end @@ -31,7 +31,7 @@ module Digest_M = struct end module type Digest_concrete = sig - module Party : sig + module Account_update : sig module V1 : sig type t = Pasta_bindings.Fp.t end @@ -56,11 +56,11 @@ module Call_forest = struct module Tree = struct module V1 = struct - type ('party, 'party_digest, 'digest) t = - { party : 'party - ; party_digest : 'party_digest + type ('account_update, 'account_update_digest, 'digest) t = + { account_update : 'account_update + ; account_update_digest : 'account_update_digest ; calls : - ( ('party, 'party_digest, 'digest) t + ( ('account_update, 'account_update_digest, 'digest) t , 'digest ) Mina_base_with_stack_hash.V1.t list @@ -69,8 +69,8 @@ module Call_forest = struct end module V1 = struct - type ('party, 'party_digest, 'digest) t = - ( ('party, 'party_digest, 'digest) Tree.V1.t + type ('account_update, 'account_update_digest, 'digest) t = + ( ('account_update, 'account_update_digest, 'digest) Tree.V1.t , 'digest ) Mina_base_with_stack_hash.V1.t list @@ -79,10 +79,10 @@ end module V1 = struct type t = - { fee_payer : Mina_base_party.Fee_payer.V1.t - ; other_parties : - ( Mina_base_party.V1.t - , Call_forest.Digest.Party.V1.t + { fee_payer : Mina_base_account_update.Fee_payer.V1.t + ; account_updates : + ( Mina_base_account_update.V1.t + , Call_forest.Digest.Account_update.V1.t , Call_forest.Digest.Forest.V1.t ) Call_forest.V1.t ; memo : Mina_base_signed_command_memo.V1.t @@ -98,7 +98,7 @@ module Valid = struct module V1 = struct type t = - { parties : V1.t + { zkapp_command : V1.t ; verification_keys : (Mina_base_account_id.V2.t * Verification_key_hash.V1.t) list } diff --git a/src/lib/mina_wire_types/mina_base/mina_base_parties.mli b/src/lib/mina_wire_types/mina_base/mina_base_zkapp_command.mli similarity index 70% rename from src/lib/mina_wire_types/mina_base/mina_base_parties.mli rename to src/lib/mina_wire_types/mina_base/mina_base_zkapp_command.mli index 7b71d0faaa7..a70dc80a335 100644 --- a/src/lib/mina_wire_types/mina_base/mina_base_parties.mli +++ b/src/lib/mina_wire_types/mina_base/mina_base_zkapp_command.mli @@ -2,7 +2,7 @@ open Utils module Digest_types : sig module type S = sig - module Party : sig + module Account_update : sig module V1 : sig type t = private Pasta_bindings.Fp.t end @@ -17,7 +17,7 @@ module Digest_types : sig end module Digest_M : sig - module Party : sig + module Account_update : sig module V1 : sig type t = private Pasta_bindings.Fp.t end @@ -31,7 +31,7 @@ module Digest_M : sig end module type Digest_concrete = sig - module Party : sig + module Account_update : sig module V1 : sig type t = Pasta_bindings.Fp.t end @@ -53,16 +53,16 @@ module Digest_make module Call_forest : sig module Digest : Digest_types.S - with module Party = Digest_M.Party + with module Account_update = Digest_M.Account_update and module Forest = Digest_M.Forest module Tree : sig module V1 : sig - type ('party, 'party_digest, 'digest) t = - { party : 'party - ; party_digest : 'party_digest + type ('account_update, 'account_update_digest, 'digest) t = + { account_update : 'account_update + ; account_update_digest : 'account_update_digest ; calls : - ( ('party, 'party_digest, 'digest) t + ( ('account_update, 'account_update_digest, 'digest) t , 'digest ) Mina_base_with_stack_hash.V1.t list @@ -71,8 +71,8 @@ module Call_forest : sig end module V1 : sig - type ('party, 'party_digest, 'digest) t = - ( ('party, 'party_digest, 'digest) Tree.V1.t + type ('account_update, 'account_update_digest, 'digest) t = + ( ('account_update, 'account_update_digest, 'digest) Tree.V1.t , 'digest ) Mina_base_with_stack_hash.V1.t list @@ -81,10 +81,10 @@ end module V1 : sig type t = - { fee_payer : Mina_base_party.Fee_payer.V1.t - ; other_parties : - ( Mina_base_party.V1.t - , Call_forest.Digest.Party.V1.t + { fee_payer : Mina_base_account_update.Fee_payer.V1.t + ; account_updates : + ( Mina_base_account_update.V1.t + , Call_forest.Digest.Account_update.V1.t , Call_forest.Digest.Forest.V1.t ) Call_forest.V1.t ; memo : Mina_base_signed_command_memo.V1.t @@ -100,7 +100,7 @@ module Valid : sig module V1 : sig type t = - { parties : V1.t + { zkapp_command : V1.t ; verification_keys : (Mina_base_account_id.V2.t * Verification_key_hash.V1.t) list } diff --git a/src/lib/mina_wire_types/test/type_equalities.ml b/src/lib/mina_wire_types/test/type_equalities.ml index ac4e47ea1f9..7c6c44d89f0 100644 --- a/src/lib/mina_wire_types/test/type_equalities.ml +++ b/src/lib/mina_wire_types/test/type_equalities.ml @@ -144,8 +144,13 @@ module Mina_base = struct (O.Signed_command.With_valid_signature.Stable) (W.Signed_command.With_valid_signature) include - Assert_equal0V1 (O.Party.Body.Fee_payer.Stable) (W.Party.Body.Fee_payer) - include Assert_equal0V1 (O.Party.Fee_payer.Stable) (W.Party.Fee_payer) + Assert_equal0V1 + (O.Account_update.Body.Fee_payer.Stable) + (W.Account_update.Body.Fee_payer) + include + Assert_equal0V1 + (O.Account_update.Fee_payer.Stable) + (W.Account_update.Fee_payer) include Assert_equal0V1 (O.Account_id.Digest.Stable) (W.Account_id.Digest) include Assert_equal0V2 (O.Account_id.Stable) (W.Account_id) include Assert_equal0V1 (O.Token_id.Stable) (W.Token_id) @@ -160,23 +165,29 @@ module Mina_base = struct Assert_equal0V1 (O.Account.Token_symbol.Stable) (W.Account.Token_symbol) include Assert_equal0V1 - (O.Party.Update.Timing_info.Stable) - (W.Party.Update.Timing_info) - include Assert_equal0V1 (O.Party.Update.Stable) (W.Party.Update) - include Assert_equal0V1 (O.Party.Body.Events'.Stable) (W.Party.Body.Events') + (O.Account_update.Update.Timing_info.Stable) + (W.Account_update.Update.Timing_info) + include + Assert_equal0V1 (O.Account_update.Update.Stable) (W.Account_update.Update) + include + Assert_equal0V1 + (O.Account_update.Body.Events'.Stable) + (W.Account_update.Body.Events') include Assert_equal0V1 (O.Ledger_hash.Stable) (W.Ledger_hash) include Assert_equal0V1 - (O.Parties.Valid.Verification_key_hash.Stable) - (W.Parties.Valid.Verification_key_hash) + (O.Zkapp_command.Valid.Verification_key_hash.Stable) + (W.Zkapp_command.Valid.Verification_key_hash) + include Assert_equal0V1 - (O.Parties.Call_forest.Digest.Party.Stable) - (W.Parties.Call_forest.Digest.Party) + (O.Zkapp_command.Call_forest.Digest.Account_update.Stable) + (W.Zkapp_command.Call_forest.Digest.AccountUpdate) + include Assert_equal0V1 - (O.Parties.Call_forest.Digest.Forest.Stable) - (W.Parties.Call_forest.Digest.Forest) + (O.Zkapp_command.Call_forest.Digest.Forest.Stable) + (W.Zkapp_command.Call_forest.Digest.Forest) include Assert_equal0V1 (O.Ledger_hash.Stable) (W.Ledger_hash) include Assert_equal0V1 @@ -192,10 +203,13 @@ module Mina_base = struct (W.Zkapp_precondition.Account) include Assert_equal0V1 - (O.Party.Account_precondition.Stable) - (W.Party.Account_precondition) - include Assert_equal0V1 (O.Party.Preconditions.Stable) (W.Party.Preconditions) - include Assert_equal0V1 (O.Party.Body.Stable) (W.Party.Body) + (O.Account_update.Account_precondition.Stable) + (W.Account_update.Account_precondition) + include + Assert_equal0V1 + (O.Account_update.Preconditions.Stable) + (W.Account_update.Preconditions) + include Assert_equal0V1 (O.Account_update.Body.Stable) (W.Account_update.Body) include Assert_equal0V2 (O.Fee_transfer.Single.Stable) (W.Fee_transfer.Single) include Assert_equal0V2 (O.Fee_transfer.Stable) (W.Fee_transfer) include @@ -204,13 +218,16 @@ module Mina_base = struct include Assert_equal2V1 (O.With_stack_hash.Stable) (W.With_stack_hash) include Assert_equal3V1 - (O.Parties.Call_forest.Tree.Stable) - (W.Parties.Call_forest.Tree) - include Assert_equal3V1 (O.Parties.Call_forest.Stable) (W.Parties.Call_forest) + (O.Zkapp_command.Call_forest.Tree.Stable) + (W.Zkapp_command.Call_forest.Tree) + include + Assert_equal3V1 + (O.Zkapp_command.Call_forest.Stable) + (W.Zkapp_command.Call_forest) include Assert_equal0V2 (O.Control.Stable) (W.Control) - include Assert_equal0V1 (O.Party.Stable) (W.Party) - include Assert_equal0V1 (O.Parties.Stable) (W.Parties) - include Assert_equal0V1 (O.Parties.Valid.Stable) (W.Parties.Valid) + include Assert_equal0V1 (O.Account_update.Stable) (W.AccountUpdate) + include Assert_equal0V1 (O.Zkapp_command.Stable) (W.Zkapp_command) + include Assert_equal0V1 (O.Zkapp_command.Valid.Stable) (W.Zkapp_command.Valid) include Assert_equal0V2 (O.User_command.Stable) (W.User_command) include Assert_equal0V2 (O.User_command.Valid.Stable) (W.User_command.Valid) end diff --git a/src/lib/network_pool/dune b/src/lib/network_pool/dune index d15bf42e3dd..69c1cbfbe02 100644 --- a/src/lib/network_pool/dune +++ b/src/lib/network_pool/dune @@ -67,7 +67,7 @@ mina_ledger mina_base.import snark_params - parties_builder + zkapp_command_builder ppx_version.runtime random_oracle_input kimchi_backend diff --git a/src/lib/network_pool/indexed_pool.ml b/src/lib/network_pool/indexed_pool.ml index 97fecbda8a3..7a3f00c1948 100644 --- a/src/lib/network_pool/indexed_pool.ml +++ b/src/lib/network_pool/indexed_pool.ml @@ -125,7 +125,7 @@ let currency_consumed_unchecked : amount | Stake_delegation _ -> zero ) - | Parties _ -> + | Zkapp_command _ -> (*TODO: document- txns succeeds with source amount insufficient in the case of zkapps*) zero in @@ -512,13 +512,15 @@ module Update = struct Transaction_hash.User_command_with_valid_signature.hash cmd in ( match Transaction_hash.User_command_with_valid_signature.data cmd with - | Parties p -> - let p = Parties.Valid.forget p in + | Zkapp_command p -> + let p = Zkapp_command.Valid.forget p in Mina_metrics.Gauge.set - Mina_metrics.Transaction_pool.parties_transaction_size - (Parties.Stable.Latest.bin_size_t p |> Float.of_int) ; - Mina_metrics.Gauge.set Mina_metrics.Transaction_pool.parties_count - (List.length (Parties.to_simple p).other_parties |> Float.of_int) + Mina_metrics.Transaction_pool.zkapp_command_transaction_size + (Zkapp_command.Stable.Latest.bin_size_t p |> Float.of_int) ; + Mina_metrics.Gauge.set + Mina_metrics.Transaction_pool.zkapp_command_count + ( List.length (Zkapp_command.to_simple p).account_updates + |> Float.of_int ) | Signed_command _ -> () ) ; { acc with @@ -881,14 +883,16 @@ let expired_by_predicate (t : t) : |> Sequence.filter_map ~f:(fun (cmd_hash, cmd) -> Transaction_hash.User_command_with_valid_signature.data cmd |> function - | User_command.Parties (ps : Parties.Valid.t) -> - Some (cmd_hash, ps.parties) + | User_command.Zkapp_command (ps : Zkapp_command.Valid.t) -> + Some (cmd_hash, ps.zkapp_command) | User_command.Signed_command _ -> None ) |> Sequence.filter ~f:(fun (_, ps) -> - ps.other_parties - |> Parties.Call_forest.exists ~f:(fun party -> - let predicate = Party.protocol_state_precondition party in + ps.account_updates + |> Zkapp_command.Call_forest.exists ~f:(fun account_update -> + let predicate = + Account_update.protocol_state_precondition account_update + in match predicate.timestamp with | Check { upper; _ } -> Block_time.(upper < of_time_ns expiry_time) @@ -978,10 +982,12 @@ module Add_from_gossip_exn (M : Writer_result.S) = struct match user_command with | User_command.Signed_command _ -> true - | User_command.Parties ps -> - ps.other_parties - |> Parties.Call_forest.exists ~f:(fun party -> - let predicate = Party.protocol_state_precondition party in + | User_command.Zkapp_command ps -> + ps.account_updates + |> Zkapp_command.Call_forest.exists ~f:(fun account_update -> + let predicate = + Account_update.protocol_state_precondition account_update + in match predicate.timestamp with | Check { lower; upper } -> (*Timestamp bounds are compared against slot start time of @@ -1413,7 +1419,7 @@ let%test_module _ = let%test_unit "age-based expiry" = Quickcheck.test ~trials:1 - (Mina_generators.User_command_generators.parties_with_ledger ()) + (Mina_generators.User_command_generators.zkapp_command_with_ledger ()) ~f:(fun (cmd, _, _, _) -> let cmd = Transaction_hash.User_command_with_valid_signature.create cmd @@ -1861,17 +1867,18 @@ let%test_module _ = : Mina_transaction_logic.Transaction_applied .Signed_command_applied .t ) - | User_command.Parties p -> ( + | User_command.Zkapp_command p -> ( let applied, _ = - Mina_ledger.Ledger.apply_parties_unchecked ~constraint_constants - ~state_view:dummy_state_view ledger p + Mina_ledger.Ledger.apply_zkapp_command_unchecked + ~constraint_constants ~state_view:dummy_state_view ledger p |> Or_error.ok_exn in match With_status.status applied.command with | Transaction_status.Applied -> () | Transaction_status.Failed failure -> - failwithf "failed to apply parties transaction to ledger: [%s]" + failwithf + "failed to apply zkapp_command transaction to ledger: [%s]" ( String.concat ~sep:", " @@ List.bind ~f:(List.map ~f:Transaction_status.Failure.to_string) @@ -1910,24 +1917,25 @@ let%test_module _ = assert_invariants pool ; pool - let make_parties_payment ~(sender : Keypair.t) ~(receiver : Keypair.t) + let make_zkapp_command_payment ~(sender : Keypair.t) ~(receiver : Keypair.t) ~double_increment_sender ~increment_receiver ~amount ~fee nonce_int = let open Currency in let nonce = Account.Nonce.of_int nonce_int in let sender_pk = Public_key.compress sender.public_key in let receiver_pk = Public_key.compress receiver.public_key in - let parties_wire : Parties.Stable.Latest.Wire.t = + let zkapp_command_wire : Zkapp_command.Stable.Latest.Wire.t = { fee_payer = - { Party.Fee_payer.body = + { Account_update.Fee_payer.body = { public_key = sender_pk; fee; nonce; valid_until = None } (* Real signature added in below *) ; authorization = Signature.dummy } - ; other_parties = - Parties.Call_forest.of_parties_list ~party_depth:(Fn.const 0) - [ { Party.Wire.body = + ; account_updates = + Zkapp_command.Call_forest.of_zkapp_command_list + ~account_update_depth:(Fn.const 0) + [ { Account_update.Wire.body = { public_key = sender_pk - ; update = Party.Update.noop + ; update = Account_update.Update.noop ; token_id = Token_id.default ; balance_change = Amount.Signed.(negate @@ of_unsigned amount) @@ -1936,10 +1944,10 @@ let%test_module _ = ; sequence_events = [] ; call_data = Snark_params.Tick.Field.zero ; preconditions = - { Party.Preconditions.network = + { Account_update.Preconditions.network = Zkapp_precondition.Protocol_state.accept ; account = - Party.Account_precondition.Nonce + Account_update.Account_precondition.Nonce (Account.Nonce.succ nonce) } ; caller = Call @@ -1947,9 +1955,9 @@ let%test_module _ = } ; authorization = None_given } - ; { Party.Wire.body = + ; { Account_update.Wire.body = { public_key = receiver_pk - ; update = Party.Update.noop + ; update = Account_update.Update.noop ; token_id = Token_id.default ; balance_change = Amount.Signed.of_unsigned amount ; increment_nonce = increment_receiver @@ -1957,9 +1965,9 @@ let%test_module _ = ; sequence_events = [] ; call_data = Snark_params.Tick.Field.zero ; preconditions = - { Party.Preconditions.network = + { Account_update.Preconditions.network = Zkapp_precondition.Protocol_state.accept - ; account = Party.Account_precondition.Accept + ; account = Account_update.Account_precondition.Accept } ; caller = Call ; use_full_commitment = not increment_receiver @@ -1970,14 +1978,14 @@ let%test_module _ = ; memo = Signed_command_memo.empty } in - let parties = Parties.of_wire parties_wire in + let zkapp_command = Zkapp_command.of_wire zkapp_command_wire in (* We skip signing the commitment and updating the authorization as it is not necessary to have a valid transaction for these tests. *) let (`If_this_is_used_it_should_have_a_comment_justifying_it cmd) = - User_command.to_valid_unsafe (User_command.Parties parties) + User_command.to_valid_unsafe (User_command.Zkapp_command zkapp_command) in Transaction_hash.User_command_with_valid_signature.create cmd - let%test_unit "support for parties commands" = + let%test_unit "support for zkapp_command commands" = let open Currency in (* let open Mina_transaction_logic.For_tests in *) let fee = Mina_compile_config.minimum_user_command_fee in @@ -1991,8 +1999,8 @@ let%test_module _ = in let add_cmd = add_to_pool ~nonce:Account_nonce.zero ~balance in let make_cmd = - make_parties_payment ~sender:kp1 ~receiver:kp2 ~increment_receiver:false - ~amount ~fee + make_zkapp_command_payment ~sender:kp1 ~receiver:kp2 + ~increment_receiver:false ~amount ~fee in Mina_ledger.Ledger.with_ledger ~depth:4 ~f:(fun ledger -> init_permissionless_ledger ledger @@ -2012,8 +2020,8 @@ let%test_module _ = let _pool = commit pool cmd3' [ cmd3; cmd4 ] in () ) - let%test_unit "nonce increment side effects from other parties are handled \ - properly" = + let%test_unit "nonce increment side effects from other zkapp_command are \ + handled properly" = let open Currency in let fee = Mina_compile_config.minimum_user_command_fee in let amount = Amount.of_int @@ Fee.to_int fee in @@ -2025,7 +2033,7 @@ let%test_module _ = Quickcheck.random_value ~seed:(`Deterministic "orange") Keypair.gen in let add_cmd = add_to_pool ~nonce:Account_nonce.zero ~balance in - let make_cmd = make_parties_payment ~amount ~fee in + let make_cmd = make_zkapp_command_payment ~amount ~fee in Mina_ledger.Ledger.with_ledger ~depth:4 ~f:(fun ledger -> init_permissionless_ledger ledger [ (kp1.public_key, balance); (kp2.public_key, balance) ] ; @@ -2065,7 +2073,7 @@ let%test_module _ = in let add_cmd = add_to_pool ~nonce:Account_nonce.zero ~balance in let make_cmd = - make_parties_payment ~sender:kp1 ~receiver:kp2 + make_zkapp_command_payment ~sender:kp1 ~receiver:kp2 ~double_increment_sender:false ~increment_receiver:false ~amount ~fee in Mina_ledger.Ledger.with_ledger ~depth:4 ~f:(fun ledger -> diff --git a/src/lib/network_pool/transaction_pool.ml b/src/lib/network_pool/transaction_pool.ml index 6d4adc04cd4..cd9f54f76ef 100644 --- a/src/lib/network_pool/transaction_pool.ml +++ b/src/lib/network_pool/transaction_pool.ml @@ -1599,30 +1599,30 @@ let%test_module _ = report_additional additional2 "expected" "actual" ) ; [%test_eq: Transaction_hash.Set.t] set1 set2 - let replace_valid_parties_authorizations ~keymap ~ledger valid_cmds : + let replace_valid_zkapp_command_authorizations ~keymap ~ledger valid_cmds : User_command.Valid.t list Deferred.t = Deferred.List.map (valid_cmds : User_command.Valid.t list) ~f:(function - | Parties parties_dummy_auths -> - let%map parties = - Parties_builder.replace_authorizations ~keymap ~prover - (Parties.Valid.forget parties_dummy_auths) + | Zkapp_command zkapp_command_dummy_auths -> + let%map zkapp_command = + Zkapp_command_builder.replace_authorizations ~keymap ~prover + (Zkapp_command.Valid.forget zkapp_command_dummy_auths) in - let valid_parties = + let valid_zkapp_command = let open Mina_ledger.Ledger in match - Parties.Valid.to_valid ~ledger ~get ~location_of_account - parties + Zkapp_command.Valid.to_valid ~ledger ~get ~location_of_account + zkapp_command with | Some ps -> ps | None -> - failwith "Could not create Parties.Valid.t" + failwith "Could not create Zkapp_command.Valid.t" in - User_command.Parties valid_parties + User_command.Zkapp_command valid_zkapp_command | Signed_command _ -> - failwith "Expected Parties valid user command" ) + failwith "Expected Zkapp_command valid user command" ) (** Assert the invariants of the locally generated command tracking system. *) let assert_locally_generated (pool : Test.Resource_pool.t) = @@ -1740,7 +1740,7 @@ let%test_module _ = ; amount = Currency.Amount.of_int amount } ) ) - let mk_transfer_parties ?valid_period ?fee_payer_idx ~sender_idx + let mk_transfer_zkapp_command ?valid_period ?fee_payer_idx ~sender_idx ~receiver_idx ~fee ~nonce ~amount () = let sender_kp = test_keys.(sender_idx) in let sender_nonce = Account.Nonce.of_int nonce in @@ -1776,32 +1776,35 @@ let%test_module _ = ; zkapp_account_keypairs = [] ; memo = Signed_command_memo.create_from_string_exn "expiry tests" ; new_zkapp_account = false - ; snapp_update = Party.Update.dummy + ; snapp_update = Account_update.Update.dummy ; current_auth = Permissions.Auth_required.Signature ; call_data = Snark_params.Tick.Field.zero ; events = [] ; sequence_events = [] ; preconditions = Some - { Party.Preconditions.network = protocol_state_precondition + { Account_update.Preconditions.network = + protocol_state_precondition ; account = - Party.Account_precondition.Nonce + Account_update.Account_precondition.Nonce ( if Option.is_none fee_payer then Account.Nonce.succ sender_nonce else sender_nonce ) } } in - let parties = Transaction_snark.For_tests.multiple_transfers test_spec in - let parties = + let zkapp_command = + Transaction_snark.For_tests.multiple_transfers test_spec + in + let zkapp_command = Option.value_exn - (Parties.Valid.to_valid ~ledger:() - ~get:(fun _ _ -> failwith "Not expecting proof parties") + (Zkapp_command.Valid.to_valid ~ledger:() + ~get:(fun _ _ -> failwith "Not expecting proof zkapp_command") ~location_of_account:(fun _ _ -> - failwith "Not expecting proof parties" ) - parties ) + failwith "Not expecting proof zkapp_command" ) + zkapp_command ) in - User_command.Parties parties + User_command.Zkapp_command zkapp_command let mk_payment ?valid_until ~sender_idx ~receiver_idx ~fee ~nonce ~amount () = @@ -1809,7 +1812,7 @@ let%test_module _ = (mk_payment' ?valid_until ~sender_idx ~fee ~nonce ~receiver_idx ~amount () ) - let mk_parties_cmds (pool : Test.Resource_pool.t) : + let mk_zkapp_command_cmds (pool : Test.Resource_pool.t) : User_command.Valid.t list Deferred.t = let num_cmds = 7 in assert (num_cmds < Array.length test_keys - 1) ; @@ -1844,15 +1847,16 @@ let%test_module _ = if n < num_cmds then let%bind cmd = let fee_payer_keypair = test_keys.(n) in - let%map (parties : Parties.t) = - Mina_generators.Parties_generators.gen_parties_from ~keymap - ~account_state_tbl ~fee_payer_keypair ~ledger:best_tip_ledger () + let%map (zkapp_command : Zkapp_command.t) = + Mina_generators.Zkapp_command_generators.gen_zkapp_command_from + ~keymap ~account_state_tbl ~fee_payer_keypair + ~ledger:best_tip_ledger () in - let parties = - { parties with - other_parties = - Parties.Call_forest.map parties.other_parties - ~f:(fun (p : Party.t) -> + let zkapp_command = + { zkapp_command with + account_updates = + Zkapp_command.Call_forest.map zkapp_command.account_updates + ~f:(fun (p : Account_update.t) -> { p with body = { p.body with @@ -1860,16 +1864,18 @@ let%test_module _ = { p.body.preconditions with account = ( match p.body.preconditions.account with - | Party.Account_precondition.Full + | Account_update.Account_precondition.Full { nonce = Zkapp_basic.Or_ignore.Check n as c ; _ } when Zkapp_precondition.Numeric.( is_constant Tc.nonce c) -> - Party.Account_precondition.Nonce n.lower - | Party.Account_precondition.Full _ -> - Party.Account_precondition.Accept + Account_update.Account_precondition.Nonce + n.lower + | Account_update.Account_precondition.Full _ + -> + Account_update.Account_precondition.Accept | pre -> pre ) } @@ -1877,22 +1883,22 @@ let%test_module _ = } ) } in - let parties = + let zkapp_command = Option.value_exn - (Parties.Valid.to_valid ~ledger:best_tip_ledger + (Zkapp_command.Valid.to_valid ~ledger:best_tip_ledger ~get:Mina_ledger.Ledger.get ~location_of_account:Mina_ledger.Ledger.location_of_account - parties ) + zkapp_command ) in - User_command.Parties parties + User_command.Zkapp_command zkapp_command in go (n + 1) (cmd :: cmds) else Quickcheck.Generator.return @@ List.rev cmds in let result = - Quickcheck.random_value ~seed:(`Deterministic "parties") (go 0 []) + Quickcheck.random_value ~seed:(`Deterministic "zkapp_command") (go 0 []) in - replace_valid_parties_authorizations ~keymap ~ledger:best_tip_ledger + replace_valid_zkapp_command_authorizations ~keymap ~ledger:best_tip_ledger result type pool_apply = (User_command.t list, [ `Other of Error.t ]) Result.t @@ -1987,16 +1993,16 @@ let%test_module _ = failwith "failed to apply user command to ledger" | _ -> () ) - | User_command.Parties p -> ( + | User_command.Zkapp_command p -> ( let applied, _ = Or_error.ok_exn - @@ Mina_ledger.Ledger.apply_parties_unchecked + @@ Mina_ledger.Ledger.apply_zkapp_command_unchecked ~constraint_constants ~state_view:dummy_state_view ledger p in match With_status.status applied.command with | Failed failures -> failwithf - "failed to apply parties transaction to ledger: [%s]" + "failed to apply zkapp_command transaction to ledger: [%s]" ( String.concat ~sep:", " @@ List.bind ~f:(List.map ~f:Transaction_status.Failure.to_string) @@ -2053,7 +2059,7 @@ let%test_module _ = let%test_unit "transactions are removed in linear case (zkapps)" = Thread_safe.block_on_async_exn (fun () -> let%bind test = setup_test () in - mk_parties_cmds test.txn_pool >>= mk_linear_case_test test ) + mk_zkapp_command_cmds test.txn_pool >>= mk_linear_case_test test ) let mk_remove_and_add_test t cmds = assert_pool_txs t [] ; @@ -2074,7 +2080,7 @@ let%test_module _ = (zkapps)" = Thread_safe.block_on_async_exn (fun () -> let%bind test = setup_test () in - mk_parties_cmds test.txn_pool >>= mk_remove_and_add_test test ) + mk_zkapp_command_cmds test.txn_pool >>= mk_remove_and_add_test test ) let mk_invalid_test t cmds = assert_pool_txs t [] ; @@ -2093,7 +2099,7 @@ let%test_module _ = let%test_unit "invalid transactions are not accepted (zkapps)" = Thread_safe.block_on_async_exn (fun () -> let%bind test = setup_test () in - mk_parties_cmds test.txn_pool >>= mk_invalid_test test ) + mk_zkapp_command_cmds test.txn_pool >>= mk_invalid_test test ) let current_global_slot () = let current_time = Block_time.now time_controller in @@ -2127,10 +2133,11 @@ let%test_module _ = changes (zkapps)" = Thread_safe.block_on_async_exn (fun () -> let%bind test = setup_test () in - mk_parties_cmds test.txn_pool + mk_zkapp_command_cmds test.txn_pool >>= mk_now_invalid_test test ~mk_command: - (mk_transfer_parties ?valid_period:None ?fee_payer_idx:None) ) + (mk_transfer_zkapp_command ?valid_period:None + ?fee_payer_idx:None ) ) let mk_expired_not_accepted_test t ~padding cmds = assert_pool_txs t [] ; @@ -2183,7 +2190,7 @@ let%test_module _ = let%test_unit "expired transactions are not accepted (zkapps)" = Thread_safe.block_on_async_exn (fun () -> let%bind test = setup_test () in - mk_parties_cmds test.txn_pool + mk_zkapp_command_cmds test.txn_pool >>= mk_expired_not_accepted_test test ~padding:55 ) let%test_unit "Expired transactions that are already in the pool are \ @@ -2299,13 +2306,13 @@ let%test_module _ = List.take independent_cmds (List.length independent_cmds / 2) in let expires_later1 = - mk_transfer_parties + mk_transfer_zkapp_command ~valid_period:{ lower = curr_time; upper = curr_time_plus_three } ~fee_payer_idx:(0, 1) ~sender_idx:1 ~receiver_idx:9 ~fee:minimum_fee ~amount:10_000_000_000 ~nonce:1 () in let expires_later2 = - mk_transfer_parties + mk_transfer_zkapp_command ~valid_period:{ lower = curr_time; upper = curr_time_plus_seven } ~fee_payer_idx:(0, 2) ~sender_idx:1 ~receiver_idx:9 ~fee:minimum_fee ~amount:10_000_000_000 ~nonce:2 () @@ -2323,13 +2330,13 @@ let%test_module _ = assert_pool_txs t (expires_later2 :: List.drop few_now 2) ; (* Add new commands, remove old commands some of which are now expired *) let expired_zkapp = - mk_transfer_parties + mk_transfer_zkapp_command ~valid_period:{ lower = curr_time; upper = curr_time } ~fee_payer_idx:(9, 0) ~sender_idx:1 ~fee:minimum_fee ~nonce:3 ~receiver_idx:5 ~amount:1_000_000_000 () in let unexpired_zkapp = - mk_transfer_parties + mk_transfer_zkapp_command ~valid_period:{ lower = curr_time; upper = curr_time_plus_seven } ~fee_payer_idx:(8, 0) ~sender_idx:1 ~fee:minimum_fee ~nonce:4 ~receiver_idx:9 ~amount:1_000_000_000 () @@ -2371,12 +2378,12 @@ let%test_module _ = let expiry = Time_ns.Span.of_sec 1. in let%bind t = setup_test ~expiry () in assert_pool_txs t [] ; - let party_transfer = - mk_transfer_parties ~fee_payer_idx:(0, 0) ~sender_idx:1 + let account_update_transfer = + mk_transfer_zkapp_command ~fee_payer_idx:(0, 0) ~sender_idx:1 ~receiver_idx:9 ~fee:minimum_fee ~amount:10_000_000_000 ~nonce:0 () in - let valid_commands = [ party_transfer ] in + let valid_commands = [ account_update_transfer ] in let%bind () = add_commands' t valid_commands in assert_pool_txs t valid_commands ; let%bind () = after (Time.Span.of_sec 2.) in @@ -2626,7 +2633,7 @@ let%test_module _ = let%test_unit "rebroadcastable transaction behavior (zkapps)" = Thread_safe.block_on_async_exn (fun () -> let%bind test = setup_test () in - mk_parties_cmds test.txn_pool >>= mk_rebroadcastable_test test ) + mk_zkapp_command_cmds test.txn_pool >>= mk_rebroadcastable_test test ) let%test_unit "apply user cmds and zkapps" = Thread_safe.block_on_async_exn (fun () -> @@ -2639,7 +2646,7 @@ let%test_module _ = *) let take_len = num_cmds / 2 in let%bind snapp_cmds = - let%map cmds = mk_parties_cmds t.txn_pool in + let%map cmds = mk_zkapp_command_cmds t.txn_pool in List.take cmds take_len in let user_cmds = List.drop independent_cmds take_len in diff --git a/src/lib/pickles/pickles.ml b/src/lib/pickles/pickles.ml index 93dc3fa30c2..945920ce9d3 100644 --- a/src/lib/pickles/pickles.ml +++ b/src/lib/pickles/pickles.ml @@ -1164,13 +1164,13 @@ module Make_str (_ : Wire_types.Concrete) = struct "0x2340A5795E22C7C923991D225400D0052B3A995C35BCCDC612E6205287419EC1" ) in - let at_party = + let at_account_update = Backend.Tick.Field.t_of_sexp (Atom "0x2340A5795E22C7C923991D225400D0052B3A995C35BCCDC612E6205287419EC1" ) in - [| transaction; at_party |] + [| transaction; at_account_update |] in let vk = Side_loaded.Verification_key.of_base58_check_exn diff --git a/src/lib/runtime_config/runtime_config.ml b/src/lib/runtime_config/runtime_config.ml index 6d1c8be43d9..bcee6585115 100644 --- a/src/lib/runtime_config/runtime_config.ml +++ b/src/lib/runtime_config/runtime_config.ml @@ -328,8 +328,8 @@ module Json_layout = struct { txpool_max_size : int option [@default None] ; peer_list_url : string option [@default None] ; transaction_expiry_hr : int option [@default None] - ; max_proof_parties : int option [@default None] - ; max_parties : int option [@default None] + ; max_proof_zkapp_command : int option [@default None] + ; max_zkapp_command : int option [@default None] ; max_event_elements : int option [@default None] ; max_sequence_event_elements : int option [@default None] } @@ -785,8 +785,8 @@ module Daemon = struct { txpool_max_size : int option ; peer_list_url : string option ; transaction_expiry_hr : int option - ; max_proof_parties : int option [@default None] - ; max_parties : int option [@default None] + ; max_proof_zkapp_command : int option [@default None] + ; max_zkapp_command : int option [@default None] ; max_event_elements : int option [@default None] ; max_sequence_event_elements : int option [@default None] } @@ -809,9 +809,11 @@ module Daemon = struct ; transaction_expiry_hr = opt_fallthrough ~default:t1.transaction_expiry_hr t2.transaction_expiry_hr - ; max_proof_parties = - opt_fallthrough ~default:t1.max_proof_parties t2.max_proof_parties - ; max_parties = opt_fallthrough ~default:t1.max_parties t2.max_parties + ; max_proof_zkapp_command = + opt_fallthrough ~default:t1.max_proof_zkapp_command + t2.max_proof_zkapp_command + ; max_zkapp_command = + opt_fallthrough ~default:t1.max_zkapp_command t2.max_zkapp_command ; max_event_elements = opt_fallthrough ~default:t1.max_event_elements t2.max_event_elements ; max_sequence_event_elements = diff --git a/src/lib/snark_worker/functor.ml b/src/lib/snark_worker/functor.ml index c1d087d3655..217644e7b21 100644 --- a/src/lib/snark_worker/functor.ml +++ b/src/lib/snark_worker/functor.ml @@ -46,14 +46,15 @@ type Structured_log_events.t += | Base_snark_generated of { time : Time_span_with_json.t ; transaction_type : String_with_json.t - ; parties_count : Int_with_json.t - ; proof_parties_count : Int_with_json.t + ; zkapp_command_count : Int_with_json.t + ; proof_zkapp_command_count : Int_with_json.t } [@@deriving register_event { msg = "Base SNARK generated in $time for $transaction_type transaction \ - with $parties_count parties and $proof_parties_count proof parties" + with $zkapp_command_count zkapp_command and \ + $proof_zkapp_command_count proof zkapp_command" }] module Make (Inputs : Intf.Inputs_intf) : @@ -159,24 +160,29 @@ module Make (Inputs : Intf.Inputs_intf) : Cryptography.snark_work_merge_time_sec (Time.Span.to_sec time)) ; [%str_log info] (Merge_snark_generated { time }) | `Transition -> - let transaction_type, parties_count, proof_parties_count = + let transaction_type, zkapp_command_count, proof_zkapp_command_count + = (*should be Some in the case of `Transition*) match Option.value_exn single with | Mina_transaction.Transaction.Command - (Mina_base.User_command.Parties parties) -> + (Mina_base.User_command.Zkapp_command zkapp_command) -> let c, p = - Mina_base.Parties.Call_forest.fold - parties.Mina_base.Parties.other_parties ~init:(1, 0) - ~f:(fun (count, proof_parties_count) party -> + Mina_base.Zkapp_command.Call_forest.fold + zkapp_command.Mina_base.Zkapp_command.account_updates + ~init:(1, 0) + ~f:(fun (count, proof_zkapp_command_count) account_update + -> ( count + 1 , if Mina_base.Control.( Tag.equal Proof - (tag (Mina_base.Party.authorization party))) - then proof_parties_count + 1 - else proof_parties_count ) ) + (tag + (Mina_base.Account_update.authorization + account_update ) )) + then proof_zkapp_command_count + 1 + else proof_zkapp_command_count ) ) in - ("parties", c, p) + ("zkapp_command", c, p) | Command (Signed_command _) -> ("signed command", 1, 0) | Coinbase _ -> @@ -189,8 +195,11 @@ module Make (Inputs : Intf.Inputs_intf) : Cryptography.snark_work_base_time_sec (Time.Span.to_sec time)) ; [%str_log info] (Base_snark_generated - { time; transaction_type; parties_count; proof_parties_count } - ) ) + { time + ; transaction_type + ; zkapp_command_count + ; proof_zkapp_command_count + } ) ) let main (module Rpcs_versioned : Intf.Rpcs_versioned_S diff --git a/src/lib/snark_worker/prod.ml b/src/lib/snark_worker/prod.ml index 8a8ef2cbca9..6ee63e7960a 100644 --- a/src/lib/snark_worker/prod.ml +++ b/src/lib/snark_worker/prod.ml @@ -56,9 +56,9 @@ module Inputs = struct Snark_work_lib.Work.Single.Spec.Stable.Latest.t [@@deriving bin_io_unversioned, sexp] - type parties_inputs = - ( Transaction_witness.Parties_segment_witness.t - * Transaction_snark.Parties_segment.Basic.t + type zkapp_command_inputs = + ( Transaction_witness.Zkapp_command_segment_witness.t + * Transaction_snark.Zkapp_command_segment.Basic.t * Transaction_snark.Statement.With_sok.t ) list [@@deriving sexp, to_yojson] @@ -101,10 +101,10 @@ module Inputs = struct -> process (fun () -> match w.transaction with - | Command (Parties parties) -> ( + | Command (Zkapp_command zkapp_command) -> ( let%bind witnesses_specs_stmts = Or_error.try_with (fun () -> - Transaction_snark.parties_witnesses_exn + Transaction_snark.zkapp_command_witnesses_exn ~constraint_constants:M.constraint_constants ~state_body:w.protocol_state_body ~fee_excess:Currency.Amount.Signed.zero @@ -118,14 +118,14 @@ module Inputs = struct ; target = input.target.pending_coinbase_stack } - , parties ) + , zkapp_command ) ] |> fst |> List.rev ) |> Result.map_error ~f:(fun e -> Error.createf - !"Failed to generate inputs for parties : \ - %s: %s" - ( Parties.to_yojson parties + !"Failed to generate inputs for \ + zkapp_command : %s: %s" + ( Zkapp_command.to_yojson zkapp_command |> Yojson.Safe.to_string ) (Error.to_string_hum e) ) |> Deferred.return @@ -144,14 +144,16 @@ module Inputs = struct $error" ~metadata: [ ( "spec" - , Transaction_snark.Parties_segment.Basic + , Transaction_snark.Zkapp_command_segment + .Basic .to_yojson spec ) ; ( "statement" , Transaction_snark.Statement.With_sok .to_yojson statement ) ; ("error", `String (Error.to_string_hum e)) ; ( "inputs" - , parties_inputs_to_yojson all_inputs ) + , zkapp_command_inputs_to_yojson + all_inputs ) ] ; Error e in @@ -175,7 +177,8 @@ module Inputs = struct (Ledger_proof.statement curr) ) ; ("error", `String (Error.to_string_hum e)) ; ( "inputs" - , parties_inputs_to_yojson all_inputs ) + , zkapp_command_inputs_to_yojson + all_inputs ) ] ; Error e in @@ -188,7 +191,7 @@ module Inputs = struct log_base_snark ~statement:{ stmt with sok_digest } ~spec ~all_inputs:inputs - (M.of_parties_segment_exn ~witness) + (M.of_zkapp_command_segment_exn ~witness) in let%map (p : Ledger_proof.t) = @@ -201,7 +204,7 @@ module Inputs = struct log_base_snark ~statement:{ stmt with sok_digest } ~spec ~all_inputs:inputs - (M.of_parties_segment_exn ~witness) + (M.of_zkapp_command_segment_exn ~witness) in log_merge_snark ~sok_digest prev curr ~all_inputs:inputs ) @@ -212,7 +215,7 @@ module Inputs = struct then p else ( [%log fatal] - "Parties transaction final statement \ + "Zkapp_command transaction final statement \ mismatch Expected $expected Got $got. All \ inputs: $inputs" ~metadata: @@ -222,11 +225,12 @@ module Inputs = struct ; ( "expected" , Transaction_snark.Statement.to_yojson input ) - ; ("inputs", parties_inputs_to_yojson inputs) + ; ( "inputs" + , zkapp_command_inputs_to_yojson inputs ) ] ; failwith - "Parties transaction final statement mismatch" - ) ) + "Zkapp_command transaction final statement \ + mismatch" ) ) | _ -> let%bind t = Deferred.return @@ -241,7 +245,7 @@ module Inputs = struct | None -> Or_error.errorf "Command has an invalid signature" ) - | Command (Parties _) -> + | Command (Zkapp_command _) -> assert false | Fee_transfer ft -> Ok (Fee_transfer ft) @@ -249,7 +253,7 @@ module Inputs = struct Ok (Coinbase cb) in Deferred.Or_error.try_with ~here:[%here] (fun () -> - M.of_non_parties_transaction + M.of_non_zkapp_command_transaction ~statement:{ input with sok_digest } { Transaction_protocol_state.Poly.transaction = t diff --git a/src/lib/snarky_js_bindings/lib/snarky_js_bindings_lib.ml b/src/lib/snarky_js_bindings/lib/snarky_js_bindings_lib.ml index cdc40c554be..6daa4d1f64d 100644 --- a/src/lib/snarky_js_bindings/lib/snarky_js_bindings_lib.ml +++ b/src/lib/snarky_js_bindings/lib/snarky_js_bindings_lib.ml @@ -1146,9 +1146,9 @@ let poseidon = val body = Js.string (zkapp_body :> string) - val partyCons = Js.string (party_cons :> string) + val accountUpdateCons = Js.string (account_update_cons :> string) - val partyNode = Js.string (party_node :> string) + val accountUpdateNode = Js.string (account_update_node :> string) end end @@ -2128,7 +2128,7 @@ let pickles_digest (choices : pickles_rule_js Js.js_array Js.t) ~auxiliary_typ:Typ.unit ~branches:(module Branches) ~max_proofs_verified:(module Pickles_types.Nat.N0) - (* ^ TODO make max_branching configurable -- needs refactor in party types *) + (* ^ TODO make max_branching configurable -- needs refactor in account_update types *) ~name ~constraint_constants in failwith "Unexpected: The exception will always fire" @@ -2152,7 +2152,7 @@ let pickles_compile (choices : pickles_rule_js Js.js_array Js.t) ~auxiliary_typ:Typ.unit ~branches:(module Branches) ~max_proofs_verified:(module Max_proofs_verified) - (* ^ TODO make max_branching configurable -- needs refactor in party types *) + (* ^ TODO make max_branching configurable -- needs refactor in account_update types *) ~name ~constraint_constants in let module Proof = (val p) in @@ -2617,65 +2617,72 @@ module Ledger = struct end end - module Party = Mina_base.Party - module Parties = Mina_base.Parties + module Account_update = Mina_base.Account_update + module Zkapp_command = Mina_base.Zkapp_command - let party_of_json = + let account_update_of_json = let deriver = - Party.Graphql_repr.deriver @@ Fields_derivers_zkapps.Derivers.o () + Account_update.Graphql_repr.deriver + @@ Fields_derivers_zkapps.Derivers.o () in - let party_of_json (party : Js.js_string Js.t) : Party.t = + let account_update_of_json (account_update : Js.js_string Js.t) : + Account_update.t = Fields_derivers_zkapps.of_json deriver - (party |> Js.to_string |> Yojson.Safe.from_string) - |> Party.of_graphql_repr + (account_update |> Js.to_string |> Yojson.Safe.from_string) + |> Account_update.of_graphql_repr in - party_of_json + account_update_of_json - (* TODO hash two parties together in the correct way *) + (* TODO hash two zkapp_command together in the correct way *) - let hash_party (p : Js.js_string Js.t) = - Party.digest (p |> party_of_json) |> Field.constant |> to_js_field + let hash_account_update (p : Js.js_string Js.t) = + Account_update.digest (p |> account_update_of_json) + |> Field.constant |> to_js_field - let forest_digest_of_field : Field.Constant.t -> Parties.Digest.Forest.t = + let forest_digest_of_field : Field.Constant.t -> Zkapp_command.Digest.Forest.t + = Obj.magic let forest_digest_of_field_checked : - Field.t -> Parties.Digest.Forest.Checked.t = + Field.t -> Zkapp_command.Digest.Forest.Checked.t = Obj.magic - let hash_transaction other_parties_hash = - let other_parties_hash = - other_parties_hash |> of_js_field |> to_unchecked + let hash_transaction account_updates_hash = + let account_updates_hash = + account_updates_hash |> of_js_field |> to_unchecked |> forest_digest_of_field in - Parties.Transaction_commitment.create ~other_parties_hash + Zkapp_command.Transaction_commitment.create ~account_updates_hash |> Field.constant |> to_js_field - let hash_transaction_checked other_parties_hash = - let other_parties_hash = - other_parties_hash |> of_js_field |> forest_digest_of_field_checked + let hash_transaction_checked account_updates_hash = + let account_updates_hash = + account_updates_hash |> of_js_field |> forest_digest_of_field_checked in - Parties.Transaction_commitment.Checked.create ~other_parties_hash + Zkapp_command.Transaction_commitment.Checked.create ~account_updates_hash |> to_js_field - type party_index = Fee_payer | Other_party of int + type account_update_index = Fee_payer | Other_account_update of int let transaction_commitment - ({ fee_payer; other_parties; memo } as tx : Parties.t) - (party_index : party_index) = - let commitment = Parties.commitment tx in + ({ fee_payer; account_updates; memo } as tx : Zkapp_command.t) + (account_update_index : account_update_index) = + let commitment = Zkapp_command.commitment tx in let full_commitment = - Parties.Transaction_commitment.create_complete commitment + Zkapp_command.Transaction_commitment.create_complete commitment ~memo_hash:(Mina_base.Signed_command_memo.hash memo) ~fee_payer_hash: - (Parties.Digest.Party.create (Party.of_fee_payer fee_payer)) + (Zkapp_command.Digest.Account_update.create + (Account_update.of_fee_payer fee_payer) ) in let use_full_commitment = - match party_index with + match account_update_index with | Fee_payer -> true - | Other_party i -> - (List.nth_exn (Parties.Call_forest.to_parties_list other_parties) i) + | Other_account_update i -> + (List.nth_exn + (Zkapp_command.Call_forest.to_zkapp_command_list account_updates) + i ) .body .use_full_commitment in @@ -2683,14 +2690,15 @@ module Ledger = struct let transaction_commitments (tx_json : Js.js_string Js.t) = let tx = - Parties.of_json @@ Yojson.Safe.from_string @@ Js.to_string tx_json + Zkapp_command.of_json @@ Yojson.Safe.from_string @@ Js.to_string tx_json in - let commitment = Parties.commitment tx in + let commitment = Zkapp_command.commitment tx in let full_commitment = - Parties.Transaction_commitment.create_complete commitment + Zkapp_command.Transaction_commitment.create_complete commitment ~memo_hash:(Mina_base.Signed_command_memo.hash tx.memo) ~fee_payer_hash: - (Parties.Digest.Party.create (Party.of_fee_payer tx.fee_payer)) + (Zkapp_command.Digest.Account_update.create + (Account_update.of_fee_payer tx.fee_payer) ) in object%js val commitment = to_js_field_unchecked commitment @@ -2698,17 +2706,20 @@ module Ledger = struct val fullCommitment = to_js_field_unchecked full_commitment end - let zkapp_public_input (tx_json : Js.js_string Js.t) (party_index : int) = + let zkapp_public_input (tx_json : Js.js_string Js.t) + (account_update_index : int) = let tx = - Parties.of_json @@ Yojson.Safe.from_string @@ Js.to_string tx_json + Zkapp_command.of_json @@ Yojson.Safe.from_string @@ Js.to_string tx_json in - let party = List.nth_exn tx.other_parties party_index in + let account_update = List.nth_exn tx.account_updates account_update_index in object%js - val party = to_js_field_unchecked (party.elt.party_digest :> Impl.field) + val account_update = + to_js_field_unchecked + (account_update.elt.account_update_digest :> Impl.field) val calls = to_js_field_unchecked - (Parties.Call_forest.hash party.elt.calls :> Impl.field) + (Zkapp_command.Call_forest.hash account_update.elt.calls :> Impl.field) end let sign_field_element (x : field_class Js.t) (key : private_key) = @@ -2719,41 +2730,45 @@ module Ledger = struct let dummy_signature () = Mina_base.Signature.(dummy |> to_base58_check) |> Js.string - let sign_party (tx_json : Js.js_string Js.t) (key : private_key) - (party_index : party_index) = + let sign_account_update (tx_json : Js.js_string Js.t) (key : private_key) + (account_update_index : account_update_index) = let tx = - Parties.of_json @@ Yojson.Safe.from_string @@ Js.to_string tx_json + Zkapp_command.of_json @@ Yojson.Safe.from_string @@ Js.to_string tx_json in let signature = Signature_lib.Schnorr.Chunked.sign (private_key key) (Random_oracle.Input.Chunked.field - (transaction_commitment tx party_index) ) + (transaction_commitment tx account_update_index) ) in - ( match party_index with + ( match account_update_index with | Fee_payer -> { tx with fee_payer = { tx.fee_payer with authorization = signature } } - | Other_party i -> + | Other_account_update i -> { tx with - other_parties = - Parties.Call_forest.mapi tx.other_parties - ~f:(fun i' (p : Party.t) -> + account_updates = + Zkapp_command.Call_forest.mapi tx.account_updates + ~f:(fun i' (p : Account_update.t) -> if i' = i then { p with authorization = Signature signature } else p ) } ) - |> Parties.to_json |> Yojson.Safe.to_string |> Js.string + |> Zkapp_command.to_json |> Yojson.Safe.to_string |> Js.string - let sign_fee_payer tx_json key = sign_party tx_json key Fee_payer + let sign_fee_payer tx_json key = sign_account_update tx_json key Fee_payer - let sign_other_party tx_json key i = sign_party tx_json key (Other_party i) + let sign_other_account_update tx_json key i = + sign_account_update tx_json key (Other_account_update i) - let check_party_signatures parties = - let ({ fee_payer; other_parties; memo } : Parties.t) = parties in - let tx_commitment = Parties.commitment parties in + let check_account_update_signatures zkapp_command = + let ({ fee_payer; account_updates; memo } : Zkapp_command.t) = + zkapp_command + in + let tx_commitment = Zkapp_command.commitment zkapp_command in let full_tx_commitment = - Parties.Transaction_commitment.create_complete tx_commitment + Zkapp_command.Transaction_commitment.create_complete tx_commitment ~memo_hash:(Mina_base.Signed_command_memo.hash memo) ~fee_payer_hash: - (Parties.Digest.Party.create (Party.of_fee_payer fee_payer)) + (Zkapp_command.Digest.Account_update.create + (Account_update.of_fee_payer fee_payer) ) in let key_to_string = Signature_lib.Public_key.Compressed.to_base58_check in let check_signature who s pk msg = @@ -2777,7 +2792,7 @@ module Ledger = struct check_signature "fee payer" fee_payer.authorization fee_payer.body.public_key full_tx_commitment ; - List.iteri (Parties.Call_forest.to_parties_list other_parties) + List.iteri (Zkapp_command.Call_forest.to_zkapp_command_list account_updates) ~f:(fun i p -> let commitment = if p.body.use_full_commitment then full_tx_commitment @@ -2785,8 +2800,9 @@ module Ledger = struct in match p.authorization with | Signature s -> - check_signature (sprintf "party %d" i) s p.body.public_key - commitment + check_signature + (sprintf "account_update %d" i) + s p.body.public_key commitment | Proof _ | None_given -> () ) @@ -2881,13 +2897,13 @@ module Ledger = struct Mina_base.Zkapp_precondition.Protocol_state.View.t -> json |> Js.to_string |> Yojson.Safe.from_string |> of_json - let apply_parties_transaction l (txn : Parties.t) + let apply_zkapp_command_transaction l (txn : Zkapp_command.t) (account_creation_fee : string) (network_state : Mina_base.Zkapp_precondition.Protocol_state.View.t) = - check_party_signatures txn ; + check_account_update_signatures txn ; let ledger = l##.value in let applied_exn = - T.apply_parties_unchecked ~state_view:network_state + T.apply_zkapp_command_unchecked ~state_view:network_state ~constraint_constants: { Genesis_constants.Constraint_constants.compiled with account_creation_fee = Currency.Fee.of_string account_creation_fee @@ -2895,7 +2911,7 @@ module Ledger = struct ledger txn in let applied, _ = Or_error.ok_exn applied_exn in - let T.Transaction_applied.Parties_applied.{ accounts; command; _ } = + let T.Transaction_applied.Zkapp_command_applied.{ accounts; command; _ } = applied in let () = @@ -2916,10 +2932,10 @@ module Ledger = struct (account_creation_fee : Js.js_string Js.t) (network_json : Js.js_string Js.t) = let txn = - Parties.of_json @@ Yojson.Safe.from_string @@ Js.to_string tx_json + Zkapp_command.of_json @@ Yojson.Safe.from_string @@ Js.to_string tx_json in let network_state = protocol_state_of_json network_json in - apply_parties_transaction l txn + apply_zkapp_command_transaction l txn (Js.to_string account_creation_fee) network_state @@ -3006,7 +3022,7 @@ module Ledger = struct static_method "signFieldElement" sign_field_element ; static_method "dummySignature" dummy_signature ; static_method "signFeePayer" sign_fee_payer ; - static_method "signOtherParty" sign_other_party ; + static_method "signOtherAccountUpdate" sign_other_account_update ; static_method "publicKeyToString" public_key_to_string ; static_method "publicKeyOfString" public_key_of_string ; @@ -3042,38 +3058,39 @@ module Ledger = struct val versionBytes = version_bytes end ) ; - static_method "hashPartyFromJson" hash_party ; - static_method "hashPartyFromFields" + static_method "hashAccountUpdateFromJson" hash_account_update ; + static_method "hashAccountUpdateFromFields" (Checked.fields_to_hash - (Mina_base.Party.Body.typ ()) - Mina_base.Party.Checked.digest ) ; + (Mina_base.Account_update.Body.typ ()) + Mina_base.Account_update.Checked.digest ) ; (* TODO this is for debugging, maybe remove later *) let body_deriver = - Mina_base.Party.Body.Graphql_repr.deriver @@ Fields_derivers_zkapps.o () + Mina_base.Account_update.Body.Graphql_repr.deriver + @@ Fields_derivers_zkapps.o () in let body_to_json value = value - |> Party.Body.to_graphql_repr ~call_depth:0 + |> Account_update.Body.to_graphql_repr ~call_depth:0 |> Fields_derivers_zkapps.to_json body_deriver in let body_of_json json = json |> Fields_derivers_zkapps.of_json body_deriver - |> Party.Body.of_graphql_repr + |> Account_update.Body.of_graphql_repr in static_method "fieldsToJson" - (fields_to_json (Mina_base.Party.Body.typ ()) body_to_json) ; + (fields_to_json (Mina_base.Account_update.Body.typ ()) body_to_json) ; static_method "fieldsOfJson" - (fields_of_json (Mina_base.Party.Body.typ ()) body_of_json) ; + (fields_of_json (Mina_base.Account_update.Body.typ ()) body_of_json) ; - (* hash inputs for various party subtypes *) + (* hash inputs for various account_update subtypes *) (* TODO: this is for testing against JS impl, remove eventually *) let timing_input (json : Js.js_string Js.t) : random_oracle_input_js = - let deriver = Party.Update.Timing_info.deriver in + let deriver = Account_update.Update.Timing_info.deriver in let json = json |> Js.to_string |> Yojson.Safe.from_string in let value = Fields_derivers_zkapps.(of_json (deriver @@ o ()) json) in - let input = Party.Update.Timing_info.to_input value in + let input = Account_update.Update.Timing_info.to_input value in random_oracle_input_to_js input in let permissions_input (json : Js.js_string Js.t) : random_oracle_input_js = @@ -3084,10 +3101,10 @@ module Ledger = struct random_oracle_input_to_js input in let update_input (json : Js.js_string Js.t) : random_oracle_input_js = - let deriver = Party.Update.deriver in + let deriver = Account_update.Update.deriver in let json = json |> Js.to_string |> Yojson.Safe.from_string in let value = Fields_derivers_zkapps.(of_json (deriver @@ o ()) json) in - let input = Party.Update.to_input value in + let input = Account_update.Update.to_input value in random_oracle_input_to_js input in let account_precondition_input (json : Js.js_string Js.t) : @@ -3109,7 +3126,7 @@ module Ledger = struct let body_input (json : Js.js_string Js.t) : random_oracle_input_js = let json = json |> Js.to_string |> Yojson.Safe.from_string in let value = body_of_json json in - let input = Party.Body.to_input value in + let input = Account_update.Body.to_input value in random_oracle_input_to_js input in diff --git a/src/lib/snarky_js_bindings/snarky_js_types.ml b/src/lib/snarky_js_bindings/snarky_js_types.ml index 43ad5a8e2b3..29a06eb305b 100644 --- a/src/lib/snarky_js_bindings/snarky_js_types.ml +++ b/src/lib/snarky_js_bindings/snarky_js_types.ml @@ -4,8 +4,8 @@ let () = let layout = Fields_derivers_zkapps.js_layout in let js_layout = `Assoc - [ ("Parties", layout Parties.deriver) - ; ("Party", layout Party.Graphql_repr.deriver) + [ ("ZkappCommand", layout Zkapp_command.deriver) + ; ("AccountUpdate", layout Account_update.Graphql_repr.deriver) ] in diff --git a/src/lib/snarky_js_bindings/snarkyjs b/src/lib/snarky_js_bindings/snarkyjs index 4e8f94fa722..524a17f3017 160000 --- a/src/lib/snarky_js_bindings/snarkyjs +++ b/src/lib/snarky_js_bindings/snarkyjs @@ -1 +1 @@ -Subproject commit 4e8f94fa722f2dc6ce743d0a3924cb68f0f77733 +Subproject commit 524a17f3017c2a5aa654de3120c9319848298479 diff --git a/src/lib/snarky_js_bindings/test_module/simple-zkapp-mina-signer-quick.js b/src/lib/snarky_js_bindings/test_module/simple-zkapp-mina-signer-quick.js index 09865ebbfae..70909aa7d5f 100644 --- a/src/lib/snarky_js_bindings/test_module/simple-zkapp-mina-signer-quick.js +++ b/src/lib/snarky_js_bindings/test_module/simple-zkapp-mina-signer-quick.js @@ -53,7 +53,7 @@ toc(); // deploy transaction tic("create deploy transaction"); -let partiesJsonDeploy = await deploy(SimpleZkapp, { +let zkappCommandJsonDeploy = await deploy(SimpleZkapp, { zkappKey, verificationKey, }); @@ -71,7 +71,7 @@ tic("sign deploy transaction"); let feePayerNonce = 0; let signedDeploy = client.signTransaction( { - parties: JSON.parse(partiesJsonDeploy), + zkappCommand: JSON.parse(zkappCommandJsonDeploy), feePayer: { feePayer: feePayerAddress, fee: `${transactionFee}`, @@ -84,13 +84,13 @@ toc(); // check that signature matches with the one snarkyjs creates on the same transaction tic("sign deploy transaction (snarkyjs, for consistency check)"); -let signedDeploySnarkyJs = signFeePayer(partiesJsonDeploy, feePayerKey, { +let signedDeploySnarkyJs = signFeePayer(zkappCommandJsonDeploy, feePayerKey, { transactionFee, feePayerNonce, }); if ( JSON.parse(signedDeploySnarkyJs).feePayer.authorization !== - JSON.parse(signedDeploy.data.parties).feePayer.authorization + JSON.parse(signedDeploy.data.zkappCommand).feePayer.authorization ) throw Error("Inconsistent fee payer signature"); toc(); diff --git a/src/lib/snarky_js_bindings/test_module/simple-zkapp-mina-signer.js b/src/lib/snarky_js_bindings/test_module/simple-zkapp-mina-signer.js index 262b2b48407..e3cab30e5c7 100644 --- a/src/lib/snarky_js_bindings/test_module/simple-zkapp-mina-signer.js +++ b/src/lib/snarky_js_bindings/test_module/simple-zkapp-mina-signer.js @@ -51,12 +51,12 @@ toc(); // deploy transaction tic("create deploy transaction"); -let partiesJsonDeploy = await deploy(SimpleZkapp, { zkappKey }); +let zkappCommandJsonDeploy = await deploy(SimpleZkapp, { zkappKey }); toc(); // update transaction tic("create update transaction (with proof)"); -let partiesJsonUpdate = await Mina.transaction(() => +let zkappCommandJsonUpdate = await Mina.transaction(() => new SimpleZkapp(zkappAddress).update(Field(3)) ) .then(async (tx) => { @@ -75,7 +75,7 @@ tic("sign deploy transaction"); let feePayerNonce = 0; let signedDeploy = client.signTransaction( { - parties: JSON.parse(partiesJsonDeploy), + zkappCommand: JSON.parse(zkappCommandJsonDeploy), feePayer: { feePayer: feePayerAddress, fee: `${transactionFee}`, @@ -88,13 +88,13 @@ toc(); // check that signature matches with the one snarkyjs creates on the same transaction tic("sign deploy transaction (snarkyjs, for consistency check)"); -let signedDeploySnarkyJs = signFeePayer(partiesJsonDeploy, feePayerKey, { +let signedDeploySnarkyJs = signFeePayer(zkappCommandJsonDeploy, feePayerKey, { transactionFee, feePayerNonce, }); if ( JSON.parse(signedDeploySnarkyJs).feePayer.authorization !== - JSON.parse(signedDeploy.data.parties).feePayer.authorization + JSON.parse(signedDeploy.data.zkappCommand).feePayer.authorization ) throw Error("Inconsistent fee payer signature"); toc(); @@ -105,7 +105,7 @@ feePayerNonce++; tic("sign update transaction"); let signedUpdate = client.signTransaction( { - parties: JSON.parse(partiesJsonUpdate), + zkappCommand: JSON.parse(zkappCommandJsonUpdate), feePayer: { feePayer: feePayerAddress, fee: `${transactionFee}`, @@ -118,13 +118,13 @@ toc(); // check that signature matches with the one snarkyjs creates on the same transaction tic("sign update transaction (snarkyjs, for consistency check)"); -let signedUpdateSnarkyJs = signFeePayer(partiesJsonUpdate, feePayerKey, { +let signedUpdateSnarkyJs = signFeePayer(zkappCommandJsonUpdate, feePayerKey, { transactionFee, feePayerNonce, }); if ( JSON.parse(signedUpdateSnarkyJs).feePayer.authorization !== - JSON.parse(signedUpdate.data.parties).feePayer.authorization + JSON.parse(signedUpdate.data.zkappCommand).feePayer.authorization ) throw Error("Inconsistent fee payer signature"); toc(); diff --git a/src/lib/snarky_js_bindings/test_module/simple-zkapp-mock-apply.js b/src/lib/snarky_js_bindings/test_module/simple-zkapp-mock-apply.js index 187a6c087fe..aaf1383d608 100644 --- a/src/lib/snarky_js_bindings/test_module/simple-zkapp-mock-apply.js +++ b/src/lib/snarky_js_bindings/test_module/simple-zkapp-mock-apply.js @@ -71,7 +71,7 @@ let { verificationKey } = await SimpleZkapp.compile(zkappAddress); toc(); tic("create deploy transaction"); -let partiesJsonDeploy = await deploy(SimpleZkapp, { +let zkappCommandJsonDeploy = await deploy(SimpleZkapp, { zkappKey, initialBalance, feePayer: { feePayerKey: sender.privateKey, fee: transactionFee }, @@ -79,7 +79,7 @@ let partiesJsonDeploy = await deploy(SimpleZkapp, { toc(); tic("apply deploy transaction"); -Local.applyJsonTransaction(partiesJsonDeploy); +Local.applyJsonTransaction(zkappCommandJsonDeploy); toc(); tic("create initialize transaction (with proof)"); @@ -87,8 +87,8 @@ let transaction = await Mina.transaction(() => { new SimpleZkapp(zkappAddress).initialize(); }); let [proof] = await transaction.prove(); -let partiesJsonInitialize = transaction.toJSON(); -partiesJsonInitialize = signFeePayer(partiesJsonInitialize, senderKey, { +let zkappCommandJsonInitialize = transaction.toJSON(); +zkappCommandJsonInitialize = signFeePayer(zkappCommandJsonInitialize, senderKey, { transactionFee, }); toc(); @@ -101,7 +101,7 @@ console.log("did proof verify?", ok); if (!ok) throw Error("proof didn't verify"); tic("apply initialize transaction"); -Local.applyJsonTransaction(partiesJsonInitialize); +Local.applyJsonTransaction(zkappCommandJsonInitialize); toc(); // check that deploy and initialize txns were applied @@ -116,14 +116,14 @@ transaction = await Mina.transaction(() => { zkapp.sign(zkappKey); }); transaction.sign(); -let partiesJsonUpdate = transaction.toJSON(); -partiesJsonUpdate = signFeePayer(partiesJsonUpdate, senderKey, { +let zkappCommandJsonUpdate = transaction.toJSON(); +zkappCommandJsonUpdate = signFeePayer(zkappCommandJsonUpdate, senderKey, { transactionFee, }); toc(); tic("apply update transaction (no proof)"); -Local.applyJsonTransaction(partiesJsonUpdate); +Local.applyJsonTransaction(zkappCommandJsonUpdate); toc(); // check that first update txn was applied @@ -136,16 +136,16 @@ transaction = await Mina.transaction(() => { new SimpleZkapp(zkappAddress).update(Field(2)); }); await transaction.prove(); -let partiesJsonUpdateWithProof = transaction.toJSON(); -partiesJsonUpdateWithProof = signFeePayer( - partiesJsonUpdateWithProof, +let zkappCommandJsonUpdateWithProof = transaction.toJSON(); +zkappCommandJsonUpdateWithProof = signFeePayer( + zkappCommandJsonUpdateWithProof, senderKey, { transactionFee } ); toc(); tic("apply update transaction (with proof)"); -Local.applyJsonTransaction(partiesJsonUpdateWithProof); +Local.applyJsonTransaction(zkappCommandJsonUpdateWithProof); toc(); // check that second update txn was applied diff --git a/src/lib/snarky_js_bindings/test_module/simple-zkapp-token.js b/src/lib/snarky_js_bindings/test_module/simple-zkapp-token.js index d8cf7e7fd44..b8be4a04c32 100644 --- a/src/lib/snarky_js_bindings/test_module/simple-zkapp-token.js +++ b/src/lib/snarky_js_bindings/test_module/simple-zkapp-token.js @@ -10,14 +10,14 @@ import { shutdown, Mina, Permissions, - Party, + AccountUpdate, UInt64, Ledger, Token, } from "snarkyjs"; function sendTransaction(tx) { - // console.log("DEBUG -- TXN\n", JSON.stringify(partiesToJson(tx.transaction))); + // console.log("DEBUG -- TXN\n", JSON.stringify(zkappCommandToJson(tx.transaction))); tx.send(); } @@ -117,7 +117,7 @@ let tx; console.log("deploy"); tx = await Local.transaction(feePayer, () => { - Party.fundNewAccount(feePayer, { initialBalance }); + Account_update.fundNewAccount(feePayer, { initialBalance }); zkapp.deploy({ zkappKey }); }); sendTransaction(tx); @@ -143,7 +143,7 @@ console.log( console.log("----------token minting----------"); tx = await Local.transaction(feePayer, () => { - Party.fundNewAccount(feePayer); + Account_update.fundNewAccount(feePayer); zkapp.mint(tokenAccount1); zkapp.sign(zkappKey); }); @@ -173,7 +173,7 @@ console.log( console.log("----------token transfer----------"); tx = await Local.transaction(feePayer, () => { - Party.fundNewAccount(feePayer); + Account_update.fundNewAccount(feePayer); zkapp.send(tokenAccount1, tokenAccount2); zkapp.sign(zkappKey); }); diff --git a/src/lib/snarky_js_bindings/test_module/simple-zkapp.js b/src/lib/snarky_js_bindings/test_module/simple-zkapp.js index db63e12d35c..f46450f2822 100644 --- a/src/lib/snarky_js_bindings/test_module/simple-zkapp.js +++ b/src/lib/snarky_js_bindings/test_module/simple-zkapp.js @@ -64,7 +64,7 @@ if (command === "deploy") { }); let { verificationKey } = await SimpleZkapp.compile(zkappAddress); - let partiesJson = await deploy(SimpleZkapp, { + let zkappCommandJson = await deploy(SimpleZkapp, { zkappKey, verificationKey, initialBalance, @@ -79,12 +79,12 @@ if (command === "deploy") { fee: transactionFee, nonce: feePayerNonce, }; - let parties = JSON.parse(partiesJson); + let zkappCommand = JSON.parse(zkappCommandJson); let { data } = client.signTransaction( - { parties, feePayer }, + { zkappCommand, feePayer }, feePayerKeyBase58 ); - console.log(data.parties); + console.log(data.zkappCommand); } if (command === "update") { @@ -98,7 +98,7 @@ if (command === "update") { new SimpleZkapp(zkappAddress).update(Field(2)); }); let [proof] = await transaction.prove(); - let partiesJson = transaction.toJSON(); + let zkappCommandJson = transaction.toJSON(); // mina-signer part let client = new Client({ network: "testnet" }); @@ -108,15 +108,15 @@ if (command === "update") { fee: transactionFee, nonce: feePayerNonce, }; - let parties = JSON.parse(partiesJson); + let zkappCommand = JSON.parse(zkappCommandJson); let { data } = client.signTransaction( - { parties, feePayer }, + { zkappCommand, feePayer }, feePayerKeyBase58 ); let ok = await verify(proof, verificationKey.data); if (!ok) throw Error("verification failed"); - console.log(data.parties); + console.log(data.zkappCommand); } shutdown(); diff --git a/src/lib/snarky_js_bindings/test_module/to-hash-input.js b/src/lib/snarky_js_bindings/test_module/to-hash-input.js index 7611afa7119..c18f490f927 100644 --- a/src/lib/snarky_js_bindings/test_module/to-hash-input.js +++ b/src/lib/snarky_js_bindings/test_module/to-hash-input.js @@ -1,6 +1,6 @@ import { isReady, - Party, + AccountUpdate, PrivateKey, Types, Field, @@ -19,13 +19,13 @@ await isReady; let { asFieldsAndAux, jsLayout, packToFields } = Experimental; -let party = Party.defaultParty(PrivateKey.random().toPublicKey()); +let account_update = Account_update.defaultAccountUpdate(PrivateKey.random().toPublicKey()); // timing let Timing = asFieldsAndAux( - jsLayout.Party.entries.body.entries.update.entries.timing.inner + jsLayout.Account_update.entries.body.entries.update.entries.timing.inner ); -let timing = party.body.update.timing.value; +let timing = account_update.body.update.timing.value; timing.initialMinimumBalance = UInt64.one; timing.vestingPeriod = UInt32.one; timing.vestingIncrement = UInt64.from(2); @@ -33,9 +33,9 @@ testInput(Timing, Ledger.hashInputFromJson.timing, timing); // permissions let Permissions_ = asFieldsAndAux( - jsLayout.Party.entries.body.entries.update.entries.permissions.inner + jsLayout.Account_update.entries.body.entries.update.entries.permissions.inner ); -let permissions = party.body.update.permissions; +let permissions = account_update.body.update.permissions; permissions.isSome = Bool(true); permissions.value = { ...Permissions.default(), @@ -50,8 +50,8 @@ testInput( ); // update -let Update = asFieldsAndAux(jsLayout.Party.entries.body.entries.update); -let update = party.body.update; +let Update = asFieldsAndAux(jsLayout.Account_update.entries.body.entries.update); +let update = account_update.body.update; update.timing.isSome = Bool(true); update.appState[0].isSome = Bool(true); @@ -60,17 +60,17 @@ update.delegate.isSome = Bool(true); let delegate = PrivateKey.random().toPublicKey(); update.delegate.value = delegate; -party.tokenSymbol.set("BLABLA"); +account_update.tokenSymbol.set("BLABLA"); testInput(Update, Ledger.hashInputFromJson.update, update); // account precondition let AccountPrecondition = asFieldsAndAux( - jsLayout.Party.entries.body.entries.preconditions.entries.account + jsLayout.Account_update.entries.body.entries.preconditions.entries.account ); -let account = party.body.preconditions.account; -party.account.balance.assertEquals(UInt64.from(1e9)); -party.account.isNew.assertEquals(Bool(true)); -party.account.delegate.assertEquals(delegate); +let account = account_update.body.preconditions.account; +account_update.account.balance.assertEquals(UInt64.from(1e9)); +account_update.account.isNew.assertEquals(Bool(true)); +account_update.account.delegate.assertEquals(delegate); account.state[0].isSome = Bool(true); account.state[0].value = Field(9); testInput( @@ -81,11 +81,11 @@ testInput( // network precondition let NetworkPrecondition = asFieldsAndAux( - jsLayout.Party.entries.body.entries.preconditions.entries.network + jsLayout.Account_update.entries.body.entries.preconditions.entries.network ); -let network = party.body.preconditions.network; -party.network.stakingEpochData.ledger.hash.assertEquals(Field.random()); -party.network.nextEpochData.lockCheckpoint.assertEquals(Field.random()); +let network = account_update.body.preconditions.network; +account_update.network.stakingEpochData.ledger.hash.assertEquals(Field.random()); +account_update.network.nextEpochData.lockCheckpoint.assertEquals(Field.random()); testInput( NetworkPrecondition, @@ -94,8 +94,8 @@ testInput( ); // body -let Body = asFieldsAndAux(jsLayout.Party.entries.body); -let body = party.body; +let Body = asFieldsAndAux(jsLayout.Account_update.entries.body); +let body = account_update.body; body.balanceChange.magnitude = UInt64.from(14197832); body.balanceChange.sgn = Sign.minusOne; body.callData = Field.random(); @@ -106,12 +106,12 @@ body.tokenId = new Token({ tokenOwner }).id; body.caller = body.tokenId; testInput(Body, Ledger.hashInputFromJson.body, body); -// party (should be same as body) +// account_update (should be same as body) testInput( - Types.Party, - (partyJson) => - Ledger.hashInputFromJson.body(JSON.stringify(JSON.parse(partyJson).body)), - party + Types.AccountUpdate, + (account_updateJson) => + Ledger.hashInputFromJson.body(JSON.stringify(JSON.parse(account_updateJson).body)), + account_update ); console.log("all hash inputs are consistent! 🎉"); diff --git a/src/lib/staged_ledger/dune b/src/lib/staged_ledger/dune index 453abdc1263..c8567094615 100644 --- a/src/lib/staged_ledger/dune +++ b/src/lib/staged_ledger/dune @@ -61,7 +61,7 @@ random_oracle kimchi_backend pickles.backend - parties_builder + zkapp_command_builder ppx_version.runtime ) (preprocessor_deps ../../config.mlh) diff --git a/src/lib/staged_ledger/staged_ledger.ml b/src/lib/staged_ledger/staged_ledger.ml index d65df1f2c0b..ddc5d67af2f 100644 --- a/src/lib/staged_ledger/staged_ledger.ml +++ b/src/lib/staged_ledger/staged_ledger.ml @@ -1784,7 +1784,7 @@ module T = struct epoch_ledger |> not - let validate_party_proofs ~logger ~validating_ledger + let validate_account_update_proofs ~logger ~validating_ledger (txn : User_command.Valid.t) = let open Result.Let_syntax in let get_verification_keys account_ids = @@ -1811,29 +1811,32 @@ module T = struct [%log error] ~metadata:[ ("account_id", Account_id.to_yojson id) ] "Staged_ledger_diff creation: Verification key not found for \ - party with proof authorization and account_id $account_id" ; + account_update with proof authorization and account_id \ + $account_id" ; Stop Account_id.Map.empty ) ~finish:Fn.id in match txn with - | Parties p -> + | Zkapp_command p -> let%map checked_verification_keys = Account_id.Map.of_alist_or_error p.verification_keys in - let proof_parties = - Parties.Call_forest.fold ~init:Account_id.Set.empty - p.parties.other_parties ~f:(fun acc p -> - if Control.(Tag.equal Proof (tag (Party.authorization p))) then - Account_id.Set.add acc (Party.account_id p) + let proof_zkapp_command = + Zkapp_command.Call_forest.fold ~init:Account_id.Set.empty + p.zkapp_command.account_updates ~f:(fun acc p -> + if + Control.(Tag.equal Proof (tag (Account_update.authorization p))) + then Account_id.Set.add acc (Account_update.account_id p) else acc ) in let current_verification_keys = - get_verification_keys (Account_id.Set.to_list proof_parties) + get_verification_keys (Account_id.Set.to_list proof_zkapp_command) in if - Account_id.Set.length proof_parties + Account_id.Set.length proof_zkapp_command = Account_id.Map.length checked_verification_keys - && Account_id.Map.equal Parties.Valid.Verification_key_hash.equal + && Account_id.Map.equal + Zkapp_command.Valid.Verification_key_hash.equal checked_verification_keys current_verification_keys then true else ( @@ -1841,11 +1844,13 @@ module T = struct ~metadata: [ ( "checked_verification_keys" , [%to_yojson: - (Account_id.t * Parties.Valid.Verification_key_hash.t) list] + (Account_id.t * Zkapp_command.Valid.Verification_key_hash.t) + list] (Account_id.Map.to_alist checked_verification_keys) ) ; ( "current_verification_keys" , [%to_yojson: - (Account_id.t * Parties.Valid.Verification_key_hash.t) list] + (Account_id.t * Zkapp_command.Valid.Verification_key_hash.t) + list] (Account_id.Map.to_alist current_verification_keys) ) ] "Staged_ledger_diff creation: Verifcation keys used for verifying \ @@ -1940,7 +1945,8 @@ module T = struct O1trace.sync_thread "validate_transaction_against_staged_ledger" (fun () -> let%bind valid_proofs = - validate_party_proofs ~logger ~validating_ledger txn + validate_account_update_proofs ~logger ~validating_ledger + txn in let%bind () = if valid_proofs then Ok () @@ -2040,7 +2046,7 @@ module T = struct [] | Failed -> [] ) - | Command (Parties { new_accounts; _ }) -> + | Command (Zkapp_command { new_accounts; _ }) -> new_accounts | Fee_transfer { new_accounts; _ } -> new_accounts @@ -2520,32 +2526,32 @@ let%test_module "staged ledger tests" = (Ledger.t * User_command.Valid.t list * int option list) Quickcheck.Generator.t = let open Quickcheck.Generator.Let_syntax in - let%bind parties_and_fee_payer_keypairs, ledger = - Mina_generators.User_command_generators.sequence_parties_with_ledger - ~length:num_zkapps ~vk ?failure () + let%bind zkapp_command_and_fee_payer_keypairs, ledger = + Mina_generators.User_command_generators + .sequence_zkapp_command_with_ledger ~length:num_zkapps ~vk ?failure () in let zkapps = - List.map parties_and_fee_payer_keypairs ~f:(function - | Parties parties_valid, _fee_payer_keypair, keymap -> - let parties_with_auths = + List.map zkapp_command_and_fee_payer_keypairs ~f:(function + | Zkapp_command zkapp_command_valid, _fee_payer_keypair, keymap -> + let zkapp_command_with_auths = Async.Thread_safe.block_on_async_exn (fun () -> - Parties_builder.replace_authorizations ~keymap - (Parties.Valid.forget parties_valid) ) + Zkapp_command_builder.replace_authorizations ~keymap + (Zkapp_command.Valid.forget zkapp_command_valid) ) in - let valid_parties_with_auths : Parties.Valid.t = + let valid_zkapp_command_with_auths : Zkapp_command.Valid.t = match - Parties.Valid.to_valid parties_with_auths ~ledger + Zkapp_command.Valid.to_valid zkapp_command_with_auths ~ledger ~get:Ledger.get ~location_of_account:Ledger.location_of_account with | Some ps -> ps | None -> - failwith "Could not create Parties.Valid.t" + failwith "Could not create Zkapp_command.Valid.t" in - User_command.Parties valid_parties_with_auths + User_command.Zkapp_command valid_zkapp_command_with_auths | Signed_command _, _, _ -> - failwith "Expected a Parties, got a Signed command" ) + failwith "Expected a Zkapp_command, got a Signed command" ) in assert (List.length zkapps = num_zkapps) ; return (ledger, zkapps, List.init iters ~f:(Fn.const None)) @@ -2557,7 +2563,8 @@ let%test_module "staged ledger tests" = let%bind iters = Int.gen_incl 1 (max_blocks_for_coverage 0) in let num_zkapps = transaction_capacity * iters in gen_zkapps - ~failure:Mina_generators.Parties_generators.Invalid_account_precondition + ~failure: + Mina_generators.Zkapp_command_generators.Invalid_account_precondition ~num_zkapps iters let gen_zkapps_at_capacity : @@ -3790,7 +3797,7 @@ let%test_module "staged ledger tests" = let amount = Amount.of_int 10_000_000_000 in let snapp_pk = Signature_lib.Public_key.compress new_kp.public_key in let snapp_update = - { Party.Update.dummy with + { Account_update.Update.dummy with delegate = Zkapp_basic.Set_or_keep.Set snapp_pk } in @@ -3842,15 +3849,16 @@ let%test_module "staged ledger tests" = ~permissions:snapp_permissions ~vk ~ledger:l snapp_pk ; l in - let%bind parties = + let%bind zkapp_command = Transaction_snark.For_tests.update_states ~zkapp_prover ~constraint_constants test_spec in - let valid_parties = + let valid_zkapp_command = Option.value_exn - (Parties.Valid.to_valid ~ledger:valid_against_ledger + (Zkapp_command.Valid.to_valid ~ledger:valid_against_ledger ~get:Ledger.get - ~location_of_account:Ledger.location_of_account parties ) + ~location_of_account:Ledger.location_of_account + zkapp_command ) in ignore (Ledger.unregister_mask_exn valid_against_ledger @@ -3862,11 +3870,12 @@ let%test_module "staged ledger tests" = let sl = ref @@ Sl.create_exn ~constraint_constants ~ledger in let%bind _proof, diff = create_and_apply sl - (Sequence.singleton (User_command.Parties valid_parties)) + (Sequence.singleton + (User_command.Zkapp_command valid_zkapp_command) ) stmt_to_work_one_prover in let commands = Staged_ledger_diff.commands diff in - (*Parties with incompatible vk should not be in the diff*) + (*Zkapp_command with incompatible vk should not be in the diff*) assert (List.is_empty commands) ; (*Update the account to have correct vk*) let loc = @@ -3885,19 +3894,23 @@ let%test_module "staged ledger tests" = let sl = ref @@ Sl.create_exn ~constraint_constants ~ledger in let%bind _proof, diff = create_and_apply sl - (Sequence.singleton (User_command.Parties valid_parties)) + (Sequence.singleton + (User_command.Zkapp_command valid_zkapp_command) ) stmt_to_work_one_prover in let commands = Staged_ledger_diff.commands diff in assert (List.length commands = 1) ; match List.hd_exn commands with - | { With_status.data = Parties _ps; status = Applied } -> + | { With_status.data = Zkapp_command _ps; status = Applied } + -> return () - | { With_status.data = Parties _ps; status = Failed tbl } -> + | { With_status.data = Zkapp_command _ps + ; status = Failed tbl + } -> failwith - (sprintf "Parties application failed %s" + (sprintf "Zkapp_command application failed %s" ( Transaction_status.Failure.Collection.to_yojson tbl |> Yojson.Safe.to_string ) ) | _ -> - failwith "expecting parties transaction" ) ) ) + failwith "expecting zkapp_command transaction" ) ) ) end ) diff --git a/src/lib/string_sign/string_sign.ml b/src/lib/string_sign/string_sign.ml index 3ee62d6aa78..c3598edc39a 100644 --- a/src/lib/string_sign/string_sign.ml +++ b/src/lib/string_sign/string_sign.ml @@ -77,7 +77,8 @@ let%test_module "Sign_string tests" = let%test "Sign, verify with default network" = let s = - "Now is the time for all good men to come to the aid of their party" + "Now is the time for all good men to come to the aid of their \ + account_update" in let signature = sign keypair.private_key s in verify signature keypair.public_key s diff --git a/src/lib/transaction/transaction.ml b/src/lib/transaction/transaction.ml index 165ed0e73c4..1c4bbcdd76b 100644 --- a/src/lib/transaction/transaction.ml +++ b/src/lib/transaction/transaction.ml @@ -69,8 +69,8 @@ let forget : Valid.t -> t = function let fee_excess : t -> Fee_excess.t Or_error.t = function | Command (Signed_command t) -> Ok (Signed_command.fee_excess t) - | Command (Parties ps) -> - Ok (Parties.fee_excess ps) + | Command (Zkapp_command ps) -> + Ok (Zkapp_command.fee_excess ps) | Fee_transfer t -> Fee_transfer.fee_excess t | Coinbase t -> @@ -88,8 +88,8 @@ let public_keys : t -> _ = function ; Signed_command.source_pk cmd ; Signed_command.receiver_pk cmd ] - | Command (Parties t) -> - Parties.accounts_accessed t |> List.map ~f:Account_id.public_key + | Command (Zkapp_command t) -> + Zkapp_command.accounts_accessed t |> List.map ~f:Account_id.public_key | Fee_transfer ft -> Fee_transfer.receiver_pks ft | Coinbase cb -> @@ -98,8 +98,8 @@ let public_keys : t -> _ = function let accounts_accessed : t -> _ = function | Command (Signed_command cmd) -> Signed_command.accounts_accessed cmd - | Command (Parties t) -> - Parties.accounts_accessed t + | Command (Zkapp_command t) -> + Zkapp_command.accounts_accessed t | Fee_transfer ft -> Fee_transfer.receivers ft | Coinbase cb -> @@ -109,8 +109,8 @@ let fee_payer_pk (t : t) = match t with | Command (Signed_command cmd) -> Signed_command.fee_payer_pk cmd - | Command (Parties t) -> - Parties.fee_payer_pk t + | Command (Zkapp_command t) -> + Zkapp_command.fee_payer_pk t | Fee_transfer ft -> Fee_transfer.fee_payer_pk ft | Coinbase cb -> diff --git a/src/lib/transaction/transaction_hash.ml b/src/lib/transaction/transaction_hash.ml index 2c31cb7529d..bfed3bf278e 100644 --- a/src/lib/transaction/transaction_hash.ml +++ b/src/lib/transaction/transaction_hash.ml @@ -34,8 +34,8 @@ let of_yojson = function let hash_signed_command cmd = cmd |> Signed_command.to_base58_check |> digest_string -let hash_parties_command cmd = - cmd |> Binable.to_string (module Parties.Stable.Latest) |> digest_string +let hash_zkapp_command_command cmd = + cmd |> Binable.to_string (module Zkapp_command.Stable.Latest) |> digest_string [%%ifdef consensus_mechanism] @@ -43,8 +43,8 @@ let hash_command cmd = match cmd with | User_command.Signed_command s -> hash_signed_command s - | User_command.Parties p -> - hash_parties_command p + | User_command.Zkapp_command p -> + hash_zkapp_command_command p let hash_fee_transfer fee_transfer = fee_transfer |> Fee_transfer.Single.to_base58_check |> digest_string diff --git a/src/lib/transaction_logic/mina_transaction_logic.ml b/src/lib/transaction_logic/mina_transaction_logic.ml index ba71db4aa9f..6bb15b919f3 100644 --- a/src/lib/transaction_logic/mina_transaction_logic.ml +++ b/src/lib/transaction_logic/mina_transaction_logic.ml @@ -3,7 +3,7 @@ open Mina_base open Currency open Signature_lib open Mina_transaction -module Parties_logic = Parties_logic +module Zkapp_command_logic = Zkapp_command_logic module Global_slot = Mina_numbers.Global_slot module Transaction_applied = struct @@ -51,14 +51,14 @@ module Transaction_applied = struct end] end - module Parties_applied = struct + module Zkapp_command_applied = struct [%%versioned module Stable = struct module V1 = struct type t = { accounts : (Account_id.Stable.V2.t * Account.Stable.V2.t option) list - ; command : Parties.Stable.V1.t With_status.Stable.V2.t + ; command : Zkapp_command.Stable.V1.t With_status.Stable.V2.t ; new_accounts : Account_id.Stable.V2.t list } [@@deriving sexp] @@ -74,7 +74,7 @@ module Transaction_applied = struct module V2 = struct type t = | Signed_command of Signed_command_applied.Stable.V2.t - | Parties of Parties_applied.Stable.V1.t + | Zkapp_command of Zkapp_command_applied.Stable.V1.t [@@deriving sexp] let to_latest = Fn.id @@ -161,8 +161,8 @@ module Transaction_applied = struct | Command (Signed_command { common = { user_command = { data; _ }; _ }; _ }) -> Command (Signed_command data) - | Command (Parties c) -> - Command (Parties c.command.data) + | Command (Zkapp_command c) -> + Command (Zkapp_command c.command.data) | Fee_transfer f -> Fee_transfer f.fee_transfer.data | Coinbase c -> @@ -182,9 +182,9 @@ module Transaction_applied = struct | Command (Signed_command uc) -> With_status.map uc.common.user_command ~f:(fun cmd -> Transaction.Command (User_command.Signed_command cmd) ) - | Command (Parties s) -> + | Command (Zkapp_command s) -> With_status.map s.command ~f:(fun c -> - Transaction.Command (User_command.Parties c) ) + Transaction.Command (User_command.Zkapp_command c) ) | Fee_transfer f -> With_status.map f.fee_transfer ~f:(fun f -> Transaction.Fee_transfer f) | Coinbase c -> @@ -196,7 +196,7 @@ module Transaction_applied = struct | Command (Signed_command { common = { user_command = { status; _ }; _ }; _ }) -> status - | Command (Parties c) -> + | Command (Zkapp_command c) -> c.command.status | Fee_transfer f -> f.fee_transfer.status @@ -229,10 +229,10 @@ module type S = sig [@@deriving sexp] end - module Parties_applied : sig - type t = Transaction_applied.Parties_applied.t = + module Zkapp_command_applied : sig + type t = Transaction_applied.Zkapp_command_applied.t = { accounts : (Account_id.t * Account.t option) list - ; command : Parties.t With_status.t + ; command : Zkapp_command.t With_status.t ; new_accounts : Account_id.t list } [@@deriving sexp] @@ -241,7 +241,7 @@ module type S = sig module Command_applied : sig type t = Transaction_applied.Command_applied.t = | Signed_command of Signed_command_applied.t - | Parties of Parties_applied.t + | Zkapp_command of Zkapp_command_applied.t [@@deriving sexp] end @@ -313,27 +313,27 @@ module type S = sig -> last_sequence_slot:Global_slot.t -> Snark_params.Tick.Field.t Pickles_types.Vector.Vector_5.t * Global_slot.t - val apply_parties_unchecked : + val apply_zkapp_command_unchecked : constraint_constants:Genesis_constants.Constraint_constants.t -> state_view:Zkapp_precondition.Protocol_state.View.t -> ledger - -> Parties.t - -> ( Transaction_applied.Parties_applied.t + -> Zkapp_command.t + -> ( Transaction_applied.Zkapp_command_applied.t * ( ( Stack_frame.value , Stack_frame.value list , Token_id.t , Amount.Signed.t , ledger , bool - , Parties.Transaction_commitment.t + , Zkapp_command.Transaction_commitment.t , Mina_numbers.Index.t , Transaction_status.Failure.Collection.t ) - Parties_logic.Local_state.t + Zkapp_command_logic.Local_state.t * Amount.Signed.t ) ) Or_error.t - (** Apply all parties within a parties transaction. This behaves as - [apply_parties_unchecked], except that the [~init] and [~f] arguments + (** Apply all zkapp_command within a zkapp_command transaction. This behaves as + [apply_zkapp_command_unchecked], except that the [~init] and [~f] arguments are provided to allow for the accumulation of the intermediate states. Invariant: [f] is always applied at least once, so it is valid to use an @@ -342,11 +342,11 @@ module type S = sig This can be used to collect the intermediate states to make them available for snark work. In particular, since the transaction snark has - a cap on the number of parties of each kind that may be included, we can + a cap on the number of zkapp_command of each kind that may be included, we can use this to retrieve the (source, target) pairs for each batch of - parties to include in the snark work spec / transaction snark witness. + zkapp_command to include in the snark work spec / transaction snark witness. *) - val apply_parties_unchecked_aux : + val apply_zkapp_command_unchecked_aux : constraint_constants:Genesis_constants.Constraint_constants.t -> state_view:Zkapp_precondition.Protocol_state.View.t -> init:'acc @@ -359,15 +359,15 @@ module type S = sig , Amount.Signed.t , ledger , bool - , Parties.Transaction_commitment.t + , Zkapp_command.Transaction_commitment.t , Mina_numbers.Index.t , Transaction_status.Failure.Collection.t ) - Parties_logic.Local_state.t + Zkapp_command_logic.Local_state.t -> 'acc ) -> ?fee_excess:Amount.Signed.t -> ledger - -> Parties.t - -> (Transaction_applied.Parties_applied.t * 'acc) Or_error.t + -> Zkapp_command.t + -> (Transaction_applied.Zkapp_command_applied.t * 'acc) Or_error.t val apply_fee_transfer : constraint_constants:Genesis_constants.Constraint_constants.t @@ -597,9 +597,9 @@ module Make (L : Ledger_intf.S) : S with type ledger := L.t = struct | Command (Signed_command uc) -> With_status.map uc.common.user_command ~f:(fun cmd -> Transaction.Command (User_command.Signed_command cmd) ) - | Command (Parties s) -> + | Command (Zkapp_command s) -> With_status.map s.command ~f:(fun c -> - Transaction.Command (User_command.Parties c) ) + Transaction.Command (User_command.Zkapp_command c) ) | Fee_transfer f -> With_status.map f.fee_transfer ~f:(fun f -> Transaction.Fee_transfer f ) @@ -613,7 +613,7 @@ module Make (L : Ledger_intf.S) : S with type ledger := L.t = struct (Signed_command { common = { user_command = { status; _ }; _ }; _ }) -> status - | Command (Parties c) -> + | Command (Zkapp_command c) -> c.command.status | Fee_transfer f -> f.fee_transfer.status @@ -1021,7 +1021,7 @@ module Make (L : Ledger_intf.S) : S with type ledger := L.t = struct let get_account p l = let loc, acct = - Or_error.ok_exn (get_with_location l (Party.account_id p)) + Or_error.ok_exn (get_with_location l (Account_update.account_id p)) in (acct, loc) @@ -1041,19 +1041,21 @@ module Make (L : Ledger_intf.S) : S with type ledger := L.t = struct module Transaction_commitment = struct type t = Field.t - let empty = Parties.Transaction_commitment.empty + let empty = Zkapp_command.Transaction_commitment.empty - let commitment ~other_parties = - let other_parties_hash = - Mina_base.Parties.Call_forest.hash other_parties + let commitment ~account_updates = + let account_updates_hash = + Mina_base.Zkapp_command.Call_forest.hash account_updates in - Parties.Transaction_commitment.create ~other_parties_hash + Zkapp_command.Transaction_commitment.create ~account_updates_hash - let full_commitment ~party ~memo_hash ~commitment = - (* when called from Parties_logic.apply, the party is the fee payer *) - let fee_payer_hash = Parties.Digest.Party.create party in - Parties.Transaction_commitment.create_complete commitment ~memo_hash - ~fee_payer_hash + let full_commitment ~account_update ~memo_hash ~commitment = + (* when called from Zkapp_command_logic.apply, the account_update is the fee payer *) + let fee_payer_hash = + Zkapp_command.Digest.Account_update.create account_update + in + Zkapp_command.Transaction_commitment.create_complete commitment + ~memo_hash ~fee_payer_hash let if_ = value_if end @@ -1106,13 +1108,14 @@ module Make (L : Ledger_intf.S) : S with type ledger := L.t = struct type t = Receipt.Chain_hash.t module Elt = struct - type t = Receipt.Parties_elt.t + type t = Receipt.Zkapp_command_elt.t let of_transaction_commitment tc = - Receipt.Parties_elt.Parties_commitment tc + Receipt.Zkapp_command_elt.Zkapp_command_commitment tc end - let cons_parties_commitment = Receipt.Chain_hash.cons_parties_commitment + let cons_zkapp_command_commitment = + Receipt.Chain_hash.cons_zkapp_command_commitment let if_ = value_if end @@ -1124,7 +1127,7 @@ module Make (L : Ledger_intf.S) : S with type ledger := L.t = struct end module Timing = struct - type t = Party.Update.Timing_info.t option + type t = Account_update.Update.Timing_info.t option let if_ = value_if @@ -1153,7 +1156,7 @@ module Make (L : Ledger_intf.S) : S with type ledger := L.t = struct let is_empty = List.is_empty - let push_events = Party.Sequence_events.push_events + let push_events = Account_update.Sequence_events.push_events end module Zkapp_uri = struct @@ -1207,16 +1210,16 @@ module Make (L : Ledger_intf.S) : S with type ledger := L.t = struct let if_ = value_if end - type timing = Party.Update.Timing_info.t option + type timing = Account_update.Update.Timing_info.t option let timing (a : t) : timing = - Party.Update.Timing_info.of_account_timing a.timing + Account_update.Update.Timing_info.of_account_timing a.timing let set_timing (a : t) (timing : timing) : t = { a with timing = Option.value_map ~default:Account_timing.Untimed - ~f:Party.Update.Timing_info.to_account_timing timing + ~f:Account_update.Update.Timing_info.to_account_timing timing } let is_timed (a : t) = @@ -1233,7 +1236,8 @@ module Make (L : Ledger_intf.S) : S with type ledger := L.t = struct validate_timing_with_min_balance' ~txn_amount:Amount.zero ~txn_global_slot ~account in - (invalid_timing, Party.Update.Timing_info.of_account_timing timing) + ( invalid_timing + , Account_update.Update.Timing_info.of_account_timing timing ) let receipt_chain_hash (a : t) : Receipt.Chain_hash.t = a.receipt_chain_hash @@ -1380,13 +1384,13 @@ module Make (L : Ledger_intf.S) : S with type ledger := L.t = struct include Zkapp_precondition.Protocol_state end - module Party = struct - include Party + module Account_update = struct + include Account_update module Account_precondition = struct - include Party.Account_precondition + include Account_update.Account_precondition - let nonce (t : Party.t) = nonce t.body.preconditions.account + let nonce (t : Account_update.t) = nonce t.body.preconditions.account end type 'a or_ignore = 'a Zkapp_basic.Or_ignore.t @@ -1397,11 +1401,11 @@ module Make (L : Ledger_intf.S) : S with type ledger := L.t = struct let caller (p : t) = p.body.caller - let check_authorization ~commitment:_ ~calls:_ (party : t) = + let check_authorization ~commitment:_ ~calls:_ (account_update : t) = (* The transaction's validity should already have been checked before this point. *) - match party.authorization with + match account_update.authorization with | Signature _ -> (`Proof_verifies false, `Signature_verifies true) | Proof _ -> @@ -1414,26 +1418,32 @@ module Make (L : Ledger_intf.S) : S with type ledger := L.t = struct type 'a set_or_keep = 'a Zkapp_basic.Set_or_keep.t - let timing (party : t) : Account.timing set_or_keep = - Set_or_keep.map ~f:Option.some party.body.update.timing + let timing (account_update : t) : Account.timing set_or_keep = + Set_or_keep.map ~f:Option.some account_update.body.update.timing - let app_state (party : t) = party.body.update.app_state + let app_state (account_update : t) = + account_update.body.update.app_state - let verification_key (party : t) = + let verification_key (account_update : t) = Zkapp_basic.Set_or_keep.map ~f:Option.some - party.body.update.verification_key + account_update.body.update.verification_key - let sequence_events (party : t) = party.body.sequence_events + let sequence_events (account_update : t) = + account_update.body.sequence_events - let zkapp_uri (party : t) = party.body.update.zkapp_uri + let zkapp_uri (account_update : t) = + account_update.body.update.zkapp_uri - let token_symbol (party : t) = party.body.update.token_symbol + let token_symbol (account_update : t) = + account_update.body.update.token_symbol - let delegate (party : t) = party.body.update.delegate + let delegate (account_update : t) = account_update.body.update.delegate - let voting_for (party : t) = party.body.update.voting_for + let voting_for (account_update : t) = + account_update.body.update.voting_for - let permissions (party : t) = party.body.update.permissions + let permissions (account_update : t) = + account_update.body.update.permissions end end @@ -1490,7 +1500,7 @@ module Make (L : Ledger_intf.S) : S with type ledger := L.t = struct type t = value - let if_ = Parties.value_if + let if_ = Zkapp_command.value_if let make = Stack_frame.make end @@ -1508,7 +1518,7 @@ module Make (L : Ledger_intf.S) : S with type ledger := L.t = struct , Transaction_commitment.t , Index.t , Bool.failure_status_tbl ) - Parties_logic.Local_state.t + Zkapp_command_logic.Local_state.t let add_check (t : t) failure b = let failure_status_tbl = @@ -1542,8 +1552,8 @@ module Make (L : Ledger_intf.S) : S with type ledger := L.t = struct open Inputs type t = - < party : Party.t - ; parties : Parties.t + < account_update : Account_update.t + ; zkapp_command : Zkapp_command.t ; account : Account.t ; ledger : Ledger.t ; amount : Amount.t @@ -1562,7 +1572,7 @@ module Make (L : Ledger_intf.S) : S with type ledger := L.t = struct , Transaction_commitment.t , Index.t , Transaction_status.Failure.Collection.t ) - Parties_logic.Local_state.t + Zkapp_command_logic.Local_state.t ; protocol_state_precondition : Zkapp_precondition.Protocol_state.t ; transaction_commitment : Transaction_commitment.t ; full_transaction_commitment : Transaction_commitment.t @@ -1570,15 +1580,15 @@ module Make (L : Ledger_intf.S) : S with type ledger := L.t = struct ; failure : Transaction_status.Failure.t option > let perform ~constraint_constants:_ (type r) - (eff : (r, t) Parties_logic.Eff.t) : r = + (eff : (r, t) Zkapp_command_logic.Eff.t) : r = match eff with | Check_protocol_state_precondition (pred, global_state) -> ( Zkapp_precondition.Protocol_state.check pred global_state.protocol_state |> fun or_err -> match or_err with Ok () -> true | Error _ -> false ) - | Check_account_precondition (party, account, new_account, local_state) - -> ( - match party.body.preconditions.account with + | Check_account_precondition + (account_update, account, new_account, local_state) -> ( + match account_update.body.preconditions.account with | Accept -> local_state | Nonce n -> @@ -1594,11 +1604,11 @@ module Make (L : Ledger_intf.S) : S with type ledger := L.t = struct Zkapp_precondition.Account.check ~new_account ~check precondition_account account ; !local_state ) - | Init_account { party = _; account = a } -> + | Init_account { account_update = _; account = a } -> a end - module M = Parties_logic.Make (Inputs) + module M = Zkapp_command_logic.Make (Inputs) let update_sequence_state sequence_state sequence_events ~txn_global_slot ~last_sequence_slot = @@ -1608,15 +1618,15 @@ module Make (L : Ledger_intf.S) : S with type ledger := L.t = struct in (sequence_state', last_sequence_slot') - let apply_parties_unchecked_aux (type user_acc) + let apply_zkapp_command_unchecked_aux (type user_acc) ~(constraint_constants : Genesis_constants.Constraint_constants.t) ~(state_view : Zkapp_precondition.Protocol_state.View.t) ~(init : user_acc) ~(f : user_acc -> _ -> user_acc) - ?(fee_excess = Amount.Signed.zero) (ledger : L.t) (c : Parties.t) : - (Transaction_applied.Parties_applied.t * user_acc) Or_error.t = + ?(fee_excess = Amount.Signed.zero) (ledger : L.t) (c : Zkapp_command.t) : + (Transaction_applied.Zkapp_command_applied.t * user_acc) Or_error.t = let open Or_error.Let_syntax in let original_account_states = - List.map (Parties.accounts_accessed c) ~f:(fun id -> + List.map (Zkapp_command.accounts_accessed c) ~f:(fun id -> ( id , Option.Let_syntax.( let%bind loc = L.location_of_account ledger id in @@ -1626,7 +1636,7 @@ module Make (L : Ledger_intf.S) : S with type ledger := L.t = struct let perform eff = Env.perform ~constraint_constants eff in let rec step_all user_acc ( (g_state : Inputs.Global_state.t) - , (l_state : _ Parties_logic.Local_state.t) ) : + , (l_state : _ Zkapp_command_logic.Local_state.t) ) : (user_acc * Transaction_status.Failure.Collection.t) Or_error.t = if List.is_empty l_state.stack_frame.Stack_frame.calls then Ok (user_acc, l_state.failure_status_tbl) @@ -1637,7 +1647,8 @@ module Make (L : Ledger_intf.S) : S with type ledger := L.t = struct in step_all (f user_acc states) states in - let initial_state : Inputs.Global_state.t * _ Parties_logic.Local_state.t = + let initial_state : + Inputs.Global_state.t * _ Zkapp_command_logic.Local_state.t = ( { protocol_state = state_view; ledger; fee_excess } , { stack_frame = ({ calls = [] @@ -1651,20 +1662,20 @@ module Make (L : Ledger_intf.S) : S with type ledger := L.t = struct ; excess = Currency.Amount.(Signed.of_unsigned zero) ; ledger ; success = true - ; party_index = Inputs.Index.zero + ; account_update_index = Inputs.Index.zero ; failure_status_tbl = [] } ) in let user_acc = f init initial_state in let%bind (start : Inputs.Global_state.t * _) = - let parties = Parties.parties c in + let zkapp_command = Zkapp_command.zkapp_command c in Or_error.try_with (fun () -> M.start ~constraint_constants - { parties; memo_hash = Signed_command_memo.hash c.memo } + { zkapp_command; memo_hash = Signed_command_memo.hash c.memo } { perform } initial_state ) in let account_states_after_fee_payer = - List.map (Parties.accounts_accessed c) ~f:(fun id -> + List.map (Zkapp_command.accounts_accessed c) ~f:(fun id -> ( id , Option.Let_syntax.( let%bind loc = L.location_of_account ledger id in @@ -1702,7 +1713,7 @@ module Make (L : Ledger_intf.S) : S with type ledger := L.t = struct in let valid_result = Ok - ( { Transaction_applied.Parties_applied.accounts = accounts () + ( { Transaction_applied.Zkapp_command_applied.accounts = accounts () ; command = { With_status.data = c ; status = @@ -1715,7 +1726,7 @@ module Make (L : Ledger_intf.S) : S with type ledger := L.t = struct in if successfully_applied then valid_result else - let other_party_accounts_unchanged = + let other_account_update_accounts_unchanged = List.fold_until account_states_after_fee_payer ~init:true ~f:(fun acc (_, loc_opt) -> match @@ -1730,20 +1741,22 @@ module Make (L : Ledger_intf.S) : S with type ledger := L.t = struct Stop false ) ~finish:Fn.id in - (*Other parties failed, therefore, updates in those should not get applied*) - if List.is_empty new_accounts && other_party_accounts_unchanged then - valid_result + (*Other zkapp_command failed, therefore, updates in those should not get applied*) + if + List.is_empty new_accounts + && other_account_update_accounts_unchanged + then valid_result else Or_error.error_string - "Parties application failed but new accounts created or some of \ - the other party updates applied" + "Zkapp_command application failed but new accounts created or \ + some of the other account_update updates applied" - let apply_parties_unchecked ~constraint_constants ~state_view ledger c = - apply_parties_unchecked_aux ~constraint_constants ~state_view ledger c + let apply_zkapp_command_unchecked ~constraint_constants ~state_view ledger c = + apply_zkapp_command_unchecked_aux ~constraint_constants ~state_view ledger c ~init:None ~f:(fun _acc (global_state, local_state) -> Some (local_state, global_state.fee_excess) ) - |> Result.map ~f:(fun (party_applied, state_res) -> - (party_applied, Option.value_exn state_res) ) + |> Result.map ~f:(fun (account_update_applied, state_res) -> + (account_update_applied, Option.value_exn state_res) ) let update_timing_when_no_deduction ~txn_global_slot account = validate_timing ~txn_amount:Amount.zero ~txn_global_slot ~account @@ -2034,11 +2047,11 @@ module Make (L : Ledger_intf.S) : S with type ledger := L.t = struct (apply_user_command_unchecked ~constraint_constants ~txn_global_slot ledger txn ) ~f:(fun applied -> Transaction_applied.Varying.Command (Signed_command applied) ) - | Command (Parties txn) -> + | Command (Zkapp_command txn) -> Or_error.map - (apply_parties_unchecked ~state_view:txn_state_view + (apply_zkapp_command_unchecked ~state_view:txn_state_view ~constraint_constants ledger txn ) ~f:(fun (applied, _) -> - Transaction_applied.Varying.Command (Parties applied) ) + Transaction_applied.Varying.Command (Zkapp_command applied) ) | Fee_transfer t -> Or_error.map (apply_fee_transfer ~constraint_constants ~txn_global_slot ledger t) @@ -2222,21 +2235,22 @@ module For_tests = struct } |> Signed_command.forget_check - let party_send ?(use_full_commitment = true) ?(double_sender_nonce = true) + let account_update_send ?(use_full_commitment = true) + ?(double_sender_nonce = true) ~(constraint_constants : Genesis_constants.Constraint_constants.t) { Transaction_spec.fee ; sender = sender, sender_nonce ; receiver ; amount ; receiver_is_new - } : Parties.t = + } : Zkapp_command.t = let sender_pk = Public_key.compress sender.public_key in let actual_nonce = (* Here, we double the spec'd nonce, because we bump the nonce a second time for the 'sender' part of the payment. *) - (* TODO: We should make bumping the nonce for signed parties optional, - flagged by a field in the party (but always true for the fee payer). + (* TODO: We should make bumping the nonce for signed zkapp_command optional, + flagged by a field in the account_update (but always true for the fee payer). This would also allow us to prevent replays of snapp proofs, by allowing them to bump their nonce. @@ -2247,9 +2261,9 @@ module For_tests = struct |> Account.Nonce.to_uint32 else sender_nonce in - let parties : Parties.Simple.t = + let zkapp_command : Zkapp_command.Simple.t = { fee_payer = - { Party.Fee_payer.body = + { Account_update.Fee_payer.body = { public_key = sender_pk ; fee ; valid_until = None @@ -2258,10 +2272,10 @@ module For_tests = struct (* Real signature added in below *) ; authorization = Signature.dummy } - ; other_parties = + ; account_updates = [ { body = { public_key = sender_pk - ; update = Party.Update.noop + ; update = Account_update.Update.noop ; token_id = Token_id.default ; balance_change = Amount.Signed.(negate (of_unsigned amount)) ; increment_nonce = not use_full_commitment @@ -2270,7 +2284,7 @@ module For_tests = struct ; call_data = Snark_params.Tick.Field.zero ; call_depth = 0 ; preconditions = - { Party.Preconditions.network = + { Account_update.Preconditions.network = Zkapp_precondition.Protocol_state.accept ; account = Nonce (Account.Nonce.succ actual_nonce) } @@ -2281,7 +2295,7 @@ module For_tests = struct } ; { body = { public_key = receiver - ; update = Party.Update.noop + ; update = Account_update.Update.noop ; token_id = Token_id.default ; balance_change = Amount.Signed.of_unsigned @@ -2297,7 +2311,7 @@ module For_tests = struct ; call_data = Snark_params.Tick.Field.zero ; call_depth = 0 ; preconditions = - { Party.Preconditions.network = + { Account_update.Preconditions.network = Zkapp_precondition.Protocol_state.accept ; account = Accept } @@ -2310,36 +2324,38 @@ module For_tests = struct ; memo = Signed_command_memo.empty } in - let parties = Parties.of_simple parties in - let commitment = Parties.commitment parties in + let zkapp_command = Zkapp_command.of_simple zkapp_command in + let commitment = Zkapp_command.commitment zkapp_command in let full_commitment = - Parties.Transaction_commitment.create_complete commitment - ~memo_hash:(Signed_command_memo.hash parties.memo) + Zkapp_command.Transaction_commitment.create_complete commitment + ~memo_hash:(Signed_command_memo.hash zkapp_command.memo) ~fee_payer_hash: - (Parties.Digest.Party.create (Party.of_fee_payer parties.fee_payer)) + (Zkapp_command.Digest.Account_update.create + (Account_update.of_fee_payer zkapp_command.fee_payer) ) in - let other_parties_signature = + let account_updates_signature = let c = if use_full_commitment then full_commitment else commitment in Schnorr.Chunked.sign sender.private_key (Random_oracle.Input.Chunked.field c) in - let other_parties = - Parties.Call_forest.map parties.other_parties ~f:(fun (party : Party.t) -> - match party.body.preconditions.account with + let account_updates = + Zkapp_command.Call_forest.map zkapp_command.account_updates + ~f:(fun (account_update : Account_update.t) -> + match account_update.body.preconditions.account with | Nonce _ -> - { party with - authorization = Control.Signature other_parties_signature + { account_update with + authorization = Control.Signature account_updates_signature } | _ -> - party ) + account_update ) in let signature = Schnorr.Chunked.sign sender.private_key (Random_oracle.Input.Chunked.field full_commitment) in - { parties with - fee_payer = { parties.fee_payer with authorization = signature } - ; other_parties + { zkapp_command with + fee_payer = { zkapp_command.fee_payer with authorization = signature } + ; account_updates } let test_eq (type l) (module L : Ledger_intf.S with type t = l) accounts @@ -2404,14 +2420,14 @@ module For_tests = struct ; next_epoch_data = epoch_data } - (* Quickcheck generator for Parties.t, derived from Test_spec generator *) - let gen_parties_from_test_spec = + (* Quickcheck generator for Zkapp_command.t, derived from Test_spec generator *) + let gen_zkapp_command_from_test_spec = let open Quickcheck.Let_syntax in let%bind use_full_commitment = Bool.quickcheck_generator in match%map Test_spec.mk_gen ~num_transactions:1 () with | { specs = [ spec ]; _ } -> - party_send ~use_full_commitment spec + account_update_send ~use_full_commitment spec | { specs; _ } -> - failwithf "gen_parties_from_test_spec: expected one spec, got %d" + failwithf "gen_zkapp_command_from_test_spec: expected one spec, got %d" (List.length specs) () end diff --git a/src/lib/transaction_logic/parties_logic.ml b/src/lib/transaction_logic/zkapp_command_logic.ml similarity index 83% rename from src/lib/transaction_logic/parties_logic.ml rename to src/lib/transaction_logic/zkapp_command_logic.ml index f2bf059538a..c2b3ee25488 100644 --- a/src/lib/transaction_logic/parties_logic.ml +++ b/src/lib/transaction_logic/zkapp_command_logic.ml @@ -1,4 +1,4 @@ -(* parties_logic.ml *) +(* zkapp_command_logic.ml *) open Core_kernel open Mina_base @@ -70,7 +70,7 @@ module type Receipt_chain_hash_intf = sig val of_transaction_commitment : transaction_commitment -> t end - val cons_parties_commitment : index -> Elt.t -> t -> t + val cons_zkapp_command_commitment : index -> Elt.t -> t -> t end module type Amount_intf = sig @@ -185,7 +185,7 @@ module Local_state = struct ; excess : 'excess ; ledger : 'ledger ; success : 'bool - ; party_index : 'length + ; account_update_index : 'length ; failure_status_tbl : 'failure_status_tbl } [@@deriving compare, equal, hash, sexp, yojson, fields, hlist] @@ -222,7 +222,7 @@ module Local_state = struct Currency.Signed_poly.Stable.V1.t , Ledger_hash.Stable.V1.t , bool - , Parties.Transaction_commitment.Stable.V1.t + , Zkapp_command.Transaction_commitment.Stable.V1.t , Mina_numbers.Index.Stable.V1.t , Transaction_status.Failure.Collection.Stable.V1.t ) Stable.V1.t @@ -243,7 +243,7 @@ module Local_state = struct , Currency.Amount.Signed.Checked.t , Ledger_hash.var , Boolean.var - , Parties.Transaction_commitment.Checked.t + , Zkapp_command.Transaction_commitment.Checked.t , Mina_numbers.Index.Checked.t , unit ) Stable.Latest.t @@ -262,7 +262,7 @@ module type Set_or_keep_intf = sig val set_or_keep : if_:(bool -> then_:'a -> else_:'a -> 'a) -> 'a t -> 'a -> 'a end -module type Party_intf = sig +module type Account_update_intf = sig type t type bool @@ -388,7 +388,7 @@ end module type Call_forest_intf = sig include Iffable - type party + type account_update module Opt : Opt_intf with type bool := bool @@ -396,7 +396,7 @@ module type Call_forest_intf = sig val is_empty : t -> bool - val pop_exn : t -> (party * t) * t + val pop_exn : t -> (account_update * t) * t end module type Stack_frame_intf = sig @@ -428,7 +428,7 @@ module type Ledger_intf = sig type token_id - type party + type account_update type account @@ -436,7 +436,7 @@ module type Ledger_intf = sig val empty : depth:int -> unit -> t - val get_account : party -> t -> account * inclusion_proof + val get_account : account_update -> t -> account * inclusion_proof val set_account : t -> account * inclusion_proof -> t @@ -595,13 +595,13 @@ module Eff = struct type (_, _) t = | Check_account_precondition : (* the bool input is a new_account flag *) - 'party + 'account_update * 'account * 'bool * 'local_state -> ( 'local_state , < bool : 'bool - ; party : 'party + ; account_update : 'account_update ; account : 'account ; local_state : 'local_state ; .. > ) @@ -615,8 +615,10 @@ module Eff = struct ; .. > ) t | Init_account : - { party : 'party; account : 'account } - -> ('account, < party : 'party ; account : 'account ; .. >) t + { account_update : 'account_update; account : 'account } + -> ( 'account + , < account_update : 'account_update ; account : 'account ; .. > ) + t end type 'e handler = { perform : 'r. ('r, 'e) Eff.t -> 'r } @@ -700,8 +702,8 @@ module type Inputs_intf = sig and Sequence_events : (Sequence_events_intf with type bool := Bool.t and type field := Field.t) - and Party : - (Party_intf + and Account_update : + (Account_update_intf with type signed_amount := Amount.Signed.t and type protocol_state_precondition := Protocol_state_precondition.t and type token_id := Token_id.t @@ -722,22 +724,23 @@ module type Inputs_intf = sig and Nonce_precondition : sig val is_constant : - Nonce.t Zkapp_precondition.Closed_interval.t Party.or_ignore -> Bool.t + Nonce.t Zkapp_precondition.Closed_interval.t Account_update.or_ignore + -> Bool.t end and Ledger : (Ledger_intf with type bool := Bool.t and type account := Account.t - and type party := Party.t + and type account_update := Account_update.t and type token_id := Token_id.t and type public_key := Public_key.t) and Call_forest : (Call_forest_intf - with type t = Party.call_forest + with type t = Account_update.call_forest and type bool := Bool.t - and type party := Party.t + and type account_update := Account_update.t and module Opt := Opt) and Stack_frame : @@ -754,14 +757,16 @@ module type Inputs_intf = sig and Transaction_commitment : sig include - Iffable with type bool := Bool.t and type t = Party.transaction_commitment + Iffable + with type bool := Bool.t + and type t = Account_update.transaction_commitment val empty : t - val commitment : other_parties:Call_forest.t -> t + val commitment : account_updates:Call_forest.t -> t val full_commitment : - party:Party.t -> memo_hash:Field.t -> commitment:t -> t + account_update:Account_update.t -> memo_hash:Field.t -> commitment:t -> t end and Index : sig @@ -813,7 +818,8 @@ module Start_data = struct [%%versioned module Stable = struct module V1 = struct - type ('parties, 'field) t = { parties : 'parties; memo_hash : 'field } + type ('zkapp_command, 'field) t = + { zkapp_command : 'zkapp_command; memo_hash : 'field } [@@deriving sexp, yojson] end end] @@ -843,17 +849,17 @@ module Make (Inputs : Inputs_intf) = struct , Opt.or_default ~if_:Call_stack.if_ ~default:(Call_stack.empty ()) next_call_stack ) - type get_next_party_result = - { party : Party.t - ; party_forest : Call_forest.t + type get_next_account_update_result = + { account_update : Account_update.t + ; account_update_forest : Call_forest.t ; new_call_stack : Call_stack.t ; new_frame : Stack_frame.t } - let get_next_party (current_forest : Stack_frame.t) + let get_next_account_update (current_forest : Stack_frame.t) (* The stack for the most recent snapp *) (call_stack : Call_stack.t) (* The partially-completed parent stacks *) - : get_next_party_result = + : get_next_account_update_result = (* If the current stack is complete, 'return' to the previous partially-completed one. *) @@ -862,7 +868,7 @@ module Make (Inputs : Inputs_intf) = struct (* Invariant: call_stack contains only non-empty forests. *) pop_call_stack call_stack in - (* TODO: I believe current should only be empty for the first party in + (* TODO: I believe current should only be empty for the first account_update in a transaction. *) let current_is_empty = Call_forest.is_empty (Stack_frame.calls current_forest) @@ -871,34 +877,36 @@ module Make (Inputs : Inputs_intf) = struct , Call_stack.if_ current_is_empty ~then_:next_call_stack ~else_:call_stack ) in - let (party, party_forest), remainder_of_current_forest = + let (account_update, account_update_forest), remainder_of_current_forest = Call_forest.pop_exn (Stack_frame.calls current_forest) in - let party_caller = Party.caller party in + let account_update_caller = Account_update.caller account_update in let is_normal_call = - Token_id.equal party_caller (Stack_frame.caller current_forest) + Token_id.equal account_update_caller (Stack_frame.caller current_forest) in let () = with_label ~label:"check valid caller" (fun () -> let is_delegate_call = - Token_id.equal party_caller + Token_id.equal account_update_caller (Stack_frame.caller_caller current_forest) in - (* Check that party has a valid caller. *) + (* Check that account_update has a valid caller. *) assert_ Bool.(is_normal_call ||| is_delegate_call) ) in (* Cases: - - [party_forest] is empty, [remainder_of_current_forest] is empty. + - [account_update_forest] is empty, [remainder_of_current_forest] is empty. Pop from the call stack to get another forest, which is guaranteed to be non-empty. The result of popping becomes the "current forest". - - [party_forest] is empty, [remainder_of_current_forest] is non-empty. + - [account_update_forest] is empty, [remainder_of_current_forest] is non-empty. Push nothing to the stack. [remainder_of_current_forest] becomes new "current forest" - - [party_forest] is non-empty, [remainder_of_current_forest] is empty. - Push nothing to the stack. [party_forest] becomes new "current forest" - - [party_forest] is non-empty, [remainder_of_current_forest] is non-empty: - Push [remainder_of_current_forest] to the stack. [party_forest] becomes new "current forest". + - [account_update_forest] is non-empty, [remainder_of_current_forest] is empty. + Push nothing to the stack. [account_update_forest] becomes new "current forest" + - [account_update_forest] is non-empty, [remainder_of_current_forest] is non-empty: + Push [remainder_of_current_forest] to the stack. [account_update_forest] becomes new "current forest". *) - let party_forest_empty = Call_forest.is_empty party_forest in + let account_update_forest_empty = + Call_forest.is_empty account_update_forest + in let remainder_of_current_forest_empty = Call_forest.is_empty remainder_of_current_forest in @@ -910,7 +918,7 @@ module Make (Inputs : Inputs_intf) = struct ~calls:remainder_of_current_forest in let new_call_stack = - Call_stack.if_ party_forest_empty + Call_stack.if_ account_update_forest_empty ~then_: (Call_stack.if_ remainder_of_current_forest_empty ~then_: @@ -923,7 +931,7 @@ module Make (Inputs : Inputs_intf) = struct ~onto:call_stack ) ) in let new_frame = - Stack_frame.if_ party_forest_empty + Stack_frame.if_ account_update_forest_empty ~then_: (Stack_frame.if_ remainder_of_current_forest_empty ~then_:newly_popped_frame ~else_:remainder_of_current_forest_frame ) @@ -931,12 +939,14 @@ module Make (Inputs : Inputs_intf) = struct (let caller = Token_id.if_ is_normal_call ~then_: - (Account_id.derive_token_id ~owner:(Party.account_id party)) + (Account_id.derive_token_id + ~owner:(Account_update.account_id account_update) ) ~else_:(Stack_frame.caller current_forest) - and caller_caller = party_caller in - Stack_frame.make ~calls:party_forest ~caller ~caller_caller ) + and caller_caller = account_update_caller in + Stack_frame.make ~calls:account_update_forest ~caller ~caller_caller + ) in - { party; party_forest; new_frame; new_call_stack } + { account_update; account_update_forest; new_frame; new_call_stack } let update_sequence_state (sequence_state : _ Pickles_types.Vector.t) sequence_events ~txn_global_slot ~last_sequence_slot = @@ -999,8 +1009,8 @@ module Make (Inputs : Inputs_intf) = struct ~else_:local_state.ledger } in - let ( (party, remaining, call_stack) - , party_forest + let ( (account_update, remaining, call_stack) + , account_update_forest , local_state , (a, inclusion_proof) ) = let to_pop, call_stack = @@ -1008,43 +1018,46 @@ module Make (Inputs : Inputs_intf) = struct | `Compute start_data -> ( Stack_frame.if_ is_start' ~then_: - (Stack_frame.make ~calls:start_data.parties + (Stack_frame.make ~calls:start_data.zkapp_command ~caller:default_caller ~caller_caller:default_caller ) ~else_:local_state.stack_frame , Call_stack.if_ is_start' ~then_:(Call_stack.empty ()) ~else_:local_state.call_stack ) | `Yes start_data -> - ( Stack_frame.make ~calls:start_data.parties ~caller:default_caller - ~caller_caller:default_caller + ( Stack_frame.make ~calls:start_data.zkapp_command + ~caller:default_caller ~caller_caller:default_caller , Call_stack.empty () ) | `No -> (local_state.stack_frame, local_state.call_stack) in - let { party - ; party_forest + let { account_update + ; account_update_forest ; new_frame = remaining ; new_call_stack = call_stack } = - with_label ~label:"get next party" (fun () -> + with_label ~label:"get next account update" (fun () -> (* TODO: Make the stack frame hashed inside of the local state *) - get_next_party to_pop call_stack ) + get_next_account_update to_pop call_stack ) in let local_state = with_label ~label:"token owner not caller" (fun () -> let default_token_or_token_owner_was_caller = (* Check that the token owner was consulted if using a non-default token *) - let party_token_id = Party.token_id party in + let account_update_token_id = + Account_update.token_id account_update + in Bool.( ||| ) - (Token_id.equal party_token_id Token_id.default) - (Token_id.equal party_token_id (Party.caller party)) + (Token_id.equal account_update_token_id Token_id.default) + (Token_id.equal account_update_token_id + (Account_update.caller account_update) ) in Local_state.add_check local_state Token_owner_not_caller default_token_or_token_owner_was_caller ) in let ((a, inclusion_proof) as acct) = with_label ~label:"get account" (fun () -> - Inputs.Ledger.get_account party local_state.ledger ) + Inputs.Ledger.get_account account_update local_state.ledger ) in Inputs.Ledger.check_inclusion local_state.ledger (a, inclusion_proof) ; let transaction_commitment, full_transaction_commitment = @@ -1055,10 +1068,10 @@ module Make (Inputs : Inputs_intf) = struct | `Yes start_data | `Compute start_data -> let tx_commitment_on_start = Transaction_commitment.commitment - ~other_parties:(Stack_frame.calls remaining) + ~account_updates:(Stack_frame.calls remaining) in let full_tx_commitment_on_start = - Transaction_commitment.full_commitment ~party + Transaction_commitment.full_commitment ~account_update ~memo_hash:start_data.memo_hash ~commitment:tx_commitment_on_start in @@ -1082,7 +1095,10 @@ module Make (Inputs : Inputs_intf) = struct ~else_:local_state.token_id } in - ((party, remaining, call_stack), party_forest, local_state, acct) + ( (account_update, remaining, call_stack) + , account_update_forest + , local_state + , acct ) in let local_state = { local_state with stack_frame = remaining; call_stack } @@ -1090,21 +1106,25 @@ module Make (Inputs : Inputs_intf) = struct let local_state = Local_state.add_new_failure_status_bucket local_state in Inputs.Ledger.check_inclusion local_state.ledger (a, inclusion_proof) ; (* Register verification key, in case it needs to be 'side-loaded' to - verify a snapp proof. + verify a zkapp proof. *) Account.register_verification_key a ; let (`Is_new account_is_new) = - Inputs.Ledger.check_account (Party.public_key party) - (Party.token_id party) (a, inclusion_proof) + Inputs.Ledger.check_account + (Account_update.public_key account_update) + (Account_update.token_id account_update) + (a, inclusion_proof) in let local_state = h.perform - (Check_account_precondition (party, a, account_is_new, local_state)) + (Check_account_precondition + (account_update, a, account_is_new, local_state) ) in let protocol_state_predicate_satisfied = h.perform (Check_protocol_state_precondition - (Party.protocol_state_precondition party, global_state) ) + ( Account_update.protocol_state_precondition account_update + , global_state ) ) in let local_state = Local_state.add_check local_state Protocol_state_precondition_unsatisfied @@ -1113,16 +1133,18 @@ module Make (Inputs : Inputs_intf) = struct let `Proof_verifies proof_verifies, `Signature_verifies signature_verifies = let commitment = Inputs.Transaction_commitment.if_ - (Inputs.Party.use_full_commitment party) + (Inputs.Account_update.use_full_commitment account_update) ~then_:local_state.full_transaction_commitment ~else_:local_state.transaction_commitment in - Inputs.Party.check_authorization ~commitment ~calls:party_forest party + Inputs.Account_update.check_authorization ~commitment + ~calls:account_update_forest account_update in (* The fee-payer must increment their nonce. *) let local_state = Local_state.add_check local_state Fee_payer_nonce_must_increase - Inputs.Bool.(Inputs.Party.increment_nonce party ||| not is_start') + Inputs.Bool.( + Inputs.Account_update.increment_nonce account_update ||| not is_start') in let local_state = Local_state.add_check local_state Fee_payer_must_be_signed @@ -1130,30 +1152,35 @@ module Make (Inputs : Inputs_intf) = struct in let local_state = let precondition_has_constant_nonce = - Inputs.Party.Account_precondition.nonce party + Inputs.Account_update.Account_precondition.nonce account_update |> Inputs.Nonce_precondition.is_constant in let increments_nonce_and_constrains_its_old_value = Inputs.Bool.( - Inputs.Party.increment_nonce party &&& precondition_has_constant_nonce) + Inputs.Account_update.increment_nonce account_update + &&& precondition_has_constant_nonce) in let depends_on_the_fee_payers_nonce_and_isnt_the_fee_payer = - Inputs.Bool.(Inputs.Party.use_full_commitment party &&& not is_start') + Inputs.Bool.( + Inputs.Account_update.use_full_commitment account_update + &&& not is_start') in let does_not_use_a_signature = Inputs.Bool.not signature_verifies in - Local_state.add_check local_state Parties_replay_check_failed + Local_state.add_check local_state Zkapp_command_replay_check_failed Inputs.Bool.( increments_nonce_and_constrains_its_old_value ||| depends_on_the_fee_payers_nonce_and_isnt_the_fee_payer ||| does_not_use_a_signature) in - let a = Account.set_token_id a (Party.token_id party) in - let party_token = Party.token_id party in - let party_token_is_default = Token_id.(equal default) party_token in + let a = Account.set_token_id a (Account_update.token_id account_update) in + let account_update_token = Account_update.token_id account_update in + let account_update_token_is_default = + Token_id.(equal default) account_update_token + in let account_is_untimed = Bool.not (Account.is_timed a) in (* Set account timing for new accounts, if specified. *) let a, local_state = - let timing = Party.Update.timing party in + let timing = Account_update.Update.timing account_update in let local_state = Local_state.add_check local_state Update_not_permitted_timing_existing_account @@ -1172,7 +1199,7 @@ module Make (Inputs : Inputs_intf) = struct in (* Apply balance change. *) let a, local_state = - let balance_change = Party.balance_change party in + let balance_change = Account_update.balance_change account_update in let balance, `Overflow failed1 = Balance.add_signed_amount_flagged (Account.balance a) balance_change in @@ -1244,7 +1271,7 @@ module Make (Inputs : Inputs_intf) = struct let a = Account.make_zkapp a in (* Update app state. *) let a, local_state = - let app_state = Party.Update.app_state party in + let app_state = Account_update.Update.app_state account_update in let keeping_app_state = Bool.all (List.map ~f:Set_or_keep.is_keep @@ -1298,7 +1325,9 @@ module Make (Inputs : Inputs_intf) = struct in (* Set verification key. *) let a, local_state = - let verification_key = Party.Update.verification_key party in + let verification_key = + Account_update.Update.verification_key account_update + in let has_permission = Controller.check ~proof_verifies ~signature_verifies (Account.Permissions.set_verification_key a) @@ -1316,7 +1345,9 @@ module Make (Inputs : Inputs_intf) = struct in (* Update sequence state. *) let a, local_state = - let sequence_events = Party.Update.sequence_events party in + let sequence_events = + Account_update.Update.sequence_events account_update + in let last_sequence_slot = Account.last_sequence_slot a in let sequence_state, last_sequence_slot = update_sequence_state (Account.sequence_state a) sequence_events @@ -1345,7 +1376,7 @@ module Make (Inputs : Inputs_intf) = struct let a = Account.unmake_zkapp a in (* Update snapp URI. *) let a, local_state = - let zkapp_uri = Party.Update.zkapp_uri party in + let zkapp_uri = Account_update.Update.zkapp_uri account_update in let has_permission = Controller.check ~proof_verifies ~signature_verifies (Account.Permissions.set_zkapp_uri a) @@ -1363,7 +1394,7 @@ module Make (Inputs : Inputs_intf) = struct in (* Update token symbol. *) let a, local_state = - let token_symbol = Party.Update.token_symbol party in + let token_symbol = Account_update.Update.token_symbol account_update in let has_permission = Controller.check ~proof_verifies ~signature_verifies (Account.Permissions.set_token_symbol a) @@ -1381,17 +1412,18 @@ module Make (Inputs : Inputs_intf) = struct in (* Update delegate. *) let a, local_state = - let delegate = Party.Update.delegate party in + let delegate = Account_update.Update.delegate account_update in let base_delegate = let should_set_new_account_delegate = (* Only accounts for the default token may delegate. *) - Bool.(account_is_new &&& party_token_is_default) + Bool.(account_is_new &&& account_update_token_is_default) in (* New accounts should have the delegate equal to the public key of the account. *) Public_key.if_ should_set_new_account_delegate - ~then_:(Party.public_key party) ~else_:(Account.delegate a) + ~then_:(Account_update.public_key account_update) + ~else_:(Account.delegate a) in let has_permission = Controller.check ~proof_verifies ~signature_verifies @@ -1402,7 +1434,7 @@ module Make (Inputs : Inputs_intf) = struct Local_state.add_check local_state Update_not_permitted_delegate Bool.( Set_or_keep.is_keep delegate - ||| (has_permission &&& party_token_is_default)) + ||| (has_permission &&& account_update_token_is_default)) in let delegate = Set_or_keep.set_or_keep ~if_:Public_key.if_ delegate base_delegate @@ -1413,7 +1445,7 @@ module Make (Inputs : Inputs_intf) = struct (* Update nonce. *) let a, local_state = let nonce = Account.nonce a in - let increment_nonce = Party.increment_nonce party in + let increment_nonce = Account_update.increment_nonce account_update in let nonce = Nonce.if_ increment_nonce ~then_:(Nonce.succ nonce) ~else_:nonce in @@ -1430,7 +1462,7 @@ module Make (Inputs : Inputs_intf) = struct in (* Update voting-for. *) let a, local_state = - let voting_for = Party.Update.voting_for party in + let voting_for = Account_update.Update.voting_for account_update in let has_permission = Controller.check ~proof_verifies ~signature_verifies (Account.Permissions.set_voting_for a) @@ -1458,8 +1490,8 @@ module Make (Inputs : Inputs_intf) = struct local_state.full_transaction_commitment |> Receipt_chain_hash.Elt.of_transaction_commitment in - Receipt_chain_hash.cons_parties_commitment local_state.party_index - elt old_hash ) + Receipt_chain_hash.cons_zkapp_command_commitment + local_state.account_update_index elt old_hash ) ~else_:old_hash in Account.set_receipt_chain_hash a new_hash @@ -1467,10 +1499,10 @@ module Make (Inputs : Inputs_intf) = struct (* Finally, update permissions. This should be the last update applied, to ensure that any earlier updates use the account's existing permissions, and not permissions that - are specified by the party! + are specified by the account_update! *) let a, local_state = - let permissions = Party.Update.permissions party in + let permissions = Account_update.Update.permissions account_update in let has_permission = Controller.check ~proof_verifies ~signature_verifies (Account.Permissions.set_permissions a) @@ -1487,7 +1519,7 @@ module Make (Inputs : Inputs_intf) = struct (a, local_state) in (* Initialize account's pk, in case it is new. *) - let a = h.perform (Init_account { party; account = a }) in + let a = h.perform (Init_account { account_update; account = a }) in (* DO NOT ADD ANY UPDATES HERE. They must be earlier in the code. See comment above. *) @@ -1496,11 +1528,11 @@ module Make (Inputs : Inputs_intf) = struct Indeed, if the account creation fee is paid, using that amount would be equivalent to paying it out to the block producer. In the case of a failure that prevents any updates from being applied, - every other party in this transaction will also fail, and the excess + every other account_update in this transaction will also fail, and the excess will never be promoted to the global excess, so this amount is irrelevant. *) - Amount.Signed.negate (Party.balance_change party) + Amount.Signed.negate (Account_update.balance_change account_update) in let new_local_fee_excess, `Overflow overflowed = let curr_token : Token_id.t = local_state.token_id in @@ -1510,14 +1542,15 @@ module Make (Inputs : Inputs_intf) = struct Bool.( assert_ ( (not is_start') - ||| (party_token_is_default &&& Amount.Signed.is_pos local_delta) )) ; + ||| ( account_update_token_is_default + &&& Amount.Signed.is_pos local_delta ) )) ; let new_local_fee_excess, `Overflow overflow = Amount.Signed.add_flagged local_state.excess local_delta in - ( Amount.Signed.if_ party_token_is_default ~then_:new_local_fee_excess - ~else_:local_state.excess - , (* No overflow if we aren't using the result of the addition (which we don't in the case that party token is not default). *) - `Overflow (Bool.( &&& ) party_token_is_default overflow) ) + ( Amount.Signed.if_ account_update_token_is_default + ~then_:new_local_fee_excess ~else_:local_state.excess + , (* No overflow if we aren't using the result of the addition (which we don't in the case that account_update token is not default). *) + `Overflow (Bool.( &&& ) account_update_token_is_default overflow) ) in let local_state = { local_state with excess = new_local_fee_excess } in let local_state = @@ -1528,25 +1561,27 @@ module Make (Inputs : Inputs_intf) = struct (* If a's token ID differs from that in the local state, then the local state excess gets moved into the execution state's fee excess. - If there are more parties to execute after this one, then the local delta gets + If there are more zkapp_command to execute after this one, then the local delta gets accumulated in the local state. - If there are no more parties to execute, then we do the same as if we switch tokens. + If there are no more zkapp_command to execute, then we do the same as if we switch tokens. The local state excess (plus the local delta) gets moved to the fee excess if it is default token. *) let new_ledger = Inputs.Ledger.set_account local_state.ledger (a, inclusion_proof) in - let is_last_party = Call_forest.is_empty (Stack_frame.calls remaining) in + let is_last_account_update = + Call_forest.is_empty (Stack_frame.calls remaining) + in let local_state = { local_state with ledger = new_ledger ; transaction_commitment = - Transaction_commitment.if_ is_last_party + Transaction_commitment.if_ is_last_account_update ~then_:Transaction_commitment.empty ~else_:local_state.transaction_commitment ; full_transaction_commitment = - Transaction_commitment.if_ is_last_party + Transaction_commitment.if_ is_last_account_update ~then_:Transaction_commitment.empty ~else_:local_state.full_transaction_commitment } @@ -1555,12 +1590,12 @@ module Make (Inputs : Inputs_intf) = struct let delta_settled = Amount.Signed.equal local_state.excess Amount.(Signed.of_unsigned zero) in - Bool.((not is_last_party) ||| delta_settled) + Bool.((not is_last_account_update) ||| delta_settled) in let local_state = Local_state.add_check local_state Invalid_fee_excess valid_fee_excess in - let update_local_excess = Bool.(is_start' ||| is_last_party) in + let update_local_excess = Bool.(is_start' ||| is_last_account_update) in let update_global_state = Bool.(update_local_excess &&& local_state.success) in @@ -1592,7 +1627,7 @@ module Make (Inputs : Inputs_intf) = struct Local_state.add_check local_state Global_excess_overflow Bool.(not global_excess_update_failed) in - (* The first party must succeed. *) + (* The first account_update must succeed. *) Bool.( assert_with_failure_status_tbl ((not is_start') ||| local_state.success) @@ -1604,7 +1639,7 @@ module Make (Inputs : Inputs_intf) = struct let local_state = (* Make sure to reset the local_state at the end of a transaction. The following fields are already reset - - parties + - zkapp_command - transaction_commitment - full_transaction_commitment - excess @@ -1612,22 +1647,23 @@ module Make (Inputs : Inputs_intf) = struct - token_id = Token_id.default - ledger = Frozen_ledger_hash.empty_hash - success = true - - party_index = Index.zero + - account_update_index = Index.zero *) { local_state with token_id = - Token_id.if_ is_last_party ~then_:Token_id.default + Token_id.if_ is_last_account_update ~then_:Token_id.default ~else_:local_state.token_id ; ledger = - Inputs.Ledger.if_ is_last_party + Inputs.Ledger.if_ is_last_account_update ~then_: (Inputs.Ledger.empty ~depth:constraint_constants.ledger_depth ()) ~else_:local_state.ledger ; success = - Bool.if_ is_last_party ~then_:Bool.true_ ~else_:local_state.success - ; party_index = - Inputs.Index.if_ is_last_party ~then_:Inputs.Index.zero - ~else_:(Inputs.Index.succ local_state.party_index) + Bool.if_ is_last_account_update ~then_:Bool.true_ + ~else_:local_state.success + ; account_update_index = + Inputs.Index.if_ is_last_account_update ~then_:Inputs.Index.zero + ~else_:(Inputs.Index.succ local_state.account_update_index) } in (global_state, local_state) diff --git a/src/lib/transaction_snark/test/account_timing/account_timing.ml b/src/lib/transaction_snark/test/account_timing/account_timing.ml index 94803dfefc3..ee4c2bbcf0d 100644 --- a/src/lib/transaction_snark/test/account_timing/account_timing.ml +++ b/src/lib/transaction_snark/test/account_timing/account_timing.ml @@ -819,19 +819,21 @@ let%test_module "account timing check" = then failwithf "Unexpected transaction error: %s" err_str () ) ) (* zkApps with timings *) - let apply_zkapp_commands_at_slot ledger slot (partiess : Parties.t list) = + let apply_zkapp_commands_at_slot ledger slot + (zkapp_commands : Zkapp_command.t list) = let state_body, _state_view = state_body_and_view_at_slot slot in - Async.Deferred.List.iter partiess ~f:(fun parties -> - Transaction_snark_tests.Util.check_parties_with_merges_exn ~state_body - ledger [ parties ] ) + Async.Deferred.List.iter zkapp_commands ~f:(fun zkapp_command -> + Transaction_snark_tests.Util.check_zkapp_command_with_merges_exn + ~state_body ledger [ zkapp_command ] ) |> Fn.flip Async.upon (fun () -> ()) let check_zkapp_failure expected_failure = function | Ok - ( (parties_applied : - Mina_transaction_logic.Transaction_applied.Parties_applied.t ) + ( (zkapp_command_applied : + Mina_transaction_logic.Transaction_applied.Zkapp_command_applied.t + ) , ( (local_state : - _ Mina_transaction_logic.Parties_logic.Local_state.t ) + _ Mina_transaction_logic.Zkapp_command_logic.Local_state.t ) , _amount ) ) -> ( (* we expect a Failed status, and the failure to appear in the failure status table @@ -839,7 +841,7 @@ let%test_module "account timing check" = let failure_statuses = local_state.failure_status_tbl |> List.concat in - match With_status.status parties_applied.command with + match With_status.status zkapp_command_applied.command with | Applied -> failwithf "Expected transaction failure: %s" (Transaction_status.Failure.to_string expected_failure) @@ -886,7 +888,7 @@ let%test_module "account timing check" = (keypair, balance_as_amount, nonce, timing) ) |> Array.of_list in - let parties = + let zkapp_command = let open Mina_base in let fee = Currency.Fee.of_int 1_000_000 in let amount = Currency.Amount.of_int 1_500_000 in @@ -900,7 +902,7 @@ let%test_module "account timing check" = let receiver_key = zkapp_keypair.public_key |> Signature_lib.Public_key.compress in - let (parties_spec : Transaction_snark.For_tests.Spec.t) = + let (zkapp_command_spec : Transaction_snark.For_tests.Spec.t) = { sender = (sender_keypair, nonce) ; fee ; fee_payer = None @@ -909,7 +911,7 @@ let%test_module "account timing check" = ; zkapp_account_keypairs = [] ; memo ; new_zkapp_account = false - ; snapp_update = Party.Update.dummy + ; snapp_update = Account_update.Update.dummy ; current_auth = Permissions.Auth_required.Signature ; call_data = Snark_params.Tick.Field.zero ; events = [] @@ -917,14 +919,14 @@ let%test_module "account timing check" = ; preconditions = None } in - Transaction_snark.For_tests.multiple_transfers parties_spec + Transaction_snark.For_tests.multiple_transfers zkapp_command_spec in - return (ledger_init_state, parties) + return (ledger_init_state, zkapp_command) in (* slot 1, well before cliff *) Quickcheck.test ~seed:(`Deterministic "zkapp command, before cliff") - ~sexp_of:[%sexp_of: Mina_ledger.Ledger.init_state * Parties.t] ~trials:2 - gen ~f:(fun (ledger_init_state, txn) -> + ~sexp_of:[%sexp_of: Mina_ledger.Ledger.init_state * Zkapp_command.t] + ~trials:2 gen ~f:(fun (ledger_init_state, txn) -> Mina_ledger.Ledger.with_ephemeral_ledger ~depth:constraint_constants.ledger_depth ~f:(fun ledger -> Mina_ledger.Ledger.apply_initial_ledger_state ledger @@ -955,7 +957,7 @@ let%test_module "account timing check" = (keypair, balance_as_amount, nonce, timing) ) |> Array.of_list in - let parties_command = + let zkapp_command_command = let open Mina_base in let fee = Currency.Fee.of_int 1_000_000 in let amount = Currency.Amount.of_int 10_000_000_000_000 in @@ -969,7 +971,7 @@ let%test_module "account timing check" = let receiver_key = zkapp_keypair.public_key |> Signature_lib.Public_key.compress in - let (parties_spec : Transaction_snark.For_tests.Spec.t) = + let (zkapp_command_spec : Transaction_snark.For_tests.Spec.t) = { sender = (sender_keypair, nonce) ; fee ; fee_payer = None @@ -978,7 +980,7 @@ let%test_module "account timing check" = ; zkapp_account_keypairs = [] ; memo ; new_zkapp_account = false - ; snapp_update = Party.Update.dummy + ; snapp_update = Account_update.Update.dummy ; current_auth = Permissions.Auth_required.Signature ; call_data = Snark_params.Tick.Field.zero ; events = [] @@ -986,14 +988,14 @@ let%test_module "account timing check" = ; preconditions = None } in - Transaction_snark.For_tests.multiple_transfers parties_spec + Transaction_snark.For_tests.multiple_transfers zkapp_command_spec in - return (ledger_init_state, parties_command) + return (ledger_init_state, zkapp_command_command) in (* slot 1, well before cliffs *) Quickcheck.test ~seed:(`Deterministic "zkapp command, before cliff") - ~sexp_of:[%sexp_of: Mina_ledger.Ledger.init_state * Parties.t] ~trials:1 - gen ~f:(fun (ledger_init_state, parties) -> + ~sexp_of:[%sexp_of: Mina_ledger.Ledger.init_state * Zkapp_command.t] + ~trials:1 gen ~f:(fun (ledger_init_state, zkapp_command) -> Mina_ledger.Ledger.with_ephemeral_ledger ~depth:constraint_constants.ledger_depth ~f:(fun ledger -> Mina_ledger.Ledger.apply_initial_ledger_state ledger @@ -1002,8 +1004,8 @@ let%test_module "account timing check" = state_body_and_view_at_slot Mina_numbers.Global_slot.(succ zero) in let result = - Mina_ledger.Ledger.apply_parties_unchecked ~constraint_constants - ~state_view ledger parties + Mina_ledger.Ledger.apply_zkapp_command_unchecked + ~constraint_constants ~state_view ledger zkapp_command in check_zkapp_failure Transaction_status.Failure.Source_minimum_balance_violation @@ -1034,7 +1036,7 @@ let%test_module "account timing check" = (keypair, balance_as_amount, nonce, timing) ) |> Array.of_list in - let parties_command = + let zkapp_command_command = let open Mina_base in let fee = Currency.Fee.of_int 1_000_000 in let amount = Currency.Amount.of_int 10_000_000_000_000 in @@ -1048,7 +1050,7 @@ let%test_module "account timing check" = let receiver_key = zkapp_keypair.public_key |> Signature_lib.Public_key.compress in - let (parties_spec : Transaction_snark.For_tests.Spec.t) = + let (zkapp_command_spec : Transaction_snark.For_tests.Spec.t) = { sender = (sender_keypair, nonce) ; fee ; fee_payer = None @@ -1057,7 +1059,7 @@ let%test_module "account timing check" = ; zkapp_account_keypairs = [] ; memo ; new_zkapp_account = false - ; snapp_update = Party.Update.dummy + ; snapp_update = Account_update.Update.dummy ; current_auth = Permissions.Auth_required.Signature ; call_data = Snark_params.Tick.Field.zero ; events = [] @@ -1065,14 +1067,14 @@ let%test_module "account timing check" = ; preconditions = None } in - Transaction_snark.For_tests.multiple_transfers parties_spec + Transaction_snark.For_tests.multiple_transfers zkapp_command_spec in - return (ledger_init_state, parties_command) + return (ledger_init_state, zkapp_command_command) in (* slot 1, well before cliffs *) Quickcheck.test ~seed:(`Deterministic "zkapp command, before cliff") - ~sexp_of:[%sexp_of: Mina_ledger.Ledger.init_state * Parties.t] ~trials:1 - gen ~f:(fun (ledger_init_state, parties) -> + ~sexp_of:[%sexp_of: Mina_ledger.Ledger.init_state * Zkapp_command.t] + ~trials:1 gen ~f:(fun (ledger_init_state, zkapp_command) -> Mina_ledger.Ledger.with_ephemeral_ledger ~depth:constraint_constants.ledger_depth ~f:(fun ledger -> Mina_ledger.Ledger.apply_initial_ledger_state ledger @@ -1081,8 +1083,8 @@ let%test_module "account timing check" = state_body_and_view_at_slot Mina_numbers.Global_slot.(succ zero) in match - Mina_ledger.Ledger.apply_parties_unchecked ~constraint_constants - ~state_view ledger parties + Mina_ledger.Ledger.apply_zkapp_command_unchecked + ~constraint_constants ~state_view ledger zkapp_command with | Ok _txn_applied -> failwith "Should have failed with min balance violation" @@ -1135,9 +1137,9 @@ let%test_module "account timing check" = ; vesting_period = Mina_numbers.Global_slot.of_int 10 ; vesting_increment = Currency.Amount.of_int 100_000_000 } - : Party.Update.Timing_info.value ) + : Account_update.Update.Timing_info.value ) in - { Party.Update.dummy with timing } ) + { Account_update.Update.dummy with timing } ) ; current_auth = Permissions.Auth_required.Proof ; call_data = Snark_params.Tick.Field.zero ; events = [] @@ -1150,14 +1152,14 @@ let%test_module "account timing check" = (zkapp_keypair.public_key |> Signature_lib.Public_key.compress) Token_id.default in - let parties, _, _, _ = + let zkapp_command, _, _, _ = ( Transaction_snark.For_tests.deploy_snapp ~constraint_constants create_timed_account_spec , timed_account_id , create_timed_account_spec.snapp_update , zkapp_keypair ) in - return (ledger_init_state, parties) + return (ledger_init_state, zkapp_command) let%test_unit "zkApp command, timed account creation, min_balance > balance" = @@ -1165,10 +1167,11 @@ let%test_module "account timing check" = ~seed: (`Deterministic "zkapp command, timed account creation, min_balance > balance" ) - ~sexp_of:[%sexp_of: Mina_ledger.Ledger.init_state * Parties.t] ~trials:1 + ~sexp_of:[%sexp_of: Mina_ledger.Ledger.init_state * Zkapp_command.t] + ~trials:1 (gen_untimed_account_and_create_timed_account ~balance:100_000_000 ~min_balance:100_000_000_000_000 ) - ~f:(fun (ledger_init_state, parties) -> + ~f:(fun (ledger_init_state, zkapp_command) -> Mina_ledger.Ledger.with_ephemeral_ledger ~depth:constraint_constants.ledger_depth ~f:(fun ledger -> Mina_ledger.Ledger.apply_initial_ledger_state ledger @@ -1177,8 +1180,8 @@ let%test_module "account timing check" = state_body_and_view_at_slot Mina_numbers.Global_slot.(succ zero) in let result = - Mina_ledger.Ledger.apply_parties_unchecked ~constraint_constants - ~state_view ledger parties + Mina_ledger.Ledger.apply_zkapp_command_unchecked + ~constraint_constants ~state_view ledger zkapp_command in check_zkapp_failure Transaction_status.Failure.Source_minimum_balance_violation @@ -1189,34 +1192,36 @@ let%test_module "account timing check" = ~seed: (`Deterministic "zkApp command, account creation, min_balance = balance" ) - ~sexp_of:[%sexp_of: Mina_ledger.Ledger.init_state * Parties.t] ~trials:1 + ~sexp_of:[%sexp_of: Mina_ledger.Ledger.init_state * Zkapp_command.t] + ~trials:1 (gen_untimed_account_and_create_timed_account ~balance:100_000_000_000_000 ~min_balance:100_000_000_000_000 ) - ~f:(fun (ledger_init_state, parties) -> + ~f:(fun (ledger_init_state, zkapp_command) -> Mina_ledger.Ledger.with_ephemeral_ledger ~depth:constraint_constants.ledger_depth ~f:(fun ledger -> Mina_ledger.Ledger.apply_initial_ledger_state ledger ledger_init_state ; apply_zkapp_commands_at_slot ledger Mina_numbers.Global_slot.(succ zero) - [ parties ] ) ) + [ zkapp_command ] ) ) let%test_unit "zkApp command, account creation, min_balance < balance" = Quickcheck.test ~seed: (`Deterministic "zkapp command, account creation, min_balance < balace" ) - ~sexp_of:[%sexp_of: Mina_ledger.Ledger.init_state * Parties.t] ~trials:1 + ~sexp_of:[%sexp_of: Mina_ledger.Ledger.init_state * Zkapp_command.t] + ~trials:1 (gen_untimed_account_and_create_timed_account ~balance:150_000_000_000_000 ~min_balance:100_000_000_000_000 ) - ~f:(fun (ledger_init_state, parties) -> + ~f:(fun (ledger_init_state, zkapp_command) -> Mina_ledger.Ledger.with_ephemeral_ledger ~depth:constraint_constants.ledger_depth ~f:(fun ledger -> Mina_ledger.Ledger.apply_initial_ledger_state ledger ledger_init_state ; apply_zkapp_commands_at_slot ledger Mina_numbers.Global_slot.(succ zero) - [ parties ] ) ) + [ zkapp_command ] ) ) let%test_unit "zkApp command, just before cliff time, insufficient balance" = @@ -1241,7 +1246,7 @@ let%test_module "account timing check" = |> Array.of_list in (* min balance = balance, spending anything before cliff should trigger min balance violation *) - let parties_command = + let zkapp_command_command = let open Mina_base in let fee = Currency.Fee.of_int 1_000_000 in let amount = Currency.Amount.of_int 10_000_000_000_000 in @@ -1255,7 +1260,7 @@ let%test_module "account timing check" = let receiver_key = zkapp_keypair.public_key |> Signature_lib.Public_key.compress in - let (parties_spec : Transaction_snark.For_tests.Spec.t) = + let (zkapp_command_spec : Transaction_snark.For_tests.Spec.t) = { sender = (sender_keypair, nonce) ; fee ; fee_payer = None @@ -1264,7 +1269,7 @@ let%test_module "account timing check" = ; zkapp_account_keypairs = [] ; memo ; new_zkapp_account = false - ; snapp_update = Party.Update.dummy + ; snapp_update = Account_update.Update.dummy ; current_auth = Permissions.Auth_required.Signature ; call_data = Snark_params.Tick.Field.zero ; events = [] @@ -1272,13 +1277,13 @@ let%test_module "account timing check" = ; preconditions = None } in - Transaction_snark.For_tests.multiple_transfers parties_spec + Transaction_snark.For_tests.multiple_transfers zkapp_command_spec in - return (ledger_init_state, parties_command) + return (ledger_init_state, zkapp_command_command) in Quickcheck.test ~seed:(`Deterministic "zkapp command, just before cliff") - ~sexp_of:[%sexp_of: Mina_ledger.Ledger.init_state * Parties.t] ~trials:1 - gen ~f:(fun (ledger_init_state, parties) -> + ~sexp_of:[%sexp_of: Mina_ledger.Ledger.init_state * Zkapp_command.t] + ~trials:1 gen ~f:(fun (ledger_init_state, zkapp_command) -> Mina_ledger.Ledger.with_ephemeral_ledger ~depth:constraint_constants.ledger_depth ~f:(fun ledger -> Mina_ledger.Ledger.apply_initial_ledger_state ledger @@ -1288,8 +1293,8 @@ let%test_module "account timing check" = Mina_numbers.Global_slot.(of_int 9999) in match - Mina_ledger.Ledger.apply_parties_unchecked ~constraint_constants - ~state_view ledger parties + Mina_ledger.Ledger.apply_zkapp_command_unchecked + ~constraint_constants ~state_view ledger zkapp_command with | Ok _txn_applied -> failwith "Should have failed with min balance violation" @@ -1326,7 +1331,7 @@ let%test_module "account timing check" = (keypair, balance_as_amount, nonce, timing) ) |> Array.of_list in - let parties = + let zkapp_command = let open Mina_base in let fee = Currency.Fee.of_int 1_000_000 in let amount = Currency.Amount.of_int 10_000_000_000_000 in @@ -1340,7 +1345,7 @@ let%test_module "account timing check" = let receiver_key = zkapp_keypair.public_key |> Signature_lib.Public_key.compress in - let (parties_spec : Transaction_snark.For_tests.Spec.t) = + let (zkapp_command_spec : Transaction_snark.For_tests.Spec.t) = { sender = (sender_keypair, nonce) ; fee ; fee_payer = None @@ -1349,7 +1354,7 @@ let%test_module "account timing check" = ; zkapp_account_keypairs = [] ; memo ; new_zkapp_account = false - ; snapp_update = Party.Update.dummy + ; snapp_update = Account_update.Update.dummy ; current_auth = Permissions.Auth_required.Signature ; call_data = Snark_params.Tick.Field.zero ; events = [] @@ -1357,20 +1362,20 @@ let%test_module "account timing check" = ; preconditions = None } in - Transaction_snark.For_tests.multiple_transfers parties_spec + Transaction_snark.For_tests.multiple_transfers zkapp_command_spec in - return (ledger_init_state, parties) + return (ledger_init_state, zkapp_command) in Quickcheck.test ~seed:(`Deterministic "zkapp command, at cliff time") - ~sexp_of:[%sexp_of: Mina_ledger.Ledger.init_state * Parties.t] ~trials:1 - gen ~f:(fun (ledger_init_state, parties) -> + ~sexp_of:[%sexp_of: Mina_ledger.Ledger.init_state * Zkapp_command.t] + ~trials:1 gen ~f:(fun (ledger_init_state, zkapp_command) -> Mina_ledger.Ledger.with_ephemeral_ledger ~depth:constraint_constants.ledger_depth ~f:(fun ledger -> Mina_ledger.Ledger.apply_initial_ledger_state ledger ledger_init_state ; apply_zkapp_commands_at_slot ledger Mina_numbers.Global_slot.(of_int 10000) - [ parties ] ) ) + [ zkapp_command ] ) ) let%test_unit "zkApp command, while vesting, sufficient balance" = let gen = @@ -1400,7 +1405,7 @@ let%test_module "account timing check" = in let fee_int = 1_000_000 in let amount_int = liquid_balance - fee_int in - let parties = + let zkapp_command = let open Mina_base in let fee = Currency.Fee.of_int 1_000_000 in let amount = Currency.Amount.of_int amount_int in @@ -1414,7 +1419,7 @@ let%test_module "account timing check" = let receiver_key = zkapp_keypair.public_key |> Signature_lib.Public_key.compress in - let (parties_spec : Transaction_snark.For_tests.Spec.t) = + let (zkapp_command_spec : Transaction_snark.For_tests.Spec.t) = { sender = (sender_keypair, nonce) ; fee ; fee_payer = None @@ -1423,7 +1428,7 @@ let%test_module "account timing check" = ; zkapp_account_keypairs = [] ; memo ; new_zkapp_account = false - ; snapp_update = Party.Update.dummy + ; snapp_update = Account_update.Update.dummy ; current_auth = Permissions.Auth_required.Signature ; call_data = Snark_params.Tick.Field.zero ; events = [] @@ -1431,20 +1436,20 @@ let%test_module "account timing check" = ; preconditions = None } in - Transaction_snark.For_tests.multiple_transfers parties_spec + Transaction_snark.For_tests.multiple_transfers zkapp_command_spec in - return (ledger_init_state, parties) + return (ledger_init_state, zkapp_command) in Quickcheck.test ~seed:(`Deterministic "zkapp command, while vesting") - ~sexp_of:[%sexp_of: Mina_ledger.Ledger.init_state * Parties.t] ~trials:1 - gen ~f:(fun (ledger_init_state, parties) -> + ~sexp_of:[%sexp_of: Mina_ledger.Ledger.init_state * Zkapp_command.t] + ~trials:1 gen ~f:(fun (ledger_init_state, zkapp_command) -> Mina_ledger.Ledger.with_ephemeral_ledger ~depth:constraint_constants.ledger_depth ~f:(fun ledger -> Mina_ledger.Ledger.apply_initial_ledger_state ledger ledger_init_state ; apply_zkapp_commands_at_slot ledger Mina_numbers.Global_slot.(of_int 10_100) - [ parties ] ) ) + [ zkapp_command ] ) ) let%test_unit "zkApp command, while vesting, insufficient balance" = let gen = @@ -1475,7 +1480,7 @@ let%test_module "account timing check" = let fee_int = 1_000_000 in (* the + 1 breaks the min balance requirement *) let amount_int = liquid_balance - fee_int + 1 in - let parties = + let zkapp_command = let open Mina_base in let fee = Currency.Fee.of_int 1_000_000 in let amount = Currency.Amount.of_int amount_int in @@ -1489,7 +1494,7 @@ let%test_module "account timing check" = let receiver_key = zkapp_keypair.public_key |> Signature_lib.Public_key.compress in - let (parties_spec : Transaction_snark.For_tests.Spec.t) = + let (zkapp_command_spec : Transaction_snark.For_tests.Spec.t) = { sender = (sender_keypair, nonce) ; fee ; fee_payer = None @@ -1498,7 +1503,7 @@ let%test_module "account timing check" = ; zkapp_account_keypairs = [] ; memo ; new_zkapp_account = false - ; snapp_update = Party.Update.dummy + ; snapp_update = Account_update.Update.dummy ; current_auth = Permissions.Auth_required.Signature ; call_data = Snark_params.Tick.Field.zero ; events = [] @@ -1506,13 +1511,13 @@ let%test_module "account timing check" = ; preconditions = None } in - Transaction_snark.For_tests.multiple_transfers parties_spec + Transaction_snark.For_tests.multiple_transfers zkapp_command_spec in - return (ledger_init_state, parties) + return (ledger_init_state, zkapp_command) in Quickcheck.test ~seed:(`Deterministic "zkapp command, while vesting") - ~sexp_of:[%sexp_of: Mina_ledger.Ledger.init_state * Parties.t] ~trials:1 - gen ~f:(fun (ledger_init_state, parties) -> + ~sexp_of:[%sexp_of: Mina_ledger.Ledger.init_state * Zkapp_command.t] + ~trials:1 gen ~f:(fun (ledger_init_state, zkapp_command) -> Mina_ledger.Ledger.with_ephemeral_ledger ~depth:constraint_constants.ledger_depth ~f:(fun ledger -> Mina_ledger.Ledger.apply_initial_ledger_state ledger @@ -1522,8 +1527,8 @@ let%test_module "account timing check" = Mina_numbers.Global_slot.(of_int 10_100) in let result = - Mina_ledger.Ledger.apply_parties_unchecked ~constraint_constants - ~state_view ledger parties + Mina_ledger.Ledger.apply_zkapp_command_unchecked + ~constraint_constants ~state_view ledger zkapp_command in check_zkapp_failure Transaction_status.Failure.Source_minimum_balance_violation @@ -1554,7 +1559,7 @@ let%test_module "account timing check" = in let fee_int = 1_000_000 in let amount_int = balance_int - fee_int in - let parties = + let zkapp_command = let open Mina_base in let fee = Currency.Fee.of_int fee_int in let amount = Currency.Amount.of_int amount_int in @@ -1568,7 +1573,7 @@ let%test_module "account timing check" = let receiver_key = zkapp_keypair.public_key |> Signature_lib.Public_key.compress in - let (parties_spec : Transaction_snark.For_tests.Spec.t) = + let (zkapp_command_spec : Transaction_snark.For_tests.Spec.t) = { sender = (sender_keypair, nonce) ; fee ; fee_payer = None @@ -1577,7 +1582,7 @@ let%test_module "account timing check" = ; zkapp_account_keypairs = [] ; memo ; new_zkapp_account = false - ; snapp_update = Party.Update.dummy + ; snapp_update = Account_update.Update.dummy ; current_auth = Permissions.Auth_required.Signature ; call_data = Snark_params.Tick.Field.zero ; events = [] @@ -1585,20 +1590,20 @@ let%test_module "account timing check" = ; preconditions = None } in - Transaction_snark.For_tests.multiple_transfers parties_spec + Transaction_snark.For_tests.multiple_transfers zkapp_command_spec in - return (ledger_init_state, parties) + return (ledger_init_state, zkapp_command) in Quickcheck.test ~seed:(`Deterministic "zkapp command, after vesting") - ~sexp_of:[%sexp_of: Mina_ledger.Ledger.init_state * Parties.t] ~trials:1 - gen ~f:(fun (ledger_init_state, parties) -> + ~sexp_of:[%sexp_of: Mina_ledger.Ledger.init_state * Zkapp_command.t] + ~trials:1 gen ~f:(fun (ledger_init_state, zkapp_command) -> Mina_ledger.Ledger.with_ephemeral_ledger ~depth:constraint_constants.ledger_depth ~f:(fun ledger -> Mina_ledger.Ledger.apply_initial_ledger_state ledger ledger_init_state ; apply_zkapp_commands_at_slot ledger Mina_numbers.Global_slot.(of_int (100_000 + 10_000)) - [ parties ] ) ) + [ zkapp_command ] ) ) (* same as previous test, amount is incremented by 1 *) let%test_unit "zkApp command, after vesting, insufficient balance" = @@ -1627,7 +1632,7 @@ let%test_module "account timing check" = let fee_int = 1_000_000 in (* the + 1 makes the balance insufficient *) let amount_int = balance_int - fee_int + 1 in - let parties_command = + let zkapp_command_command = let open Mina_base in let fee = Currency.Fee.of_int fee_int in let amount = Currency.Amount.of_int amount_int in @@ -1641,7 +1646,7 @@ let%test_module "account timing check" = let receiver_key = zkapp_keypair.public_key |> Signature_lib.Public_key.compress in - let (parties_spec : Transaction_snark.For_tests.Spec.t) = + let (zkapp_command_spec : Transaction_snark.For_tests.Spec.t) = { sender = (sender_keypair, nonce) ; fee ; fee_payer = None @@ -1650,7 +1655,7 @@ let%test_module "account timing check" = ; zkapp_account_keypairs = [] ; memo ; new_zkapp_account = false - ; snapp_update = Party.Update.dummy + ; snapp_update = Account_update.Update.dummy ; current_auth = Permissions.Auth_required.Signature ; call_data = Snark_params.Tick.Field.zero ; events = [] @@ -1658,13 +1663,13 @@ let%test_module "account timing check" = ; preconditions = None } in - Transaction_snark.For_tests.multiple_transfers parties_spec + Transaction_snark.For_tests.multiple_transfers zkapp_command_spec in - return (ledger_init_state, parties_command) + return (ledger_init_state, zkapp_command_command) in Quickcheck.test ~seed:(`Deterministic "zkapp command, after vesting") - ~sexp_of:[%sexp_of: Mina_ledger.Ledger.init_state * Parties.t] ~trials:1 - gen ~f:(fun (ledger_init_state, parties) -> + ~sexp_of:[%sexp_of: Mina_ledger.Ledger.init_state * Zkapp_command.t] + ~trials:1 gen ~f:(fun (ledger_init_state, zkapp_command) -> Mina_ledger.Ledger.with_ephemeral_ledger ~depth:constraint_constants.ledger_depth ~f:(fun ledger -> Mina_ledger.Ledger.apply_initial_ledger_state ledger @@ -1675,8 +1680,8 @@ let%test_module "account timing check" = Mina_numbers.Global_slot.(of_int (100_000 + 10_000)) in let result = - Mina_ledger.Ledger.apply_parties_unchecked ~constraint_constants - ~state_view ledger parties + Mina_ledger.Ledger.apply_zkapp_command_unchecked + ~constraint_constants ~state_view ledger zkapp_command in check_zkapp_failure Transaction_status.Failure.Overflow result ) ) @@ -1712,9 +1717,9 @@ let%test_module "account timing check" = ; vesting_period = Mina_numbers.Global_slot.of_int 10 ; vesting_increment = Currency.Amount.of_int 1_000_000_000 } - : Party.Update.Timing_info.value ) + : Account_update.Update.Timing_info.value ) in - { Party.Update.dummy with timing } ) + { Account_update.Update.dummy with timing } ) ; current_auth = Permissions.Auth_required.Proof ; call_data = Snark_params.Tick.Field.zero ; events = [] @@ -1727,7 +1732,7 @@ let%test_module "account timing check" = (zkapp_keypair.public_key |> Signature_lib.Public_key.compress) Token_id.default in - let create_timed_account_parties, _, _, _ = + let create_timed_account_zkapp_command, _, _, _ = ( Transaction_snark.For_tests.deploy_snapp ~no_auth:true ~constraint_constants create_timed_account_spec , timing_account_id @@ -1736,7 +1741,7 @@ let%test_module "account timing check" = in let gen = Quickcheck.Generator.return - (ledger_init_state, create_timed_account_parties) + (ledger_init_state, create_timed_account_zkapp_command) in Async.Thread_safe.block_on_async_exn (fun () -> Async.Quickcheck.async_test @@ -1744,20 +1749,20 @@ let%test_module "account timing check" = (`Deterministic "zkapp command, create timed account with wrong authorization" ) - ~sexp_of:[%sexp_of: Mina_ledger.Ledger.init_state * Parties.t] + ~sexp_of:[%sexp_of: Mina_ledger.Ledger.init_state * Zkapp_command.t] ~trials:1 gen - ~f:(fun (ledger_init_state, create_timed_account_parties) -> + ~f:(fun (ledger_init_state, create_timed_account_zkapp_command) -> let ledger = Mina_ledger.Ledger.create ~depth:constraint_constants.ledger_depth () in Mina_ledger.Ledger.apply_initial_ledger_state ledger ledger_init_state ; - Transaction_snark_tests.Util.check_parties_with_merges_exn + Transaction_snark_tests.Util.check_zkapp_command_with_merges_exn ~expected_failure: Transaction_status.Failure .Update_not_permitted_timing_existing_account ledger - [ create_timed_account_parties ] ) ) + [ create_timed_account_zkapp_command ] ) ) let%test_unit "zkApp command, change untimed account to timed" = Async.Thread_safe.block_on_async_exn (fun () -> @@ -1792,9 +1797,9 @@ let%test_module "account timing check" = ; vesting_increment = Currency.Amount.of_int 1_000_000_000 } - : Party.Update.Timing_info.value ) + : Account_update.Update.Timing_info.value ) in - { Party.Update.dummy with timing } ) + { Account_update.Update.dummy with timing } ) ; current_auth = Permissions.Auth_required.Signature ; call_data = Snark_params.Tick.Field.zero ; events = [] @@ -1803,28 +1808,30 @@ let%test_module "account timing check" = } in let open Async.Deferred.Let_syntax in - let%bind update_timing_parties = + let%bind update_timing_zkapp_command = Transaction_snark.For_tests.update_states ~constraint_constants update_timing_spec in let gen = Quickcheck.Generator.return - (ledger_init_state, update_timing_parties) + (ledger_init_state, update_timing_zkapp_command) in Async.Quickcheck.async_test ~seed: (`Deterministic "zkapp command, change untimed account to timed account" ) - ~sexp_of:[%sexp_of: Mina_ledger.Ledger.init_state * Parties.t] - ~trials:1 gen ~f:(fun (ledger_init_state, update_timing_parties) -> + ~sexp_of:[%sexp_of: Mina_ledger.Ledger.init_state * Zkapp_command.t] + ~trials:1 gen + ~f:(fun (ledger_init_state, update_timing_zkapp_command) -> let ledger = Mina_ledger.Ledger.create ~depth:constraint_constants.ledger_depth () in Mina_ledger.Ledger.apply_initial_ledger_state ledger ledger_init_state ; - Transaction_snark_tests.Util.check_parties_with_merges_exn ledger - [ update_timing_parties ] ) ) + Transaction_snark_tests.Util.check_zkapp_command_with_merges_exn + ledger + [ update_timing_zkapp_command ] ) ) let%test_unit "zkApp command, invalid update for timed account" = Async.Thread_safe.block_on_async_exn (fun () -> @@ -1870,9 +1877,9 @@ let%test_module "account timing check" = ; vesting_increment = Currency.Amount.of_int 1_000_000_000 } - : Party.Update.Timing_info.value ) + : Account_update.Update.Timing_info.value ) in - { Party.Update.dummy with timing } ) + { Account_update.Update.dummy with timing } ) ; current_auth = Permissions.Auth_required.Signature ; call_data = Snark_params.Tick.Field.zero ; events = [] @@ -1881,22 +1888,23 @@ let%test_module "account timing check" = } in let open Async.Deferred.Let_syntax in - let%map update_timing_parties = + let%map update_timing_zkapp_command = Transaction_snark.For_tests.update_states ~constraint_constants update_timing_spec in let gen = Quickcheck.Generator.return - (ledger_init_state, update_timing_parties) + (ledger_init_state, update_timing_zkapp_command) in Async.Thread_safe.block_on_async_exn (fun () -> Async.Quickcheck.async_test ~seed: (`Deterministic "zkapp command, invalid update for timed account" ) - ~sexp_of:[%sexp_of: Mina_ledger.Ledger.init_state * Parties.t] + ~sexp_of: + [%sexp_of: Mina_ledger.Ledger.init_state * Zkapp_command.t] ~trials:1 gen - ~f:(fun (ledger_init_state, update_timing_parties) -> + ~f:(fun (ledger_init_state, update_timing_zkapp_command) -> let ledger = Mina_ledger.Ledger.create ~depth:constraint_constants.ledger_depth () @@ -1904,9 +1912,10 @@ let%test_module "account timing check" = Mina_ledger.Ledger.apply_initial_ledger_state ledger ledger_init_state ; - Transaction_snark_tests.Util.check_parties_with_merges_exn + Transaction_snark_tests.Util + .check_zkapp_command_with_merges_exn ~expected_failure: Transaction_status.Failure .Update_not_permitted_timing_existing_account ledger - [ update_timing_parties ] ) ) ) + [ update_timing_zkapp_command ] ) ) ) end ) diff --git a/src/lib/transaction_snark/test/app_state/app_state.ml b/src/lib/transaction_snark/test/app_state/app_state.ml index 2a5fd1726b7..b9b759f07bd 100644 --- a/src/lib/transaction_snark/test/app_state/app_state.ml +++ b/src/lib/transaction_snark/test/app_state/app_state.ml @@ -9,7 +9,7 @@ struct Mina_base.Transaction_status.Failure.Update_not_permitted_app_state let snapp_update = - { Party.Update.dummy with + { Account_update.Update.dummy with app_state = Vector.init Zkapp_state.Max_state_size.n ~f:(fun i -> Zkapp_basic.Set_or_keep.Set (Snark_params.Tick.Field.of_int i) ) diff --git a/src/lib/transaction_snark/test/delegate/delegate.ml b/src/lib/transaction_snark/test/delegate/delegate.ml index bdc63f5a084..f80c389ce7d 100644 --- a/src/lib/transaction_snark/test/delegate/delegate.ml +++ b/src/lib/transaction_snark/test/delegate/delegate.ml @@ -11,7 +11,9 @@ struct let pk = Async.Quickcheck.random_value Signature_lib.Public_key.Compressed.gen in - { Party.Update.dummy with delegate = Zkapp_basic.Set_or_keep.Set pk } + { Account_update.Update.dummy with + delegate = Zkapp_basic.Set_or_keep.Set pk + } end let%test_module "Update account delegate" = diff --git a/src/lib/transaction_snark/test/fee_payer/fee_payer.ml b/src/lib/transaction_snark/test/fee_payer/fee_payer.ml index a531f306dc8..d3046a50175 100644 --- a/src/lib/transaction_snark/test/fee_payer/fee_payer.ml +++ b/src/lib/transaction_snark/test/fee_payer/fee_payer.ml @@ -15,8 +15,8 @@ let%test_module "Fee payer tests" = let constraint_constants = U.constraint_constants - let snapp_update : Party.Update.t = - { Party.Update.dummy with + let snapp_update : Account_update.Update.t = + { Account_update.Update.dummy with app_state = Pickles_types.Vector.init Zkapp_state.Max_state_size.n ~f:(fun i -> Zkapp_basic.Set_or_keep.Set (Pickles.Backend.Tick.Field.of_int i) ) @@ -160,7 +160,7 @@ let%test_module "Fee payer tests" = ; preconditions = None } in - let parties = + let zkapp_command = Transaction_snark.For_tests.deploy_snapp test_spec ~constraint_constants in @@ -171,7 +171,7 @@ let%test_module "Fee payer tests" = Ledger.apply_transaction ledger0 ~constraint_constants ~txn_state_view: (Mina_state.Protocol_state.Body.view U.genesis_state_body) - (Transaction.Command (Parties parties)) + (Transaction.Command (Zkapp_command zkapp_command)) with | Error _ -> (*TODO : match on exact error*) () @@ -180,14 +180,14 @@ let%test_module "Fee payer tests" = (*Sparse ledger application fails*) match Or_error.try_with (fun () -> - Transaction_snark.parties_witnesses_exn + Transaction_snark.zkapp_command_witnesses_exn ~constraint_constants ~state_body:U.genesis_state_body ~fee_excess:Amount.Signed.zero (`Ledger ledger) [ ( `Pending_coinbase_init_stack U.init_stack , `Pending_coinbase_of_statement (U.pending_coinbase_state_stack ~state_body_hash:U.genesis_state_body_hash ) - , parties ) + , zkapp_command ) ] ) with | Ok _a -> diff --git a/src/lib/transaction_snark/test/multisig_account/multisig_account.ml b/src/lib/transaction_snark/test/multisig_account/multisig_account.ml index fad89703402..7e454477674 100644 --- a/src/lib/transaction_snark/test/multisig_account/multisig_account.ml +++ b/src/lib/transaction_snark/test/multisig_account/multisig_account.ml @@ -310,10 +310,10 @@ let%test_module "multisig_account" = let permissions = Zkapp_basic.Set_or_keep.Set Permissions.empty in - { Party.Update.noop with permissions } + { Account_update.Update.noop with permissions } in let sender_pk = sender.public_key |> Public_key.compress in - let fee_payer : Party.Fee_payer.t = + let fee_payer : Account_update.Fee_payer.t = { body = { public_key = sender_pk ; fee @@ -324,10 +324,10 @@ let%test_module "multisig_account" = ; authorization = Signature.dummy } in - let sender_party_data : Party.Simple.t = + let sender_account_update_data : Account_update.Simple.t = { body = { public_key = sender_pk - ; update = Party.Update.noop + ; update = Account_update.Update.noop ; token_id = Token_id.default ; balance_change = Currency.Amount.(Signed.(negate (of_unsigned amount))) @@ -337,7 +337,7 @@ let%test_module "multisig_account" = ; call_data = Field.zero ; call_depth = 0 ; preconditions = - { Party.Preconditions.network = + { Account_update.Preconditions.network = Zkapp_precondition.Protocol_state.accept ; account = Nonce (Account.Nonce.succ sender_nonce) } @@ -347,7 +347,7 @@ let%test_module "multisig_account" = ; authorization = Signature Signature.dummy } in - let snapp_party_data : Party.Simple.t = + let snapp_account_update_data : Account_update.Simple.t = { body = { public_key = multisig_account_pk ; update = update_empty_permissions @@ -360,7 +360,7 @@ let%test_module "multisig_account" = ; call_data = Field.zero ; call_depth = 0 ; preconditions = - { Party.Preconditions.network = + { Account_update.Preconditions.network = Zkapp_precondition.Protocol_state.accept ; account = Full Zkapp_precondition.Account.accept } @@ -372,24 +372,26 @@ let%test_module "multisig_account" = in let memo = Signed_command_memo.empty in let ps = - Parties.Call_forest.of_parties_list - ~party_depth:(fun (p : Party.Simple.t) -> p.body.call_depth) - [ sender_party_data; snapp_party_data ] - |> Parties.Call_forest.add_callers_simple - |> Parties.Call_forest.accumulate_hashes_predicated + Zkapp_command.Call_forest.of_zkapp_command_list + ~account_update_depth:(fun (p : Account_update.Simple.t) -> + p.body.call_depth ) + [ sender_account_update_data; snapp_account_update_data ] + |> Zkapp_command.Call_forest.add_callers_simple + |> Zkapp_command.Call_forest.accumulate_hashes_predicated in - let other_parties_hash = Parties.Call_forest.hash ps in - let transaction : Parties.Transaction_commitment.t = + let account_updates_hash = Zkapp_command.Call_forest.hash ps in + let transaction : Zkapp_command.Transaction_commitment.t = (*FIXME: is this correct? *) - Parties.Transaction_commitment.create ~other_parties_hash + Zkapp_command.Transaction_commitment.create + ~account_updates_hash in let tx_statement : Zkapp_statement.t = - { party = - Party.Body.digest - (Parties.add_caller_simple snapp_party_data + { account_update = + Account_update.Body.digest + (Zkapp_command.add_caller_simple snapp_account_update_data Token_id.default ) .body - ; calls = (Parties.Digest.Forest.empty :> field) + ; calls = (Zkapp_command.Digest.Forest.empty :> field) } in let msg = @@ -423,11 +425,12 @@ let%test_module "multisig_account" = in let fee_payer = let txn_comm = - Parties.Transaction_commitment.create_complete transaction + Zkapp_command.Transaction_commitment.create_complete + transaction ~memo_hash:(Signed_command_memo.hash memo) ~fee_payer_hash: - (Parties.Digest.Party.create - (Party.of_fee_payer fee_payer) ) + (Zkapp_command.Digest.Account_update.create + (Account_update.of_fee_payer fee_payer) ) in { fee_payer with authorization = @@ -435,20 +438,20 @@ let%test_module "multisig_account" = (Random_oracle.Input.Chunked.field txn_comm) } in - let sender : Party.Simple.t = - { body = sender_party_data.body + let sender : Account_update.Simple.t = + { body = sender_account_update_data.body ; authorization = Signature (Signature_lib.Schnorr.Chunked.sign sender.private_key (Random_oracle.Input.Chunked.field transaction) ) } in - let parties : Parties.t = - Parties.of_simple + let zkapp_command : Zkapp_command.t = + Zkapp_command.of_simple { fee_payer - ; other_parties = + ; account_updates = [ sender - ; { body = snapp_party_data.body + ; { body = snapp_account_update_data.body ; authorization = Proof pi } ] @@ -456,5 +459,7 @@ let%test_module "multisig_account" = } in Init_ledger.init (module Ledger.Ledger_inner) init_ledger ledger ; - ignore (U.apply_parties ledger [ parties ] : Sparse_ledger.t) ) ) + ignore + ( U.apply_zkapp_command ledger [ zkapp_command ] + : Sparse_ledger.t ) ) ) end ) diff --git a/src/lib/transaction_snark/test/party_preconditions/dune b/src/lib/transaction_snark/test/party_preconditions/dune index 85e4eff5010..44d829011ab 100644 --- a/src/lib/transaction_snark/test/party_preconditions/dune +++ b/src/lib/transaction_snark/test/party_preconditions/dune @@ -1,5 +1,5 @@ (library - (name party_precondition_tests) + (name account_update_precondition_tests) (libraries ;; opam libraries ppx_inline_test.config diff --git a/src/lib/transaction_snark/test/party_preconditions/party_preconditions.ml b/src/lib/transaction_snark/test/party_preconditions/party_preconditions.ml index c42e28507eb..6cba4eb552f 100644 --- a/src/lib/transaction_snark/test/party_preconditions/party_preconditions.ml +++ b/src/lib/transaction_snark/test/party_preconditions/party_preconditions.ml @@ -14,8 +14,8 @@ let%test_module "Protocol state precondition tests" = let memo = Signed_command_memo.create_from_string_exn "protocol state precondition" - let snapp_update : Party.Update.t = - { Party.Update.dummy with + let snapp_update : Account_update.Update.t = + { Account_update.Update.dummy with app_state = Pickles_types.Vector.init Zkapp_state.Max_state_size.n ~f:(fun i -> Zkapp_basic.Set_or_keep.Set (Pickles.Backend.Tick.Field.of_int i) ) @@ -79,10 +79,10 @@ let%test_module "Protocol state precondition tests" = ; sequence_events = [] ; preconditions = Some - { Party.Preconditions.network = + { Account_update.Preconditions.network = precondition_exact (Mina_state.Protocol_state.Body.view state_body) - ; account = Party.Account_precondition.Accept + ; account = Account_update.Account_precondition.Accept } } in @@ -96,7 +96,8 @@ let%test_module "Protocol state precondition tests" = let open Quickcheck.Generator.Let_syntax in let%bind ledger = U.gen_snapp_ledger in let%map network_precondition = - Mina_generators.Parties_generators.gen_protocol_state_precondition + Mina_generators.Zkapp_command_generators + .gen_protocol_state_precondition (Mina_state.Protocol_state.Body.view state_body) in (ledger, network_precondition) @@ -122,8 +123,8 @@ let%test_module "Protocol state precondition tests" = ; sequence_events = [] ; preconditions = Some - { Party.Preconditions.network = network_precondition - ; account = Party.Account_precondition.Accept + { Account_update.Preconditions.network = network_precondition + ; account = Account_update.Account_precondition.Accept } } in @@ -131,14 +132,15 @@ let%test_module "Protocol state precondition tests" = ~zkapp_prover ~snapp_pk:(Public_key.compress new_kp.public_key) ) - let%test_unit "invalid protocol state predicate in other parties" = + let%test_unit "invalid protocol state predicate in other zkapp_command" = let state_body = U.genesis_state_body in let psv = Mina_state.Protocol_state.Body.view state_body in let gen = let open Quickcheck.Let_syntax in let%bind ledger = U.gen_snapp_ledger in let%map network_precondition = - Mina_generators.Parties_generators.gen_protocol_state_precondition psv + Mina_generators.Zkapp_command_generators + .gen_protocol_state_precondition psv in (ledger, network_precondition) in @@ -169,7 +171,7 @@ let%test_module "Protocol state precondition tests" = Signature_lib.Public_key.compress new_kp.public_key in let fee_payer = - { Party.Fee_payer.body = + { Account_update.Fee_payer.body = { public_key = sender_pk ; fee ; valid_until = None @@ -179,10 +181,10 @@ let%test_module "Protocol state precondition tests" = ; authorization = Signature.dummy } in - let sender_party : Party.Simple.t = + let sender_account_update : Account_update.Simple.t = { body = { public_key = sender_pk - ; update = Party.Update.noop + ; update = Account_update.Update.noop ; token_id = Token_id.default ; balance_change = Amount.(Signed.(negate (of_unsigned amount))) @@ -192,7 +194,7 @@ let%test_module "Protocol state precondition tests" = ; call_data = Snark_params.Tick.Field.zero ; call_depth = 0 ; preconditions = - { Party.Preconditions.network = + { Account_update.Preconditions.network = invalid_network_precondition ; account = Nonce (Account.Nonce.succ sender_nonce) } @@ -203,7 +205,7 @@ let%test_module "Protocol state precondition tests" = ; authorization = Control.Signature Signature.dummy } in - let snapp_party : Party.Simple.t = + let snapp_account_update : Account_update.Simple.t = { body = { public_key = snapp_pk ; update = snapp_update @@ -222,9 +224,10 @@ let%test_module "Protocol state precondition tests" = ; call_data = Snark_params.Tick.Field.zero ; call_depth = 0 ; preconditions = - { Party.Preconditions.network = + { Account_update.Preconditions.network = invalid_network_precondition - ; account = Party.Account_precondition.Accept + ; account = + Account_update.Account_precondition.Accept } ; use_full_commitment = true ; caller = Call @@ -235,20 +238,25 @@ let%test_module "Protocol state precondition tests" = } in let ps = - Parties.Call_forest.With_hashes.of_parties_simple_list - [ sender_party; snapp_party ] + Zkapp_command.Call_forest.With_hashes + .of_zkapp_command_simple_list + [ sender_account_update; snapp_account_update ] + in + let account_updates_hash = + Zkapp_command.Call_forest.hash ps in - let other_parties_hash = Parties.Call_forest.hash ps in let commitment = - Parties.Transaction_commitment.create ~other_parties_hash + Zkapp_command.Transaction_commitment.create + ~account_updates_hash in let memo_hash = Signed_command_memo.hash memo in let fee_payer_hash = - Parties.Digest.Party.create (Party.of_fee_payer fee_payer) + Zkapp_command.Digest.Account_update.create + (Account_update.of_fee_payer fee_payer) in let full_commitment = - Parties.Transaction_commitment.create_complete commitment - ~memo_hash ~fee_payer_hash + Zkapp_command.Transaction_commitment.create_complete + commitment ~memo_hash ~fee_payer_hash in let fee_payer = let fee_payer_signature_auth = @@ -257,40 +265,41 @@ let%test_module "Protocol state precondition tests" = in { fee_payer with authorization = fee_payer_signature_auth } in - let sender_party : Party.Simple.t = + let sender_account_update : Account_update.Simple.t = let signature_auth : Signature.t = Signature_lib.Schnorr.Chunked.sign sender.private_key (Random_oracle.Input.Chunked.field commitment) in - { sender_party with + { sender_account_update with authorization = Control.Signature signature_auth } in - let snapp_party = + let snapp_account_update = let signature_auth = Signature_lib.Schnorr.Chunked.sign new_kp.private_key (Random_oracle.Input.Chunked.field full_commitment) in - { snapp_party with + { snapp_account_update with authorization = Control.Signature signature_auth } in - let parties_with_valid_fee_payer = + let zkapp_command_with_valid_fee_payer = { fee_payer ; memo - ; other_parties = [ sender_party; snapp_party ] + ; account_updates = + [ sender_account_update; snapp_account_update ] } - |> Parties.of_simple + |> Zkapp_command.of_simple in Mina_transaction_logic.For_tests.Init_ledger.init (module Mina_ledger.Ledger.Ledger_inner) init_ledger ledger ; - U.check_parties_with_merges_exn + U.check_zkapp_command_with_merges_exn ~expected_failure: Transaction_status.Failure .Protocol_state_precondition_unsatisfied ~state_body ledger - [ parties_with_valid_fee_payer ] ) ) ) + [ zkapp_command_with_valid_fee_payer ] ) ) ) end ) let%test_module "Account precondition tests" = @@ -301,8 +310,8 @@ let%test_module "Account precondition tests" = let memo = Signed_command_memo.create_from_string_exn "account precondition" - let snapp_update : Party.Update.t = - { Party.Update.dummy with + let snapp_update : Account_update.Update.t = + { Account_update.Update.dummy with app_state = Pickles_types.Vector.init Zkapp_state.Max_state_size.n ~f:(fun i -> Zkapp_basic.Set_or_keep.Set (Pickles.Backend.Tick.Field.of_int i) ) @@ -374,7 +383,7 @@ let%test_module "Account precondition tests" = ; is_new } in - Party.Account_precondition.Full predicate_account + Account_update.Account_precondition.Full predicate_account let%test_unit "exact account predicate" = Quickcheck.test ~trials:1 U.gen_snapp_ledger @@ -408,7 +417,7 @@ let%test_module "Account precondition tests" = ; sequence_events = [] ; preconditions = Some - { Party.Preconditions.network = + { Account_update.Preconditions.network = Zkapp_precondition.Protocol_state.accept ; account = precondition_exact snapp_account } @@ -421,11 +430,12 @@ let%test_module "Account precondition tests" = Transaction_snark.For_tests.create_trivial_zkapp_account ~vk ~ledger snapp_pk ; let open Async.Deferred.Let_syntax in - let%bind parties = + let%bind zkapp_command = Transaction_snark.For_tests.update_states ~zkapp_prover ~constraint_constants test_spec in - U.check_parties_with_merges_exn ~state_body ledger [ parties ] ) ) ) + U.check_zkapp_command_with_merges_exn ~state_body ledger + [ zkapp_command ] ) ) ) let%test_unit "generated account precondition" = let gen = @@ -436,7 +446,7 @@ let%test_module "Account precondition tests" = Transaction_snark.For_tests.trivial_zkapp_account ~vk snapp_pk in let%map account_precondition = - Mina_generators.Parties_generators + Mina_generators.Zkapp_command_generators .gen_account_precondition_from_account snapp_account ~first_use_of_account:true in @@ -476,19 +486,20 @@ let%test_module "Account precondition tests" = ; sequence_events = [] ; preconditions = Some - { Party.Preconditions.network = + { Account_update.Preconditions.network = Zkapp_precondition.Protocol_state.accept ; account = account_precondition } } in - let%bind parties = + let%bind zkapp_command = Transaction_snark.For_tests.update_states ~zkapp_prover ~constraint_constants test_spec in - U.check_parties_with_merges_exn ~state_body ledger [ parties ] ) ) ) + U.check_zkapp_command_with_merges_exn ~state_body ledger + [ zkapp_command ] ) ) ) - let%test_unit "invalid account predicate in other parties" = + let%test_unit "invalid account predicate in other zkapp_command" = let state_body = U.genesis_state_body in let gen = let open Quickcheck.Generator.Let_syntax in @@ -498,7 +509,7 @@ let%test_module "Account precondition tests" = Transaction_snark.For_tests.trivial_zkapp_account ~vk snapp_pk in let%map account_precondition = - Mina_generators.Parties_generators.( + Mina_generators.Zkapp_command_generators.( gen_account_precondition_from_account ~first_use_of_account:true ~failure:Invalid_account_precondition snapp_account) in @@ -527,14 +538,14 @@ let%test_module "Account precondition tests" = ; sequence_events = [] ; preconditions = Some - { Party.Preconditions.network = + { Account_update.Preconditions.network = Zkapp_precondition.Protocol_state.accept ; account = account_precondition } } in let open Async.Deferred.Let_syntax in - let%bind parties = + let%bind zkapp_command = Transaction_snark.For_tests.update_states ~zkapp_prover ~constraint_constants test_spec in @@ -547,11 +558,11 @@ let%test_module "Account precondition tests" = in Transaction_snark.For_tests.create_trivial_zkapp_account ~vk ~ledger snapp_pk ; - U.check_parties_with_merges_exn + U.check_zkapp_command_with_merges_exn ~expected_failure: Transaction_status.Failure .Account_nonce_precondition_unsatisfied ~state_body ledger - [ parties ] ) ) ) + [ zkapp_command ] ) ) ) let%test_unit "invalid account predicate in fee payer" = let state_body = U.genesis_state_body in @@ -570,7 +581,7 @@ let%test_module "Account precondition tests" = Signature_lib.Public_key.compress new_kp.public_key in let fee_payer = - { Party.Fee_payer.body = + { Account_update.Fee_payer.body = { public_key = sender_pk ; fee ; valid_until = None @@ -580,10 +591,10 @@ let%test_module "Account precondition tests" = ; authorization = Signature.dummy } in - let sender_party : Party.Simple.t = + let sender_account_update : Account_update.Simple.t = { body = { public_key = sender_pk - ; update = Party.Update.noop + ; update = Account_update.Update.noop ; token_id = Token_id.default ; balance_change = Amount.(Signed.(negate (of_unsigned amount))) @@ -593,7 +604,7 @@ let%test_module "Account precondition tests" = ; call_data = Snark_params.Tick.Field.zero ; call_depth = 0 ; preconditions = - { Party.Preconditions.network = + { Account_update.Preconditions.network = Zkapp_precondition.Protocol_state.accept ; account = Nonce (Account.Nonce.succ sender_nonce) } @@ -604,7 +615,7 @@ let%test_module "Account precondition tests" = ; authorization = Control.Signature Signature.dummy } in - let snapp_party : Party.Simple.t = + let snapp_account_update : Account_update.Simple.t = { body = { public_key = snapp_pk ; update = snapp_update @@ -621,9 +632,9 @@ let%test_module "Account precondition tests" = ; call_data = Snark_params.Tick.Field.zero ; call_depth = 0 ; preconditions = - { Party.Preconditions.network = + { Account_update.Preconditions.network = Zkapp_precondition.Protocol_state.accept - ; account = Party.Account_precondition.Accept + ; account = Account_update.Account_precondition.Accept } ; use_full_commitment = true ; caller = Call @@ -633,19 +644,22 @@ let%test_module "Account precondition tests" = } in let ps = - Parties.Call_forest.With_hashes.of_parties_simple_list - [ sender_party; snapp_party ] + Zkapp_command.Call_forest.With_hashes + .of_zkapp_command_simple_list + [ sender_account_update; snapp_account_update ] in - let other_parties_hash = Parties.Call_forest.hash ps in + let account_updates_hash = Zkapp_command.Call_forest.hash ps in let commitment = - Parties.Transaction_commitment.create ~other_parties_hash + Zkapp_command.Transaction_commitment.create + ~account_updates_hash in let memo_hash = Signed_command_memo.hash memo in let fee_payer_hash = - Parties.Digest.Party.create (Party.of_fee_payer fee_payer) + Zkapp_command.Digest.Account_update.create + (Account_update.of_fee_payer fee_payer) in let full_commitment = - Parties.Transaction_commitment.create_complete commitment + Zkapp_command.Transaction_commitment.create_complete commitment ~memo_hash ~fee_payer_hash in let fee_payer = @@ -655,37 +669,39 @@ let%test_module "Account precondition tests" = in { fee_payer with authorization = fee_payer_signature_auth } in - let sender_party = + let sender_account_update = let signature_auth : Signature.t = Signature_lib.Schnorr.Chunked.sign sender.private_key (Random_oracle.Input.Chunked.field commitment) in - { sender_party with + { sender_account_update with authorization = Control.Signature signature_auth } in - let snapp_party = + let snapp_account_update = let signature_auth = Signature_lib.Schnorr.Chunked.sign new_kp.private_key (Random_oracle.Input.Chunked.field full_commitment) in - { snapp_party with + { snapp_account_update with authorization = Control.Signature signature_auth } in - let parties_with_invalid_fee_payer = - Parties.of_simple + let zkapp_command_with_invalid_fee_payer = + Zkapp_command.of_simple { fee_payer ; memo - ; other_parties = [ sender_party; snapp_party ] + ; account_updates = + [ sender_account_update; snapp_account_update ] } in Mina_transaction_logic.For_tests.Init_ledger.init (module Mina_ledger.Ledger.Ledger_inner) init_ledger ledger ; match - Mina_ledger.Ledger.apply_parties_unchecked ~constraint_constants - ~state_view:psv ledger parties_with_invalid_fee_payer + Mina_ledger.Ledger.apply_zkapp_command_unchecked + ~constraint_constants ~state_view:psv ledger + zkapp_command_with_invalid_fee_payer with | Error e -> assert ( diff --git a/src/lib/transaction_snark/test/permissions/permissions.ml b/src/lib/transaction_snark/test/permissions/permissions.ml index 71434a8eba4..4dae3fe157c 100644 --- a/src/lib/transaction_snark/test/permissions/permissions.ml +++ b/src/lib/transaction_snark/test/permissions/permissions.ml @@ -8,7 +8,7 @@ struct Mina_base.Transaction_status.Failure.Update_not_permitted_permissions let snapp_update = - { Party.Update.dummy with + { Account_update.Update.dummy with permissions = Zkapp_basic.Set_or_keep.Set { Permissions.user_default with diff --git a/src/lib/transaction_snark/test/ring_sig.ml b/src/lib/transaction_snark/test/ring_sig.ml index ea8502741a0..83be394319e 100644 --- a/src/lib/transaction_snark/test/ring_sig.ml +++ b/src/lib/transaction_snark/test/ring_sig.ml @@ -7,7 +7,7 @@ module Impl = Pickles.Impls.Step module Inner_curve = Snark_params.Tick.Inner_curve module Nat = Pickles_types.Nat module Local_state = Mina_state.Local_state -module Parties_segment = Transaction_snark.Parties_segment +module Zkapp_command_segment = Transaction_snark.Zkapp_command_segment module Statement = Transaction_snark.Statement open Snark_params.Tick open Snark_params.Tick.Let_syntax @@ -98,8 +98,8 @@ let%test_unit "1-of-2" = |> Checked.map ~f:As_prover.return |> run_and_check |> Or_error.ok_exn ) -(* test a snapp tx with a 3-party ring *) -let%test_unit "ring-signature snapp tx with 3 parties" = +(* test a snapp tx with a 3-account_update ring *) +let%test_unit "ring-signature snapp tx with 3 zkapp_command" = let open Mina_transaction_logic.For_tests in let gen = let open Quickcheck.Generator.Let_syntax in @@ -111,7 +111,7 @@ let%test_unit "ring-signature snapp tx with 3 parties" = and test_spec = Test_spec.gen in (ring_member_sks, sign_index, test_spec) in - (* set to true to print vk, parties *) + (* set to true to print vk, zkapp_command *) let debug_mode : bool = false in Quickcheck.test ~trials:1 gen ~f:(fun (ring_member_sks, sign_index, { init_ledger; specs }) -> @@ -175,8 +175,8 @@ let%test_unit "ring-signature snapp tx with 3 parties" = } } ) ; let sender_pk = sender.public_key |> Public_key.compress in - let fee_payer : Party.Fee_payer.t = - { Party.Fee_payer.body = + let fee_payer : Account_update.Fee_payer.t = + { Account_update.Fee_payer.body = { public_key = sender_pk ; fee = Amount.to_fee fee ; valid_until = None @@ -186,10 +186,10 @@ let%test_unit "ring-signature snapp tx with 3 parties" = ; authorization = Signature.dummy } in - let sender_party_data : Party.Simple.t = + let sender_account_update_data : Account_update.Simple.t = { body = { public_key = sender_pk - ; update = Party.Update.noop + ; update = Account_update.Update.noop ; token_id = Token_id.default ; balance_change = Amount.(Signed.(negate (of_unsigned amount))) ; increment_nonce = true @@ -198,7 +198,7 @@ let%test_unit "ring-signature snapp tx with 3 parties" = ; call_data = Field.zero ; call_depth = 0 ; preconditions = - { Party.Preconditions.network = + { Account_update.Preconditions.network = Zkapp_precondition.Protocol_state.accept ; account = Nonce (Account.Nonce.succ sender_nonce) } @@ -208,10 +208,10 @@ let%test_unit "ring-signature snapp tx with 3 parties" = ; authorization = Signature Signature.dummy } in - let snapp_party_data : Party.Simple.t = + let snapp_account_update_data : Account_update.Simple.t = { body = { public_key = ringsig_account_pk - ; update = Party.Update.noop + ; update = Account_update.Update.noop ; token_id = Token_id.default ; balance_change = Amount.Signed.(of_unsigned amount) ; events = [] @@ -220,7 +220,7 @@ let%test_unit "ring-signature snapp tx with 3 parties" = ; call_depth = 0 ; increment_nonce = false ; preconditions = - { Party.Preconditions.network = + { Account_update.Preconditions.network = Zkapp_precondition.Protocol_state.accept ; account = Full Zkapp_precondition.Account.accept } @@ -232,21 +232,22 @@ let%test_unit "ring-signature snapp tx with 3 parties" = in let protocol_state = Zkapp_precondition.Protocol_state.accept in let ps = - Parties.Call_forest.With_hashes.of_parties_simple_list - [ sender_party_data; snapp_party_data ] + Zkapp_command.Call_forest.With_hashes.of_zkapp_command_simple_list + [ sender_account_update_data; snapp_account_update_data ] in - let other_parties_hash = Parties.Call_forest.hash ps in + let account_updates_hash = Zkapp_command.Call_forest.hash ps in let memo = Signed_command_memo.empty in let memo_hash = Signed_command_memo.hash memo in - let transaction : Parties.Transaction_commitment.t = - Parties.Transaction_commitment.create ~other_parties_hash + let transaction : Zkapp_command.Transaction_commitment.t = + Zkapp_command.Transaction_commitment.create ~account_updates_hash in let tx_statement : Zkapp_statement.t = - { party = - Party.Body.digest - (Parties.add_caller_simple snapp_party_data Token_id.default) + { account_update = + Account_update.Body.digest + (Zkapp_command.add_caller_simple snapp_account_update_data + Token_id.default ) .body - ; calls = (Parties.Digest.Forest.empty :> field) + ; calls = (Zkapp_command.Digest.Forest.empty :> field) } in let msg = @@ -268,10 +269,11 @@ let%test_unit "ring-signature snapp tx with 3 parties" = in let fee_payer = let txn_comm = - Parties.Transaction_commitment.create_complete transaction + Zkapp_command.Transaction_commitment.create_complete transaction ~memo_hash ~fee_payer_hash: - (Parties.Digest.Party.create (Party.of_fee_payer fee_payer)) + (Zkapp_command.Digest.Account_update.create + (Account_update.of_fee_payer fee_payer) ) in { fee_payer with authorization = @@ -279,46 +281,48 @@ let%test_unit "ring-signature snapp tx with 3 parties" = (Random_oracle.Input.Chunked.field txn_comm) } in - let sender : Party.Simple.t = + let sender : Account_update.Simple.t = let sender_signature = Signature_lib.Schnorr.Chunked.sign sender.private_key (Random_oracle.Input.Chunked.field transaction) in - { body = sender_party_data.body + { body = sender_account_update_data.body ; authorization = Signature sender_signature } in - let parties : Parties.t = - Parties.of_simple + let zkapp_command : Zkapp_command.t = + Zkapp_command.of_simple { fee_payer - ; other_parties = + ; account_updates = [ sender - ; { body = snapp_party_data.body; authorization = Proof pi } + ; { body = snapp_account_update_data.body + ; authorization = Proof pi + } ] ; memo } in ( if debug_mode then (* print fee payer *) - Party.Fee_payer.to_yojson fee_payer + Account_update.Fee_payer.to_yojson fee_payer |> Yojson.Safe.pretty_to_string |> printf "fee_payer:\n%s\n\n" |> fun () -> - (* print other_party data *) - Parties.Call_forest.iteri parties.other_parties - ~f:(fun idx (p : Party.t) -> - Party.Body.to_yojson p.body + (* print other_account_update data *) + Zkapp_command.Call_forest.iteri zkapp_command.account_updates + ~f:(fun idx (p : Account_update.t) -> + Account_update.Body.to_yojson p.body |> Yojson.Safe.pretty_to_string - |> printf "other_party #%d body:\n%s\n\n" idx ) + |> printf "other_account_update #%d body:\n%s\n\n" idx ) |> fun () -> - (* print other_party proof *) + (* print other_account_update proof *) Pickles.Side_loaded.Proof.Stable.V2.sexp_of_t pi |> Sexp.to_string |> Base64.encode_exn - |> printf "other_party_proof:\n%s\n\n" + |> printf "other_account_update_proof:\n%s\n\n" |> fun () -> (* print protocol_state *) Zkapp_precondition.Protocol_state.to_yojson protocol_state |> Yojson.Safe.pretty_to_string |> printf "protocol_state:\n%s\n\n" ) |> fun () -> - ignore (apply_parties ledger [ parties ] : Sparse_ledger.t) ) ) + ignore (apply_zkapp_command ledger [ zkapp_command ] : Sparse_ledger.t) ) ) diff --git a/src/lib/transaction_snark/test/test_zkapp_update.ml b/src/lib/transaction_snark/test/test_zkapp_update.ml index f945e355130..1a0f6a8a1bf 100644 --- a/src/lib/transaction_snark/test/test_zkapp_update.ml +++ b/src/lib/transaction_snark/test/test_zkapp_update.ml @@ -7,8 +7,8 @@ module Spec = Transaction_snark.For_tests.Spec open Mina_base module type Input_intf = sig - (*Spec for all the updates to generate a parties transaction*) - val snapp_update : Party.Update.t + (*Spec for all the updates to generate a zkapp_command transaction*) + val snapp_update : Account_update.Update.t val test_description : string diff --git a/src/lib/transaction_snark/test/token_symbol/token_symbol.ml b/src/lib/transaction_snark/test/token_symbol/token_symbol.ml index 569ca9c42f3..8011e2d6b65 100644 --- a/src/lib/transaction_snark/test/token_symbol/token_symbol.ml +++ b/src/lib/transaction_snark/test/token_symbol/token_symbol.ml @@ -8,7 +8,7 @@ struct Mina_base.Transaction_status.Failure.Update_not_permitted_token_symbol let snapp_update = - { Party.Update.dummy with + { Account_update.Update.dummy with token_symbol = Zkapp_basic.Set_or_keep.Set "Zoozoo" } end diff --git a/src/lib/transaction_snark/test/transaction_union/transaction_union.ml b/src/lib/transaction_snark/test/transaction_union/transaction_union.ml index 85f1085e65a..ce4f6aa5b5d 100644 --- a/src/lib/transaction_snark/test/transaction_union/transaction_union.ml +++ b/src/lib/transaction_snark/test/transaction_union/transaction_union.ml @@ -625,7 +625,7 @@ let%test_module "Transaction union tests" = let sub_fee fee = sub_amount (Amount.of_fee fee) - (*TODO: test with parties transactions + (*TODO: test with zkapp_command transactions let%test_unit "transfer non-default tokens to a new account: fails but \ charges fee" = Test_util.with_randomness 123456789 (fun () -> diff --git a/src/lib/transaction_snark/test/util.ml b/src/lib/transaction_snark/test/util.ml index c7d2d047a04..d31c60b12b7 100644 --- a/src/lib/transaction_snark/test/util.ml +++ b/src/lib/transaction_snark/test/util.ml @@ -4,7 +4,7 @@ open Mina_base open Signature_lib module Tick = Snark_params.Tick module Impl = Pickles.Impls.Step -module Parties_segment = Transaction_snark.Parties_segment +module Zkapp_command_segment = Transaction_snark.Zkapp_command_segment module Statement = Transaction_snark.Statement let constraint_constants = Genesis_constants.Constraint_constants.compiled @@ -62,9 +62,9 @@ let pending_coinbase_state_stack ~state_body_hash = ; target = Pending_coinbase.Stack.push_state state_body_hash init_stack } -let apply_parties ledger parties = - let parties = - match parties with +let apply_zkapp_command ledger zkapp_command = + let zkapp_command = + match zkapp_command with | [] -> [] | [ ps ] -> @@ -97,9 +97,9 @@ let apply_parties ledger parties = ps1 :: ps2 :: List.map rest ~f:unchanged_stack_state in let witnesses, final_ledger = - Transaction_snark.parties_witnesses_exn ~constraint_constants + Transaction_snark.zkapp_command_witnesses_exn ~constraint_constants ~state_body:genesis_state_body ~fee_excess:Amount.Signed.zero - (`Ledger ledger) parties + (`Ledger ledger) zkapp_command in let open Impl in List.iter (List.rev witnesses) ~f:(fun (witness, spec, statement) -> @@ -108,8 +108,9 @@ let apply_parties ledger parties = exists Statement.With_sok.typ ~compute:(fun () -> statement) in let _opt_snapp_stmt = - Transaction_snark.Base.Parties_snark.main ~constraint_constants - (Parties_segment.Basic.to_single_list spec) + Transaction_snark.Base.Zkapp_command_snark.main + ~constraint_constants + (Zkapp_command_segment.Basic.to_single_list spec) s ~witness in fun () -> () ) @@ -120,21 +121,21 @@ let trivial_zkapp = lazy (Transaction_snark.For_tests.create_trivial_snapp ~constraint_constants ()) -let check_parties_with_merges_exn ?expected_failure - ?(state_body = genesis_state_body) ledger partiess = +let check_zkapp_command_with_merges_exn ?expected_failure + ?(state_body = genesis_state_body) ledger zkapp_commands = let module T = (val Lazy.force snark_module) in (*TODO: merge multiple snapp transactions*) let state_view = Mina_state.Protocol_state.Body.view state_body in let state_body_hash = Mina_state.Protocol_state.Body.hash state_body in - Async.Deferred.List.iter partiess ~f:(fun parties -> + Async.Deferred.List.iter zkapp_commands ~f:(fun zkapp_command -> match Or_error.try_with (fun () -> - Transaction_snark.parties_witnesses_exn ~constraint_constants + Transaction_snark.zkapp_command_witnesses_exn ~constraint_constants ~state_body ~fee_excess:Amount.Signed.zero (`Ledger ledger) [ ( `Pending_coinbase_init_stack init_stack , `Pending_coinbase_of_statement (pending_coinbase_state_stack ~state_body_hash) - , parties ) + , zkapp_command ) ] ) with | Error e -> ( @@ -153,11 +154,12 @@ let check_parties_with_merges_exn ?expected_failure let applied = Ledger.apply_transaction ~constraint_constants ~txn_state_view:state_view ledger - (Mina_transaction.Transaction.Command (Parties parties)) + (Mina_transaction.Transaction.Command (Zkapp_command zkapp_command) + ) |> Or_error.ok_exn in match applied.varying with - | Command (Parties { command; _ }) -> ( + | Command (Zkapp_command { command; _ }) -> ( match command.status with | Applied -> ( match expected_failure with @@ -177,7 +179,7 @@ let check_parties_with_merges_exn ?expected_failure let open Async.Deferred.Or_error.Let_syntax in let%bind p1 = Async.Deferred.Or_error.try_with (fun () -> - T.of_parties_segment_exn ~statement:stmt + T.of_zkapp_command_segment_exn ~statement:stmt ~witness ~spec ) in Async.Deferred.List.fold ~init:(Ok p1) rest @@ -185,8 +187,8 @@ let check_parties_with_merges_exn ?expected_failure let%bind prev = Async.Deferred.return acc in let%bind curr = Async.Deferred.Or_error.try_with (fun () -> - T.of_parties_segment_exn ~statement:stmt - ~witness ~spec ) + T.of_zkapp_command_segment_exn + ~statement:stmt ~witness ~spec ) in let sok_digest = Sok_message.create ~fee:Fee.zero @@ -233,7 +235,7 @@ let check_parties_with_merges_exn ?expected_failure failure failure_tbl ) else Async.Deferred.unit ) ) | _ -> - failwith "parties expected" ) ) + failwith "zkapp_command expected" ) ) let dummy_rule self : _ Pickles.Inductive_rule.t = let open Tick in @@ -290,14 +292,14 @@ let test_snapp_update ?expected_failure ?state_body ?snapp_permissions ~vk Transaction_snark.For_tests.create_trivial_zkapp_account ?permissions:snapp_permissions ~vk ~ledger snapp_pk ; let open Async.Deferred.Let_syntax in - let%bind parties = + let%bind zkapp_command = Transaction_snark.For_tests.update_states ~zkapp_prover ~constraint_constants test_spec in - check_parties_with_merges_exn ?expected_failure ?state_body ledger - [ parties ] ) ) + check_zkapp_command_with_merges_exn ?expected_failure ?state_body + ledger [ zkapp_command ] ) ) -let permissions_from_update (update : Party.Update.t) ~auth = +let permissions_from_update (update : Account_update.Update.t) ~auth = let default = Permissions.user_default in { default with edit_state = @@ -428,8 +430,8 @@ let test_transaction_union ?expected_failure ?txn_global_slot ledger txn = `Transaction (Fee_transfer x) | Coinbase x -> `Transaction (Coinbase x) - | Command (Parties x) -> - `Parties x + | Command (Zkapp_command x) -> + `Zkapp_command x in let source = Ledger.merkle_root ledger in let pending_coinbase_stack = Pending_coinbase.Stack.empty in @@ -477,8 +479,8 @@ let test_transaction_union ?expected_failure ?txn_global_slot ledger txn = | Command (Signed_command uc) -> ( Signed_command.accounts_accessed (uc :> Signed_command.t) , pending_coinbase_stack ) - | Command (Parties _) -> - failwith "Parties commands not supported here" + | Command (Zkapp_command _) -> + failwith "Zkapp_command commands not supported here" | Fee_transfer ft -> (Fee_transfer.receivers ft, pending_coinbase_stack) | Coinbase cb -> @@ -489,8 +491,8 @@ let test_transaction_union ?expected_failure ?txn_global_slot ledger txn = match to_preunion txn_unchecked with | `Transaction t -> (Transaction_union.of_transaction t).signer |> Public_key.compress - | `Parties c -> - Account_id.public_key (Parties.fee_payer c) + | `Zkapp_command c -> + Account_id.public_key (Zkapp_command.fee_payer c) in let sparse_ledger = Sparse_ledger.of_ledger_subset_exn ledger mentioned_keys diff --git a/src/lib/transaction_snark/test/util.mli b/src/lib/transaction_snark/test/util.mli index 3fd7dedd2fc..a92fc728aaa 100644 --- a/src/lib/transaction_snark/test/util.mli +++ b/src/lib/transaction_snark/test/util.mli @@ -32,7 +32,7 @@ val pending_coinbase_state_stack : state_body_hash:State_hash.t -> Transaction_snark.Pending_coinbase_stack_state.t -val apply_parties : Ledger.t -> Parties.t list -> Sparse_ledger.t +val apply_zkapp_command : Ledger.t -> Zkapp_command.t list -> Sparse_ledger.t val dummy_rule : (Zkapp_statement.Checked.t, 'a, 'b, 'c) Pickles.Tag.t @@ -48,15 +48,15 @@ val dummy_rule : , unit ) Pickles.Inductive_rule.t -(** Generates base and merge snarks of all the party segments +(** Generates base and merge snarks of all the account_update segments Raises if either the snark generation or application fails *) -val check_parties_with_merges_exn : +val check_zkapp_command_with_merges_exn : ?expected_failure:Mina_base.Transaction_status.Failure.t -> ?state_body:Transaction_protocol_state.Block_data.t -> Ledger.t - -> Parties.t list + -> Zkapp_command.t list -> unit Async.Deferred.t (** Verification key of a trivial smart contract *) @@ -99,7 +99,7 @@ val test_snapp_update : -> unit val permissions_from_update : - Party.Update.t + Account_update.Update.t -> auth:Permissions.Auth_required.t -> Permissions.Auth_required.t Permissions.Poly.t diff --git a/src/lib/transaction_snark/test/verification_key/verification_key.ml b/src/lib/transaction_snark/test/verification_key/verification_key.ml index 3511d2a56cd..bd2e45d5f4d 100644 --- a/src/lib/transaction_snark/test/verification_key/verification_key.ml +++ b/src/lib/transaction_snark/test/verification_key/verification_key.ml @@ -8,14 +8,14 @@ struct let failure_expected = Mina_base.Transaction_status.Failure.Update_not_permitted_verification_key - let snapp_update : Party.Update.t = + let snapp_update : Account_update.Update.t = let new_verification_key : (Side_loaded.Verification_key.t, Zkapp_basic.F.t) With_hash.t = let data = Pickles.Side_loaded.Verification_key.dummy in let hash = Zkapp_account.dummy_vk_hash () in ({ data; hash } : _ With_hash.t) in - { Party.Update.dummy with + { Account_update.Update.dummy with verification_key = Zkapp_basic.Set_or_keep.Set new_verification_key } end diff --git a/src/lib/transaction_snark/test/voting_for/voting_for.ml b/src/lib/transaction_snark/test/voting_for/voting_for.ml index 55fe27b839b..bde5a8dcb18 100644 --- a/src/lib/transaction_snark/test/voting_for/voting_for.ml +++ b/src/lib/transaction_snark/test/voting_for/voting_for.ml @@ -7,8 +7,8 @@ struct let failure_expected = Mina_base.Transaction_status.Failure.Update_not_permitted_voting_for - let snapp_update : Party.Update.t = - { Party.Update.dummy with + let snapp_update : Account_update.Update.t = + { Account_update.Update.dummy with voting_for = Zkapp_basic.Set_or_keep.Set (Async.Quickcheck.random_value State_hash.gen) diff --git a/src/lib/transaction_snark/test/zkapp_deploy/zkapp_deploy.ml b/src/lib/transaction_snark/test/zkapp_deploy/zkapp_deploy.ml index 70a94b12b33..47815217985 100644 --- a/src/lib/transaction_snark/test/zkapp_deploy/zkapp_deploy.ml +++ b/src/lib/transaction_snark/test/zkapp_deploy/zkapp_deploy.ml @@ -28,7 +28,7 @@ let%test_module "Snapp deploy tests" = ; zkapp_account_keypairs = [ new_kp ] ; memo ; new_zkapp_account = true - ; snapp_update = Party.Update.dummy + ; snapp_update = Account_update.Update.dummy ; current_auth = Permissions.Auth_required.Signature ; call_data = Snark_params.Tick.Field.zero ; events = [] @@ -36,14 +36,14 @@ let%test_module "Snapp deploy tests" = ; preconditions = None } in - let parties = + let zkapp_command = Transaction_snark.For_tests.deploy_snapp test_spec ~constraint_constants in Init_ledger.init (module Ledger.Ledger_inner) init_ledger ledger ; - U.check_parties_with_merges_exn ledger [ parties ] ) ) ) + U.check_zkapp_command_with_merges_exn ledger [ zkapp_command ] ) ) ) let%test_unit "deploy multiple ZkApps" = let open Mina_transaction_logic.For_tests in @@ -70,7 +70,7 @@ let%test_module "Snapp deploy tests" = ; zkapp_account_keypairs = kps ; memo ; new_zkapp_account = true - ; snapp_update = Party.Update.dummy + ; snapp_update = Account_update.Update.dummy ; current_auth = Permissions.Auth_required.Signature ; call_data = Snark_params.Tick.Field.zero ; events = [] @@ -78,14 +78,14 @@ let%test_module "Snapp deploy tests" = ; preconditions = None } in - let parties = + let zkapp_command = Transaction_snark.For_tests.deploy_snapp test_spec ~constraint_constants in Init_ledger.init (module Ledger.Ledger_inner) init_ledger ledger ; - U.check_parties_with_merges_exn ledger [ parties ] ) ) ) + U.check_zkapp_command_with_merges_exn ledger [ zkapp_command ] ) ) ) let%test_unit "change a non-snapp account to snapp account/deploy a smart \ contract" = @@ -106,7 +106,7 @@ let%test_module "Snapp deploy tests" = ; zkapp_account_keypairs = [ fst spec.sender ] ; memo ; new_zkapp_account = false - ; snapp_update = Party.Update.dummy + ; snapp_update = Account_update.Update.dummy ; current_auth = Permissions.Auth_required.Signature ; call_data = Snark_params.Tick.Field.zero ; events = [] @@ -114,14 +114,14 @@ let%test_module "Snapp deploy tests" = ; preconditions = None } in - let parties = + let zkapp_command = Transaction_snark.For_tests.deploy_snapp test_spec ~constraint_constants in Init_ledger.init (module Ledger.Ledger_inner) init_ledger ledger ; - U.check_parties_with_merges_exn ledger [ parties ] ) ) ) + U.check_zkapp_command_with_merges_exn ledger [ zkapp_command ] ) ) ) let%test_unit "change a non-snapp account to snapp account/deploy a smart \ contract- different fee payer" = @@ -143,7 +143,7 @@ let%test_module "Snapp deploy tests" = ; zkapp_account_keypairs = [ fst spec1.sender ] ; memo ; new_zkapp_account = false - ; snapp_update = Party.Update.dummy + ; snapp_update = Account_update.Update.dummy ; current_auth = Permissions.Auth_required.Signature ; call_data = Snark_params.Tick.Field.zero ; events = [] @@ -151,14 +151,14 @@ let%test_module "Snapp deploy tests" = ; preconditions = None } in - let parties = + let zkapp_command = Transaction_snark.For_tests.deploy_snapp test_spec ~constraint_constants in Init_ledger.init (module Ledger.Ledger_inner) init_ledger ledger ; - U.check_parties_with_merges_exn ledger [ parties ] ) ) ) + U.check_zkapp_command_with_merges_exn ledger [ zkapp_command ] ) ) ) let%test_unit "Fails to deploy if the account is not present and amount is \ insufficient" = @@ -180,7 +180,7 @@ let%test_module "Snapp deploy tests" = ; zkapp_account_keypairs = [ new_kp ] ; memo ; new_zkapp_account = false - ; snapp_update = Party.Update.dummy + ; snapp_update = Account_update.Update.dummy ; current_auth = Permissions.Auth_required.Signature ; call_data = Snark_params.Tick.Field.zero ; events = [] @@ -188,13 +188,13 @@ let%test_module "Snapp deploy tests" = ; preconditions = None } in - let parties = + let zkapp_command = Transaction_snark.For_tests.deploy_snapp test_spec ~constraint_constants in Init_ledger.init (module Ledger.Ledger_inner) init_ledger ledger ; - U.check_parties_with_merges_exn ledger - ~expected_failure:Invalid_fee_excess [ parties ] ) ) ) + U.check_zkapp_command_with_merges_exn ledger + ~expected_failure:Invalid_fee_excess [ zkapp_command ] ) ) ) end ) diff --git a/src/lib/transaction_snark/test/zkapp_fuzzy/dune b/src/lib/transaction_snark/test/zkapp_fuzzy/dune index 2a54d81fd8f..87f21db914f 100644 --- a/src/lib/transaction_snark/test/zkapp_fuzzy/dune +++ b/src/lib/transaction_snark/test/zkapp_fuzzy/dune @@ -36,7 +36,7 @@ with_hash random_oracle sexplib0 - parties_builder + zkapp_command_builder ) (link_flags (-linkall)) (preprocess 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 0983ab66ca3..5a0fe8c5f29 100644 --- a/src/lib/transaction_snark/test/zkapp_fuzzy/zkapp_fuzzy.ml +++ b/src/lib/transaction_snark/test/zkapp_fuzzy/zkapp_fuzzy.ml @@ -93,8 +93,8 @@ let mk_ledgers_and_fee_payers ?(is_timed = false) ~num_of_fee_payers () = let `VK vk, `Prover prover = Lazy.force U.trivial_zkapp -let generate_parties_and_apply_them_consecutively ~trials ~max_other_parties () - = +let generate_zkapp_command_and_apply_them_consecutively ~trials + ~max_account_updates () = let num_of_fee_payers = 5 in let ledger, fee_payer_keypairs, keymap = mk_ledgers_and_fee_payers ~num_of_fee_payers () @@ -103,20 +103,20 @@ let generate_parties_and_apply_them_consecutively ~trials ~max_other_parties () Test_util.with_randomness 123456789 (fun () -> let test i = Quickcheck.test ~trials:1 - (Mina_generators.Parties_generators.gen_parties_from + (Mina_generators.Zkapp_command_generators.gen_zkapp_command_from ~protocol_state_view:U.genesis_state_view ~account_state_tbl ~fee_payer_keypair:fee_payer_keypairs.(i / 2) - ~max_other_parties ~keymap ~ledger ~vk () ) - ~f:(fun parties_dummy_auths -> + ~max_account_updates ~keymap ~ledger ~vk () ) + ~f:(fun zkapp_command_dummy_auths -> let open Async in Thread_safe.block_on_async_exn (fun () -> - let%bind.Deferred parties = - Parties_builder.replace_authorizations ~prover ~keymap - parties_dummy_auths + let%bind.Deferred zkapp_command = + Zkapp_command_builder.replace_authorizations ~prover ~keymap + zkapp_command_dummy_auths in [%log info] ~metadata: - [ ("parties", Parties.to_yojson parties) + [ ("zkapp_command", Zkapp_command.to_yojson zkapp_command) ; ( "accounts" , `List (List.map @@ -128,14 +128,16 @@ let generate_parties_and_apply_them_consecutively ~trials ~max_other_parties () |> Mina_ledger.Ledger.get ledger |> Option.value_exn |> Account.to_yojson ) ) ) ] - "generated parties" ; - U.check_parties_with_merges_exn ledger [ parties ] ) ) + "generated zkapp_command" ; + U.check_zkapp_command_with_merges_exn ledger [ zkapp_command ] ) + ) in for i = 0 to trials - 1 do test i done ) -let generate_parties_and_apply_them_freshly ~trials ~max_other_parties () = +let generate_zkapp_command_and_apply_them_freshly ~trials ~max_account_updates + () = let num_of_fee_payers = 5 in Test_util.with_randomness 123456789 (fun () -> let test i = @@ -143,24 +145,25 @@ let generate_parties_and_apply_them_freshly ~trials ~max_other_parties () = mk_ledgers_and_fee_payers ~num_of_fee_payers () in Quickcheck.test ~trials:1 - (Mina_generators.Parties_generators.gen_parties_from + (Mina_generators.Zkapp_command_generators.gen_zkapp_command_from ~protocol_state_view:U.genesis_state_view ~fee_payer_keypair:fee_payer_keypairs.(i / 2) - ~max_other_parties ~keymap ~ledger ~vk () ) - ~f:(fun parties_dummy_auths -> + ~max_account_updates ~keymap ~ledger ~vk () ) + ~f:(fun zkapp_command_dummy_auths -> let open Async in Thread_safe.block_on_async_exn (fun () -> - let%bind.Deferred parties = - Parties_builder.replace_authorizations ~prover ~keymap - parties_dummy_auths + let%bind.Deferred zkapp_command = + Zkapp_command_builder.replace_authorizations ~prover ~keymap + zkapp_command_dummy_auths in - U.check_parties_with_merges_exn ledger [ parties ] ) ) + U.check_zkapp_command_with_merges_exn ledger [ zkapp_command ] ) + ) in for i = 0 to trials - 1 do test i done ) -let mk_invalid_test ~num_of_fee_payers ~trials ~max_other_parties +let mk_invalid_test ~num_of_fee_payers ~trials ~max_account_updates ~type_of_failure ~expected_failure_status = Test_util.with_randomness 123456789 (fun () -> let test i = @@ -168,29 +171,30 @@ let mk_invalid_test ~num_of_fee_payers ~trials ~max_other_parties mk_ledgers_and_fee_payers ~num_of_fee_payers () in Quickcheck.test ~trials:1 - (Mina_generators.Parties_generators.gen_parties_from + (Mina_generators.Zkapp_command_generators.gen_zkapp_command_from ~failure:type_of_failure ~protocol_state_view:U.genesis_state_view ~fee_payer_keypair:fee_payer_keypairs.(i / 2) - ~max_other_parties ~keymap ~ledger ~vk () ) - ~f:(fun parties_dummy_auths -> + ~max_account_updates ~keymap ~ledger ~vk () ) + ~f:(fun zkapp_command_dummy_auths -> let open Async in Thread_safe.block_on_async_exn (fun () -> - let%bind.Deferred parties = - Parties_builder.replace_authorizations ~prover ~keymap - parties_dummy_auths + let%bind.Deferred zkapp_command = + Zkapp_command_builder.replace_authorizations ~prover ~keymap + zkapp_command_dummy_auths in [%log info] - ~metadata:[ ("parties", Parties.to_yojson parties) ] - "generated parties" ; - U.check_parties_with_merges_exn - ~expected_failure:expected_failure_status ledger [ parties ] - ~state_body:U.genesis_state_body ) ) + ~metadata: + [ ("zkapp_command", Zkapp_command.to_yojson zkapp_command) ] + "generated zkapp_command" ; + U.check_zkapp_command_with_merges_exn + ~expected_failure:expected_failure_status ledger + [ zkapp_command ] ~state_body:U.genesis_state_body ) ) in for i = 0 to trials - 1 do test i done ) -let test_timed_account ~trials ~max_other_parties () = +let test_timed_account ~trials ~max_account_updates () = let num_of_fee_payers = 5 in Test_util.with_randomness 123456789 (fun () -> let test i = @@ -198,24 +202,25 @@ let test_timed_account ~trials ~max_other_parties () = mk_ledgers_and_fee_payers ~is_timed:true ~num_of_fee_payers () in Quickcheck.test ~trials:1 - (Mina_generators.Parties_generators.gen_parties_from + (Mina_generators.Zkapp_command_generators.gen_zkapp_command_from ~protocol_state_view:U.genesis_state_view ~fee_payer_keypair:fee_payer_keypairs.(i / 2) - ~max_other_parties ~keymap ~ledger ~vk () ) - ~f:(fun parties_dummy_auths -> + ~max_account_updates ~keymap ~ledger ~vk () ) + ~f:(fun zkapp_command_dummy_auths -> let open Async in Thread_safe.block_on_async_exn (fun () -> - let%bind.Deferred parties = - Parties_builder.replace_authorizations ~prover ~keymap - parties_dummy_auths + let%bind.Deferred zkapp_command = + Zkapp_command_builder.replace_authorizations ~prover ~keymap + zkapp_command_dummy_auths in [%log info] - ~metadata:[ ("parties", Parties.to_yojson parties) ] - "generated parties" ; - U.check_parties_with_merges_exn + ~metadata: + [ ("zkapp_command", Zkapp_command.to_yojson zkapp_command) ] + "generated zkapp_command" ; + U.check_zkapp_command_with_merges_exn ~expected_failure: Transaction_status.Failure.Source_minimum_balance_violation - ledger [ parties ] ~state_body:U.genesis_state_body ) ) + ledger [ zkapp_command ] ~state_body:U.genesis_state_body ) ) in for i = 0 to trials - 1 do test i @@ -232,31 +237,32 @@ let () = in fun () -> let num_of_fee_payers = 5 in - let max_other_parties = 3 in - generate_parties_and_apply_them_consecutively ~trials - ~max_other_parties () ; - generate_parties_and_apply_them_freshly ~trials ~max_other_parties () ; - let open Mina_generators.Parties_generators in + let max_account_updates = 3 in + generate_zkapp_command_and_apply_them_consecutively ~trials + ~max_account_updates () ; + generate_zkapp_command_and_apply_them_freshly ~trials + ~max_account_updates () ; + let open Mina_generators.Zkapp_command_generators in let open Transaction_status.Failure in - mk_invalid_test ~num_of_fee_payers ~trials ~max_other_parties + mk_invalid_test ~num_of_fee_payers ~trials ~max_account_updates ~type_of_failure:Invalid_protocol_state_precondition ~expected_failure_status:Protocol_state_precondition_unsatisfied ; - mk_invalid_test ~num_of_fee_payers ~trials ~max_other_parties + mk_invalid_test ~num_of_fee_payers ~trials ~max_account_updates ~type_of_failure:(Update_not_permitted `App_state) ~expected_failure_status:Update_not_permitted_app_state ; - mk_invalid_test ~num_of_fee_payers ~trials ~max_other_parties + mk_invalid_test ~num_of_fee_payers ~trials ~max_account_updates ~type_of_failure:(Update_not_permitted `Verification_key) ~expected_failure_status:Update_not_permitted_verification_key ; - mk_invalid_test ~num_of_fee_payers ~trials ~max_other_parties + mk_invalid_test ~num_of_fee_payers ~trials ~max_account_updates ~type_of_failure:(Update_not_permitted `Zkapp_uri) ~expected_failure_status:Update_not_permitted_zkapp_uri ; - mk_invalid_test ~num_of_fee_payers ~trials ~max_other_parties + mk_invalid_test ~num_of_fee_payers ~trials ~max_account_updates ~type_of_failure:(Update_not_permitted `Token_symbol) ~expected_failure_status:Update_not_permitted_token_symbol ; - mk_invalid_test ~num_of_fee_payers ~trials ~max_other_parties + mk_invalid_test ~num_of_fee_payers ~trials ~max_account_updates ~type_of_failure:(Update_not_permitted `Voting_for) ~expected_failure_status:Update_not_permitted_voting_for ; - mk_invalid_test ~num_of_fee_payers ~trials ~max_other_parties + mk_invalid_test ~num_of_fee_payers ~trials ~max_account_updates ~type_of_failure:(Update_not_permitted `Balance) ~expected_failure_status:Update_not_permitted_balance ; - test_timed_account ~trials ~max_other_parties ()) + test_timed_account ~trials ~max_account_updates ()) diff --git a/src/lib/transaction_snark/test/zkapp_payments/zkapp_payments.ml b/src/lib/transaction_snark/test/zkapp_payments/zkapp_payments.ml index 1cb7123f80e..00428acdbf7 100644 --- a/src/lib/transaction_snark/test/zkapp_payments/zkapp_payments.ml +++ b/src/lib/transaction_snark/test/zkapp_payments/zkapp_payments.ml @@ -13,14 +13,14 @@ let%test_module "Zkapp payments tests" = let constraint_constants = U.constraint_constants - let merkle_root_after_parties_exn t ~txn_state_view txn = + let merkle_root_after_zkapp_command_exn t ~txn_state_view txn = let hash = - Ledger.merkle_root_after_parties_exn + Ledger.merkle_root_after_zkapp_command_exn ~constraint_constants:U.constraint_constants ~txn_state_view t txn in Frozen_ledger_hash.of_ledger_hash hash - let signed_signed ~(wallets : U.Wallet.t array) i j : Parties.t = + let signed_signed ~(wallets : U.Wallet.t array) i j : Zkapp_command.t = let full_amount = 8_000_000_000 in let fee = Fee.of_int (Random.int full_amount) in let receiver_amount = @@ -32,7 +32,7 @@ let%test_module "Zkapp payments tests" = let new_state : _ Zkapp_state.V.t = Pickles_types.Vector.init Zkapp_state.Max_state_size.n ~f:Field.of_int in - Parties.of_simple + Zkapp_command.of_simple { fee_payer = { body = { public_key = acct1.account.public_key @@ -42,7 +42,7 @@ let%test_module "Zkapp payments tests" = } ; authorization = Signature.dummy } - ; other_parties = + ; account_updates = [ { body = { public_key = acct1.account.public_key ; update = @@ -66,7 +66,7 @@ let%test_module "Zkapp payments tests" = ; call_data = Field.zero ; call_depth = 0 ; preconditions = - { Party.Preconditions.network = + { Account_update.Preconditions.network = Zkapp_precondition.Protocol_state.accept ; account = Accept } @@ -77,7 +77,7 @@ let%test_module "Zkapp payments tests" = } ; { body = { public_key = acct2.account.public_key - ; update = Party.Update.noop + ; update = Account_update.Update.noop ; token_id = Token_id.default ; balance_change = Amount.Signed.(of_unsigned receiver_amount) ; increment_nonce = false @@ -86,7 +86,7 @@ let%test_module "Zkapp payments tests" = ; call_data = Field.zero ; call_depth = 0 ; preconditions = - { Party.Preconditions.network = + { Account_update.Preconditions.network = Zkapp_precondition.Protocol_state.accept ; account = Accept } @@ -121,9 +121,9 @@ let%test_module "Zkapp payments tests" = (*Testing merkle root change*) let (`If_this_is_used_it_should_have_a_comment_justifying_it t1) = - Parties.Valid.to_valid_unsafe t1 + Zkapp_command.Valid.to_valid_unsafe t1 in - merkle_root_after_parties_exn ledger ~txn_state_view t1 + merkle_root_after_zkapp_command_exn ledger ~txn_state_view t1 in let hash_post = Ledger.merkle_root ledger in [%test_eq: Field.t] hash_pre hash_post ) ) @@ -132,27 +132,31 @@ let%test_module "Zkapp payments tests" = let open Mina_transaction_logic.For_tests in Quickcheck.test ~trials:2 Test_spec.gen ~f:(fun { init_ledger; specs } -> Ledger.with_ledger ~depth:U.ledger_depth ~f:(fun ledger -> - let parties = - party_send ~constraint_constants (List.hd_exn specs) + let zkapp_command = + account_update_send ~constraint_constants (List.hd_exn specs) in Init_ledger.init (module Ledger.Ledger_inner) init_ledger ledger ; - ignore (U.apply_parties ledger [ parties ] : Sparse_ledger.t) ) ) + ignore + ( U.apply_zkapp_command ledger [ zkapp_command ] + : Sparse_ledger.t ) ) ) let%test_unit "Consecutive zkapps-based payments" = let open Mina_transaction_logic.For_tests in Quickcheck.test ~trials:2 Test_spec.gen ~f:(fun { init_ledger; specs } -> Ledger.with_ledger ~depth:U.ledger_depth ~f:(fun ledger -> - let partiess = + let zkapp_commands = List.map ~f:(fun s -> let use_full_commitment = Quickcheck.random_value Bool.quickcheck_generator in - party_send ~constraint_constants ~use_full_commitment s ) + account_update_send ~constraint_constants + ~use_full_commitment s ) specs in Init_ledger.init (module Ledger.Ledger_inner) init_ledger ledger ; - ignore (U.apply_parties ledger partiess : Sparse_ledger.t) ) ) + ignore + (U.apply_zkapp_command ledger zkapp_commands : Sparse_ledger.t) ) ) let%test_unit "multiple transfers from one account" = let open Mina_transaction_logic.For_tests in @@ -188,7 +192,7 @@ let%test_module "Zkapp payments tests" = ; zkapp_account_keypairs = [] ; memo ; new_zkapp_account = false - ; snapp_update = Party.Update.dummy + ; snapp_update = Account_update.Update.dummy ; current_auth = Permissions.Auth_required.Signature ; call_data = Snark_params.Tick.Field.zero ; events = [] @@ -196,13 +200,13 @@ let%test_module "Zkapp payments tests" = ; preconditions = None } in - let parties = + let zkapp_command = Transaction_snark.For_tests.multiple_transfers test_spec in Init_ledger.init (module Ledger.Ledger_inner) init_ledger ledger ; - U.check_parties_with_merges_exn ledger [ parties ] ) ) ) + U.check_zkapp_command_with_merges_exn ledger [ zkapp_command ] ) ) ) let%test_unit "zkapps payments failed due to insufficient funds" = let open Mina_transaction_logic.For_tests in @@ -255,7 +259,7 @@ let%test_module "Zkapp payments tests" = ; zkapp_account_keypairs = [] ; memo ; new_zkapp_account = false - ; snapp_update = Party.Update.dummy + ; snapp_update = Account_update.Update.dummy ; current_auth = Permissions.Auth_required.Signature ; call_data = Snark_params.Tick.Field.zero ; events = [] @@ -263,10 +267,10 @@ let%test_module "Zkapp payments tests" = ; preconditions = None } in - let parties = + let zkapp_command = Transaction_snark.For_tests.multiple_transfers test_spec in - U.check_parties_with_merges_exn + U.check_zkapp_command_with_merges_exn ~expected_failure:Transaction_status.Failure.Overflow ledger - [ parties ] ) ) ) + [ zkapp_command ] ) ) ) end ) diff --git a/src/lib/transaction_snark/test/zkapp_tokens/dune b/src/lib/transaction_snark/test/zkapp_tokens/dune index 19b4c08542b..a353d1417e2 100644 --- a/src/lib/transaction_snark/test/zkapp_tokens/dune +++ b/src/lib/transaction_snark/test/zkapp_tokens/dune @@ -17,7 +17,7 @@ currency pickles mina_numbers - parties_builder + zkapp_command_builder signature_lib genesis_constants sgn diff --git a/src/lib/transaction_snark/test/zkapp_tokens/zkapp_tokens.ml b/src/lib/transaction_snark/test/zkapp_tokens/zkapp_tokens.ml index e4afa458350..908e35a7d6f 100644 --- a/src/lib/transaction_snark/test/zkapp_tokens/zkapp_tokens.ml +++ b/src/lib/transaction_snark/test/zkapp_tokens/zkapp_tokens.ml @@ -86,148 +86,152 @@ let%test_module "Zkapp tokens tests" = in nonce in - let%bind create_token_parties = - let open Parties_builder in + let%bind create_token_zkapp_command = + let open Zkapp_command_builder in let nonce = nonce_from_ledger () in let with_dummy_signatures = mk_forest [ mk_node - (mk_party_body Call token_funder Token_id.default + (mk_account_update_body Call token_funder + Token_id.default (-(11 * account_creation_fee)) ) [] ; mk_node - (mk_party_body Call token_owner Token_id.default + (mk_account_update_body Call token_owner + Token_id.default (10 * account_creation_fee) ) [] ] - |> mk_parties_transaction ~fee:7 ~fee_payer_pk:pk + |> mk_zkapp_command_transaction ~fee:7 ~fee_payer_pk:pk ~fee_payer_nonce:nonce in replace_authorizations ~keymap with_dummy_signatures in let%bind () = - U.check_parties_with_merges_exn ledger - [ create_token_parties ] + U.check_zkapp_command_with_merges_exn ledger + [ create_token_zkapp_command ] in ignore ( ledger_get_exn ledger (Public_key.compress token_owner.public_key) Token_id.default : Account.t ) ; - let%bind mint_token_parties = - let open Parties_builder in + let%bind mint_token_zkapp_command = + let open Zkapp_command_builder in let nonce = nonce_from_ledger () in let with_dummy_signatures = mk_forest [ mk_node - (mk_party_body Call token_owner Token_id.default - (-account_creation_fee) ) + (mk_account_update_body Call token_owner + Token_id.default (-account_creation_fee) ) [ mk_node - (mk_party_body Call token_accounts.(0) + (mk_account_update_body Call token_accounts.(0) custom_token_id 100 ) [] ] ] - |> mk_parties_transaction ~fee:7 ~fee_payer_pk:pk + |> mk_zkapp_command_transaction ~fee:7 ~fee_payer_pk:pk ~fee_payer_nonce:nonce in replace_authorizations ~keymap with_dummy_signatures in let%bind () = - U.check_parties_with_merges_exn ledger - [ mint_token_parties ] + U.check_zkapp_command_with_merges_exn ledger + [ mint_token_zkapp_command ] in check_token_balance token_accounts.(0) custom_token_id 100 ; - let%bind mint_token2_parties = - let open Parties_builder in + let%bind mint_token2_zkapp_command = + let open Zkapp_command_builder in let nonce = nonce_from_ledger () in let with_dummy_signatures = mk_forest [ mk_node - (mk_party_body Call token_owner Token_id.default + (mk_account_update_body Call token_owner + Token_id.default (-2 * account_creation_fee) ) [ mk_node - (mk_party_body Call token_owner custom_token_id - 0 ) + (mk_account_update_body Call token_owner + custom_token_id 0 ) [ mk_node - (mk_party_body Call token_accounts.(2) - custom_token_id2 500 ) + (mk_account_update_body Call + token_accounts.(2) custom_token_id2 500 ) [] ] ] ] - |> mk_parties_transaction ~fee:7 ~fee_payer_pk:pk + |> mk_zkapp_command_transaction ~fee:7 ~fee_payer_pk:pk ~fee_payer_nonce:nonce in replace_authorizations ~keymap with_dummy_signatures in let%bind () = - U.check_parties_with_merges_exn ledger - [ mint_token2_parties ] + U.check_zkapp_command_with_merges_exn ledger + [ mint_token2_zkapp_command ] in check_token_balance token_accounts.(2) custom_token_id2 500 ; - let%bind token_transfer_parties = - let open Parties_builder in + let%bind token_transfer_zkapp_command = + let open Zkapp_command_builder in let nonce = nonce_from_ledger () in let with_dummy_signatures = mk_forest [ mk_node - (mk_party_body Call token_owner Token_id.default + (mk_account_update_body Call token_owner + Token_id.default (-2 * account_creation_fee) ) [ mk_node - (mk_party_body Call token_accounts.(0) + (mk_account_update_body Call token_accounts.(0) custom_token_id (-30) ) [] ; mk_node - (mk_party_body Call token_accounts.(1) + (mk_account_update_body Call token_accounts.(1) custom_token_id 30 ) [] ; mk_node - (mk_party_body Call fee_payer_keypair + (mk_account_update_body Call fee_payer_keypair Token_id.default (-50) ) [] ; mk_node - (mk_party_body Call token_funder + (mk_account_update_body Call token_funder Token_id.default 50 ) [] ; mk_node - (mk_party_body Call token_accounts.(0) + (mk_account_update_body Call token_accounts.(0) custom_token_id (-10) ) [] ; mk_node - (mk_party_body Call token_accounts.(1) + (mk_account_update_body Call token_accounts.(1) custom_token_id 10 ) [] ; mk_node - (mk_party_body Call token_accounts.(1) + (mk_account_update_body Call token_accounts.(1) custom_token_id (-5) ) [] ; mk_node - (mk_party_body Call token_accounts.(0) + (mk_account_update_body Call token_accounts.(0) custom_token_id 5 ) [] ; mk_node - (mk_party_body Call token_owner custom_token_id - 0 ) + (mk_account_update_body Call token_owner + custom_token_id 0 ) [ mk_node - (mk_party_body Call token_accounts.(2) - custom_token_id2 (-210) ) + (mk_account_update_body Call + token_accounts.(2) custom_token_id2 (-210) ) [] ; mk_node - (mk_party_body Call token_accounts.(3) - custom_token_id2 210 ) + (mk_account_update_body Call + token_accounts.(3) custom_token_id2 210 ) [] ] ] ] - |> mk_parties_transaction ~fee:7 ~fee_payer_pk:pk + |> mk_zkapp_command_transaction ~fee:7 ~fee_payer_pk:pk ~fee_payer_nonce:nonce in replace_authorizations ~keymap with_dummy_signatures in let%bind () = - U.check_parties_with_merges_exn ledger - [ token_transfer_parties ] + U.check_zkapp_command_with_merges_exn ledger + [ token_transfer_zkapp_command ] in check_token_balance token_accounts.(0) custom_token_id 65 ; check_token_balance token_accounts.(1) custom_token_id 35 ; diff --git a/src/lib/transaction_snark/test/zkapp_uri/zkapp_uri.ml b/src/lib/transaction_snark/test/zkapp_uri/zkapp_uri.ml index 63c3cd2d434..b7761e39f4a 100644 --- a/src/lib/transaction_snark/test/zkapp_uri/zkapp_uri.ml +++ b/src/lib/transaction_snark/test/zkapp_uri/zkapp_uri.ml @@ -8,7 +8,7 @@ struct Mina_base.Transaction_status.Failure.Update_not_permitted_zkapp_uri let snapp_update = - { Party.Update.dummy with + { Account_update.Update.dummy with zkapp_uri = Zkapp_basic.Set_or_keep.Set "https://www.minaprotocol.com" } end diff --git a/src/lib/transaction_snark/test/zkapps_examples/add_events/add_events.ml b/src/lib/transaction_snark/test/zkapps_examples/add_events/add_events.ml index 27ce58b1aaf..0e5e2fe4dee 100644 --- a/src/lib/transaction_snark/test/zkapps_examples/add_events/add_events.ml +++ b/src/lib/transaction_snark/test/zkapps_examples/add_events/add_events.ml @@ -38,12 +38,12 @@ let%test_module "Add events test" = let vk = Pickles.Side_loaded.Verification_key.of_compiled tag - module Deploy_party = struct - let party_body : Party.Body.t = - { Party.Body.dummy with + module Deploy_account_update = struct + let account_update_body : Account_update.Body.t = + { Account_update.Body.dummy with public_key = pk_compressed ; update = - { Party.Update.dummy with + { Account_update.Update.dummy with verification_key = Set { data = vk; hash = Zkapp_account.digest_vk vk } ; permissions = @@ -63,18 +63,21 @@ let%test_module "Add events test" = } ; use_full_commitment = true ; preconditions = - { Party.Preconditions.network = + { Account_update.Preconditions.network = Zkapp_precondition.Protocol_state.accept ; account = Accept } } - let party : Party.t = - { body = party_body; authorization = Signature Signature.dummy } + let account_update : Account_update.t = + { body = account_update_body + ; authorization = Signature Signature.dummy + } end - module Initialize_party = struct - let party, () = Async.Thread_safe.block_on_async_exn initialize_prover + module Initialize_account_update = struct + let account_update, () = + Async.Thread_safe.block_on_async_exn initialize_prover end module Add_events = struct @@ -84,21 +87,23 @@ let%test_module "Add events test" = Array.init event_length ~f:(fun inner -> Snark_params.Tick.Field.of_int (outer + inner) ) ) - let party, () = + let account_update, () = Async.Thread_safe.block_on_async_exn (add_events_prover ~handler:(Zkapps_add_events.update_events_handler events) ) end - let test_parties ?expected_failure parties = + let test_zkapp_command ?expected_failure zkapp_command = let memo = Signed_command_memo.empty in - let transaction_commitment : Parties.Transaction_commitment.t = - let other_parties_hash = Parties.Call_forest.hash parties in - Parties.Transaction_commitment.create ~other_parties_hash + let transaction_commitment : Zkapp_command.Transaction_commitment.t = + let account_updates_hash = + Zkapp_command.Call_forest.hash zkapp_command + in + Zkapp_command.Transaction_commitment.create ~account_updates_hash in - let fee_payer : Party.Fee_payer.t = + let fee_payer : Account_update.Fee_payer.t = { body = - { Party.Body.Fee_payer.dummy with + { Account_update.Body.Fee_payer.dummy with public_key = pk_compressed ; fee = Currency.Fee.(of_int 100) } @@ -107,14 +112,14 @@ let%test_module "Add events test" = in let memo_hash = Signed_command_memo.hash memo in let full_commitment = - Parties.Transaction_commitment.create_complete transaction_commitment - ~memo_hash + Zkapp_command.Transaction_commitment.create_complete + transaction_commitment ~memo_hash ~fee_payer_hash: - (Parties.Call_forest.Digest.Party.create - (Party.of_fee_payer fee_payer) ) + (Zkapp_command.Call_forest.Digest.Account_update.create + (Account_update.of_fee_payer fee_payer) ) in - let sign_all ({ fee_payer; other_parties; memo } : Parties.t) : Parties.t - = + let sign_all ({ fee_payer; account_updates; memo } : Zkapp_command.t) : + Zkapp_command.t = let fee_payer = match fee_payer with | { body = { public_key; _ }; _ } @@ -127,30 +132,30 @@ let%test_module "Add events test" = | fee_payer -> fee_payer in - let other_parties = - Parties.Call_forest.map other_parties ~f:(function + let account_updates = + Zkapp_command.Call_forest.map account_updates ~f:(function | ({ body = { public_key; use_full_commitment; _ } ; authorization = Signature _ - } as party : - Party.t ) + } as account_update : + Account_update.t ) when Public_key.Compressed.equal public_key pk_compressed -> let commitment = if use_full_commitment then full_commitment else transaction_commitment in - { party with + { account_update with authorization = Signature (Schnorr.Chunked.sign sk (Random_oracle.Input.Chunked.field commitment) ) } - | party -> - party ) + | account_update -> + account_update ) in - { fee_payer; other_parties; memo } + { fee_payer; account_updates; memo } in - let parties : Parties.t = - sign_all { fee_payer; other_parties = parties; memo } + let zkapp_command : Zkapp_command.t = + sign_all { fee_payer; account_updates = zkapp_command; memo } in Ledger.with_ledger ~depth:ledger_depth ~f:(fun ledger -> let account = @@ -161,8 +166,9 @@ let%test_module "Add events test" = |> Or_error.ok_exn in Async.Thread_safe.block_on_async_exn (fun () -> - check_parties_with_merges_exn ?expected_failure ledger [ parties ] ) ; - (parties, Ledger.get ledger loc) ) + check_zkapp_command_with_merges_exn ?expected_failure ledger + [ zkapp_command ] ) ; + (zkapp_command, Ledger.get ledger loc) ) module Events_verifier = Merkle_list_verifier.Make (struct type proof_elem = Mina_base.Zkapp_account.Event.t @@ -175,51 +181,61 @@ let%test_module "Add events test" = end) let%test_unit "Initialize" = - let parties, account = + let zkapp_command, account = [] - |> Parties.Call_forest.cons_tree Initialize_party.party - |> Parties.Call_forest.cons Deploy_party.party - |> test_parties + |> Zkapp_command.Call_forest.cons_tree + Initialize_account_update.account_update + |> Zkapp_command.Call_forest.cons Deploy_account_update.account_update + |> test_zkapp_command in assert (Option.is_some account) ; - let other_parties = Parties.Call_forest.to_list parties.other_parties in + let account_updates = + Zkapp_command.Call_forest.to_list zkapp_command.account_updates + in (* we haven't added any events, so should see default empty list *) - List.iter other_parties ~f:(fun party -> - assert (List.is_empty party.body.events) ) + List.iter account_updates ~f:(fun account_update -> + assert (List.is_empty account_update.body.events) ) let%test_unit "Initialize and add events" = - let parties, account = + let zkapp_command, account = [] - |> Parties.Call_forest.cons_tree Add_events.party - |> Parties.Call_forest.cons_tree Initialize_party.party - |> Parties.Call_forest.cons Deploy_party.party - |> test_parties + |> Zkapp_command.Call_forest.cons_tree Add_events.account_update + |> Zkapp_command.Call_forest.cons_tree + Initialize_account_update.account_update + |> Zkapp_command.Call_forest.cons Deploy_account_update.account_update + |> test_zkapp_command in assert (Option.is_some account) ; - let other_parties = Parties.Call_forest.to_list parties.other_parties in - List.iteri other_parties ~f:(fun i party -> - if i > 1 then assert (not @@ List.is_empty party.body.events) - else assert (List.is_empty party.body.events) ) + let account_updates = + Zkapp_command.Call_forest.to_list zkapp_command.account_updates + in + List.iteri account_updates ~f:(fun i account_update -> + if i > 1 then assert (not @@ List.is_empty account_update.body.events) + else assert (List.is_empty account_update.body.events) ) let%test_unit "Initialize and add several events" = - let parties, account = + let zkapp_command, account = [] - |> Parties.Call_forest.cons_tree Add_events.party - |> Parties.Call_forest.cons_tree Add_events.party - |> Parties.Call_forest.cons_tree Add_events.party - |> Parties.Call_forest.cons_tree Initialize_party.party - |> Parties.Call_forest.cons Deploy_party.party - |> test_parties + |> Zkapp_command.Call_forest.cons_tree Add_events.account_update + |> Zkapp_command.Call_forest.cons_tree Add_events.account_update + |> Zkapp_command.Call_forest.cons_tree Add_events.account_update + |> Zkapp_command.Call_forest.cons_tree + Initialize_account_update.account_update + |> Zkapp_command.Call_forest.cons Deploy_account_update.account_update + |> test_zkapp_command in assert (Option.is_some account) ; - let other_parties = Parties.Call_forest.to_list parties.other_parties in - List.iteri other_parties ~f:(fun i party -> - if i > 1 then assert (not @@ List.is_empty party.body.events) - else assert (List.is_empty party.body.events) ) ; - let parties_with_events = List.drop other_parties 2 in - (* assemble big list of events from the Partys with events *) + let account_updates = + Zkapp_command.Call_forest.to_list zkapp_command.account_updates + in + List.iteri account_updates ~f:(fun i account_update -> + if i > 1 then assert (not @@ List.is_empty account_update.body.events) + else assert (List.is_empty account_update.body.events) ) ; + let zkapp_command_with_events = List.drop account_updates 2 in + (* assemble big list of events from the AccountUpdates with events *) let all_events = - List.concat_map parties_with_events ~f:(fun party -> party.body.events) + List.concat_map zkapp_command_with_events ~f:(fun account_update -> + account_update.body.events ) in let all_events_hash = Mina_base.Zkapp_account.Events.hash all_events in (* verify the hash; Events.hash does a fold_right, so we use verify_right diff --git a/src/lib/transaction_snark/test/zkapps_examples/empty_update/empty_update.ml b/src/lib/transaction_snark/test/zkapps_examples/empty_update/empty_update.ml index af56d6eb4da..8f99c09768b 100644 --- a/src/lib/transaction_snark/test/zkapps_examples/empty_update/empty_update.ml +++ b/src/lib/transaction_snark/test/zkapps_examples/empty_update/empty_update.ml @@ -6,7 +6,7 @@ module Impl = Pickles.Impls.Step module Inner_curve = Snark_params.Tick.Inner_curve module Nat = Pickles_types.Nat module Local_state = Mina_state.Local_state -module Parties_segment = Transaction_snark.Parties_segment +module Zkapp_command_segment = Transaction_snark.Zkapp_command_segment let sk = Private_key.create () @@ -30,14 +30,14 @@ module P = (val p_module) let vk = Pickles.Side_loaded.Verification_key.of_compiled tag -let party, () = Async.Thread_safe.block_on_async_exn prover +let account_update, () = Async.Thread_safe.block_on_async_exn prover -let deploy_party_body : Party.Body.t = +let deploy_account_update_body : Account_update.Body.t = (* TODO: This is a pain. *) - { Party.Body.dummy with + { Account_update.Body.dummy with public_key = pk_compressed ; update = - { Party.Update.dummy with + { Account_update.Update.dummy with verification_key = Set { data = vk @@ -49,33 +49,36 @@ let deploy_party_body : Party.Body.t = } } ; preconditions = - { Party.Preconditions.network = Zkapp_precondition.Protocol_state.accept + { Account_update.Preconditions.network = + Zkapp_precondition.Protocol_state.accept ; account = Accept } ; caller = Token_id.default ; use_full_commitment = true } -let deploy_party : Party.t = +let deploy_account_update : Account_update.t = (* TODO: This is a pain. *) - { body = deploy_party_body; authorization = Signature Signature.dummy } + { body = deploy_account_update_body + ; authorization = Signature Signature.dummy + } -let other_parties = +let account_updates = [] - |> Parties.Call_forest.cons_tree party - |> Parties.Call_forest.cons deploy_party + |> Zkapp_command.Call_forest.cons_tree account_update + |> Zkapp_command.Call_forest.cons deploy_account_update let memo = Signed_command_memo.empty -let transaction_commitment : Parties.Transaction_commitment.t = +let transaction_commitment : Zkapp_command.Transaction_commitment.t = (* TODO: This is a pain. *) - let other_parties_hash = Parties.Call_forest.hash other_parties in - Parties.Transaction_commitment.create ~other_parties_hash + let account_updates_hash = Zkapp_command.Call_forest.hash account_updates in + Zkapp_command.Transaction_commitment.create ~account_updates_hash let fee_payer = (* TODO: This is a pain. *) - { Party.Fee_payer.body = - { Party.Body.Fee_payer.dummy with + { Account_update.Fee_payer.body = + { Account_update.Body.Fee_payer.dummy with public_key = pk_compressed ; fee = Currency.Fee.(of_int 100) } @@ -84,12 +87,15 @@ let fee_payer = let full_commitment = (* TODO: This is a pain. *) - Parties.Transaction_commitment.create_complete transaction_commitment + Zkapp_command.Transaction_commitment.create_complete transaction_commitment ~memo_hash:(Signed_command_memo.hash memo) - ~fee_payer_hash:(Parties.Digest.Party.create (Party.of_fee_payer fee_payer)) + ~fee_payer_hash: + (Zkapp_command.Digest.Account_update.create + (Account_update.of_fee_payer fee_payer) ) (* TODO: Make this better. *) -let sign_all ({ fee_payer; other_parties; memo } : Parties.t) : Parties.t = +let sign_all ({ fee_payer; account_updates; memo } : Zkapp_command.t) : + Zkapp_command.t = let fee_payer = match fee_payer with | { body = { public_key; _ }; _ } @@ -102,32 +108,32 @@ let sign_all ({ fee_payer; other_parties; memo } : Parties.t) : Parties.t = | fee_payer -> fee_payer in - let other_parties = - Parties.Call_forest.map other_parties ~f:(function + let account_updates = + Zkapp_command.Call_forest.map account_updates ~f:(function | ({ body = { public_key; use_full_commitment; _ } ; authorization = Signature _ - } as party : - Party.t ) + } as account_update : + Account_update.t ) when Public_key.Compressed.equal public_key pk_compressed -> let commitment = if use_full_commitment then full_commitment else transaction_commitment in - { party with + { account_update with authorization = Control.Signature (Schnorr.Chunked.sign sk (Random_oracle.Input.Chunked.field commitment) ) } - | party -> - party ) + | account_update -> + account_update ) in - { fee_payer; other_parties; memo } + { fee_payer; account_updates; memo } -let parties : Parties.t = +let zkapp_command : Zkapp_command.t = sign_all { fee_payer = { body = fee_payer.body; authorization = Signature.dummy } - ; other_parties + ; account_updates ; memo } @@ -139,4 +145,4 @@ let () = Currency.Balance.( Option.value_exn (add_amount zero (Currency.Amount.of_int 500))) ) in - ignore (apply_parties ledger [ parties ] : Sparse_ledger.t) ) + ignore (apply_zkapp_command ledger [ zkapp_command ] : Sparse_ledger.t) ) diff --git a/src/lib/transaction_snark/test/zkapps_examples/initialize_state/initialize_state.ml b/src/lib/transaction_snark/test/zkapps_examples/initialize_state/initialize_state.ml index 34233ffbda1..a70737ccfb1 100644 --- a/src/lib/transaction_snark/test/zkapps_examples/initialize_state/initialize_state.ml +++ b/src/lib/transaction_snark/test/zkapps_examples/initialize_state/initialize_state.ml @@ -6,7 +6,7 @@ module Impl = Pickles.Impls.Step module Inner_curve = Snark_params.Tick.Inner_curve module Nat = Pickles_types.Nat module Local_state = Mina_state.Local_state -module Parties_segment = Transaction_snark.Parties_segment +module Zkapp_command_segment = Transaction_snark.Zkapp_command_segment module Statement = Transaction_snark.Statement let%test_module "Initialize state test" = @@ -42,12 +42,12 @@ let%test_module "Initialize state test" = let vk = Pickles.Side_loaded.Verification_key.of_compiled tag - module Deploy_party = struct - let party_body : Party.Body.t = - { Party.Body.dummy with + module Deploy_account_update = struct + let account_update_body : Account_update.Body.t = + { Account_update.Body.dummy with public_key = pk_compressed ; update = - { Party.Update.dummy with + { Account_update.Update.dummy with verification_key = Set { data = vk @@ -74,40 +74,45 @@ let%test_module "Initialize state test" = } ; use_full_commitment = true ; preconditions = - { Party.Preconditions.network = + { Account_update.Preconditions.network = Zkapp_precondition.Protocol_state.accept ; account = Accept } } - let party : Party.t = + let account_update : Account_update.t = (* TODO: This is a pain. *) - { body = party_body; authorization = Signature Signature.dummy } + { body = account_update_body + ; authorization = Signature Signature.dummy + } end - module Initialize_party = struct - let party, () = Async.Thread_safe.block_on_async_exn initialize_prover + module Initialize_account_update = struct + let account_update, () = + Async.Thread_safe.block_on_async_exn initialize_prover end - module Update_state_party = struct + module Update_state_account_update = struct let new_state = List.init 8 ~f:(fun _ -> Snark_params.Tick.Field.one) - let party, () = + let account_update, () = Async.Thread_safe.block_on_async_exn (update_state_prover ~handler:(Zkapps_initialize_state.update_state_handler new_state) ) end - let test_parties ?expected_failure parties = + let test_zkapp_command ?expected_failure zkapp_command = let memo = Signed_command_memo.empty in - let transaction_commitment : Parties.Transaction_commitment.t = + let transaction_commitment : Zkapp_command.Transaction_commitment.t = (* TODO: This is a pain. *) - let other_parties_hash = Parties.Call_forest.hash parties in - Parties.Transaction_commitment.create ~other_parties_hash + let account_updates_hash = + Zkapp_command.Call_forest.hash zkapp_command + in + Zkapp_command.Transaction_commitment.create ~account_updates_hash in - let fee_payer : Party.Fee_payer.t = + let fee_payer : Account_update.Fee_payer.t = { body = - { Party.Body.Fee_payer.dummy with + { Account_update.Body.Fee_payer.dummy with public_key = pk_compressed ; fee = Currency.Fee.(of_int 100) } @@ -116,14 +121,14 @@ let%test_module "Initialize state test" = in let memo_hash = Signed_command_memo.hash memo in let full_commitment = - Parties.Transaction_commitment.create_complete transaction_commitment - ~memo_hash + Zkapp_command.Transaction_commitment.create_complete + transaction_commitment ~memo_hash ~fee_payer_hash: - (Parties.Call_forest.Digest.Party.create - (Party.of_fee_payer fee_payer) ) + (Zkapp_command.Call_forest.Digest.Account_update.create + (Account_update.of_fee_payer fee_payer) ) in - let sign_all ({ fee_payer; other_parties; memo } : Parties.t) : Parties.t - = + let sign_all ({ fee_payer; account_updates; memo } : Zkapp_command.t) : + Zkapp_command.t = let fee_payer = match fee_payer with | { body = { public_key; _ }; _ } @@ -136,30 +141,30 @@ let%test_module "Initialize state test" = | fee_payer -> fee_payer in - let other_parties = - Parties.Call_forest.map other_parties ~f:(function + let account_updates = + Zkapp_command.Call_forest.map account_updates ~f:(function | ({ body = { public_key; use_full_commitment; _ } ; authorization = Signature _ - } as party : - Party.t ) + } as account_update : + Account_update.t ) when Public_key.Compressed.equal public_key pk_compressed -> let commitment = if use_full_commitment then full_commitment else transaction_commitment in - { party with + { account_update with authorization = Signature (Schnorr.Chunked.sign sk (Random_oracle.Input.Chunked.field commitment) ) } - | party -> - party ) + | account_update -> + account_update ) in - { fee_payer; other_parties; memo } + { fee_payer; account_updates; memo } in - let parties : Parties.t = - sign_all { fee_payer; other_parties = parties; memo } + let zkapp_command : Zkapp_command.t = + sign_all { fee_payer; account_updates = zkapp_command; memo } in Ledger.with_ledger ~depth:ledger_depth ~f:(fun ledger -> let account = @@ -172,15 +177,17 @@ let%test_module "Initialize state test" = |> Or_error.ok_exn in Async.Thread_safe.block_on_async_exn (fun () -> - check_parties_with_merges_exn ?expected_failure ledger [ parties ] ) ; + check_zkapp_command_with_merges_exn ?expected_failure ledger + [ zkapp_command ] ) ; Ledger.get ledger loc ) let%test_unit "Initialize" = let account = [] - |> Parties.Call_forest.cons_tree Initialize_party.party - |> Parties.Call_forest.cons Deploy_party.party - |> test_parties + |> Zkapp_command.Call_forest.cons_tree + Initialize_account_update.account_update + |> Zkapp_command.Call_forest.cons Deploy_account_update.account_update + |> test_zkapp_command in let zkapp_state = (Option.value_exn (Option.value_exn account).zkapp).app_state @@ -192,10 +199,12 @@ let%test_module "Initialize state test" = let%test_unit "Initialize and update" = let account = [] - |> Parties.Call_forest.cons_tree Update_state_party.party - |> Parties.Call_forest.cons_tree Initialize_party.party - |> Parties.Call_forest.cons Deploy_party.party - |> test_parties + |> Zkapp_command.Call_forest.cons_tree + Update_state_account_update.account_update + |> Zkapp_command.Call_forest.cons_tree + Initialize_account_update.account_update + |> Zkapp_command.Call_forest.cons Deploy_account_update.account_update + |> test_zkapp_command in let zkapp_state = (Option.value_exn (Option.value_exn account).zkapp).app_state @@ -207,11 +216,14 @@ let%test_module "Initialize state test" = let%test_unit "Initialize and multiple update" = let account = [] - |> Parties.Call_forest.cons_tree Update_state_party.party - |> Parties.Call_forest.cons_tree Update_state_party.party - |> Parties.Call_forest.cons_tree Initialize_party.party - |> Parties.Call_forest.cons Deploy_party.party - |> test_parties + |> Zkapp_command.Call_forest.cons_tree + Update_state_account_update.account_update + |> Zkapp_command.Call_forest.cons_tree + Update_state_account_update.account_update + |> Zkapp_command.Call_forest.cons_tree + Initialize_account_update.account_update + |> Zkapp_command.Call_forest.cons Deploy_account_update.account_update + |> test_zkapp_command in let zkapp_state = (Option.value_exn (Option.value_exn account).zkapp).app_state @@ -223,9 +235,10 @@ let%test_module "Initialize state test" = let%test_unit "Update without initialize fails" = let account = [] - |> Parties.Call_forest.cons_tree Update_state_party.party - |> Parties.Call_forest.cons Deploy_party.party - |> test_parties + |> Zkapp_command.Call_forest.cons_tree + Update_state_account_update.account_update + |> Zkapp_command.Call_forest.cons Deploy_account_update.account_update + |> test_zkapp_command ~expected_failure:Account_proved_state_precondition_unsatisfied in assert (Option.is_none (Option.value_exn account).zkapp) @@ -233,10 +246,12 @@ let%test_module "Initialize state test" = let%test_unit "Double initialize fails" = let account = [] - |> Parties.Call_forest.cons_tree Initialize_party.party - |> Parties.Call_forest.cons_tree Initialize_party.party - |> Parties.Call_forest.cons Deploy_party.party - |> test_parties + |> Zkapp_command.Call_forest.cons_tree + Initialize_account_update.account_update + |> Zkapp_command.Call_forest.cons_tree + Initialize_account_update.account_update + |> Zkapp_command.Call_forest.cons Deploy_account_update.account_update + |> test_zkapp_command ~expected_failure:Account_proved_state_precondition_unsatisfied in assert (Option.is_none (Option.value_exn account).zkapp) @@ -244,11 +259,14 @@ let%test_module "Initialize state test" = let%test_unit "Initialize after update fails" = let account = [] - |> Parties.Call_forest.cons_tree Initialize_party.party - |> Parties.Call_forest.cons_tree Update_state_party.party - |> Parties.Call_forest.cons_tree Initialize_party.party - |> Parties.Call_forest.cons Deploy_party.party - |> test_parties + |> Zkapp_command.Call_forest.cons_tree + Initialize_account_update.account_update + |> Zkapp_command.Call_forest.cons_tree + Update_state_account_update.account_update + |> Zkapp_command.Call_forest.cons_tree + Initialize_account_update.account_update + |> Zkapp_command.Call_forest.cons Deploy_account_update.account_update + |> test_zkapp_command ~expected_failure:Account_proved_state_precondition_unsatisfied in assert (Option.is_none (Option.value_exn account).zkapp) @@ -260,9 +278,11 @@ let%test_module "Initialize state test" = in the account. *) [] - |> Parties.Call_forest.cons_tree Update_state_party.party - |> Parties.Call_forest.cons_tree Initialize_party.party - |> test_parties ) + |> Zkapp_command.Call_forest.cons_tree + Update_state_account_update.account_update + |> Zkapp_command.Call_forest.cons_tree + Initialize_account_update.account_update + |> test_zkapp_command ) in assert (Or_error.is_error account) end ) diff --git a/src/lib/transaction_snark/test/zkapps_examples/sequence_events/sequence_events.ml b/src/lib/transaction_snark/test/zkapps_examples/sequence_events/sequence_events.ml index 4c163ca7fe4..bd2dc521b42 100644 --- a/src/lib/transaction_snark/test/zkapps_examples/sequence_events/sequence_events.ml +++ b/src/lib/transaction_snark/test/zkapps_examples/sequence_events/sequence_events.ml @@ -38,12 +38,12 @@ let%test_module "Sequence events test" = let vk = Pickles.Side_loaded.Verification_key.of_compiled tag - module Deploy_party = struct - let party_body : Party.Body.t = - { Party.Body.dummy with + module Deploy_account_update = struct + let account_update_body : Account_update.Body.t = + { Account_update.Body.dummy with public_key = pk_compressed ; update = - { Party.Update.dummy with + { Account_update.Update.dummy with verification_key = Set { data = vk; hash = Zkapp_account.digest_vk vk } ; permissions = @@ -63,18 +63,21 @@ let%test_module "Sequence events test" = } ; use_full_commitment = true ; preconditions = - { Party.Preconditions.network = + { Account_update.Preconditions.network = Zkapp_precondition.Protocol_state.accept ; account = Accept } } - let party : Party.t = - { body = party_body; authorization = Signature Signature.dummy } + let account_update : Account_update.t = + { body = account_update_body + ; authorization = Signature Signature.dummy + } end - module Initialize_party = struct - let party, () = Async.Thread_safe.block_on_async_exn initialize_prover + module Initialize_account_update = struct + let account_update, () = + Async.Thread_safe.block_on_async_exn initialize_prover end module Add_sequence_events = struct @@ -84,7 +87,7 @@ let%test_module "Sequence events test" = Array.init event_length ~f:(fun inner -> Snark_params.Tick.Field.of_int (outer + inner) ) ) - let party, () = + let account_update, () = Async.Thread_safe.block_on_async_exn (add_sequence_events_prover ~handler: @@ -92,16 +95,18 @@ let%test_module "Sequence events test" = sequence_events ) ) end - let test_parties ?expected_failure ?state_body ?(fee_payer_nonce = 0) - ~ledger parties = + let test_zkapp_command ?expected_failure ?state_body ?(fee_payer_nonce = 0) + ~ledger zkapp_command = let memo = Signed_command_memo.empty in - let transaction_commitment : Parties.Transaction_commitment.t = - let other_parties_hash = Parties.Call_forest.hash parties in - Parties.Transaction_commitment.create ~other_parties_hash + let transaction_commitment : Zkapp_command.Transaction_commitment.t = + let account_updates_hash = + Zkapp_command.Call_forest.hash zkapp_command + in + Zkapp_command.Transaction_commitment.create ~account_updates_hash in - let fee_payer : Party.Fee_payer.t = + let fee_payer : Account_update.Fee_payer.t = { body = - { Party.Body.Fee_payer.dummy with + { Account_update.Body.Fee_payer.dummy with public_key = pk_compressed ; fee = Currency.Fee.(of_int 50) ; nonce = Account.Nonce.of_int fee_payer_nonce @@ -111,14 +116,14 @@ let%test_module "Sequence events test" = in let memo_hash = Signed_command_memo.hash memo in let full_commitment = - Parties.Transaction_commitment.create_complete transaction_commitment - ~memo_hash + Zkapp_command.Transaction_commitment.create_complete + transaction_commitment ~memo_hash ~fee_payer_hash: - (Parties.Call_forest.Digest.Party.create - (Party.of_fee_payer fee_payer) ) + (Zkapp_command.Call_forest.Digest.Account_update.create + (Account_update.of_fee_payer fee_payer) ) in - let sign_all ({ fee_payer; other_parties; memo } : Parties.t) : Parties.t - = + let sign_all ({ fee_payer; account_updates; memo } : Zkapp_command.t) : + Zkapp_command.t = let fee_payer = match fee_payer with | { body = { public_key; _ }; _ } @@ -131,30 +136,30 @@ let%test_module "Sequence events test" = | fee_payer -> fee_payer in - let other_parties = - Parties.Call_forest.map other_parties ~f:(function + let account_updates = + Zkapp_command.Call_forest.map account_updates ~f:(function | ({ body = { public_key; use_full_commitment; _ } ; authorization = Signature _ - } as party : - Party.t ) + } as account_update : + Account_update.t ) when Public_key.Compressed.equal public_key pk_compressed -> let commitment = if use_full_commitment then full_commitment else transaction_commitment in - { party with + { account_update with authorization = Signature (Schnorr.Chunked.sign sk (Random_oracle.Input.Chunked.field commitment) ) } - | party -> - party ) + | account_update -> + account_update ) in - { fee_payer; other_parties; memo } + { fee_payer; account_updates; memo } in - let parties : Parties.t = - sign_all { fee_payer; other_parties = parties; memo } + let zkapp_command : Zkapp_command.t = + sign_all { fee_payer; account_updates = zkapp_command; memo } in let account = Account.create account_id Currency.Balance.(of_int 500) in let _, loc = @@ -162,9 +167,9 @@ let%test_module "Sequence events test" = |> Or_error.ok_exn in Async.Thread_safe.block_on_async_exn (fun () -> - check_parties_with_merges_exn ?state_body ?expected_failure ledger - [ parties ] ) ; - (parties, Ledger.get ledger loc) + check_zkapp_command_with_merges_exn ?state_body ?expected_failure + ledger [ zkapp_command ] ) ; + (zkapp_command, Ledger.get ledger loc) let create_ledger () = Ledger.create ~depth:ledger_depth () @@ -175,30 +180,36 @@ let%test_module "Sequence events test" = (Pickles_types.Vector.Vector_5.to_list seq_state, last_seq_slot) let%test_unit "Initialize" = - let parties, account = + let zkapp_command, account = let ledger = create_ledger () in [] - |> Parties.Call_forest.cons_tree Initialize_party.party - |> Parties.Call_forest.cons Deploy_party.party - |> test_parties ~ledger + |> Zkapp_command.Call_forest.cons_tree + Initialize_account_update.account_update + |> Zkapp_command.Call_forest.cons Deploy_account_update.account_update + |> test_zkapp_command ~ledger in assert (Option.is_some account) ; - let other_parties = Parties.Call_forest.to_list parties.other_parties in + let account_updates = + Zkapp_command.Call_forest.to_list zkapp_command.account_updates + in (* we haven't added any sequence events *) - List.iter other_parties ~f:(fun party -> - assert (List.is_empty party.body.sequence_events) ) + List.iter account_updates ~f:(fun account_update -> + assert (List.is_empty account_update.body.sequence_events) ) let%test_unit "Initialize and add sequence events" = - let parties0, account0 = + let zkapp_command0, account0 = let ledger = create_ledger () in [] - |> Parties.Call_forest.cons_tree Initialize_party.party - |> Parties.Call_forest.cons Deploy_party.party - |> test_parties ~ledger + |> Zkapp_command.Call_forest.cons_tree + Initialize_account_update.account_update + |> Zkapp_command.Call_forest.cons Deploy_account_update.account_update + |> test_zkapp_command ~ledger in - let other_parties0 = Parties.Call_forest.to_list parties0.other_parties in - List.iter other_parties0 ~f:(fun party -> - assert (List.is_empty party.body.sequence_events) ) ; + let account_updates0 = + Zkapp_command.Call_forest.to_list zkapp_command0.account_updates + in + List.iter account_updates0 ~f:(fun account_update -> + assert (List.is_empty account_update.body.sequence_events) ) ; assert (Option.is_some account0) ; (* sequence state unmodified *) let seq_state_elts0, last_seq_slot0 = @@ -210,19 +221,24 @@ let%test_module "Sequence events test" = Zkapp_account.Sequence_events.empty_state_element ) ) ; (* last seq slot is 0 *) assert (Mina_numbers.Global_slot.(equal zero) last_seq_slot0) ; - let parties1, account1 = + let zkapp_command1, account1 = let ledger = create_ledger () in [] - |> Parties.Call_forest.cons_tree Add_sequence_events.party - |> Parties.Call_forest.cons_tree Initialize_party.party - |> Parties.Call_forest.cons Deploy_party.party - |> test_parties ~ledger + |> Zkapp_command.Call_forest.cons_tree + Add_sequence_events.account_update + |> Zkapp_command.Call_forest.cons_tree + Initialize_account_update.account_update + |> Zkapp_command.Call_forest.cons Deploy_account_update.account_update + |> test_zkapp_command ~ledger in assert (Option.is_some account1) ; - let other_parties1 = Parties.Call_forest.to_list parties1.other_parties in - List.iteri other_parties1 ~f:(fun i party -> - if i > 1 then assert (not @@ List.is_empty party.body.sequence_events) - else assert (List.is_empty party.body.sequence_events) ) ; + let account_updates1 = + Zkapp_command.Call_forest.to_list zkapp_command1.account_updates + in + List.iteri account_updates1 ~f:(fun i account_update -> + if i > 1 then + assert (not @@ List.is_empty account_update.body.sequence_events) + else assert (List.is_empty account_update.body.sequence_events) ) ; let seq_state_elts1, last_seq_slot1 = seq_state_elts_of_account account1 in @@ -252,13 +268,15 @@ let%test_module "Sequence events test" = in let ledger = create_ledger () in let slot1 = Mina_numbers.Global_slot.of_int 1 in - let _parties0, account0 = + let _zkapp_command0, account0 = let state_body = make_state_body slot1 in [] - |> Parties.Call_forest.cons_tree Add_sequence_events.party - |> Parties.Call_forest.cons_tree Initialize_party.party - |> Parties.Call_forest.cons Deploy_party.party - |> test_parties ~state_body ~ledger + |> Zkapp_command.Call_forest.cons_tree + Add_sequence_events.account_update + |> Zkapp_command.Call_forest.cons_tree + Initialize_account_update.account_update + |> Zkapp_command.Call_forest.cons Deploy_account_update.account_update + |> test_zkapp_command ~state_body ~ledger in assert (Option.is_some account0) ; let seq_state_elts0, last_seq_slot0 = @@ -282,11 +300,12 @@ let%test_module "Sequence events test" = (* seq slot is 1 *) assert (Mina_numbers.Global_slot.equal slot1 last_seq_slot0) ; let slot2 = Mina_numbers.Global_slot.of_int 2 in - let _parties1, account1 = + let _zkapp_command1, account1 = let state_body = make_state_body slot2 in [] - |> Parties.Call_forest.cons_tree Add_sequence_events.party - |> test_parties ~state_body ~fee_payer_nonce:1 ~ledger + |> Zkapp_command.Call_forest.cons_tree + Add_sequence_events.account_update + |> test_zkapp_command ~state_body ~fee_payer_nonce:1 ~ledger in assert (Option.is_some account1) ; let seq_state_elts1, last_seq_slot1 = @@ -314,11 +333,12 @@ let%test_module "Sequence events test" = (* seq slot is 2 *) assert (Mina_numbers.Global_slot.equal slot2 last_seq_slot1) ; let slot3 = Mina_numbers.Global_slot.of_int 3 in - let _parties2, account2 = + let _zkapp_command2, account2 = let state_body = make_state_body slot3 in [] - |> Parties.Call_forest.cons_tree Add_sequence_events.party - |> test_parties ~state_body ~fee_payer_nonce:2 ~ledger + |> Zkapp_command.Call_forest.cons_tree + Add_sequence_events.account_update + |> test_zkapp_command ~state_body ~fee_payer_nonce:2 ~ledger in assert (Option.is_some account2) ; let seq_state_elts2, last_seq_slot2 = diff --git a/src/lib/transaction_snark/transaction_snark.ml b/src/lib/transaction_snark/transaction_snark.ml index 0010c27e6bb..891ba07c68d 100644 --- a/src/lib/transaction_snark/transaction_snark.ml +++ b/src/lib/transaction_snark/transaction_snark.ml @@ -22,8 +22,8 @@ let to_preunion (t : Transaction.t) = `Transaction (Fee_transfer x) | Coinbase x -> `Transaction (Coinbase x) - | Command (Parties x) -> - `Parties x + | Command (Zkapp_command x) -> + `Zkapp_command x let with_top_hash_logging f = let old = !top_hash_logging_enabled in @@ -411,7 +411,7 @@ let chain if_ b ~then_ ~else_ = let%bind then_ = then_ and else_ = else_ in if_ b ~then_ ~else_ -module Parties_segment = struct +module Zkapp_command_segment = struct module Spec = struct type single = { auth_type : Control.Tag.t @@ -444,7 +444,8 @@ module Parties_segment = struct ] -> Opt_signed_opt_signed | _ -> - failwith "Parties_segment.Basic.of_controls: Unsupported combination" + failwith + "Zkapp_command_segment.Basic.of_controls: Unsupported combination" let opt_signed ~is_start : Spec.single = { auth_type = Signature; is_start } @@ -481,7 +482,7 @@ module Parties_segment = struct [ { auth_type = Proof; is_start = `No } ] end - module Witness = Transaction_witness.Parties_segment_witness + module Witness = Transaction_witness.Zkapp_command_segment_witness end (* Currently, a circuit must have at least 1 of every type of constraint. *) @@ -919,8 +920,8 @@ module Base = struct Schnorr.Chunked.Checked.verifies shifted signature pk (Random_oracle.Input.Chunked.field payload_digest) - module Parties_snark = struct - open Parties_segment + module Zkapp_command_snark = struct + open Zkapp_command_segment open Spec module Global_state = struct @@ -949,9 +950,11 @@ module Base = struct val set_zkapp_input : Zkapp_statement.Checked.t -> unit end - type party = Zkapp_call_forest.Checked.party = - { party : - (Party.Body.Checked.t, Parties.Digest.Party.Checked.t) With_hash.t + type account_update = Zkapp_call_forest.Checked.account_update = + { account_update : + ( Account_update.Body.Checked.t + , Zkapp_command.Digest.Account_update.Checked.t ) + With_hash.t ; control : Control.t Prover_value.t } @@ -964,15 +967,17 @@ module Base = struct let if_ = Field.if_ - let empty = Field.constant Parties.Transaction_commitment.empty + let empty = Field.constant Zkapp_command.Transaction_commitment.empty - let commitment ~other_parties:{ With_hash.hash = other_parties_hash; _ } - = - Parties.Transaction_commitment.Checked.create ~other_parties_hash + let commitment + ~account_updates:{ With_hash.hash = account_updates_hash; _ } = + Zkapp_command.Transaction_commitment.Checked.create + ~account_updates_hash - let full_commitment ~party:{ party; _ } ~memo_hash ~commitment = - Parties.Transaction_commitment.Checked.create_complete commitment - ~memo_hash ~fee_payer_hash:party.hash + let full_commitment ~account_update:{ account_update; _ } ~memo_hash + ~commitment = + Zkapp_command.Transaction_commitment.Checked.create_complete + commitment ~memo_hash ~fee_payer_hash:account_update.hash end module Bool = struct @@ -1074,13 +1079,14 @@ module Base = struct type nonrec t = t module Elt = struct - type t = Parties_elt.t + type t = Zkapp_command_elt.t - let of_transaction_commitment tc = Parties_elt.Parties_commitment tc + let of_transaction_commitment tc = + Zkapp_command_elt.Zkapp_command_commitment tc end - let cons_parties_commitment index elt t = - run_checked (cons_parties_commitment index elt t) + let cons_zkapp_command_commitment index elt t = + run_checked (cons_zkapp_command_commitment index elt t) let if_ b ~then_ ~else_ = run_checked (if_ b ~then_ ~else_) end @@ -1101,9 +1107,10 @@ module Base = struct module Sequence_events = struct type t = Zkapp_account.Sequence_events.var - let is_empty x = run_checked (Party.Sequence_events.is_empty_var x) + let is_empty x = + run_checked (Account_update.Sequence_events.is_empty_var x) - let push_events = Party.Sequence_events.push_events_checked + let push_events = Account_update.Sequence_events.push_events_checked end module Zkapp_uri = struct @@ -1331,7 +1338,8 @@ module Base = struct ; hash = lazy (Stack_frame.Digest.Checked.create - ~hash_parties:(fun (calls : Call_forest.t) -> calls.hash) + ~hash_zkapp_command:(fun (calls : Call_forest.t) -> + calls.hash ) frame ) } @@ -1343,7 +1351,7 @@ module Base = struct let unhash (h : Stack_frame.Digest.Checked.t) (frame : ( Mina_base.Token_id.Stable.V1.t - , Mina_base.Parties.Call_forest.With_hashes.Stable.V1.t ) + , Mina_base.Zkapp_command.Call_forest.With_hashes.Stable.V1.t ) Stack_frame.Stable.V1.t V.t ) : t = with_label "unhash" (fun () -> @@ -1356,10 +1364,10 @@ module Base = struct (V.get frame).caller_caller ) ; calls = { hash = - exists Mina_base.Parties.Digest.Forest.typ + exists Mina_base.Zkapp_command.Digest.Forest.typ ~compute:(fun () -> (V.get frame).calls - |> Mina_base.Parties.Call_forest.hash ) + |> Mina_base.Zkapp_command.Call_forest.hash ) ; data = V.map frame ~f:(fun frame -> frame.calls) } } @@ -1377,10 +1385,10 @@ module Base = struct type frame = ( caller - , ( Party.t - , Parties.Digest.Party.t - , Parties.Digest.Forest.t ) - Parties.Call_forest.t ) + , ( Account_update.t + , Zkapp_command.Digest.Account_update.t + , Zkapp_command.Digest.Forest.t ) + Zkapp_command.Call_forest.t ) Stack_frame.t end @@ -1425,9 +1433,10 @@ module Base = struct let elt : Stack_frame.frame = let calls : Call_forest.t = { hash = - exists Mina_base.Parties.Digest.Forest.typ ~compute:(fun () -> + exists Mina_base.Zkapp_command.Digest.Forest.typ + ~compute:(fun () -> (V.get elt_ref).data.calls - |> Mina_base.Parties.Call_forest.hash ) + |> Mina_base.Zkapp_command.Call_forest.hash ) ; data = V.map elt_ref ~f:(fun frame -> frame.data.calls) } and caller = @@ -1583,7 +1592,7 @@ module Base = struct , Transaction_commitment.t , Index.t , Bool.failure_status_tbl ) - Mina_transaction_logic.Parties_logic.Local_state.t + Mina_transaction_logic.Zkapp_command_logic.Local_state.t let add_check (t : t) _failure b = { t with success = Bool.(t.success &&& b) } @@ -1675,14 +1684,16 @@ module Base = struct let idx ledger id = Sparse_ledger.find_index_exn ledger id - let body_id (body : Party.Body.Checked.t) = + let body_id (body : Account_update.Body.Checked.t) = let open As_prover in Mina_base.Account_id.create (read Signature_lib.Public_key.Compressed.typ body.public_key) (read Mina_base.Token_id.typ body.token_id) - let get_account { party; _ } ((_root, ledger) : t) = - let idx = V.map ledger ~f:(fun l -> idx l (body_id party.data)) in + let get_account { account_update; _ } ((_root, ledger) : t) = + let idx = + V.map ledger ~f:(fun l -> idx l (body_id account_update.data)) + in let account = exists Mina_base.Account.Checked.Unhashed.typ ~compute:(fun () -> Sparse_ledger.get_exn (V.get ledger) (V.get idx) ) @@ -1745,8 +1756,8 @@ module Base = struct `Is_new is_new end - module Party = struct - type t = party + module Account_update = struct + type t = account_update type call_forest = Call_forest.t @@ -1754,31 +1765,32 @@ module Base = struct type transaction_commitment = Transaction_commitment.t - let balance_change (t : t) = t.party.data.balance_change + let balance_change (t : t) = t.account_update.data.balance_change let protocol_state_precondition (t : t) = - t.party.data.preconditions.network + t.account_update.data.preconditions.network - let token_id (t : t) = t.party.data.token_id + let token_id (t : t) = t.account_update.data.token_id - let public_key (t : t) = t.party.data.public_key + let public_key (t : t) = t.account_update.data.public_key - let caller (t : t) = t.party.data.caller + let caller (t : t) = t.account_update.data.caller let account_id (t : t) = Account_id.create (public_key t) (token_id t) - let use_full_commitment (t : t) = t.party.data.use_full_commitment + let use_full_commitment (t : t) = + t.account_update.data.use_full_commitment - let increment_nonce (t : t) = t.party.data.increment_nonce + let increment_nonce (t : t) = t.account_update.data.increment_nonce let check_authorization ~commitment ~calls:({ hash = calls; _ } : Call_forest.t) - ({ party; control; _ } : t) = + ({ account_update; control; _ } : t) = let proof_verifies = match auth_type with | Proof -> set_zkapp_input - { party = (party.hash :> Field.t) + { account_update = (account_update.hash :> Field.t) ; calls = (calls :> Field.t) } ; Boolean.true_ @@ -1808,7 +1820,7 @@ module Base = struct signature_verifies ~shifted:(module S) ~payload_digest:commitment signature - party.data.public_key ) + account_update.data.public_key ) in ( `Proof_verifies proof_verifies , `Signature_verifies signature_verifies ) @@ -1818,32 +1830,40 @@ module Base = struct type 'a set_or_keep = 'a Set_or_keep.Checked.t - let timing ({ party; _ } : t) : Account.timing set_or_keep = + let timing ({ account_update; _ } : t) : Account.timing set_or_keep + = Set_or_keep.Checked.map - ~f:Party.Update.Timing_info.Checked.to_account_timing - party.data.update.timing + ~f:Account_update.Update.Timing_info.Checked.to_account_timing + account_update.data.update.timing - let app_state ({ party; _ } : t) = party.data.update.app_state + let app_state ({ account_update; _ } : t) = + account_update.data.update.app_state - let verification_key ({ party; _ } : t) = - party.data.update.verification_key + let verification_key ({ account_update; _ } : t) = + account_update.data.update.verification_key - let sequence_events ({ party; _ } : t) = party.data.sequence_events + let sequence_events ({ account_update; _ } : t) = + account_update.data.sequence_events - let zkapp_uri ({ party; _ } : t) = party.data.update.zkapp_uri + let zkapp_uri ({ account_update; _ } : t) = + account_update.data.update.zkapp_uri - let token_symbol ({ party; _ } : t) = party.data.update.token_symbol + let token_symbol ({ account_update; _ } : t) = + account_update.data.update.token_symbol - let delegate ({ party; _ } : t) = party.data.update.delegate + let delegate ({ account_update; _ } : t) = + account_update.data.update.delegate - let voting_for ({ party; _ } : t) = party.data.update.voting_for + let voting_for ({ account_update; _ } : t) = + account_update.data.update.voting_for - let permissions ({ party; _ } : t) = party.data.update.permissions + let permissions ({ account_update; _ } : t) = + account_update.data.update.permissions end module Account_precondition = struct - let nonce ({ party; _ } : t) = - party.data.preconditions.account.nonce + let nonce ({ account_update; _ } : t) = + account_update.data.preconditions.account.nonce end end @@ -1882,7 +1902,7 @@ module Base = struct open Inputs type t = - < party : Party.t + < account_update : Account_update.t ; account : Account.t ; ledger : Ledger.t ; amount : Amount.t @@ -1891,7 +1911,7 @@ module Base = struct ; token_id : Token_id.t ; global_state : Global_state.t ; inclusion_proof : (Bool.t * Field.t) list - ; parties : Parties.t + ; zkapp_command : Zkapp_command.t ; local_state : ( Stack_frame.t , Call_stack.t @@ -1902,7 +1922,7 @@ module Base = struct , Transaction_commitment.t , Index.t , unit ) - Mina_transaction_logic.Parties_logic.Local_state.t + Mina_transaction_logic.Zkapp_command_logic.Local_state.t ; protocol_state_precondition : Zkapp_precondition.Protocol_state.Checked.t ; transaction_commitment : Transaction_commitment.t @@ -1911,29 +1931,30 @@ module Base = struct ; failure : unit > end - include Mina_transaction_logic.Parties_logic.Make (Inputs) + include Mina_transaction_logic.Zkapp_command_logic.Make (Inputs) let perform (type r) - (eff : (r, Env.t) Mina_transaction_logic.Parties_logic.Eff.t) : r = + (eff : (r, Env.t) Mina_transaction_logic.Zkapp_command_logic.Eff.t) : + r = match eff with | Check_protocol_state_precondition (protocol_state_predicate, global_state) -> Zkapp_precondition.Protocol_state.Checked.check protocol_state_predicate global_state.protocol_state | Check_account_precondition - ({ party; _ }, account, new_account, local_state) -> + ({ account_update; _ }, account, new_account, local_state) -> let local_state = ref local_state in let check failure b = local_state := Inputs.Local_state.add_check !local_state failure b in Zkapp_precondition.Account.Checked.check ~new_account ~check - party.data.preconditions.account account.data ; + account_update.data.preconditions.account account.data ; !local_state - | Init_account { party = { party; _ }; account } -> + | Init_account { account_update = { account_update; _ }; account } -> let account' : Account.Checked.Unhashed.t = { account.data with - public_key = party.data.public_key - ; token_id = party.data.token_id + public_key = account_update.data.public_key + ; token_id = account_update.data.token_id } in Inputs.Account.account_with_hash account' @@ -1996,8 +2017,8 @@ module Base = struct ~pending_coinbase_stack_after:statement.target.pending_coinbase_stack state_body ) ; let init : - Global_state.t * _ Mina_transaction_logic.Parties_logic.Local_state.t - = + Global_state.t + * _ Mina_transaction_logic.Zkapp_command_logic.Local_state.t = let g : Global_state.t = { ledger = ( statement.source.ledger @@ -2007,7 +2028,7 @@ module Base = struct Mina_state.Protocol_state.Body.view_checked state_body } in - let l : _ Mina_transaction_logic.Parties_logic.Local_state.t = + let l : _ Mina_transaction_logic.Zkapp_command_logic.Local_state.t = { stack_frame = Inputs.Stack_frame.unhash statement.source.local_state.stack_frame (V.create (fun () -> !witness.local_state_init.stack_frame)) @@ -2025,41 +2046,43 @@ module Base = struct ( statement.source.local_state.ledger , V.create (fun () -> !witness.local_state_init.ledger) ) ; success = statement.source.local_state.success - ; party_index = statement.source.local_state.party_index + ; account_update_index = + statement.source.local_state.account_update_index ; failure_status_tbl = () } in (g, l) in - let start_parties = - As_prover.Ref.create (fun () -> !witness.start_parties) + let start_zkapp_command = + As_prover.Ref.create (fun () -> !witness.start_zkapp_command) in let zkapp_input = ref None in let global, local = - List.fold_left spec ~init ~f:(fun ((_, local) as acc) party_spec -> + List.fold_left spec ~init + ~f:(fun ((_, local) as acc) account_update_spec -> let module S = Single (struct let constraint_constants = constraint_constants - let spec = party_spec + let spec = account_update_spec let set_zkapp_input x = zkapp_input := Some x end) in let finish v = - let open Mina_transaction_logic.Parties_logic.Start_data in + let open Mina_transaction_logic.Zkapp_command_logic.Start_data in let ps = V.map v ~f:(function | `Skip -> [] | `Start p -> - Parties.parties p.parties ) + Zkapp_command.zkapp_command p.zkapp_command ) in let h = - exists Parties.Digest.Forest.typ ~compute:(fun () -> - Parties.Call_forest.hash (V.get ps) ) + exists Zkapp_command.Digest.Forest.typ ~compute:(fun () -> + Zkapp_command.Call_forest.hash (V.get ps) ) in let start_data = - { Mina_transaction_logic.Parties_logic.Start_data.parties = - { With_hash.hash = h; data = ps } + { Mina_transaction_logic.Zkapp_command_logic.Start_data + .zkapp_command = { With_hash.hash = h; data = ps } ; memo_hash = exists Field.typ ~compute:(fun () -> match V.get v with @@ -2073,7 +2096,7 @@ module Base = struct with_label "apply" (fun () -> S.apply ~constraint_constants ~is_start: - ( match party_spec.is_start with + ( match account_update_spec.is_start with | `No -> `No | `Yes -> @@ -2087,7 +2110,7 @@ module Base = struct (global_state, { local_state with failure_status_tbl = () }) in let acc' = - match party_spec.is_start with + match account_update_spec.is_start with | `No -> let global_state, local_state = S.apply ~constraint_constants ~is_start:`No @@ -2098,30 +2121,30 @@ module Base = struct (global_state, { local_state with failure_status_tbl = () }) | `Compute_in_circuit -> V.create (fun () -> - match As_prover.Ref.get start_parties with + match As_prover.Ref.get start_zkapp_command with | [] -> `Skip | p :: ps -> let should_pop = - Mina_base.Parties.Call_forest.is_empty + Mina_base.Zkapp_command.Call_forest.is_empty (V.get local.stack_frame.data.calls.data) in if should_pop then ( - As_prover.Ref.set start_parties ps ; + As_prover.Ref.set start_zkapp_command ps ; `Start p ) else `Skip ) |> finish | `Yes -> as_prover (fun () -> assert ( - Mina_base.Parties.Call_forest.is_empty + Mina_base.Zkapp_command.Call_forest.is_empty (V.get local.stack_frame.data.calls.data) ) ) ; V.create (fun () -> - match As_prover.Ref.get start_parties with + match As_prover.Ref.get start_zkapp_command with | [] -> assert false | p :: ps -> - As_prover.Ref.set start_parties ps ; + As_prover.Ref.set start_zkapp_command ps ; `Start p ) |> finish in @@ -3350,14 +3373,14 @@ let system ~proof_level ~constraint_constants = (Genesis_constants.Constraint_constants.to_snark_keys_header constraint_constants ) ~choices:(fun ~self -> - let parties x = - Base.Parties_snark.rule ~constraint_constants ~proof_level x + let zkapp_command x = + Base.Zkapp_command_snark.rule ~constraint_constants ~proof_level x in [ Base.rule ~constraint_constants ; Merge.rule ~proof_level self - ; parties Opt_signed_opt_signed - ; parties Opt_signed - ; parties Proved + ; zkapp_command Opt_signed_opt_signed + ; zkapp_command Opt_signed + ; zkapp_command Proved ] ) ) module Verification = struct @@ -3383,7 +3406,7 @@ module type S = sig val cache_handle : Pickles.Cache_handle.t - val of_non_parties_transaction : + val of_non_zkapp_command_transaction : statement:Statement.With_sok.t -> init_stack:Pending_coinbase.Stack.t -> Transaction.Valid.t Transaction_protocol_state.t @@ -3404,10 +3427,10 @@ module type S = sig -> Tick.Handler.t -> t Async.Deferred.t - val of_parties_segment_exn : + val of_zkapp_command_segment_exn : statement:Statement.With_sok.t - -> witness:Parties_segment.Witness.t - -> spec:Parties_segment.Basic.t + -> witness:Zkapp_command_segment.Witness.t + -> spec:Zkapp_command_segment.Basic.t -> t Async.Deferred.t val merge : @@ -3451,8 +3474,9 @@ let check_transaction ?preeval ~constraint_constants ~sok_message ~source in let state_body = Transaction_protocol_state.block_data transaction_in_block in match to_preunion (Transaction.forget transaction) with - | `Parties _ -> - failwith "Called non-party transaction with parties transaction" + | `Zkapp_command _ -> + failwith + "Called non-account_update transaction with zkapp_command transaction" | `Transaction t -> check_transaction_union ?preeval ~constraint_constants ~supply_increase sok_message source target init_stack pending_coinbase_stack_state @@ -3503,8 +3527,9 @@ let generate_transaction_witness ?preeval ~constraint_constants ~sok_message (Transaction.forget (Transaction_protocol_state.transaction transaction_in_block) ) with - | `Parties _ -> - failwith "Called non-party transaction with parties transaction" + | `Zkapp_command _ -> + failwith + "Called non-account_update transaction with zkapp_command transaction" | `Transaction t -> generate_transaction_union_witness ?preeval ~constraint_constants ~supply_increase sok_message source target @@ -3551,262 +3576,295 @@ type local_state = , Currency.Amount.Signed.t , Sparse_ledger.t , bool - , Parties.Transaction_commitment.t + , Zkapp_command.Transaction_commitment.t , Mina_numbers.Index.t , Transaction_status.Failure.Collection.t ) - Mina_transaction_logic.Parties_logic.Local_state.t + Mina_transaction_logic.Zkapp_command_logic.Local_state.t type global_state = Sparse_ledger.Global_state.t -module Parties_intermediate_state = struct +module Zkapp_command_intermediate_state = struct type state = { global : global_state; local : local_state } type t = { kind : [ `Same | `New | `Two_new ] - ; spec : Parties_segment.Basic.t + ; spec : Zkapp_command_segment.Basic.t ; state_before : state ; state_after : state } end -(** [group_by_parties_rev partiess stmtss] identifies before/after pairs of - statements, corresponding to parties in [partiess] which minimize the - number of snark proofs needed to prove all of the parties. +(** [group_by_zkapp_command_rev zkapp_commands stmtss] identifies before/after pairs of + statements, corresponding to zkapp_command in [zkapp_commands] which minimize the + number of snark proofs needed to prove all of the zkapp_command. - This function is intended to take the parties from multiple transactions as - its input, which may be converted from a [Parties.t list] using - [List.map ~f:Parties.parties]. The [stmtss] argument should be a list of - the same length, with 1 more state than the number of parties for each + This function is intended to take the zkapp_command from multiple transactions as + its input, which may be converted from a [Zkapp_command.t list] using + [List.map ~f:Zkapp_command.zkapp_command]. The [stmtss] argument should be a list of + the same length, with 1 more state than the number of zkapp_command for each transaction. - For example, two transactions made up of parties [[p1; p2; p3]] and + For example, two transactions made up of zkapp_command [[p1; p2; p3]] and [[p4; p5]] should have the statements [[[s0; s1; s2; s3]; [s3; s4; s5]]], where each [s_n] is the state after applying [p_n] on top of [s_{n-1}], and where [s0] is the initial state before any of the transactions have been applied. Each pair is also identified with one of [`Same], [`New], or [`Two_new], - indicating that the next one ([`New]) or next two ([`Two_new]) [Parties.t]s + indicating that the next one ([`New]) or next two ([`Two_new]) [Zkapp_command.t]s will need to be passed as part of the snark witness while applying that pair. *) -let group_by_parties_rev (partiess : Party.t list list) +let group_by_zkapp_command_rev (zkapp_commands : Account_update.t list list) (stmtss : (global_state * local_state) list list) : - Parties_intermediate_state.t list = + Zkapp_command_intermediate_state.t list = let intermediate_state ~kind ~spec ~before ~after = - { Parties_intermediate_state.kind + { Zkapp_command_intermediate_state.kind ; spec ; state_before = { global = fst before; local = snd before } ; state_after = { global = fst after; local = snd after } } in - let rec group_by_parties_rev (partiess : Party.t list list) stmtss acc = - match (partiess, stmtss) with + let rec group_by_zkapp_command_rev + (zkapp_commands : Account_update.t list list) stmtss acc = + match (zkapp_commands, stmtss) with | ([] | [ [] ]), [ _ ] -> - (* We've associated statements with all given parties. *) + (* We've associated statements with all given zkapp_command. *) acc | [ [ { authorization = a1; _ } ] ], [ [ before; after ] ] -> - (* There are no later parties to pair this one with. Prove it on its + (* There are no later zkapp_command to pair this one with. Prove it on its own. *) intermediate_state ~kind:`Same - ~spec:(Parties_segment.Basic.of_controls [ a1 ]) + ~spec:(Zkapp_command_segment.Basic.of_controls [ a1 ]) ~before ~after :: acc | [ []; [ { authorization = a1; _ } ] ], [ [ _ ]; [ before; after ] ] -> - (* This party is part of a new transaction, and there are no later - parties to pair it with. Prove it on its own. + (* This account_update is part of a new transaction, and there are no later + zkapp_command to pair it with. Prove it on its own. *) intermediate_state ~kind:`New - ~spec:(Parties_segment.Basic.of_controls [ a1 ]) + ~spec:(Zkapp_command_segment.Basic.of_controls [ a1 ]) ~before ~after :: acc - | ( ({ authorization = Proof _ as a1; _ } :: parties) :: partiess + | ( ({ authorization = Proof _ as a1; _ } :: zkapp_command) :: zkapp_commands , (before :: (after :: _ as stmts)) :: stmtss ) -> - (* This party contains a proof, don't pair it with other parties. *) - group_by_parties_rev (parties :: partiess) (stmts :: stmtss) + (* This account_update contains a proof, don't pair it with other zkapp_command. *) + group_by_zkapp_command_rev + (zkapp_command :: zkapp_commands) + (stmts :: stmtss) ( intermediate_state ~kind:`Same - ~spec:(Parties_segment.Basic.of_controls [ a1 ]) + ~spec:(Zkapp_command_segment.Basic.of_controls [ a1 ]) ~before ~after :: acc ) - | ( [] :: ({ authorization = Proof _ as a1; _ } :: parties) :: partiess + | ( [] + :: ({ authorization = Proof _ as a1; _ } :: zkapp_command) + :: zkapp_commands , [ _ ] :: (before :: (after :: _ as stmts)) :: stmtss ) -> - (* This party is part of a new transaction, and contains a proof, don't - pair it with other parties. + (* This account_update is part of a new transaction, and contains a proof, don't + pair it with other zkapp_command. *) - group_by_parties_rev (parties :: partiess) (stmts :: stmtss) + group_by_zkapp_command_rev + (zkapp_command :: zkapp_commands) + (stmts :: stmtss) ( intermediate_state ~kind:`New - ~spec:(Parties_segment.Basic.of_controls [ a1 ]) + ~spec:(Zkapp_command_segment.Basic.of_controls [ a1 ]) ~before ~after :: acc ) | ( ({ authorization = a1; _ } - :: ({ authorization = Proof _; _ } :: _ as parties) ) - :: partiess + :: ({ authorization = Proof _; _ } :: _ as zkapp_command) ) + :: zkapp_commands , (before :: (after :: _ as stmts)) :: stmtss ) -> - (* The next party contains a proof, don't pair it with this party. *) - group_by_parties_rev (parties :: partiess) (stmts :: stmtss) + (* The next account_update contains a proof, don't pair it with this account_update. *) + group_by_zkapp_command_rev + (zkapp_command :: zkapp_commands) + (stmts :: stmtss) ( intermediate_state ~kind:`Same - ~spec:(Parties_segment.Basic.of_controls [ a1 ]) + ~spec:(Zkapp_command_segment.Basic.of_controls [ a1 ]) ~before ~after :: acc ) - | ( ({ authorization = a1; _ } :: ([] as parties)) - :: (({ authorization = Proof _; _ } :: _) :: _ as partiess) + | ( ({ authorization = a1; _ } :: ([] as zkapp_command)) + :: (({ authorization = Proof _; _ } :: _) :: _ as zkapp_commands) , (before :: (after :: _ as stmts)) :: stmtss ) -> - (* The next party is in the next transaction and contains a proof, - don't pair it with this party. + (* The next account_update is in the next transaction and contains a proof, + don't pair it with this account_update. *) - group_by_parties_rev (parties :: partiess) (stmts :: stmtss) + group_by_zkapp_command_rev + (zkapp_command :: zkapp_commands) + (stmts :: stmtss) ( intermediate_state ~kind:`Same - ~spec:(Parties_segment.Basic.of_controls [ a1 ]) + ~spec:(Zkapp_command_segment.Basic.of_controls [ a1 ]) ~before ~after :: acc ) | ( ({ authorization = (Signature _ | None_given) as a1; _ } - :: { authorization = (Signature _ | None_given) as a2; _ } :: parties ) - :: partiess + :: { authorization = (Signature _ | None_given) as a2; _ } + :: zkapp_command ) + :: zkapp_commands , (before :: _ :: (after :: _ as stmts)) :: stmtss ) -> - (* The next two parties do not contain proofs, and are within the same + (* The next two zkapp_command do not contain proofs, and are within the same transaction. Pair them. Ok to get "use_full_commitment" of [a1] because neither of them contain a proof. *) - group_by_parties_rev (parties :: partiess) (stmts :: stmtss) + group_by_zkapp_command_rev + (zkapp_command :: zkapp_commands) + (stmts :: stmtss) ( intermediate_state ~kind:`Same - ~spec:(Parties_segment.Basic.of_controls [ a1; a2 ]) + ~spec:(Zkapp_command_segment.Basic.of_controls [ a1; a2 ]) ~before ~after :: acc ) | ( [] :: ({ authorization = a1; _ } - :: ({ authorization = Proof _; _ } :: _ as parties) ) - :: partiess + :: ({ authorization = Proof _; _ } :: _ as zkapp_command) ) + :: zkapp_commands , [ _ ] :: (before :: (after :: _ as stmts)) :: stmtss ) -> - (* This party is in the next transaction, and the next party contains a - proof, don't pair it with this party. + (* This account_update is in the next transaction, and the next account_update contains a + proof, don't pair it with this account_update. *) - group_by_parties_rev (parties :: partiess) (stmts :: stmtss) + group_by_zkapp_command_rev + (zkapp_command :: zkapp_commands) + (stmts :: stmtss) ( intermediate_state ~kind:`New - ~spec:(Parties_segment.Basic.of_controls [ a1 ]) + ~spec:(Zkapp_command_segment.Basic.of_controls [ a1 ]) ~before ~after :: acc ) | ( [] :: ({ authorization = (Signature _ | None_given) as a1; _ } - :: { authorization = (Signature _ | None_given) as a2; _ } :: parties - ) - :: partiess + :: { authorization = (Signature _ | None_given) as a2; _ } + :: zkapp_command ) + :: zkapp_commands , [ _ ] :: (before :: _ :: (after :: _ as stmts)) :: stmtss ) -> - (* The next two parties do not contain proofs, and are within the same + (* The next two zkapp_command do not contain proofs, and are within the same new transaction. Pair them. Ok to get "use_full_commitment" of [a1] because neither of them contain a proof. *) - group_by_parties_rev (parties :: partiess) (stmts :: stmtss) + group_by_zkapp_command_rev + (zkapp_command :: zkapp_commands) + (stmts :: stmtss) ( intermediate_state ~kind:`New - ~spec:(Parties_segment.Basic.of_controls [ a1; a2 ]) + ~spec:(Zkapp_command_segment.Basic.of_controls [ a1; a2 ]) ~before ~after :: acc ) | ( [ { authorization = (Signature _ | None_given) as a1; _ } ] - :: ({ authorization = (Signature _ | None_given) as a2; _ } :: parties) - :: partiess + :: ({ authorization = (Signature _ | None_given) as a2; _ } + :: zkapp_command ) + :: zkapp_commands , (before :: _after1) :: (_before2 :: (after :: _ as stmts)) :: stmtss ) -> - (* The next two parties do not contain proofs, and the second is within + (* The next two zkapp_command do not contain proofs, and the second is within a new transaction. Pair them. Ok to get "use_full_commitment" of [a1] because neither of them contain a proof. *) - group_by_parties_rev (parties :: partiess) (stmts :: stmtss) + group_by_zkapp_command_rev + (zkapp_command :: zkapp_commands) + (stmts :: stmtss) ( intermediate_state ~kind:`New - ~spec:(Parties_segment.Basic.of_controls [ a1; a2 ]) + ~spec:(Zkapp_command_segment.Basic.of_controls [ a1; a2 ]) ~before ~after :: acc ) | ( [] - :: ({ authorization = a1; _ } :: parties) - :: (({ authorization = Proof _; _ } :: _) :: _ as partiess) + :: ({ authorization = a1; _ } :: zkapp_command) + :: (({ authorization = Proof _; _ } :: _) :: _ as zkapp_commands) , [ _ ] :: (before :: ([ after ] as stmts)) :: (_ :: _ as stmtss) ) -> - (* The next transaction contains a proof, and this party is in a new - transaction, don't pair it with the next party. + (* The next transaction contains a proof, and this account_update is in a new + transaction, don't pair it with the next account_update. *) - group_by_parties_rev (parties :: partiess) (stmts :: stmtss) + group_by_zkapp_command_rev + (zkapp_command :: zkapp_commands) + (stmts :: stmtss) ( intermediate_state ~kind:`New - ~spec:(Parties_segment.Basic.of_controls [ a1 ]) + ~spec:(Zkapp_command_segment.Basic.of_controls [ a1 ]) ~before ~after :: acc ) | ( [] :: [ { authorization = (Signature _ | None_given) as a1; _ } ] :: ({ authorization = (Signature _ | None_given) as a2; _ } - :: parties ) - :: partiess + :: zkapp_command ) + :: zkapp_commands , [ _ ] :: [ before; _after1 ] :: (_before2 :: (after :: _ as stmts)) :: stmtss ) -> - (* The next two parties do not contain proofs, the first is within a + (* The next two zkapp_command do not contain proofs, the first is within a new transaction, and the second is within another new transaction. Pair them. Ok to get "use_full_commitment" of [a1] because neither of them contain a proof. *) - group_by_parties_rev (parties :: partiess) (stmts :: stmtss) + group_by_zkapp_command_rev + (zkapp_command :: zkapp_commands) + (stmts :: stmtss) ( intermediate_state ~kind:`Two_new - ~spec:(Parties_segment.Basic.of_controls [ a1; a2 ]) + ~spec:(Zkapp_command_segment.Basic.of_controls [ a1; a2 ]) ~before ~after :: acc ) | [ [ { authorization = a1; _ } ] ], (before :: after :: _) :: _ -> - (* This party is the final party given. Prove it on its own. *) + (* This account_update is the final account_update given. Prove it on its own. *) intermediate_state ~kind:`Same - ~spec:(Parties_segment.Basic.of_controls [ a1 ]) + ~spec:(Zkapp_command_segment.Basic.of_controls [ a1 ]) ~before ~after :: acc | ( [] :: [ { authorization = a1; _ } ] :: [] :: _ , [ _ ] :: (before :: after :: _) :: _ ) -> - (* This party is the final party given, in a new transaction. Prove it + (* This account_update is the final account_update given, in a new transaction. Prove it on its own. *) intermediate_state ~kind:`New - ~spec:(Parties_segment.Basic.of_controls [ a1 ]) + ~spec:(Zkapp_command_segment.Basic.of_controls [ a1 ]) ~before ~after :: acc | _, [] -> - failwith "group_by_parties_rev: No statements remaining" + failwith "group_by_zkapp_command_rev: No statements remaining" | ([] | [ [] ]), _ -> - failwith "group_by_parties_rev: Unmatched statements remaining" + failwith "group_by_zkapp_command_rev: Unmatched statements remaining" | [] :: _, [] :: _ -> failwith - "group_by_parties_rev: No final statement for current transaction" + "group_by_zkapp_command_rev: No final statement for current \ + transaction" | [] :: _, (_ :: _ :: _) :: _ -> failwith - "group_by_parties_rev: Unmatched statements for current transaction" + "group_by_zkapp_command_rev: Unmatched statements for current \ + transaction" | [] :: [ _ ] :: _, [ _ ] :: (_ :: _ :: _ :: _) :: _ -> failwith - "group_by_parties_rev: Unmatched statements for next transaction" + "group_by_zkapp_command_rev: Unmatched statements for next \ + transaction" | [ []; [ _ ] ], [ _ ] :: [ _; _ ] :: _ :: _ -> failwith - "group_by_parties_rev: Unmatched statements after next transaction" + "group_by_zkapp_command_rev: Unmatched statements after next \ + transaction" | (_ :: _) :: _, ([] | [ _ ]) :: _ | (_ :: _ :: _) :: _, [ _; _ ] :: _ -> failwith - "group_by_parties_rev: Too few statements remaining for the current \ - transaction" + "group_by_zkapp_command_rev: Too few statements remaining for the \ + current transaction" | ([] | [ _ ]) :: [] :: _, _ -> - failwith "group_by_parties_rev: The next transaction has no parties" + failwith + "group_by_zkapp_command_rev: The next transaction has no \ + zkapp_command" | [] :: (_ :: _) :: _, _ :: ([] | [ _ ]) :: _ | [] :: (_ :: _ :: _) :: _, _ :: [ _; _ ] :: _ -> failwith - "group_by_parties_rev: Too few statements remaining for the next \ - transaction" + "group_by_zkapp_command_rev: Too few statements remaining for the \ + next transaction" | [ _ ] :: (_ :: _) :: _, _ :: ([] | [ _ ]) :: _ -> failwith - "group_by_parties_rev: Too few statements remaining for the next \ - transaction" + "group_by_zkapp_command_rev: Too few statements remaining for the \ + next transaction" | [] :: [ _ ] :: (_ :: _) :: _, _ :: _ :: ([] | [ _ ]) :: _ -> failwith - "group_by_parties_rev: Too few statements remaining for the \ + "group_by_zkapp_command_rev: Too few statements remaining for the \ transaction after next" | ([] | [ _ ]) :: (_ :: _) :: _, [ _ ] -> failwith - "group_by_parties_rev: No statements given for the next transaction" + "group_by_zkapp_command_rev: No statements given for the next \ + transaction" | [] :: [ _ ] :: (_ :: _) :: _, [ _; _ :: _ :: _ ] -> failwith - "group_by_parties_rev: No statements given for transaction after next" + "group_by_zkapp_command_rev: No statements given for transaction \ + after next" in - group_by_parties_rev partiess stmtss [] + group_by_zkapp_command_rev zkapp_commands stmtss [] let rec accumulate_call_stack_hashes ~(hash_frame : 'frame -> Stack_frame.Digest.t) (frames : 'frame list) : @@ -3822,29 +3880,31 @@ let rec accumulate_call_stack_hashes in { stack_hash = Call_stack_digest.cons h_f h_tl; elt = f } :: tl -let parties_witnesses_exn ~constraint_constants ~state_body ~fee_excess ledger - (partiess : +let zkapp_command_witnesses_exn ~constraint_constants ~state_body ~fee_excess + ledger + (zkapp_commands : ( [ `Pending_coinbase_init_stack of Pending_coinbase.Stack.t ] * [ `Pending_coinbase_of_statement of Pending_coinbase_stack_state.t ] - * Parties.t ) + * Zkapp_command.t ) list ) = let sparse_ledger = match ledger with | `Ledger ledger -> Sparse_ledger.of_ledger_subset_exn ledger (List.concat_map - ~f:(fun (_, _, parties) -> Parties.accounts_accessed parties) - partiess ) + ~f:(fun (_, _, zkapp_command) -> + Zkapp_command.accounts_accessed zkapp_command ) + zkapp_commands ) | `Sparse_ledger sparse_ledger -> sparse_ledger in let state_view = Mina_state.Protocol_state.Body.view state_body in let _, _, states_rev = - List.fold_left ~init:(fee_excess, sparse_ledger, []) partiess - ~f:(fun (fee_excess, sparse_ledger, statess_rev) (_, _, parties) -> + List.fold_left ~init:(fee_excess, sparse_ledger, []) zkapp_commands + ~f:(fun (fee_excess, sparse_ledger, statess_rev) (_, _, zkapp_command) -> let _, states = - Sparse_ledger.apply_parties_unchecked_with_states sparse_ledger - ~constraint_constants ~state_view ~fee_excess parties + Sparse_ledger.apply_zkapp_command_unchecked_with_states sparse_ledger + ~constraint_constants ~state_view ~fee_excess zkapp_command |> Or_error.ok_exn in let final_state = fst (List.last_exn states) in @@ -3852,30 +3912,34 @@ let parties_witnesses_exn ~constraint_constants ~state_body ~fee_excess ledger in let states = List.rev states_rev in let states_rev = - group_by_parties_rev + group_by_zkapp_command_rev ( [] :: List.map - ~f:(fun (_, _, parties) -> Parties.parties_list parties) - partiess ) + ~f:(fun (_, _, zkapp_command) -> + Zkapp_command.zkapp_command_list zkapp_command ) + zkapp_commands ) ([ List.hd_exn (List.hd_exn states) ] :: states) in let commitment = ref (Local_state.dummy ()).transaction_commitment in let full_commitment = ref (Local_state.dummy ()).full_transaction_commitment in - let remaining_parties = - let partiess = - List.map partiess + let remaining_zkapp_command = + let zkapp_commands = + List.map zkapp_commands ~f:(fun - (pending_coinbase_init_stack, pending_coinbase_stack_state, parties) + ( pending_coinbase_init_stack + , pending_coinbase_stack_state + , zkapp_command ) -> ( pending_coinbase_init_stack , pending_coinbase_stack_state - , { Mina_transaction_logic.Parties_logic.Start_data.parties - ; memo_hash = Signed_command_memo.hash parties.memo + , { Mina_transaction_logic.Zkapp_command_logic.Start_data + .zkapp_command + ; memo_hash = Signed_command_memo.hash zkapp_command.memo } ) ) in - ref partiess + ref zkapp_commands in let pending_coinbase_init_stack = ref Pending_coinbase.Stack.empty in let pending_coinbase_stack_state = @@ -3888,7 +3952,8 @@ let parties_witnesses_exn ~constraint_constants ~state_body ~fee_excess ledger match states_rev with | [] -> sparse_ledger - | { Parties_intermediate_state.state_after = { global = { ledger; _ }; _ } + | { Zkapp_command_intermediate_state.state_after = + { global = { ledger; _ }; _ } ; _ } :: _ -> @@ -3896,7 +3961,7 @@ let parties_witnesses_exn ~constraint_constants ~state_body ~fee_excess ledger in ( List.fold_right states_rev ~init:[] ~f:(fun - { Parties_intermediate_state.kind + { Zkapp_command_intermediate_state.kind ; spec ; state_before = { global = source_global; local = source_local } ; state_after = { global = target_global; local = target_local } @@ -3908,7 +3973,7 @@ let parties_witnesses_exn ~constraint_constants ~state_body ~fee_excess ledger let target_local = { target_local with failure_status_tbl = [] } in let current_commitment = !commitment in let current_full_commitment = !full_commitment in - let ( start_parties + let ( start_zkapp_command , next_commitment , next_full_commitment , pending_coinbase_init_stack @@ -3917,23 +3982,23 @@ let parties_witnesses_exn ~constraint_constants ~state_body ~fee_excess ledger match (target_local.stack_frame.calls, target_local.call_stack) with | [], [] -> (* The commitment will be cleared, because this is the last - party. + account_update. *) - Parties.Transaction_commitment.(empty, empty) + Zkapp_command.Transaction_commitment.(empty, empty) | _ -> mk () in - let mk_next_commitments (parties : Parties.t) = + let mk_next_commitments (zkapp_command : Zkapp_command.t) = empty_if_last (fun () -> - let next_commitment = Parties.commitment parties in - let memo_hash = Signed_command_memo.hash parties.memo in + let next_commitment = Zkapp_command.commitment zkapp_command in + let memo_hash = Signed_command_memo.hash zkapp_command.memo in let fee_payer_hash = - Parties.Digest.Party.create - (Party.of_fee_payer parties.fee_payer) + Zkapp_command.Digest.Account_update.create + (Account_update.of_fee_payer zkapp_command.fee_payer) in let next_full_commitment = - Parties.Transaction_commitment.create_complete next_commitment - ~memo_hash ~fee_payer_hash + Zkapp_command.Transaction_commitment.create_complete + next_commitment ~memo_hash ~fee_payer_hash in (next_commitment, next_full_commitment) ) in @@ -3949,43 +4014,43 @@ let parties_witnesses_exn ~constraint_constants ~state_body ~fee_excess ledger , !pending_coinbase_init_stack , !pending_coinbase_stack_state ) | `New -> ( - match !remaining_parties with + match !remaining_zkapp_command with | ( `Pending_coinbase_init_stack pending_coinbase_init_stack1 , `Pending_coinbase_of_statement pending_coinbase_stack_state1 - , parties ) + , zkapp_command ) :: rest -> let commitment', full_commitment' = - mk_next_commitments parties.parties + mk_next_commitments zkapp_command.zkapp_command in - remaining_parties := rest ; + remaining_zkapp_command := rest ; commitment := commitment' ; full_commitment := full_commitment' ; pending_coinbase_init_stack := pending_coinbase_init_stack1 ; pending_coinbase_stack_state := pending_coinbase_stack_state1 ; - ( [ parties ] + ( [ zkapp_command ] , commitment' , full_commitment' , !pending_coinbase_init_stack , !pending_coinbase_stack_state ) | _ -> - failwith "Not enough remaining parties" ) + failwith "Not enough remaining zkapp_command" ) | `Two_new -> ( - match !remaining_parties with + match !remaining_zkapp_command with | ( `Pending_coinbase_init_stack pending_coinbase_init_stack1 , `Pending_coinbase_of_statement pending_coinbase_stack_state1 - , parties1 ) + , zkapp_command1 ) :: ( `Pending_coinbase_init_stack _pending_coinbase_init_stack2 , `Pending_coinbase_of_statement pending_coinbase_stack_state2 - , parties2 ) + , zkapp_command2 ) :: rest -> let commitment', full_commitment' = - mk_next_commitments parties2.parties + mk_next_commitments zkapp_command2.zkapp_command in - remaining_parties := rest ; + remaining_zkapp_command := rest ; commitment := commitment' ; full_commitment := full_commitment' ; - (*TODO: Remove `Two_new case because the resulting pending_coinbase_init_stack will not be correct for parties2 if it is in a different scan state tree*) + (*TODO: Remove `Two_new case because the resulting pending_coinbase_init_stack will not be correct for zkapp_command2 if it is in a different scan state tree*) pending_coinbase_init_stack := pending_coinbase_init_stack1 ; pending_coinbase_stack_state := { pending_coinbase_stack_state1 with @@ -3993,13 +4058,13 @@ let parties_witnesses_exn ~constraint_constants ~state_body ~fee_excess ledger pending_coinbase_stack_state2 .Pending_coinbase_stack_state.target } ; - ( [ parties1; parties2 ] + ( [ zkapp_command1; zkapp_command2 ] , commitment' , full_commitment' , !pending_coinbase_init_stack , !pending_coinbase_stack_state ) | _ -> - failwith "Not enough remaining parties" ) + failwith "Not enough remaining zkapp_command" ) in let hash_local_state (local : @@ -4012,7 +4077,7 @@ let parties_witnesses_exn ~constraint_constants ~state_body ~fee_excess ledger , _ , _ , _ ) - Mina_transaction_logic.Parties_logic.Local_state.t ) = + Mina_transaction_logic.Zkapp_command_logic.Local_state.t ) = { local with stack_frame = local.stack_frame ; call_stack = @@ -4034,10 +4099,10 @@ let parties_witnesses_exn ~constraint_constants ~state_body ~fee_excess ledger ; full_transaction_commitment = next_full_commitment } in - let w : Parties_segment.Witness.t = + let w : Zkapp_command_segment.Witness.t = { global_ledger = source_global.ledger ; local_state_init = source_local - ; start_parties + ; start_zkapp_command ; state_body ; init_stack = pending_coinbase_init_stack } @@ -4072,10 +4137,10 @@ let parties_witnesses_exn ~constraint_constants ~state_body ~fee_excess ledger let statement : Statement.With_sok.t = (* empty ledger hash in the local state at the beginning of each transaction - `parties` in local state is empty for the first segment*) + `zkapp_command` in local state is empty for the first segment*) let source_local_ledger = - if Parties.Call_forest.is_empty source_local.stack_frame.calls then - Frozen_ledger_hash.empty_hash + if Zkapp_command.Call_forest.is_empty source_local.stack_frame.calls + then Frozen_ledger_hash.empty_hash else Sparse_ledger.merkle_root source_local.ledger in { source = @@ -4143,30 +4208,31 @@ struct (List.map ts ~f:(fun ({ statement; proof }, _) -> (statement, proof))) else Async.return false - let first_party (witness : Transaction_witness.Parties_segment_witness.t) = + let first_account_update + (witness : Transaction_witness.Zkapp_command_segment_witness.t) = match witness.local_state_init.stack_frame.calls with | [] -> with_return (fun { return } -> - List.iter witness.start_parties ~f:(fun s -> - Parties.Call_forest.iteri + List.iter witness.start_zkapp_command ~f:(fun s -> + Zkapp_command.Call_forest.iteri ~f:(fun _i x -> return (Some x)) - s.parties.other_parties ) ; + s.zkapp_command.account_updates ) ; None ) | xs -> - Parties.Call_forest.hd_party xs + Zkapp_command.Call_forest.hd_account_update xs - let party_proof (p : Party.t) = + let account_update_proof (p : Account_update.t) = match p.authorization with | Proof p -> Some p | Signature _ | None_given -> None - let snapp_proof_data ~(witness : Transaction_witness.Parties_segment_witness.t) - = + let snapp_proof_data + ~(witness : Transaction_witness.Zkapp_command_segment_witness.t) = let open Option.Let_syntax in - let%bind p = first_party witness in - let%map pi = party_proof p in + let%bind p = first_account_update witness in + let%map pi = account_update_proof p in let vk = let account_id = Account_id.create p.body.public_key p.body.token_id in let account : Account.t = @@ -4185,9 +4251,9 @@ struct in (pi, vk) - let of_parties_segment_exn ~statement ~witness - ~(spec : Parties_segment.Basic.t) : t Async.Deferred.t = - Base.Parties_snark.witness := Some witness ; + let of_zkapp_command_segment_exn ~statement ~witness + ~(spec : Zkapp_command_segment.Basic.t) : t Async.Deferred.t = + Base.Zkapp_command_snark.witness := Some witness ; let res = match spec with | Opt_signed -> @@ -4197,16 +4263,16 @@ struct | Proved -> ( match snapp_proof_data ~witness with | None -> - failwith "of_parties_segment: Expected exactly one proof" + failwith "of_zkapp_command_segment: Expected exactly one proof" | Some (p, v) -> Pickles.Side_loaded.in_prover (Base.side_loaded 0) v.data ; proved - ~handler:(Base.Parties_snark.handle_zkapp_proof p) + ~handler:(Base.Zkapp_command_snark.handle_zkapp_proof p) statement ) in let open Async in let%map (), (), proof = res in - Base.Parties_snark.witness := None ; + Base.Zkapp_command_snark.witness := None ; { proof; statement } let of_transaction_union ~statement ~init_stack transaction state_body handler @@ -4221,8 +4287,8 @@ struct in { statement; proof } - let of_non_parties_transaction ~statement ~init_stack transaction_in_block - handler = + let of_non_zkapp_command_transaction ~statement ~init_stack + transaction_in_block handler = let transaction : Transaction.t = Transaction.forget (Transaction_protocol_state.transaction transaction_in_block) @@ -4231,15 +4297,16 @@ struct Transaction_protocol_state.block_data transaction_in_block in match to_preunion transaction with - | `Parties _ -> - failwith "Called Non-parties transaction with parties transaction" + | `Zkapp_command _ -> + failwith + "Called Non-zkapp_command transaction with zkapp_command transaction" | `Transaction t -> of_transaction_union ~statement ~init_stack (Transaction_union.of_transaction t) state_body handler let of_user_command ~statement ~init_stack user_command_in_block handler = - of_non_parties_transaction ~statement ~init_stack + of_non_zkapp_command_transaction ~statement ~init_stack { user_command_in_block with transaction = Command @@ -4249,7 +4316,7 @@ struct handler let of_fee_transfer ~statement ~init_stack transfer_in_block handler = - of_non_parties_transaction ~statement ~init_stack + of_non_zkapp_command_transaction ~statement ~init_stack { transfer_in_block with transaction = Fee_transfer @@ -4287,13 +4354,13 @@ module For_tests = struct ; zkapp_account_keypairs : Signature_lib.Keypair.t list ; memo : Signed_command_memo.t ; new_zkapp_account : bool - ; snapp_update : Party.Update.t + ; snapp_update : Account_update.Update.t (* Authorization for the update being performed *) ; current_auth : Permissions.Auth_required.t ; sequence_events : Tick.Field.t array list ; events : Tick.Field.t array list ; call_data : Tick.Field.t - ; preconditions : Party.Preconditions.t option + ; preconditions : Account_update.Preconditions.t option } [@@deriving sexp] end @@ -4370,7 +4437,7 @@ module For_tests = struct ( `VK (With_hash.of_data ~hash_data:Zkapp_account.digest_vk vk) , `Prover trivial_prover ) - let create_parties + let create_zkapp_command ~(constraint_constants : Genesis_constants.Constraint_constants.t) spec ~update = let { Spec.fee @@ -4390,7 +4457,7 @@ module For_tests = struct spec in let sender_pk = sender.public_key |> Public_key.compress in - let fee_payer : Party.Fee_payer.t = + let fee_payer : Account_update.Fee_payer.t = let public_key, nonce = match fee_payer_opt with | None -> @@ -4416,7 +4483,7 @@ module For_tests = struct let preconditions' = Option.value preconditions ~default: - { Party.Preconditions.network = + { Account_update.Preconditions.network = Option.value_map preconditions ~f:(fun { network; _ } -> network) ~default:Zkapp_precondition.Protocol_state.accept @@ -4427,10 +4494,10 @@ module For_tests = struct } in - let sender_party : Party.Simple.t option = - let sender_party_body : Party.Body.Simple.t = + let sender_account_update : Account_update.Simple.t option = + let sender_account_update_body : Account_update.Body.Simple.t = { public_key = sender_pk - ; update = Party.Update.noop + ; update = Account_update.Update.noop ; token_id = Token_id.default ; balance_change = Amount.(Signed.(negate (of_unsigned amount))) ; increment_nonce = true @@ -4445,13 +4512,13 @@ module For_tests = struct in Option.some_if ((not (List.is_empty receivers)) || new_zkapp_account) - ( { body = sender_party_body + ( { body = sender_account_update_body ; authorization = Control.Signature Signature.dummy (*To be updated later*) } - : Party.Simple.t ) + : Account_update.Simple.t ) in - let snapp_parties : Party.Simple.t list = + let snapp_zkapp_command : Account_update.Simple.t list = let num_keypairs = List.length zkapp_account_keypairs in let account_creation_fee = Amount.of_fee constraint_constants.account_creation_fee @@ -4510,10 +4577,10 @@ module For_tests = struct ; authorization = Control.Signature Signature.dummy (*To be updated later*) } - : Party.Simple.t ) ) + : Account_update.Simple.t ) ) in let other_receivers = - List.map receivers ~f:(fun (receiver, amt) : Party.Simple.t -> + List.map receivers ~f:(fun (receiver, amt) : Account_update.Simple.t -> { body = { public_key = receiver ; update @@ -4531,22 +4598,24 @@ module For_tests = struct ; authorization = Control.None_given } ) in - let other_parties_data = - Option.value_map ~default:[] sender_party ~f:(fun p -> [ p ]) - @ snapp_parties @ other_receivers + let account_updates_data = + Option.value_map ~default:[] sender_account_update ~f:(fun p -> [ p ]) + @ snapp_zkapp_command @ other_receivers in let ps = - Parties.Call_forest.With_hashes.of_parties_simple_list other_parties_data + Zkapp_command.Call_forest.With_hashes.of_zkapp_command_simple_list + account_updates_data in - let other_parties_hash = Parties.Call_forest.hash ps in - let commitment : Parties.Transaction_commitment.t = - Parties.Transaction_commitment.create ~other_parties_hash + let account_updates_hash = Zkapp_command.Call_forest.hash ps in + let commitment : Zkapp_command.Transaction_commitment.t = + Zkapp_command.Transaction_commitment.create ~account_updates_hash in let full_commitment = - Parties.Transaction_commitment.create_complete commitment + Zkapp_command.Transaction_commitment.create_complete commitment ~memo_hash:(Signed_command_memo.hash memo) ~fee_payer_hash: - (Parties.Digest.Party.create (Party.of_fee_payer fee_payer)) + (Zkapp_command.Digest.Account_update.create + (Account_update.of_fee_payer fee_payer) ) in let fee_payer = let fee_payer_signature_auth = @@ -4560,8 +4629,8 @@ module For_tests = struct in { fee_payer with authorization = fee_payer_signature_auth } in - let sender_party = - Option.map sender_party ~f:(fun s : Party.Simple.t -> + let sender_account_update = + Option.map sender_account_update ~f:(fun s : Account_update.Simple.t -> let commitment = if s.body.use_full_commitment then full_commitment else commitment in @@ -4571,10 +4640,11 @@ module For_tests = struct in { body = s.body; authorization = Signature sender_signature_auth } ) in - ( `Parties - (Parties.of_simple { fee_payer; other_parties = other_receivers; memo }) - , `Sender_party sender_party - , `Proof_parties snapp_parties + ( `Zkapp_command + (Zkapp_command.of_simple + { fee_payer; account_updates = other_receivers; memo } ) + , `Sender_account_update sender_account_update + , `Proof_zkapp_command snapp_zkapp_command , `Txn_commitment commitment , `Full_txn_commitment full_commitment ) @@ -4602,66 +4672,75 @@ module For_tests = struct } } in - let ( `Parties { Parties.fee_payer; other_parties; memo } - , `Sender_party sender_party - , `Proof_parties snapp_parties + let ( `Zkapp_command { Zkapp_command.fee_payer; account_updates; memo } + , `Sender_account_update sender_account_update + , `Proof_zkapp_command snapp_zkapp_command , `Txn_commitment commitment , `Full_txn_commitment full_commitment ) = - create_parties ~constraint_constants spec ~update:update_vk + create_zkapp_command ~constraint_constants spec ~update:update_vk in - assert (List.is_empty other_parties) ; - (* invariant: same number of keypairs, snapp_parties *) - let snapp_parties_keypairs = - List.zip_exn snapp_parties spec.zkapp_account_keypairs + assert (List.is_empty account_updates) ; + (* invariant: same number of keypairs, snapp_zkapp_command *) + let snapp_zkapp_command_keypairs = + List.zip_exn snapp_zkapp_command spec.zkapp_account_keypairs in - let snapp_parties = - List.map snapp_parties_keypairs ~f:(fun (snapp_party, keypair) -> + let snapp_zkapp_command = + List.map snapp_zkapp_command_keypairs + ~f:(fun (snapp_account_update, keypair) -> if no_auth then - ( { body = snapp_party.body; authorization = None_given } - : Party.Simple.t ) + ( { body = snapp_account_update.body; authorization = None_given } + : Account_update.Simple.t ) else let commitment = - if snapp_party.body.use_full_commitment then full_commitment + if snapp_account_update.body.use_full_commitment then + full_commitment else commitment in let signature = Signature_lib.Schnorr.Chunked.sign keypair.private_key (Random_oracle.Input.Chunked.field commitment) in - ( { body = snapp_party.body; authorization = Signature signature } - : Party.Simple.t ) ) + ( { body = snapp_account_update.body + ; authorization = Signature signature + } + : Account_update.Simple.t ) ) in - let other_parties = Option.to_list sender_party @ snapp_parties in - let parties : Parties.t = - Parties.of_simple { fee_payer; other_parties; memo } + let account_updates = + Option.to_list sender_account_update @ snapp_zkapp_command in - parties + let zkapp_command : Zkapp_command.t = + Zkapp_command.of_simple { fee_payer; account_updates; memo } + in + zkapp_command let update_states ?zkapp_prover ~constraint_constants (spec : Spec.t) = - let ( `Parties { Parties.fee_payer; other_parties; memo } - , `Sender_party sender_party - , `Proof_parties snapp_parties + let ( `Zkapp_command { Zkapp_command.fee_payer; account_updates; memo } + , `Sender_account_update sender_account_update + , `Proof_zkapp_command snapp_zkapp_command , `Txn_commitment commitment , `Full_txn_commitment full_commitment ) = - create_parties ~constraint_constants spec ~update:spec.snapp_update + create_zkapp_command ~constraint_constants spec ~update:spec.snapp_update in - assert (List.is_empty other_parties) ; - assert (Option.is_none sender_party) ; - assert (not @@ List.is_empty snapp_parties) ; - let snapp_parties = - snapp_parties + assert (List.is_empty account_updates) ; + assert (Option.is_none sender_account_update) ; + assert (not @@ List.is_empty snapp_zkapp_command) ; + let snapp_zkapp_command = + snapp_zkapp_command |> List.map ~f:(fun p -> (p, p)) - |> Parties.Call_forest.With_hashes_and_data.of_parties_simple_list + |> Zkapp_command.Call_forest.With_hashes_and_data + .of_zkapp_command_simple_list |> Zkapp_statement.zkapp_statements_of_forest - |> Parties.Call_forest.to_parties_list + |> Zkapp_command.Call_forest.to_zkapp_command_list in - let snapp_parties_keypairs = - List.zip_exn snapp_parties spec.zkapp_account_keypairs + let snapp_zkapp_command_keypairs = + List.zip_exn snapp_zkapp_command spec.zkapp_account_keypairs in - let%map.Async.Deferred snapp_parties = - Async.Deferred.List.map snapp_parties_keypairs + let%map.Async.Deferred snapp_zkapp_command = + Async.Deferred.List.map snapp_zkapp_command_keypairs ~f:(fun - (((snapp_party, simple_snapp_party), tx_statement), snapp_keypair) + ( ( (snapp_account_update, simple_snapp_account_update) + , tx_statement ) + , snapp_keypair ) -> match spec.current_auth with | Permissions.Auth_required.Proof -> @@ -4683,11 +4762,14 @@ module For_tests = struct = prover ~handler tx_statement in - ( { body = simple_snapp_party.body; authorization = Proof pi } - : Party.Simple.t ) + ( { body = simple_snapp_account_update.body + ; authorization = Proof pi + } + : Account_update.Simple.t ) | Signature -> let commitment = - if snapp_party.body.use_full_commitment then full_commitment + if snapp_account_update.body.use_full_commitment then + full_commitment else commitment in let signature = @@ -4695,43 +4777,45 @@ module For_tests = struct (Random_oracle.Input.Chunked.field commitment) in Async.Deferred.return - ( { body = simple_snapp_party.body + ( { body = simple_snapp_account_update.body ; authorization = Signature signature } - : Party.Simple.t ) + : Account_update.Simple.t ) | None -> Async.Deferred.return - ( { body = simple_snapp_party.body; authorization = None_given } - : Party.Simple.t ) + ( { body = simple_snapp_account_update.body + ; authorization = None_given + } + : Account_update.Simple.t ) | _ -> failwith "Current authorization not Proof or Signature or None_given" ) in - let other_parties = snapp_parties in - let parties : Parties.t = - Parties.of_simple { fee_payer; other_parties; memo } + let account_updates = snapp_zkapp_command in + let zkapp_command : Zkapp_command.t = + Zkapp_command.of_simple { fee_payer; account_updates; memo } in - parties + zkapp_command let multiple_transfers (spec : Spec.t) = - let ( `Parties parties - , `Sender_party sender_party - , `Proof_parties snapp_parties + let ( `Zkapp_command zkapp_command + , `Sender_account_update sender_account_update + , `Proof_zkapp_command snapp_zkapp_command , `Txn_commitment _commitment , `Full_txn_commitment _full_commitment ) = - create_parties + create_zkapp_command ~constraint_constants:Genesis_constants.Constraint_constants.compiled spec ~update:spec.snapp_update in - assert (Option.is_some sender_party) ; - assert (List.is_empty snapp_parties) ; - let other_parties = - let sender_party = Option.value_exn sender_party in - Parties.Call_forest.cons - (Parties.add_caller_simple sender_party Token_id.default) - parties.other_parties + assert (Option.is_some sender_account_update) ; + assert (List.is_empty snapp_zkapp_command) ; + let account_updates = + let sender_account_update = Option.value_exn sender_account_update in + Zkapp_command.Call_forest.cons + (Zkapp_command.add_caller_simple sender_account_update Token_id.default) + zkapp_command.account_updates in - { parties with other_parties } + { zkapp_command with account_updates } let trivial_zkapp_account ?(permissions = Permissions.user_default) ~vk pk = let id = Account_id.create pk Token_id.default in @@ -4791,10 +4875,10 @@ module For_tests = struct { Permissions.user_default with send = Permissions.Auth_required.Proof } |> Zkapp_basic.Set_or_keep.Set in - { Party.Update.dummy with permissions } + { Account_update.Update.dummy with permissions } in let sender_pk = sender.public_key |> Public_key.compress in - let fee_payer : Party.Fee_payer.t = + let fee_payer : Account_update.Fee_payer.t = { body = { public_key = sender_pk ; fee @@ -4805,10 +4889,10 @@ module For_tests = struct ; authorization = Signature.dummy } in - let sender_party_data : Party.Simple.t = + let sender_account_update_data : Account_update.Simple.t = { body = { public_key = sender_pk - ; update = Party.Update.noop + ; update = Account_update.Update.noop ; token_id = Token_id.default ; balance_change = Amount.(Signed.(negate (of_unsigned amount))) ; increment_nonce = true @@ -4826,7 +4910,7 @@ module For_tests = struct ; authorization = Signature Signature.dummy } in - let snapp_party_data : Party.Simple.t = + let snapp_account_update_data : Account_update.Simple.t = { body = { public_key = trivial_account_pk ; update = update_empty_permissions @@ -4849,25 +4933,25 @@ module For_tests = struct in let memo = Signed_command_memo.empty in let ps = - Parties.Call_forest.With_hashes.of_parties_simple_list - [ sender_party_data; snapp_party_data ] + Zkapp_command.Call_forest.With_hashes.of_zkapp_command_simple_list + [ sender_account_update_data; snapp_account_update_data ] in - let other_parties_hash = Parties.Call_forest.hash ps in - let transaction : Parties.Transaction_commitment.t = + let account_updates_hash = Zkapp_command.Call_forest.hash ps in + let transaction : Zkapp_command.Transaction_commitment.t = (*FIXME: is this correct? *) - Parties.Transaction_commitment.create ~other_parties_hash + Zkapp_command.Transaction_commitment.create ~account_updates_hash in - let proof_party = + let proof_account_update = let tree = - Parties.Call_forest.With_hashes.of_parties_simple_list - [ snapp_party_data ] + Zkapp_command.Call_forest.With_hashes.of_zkapp_command_simple_list + [ snapp_account_update_data ] |> List.hd_exn in - tree.elt.party_digest + tree.elt.account_update_digest in let tx_statement : Zkapp_statement.t = - { party = (proof_party :> Field.t) - ; calls = (Parties.Digest.Forest.empty :> Field.t) + { account_update = (proof_account_update :> Field.t) + ; calls = (Zkapp_command.Digest.Forest.empty :> Field.t) } in let handler (Snarky_backendless.Request.With { request; respond }) = @@ -4878,10 +4962,11 @@ module For_tests = struct in let fee_payer_signature_auth = let txn_comm = - Parties.Transaction_commitment.create_complete transaction + Zkapp_command.Transaction_commitment.create_complete transaction ~memo_hash:(Signed_command_memo.hash memo) ~fee_payer_hash: - (Parties.Digest.Party.create (Party.of_fee_payer fee_payer)) + (Zkapp_command.Digest.Account_update.create + (Account_update.of_fee_payer fee_payer) ) in Signature_lib.Schnorr.Chunked.sign sender.private_key (Random_oracle.Input.Chunked.field txn_comm) @@ -4893,14 +4978,18 @@ module For_tests = struct Signature_lib.Schnorr.Chunked.sign sender.private_key (Random_oracle.Input.Chunked.field transaction) in - let sender : Party.Simple.t = - { sender_party_data with authorization = Signature sender_signature_auth } + let sender : Account_update.Simple.t = + { sender_account_update_data with + authorization = Signature sender_signature_auth + } in - let other_parties = - [ sender; { body = snapp_party_data.body; authorization = Proof pi } ] + let account_updates = + [ sender + ; { body = snapp_account_update_data.body; authorization = Proof pi } + ] in - let parties : Parties.t = - Parties.of_simple { fee_payer; other_parties; memo } + let zkapp_command : Zkapp_command.t = + Zkapp_command.of_simple { fee_payer; account_updates; memo } in - parties + zkapp_command end diff --git a/src/lib/transaction_snark/transaction_snark.mli b/src/lib/transaction_snark/transaction_snark.mli index d315a40cd74..383180e34cf 100644 --- a/src/lib/transaction_snark/transaction_snark.mli +++ b/src/lib/transaction_snark/transaction_snark.mli @@ -106,7 +106,7 @@ module Statement : sig , 'pending_coinbase , 'fee_excess , 'sok_digest - , Mina_transaction_logic.Parties_logic.Local_state.Value.t ) + , Mina_transaction_logic.Zkapp_command_logic.Local_state.Value.t ) t end @@ -286,7 +286,7 @@ val generate_transaction_witness : -> Tick.Handler.t -> unit -module Parties_segment : sig +module Zkapp_command_segment : sig module Spec : sig type single = { auth_type : Control.Tag.t @@ -296,7 +296,7 @@ module Parties_segment : sig type t = single list end - module Witness = Transaction_witness.Parties_segment_witness + module Witness = Transaction_witness.Zkapp_command_segment_witness module Basic : sig [%%versioned: @@ -318,7 +318,7 @@ module type S = sig val cache_handle : Pickles.Cache_handle.t - val of_non_parties_transaction : + val of_non_zkapp_command_transaction : statement:Statement.With_sok.t -> init_stack:Pending_coinbase.Stack.t -> Transaction.Valid.t Transaction_protocol_state.t @@ -339,10 +339,10 @@ module type S = sig -> Tick.Handler.t -> t Async.Deferred.t - val of_parties_segment_exn : + val of_zkapp_command_segment_exn : statement:Statement.With_sok.t - -> witness:Parties_segment.Witness.t - -> spec:Parties_segment.Basic.t + -> witness:Zkapp_command_segment.Witness.t + -> spec:Zkapp_command_segment.Basic.t -> t Async.Deferred.t val merge : @@ -356,74 +356,74 @@ type local_state = , Currency.Amount.Signed.t , Mina_ledger.Sparse_ledger.t , bool - , Parties.Transaction_commitment.t + , Zkapp_command.Transaction_commitment.t , Mina_numbers.Index.t , Transaction_status.Failure.Collection.t ) - Mina_transaction_logic.Parties_logic.Local_state.t + Mina_transaction_logic.Zkapp_command_logic.Local_state.t type global_state = Mina_ledger.Sparse_ledger.Global_state.t -(** Represents before/after pairs of states, corresponding to parties in a list of parties transactions. +(** Represents before/after pairs of states, corresponding to zkapp_command in a list of zkapp_command transactions. *) -module Parties_intermediate_state : sig +module Zkapp_command_intermediate_state : sig type state = { global : global_state; local : local_state } type t = { kind : [ `Same | `New | `Two_new ] - ; spec : Parties_segment.Basic.t + ; spec : Zkapp_command_segment.Basic.t ; state_before : state ; state_after : state } end -(** [group_by_parties_rev partiess stmtss] identifies before/after pairs of - statements, corresponding to parties in [partiess] which minimize the - number of snark proofs needed to prove all of the parties. +(** [group_by_zkapp_command_rev zkapp_commands stmtss] identifies before/after pairs of + statements, corresponding to zkapp_command in [zkapp_commands] which minimize the + number of snark proofs needed to prove all of the zkapp_command. - This function is intended to take the parties from multiple transactions as - its input, which may be converted from a [Parties.t list] using - [List.map ~f:Parties.parties]. The [stmtss] argument should be a list of - the same length, with 1 more state than the number of parties for each + This function is intended to take the zkapp_command from multiple transactions as + its input, which may be converted from a [Zkapp_command.t list] using + [List.map ~f:Zkapp_command.zkapp_command]. The [stmtss] argument should be a list of + the same length, with 1 more state than the number of zkapp_command for each transaction. - For example, two transactions made up of parties [[p1; p2; p3]] and + For example, two transactions made up of zkapp_command [[p1; p2; p3]] and [[p4; p5]] should have the statements [[[s0; s1; s2; s3]; [s3; s4; s5]]], where each [s_n] is the state after applying [p_n] on top of [s_{n-1}], and where [s0] is the initial state before any of the transactions have been applied. Each pair is also identified with one of [`Same], [`New], or [`Two_new], - indicating that the next one ([`New]) or next two ([`Two_new]) [Parties.t]s + indicating that the next one ([`New]) or next two ([`Two_new]) [Zkapp_command.t]s will need to be passed as part of the snark witness while applying that pair. *) -val group_by_parties_rev : - Party.t list list +val group_by_zkapp_command_rev : + Account_update.t list list -> (global_state * local_state) list list - -> Parties_intermediate_state.t list + -> Zkapp_command_intermediate_state.t list -(** [parties_witnesses_exn ledger partiess] generates the parties segment witnesses +(** [zkapp_command_witnesses_exn ledger zkapp_commands] generates the zkapp_command segment witnesses and corresponding statements needed to prove the application of each - parties transaction in [partiess] on top of ledger. If multiple parties are + zkapp_command transaction in [zkapp_commands] on top of ledger. If multiple zkapp_command are given, they are applied in order and grouped together to minimise the number of transaction proofs that would be required. - There must be at least one parties transaction in [parties]. + There must be at least one zkapp_command transaction in [zkapp_command]. The returned value is a list of tuples, each corresponding to a single - proof for some parts of some parties transactions, comprising: + proof for some parts of some zkapp_command transactions, comprising: * the witness information for the segment, to be passed to the prover * the segment kind, identifying the type of proof that will be generated * the proof statement, describing the transition between the states before and after the segment * the list of calculated 'snapp statements', corresponding to the expected - public input of any snapp parties in the current segment. + public input of any snapp zkapp_command in the current segment. WARNING: This function calls the transaction logic internally, and thus may raise an exception if the transaction logic would also do so. This function - should only be used on parties that are already known to pass transaction + should only be used on zkapp_command that are already known to pass transaction logic without an exception. *) -val parties_witnesses_exn : +val zkapp_command_witnesses_exn : constraint_constants:Genesis_constants.Constraint_constants.t -> state_body:Transaction_protocol_state.Block_data.t -> fee_excess:Currency.Amount.Signed.t @@ -431,9 +431,11 @@ val parties_witnesses_exn : | `Sparse_ledger of Mina_ledger.Sparse_ledger.t ] -> ( [ `Pending_coinbase_init_stack of Pending_coinbase.Stack.t ] * [ `Pending_coinbase_of_statement of Pending_coinbase_stack_state.t ] - * Parties.t ) + * Zkapp_command.t ) list - -> (Parties_segment.Witness.t * Parties_segment.Basic.t * Statement.With_sok.t) + -> ( Zkapp_command_segment.Witness.t + * Zkapp_command_segment.Basic.t + * Statement.With_sok.t ) list * Mina_ledger.Sparse_ledger.t @@ -486,10 +488,10 @@ module Base : sig Account_timing.As_record.t ) Tick.Checked.t - module Parties_snark : sig + module Zkapp_command_snark : sig val main : - ?witness:Parties_segment.Witness.t - -> Parties_segment.Spec.t + ?witness:Zkapp_command_segment.Witness.t + -> Zkapp_command_segment.Spec.t -> constraint_constants:Genesis_constants.Constraint_constants.t -> Statement.With_sok.var -> Zkapp_statement.Checked.t option @@ -508,12 +510,12 @@ module For_tests : sig ; zkapp_account_keypairs : Signature_lib.Keypair.t list ; memo : Signed_command_memo.t ; new_zkapp_account : bool - ; snapp_update : Party.Update.t + ; snapp_update : Account_update.Update.t ; current_auth : Permissions.Auth_required.t ; sequence_events : Tick.Field.t array list ; events : Tick.Field.t array list ; call_data : Tick.Field.t - ; preconditions : Party.Preconditions.t option + ; preconditions : Account_update.Preconditions.t option } [@@deriving sexp] end @@ -522,7 +524,7 @@ module For_tests : sig ?no_auth:bool -> constraint_constants:Genesis_constants.Constraint_constants.t -> Spec.t - -> Parties.t + -> Zkapp_command.t val update_states : ?zkapp_prover: @@ -535,7 +537,7 @@ module For_tests : sig Pickles.Prover.t -> constraint_constants:Genesis_constants.Constraint_constants.t -> Spec.t - -> Parties.t Async.Deferred.t + -> Zkapp_command.t Async.Deferred.t val create_trivial_predicate_snapp : constraint_constants:Genesis_constants.Constraint_constants.t @@ -543,7 +545,7 @@ module For_tests : sig -> snapp_kp:Signature_lib.Keypair.t -> Mina_transaction_logic.For_tests.Transaction_spec.t -> Mina_ledger.Ledger.t - -> Parties.t Async.Deferred.t + -> Zkapp_command.t Async.Deferred.t val trivial_zkapp_account : ?permissions:Permissions.t @@ -571,5 +573,5 @@ module For_tests : sig Async.Deferred.t ) Pickles.Prover.t ] - val multiple_transfers : Spec.t -> Parties.t + val multiple_transfers : Spec.t -> Zkapp_command.t end diff --git a/src/lib/transaction_snark_scan_state/transaction_snark_scan_state.ml b/src/lib/transaction_snark_scan_state/transaction_snark_scan_state.ml index 0a2a44e0fc3..0b834d27452 100644 --- a/src/lib/transaction_snark_scan_state/transaction_snark_scan_state.ml +++ b/src/lib/transaction_snark_scan_state/transaction_snark_scan_state.ml @@ -548,7 +548,7 @@ struct "did not connect with pending-coinbase stack" and () = clarify_error - (Mina_transaction_logic.Parties_logic.Local_state.Value.equal + (Mina_transaction_logic.Zkapp_command_logic.Local_state.Value.equal reg1.local_state reg2.local_state ) "did not connect with local state" in diff --git a/src/lib/transaction_witness/transaction_witness.ml b/src/lib/transaction_witness/transaction_witness.ml index b76fb41355f..d4fe592f2f2 100644 --- a/src/lib/transaction_witness/transaction_witness.ml +++ b/src/lib/transaction_witness/transaction_witness.ml @@ -1,6 +1,6 @@ open Core_kernel -module Parties_segment_witness = struct +module Zkapp_command_segment_witness = struct open Mina_base open Mina_ledger open Currency @@ -13,10 +13,10 @@ module Parties_segment_witness = struct { global_ledger : Sparse_ledger.Stable.V2.t ; local_state_init : ( ( Token_id.Stable.V1.t - , Parties.Call_forest.With_hashes.Stable.V1.t ) + , Zkapp_command.Call_forest.With_hashes.Stable.V1.t ) Stack_frame.Stable.V1.t , ( ( ( Token_id.Stable.V1.t - , Parties.Call_forest.With_hashes.Stable.V1.t ) + , Zkapp_command.Call_forest.With_hashes.Stable.V1.t ) Stack_frame.Stable.V1.t , Stack_frame.Digest.Stable.V1.t ) With_hash.Stable.V1.t @@ -30,11 +30,11 @@ module Parties_segment_witness = struct , Kimchi_backend.Pasta.Basic.Fp.Stable.V1.t , Mina_numbers.Index.Stable.V1.t , Transaction_status.Failure.Collection.Stable.V1.t ) - Mina_transaction_logic.Parties_logic.Local_state.Stable.V1.t - ; start_parties : - ( Parties.Stable.V1.t + Mina_transaction_logic.Zkapp_command_logic.Local_state.Stable.V1.t + ; start_zkapp_command : + ( Zkapp_command.Stable.V1.t , Kimchi_backend.Pasta.Basic.Fp.Stable.V1.t ) - Mina_transaction_logic.Parties_logic.Start_data.Stable.V1.t + Mina_transaction_logic.Zkapp_command_logic.Start_data.Stable.V1.t list ; state_body : Mina_state.Protocol_state.Body.Value.Stable.V2.t ; init_stack : Mina_base.Pending_coinbase.Stack_versioned.Stable.V1.t diff --git a/src/lib/transaction_witness/transaction_witness.mli b/src/lib/transaction_witness/transaction_witness.mli index b1a60da22d0..1421fa25876 100644 --- a/src/lib/transaction_witness/transaction_witness.mli +++ b/src/lib/transaction_witness/transaction_witness.mli @@ -1,6 +1,6 @@ open Core_kernel -module Parties_segment_witness : sig +module Zkapp_command_segment_witness : sig open Mina_base open Mina_ledger open Currency @@ -12,10 +12,10 @@ module Parties_segment_witness : sig { global_ledger : Sparse_ledger.Stable.V2.t ; local_state_init : ( ( Token_id.Stable.V1.t - , Parties.Call_forest.With_hashes.Stable.V1.t ) + , Zkapp_command.Call_forest.With_hashes.Stable.V1.t ) Stack_frame.Stable.V1.t , ( ( ( Token_id.Stable.V1.t - , Parties.Call_forest.With_hashes.Stable.V1.t ) + , Zkapp_command.Call_forest.With_hashes.Stable.V1.t ) Stack_frame.Stable.V1.t , Stack_frame.Digest.Stable.V1.t ) With_hash.t @@ -29,11 +29,11 @@ module Parties_segment_witness : sig , Kimchi_backend.Pasta.Basic.Fp.Stable.V1.t , Mina_numbers.Index.Stable.V1.t , Transaction_status.Failure.Collection.Stable.V1.t ) - Mina_transaction_logic.Parties_logic.Local_state.Stable.V1.t - ; start_parties : - ( Parties.Stable.V1.t + Mina_transaction_logic.Zkapp_command_logic.Local_state.Stable.V1.t + ; start_zkapp_command : + ( Zkapp_command.Stable.V1.t , Kimchi_backend.Pasta.Basic.Fp.Stable.V1.t ) - Mina_transaction_logic.Parties_logic.Start_data.Stable.V1.t + Mina_transaction_logic.Zkapp_command_logic.Start_data.Stable.V1.t list ; state_body : Mina_state.Protocol_state.Body.Value.Stable.V2.t ; init_stack : Pending_coinbase.Stack_versioned.Stable.V1.t diff --git a/src/lib/transition_frontier/full_frontier/full_frontier.ml b/src/lib/transition_frontier/full_frontier/full_frontier.ml index 07c8b6d0cbe..4e707515735 100644 --- a/src/lib/transition_frontier/full_frontier/full_frontier.ml +++ b/src/lib/transition_frontier/full_frontier/full_frontier.ml @@ -789,7 +789,7 @@ let update_metrics_with_diff (type mutant) (List.fold ~init:0 ~f:(fun c cmd -> match cmd.data with - | Mina_base.User_command.Poly.Parties _ -> + | Mina_base.User_command.Poly.Zkapp_command _ -> c + 1 | _ -> c ) diff --git a/src/lib/user_command_input/user_command_input.ml b/src/lib/user_command_input/user_command_input.ml index f25fc256065..4642bee6d36 100644 --- a/src/lib/user_command_input/user_command_input.ml +++ b/src/lib/user_command_input/user_command_input.ml @@ -152,7 +152,7 @@ let inferred_nonce ~get_current_nonce ~(fee_payer : Account_id.t) ~nonce_map = match Map.find nonce_map fee_payer with | Some (min_nonce, nonce) -> (* Multiple user commands from the same fee-payer. *) - (* TODO: this logic does not currently support parties transactions, as parties transactions can increment the fee payer nonce more than once (#11001) *) + (* TODO: this logic does not currently support zkapp_command transactions, as zkapp_command transactions can increment the fee payer nonce more than once (#11001) *) let next_nonce = Account_nonce.succ nonce in let updated_map = update_map ~data:(min_nonce, next_nonce) in Ok (min_nonce, next_nonce, updated_map) diff --git a/src/lib/verifier/common.ml b/src/lib/verifier/common.ml index 2c3327e7874..97f2e475eb6 100644 --- a/src/lib/verifier/common.ml +++ b/src/lib/verifier/common.ml @@ -40,17 +40,21 @@ let check : `Valid (User_command.Signed_command c) | None -> `Invalid_signature (Signed_command.public_keys c) ) - | Parties ({ fee_payer; other_parties; memo } as parties_with_vk) -> + | Zkapp_command ({ fee_payer; account_updates; memo } as zkapp_command_with_vk) + -> with_return (fun { return } -> - let other_parties_hash = Parties.Call_forest.hash other_parties in + let account_updates_hash = + Zkapp_command.Call_forest.hash account_updates + in let tx_commitment = - Parties.Transaction_commitment.create ~other_parties_hash + Zkapp_command.Transaction_commitment.create ~account_updates_hash in let full_tx_commitment = - Parties.Transaction_commitment.create_complete tx_commitment + Zkapp_command.Transaction_commitment.create_complete tx_commitment ~memo_hash:(Signed_command_memo.hash memo) ~fee_payer_hash: - (Parties.Digest.Party.create (Party.of_fee_payer fee_payer)) + (Zkapp_command.Digest.Account_update.create + (Account_update.of_fee_payer fee_payer) ) in let check_signature s pk msg = match Signature_lib.Public_key.decompress pk with @@ -69,14 +73,14 @@ let check : in check_signature fee_payer.authorization fee_payer.body.public_key full_tx_commitment ; - let parties_with_hashes_list = - other_parties |> Zkapp_statement.zkapp_statements_of_forest' - |> Parties.Call_forest.With_hashes_and_data - .to_parties_with_hashes_list + let zkapp_command_with_hashes_list = + account_updates |> Zkapp_statement.zkapp_statements_of_forest' + |> Zkapp_command.Call_forest.With_hashes_and_data + .to_zkapp_command_with_hashes_list in let valid_assuming = - List.filter_map parties_with_hashes_list - ~f:(fun ((p, (vk_opt, stmt)), _at_party) -> + List.filter_map zkapp_command_with_hashes_list + ~f:(fun ((p, (vk_opt, stmt)), _at_account_update) -> let commitment = if p.body.use_full_commitment then full_tx_commitment else tx_commitment @@ -92,16 +96,19 @@ let check : | None -> return (`Missing_verification_key - [ Account_id.public_key @@ Party.account_id p ] ) + [ Account_id.public_key + @@ Account_update.account_id p + ] ) | Some (vk : _ With_hash.t) -> Some (vk.data, stmt, pi) ) ) in let v : User_command.Valid.t = (*Verification keys should be present if it reaches here*) - let parties = - Option.value_exn (Parties.Valid.of_verifiable parties_with_vk) + let zkapp_command = + Option.value_exn + (Zkapp_command.Valid.of_verifiable zkapp_command_with_vk) in - User_command.Poly.Parties parties + User_command.Poly.Zkapp_command zkapp_command in match valid_assuming with | [] -> diff --git a/src/lib/parties_builder/dune b/src/lib/zkapp_command_builder/dune similarity index 80% rename from src/lib/parties_builder/dune rename to src/lib/zkapp_command_builder/dune index 92bf55b913b..0fdfd16740f 100644 --- a/src/lib/parties_builder/dune +++ b/src/lib/zkapp_command_builder/dune @@ -1,6 +1,6 @@ (library - (name parties_builder) - (public_name parties_builder) + (name zkapp_command_builder) + (public_name zkapp_command_builder) (library_flags -linkall) (libraries ;; opam libraries @@ -26,4 +26,4 @@ (preprocess (pps ppx_jane ppx_annot ppx_snarky ppx_here ppx_mina ppx_version)) (instrumentation (backend bisect_ppx)) - (synopsis "Builder Parties.t via combinators")) + (synopsis "Builder Zkapp_command.t via combinators")) diff --git a/src/lib/parties_builder/parties_builder.ml b/src/lib/zkapp_command_builder/zkapp_command_builder.ml similarity index 57% rename from src/lib/parties_builder/parties_builder.ml rename to src/lib/zkapp_command_builder/zkapp_command_builder.ml index cbad490c92f..bed2257fcf6 100644 --- a/src/lib/parties_builder/parties_builder.ml +++ b/src/lib/zkapp_command_builder/zkapp_command_builder.ml @@ -1,17 +1,19 @@ -(* parties_builder.ml -- combinators to build Parties.t for tests *) +(* zkapp_command_builder.ml -- combinators to build Zkapp_command.t for tests *) open Core_kernel open Mina_base -let mk_forest ps : (Party.Body.Simple.t, unit, unit) Parties.Call_forest.t = +let mk_forest ps : + (Account_update.Body.Simple.t, unit, unit) Zkapp_command.Call_forest.t = List.map ps ~f:(fun p -> { With_stack_hash.elt = p; stack_hash = () }) -let mk_node party calls = - { Parties.Call_forest.Tree.party; party_digest = (); calls = mk_forest calls } +let mk_node account_update calls : _ Zkapp_command.Call_forest.Tree.t = + { account_update; account_update_digest = (); calls = mk_forest calls } -let mk_party_body caller kp token_id balance_change : Party.Body.Simple.t = +let mk_account_update_body caller kp token_id balance_change : + Account_update.Body.Simple.t = let open Signature_lib in - { update = Party.Update.noop + { update = Account_update.Update.noop ; public_key = Public_key.compress kp.Keypair.public_key ; token_id ; balance_change = @@ -25,15 +27,15 @@ let mk_party_body caller kp token_id balance_change : Party.Body.Simple.t = ; call_depth = 0 ; preconditions = { network = Zkapp_precondition.Protocol_state.accept - ; account = Party.Account_precondition.Accept + ; account = Account_update.Account_precondition.Accept } ; use_full_commitment = true ; caller } -let mk_parties_transaction ?memo ~fee ~fee_payer_pk ~fee_payer_nonce - other_parties : Parties.t = - let fee_payer : Party.Fee_payer.t = +let mk_zkapp_command ?memo ~fee ~fee_payer_pk ~fee_payer_nonce account_updates : + Zkapp_command.t = + let fee_payer : Account_update.Fee_payer.t = { body = { public_key = fee_payer_pk ; fee = Currency.Fee.of_int fee @@ -49,39 +51,40 @@ let mk_parties_transaction ?memo ~fee ~fee_payer_pk ~fee_payer_nonce in { fee_payer ; memo - ; other_parties = - other_parties - |> Parties.Call_forest.map - ~f:(fun (p : Party.Body.Simple.t) : Party.Simple.t -> - { body = p; authorization = Signature Signature.dummy } ) - |> Parties.Call_forest.add_callers_simple - |> Parties.Call_forest.accumulate_hashes_predicated + ; account_updates = + account_updates + |> Zkapp_command.Call_forest.map + ~f:(fun (p : Account_update.Body.Simple.t) : Account_update.Simple.t + -> { body = p; authorization = Signature Signature.dummy } ) + |> Zkapp_command.Call_forest.add_callers_simple + |> Zkapp_command.Call_forest.accumulate_hashes_predicated } -let get_transaction_commitments (parties : Parties.t) = - let memo_hash = Signed_command_memo.hash parties.memo in +let get_transaction_commitments (zkapp_command : Zkapp_command.t) = + let memo_hash = Signed_command_memo.hash zkapp_command.memo in let fee_payer_hash = - Party.of_fee_payer parties.fee_payer |> Parties.Digest.Party.create + Account_update.of_fee_payer zkapp_command.fee_payer + |> Zkapp_command.Digest.Account_update.create in - let other_parties_hash = Parties.other_parties_hash parties in + let account_updates_hash = Zkapp_command.account_updates_hash zkapp_command in let txn_commitment = - Parties.Transaction_commitment.create ~other_parties_hash + Zkapp_command.Transaction_commitment.create ~account_updates_hash in let full_txn_commitment = - Parties.Transaction_commitment.create_complete txn_commitment ~memo_hash - ~fee_payer_hash + Zkapp_command.Transaction_commitment.create_complete txn_commitment + ~memo_hash ~fee_payer_hash in (txn_commitment, full_txn_commitment) -(* replace dummy signatures, proofs with valid ones for fee payer, other parties +(* replace dummy signatures, proofs with valid ones for fee payer, other zkapp_command [keymap] maps compressed public keys to private keys *) -let replace_authorizations ?prover ~keymap (parties : Parties.t) : - Parties.t Async_kernel.Deferred.t = +let replace_authorizations ?prover ~keymap (zkapp_command : Zkapp_command.t) : + Zkapp_command.t Async_kernel.Deferred.t = let txn_commitment, full_txn_commitment = - get_transaction_commitments parties + get_transaction_commitments zkapp_command in - let sign_for_party ~use_full_commitment sk = + let sign_for_account_update ~use_full_commitment sk = let commitment = if use_full_commitment then full_txn_commitment else txn_commitment in @@ -90,18 +93,18 @@ let replace_authorizations ?prover ~keymap (parties : Parties.t) : in let fee_payer_sk = Signature_lib.Public_key.Compressed.Map.find_exn keymap - parties.fee_payer.body.public_key + zkapp_command.fee_payer.body.public_key in let fee_payer_signature = - sign_for_party ~use_full_commitment:true fee_payer_sk + sign_for_account_update ~use_full_commitment:true fee_payer_sk in let fee_payer_with_valid_signature = - { parties.fee_payer with authorization = fee_payer_signature } + { zkapp_command.fee_payer with authorization = fee_payer_signature } in let open Async_kernel.Deferred.Let_syntax in - let%map other_parties_with_valid_signatures = - Parties.Call_forest.deferred_mapi parties.other_parties - ~f:(fun _ndx ({ body; authorization } : Party.t) tree -> + let%map account_updates_with_valid_signatures = + Zkapp_command.Call_forest.deferred_mapi zkapp_command.account_updates + ~f:(fun _ndx ({ body; authorization } : Account_update.t) tree -> let%map authorization_with_valid_signature = match authorization with | Control.Signature _dummy -> @@ -119,7 +122,7 @@ let replace_authorizations ?prover ~keymap (parties : Parties.t) : () in let use_full_commitment = body.use_full_commitment in - let signature = sign_for_party ~use_full_commitment sk in + let signature = sign_for_account_update ~use_full_commitment sk in return (Control.Signature signature) | Proof _ -> ( match prover with @@ -138,9 +141,11 @@ let replace_authorizations ?prover ~keymap (parties : Parties.t) : | None_given -> return authorization in - { Party.body; authorization = authorization_with_valid_signature } ) + { Account_update.body + ; authorization = authorization_with_valid_signature + } ) in - { parties with + { zkapp_command with fee_payer = fee_payer_with_valid_signature - ; other_parties = other_parties_with_valid_signatures + ; account_updates = account_updates_with_valid_signatures } diff --git a/src/lib/zkapps_examples/add_events/zkapps_add_events.ml b/src/lib/zkapps_examples/add_events/zkapps_add_events.ml index 8c049c7709d..015e5c343ba 100644 --- a/src/lib/zkapps_examples/add_events/zkapps_add_events.ml +++ b/src/lib/zkapps_examples/add_events/zkapps_add_events.ml @@ -5,7 +5,7 @@ open Zkapps_examples let initialize public_key = Zkapps_examples.wrap_main (fun () -> - Party_under_construction.In_circuit.create + AccountUpdate_under_construction.In_circuit.create ~public_key:(Public_key.Compressed.var_of_t public_key) ~token_id:Token_id.(Checked.constant default) () ) @@ -27,8 +27,8 @@ let event_length = 7 let update_events public_key = Zkapps_examples.wrap_main (fun () -> - let party = - Party_under_construction.In_circuit.create + let account_update = + AccountUpdate_under_construction.In_circuit.create ~public_key:(Public_key.Compressed.var_of_t public_key) ~token_id:Token_id.(Checked.constant default) () @@ -39,7 +39,8 @@ let update_events public_key = (Typ.list ~length:num_events (Typ.array ~length:event_length Field.typ) ) in - Party_under_construction.In_circuit.add_events events party ) + AccountUpdate_under_construction.In_circuit.add_events events + account_update ) let initialize_rule public_key : _ Pickles.Inductive_rule.t = { identifier = "Initialize zkApp" diff --git a/src/lib/zkapps_examples/empty_update/zkapps_empty_update.ml b/src/lib/zkapps_examples/empty_update/zkapps_empty_update.ml index 5e9351dbf9c..727d367c409 100644 --- a/src/lib/zkapps_examples/empty_update/zkapps_empty_update.ml +++ b/src/lib/zkapps_examples/empty_update/zkapps_empty_update.ml @@ -7,7 +7,7 @@ open Zkapps_examples *) let main public_key = Zkapps_examples.wrap_main (fun () -> - Party_under_construction.In_circuit.create + AccountUpdate_under_construction.In_circuit.create ~public_key:(Public_key.Compressed.var_of_t public_key) ~token_id:Token_id.(Checked.constant default) () ) @@ -22,6 +22,7 @@ let rule public_key : _ Pickles.Inductive_rule.t = (* TODO: This shouldn't exist, the circuit should just return the requisite value. *) -let generate_party public_key = - Party_under_construction.create ~public_key ~token_id:Token_id.default () - |> Party_under_construction.to_party +let generate_account_update public_key = + AccountUpdate_under_construction.create ~public_key ~token_id:Token_id.default + () + |> AccountUpdate_under_construction.to_account_update diff --git a/src/lib/zkapps_examples/initialize_state/zkapps_initialize_state.ml b/src/lib/zkapps_examples/initialize_state/zkapps_initialize_state.ml index f3cbdae0809..9fb16bb10e5 100644 --- a/src/lib/zkapps_examples/initialize_state/zkapps_initialize_state.ml +++ b/src/lib/zkapps_examples/initialize_state/zkapps_initialize_state.ml @@ -18,8 +18,8 @@ let initial_state = let initialize public_key = Zkapps_examples.wrap_main (fun () -> - let party = - Party_under_construction.In_circuit.create + let account_update = + AccountUpdate_under_construction.In_circuit.create ~public_key:(Public_key.Compressed.var_of_t public_key) ~token_id:Token_id.(Checked.constant default) () @@ -27,8 +27,10 @@ let initialize public_key = let initial_state = List.map ~f:Field.constant (Lazy.force initial_state) in - party |> Party_under_construction.In_circuit.assert_state_unproved - |> Party_under_construction.In_circuit.set_full_state initial_state ) + account_update + |> AccountUpdate_under_construction.In_circuit.assert_state_unproved + |> AccountUpdate_under_construction.In_circuit.set_full_state + initial_state ) type _ Snarky_backendless.Request.t += | New_state : Field.Constant.t list Snarky_backendless.Request.t @@ -43,8 +45,8 @@ let update_state_handler (new_state : Field.Constant.t list) let update_state public_key = Zkapps_examples.wrap_main (fun () -> - let party = - Party_under_construction.In_circuit.create + let account_update = + AccountUpdate_under_construction.In_circuit.create ~public_key:(Public_key.Compressed.var_of_t public_key) ~token_id:Token_id.(Checked.constant default) () @@ -52,8 +54,9 @@ let update_state public_key = let new_state = exists (Typ.list ~length:8 Field.typ) ~request:(fun () -> New_state) in - party |> Party_under_construction.In_circuit.assert_state_proved - |> Party_under_construction.In_circuit.set_full_state new_state ) + account_update + |> AccountUpdate_under_construction.In_circuit.assert_state_proved + |> AccountUpdate_under_construction.In_circuit.set_full_state new_state ) let initialize_rule public_key : _ Pickles.Inductive_rule.t = { identifier = "Initialize snapp" @@ -69,14 +72,16 @@ let update_state_rule public_key : _ Pickles.Inductive_rule.t = ; uses_lookup = false } -let generate_initialize_party public_key = - Party_under_construction.create ~public_key ~token_id:Token_id.default () - |> Party_under_construction.assert_state_unproved - |> Party_under_construction.set_full_state (Lazy.force initial_state) - |> Party_under_construction.to_party +let generate_initialize_account_update public_key = + AccountUpdate_under_construction.create ~public_key ~token_id:Token_id.default + () + |> AccountUpdate_under_construction.assert_state_unproved + |> AccountUpdate_under_construction.set_full_state (Lazy.force initial_state) + |> AccountUpdate_under_construction.to_account_update -let generate_update_state_party public_key new_state = - Party_under_construction.create ~public_key ~token_id:Token_id.default () - |> Party_under_construction.assert_state_proved - |> Party_under_construction.set_full_state new_state - |> Party_under_construction.to_party +let generate_update_state_account_update public_key new_state = + AccountUpdate_under_construction.create ~public_key ~token_id:Token_id.default + () + |> AccountUpdate_under_construction.assert_state_proved + |> AccountUpdate_under_construction.set_full_state new_state + |> AccountUpdate_under_construction.to_account_update diff --git a/src/lib/zkapps_examples/sequence_events/zkapps_sequence_events.ml b/src/lib/zkapps_examples/sequence_events/zkapps_sequence_events.ml index 6e0ab4d94af..1d177ffda87 100644 --- a/src/lib/zkapps_examples/sequence_events/zkapps_sequence_events.ml +++ b/src/lib/zkapps_examples/sequence_events/zkapps_sequence_events.ml @@ -5,7 +5,7 @@ open Zkapps_examples let initialize public_key = Zkapps_examples.wrap_main (fun () -> - Party_under_construction.In_circuit.create + AccountUpdate_under_construction.In_circuit.create ~public_key:(Public_key.Compressed.var_of_t public_key) ~token_id:Token_id.(Checked.constant default) () ) @@ -29,8 +29,8 @@ let event_length = 13 let update_sequence_events public_key = Zkapps_examples.wrap_main (fun () -> - let party = - Party_under_construction.In_circuit.create + let account_update = + AccountUpdate_under_construction.In_circuit.create ~public_key:(Public_key.Compressed.var_of_t public_key) ~token_id:Token_id.(Checked.constant default) () @@ -41,8 +41,8 @@ let update_sequence_events public_key = (Typ.list ~length:num_events (Typ.array ~length:event_length Field.typ) ) in - Party_under_construction.In_circuit.add_sequence_events sequence_events - party ) + AccountUpdate_under_construction.In_circuit.add_sequence_events + sequence_events account_update ) let initialize_rule public_key : _ Pickles.Inductive_rule.t = { identifier = "Initialize zkApp" diff --git a/src/lib/zkapps_examples/zkapps_examples.ml b/src/lib/zkapps_examples/zkapps_examples.ml index ce3fd64a295..04ce35990be 100644 --- a/src/lib/zkapps_examples/zkapps_examples.ml +++ b/src/lib/zkapps_examples/zkapps_examples.ml @@ -5,7 +5,7 @@ open Currency open Signature_lib open Mina_base -module Party_under_construction = struct +module AccountUpdate_under_construction = struct module Account_condition = struct type t = { state_proved : bool option } @@ -57,8 +57,8 @@ module Party_under_construction = struct let create () = { app_state = [ None; None; None; None; None; None; None; None ] } - let to_parties_update ({ app_state } : t) : Party.Update.t = - let default : Party.Update.t = + let to_zkapp_command_update ({ app_state } : t) : Account_update.Update.t = + let default : Account_update.Update.t = { app_state = [ Keep; Keep; Keep; Keep; Keep; Keep; Keep; Keep ] ; delegate = Keep ; verification_key = Keep @@ -127,17 +127,17 @@ module Party_under_construction = struct ; sequence_events = Sequence_events.create () } - let to_party (t : t) : Party.Body.t = + let to_account_update (t : t) : Account_update.Body.t = { public_key = t.public_key ; token_id = t.token_id - ; update = Update.to_parties_update t.update + ; update = Update.to_zkapp_command_update t.update ; balance_change = { magnitude = Amount.zero; sgn = Pos } ; increment_nonce = false ; events = t.events.events ; sequence_events = [] ; call_data = Field.Constant.zero ; preconditions = - { Party.Preconditions.network = + { Account_update.Preconditions.network = { snarked_ledger_hash = Ignore ; timestamp = Ignore ; blockchain_length = Ignore @@ -212,7 +212,7 @@ module Party_under_construction = struct in let default = var_of_t - (Party.Account_precondition.typ ()) + (Account_update.Account_precondition.typ ()) (Full { balance = Ignore ; nonce = Ignore @@ -267,7 +267,8 @@ module Party_under_construction = struct let create () = { app_state = [ None; None; None; None; None; None; None; None ] } - let to_parties_update ({ app_state } : t) : Party.Update.Checked.t = + let to_zkapp_command_update ({ app_state } : t) : + Account_update.Update.Checked.t = (* TODO: Don't do this. *) let var_of_t (type var value) (typ : (var, value) Typ.t) (x : value) : var = @@ -278,7 +279,8 @@ module Party_under_construction = struct typ.var_of_fields (fields, aux) in let default = - var_of_t (Party.Update.typ ()) + var_of_t + (Account_update.Update.typ ()) { app_state = [ Keep; Keep; Keep; Keep; Keep; Keep; Keep; Keep ] ; delegate = Keep ; verification_key = Keep @@ -326,7 +328,7 @@ module Party_under_construction = struct let add_events t events : t = { events = t.events @ events } - let to_parties_events ({ events } : t) : Zkapp_account.Events.var = + let to_zkapp_command_events ({ events } : t) : Zkapp_account.Events.var = let open Core_kernel in let empty_var : Zkapp_account.Events.var = exists ~compute:(fun () -> []) Zkapp_account.Events.typ @@ -344,7 +346,7 @@ module Party_under_construction = struct let add_sequence_events t sequence_events : t = { sequence_events = t.sequence_events @ sequence_events } - let to_parties_sequence_events ({ sequence_events } : t) : + let to_zkapp_command_sequence_events ({ sequence_events } : t) : Zkapp_account.Sequence_events.var = let open Core_kernel in let empty_var : Zkapp_account.Events.var = @@ -374,8 +376,8 @@ module Party_under_construction = struct ; sequence_events = Sequence_events.create () } - let to_party_and_calls (t : t) : - Party.Body.Checked.t * Zkapp_call_forest.Checked.t = + let to_account_update_and_calls (t : t) : + Account_update.Body.Checked.t * Zkapp_call_forest.Checked.t = (* TODO: Don't do this. *) let var_of_t (type var value) (typ : (var, value) Typ.t) (x : value) : var = @@ -385,19 +387,19 @@ module Party_under_construction = struct let fields = Array.map Field.Var.constant fields in typ.var_of_fields (fields, aux) in - let party : Party.Body.Checked.t = + let account_update : Account_update.Body.Checked.t = { public_key = t.public_key ; token_id = t.token_id - ; update = Update.to_parties_update t.update + ; update = Update.to_zkapp_command_update t.update ; balance_change = var_of_t Amount.Signed.typ { magnitude = Amount.zero; sgn = Pos } ; increment_nonce = Boolean.false_ - ; events = Events.to_parties_events t.events + ; events = Events.to_zkapp_command_events t.events ; sequence_events = - Sequence_events.to_parties_sequence_events t.sequence_events + Sequence_events.to_zkapp_command_sequence_events t.sequence_events ; call_data = Field.zero ; preconditions = - { Party.Preconditions.Checked.network = + { Account_update.Preconditions.Checked.network = var_of_t Zkapp_precondition.Protocol_state.typ { snarked_ledger_hash = Ignore ; timestamp = Ignore @@ -435,7 +437,7 @@ module Party_under_construction = struct } in let calls = exists Zkapp_call_forest.typ ~compute:(fun () -> []) in - (party, calls) + (account_update, calls) let assert_state_unproved (t : t) = { t with @@ -485,37 +487,45 @@ let dummy_constraints () = : Field.t * Field.t ) type return_type = - { party : Party.Body.t - ; party_digest : Parties.Digest.Party.t + { account_update : Account_update.Body.t + ; account_update_digest : Zkapp_command.Digest.Account_update.t ; calls : - ( ( Party.t - , Parties.Digest.Party.t - , Parties.Digest.Forest.t ) - Parties.Call_forest.Tree.t - , Parties.Digest.Forest.t ) + ( ( Account_update.t + , Zkapp_command.Digest.Account_update.t + , Zkapp_command.Digest.Forest.t ) + Zkapp_command.Call_forest.Tree.t + , Zkapp_command.Digest.Forest.t ) With_stack_hash.t list } -let to_party party : Zkapp_statement.Checked.t * return_type Prover_value.t = +let to_account_update account_update : + Zkapp_statement.Checked.t * return_type Prover_value.t = dummy_constraints () ; - let party, calls = - Party_under_construction.In_circuit.to_party_and_calls party + let account_update, calls = + AccountUpdate_under_construction.In_circuit.to_account_update_and_calls + account_update + in + let account_update_digest = + Zkapp_command.Call_forest.Digest.Account_update.Checked.create + account_update in - let party_digest = Parties.Call_forest.Digest.Party.Checked.create party in let public_output : Zkapp_statement.Checked.t = - { party = (party_digest :> Field.t) + { account_update = (account_update_digest :> Field.t) ; calls = (Zkapp_call_forest.Checked.hash calls :> Field.t) } in let auxiliary_output = Prover_value.create (fun () -> - let party = As_prover.read (Party.Body.typ ()) party in - let party_digest = - As_prover.read Parties.Call_forest.Digest.Party.typ party_digest + let account_update = + As_prover.read (Account_update.Body.typ ()) account_update + in + let account_update_digest = + As_prover.read Zkapp_command.Call_forest.Digest.Account_update.typ + account_update_digest in let calls = Prover_value.get calls.data in - { party; calls; party_digest } ) + { account_update; calls; account_update_digest } ) in (public_output, auxiliary_output) @@ -557,7 +567,7 @@ let compile : , heightss , unit , unit - , Party_under_construction.In_circuit.t + , AccountUpdate_under_construction.In_circuit.t , unit (* TODO: Remove? *) , auxiliary_var , auxiliary_value ) @@ -578,10 +588,10 @@ let compile : , widthss , heightss , unit - , ( ( Party.t - , Parties.Digest.Party.t - , Parties.Digest.Forest.t ) - Parties.Call_forest.Tree.t + , ( ( Account_update.t + , Zkapp_command.Digest.Account_update.t + , Zkapp_command.Digest.Forest.t ) + Zkapp_command.Call_forest.Tree.t * auxiliary_value ) Deferred.t ) H3_2.T(Pickles.Prover).t = @@ -596,7 +606,7 @@ let compile : , heightss , unit , unit - , Party_under_construction.In_circuit.t + , AccountUpdate_under_construction.In_circuit.t , unit , auxiliary_var , auxiliary_value ) @@ -621,17 +631,17 @@ let compile : ; main = (fun main_input -> let { Pickles.Inductive_rule.previous_proof_statements - ; public_output = party_under_construction + ; public_output = account_update_under_construction ; auxiliary_output } = main main_input in - let public_output, party_tree = - to_party party_under_construction + let public_output, account_update_tree = + to_account_update account_update_under_construction in { previous_proof_statements ; public_output - ; auxiliary_output = (party_tree, auxiliary_output) + ; auxiliary_output = (account_update_tree, auxiliary_output) } ) } :: go choices @@ -660,10 +670,10 @@ let compile : , widthss , heightss , unit - , ( ( Party.t - , Parties.Digest.Party.t - , Parties.Digest.Forest.t ) - Parties.Call_forest.Tree.t + , ( ( Account_update.t + , Zkapp_command.Digest.Account_update.t + , Zkapp_command.Digest.Forest.t ) + Zkapp_command.Call_forest.Tree.t * auxiliary_value ) Deferred.t ) H3_2.T(Pickles.Prover).t = function @@ -673,16 +683,20 @@ let compile : let prover ?handler () = let open Async_kernel in let%map ( _stmt - , ({ party; party_digest; calls }, auxiliary_value) + , ( { account_update; account_update_digest; calls } + , auxiliary_value ) , proof ) = prover ?handler () in - let party : Party.t = - { body = party + let account_update : Account_update.t = + { body = account_update ; authorization = Proof (Pickles.Side_loaded.Proof.of_proof proof) } in - ( { Parties.Call_forest.Tree.party; party_digest; calls } + ( { Zkapp_command.Call_forest.Tree.account_update + ; account_update_digest + ; calls + } , auxiliary_value ) in prover :: go provers diff --git a/src/parties_builder.opam b/src/zkapp_command_builder.opam similarity index 100% rename from src/parties_builder.opam rename to src/zkapp_command_builder.opam From 7214cf079a42ebfe503c14c065ea3313aff0b2df Mon Sep 17 00:00:00 2001 From: Paul Steckler Date: Wed, 7 Sep 2022 12:15:34 -0700 Subject: [PATCH 063/144] fix test exec build --- src/lib/integration_test_cloud_engine/kubernetes_network.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/integration_test_cloud_engine/kubernetes_network.ml b/src/lib/integration_test_cloud_engine/kubernetes_network.ml index 932004c08b3..b8be90fee86 100644 --- a/src/lib/integration_test_cloud_engine/kubernetes_network.ml +++ b/src/lib/integration_test_cloud_engine/kubernetes_network.ml @@ -733,7 +733,7 @@ module Node = struct |> Yojson.Safe.to_string ) in let zkapp_id = - Mina_base.Parties.to_base58_check + Mina_base.Zkapp_command.to_base58_check sent_zkapp_obj.internalSendZkapp.zkapp.id in [%log info] "Sent zkapp" ~metadata:[ ("zkapp_id", `String zkapp_id) ] ; From 72ac4afbe329a822e4933d87fa0ee208a6d0f872 Mon Sep 17 00:00:00 2001 From: Deepthi S Kumar Date: Wed, 7 Sep 2022 15:30:34 -0700 Subject: [PATCH 064/144] zkapp transaction metrics --- src/app/cli/src/init/coda_run.ml | 6 ++--- src/lib/mina_metrics/mina_metrics.mli | 10 ++++--- .../mina_metrics/no_metrics/mina_metrics.ml | 10 ++++--- .../prometheus_metrics/mina_metrics.ml | 22 ++++++++++------ src/lib/network_pool/indexed_pool.ml | 26 ++++++++++++++++--- src/lib/snark_worker/functor.ml | 21 ++++++++++++--- 6 files changed, 70 insertions(+), 25 deletions(-) diff --git a/src/app/cli/src/init/coda_run.ml b/src/app/cli/src/init/coda_run.ml index 55b5d9f5b2b..6d48b88ff72 100644 --- a/src/app/cli/src/init/coda_run.ml +++ b/src/app/cli/src/init/coda_run.ml @@ -439,10 +439,10 @@ let setup_local_server ?(client_trustlist = []) ?rest_server_port Perf_histograms.add_span ~name:"snark_worker_transition_time" total ; Mina_metrics.( Cryptography.( - Snark_work_histogram.observe snark_work_base_time_sec - (Time.Span.to_sec total) ; + Gauge.set snark_work_base_time_sec (Time.Span.to_sec total) ; Gauge.set transaction_length (Float.of_int parties_count) ; - Gauge.set proof_parties (Float.of_int proof_parties_count))) ) + Gauge.set zkapp_proof_updates (Float.of_int proof_parties_count))) + ) in let snark_worker_impls = [ implement Snark_worker.Rpcs_versioned.Get_work.Latest.rpc (fun () () -> diff --git a/src/lib/mina_metrics/mina_metrics.mli b/src/lib/mina_metrics/mina_metrics.mli index 01345159b41..002d705141e 100644 --- a/src/lib/mina_metrics/mina_metrics.mli +++ b/src/lib/mina_metrics/mina_metrics.mli @@ -58,11 +58,11 @@ module Cryptography : sig val snark_work_merge_time_sec : Snark_work_histogram.t - val snark_work_base_time_sec : Snark_work_histogram.t + val snark_work_base_time_sec : Gauge.t val transaction_length : Gauge.t - val proof_parties : Gauge.t + val zkapp_proof_updates : Gauge.t end module Bootstrap : sig @@ -84,9 +84,11 @@ module Transaction_pool : sig val transactions_added_to_pool : Counter.t - val parties_transaction_size : Gauge.t + val zkapp_transaction_size : Gauge.t - val parties_count : Gauge.t + val zkapp_updates : Gauge.t + + val zkapp_proof_updates : Gauge.t end module Network : sig diff --git a/src/lib/mina_metrics/no_metrics/mina_metrics.ml b/src/lib/mina_metrics/no_metrics/mina_metrics.ml index fa89b71fdc4..e2a3e8f3cd4 100644 --- a/src/lib/mina_metrics/no_metrics/mina_metrics.ml +++ b/src/lib/mina_metrics/no_metrics/mina_metrics.ml @@ -68,11 +68,11 @@ module Cryptography = struct let snark_work_merge_time_sec : Snark_work_histogram.t = () - let snark_work_base_time_sec : Snark_work_histogram.t = () + let snark_work_base_time_sec : Gauge.t = () let transaction_length : Gauge.t = () - let proof_parties : Gauge.t = () + let zkapp_proof_updates : Gauge.t = () end module Bootstrap = struct @@ -94,9 +94,11 @@ module Transaction_pool = struct let transactions_added_to_pool : Counter.t = () - let parties_transaction_size : Gauge.t = () + let zkapp_transaction_size : Gauge.t = () - let parties_count : Gauge.t = () + let zkapp_updates : Gauge.t = () + + let zkapp_proof_updates : Guage.t = () end module Network = struct diff --git a/src/lib/mina_metrics/prometheus_metrics/mina_metrics.ml b/src/lib/mina_metrics/prometheus_metrics/mina_metrics.ml index e42e5435200..b3f861b02b1 100644 --- a/src/lib/mina_metrics/prometheus_metrics/mina_metrics.ml +++ b/src/lib/mina_metrics/prometheus_metrics/mina_metrics.ml @@ -276,8 +276,7 @@ module Cryptography = struct let snark_work_base_time_sec = let help = "time elapsed while doing base proof" in - Snark_work_histogram.v "snark_work_base_time_sec" ~help ~namespace - ~subsystem + Gauge.v "snark_work_base_time_sec" ~help ~namespace ~subsystem let transaction_length = let help = @@ -285,12 +284,12 @@ module Cryptography = struct in Gauge.v "transaction_length" ~help ~namespace ~subsystem - let proof_parties = + let zkapp_proof_updates = let help = "Number of parties with proof authorization in a parties transaction (0 \ for simple transactions)" in - Gauge.v "proof_parties" ~help ~namespace ~subsystem + Gauge.v "zkapp_proof_updates" ~help ~namespace ~subsystem (* TODO: let transaction_proving_time_ms = @@ -344,13 +343,20 @@ module Transaction_pool = struct in Counter.v "transactions_added_to_pool" ~help ~namespace ~subsystem - let parties_transaction_size : Gauge.t = + let zkapp_transaction_size : Gauge.t = let help = "Size of valid parties transaction received (bin_size_t)" in - Gauge.v "parties_transaction_size" ~help ~namespace ~subsystem + Gauge.v "zkapp_transaction_size" ~help ~namespace ~subsystem - let parties_count : Gauge.t = + let zkapp_updates : Gauge.t = let help = "Number of parties in a valid transaction received" in - Gauge.v "parties_count" ~help ~namespace ~subsystem + Gauge.v "zkapp_updates" ~help ~namespace ~subsystem + + let zkapp_proof_updates : Gauge.t = + let help = + "Number of parties with proof authorization in a parties transaction (0 \ + for simple transactions)" + in + Gauge.v "zkapp_proof_updates" ~help ~namespace ~subsystem end module Metric_map (Metric : sig diff --git a/src/lib/network_pool/indexed_pool.ml b/src/lib/network_pool/indexed_pool.ml index 97fecbda8a3..9a2fc8841a9 100644 --- a/src/lib/network_pool/indexed_pool.ml +++ b/src/lib/network_pool/indexed_pool.ml @@ -514,11 +514,31 @@ module Update = struct ( match Transaction_hash.User_command_with_valid_signature.data cmd with | Parties p -> let p = Parties.Valid.forget p in + let updates, proof_updates = + let init = + match (Party.of_fee_payer p.fee_payer).authorization with + | Proof _ -> + (1, 1) + | _ -> + (1, 0) + in + Parties.Call_forest.fold p.Parties.other_parties ~init + ~f:(fun (count, proof_parties_count) party -> + ( count + 1 + , if + Control.( + Tag.equal Proof (tag (Party.authorization party))) + then proof_parties_count + 1 + else proof_parties_count ) ) + in Mina_metrics.Gauge.set - Mina_metrics.Transaction_pool.parties_transaction_size + Mina_metrics.Transaction_pool.zkapp_transaction_size (Parties.Stable.Latest.bin_size_t p |> Float.of_int) ; - Mina_metrics.Gauge.set Mina_metrics.Transaction_pool.parties_count - (List.length (Parties.to_simple p).other_parties |> Float.of_int) + Mina_metrics.Gauge.set Mina_metrics.Transaction_pool.zkapp_updates + (Float.of_int updates) ; + Mina_metrics.Gauge.set + Mina_metrics.Transaction_pool.zkapp_proof_updates + (Float.of_int proof_updates) | Signed_command _ -> () ) ; { acc with diff --git a/src/lib/snark_worker/functor.ml b/src/lib/snark_worker/functor.ml index c1d087d3655..5b3451873e8 100644 --- a/src/lib/snark_worker/functor.ml +++ b/src/lib/snark_worker/functor.ml @@ -164,9 +164,20 @@ module Make (Inputs : Intf.Inputs_intf) : match Option.value_exn single with | Mina_transaction.Transaction.Command (Mina_base.User_command.Parties parties) -> + let init = + match + (Mina_base.Party.of_fee_payer + parties.Mina_base.Parties.fee_payer ) + .authorization + with + | Proof _ -> + (1, 1) + | _ -> + (1, 0) + in let c, p = Mina_base.Parties.Call_forest.fold - parties.Mina_base.Parties.other_parties ~init:(1, 0) + parties.Mina_base.Parties.other_parties ~init ~f:(fun (count, proof_parties_count) party -> ( count + 1 , if @@ -185,8 +196,12 @@ module Make (Inputs : Intf.Inputs_intf) : ("fee_transfer", 1, 0) in Mina_metrics.( - Cryptography.Snark_work_histogram.observe - Cryptography.snark_work_base_time_sec (Time.Span.to_sec time)) ; + Gauge.set Cryptography.snark_work_base_time_sec + (Time.Span.to_sec time) ; + Gauge.set Cryptography.transaction_length + (Float.of_int parties_count) ; + Gauge.set Cryptography.zkapp_proof_updates + (Float.of_int proof_parties_count)) ; [%str_log info] (Base_snark_generated { time; transaction_type; parties_count; proof_parties_count } From 37cef53eee0e8320a3e9dab0f36641ceccc94937 Mon Sep 17 00:00:00 2001 From: Nathan Holland Date: Wed, 7 Sep 2022 08:06:41 -0400 Subject: [PATCH 065/144] Update helm chart version references --- automation/terraform/modules/kubernetes/testnet/helm.tf | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/automation/terraform/modules/kubernetes/testnet/helm.tf b/automation/terraform/modules/kubernetes/testnet/helm.tf index 194f4a42f1d..873eef5c1fb 100644 --- a/automation/terraform/modules/kubernetes/testnet/helm.tf +++ b/automation/terraform/modules/kubernetes/testnet/helm.tf @@ -26,7 +26,7 @@ resource "helm_release" "seeds" { name = "${var.testnet_name}-seeds" repository = var.use_local_charts ? "" : local.mina_helm_repo chart = var.use_local_charts ? "../../../../helm/seed-node" : "seed-node" - version = "1.0.6" + version = "1.0.8" namespace = kubernetes_namespace.testnet_namespace.metadata[0].name values = [ yamlencode(local.seed_vars) @@ -47,7 +47,7 @@ resource "helm_release" "block_producers" { name = "${var.testnet_name}-block-producers" repository = var.use_local_charts ? "" : local.mina_helm_repo chart = var.use_local_charts ? "../../../../helm/block-producer" : "block-producer" - version = "1.0.5" + version = "1.0.7" namespace = kubernetes_namespace.testnet_namespace.metadata[0].name values = [ yamlencode(local.block_producer_vars) @@ -83,7 +83,7 @@ resource "helm_release" "snark_workers" { name = "${var.testnet_name}-snark-set-${count.index + 1}" repository = var.use_local_charts ? "" : local.mina_helm_repo chart = var.use_local_charts ? "../../../../helm/snark-worker" : "snark-worker" - version = "1.0.3" + version = "1.0.5" namespace = kubernetes_namespace.testnet_namespace.metadata[0].name values = [ yamlencode(local.snark_vars[count.index]) @@ -102,7 +102,7 @@ resource "helm_release" "archive_node" { name = "archive-${count.index + 1}" repository = var.use_local_charts ? "" : local.mina_helm_repo chart = var.use_local_charts ? "../../../../helm/archive-node" : "archive-node" - version = "1.0.5" + version = "1.0.7" namespace = kubernetes_namespace.testnet_namespace.metadata[0].name values = [ yamlencode(local.archive_vars[count.index]) From 1ebed23f711451019a8c10a98f20d913156a92aa Mon Sep 17 00:00:00 2001 From: Nathan Holland Date: Wed, 7 Sep 2022 18:12:59 -0400 Subject: [PATCH 066/144] Fix libp2p key perms in helm charts --- helm/archive-node/templates/archive.yaml | 2 +- helm/block-producer/templates/block-producer.yaml | 2 +- helm/seed-node/templates/seed-node.yaml | 2 +- helm/snark-worker/templates/snark-coordinator.yaml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/helm/archive-node/templates/archive.yaml b/helm/archive-node/templates/archive.yaml index 8407f71d1ac..354996ed2b1 100644 --- a/helm/archive-node/templates/archive.yaml +++ b/helm/archive-node/templates/archive.yaml @@ -30,7 +30,7 @@ spec: command: - bash - -c - - mina libp2p generate-keypair --privkey-path /root/libp2p-keys/key + - mina libp2p generate-keypair --privkey-path /root/libp2p-keys/key && /bin/chmod -R 0700 /root/libp2p-keys/ volumeMounts: - name: actual-libp2p mountPath: /root/libp2p-keys diff --git a/helm/block-producer/templates/block-producer.yaml b/helm/block-producer/templates/block-producer.yaml index f3b29623273..1b364847306 100644 --- a/helm/block-producer/templates/block-producer.yaml +++ b/helm/block-producer/templates/block-producer.yaml @@ -79,7 +79,7 @@ spec: command: - bash - -c - - mina libp2p generate-keypair --privkey-path /root/libp2p-keys/key + - mina libp2p generate-keypair --privkey-path /root/libp2p-keys/key && /bin/chmod -R 0700 /root/libp2p-keys/ volumeMounts: - name: actual-libp2p mountPath: /root/libp2p-keys diff --git a/helm/seed-node/templates/seed-node.yaml b/helm/seed-node/templates/seed-node.yaml index 5b5f9df8178..93ed3f83882 100644 --- a/helm/seed-node/templates/seed-node.yaml +++ b/helm/seed-node/templates/seed-node.yaml @@ -43,7 +43,7 @@ spec: command: - bash - -c - - mina libp2p generate-keypair --privkey-path /root/libp2p-keys/key + - mina libp2p generate-keypair --privkey-path /root/libp2p-keys/key && /bin/chmod -R 0700 /root/libp2p-keys/ volumeMounts: - name: actual-libp2p mountPath: /root/libp2p-keys diff --git a/helm/snark-worker/templates/snark-coordinator.yaml b/helm/snark-worker/templates/snark-coordinator.yaml index df5310eef7d..bafca2b9118 100644 --- a/helm/snark-worker/templates/snark-coordinator.yaml +++ b/helm/snark-worker/templates/snark-coordinator.yaml @@ -28,7 +28,7 @@ spec: command: - bash - -c - - mina libp2p generate-keypair --privkey-path /root/libp2p-keys/key + - mina libp2p generate-keypair --privkey-path /root/libp2p-keys/key && /bin/chmod -R 0700 /root/libp2p-keys/ volumeMounts: - name: actual-libp2p mountPath: /root/libp2p-keys From 27281323f95d140fec9b18693e01d567abe75321 Mon Sep 17 00:00:00 2001 From: Paul Steckler Date: Wed, 7 Sep 2022 18:31:52 -0700 Subject: [PATCH 067/144] fix SnarkyJS tests --- frontend/mina-signer/src/MinaSigner.ts | 55 +- frontend/mina-signer/src/TSTypes.ts | 10 +- frontend/mina-signer/src/Utils.ts | 6 +- frontend/mina-signer/tests/party.test.ts | 34 +- src/app/client_sdk/client_sdk.ml | 6 +- .../test_module/package-lock.json | 890 ++++-------------- .../test_module/to-hash-input.js | 14 +- 7 files changed, 247 insertions(+), 768 deletions(-) diff --git a/frontend/mina-signer/src/MinaSigner.ts b/frontend/mina-signer/src/MinaSigner.ts index 1b32e4359b4..f65a09ea872 100644 --- a/frontend/mina-signer/src/MinaSigner.ts +++ b/frontend/mina-signer/src/MinaSigner.ts @@ -11,12 +11,12 @@ import type { Payment, StakeDelegation, Message, - AccountUpdate, - OtherZkapp_command, + ZkappCommand, + AccountUpdates, SignableData, } from "./TSTypes"; -import { isPayment, isMessage, isStakeDelegation, isAccountUpdate } from "./Utils"; +import { isPayment, isMessage, isStakeDelegation, isZkappCommand } from "./Utils"; const defaultValidUntil = "4294967295"; @@ -330,31 +330,31 @@ class Client { } /** - * Sign a zkapp_command transaction using a private key. + * Sign a zkapp command transaction using a private key. * * This type of transaction allows a user to update state on a given * Smart Contract running on Mina. * - * @param accountUpdate A object representing a Zkapp_command tx + * @param zkappCommand A object representing a zkApp command tx * @param privateKey The fee payer private key - * @returns Signed zkapp_command + * @returns Signed ZkappCommand */ - public signAccountUpdate(accountUpdate: AccountUpdate, privateKey: PrivateKey): Signed { - const zkapp_command = JSON.stringify(accountUpdate.zkapp_command.accountUpdates); + public signZkappCommand(zkappCommand: ZkappCommand, privateKey: PrivateKey): Signed { + const account_updates = JSON.stringify(zkappCommand.zkappCommand.accountUpdates); if ( - accountUpdate.feePayer.fee === undefined || - accountUpdate.feePayer.fee < this.getAccountUpdateMinimumFee(accountUpdate.zkapp_command.accountUpdates) + zkappCommand.feePayer.fee === undefined || + zkappCommand.feePayer.fee < this.getAccountUpdateMinimumFee(zkappCommand.zkappCommand.accountUpdates) ) { throw `Fee must be greater than ${this.getAccountUpdateMinimumFee( - accountUpdate.zkapp_command.accountUpdates + zkappCommand.zkappCommand.accountUpdates )}`; } - const memo = accountUpdate.feePayer.memo ?? ""; - const fee = String(accountUpdate.feePayer.fee); - const nonce = String(accountUpdate.feePayer.nonce); - const feePayer = String(accountUpdate.feePayer.feePayer); - const signedZkapp_command = minaSDK.signAccountUpdate( - zkapp_command, + const memo = zkappCommand.feePayer.memo ?? ""; + const fee = String(zkappCommand.feePayer.fee); + const nonce = String(zkappCommand.feePayer.nonce); + const feePayer = String(zkappCommand.feePayer.feePayer); + const signedZkappCommand = minaSDK.signZkappCommand( + account_updates, { feePayer, fee, @@ -364,9 +364,9 @@ class Client { privateKey ); return { - signature: JSON.parse(signedZkapp_command).feePayer.authorization, + signature: JSON.parse(signedZkappCommand).feePayer.authorization, data: { - zkapp_command: signedZkapp_command, + zkappCommand: signedZkappCommand, feePayer: { feePayer, fee, @@ -404,7 +404,7 @@ class Client { /** * Signs an arbitrary payload using a private key. This function can sign messages, - * payments, stake delegations, and zkapp_command. If the payload is unrecognized, an Error + * payments, stake delegations, and zkapp commands. If the payload is unrecognized, an Error * is thrown. * * @param payload A signable payload @@ -415,7 +415,8 @@ class Client { payload: SignableData, privateKey: PrivateKey ): Signed { - if (isMessage(payload)) { + console.log (payload); + if (isMessage(payload)) { return this.signMessage(payload.message, { publicKey: payload.publicKey, privateKey, @@ -427,22 +428,22 @@ class Client { if (isStakeDelegation(payload)) { return this.signStakeDelegation(payload, privateKey); } - if (isAccountUpdate(payload)) { - return this.signAccountUpdate(payload, privateKey); + if (isZkappCommand(payload)) { + return this.signZkappCommand(payload, privateKey); } else { throw new Error(`Expected signable payload, got '${payload}'.`); } } /** - * Calculates the minimum fee of an accountUpdate transaction. A fee for a accountUpdate transaction is - * the sum of all zkapp_command plus the specified fee amount. If no fee is passed in, `0.001` + * Calculates the minimum fee of a zkapp command transaction. A fee for a zkapp command transaction is + * the sum of all account updates plus the specified fee amount. If no fee is passed in, `0.001` * is used (according to the Mina spec) by default. - * @param p An accountUpdate object + * @param p An accountUpdates object * @param fee The fee per accountUpdate amount * @returns The fee to be paid by the fee payer accountUpdate */ - public getAccountUpdateMinimumFee(p: OtherZkapp_command, fee: number = 0.001) { + public getAccountUpdateMinimumFee(p: AccountUpdates, fee: number = 0.001) { return p.reduce((accumulatedFee, _) => accumulatedFee + fee, 0); } } diff --git a/frontend/mina-signer/src/TSTypes.ts b/frontend/mina-signer/src/TSTypes.ts index ce8e573fbc9..620c229626e 100644 --- a/frontend/mina-signer/src/TSTypes.ts +++ b/frontend/mina-signer/src/TSTypes.ts @@ -40,14 +40,14 @@ export type Payment = { readonly validUntil?: UInt32; }; -export type OtherZkapp_command = { +export type AccountUpdates = { body: any; authorization: any; }[]; -export type AccountUpdate = { - readonly zkapp_command: { - accountUpdates: OtherZkapp_command; +export type ZkappCommand = { + readonly zkappCommand: { + accountUpdates : AccountUpdates; }; readonly feePayer: { @@ -58,7 +58,7 @@ export type AccountUpdate = { }; }; -export type SignableData = Message | StakeDelegation | Payment | AccountUpdate; +export type SignableData = Message | StakeDelegation | Payment | ZkappCommand; export type Signed = { readonly signature: Signature; diff --git a/frontend/mina-signer/src/Utils.ts b/frontend/mina-signer/src/Utils.ts index 13246aa836e..8d4b0ba22ee 100644 --- a/frontend/mina-signer/src/Utils.ts +++ b/frontend/mina-signer/src/Utils.ts @@ -2,7 +2,7 @@ import type { Payment, StakeDelegation, Message, - AccountUpdate, + ZkappCommand, SignableData, } from "./TSTypes"; @@ -15,8 +15,8 @@ function hasCommonProperties(data: SignableData) { ); } -export function isAccountUpdate(p: AccountUpdate): p is AccountUpdate { - return p.hasOwnProperty("zkapp_command") && p.hasOwnProperty("feePayer"); +export function isZkappCommand(p: ZkappCommand): p is ZkappCommand { + return p.hasOwnProperty("zkappCommand") && p.hasOwnProperty("feePayer"); } export function isPayment(p: SignableData): p is Payment { diff --git a/frontend/mina-signer/tests/party.test.ts b/frontend/mina-signer/tests/party.test.ts index eb07d2a21c8..807a51abc7b 100644 --- a/frontend/mina-signer/tests/party.test.ts +++ b/frontend/mina-signer/tests/party.test.ts @@ -1,14 +1,14 @@ import Client from "../src/MinaSigner"; -import type { AccountUpdate, Signed } from "../src/TSTypes"; +import type { ZkappCommand, Signed } from "../src/TSTypes"; /** - * This is an example of a Zkapp_command transaction. This can be generated by + * This is an example of a zkapp command transaction. This can be generated by * creating a transaction in SnarkyJS and printing it out as JSON. * * TODO: When there is an example of how to do this in the SnarkyJS repo, * use that example instead. */ -let mockedZkapp_command = { +let mockedZkappCommand = { accountUpdates: [ { body: { @@ -100,18 +100,18 @@ let mockedZkapp_command = { ], memo: "E4YM2vTHhWEg66xpj52JErHUBU4pZ1yageL4TVDDpTTSsv8mK6YaH", }; -describe("AccountUpdate", () => { +describe("ZkappCommand", () => { let client: Client; beforeAll(async () => { client = new Client({ network: "mainnet" }); }); - it("generates a signed accountUpdate", () => { + it("generates a signed zkapp command", () => { const keypair = client.genKeys(); - const zkapp_command = client.signAccountUpdate( + const zkappCommand = client.signZkappCommand( { - zkapp_command: mockedZkapp_command, + zkappCommand: mockedZkappCommand, feePayer: { feePayer: keypair.publicKey, fee: "1", @@ -121,15 +121,15 @@ describe("AccountUpdate", () => { }, keypair.privateKey ); - expect(zkapp_command.data).toBeDefined(); - expect(zkapp_command.signature).toBeDefined(); + expect(zkappCommand.data).toBeDefined(); + expect(zkappCommand.signature).toBeDefined(); }); it("generates a signed accountUpdate by using signTransaction", () => { const keypair = client.genKeys(); - const zkapp_command = client.signTransaction( + const zkappCommand = client.signTransaction( { - zkapp_command: mockedZkapp_command, + zkappCommand: mockedZkappCommand, feePayer: { feePayer: keypair.publicKey, fee: "1", @@ -138,17 +138,17 @@ describe("AccountUpdate", () => { }, }, keypair.privateKey - ) as Signed; - expect(zkapp_command.data).toBeDefined(); - expect(zkapp_command.signature).toBeDefined(); + ) as Signed; + expect(zkappCommand.data).toBeDefined(); + expect(zkappCommand.signature).toBeDefined(); }); it("should throw an error if no fee is passed to the feePayer", () => { const keypair = client.genKeys(); expect(() => { - client.signAccountUpdate( + client.signZkappCommand( { - zkapp_command: mockedZkapp_command, + zkappCommand: mockedZkappCommand, // @ts-ignore - fee is not defined feePayer: { feePayer: keypair.publicKey, @@ -162,6 +162,6 @@ describe("AccountUpdate", () => { }); it("should calculate a correct minimum fee", () => { - expect(client.getAccountUpdateMinimumFee(mockedZkapp_command.accountUpdates, 1)).toBe(1); + expect(client.getAccountUpdateMinimumFee(mockedZkappCommand.accountUpdates, 1)).toBe(1); }); }); diff --git a/src/app/client_sdk/client_sdk.ml b/src/app/client_sdk/client_sdk.ml index edf3af64b04..08d02b7c1f8 100644 --- a/src/app/client_sdk/client_sdk.ml +++ b/src/app/client_sdk/client_sdk.ml @@ -33,12 +33,12 @@ let _ = val publicKey = pk_str_js end - (** generate a zkapp_command fee payer and sign other zkapp_command with the fee payer account *) - method signAccountUpdate (zkapp_command_js : string_js) + (** generate a zkapp command fee payer and sign account updates with the fee payer account *) + method signZkappCommand (account_updates_js : string_js) (fee_payer_js : payload_fee_payer_js) (sk_base58_check_js : string_js) = let account_updates_json = - zkapp_command_js |> Js.to_string |> Yojson.Safe.from_string + account_updates_js |> Js.to_string |> Yojson.Safe.from_string in let account_updates = Zkapp_command.account_updates_of_json account_updates_json diff --git a/src/lib/snarky_js_bindings/test_module/package-lock.json b/src/lib/snarky_js_bindings/test_module/package-lock.json index 9f678decea6..e0d684b7cf6 100644 --- a/src/lib/snarky_js_bindings/test_module/package-lock.json +++ b/src/lib/snarky_js_bindings/test_module/package-lock.json @@ -13,7 +13,7 @@ } }, "../../../../frontend/mina-signer": { - "version": "1.2.0", + "version": "1.3.0", "license": "Apache-2.0", "dependencies": { "@types/node": "^13.7.0", @@ -25,6 +25,7 @@ "@babel/preset-typescript": "^7.16.0", "@types/jest": "^27.0.3", "babel-jest": "^27.3.1", + "jest": "^27.3.1", "ts-jest": "^27.0.7", "ts-node": "^10.4.0", "typescript": "^4.5.2" @@ -1541,8 +1542,7 @@ "../../../../frontend/mina-signer/node_modules/@bcoe/v8-coverage": { "version": "0.2.3", "dev": true, - "license": "MIT", - "peer": true + "license": "MIT" }, "../../../../frontend/mina-signer/node_modules/@cspotcode/source-map-consumer": { "version": "0.8.0", @@ -1590,7 +1590,6 @@ "version": "27.3.1", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@jest/types": "^27.2.5", "@types/node": "*", @@ -1607,7 +1606,6 @@ "version": "4.3.0", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "color-convert": "^2.0.1" }, @@ -1622,7 +1620,6 @@ "version": "4.1.2", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "ansi-styles": "^4.1.0", "supports-color": "^7.1.0" @@ -1638,7 +1635,6 @@ "version": "2.0.1", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "color-name": "~1.1.4" }, @@ -1649,14 +1645,12 @@ "../../../../frontend/mina-signer/node_modules/@jest/console/node_modules/color-name": { "version": "1.1.4", "dev": true, - "license": "MIT", - "peer": true + "license": "MIT" }, "../../../../frontend/mina-signer/node_modules/@jest/console/node_modules/has-flag": { "version": "4.0.0", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">=8" } @@ -1665,7 +1659,6 @@ "version": "7.2.0", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "has-flag": "^4.0.0" }, @@ -1677,7 +1670,6 @@ "version": "27.3.1", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@jest/console": "^27.3.1", "@jest/reporters": "^27.3.1", @@ -1724,7 +1716,6 @@ "version": "4.3.0", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "color-convert": "^2.0.1" }, @@ -1739,7 +1730,6 @@ "version": "4.1.2", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "ansi-styles": "^4.1.0", "supports-color": "^7.1.0" @@ -1755,7 +1745,6 @@ "version": "2.0.1", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "color-name": "~1.1.4" }, @@ -1766,14 +1755,12 @@ "../../../../frontend/mina-signer/node_modules/@jest/core/node_modules/color-name": { "version": "1.1.4", "dev": true, - "license": "MIT", - "peer": true + "license": "MIT" }, "../../../../frontend/mina-signer/node_modules/@jest/core/node_modules/has-flag": { "version": "4.0.0", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">=8" } @@ -1782,7 +1769,6 @@ "version": "7.2.0", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "has-flag": "^4.0.0" }, @@ -1794,7 +1780,6 @@ "version": "27.3.1", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@jest/fake-timers": "^27.3.1", "@jest/types": "^27.2.5", @@ -1809,7 +1794,6 @@ "version": "27.3.1", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@jest/types": "^27.2.5", "@sinonjs/fake-timers": "^8.0.1", @@ -1826,7 +1810,6 @@ "version": "27.3.1", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@jest/environment": "^27.3.1", "@jest/types": "^27.2.5", @@ -1840,7 +1823,6 @@ "version": "27.3.1", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@bcoe/v8-coverage": "^0.2.3", "@jest/console": "^27.3.1", @@ -1884,7 +1866,6 @@ "version": "4.3.0", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "color-convert": "^2.0.1" }, @@ -1899,7 +1880,6 @@ "version": "4.1.2", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "ansi-styles": "^4.1.0", "supports-color": "^7.1.0" @@ -1915,7 +1895,6 @@ "version": "2.0.1", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "color-name": "~1.1.4" }, @@ -1926,14 +1905,12 @@ "../../../../frontend/mina-signer/node_modules/@jest/reporters/node_modules/color-name": { "version": "1.1.4", "dev": true, - "license": "MIT", - "peer": true + "license": "MIT" }, "../../../../frontend/mina-signer/node_modules/@jest/reporters/node_modules/has-flag": { "version": "4.0.0", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">=8" } @@ -1942,7 +1919,6 @@ "version": "4.0.3", "dev": true, "license": "BSD-3-Clause", - "peer": true, "dependencies": { "@babel/core": "^7.7.5", "@istanbuljs/schema": "^0.1.2", @@ -1957,7 +1933,6 @@ "version": "0.6.1", "dev": true, "license": "BSD-3-Clause", - "peer": true, "engines": { "node": ">=0.10.0" } @@ -1966,7 +1941,6 @@ "version": "7.2.0", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "has-flag": "^4.0.0" }, @@ -1978,7 +1952,6 @@ "version": "27.0.6", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "callsites": "^3.0.0", "graceful-fs": "^4.2.4", @@ -1992,7 +1965,6 @@ "version": "0.6.1", "dev": true, "license": "BSD-3-Clause", - "peer": true, "engines": { "node": ">=0.10.0" } @@ -2001,7 +1973,6 @@ "version": "27.3.1", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@jest/console": "^27.3.1", "@jest/types": "^27.2.5", @@ -2016,7 +1987,6 @@ "version": "27.3.1", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@jest/test-result": "^27.3.1", "graceful-fs": "^4.2.4", @@ -2207,7 +2177,6 @@ "version": "1.8.3", "dev": true, "license": "BSD-3-Clause", - "peer": true, "dependencies": { "type-detect": "4.0.8" } @@ -2216,7 +2185,6 @@ "version": "8.1.0", "dev": true, "license": "BSD-3-Clause", - "peer": true, "dependencies": { "@sinonjs/commons": "^1.7.0" } @@ -2225,7 +2193,6 @@ "version": "1.1.2", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">= 6" } @@ -2332,14 +2299,12 @@ "../../../../frontend/mina-signer/node_modules/@types/prettier": { "version": "2.4.2", "dev": true, - "license": "MIT", - "peer": true + "license": "MIT" }, "../../../../frontend/mina-signer/node_modules/@types/stack-utils": { "version": "2.0.1", "dev": true, - "license": "MIT", - "peer": true + "license": "MIT" }, "../../../../frontend/mina-signer/node_modules/@types/yargs": { "version": "16.0.4", @@ -2357,8 +2322,7 @@ "../../../../frontend/mina-signer/node_modules/abab": { "version": "2.0.5", "dev": true, - "license": "BSD-3-Clause", - "peer": true + "license": "BSD-3-Clause" }, "../../../../frontend/mina-signer/node_modules/acorn": { "version": "8.6.0", @@ -2375,7 +2339,6 @@ "version": "6.0.0", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "acorn": "^7.1.1", "acorn-walk": "^7.1.1" @@ -2385,7 +2348,6 @@ "version": "7.4.1", "dev": true, "license": "MIT", - "peer": true, "bin": { "acorn": "bin/acorn" }, @@ -2397,7 +2359,6 @@ "version": "7.2.0", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">=0.4.0" } @@ -2406,7 +2367,6 @@ "version": "6.0.2", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "debug": "4" }, @@ -2418,7 +2378,6 @@ "version": "4.3.2", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "type-fest": "^0.21.3" }, @@ -2476,8 +2435,7 @@ "../../../../frontend/mina-signer/node_modules/asynckit": { "version": "0.4.0", "dev": true, - "license": "MIT", - "peer": true + "license": "MIT" }, "../../../../frontend/mina-signer/node_modules/babel-jest": { "version": "27.3.1", @@ -2702,8 +2660,7 @@ "../../../../frontend/mina-signer/node_modules/browser-process-hrtime": { "version": "1.0.0", "dev": true, - "license": "BSD-2-Clause", - "peer": true + "license": "BSD-2-Clause" }, "../../../../frontend/mina-signer/node_modules/browserslist": { "version": "4.18.1", @@ -2749,8 +2706,7 @@ "../../../../frontend/mina-signer/node_modules/buffer-from": { "version": "1.1.2", "dev": true, - "license": "MIT", - "peer": true + "license": "MIT" }, "../../../../frontend/mina-signer/node_modules/call-bind": { "version": "1.0.2", @@ -2768,7 +2724,6 @@ "version": "3.1.0", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">=6" } @@ -2807,7 +2762,6 @@ "version": "1.0.2", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">=10" } @@ -2820,14 +2774,12 @@ "../../../../frontend/mina-signer/node_modules/cjs-module-lexer": { "version": "1.2.2", "dev": true, - "license": "MIT", - "peer": true + "license": "MIT" }, "../../../../frontend/mina-signer/node_modules/cliui": { "version": "7.0.4", "dev": true, "license": "ISC", - "peer": true, "dependencies": { "string-width": "^4.2.0", "strip-ansi": "^6.0.0", @@ -2838,7 +2790,6 @@ "version": "4.6.0", "dev": true, "license": "MIT", - "peer": true, "engines": { "iojs": ">= 1.0.0", "node": ">= 0.12.0" @@ -2847,8 +2798,7 @@ "../../../../frontend/mina-signer/node_modules/collect-v8-coverage": { "version": "1.0.1", "dev": true, - "license": "MIT", - "peer": true + "license": "MIT" }, "../../../../frontend/mina-signer/node_modules/color-convert": { "version": "1.9.3", @@ -2867,7 +2817,6 @@ "version": "1.0.8", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "delayed-stream": "~1.0.0" }, @@ -2918,7 +2867,6 @@ "version": "7.0.3", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "path-key": "^3.1.0", "shebang-command": "^2.0.0", @@ -2931,14 +2879,12 @@ "../../../../frontend/mina-signer/node_modules/cssom": { "version": "0.4.4", "dev": true, - "license": "MIT", - "peer": true + "license": "MIT" }, "../../../../frontend/mina-signer/node_modules/cssstyle": { "version": "2.3.0", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "cssom": "~0.3.6" }, @@ -2949,14 +2895,12 @@ "../../../../frontend/mina-signer/node_modules/cssstyle/node_modules/cssom": { "version": "0.3.8", "dev": true, - "license": "MIT", - "peer": true + "license": "MIT" }, "../../../../frontend/mina-signer/node_modules/data-urls": { "version": "2.0.0", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "abab": "^2.0.3", "whatwg-mimetype": "^2.3.0", @@ -2985,26 +2929,22 @@ "../../../../frontend/mina-signer/node_modules/decimal.js": { "version": "10.3.1", "dev": true, - "license": "MIT", - "peer": true + "license": "MIT" }, "../../../../frontend/mina-signer/node_modules/dedent": { "version": "0.7.0", "dev": true, - "license": "MIT", - "peer": true + "license": "MIT" }, "../../../../frontend/mina-signer/node_modules/deep-is": { "version": "0.1.4", "dev": true, - "license": "MIT", - "peer": true + "license": "MIT" }, "../../../../frontend/mina-signer/node_modules/deepmerge": { "version": "4.2.2", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">=0.10.0" } @@ -3024,7 +2964,6 @@ "version": "1.0.0", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">=0.4.0" } @@ -3033,7 +2972,6 @@ "version": "3.1.0", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">=8" } @@ -3058,7 +2996,6 @@ "version": "2.0.1", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "webidl-conversions": "^5.0.0" }, @@ -3070,7 +3007,6 @@ "version": "5.0.0", "dev": true, "license": "BSD-2-Clause", - "peer": true, "engines": { "node": ">=8" } @@ -3084,7 +3020,6 @@ "version": "0.8.1", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">=10" }, @@ -3095,8 +3030,7 @@ "../../../../frontend/mina-signer/node_modules/emoji-regex": { "version": "8.0.0", "dev": true, - "license": "MIT", - "peer": true + "license": "MIT" }, "../../../../frontend/mina-signer/node_modules/env": { "version": "0.0.2", @@ -3124,7 +3058,6 @@ "version": "2.0.0", "dev": true, "license": "BSD-2-Clause", - "peer": true, "dependencies": { "esprima": "^4.0.1", "estraverse": "^5.2.0", @@ -3147,7 +3080,6 @@ "dev": true, "license": "BSD-3-Clause", "optional": true, - "peer": true, "engines": { "node": ">=0.10.0" } @@ -3168,7 +3100,6 @@ "version": "5.3.0", "dev": true, "license": "BSD-2-Clause", - "peer": true, "engines": { "node": ">=4.0" } @@ -3185,7 +3116,6 @@ "version": "5.1.1", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "cross-spawn": "^7.0.3", "get-stream": "^6.0.0", @@ -3207,7 +3137,6 @@ "../../../../frontend/mina-signer/node_modules/exit": { "version": "0.1.2", "dev": true, - "peer": true, "engines": { "node": ">= 0.8.0" } @@ -3216,7 +3145,6 @@ "version": "27.3.1", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@jest/types": "^27.2.5", "ansi-styles": "^5.0.0", @@ -3233,7 +3161,6 @@ "version": "5.2.0", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">=10" }, @@ -3249,8 +3176,7 @@ "../../../../frontend/mina-signer/node_modules/fast-levenshtein": { "version": "2.0.6", "dev": true, - "license": "MIT", - "peer": true + "license": "MIT" }, "../../../../frontend/mina-signer/node_modules/fb-watchman": { "version": "2.0.1", @@ -3287,7 +3213,6 @@ "version": "3.0.1", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "asynckit": "^0.4.0", "combined-stream": "^1.0.8", @@ -3319,7 +3244,6 @@ "version": "2.0.5", "dev": true, "license": "ISC", - "peer": true, "engines": { "node": "6.* || 8.* || >= 10.*" } @@ -3349,7 +3273,6 @@ "version": "6.0.1", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">=10" }, @@ -3423,7 +3346,6 @@ "version": "2.0.1", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "whatwg-encoding": "^1.0.5" }, @@ -3434,14 +3356,12 @@ "../../../../frontend/mina-signer/node_modules/html-escaper": { "version": "2.0.2", "dev": true, - "license": "MIT", - "peer": true + "license": "MIT" }, "../../../../frontend/mina-signer/node_modules/http-proxy-agent": { "version": "4.0.1", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@tootallnate/once": "1", "agent-base": "6", @@ -3455,7 +3375,6 @@ "version": "5.0.0", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "agent-base": "6", "debug": "4" @@ -3468,7 +3387,6 @@ "version": "2.1.0", "dev": true, "license": "Apache-2.0", - "peer": true, "engines": { "node": ">=10.17.0" } @@ -3477,7 +3395,6 @@ "version": "0.4.24", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "safer-buffer": ">= 2.1.2 < 3" }, @@ -3489,7 +3406,6 @@ "version": "3.0.3", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "pkg-dir": "^4.2.0", "resolve-cwd": "^3.0.0" @@ -3538,7 +3454,6 @@ "version": "3.0.0", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">=8" } @@ -3547,7 +3462,6 @@ "version": "2.1.0", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">=6" } @@ -3563,14 +3477,12 @@ "../../../../frontend/mina-signer/node_modules/is-potential-custom-element-name": { "version": "1.0.1", "dev": true, - "license": "MIT", - "peer": true + "license": "MIT" }, "../../../../frontend/mina-signer/node_modules/is-stream": { "version": "2.0.1", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">=8" }, @@ -3586,8 +3498,7 @@ "../../../../frontend/mina-signer/node_modules/isexe": { "version": "2.0.0", "dev": true, - "license": "ISC", - "peer": true + "license": "ISC" }, "../../../../frontend/mina-signer/node_modules/istanbul-lib-coverage": { "version": "3.2.0", @@ -3616,7 +3527,6 @@ "version": "3.0.0", "dev": true, "license": "BSD-3-Clause", - "peer": true, "dependencies": { "istanbul-lib-coverage": "^3.0.0", "make-dir": "^3.0.0", @@ -3630,7 +3540,6 @@ "version": "4.0.0", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">=8" } @@ -3639,7 +3548,6 @@ "version": "7.2.0", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "has-flag": "^4.0.0" }, @@ -3651,7 +3559,6 @@ "version": "4.0.1", "dev": true, "license": "BSD-3-Clause", - "peer": true, "dependencies": { "debug": "^4.1.1", "istanbul-lib-coverage": "^3.0.0", @@ -3665,7 +3572,6 @@ "version": "0.6.1", "dev": true, "license": "BSD-3-Clause", - "peer": true, "engines": { "node": ">=0.10.0" } @@ -3674,7 +3580,6 @@ "version": "3.0.5", "dev": true, "license": "BSD-3-Clause", - "peer": true, "dependencies": { "html-escaper": "^2.0.0", "istanbul-lib-report": "^3.0.0" @@ -3687,7 +3592,6 @@ "version": "27.3.1", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@jest/core": "^27.3.1", "import-local": "^3.0.2", @@ -3712,7 +3616,6 @@ "version": "27.3.0", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@jest/types": "^27.2.5", "execa": "^5.0.0", @@ -3726,7 +3629,6 @@ "version": "27.3.1", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@jest/environment": "^27.3.1", "@jest/test-result": "^27.3.1", @@ -3756,7 +3658,6 @@ "version": "4.3.0", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "color-convert": "^2.0.1" }, @@ -3771,7 +3672,6 @@ "version": "4.1.2", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "ansi-styles": "^4.1.0", "supports-color": "^7.1.0" @@ -3787,7 +3687,6 @@ "version": "2.0.1", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "color-name": "~1.1.4" }, @@ -3798,14 +3697,12 @@ "../../../../frontend/mina-signer/node_modules/jest-circus/node_modules/color-name": { "version": "1.1.4", "dev": true, - "license": "MIT", - "peer": true + "license": "MIT" }, "../../../../frontend/mina-signer/node_modules/jest-circus/node_modules/has-flag": { "version": "4.0.0", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">=8" } @@ -3814,7 +3711,6 @@ "version": "7.2.0", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "has-flag": "^4.0.0" }, @@ -3826,7 +3722,6 @@ "version": "27.3.1", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@jest/core": "^27.3.1", "@jest/test-result": "^27.3.1", @@ -3860,7 +3755,6 @@ "version": "4.3.0", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "color-convert": "^2.0.1" }, @@ -3875,7 +3769,6 @@ "version": "4.1.2", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "ansi-styles": "^4.1.0", "supports-color": "^7.1.0" @@ -3891,7 +3784,6 @@ "version": "2.0.1", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "color-name": "~1.1.4" }, @@ -3902,14 +3794,12 @@ "../../../../frontend/mina-signer/node_modules/jest-cli/node_modules/color-name": { "version": "1.1.4", "dev": true, - "license": "MIT", - "peer": true + "license": "MIT" }, "../../../../frontend/mina-signer/node_modules/jest-cli/node_modules/has-flag": { "version": "4.0.0", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">=8" } @@ -3918,7 +3808,6 @@ "version": "7.2.0", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "has-flag": "^4.0.0" }, @@ -3930,7 +3819,6 @@ "version": "27.3.1", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@babel/core": "^7.1.0", "@jest/test-sequencer": "^27.3.1", @@ -3970,7 +3858,6 @@ "version": "4.3.0", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "color-convert": "^2.0.1" }, @@ -3985,7 +3872,6 @@ "version": "4.1.2", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "ansi-styles": "^4.1.0", "supports-color": "^7.1.0" @@ -4001,7 +3887,6 @@ "version": "2.0.1", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "color-name": "~1.1.4" }, @@ -4012,14 +3897,12 @@ "../../../../frontend/mina-signer/node_modules/jest-config/node_modules/color-name": { "version": "1.1.4", "dev": true, - "license": "MIT", - "peer": true + "license": "MIT" }, "../../../../frontend/mina-signer/node_modules/jest-config/node_modules/has-flag": { "version": "4.0.0", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">=8" } @@ -4028,7 +3911,6 @@ "version": "7.2.0", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "has-flag": "^4.0.0" }, @@ -4118,7 +4000,6 @@ "version": "27.0.6", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "detect-newline": "^3.0.0" }, @@ -4130,7 +4011,6 @@ "version": "27.3.1", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@jest/types": "^27.2.5", "chalk": "^4.0.0", @@ -4146,7 +4026,6 @@ "version": "4.3.0", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "color-convert": "^2.0.1" }, @@ -4161,7 +4040,6 @@ "version": "4.1.2", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "ansi-styles": "^4.1.0", "supports-color": "^7.1.0" @@ -4177,7 +4055,6 @@ "version": "2.0.1", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "color-name": "~1.1.4" }, @@ -4188,14 +4065,12 @@ "../../../../frontend/mina-signer/node_modules/jest-each/node_modules/color-name": { "version": "1.1.4", "dev": true, - "license": "MIT", - "peer": true + "license": "MIT" }, "../../../../frontend/mina-signer/node_modules/jest-each/node_modules/has-flag": { "version": "4.0.0", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">=8" } @@ -4204,7 +4079,6 @@ "version": "7.2.0", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "has-flag": "^4.0.0" }, @@ -4216,7 +4090,6 @@ "version": "27.3.1", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@jest/environment": "^27.3.1", "@jest/fake-timers": "^27.3.1", @@ -4234,7 +4107,6 @@ "version": "27.3.1", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@jest/environment": "^27.3.1", "@jest/fake-timers": "^27.3.1", @@ -4284,7 +4156,6 @@ "version": "27.3.1", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@babel/traverse": "^7.1.0", "@jest/environment": "^27.3.1", @@ -4313,7 +4184,6 @@ "version": "4.3.0", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "color-convert": "^2.0.1" }, @@ -4328,7 +4198,6 @@ "version": "4.1.2", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "ansi-styles": "^4.1.0", "supports-color": "^7.1.0" @@ -4344,7 +4213,6 @@ "version": "2.0.1", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "color-name": "~1.1.4" }, @@ -4355,14 +4223,12 @@ "../../../../frontend/mina-signer/node_modules/jest-jasmine2/node_modules/color-name": { "version": "1.1.4", "dev": true, - "license": "MIT", - "peer": true + "license": "MIT" }, "../../../../frontend/mina-signer/node_modules/jest-jasmine2/node_modules/has-flag": { "version": "4.0.0", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">=8" } @@ -4371,7 +4237,6 @@ "version": "7.2.0", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "has-flag": "^4.0.0" }, @@ -4383,7 +4248,6 @@ "version": "27.3.1", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "jest-get-type": "^27.3.1", "pretty-format": "^27.3.1" @@ -4396,7 +4260,6 @@ "version": "27.3.1", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "chalk": "^4.0.0", "jest-diff": "^27.3.1", @@ -4411,7 +4274,6 @@ "version": "4.3.0", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "color-convert": "^2.0.1" }, @@ -4426,7 +4288,6 @@ "version": "4.1.2", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "ansi-styles": "^4.1.0", "supports-color": "^7.1.0" @@ -4442,7 +4303,6 @@ "version": "2.0.1", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "color-name": "~1.1.4" }, @@ -4453,14 +4313,12 @@ "../../../../frontend/mina-signer/node_modules/jest-matcher-utils/node_modules/color-name": { "version": "1.1.4", "dev": true, - "license": "MIT", - "peer": true + "license": "MIT" }, "../../../../frontend/mina-signer/node_modules/jest-matcher-utils/node_modules/has-flag": { "version": "4.0.0", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">=8" } @@ -4469,7 +4327,6 @@ "version": "7.2.0", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "has-flag": "^4.0.0" }, @@ -4481,7 +4338,6 @@ "version": "27.3.1", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@babel/code-frame": "^7.12.13", "@jest/types": "^27.2.5", @@ -4501,7 +4357,6 @@ "version": "4.3.0", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "color-convert": "^2.0.1" }, @@ -4516,7 +4371,6 @@ "version": "4.1.2", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "ansi-styles": "^4.1.0", "supports-color": "^7.1.0" @@ -4532,7 +4386,6 @@ "version": "2.0.1", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "color-name": "~1.1.4" }, @@ -4543,14 +4396,12 @@ "../../../../frontend/mina-signer/node_modules/jest-message-util/node_modules/color-name": { "version": "1.1.4", "dev": true, - "license": "MIT", - "peer": true + "license": "MIT" }, "../../../../frontend/mina-signer/node_modules/jest-message-util/node_modules/has-flag": { "version": "4.0.0", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">=8" } @@ -4559,7 +4410,6 @@ "version": "7.2.0", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "has-flag": "^4.0.0" }, @@ -4571,7 +4421,6 @@ "version": "27.3.0", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@jest/types": "^27.2.5", "@types/node": "*" @@ -4584,7 +4433,6 @@ "version": "1.2.2", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">=6" }, @@ -4609,7 +4457,6 @@ "version": "27.3.1", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@jest/types": "^27.2.5", "chalk": "^4.0.0", @@ -4630,7 +4477,6 @@ "version": "27.3.1", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@jest/types": "^27.2.5", "jest-regex-util": "^27.0.6", @@ -4644,7 +4490,6 @@ "version": "4.3.0", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "color-convert": "^2.0.1" }, @@ -4659,7 +4504,6 @@ "version": "4.1.2", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "ansi-styles": "^4.1.0", "supports-color": "^7.1.0" @@ -4675,7 +4519,6 @@ "version": "2.0.1", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "color-name": "~1.1.4" }, @@ -4686,14 +4529,12 @@ "../../../../frontend/mina-signer/node_modules/jest-resolve/node_modules/color-name": { "version": "1.1.4", "dev": true, - "license": "MIT", - "peer": true + "license": "MIT" }, "../../../../frontend/mina-signer/node_modules/jest-resolve/node_modules/has-flag": { "version": "4.0.0", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">=8" } @@ -4702,7 +4543,6 @@ "version": "7.2.0", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "has-flag": "^4.0.0" }, @@ -4714,7 +4554,6 @@ "version": "27.3.1", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@jest/console": "^27.3.1", "@jest/environment": "^27.3.1", @@ -4747,7 +4586,6 @@ "version": "4.3.0", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "color-convert": "^2.0.1" }, @@ -4762,7 +4600,6 @@ "version": "4.1.2", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "ansi-styles": "^4.1.0", "supports-color": "^7.1.0" @@ -4778,7 +4615,6 @@ "version": "2.0.1", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "color-name": "~1.1.4" }, @@ -4789,14 +4625,12 @@ "../../../../frontend/mina-signer/node_modules/jest-runner/node_modules/color-name": { "version": "1.1.4", "dev": true, - "license": "MIT", - "peer": true + "license": "MIT" }, "../../../../frontend/mina-signer/node_modules/jest-runner/node_modules/has-flag": { "version": "4.0.0", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">=8" } @@ -4805,7 +4639,6 @@ "version": "7.2.0", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "has-flag": "^4.0.0" }, @@ -4817,7 +4650,6 @@ "version": "27.3.1", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@jest/console": "^27.3.1", "@jest/environment": "^27.3.1", @@ -4854,7 +4686,6 @@ "version": "4.3.0", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "color-convert": "^2.0.1" }, @@ -4869,7 +4700,6 @@ "version": "4.1.2", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "ansi-styles": "^4.1.0", "supports-color": "^7.1.0" @@ -4885,7 +4715,6 @@ "version": "2.0.1", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "color-name": "~1.1.4" }, @@ -4896,14 +4725,12 @@ "../../../../frontend/mina-signer/node_modules/jest-runtime/node_modules/color-name": { "version": "1.1.4", "dev": true, - "license": "MIT", - "peer": true + "license": "MIT" }, "../../../../frontend/mina-signer/node_modules/jest-runtime/node_modules/has-flag": { "version": "4.0.0", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">=8" } @@ -4912,7 +4739,6 @@ "version": "7.2.0", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "has-flag": "^4.0.0" }, @@ -4936,7 +4762,6 @@ "version": "27.3.1", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@babel/core": "^7.7.2", "@babel/generator": "^7.7.2", @@ -4971,7 +4796,6 @@ "version": "4.3.0", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "color-convert": "^2.0.1" }, @@ -4986,7 +4810,6 @@ "version": "4.1.2", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "ansi-styles": "^4.1.0", "supports-color": "^7.1.0" @@ -5002,7 +4825,6 @@ "version": "2.0.1", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "color-name": "~1.1.4" }, @@ -5013,14 +4835,12 @@ "../../../../frontend/mina-signer/node_modules/jest-snapshot/node_modules/color-name": { "version": "1.1.4", "dev": true, - "license": "MIT", - "peer": true + "license": "MIT" }, "../../../../frontend/mina-signer/node_modules/jest-snapshot/node_modules/has-flag": { "version": "4.0.0", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">=8" } @@ -5029,7 +4849,6 @@ "version": "7.3.5", "dev": true, "license": "ISC", - "peer": true, "dependencies": { "lru-cache": "^6.0.0" }, @@ -5044,7 +4863,6 @@ "version": "7.2.0", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "has-flag": "^4.0.0" }, @@ -5136,7 +4954,6 @@ "version": "27.3.1", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@jest/types": "^27.2.5", "camelcase": "^6.2.0", @@ -5153,7 +4970,6 @@ "version": "4.3.0", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "color-convert": "^2.0.1" }, @@ -5168,7 +4984,6 @@ "version": "6.2.1", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">=10" }, @@ -5180,7 +4995,6 @@ "version": "4.1.2", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "ansi-styles": "^4.1.0", "supports-color": "^7.1.0" @@ -5196,7 +5010,6 @@ "version": "2.0.1", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "color-name": "~1.1.4" }, @@ -5207,14 +5020,12 @@ "../../../../frontend/mina-signer/node_modules/jest-validate/node_modules/color-name": { "version": "1.1.4", "dev": true, - "license": "MIT", - "peer": true + "license": "MIT" }, "../../../../frontend/mina-signer/node_modules/jest-validate/node_modules/has-flag": { "version": "4.0.0", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">=8" } @@ -5223,7 +5034,6 @@ "version": "7.2.0", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "has-flag": "^4.0.0" }, @@ -5235,7 +5045,6 @@ "version": "27.3.1", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@jest/test-result": "^27.3.1", "@jest/types": "^27.2.5", @@ -5253,7 +5062,6 @@ "version": "4.3.0", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "color-convert": "^2.0.1" }, @@ -5268,7 +5076,6 @@ "version": "4.1.2", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "ansi-styles": "^4.1.0", "supports-color": "^7.1.0" @@ -5284,7 +5091,6 @@ "version": "2.0.1", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "color-name": "~1.1.4" }, @@ -5295,14 +5101,12 @@ "../../../../frontend/mina-signer/node_modules/jest-watcher/node_modules/color-name": { "version": "1.1.4", "dev": true, - "license": "MIT", - "peer": true + "license": "MIT" }, "../../../../frontend/mina-signer/node_modules/jest-watcher/node_modules/has-flag": { "version": "4.0.0", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">=8" } @@ -5311,7 +5115,6 @@ "version": "7.2.0", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "has-flag": "^4.0.0" }, @@ -5375,7 +5178,6 @@ "version": "16.7.0", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "abab": "^2.0.5", "acorn": "^8.2.4", @@ -5446,7 +5248,6 @@ "version": "3.0.3", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">=6" } @@ -5455,7 +5256,6 @@ "version": "3.1.0", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">=6" } @@ -5464,7 +5264,6 @@ "version": "0.3.0", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "prelude-ls": "~1.1.2", "type-check": "~0.3.2" @@ -5487,8 +5286,7 @@ "../../../../frontend/mina-signer/node_modules/lodash": { "version": "4.17.21", "dev": true, - "license": "MIT", - "peer": true + "license": "MIT" }, "../../../../frontend/mina-signer/node_modules/lodash.debounce": { "version": "4.0.8", @@ -5515,7 +5313,6 @@ "version": "3.1.0", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "semver": "^6.0.0" }, @@ -5560,7 +5357,6 @@ "version": "1.51.0", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">= 0.6" } @@ -5569,7 +5365,6 @@ "version": "2.1.34", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "mime-db": "1.51.0" }, @@ -5581,7 +5376,6 @@ "version": "2.1.0", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">=6" } @@ -5610,8 +5404,7 @@ "../../../../frontend/mina-signer/node_modules/natural-compare": { "version": "1.4.0", "dev": true, - "license": "MIT", - "peer": true + "license": "MIT" }, "../../../../frontend/mina-signer/node_modules/node-int64": { "version": "0.4.0", @@ -5643,7 +5436,6 @@ "version": "4.0.1", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "path-key": "^3.0.0" }, @@ -5654,8 +5446,7 @@ "../../../../frontend/mina-signer/node_modules/nwsapi": { "version": "2.2.0", "dev": true, - "license": "MIT", - "peer": true + "license": "MIT" }, "../../../../frontend/mina-signer/node_modules/object-keys": { "version": "1.1.1", @@ -5694,7 +5485,6 @@ "version": "5.1.2", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "mimic-fn": "^2.1.0" }, @@ -5709,7 +5499,6 @@ "version": "0.8.3", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "deep-is": "~0.1.3", "fast-levenshtein": "~2.0.6", @@ -5758,8 +5547,7 @@ "../../../../frontend/mina-signer/node_modules/parse5": { "version": "6.0.1", "dev": true, - "license": "MIT", - "peer": true + "license": "MIT" }, "../../../../frontend/mina-signer/node_modules/path-exists": { "version": "4.0.0", @@ -5781,7 +5569,6 @@ "version": "3.1.1", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">=8" } @@ -5822,7 +5609,6 @@ "version": "4.2.0", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "find-up": "^4.0.0" }, @@ -5833,7 +5619,6 @@ "../../../../frontend/mina-signer/node_modules/prelude-ls": { "version": "1.1.2", "dev": true, - "peer": true, "engines": { "node": ">= 0.8.0" } @@ -5867,7 +5652,6 @@ "version": "2.4.2", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "kleur": "^3.0.3", "sisteransi": "^1.0.5" @@ -5879,14 +5663,12 @@ "../../../../frontend/mina-signer/node_modules/psl": { "version": "1.8.0", "dev": true, - "license": "MIT", - "peer": true + "license": "MIT" }, "../../../../frontend/mina-signer/node_modules/punycode": { "version": "2.1.1", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">=6" } @@ -5968,7 +5750,6 @@ "version": "2.1.1", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">=0.10.0" } @@ -5989,7 +5770,6 @@ "version": "3.0.0", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "resolve-from": "^5.0.0" }, @@ -6009,7 +5789,6 @@ "version": "1.1.0", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">=10" } @@ -6018,7 +5797,6 @@ "version": "3.0.2", "dev": true, "license": "ISC", - "peer": true, "dependencies": { "glob": "^7.1.3" }, @@ -6037,14 +5815,12 @@ "../../../../frontend/mina-signer/node_modules/safer-buffer": { "version": "2.1.2", "dev": true, - "license": "MIT", - "peer": true + "license": "MIT" }, "../../../../frontend/mina-signer/node_modules/saxes": { "version": "5.0.1", "dev": true, "license": "ISC", - "peer": true, "dependencies": { "xmlchars": "^2.2.0" }, @@ -6064,7 +5840,6 @@ "version": "2.0.0", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "shebang-regex": "^3.0.0" }, @@ -6076,7 +5851,6 @@ "version": "3.0.0", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">=8" } @@ -6089,8 +5863,7 @@ "../../../../frontend/mina-signer/node_modules/sisteransi": { "version": "1.0.5", "dev": true, - "license": "MIT", - "peer": true + "license": "MIT" }, "../../../../frontend/mina-signer/node_modules/slash": { "version": "3.0.0", @@ -6112,7 +5885,6 @@ "version": "0.5.21", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "buffer-from": "^1.0.0", "source-map": "^0.6.0" @@ -6122,7 +5894,6 @@ "version": "0.6.1", "dev": true, "license": "BSD-3-Clause", - "peer": true, "engines": { "node": ">=0.10.0" } @@ -6136,7 +5907,6 @@ "version": "2.0.5", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "escape-string-regexp": "^2.0.0" }, @@ -6148,7 +5918,6 @@ "version": "2.0.0", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">=8" } @@ -6157,7 +5926,6 @@ "version": "4.0.2", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "char-regex": "^1.0.2", "strip-ansi": "^6.0.0" @@ -6170,7 +5938,6 @@ "version": "4.2.3", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "emoji-regex": "^8.0.0", "is-fullwidth-code-point": "^3.0.0", @@ -6184,7 +5951,6 @@ "version": "6.0.1", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "ansi-regex": "^5.0.1" }, @@ -6196,7 +5962,6 @@ "version": "4.0.0", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">=8" } @@ -6205,7 +5970,6 @@ "version": "2.0.0", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">=6" } @@ -6225,7 +5989,6 @@ "version": "2.2.0", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "has-flag": "^4.0.0", "supports-color": "^7.0.0" @@ -6238,7 +6001,6 @@ "version": "4.0.0", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">=8" } @@ -6247,7 +6009,6 @@ "version": "7.2.0", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "has-flag": "^4.0.0" }, @@ -6258,14 +6019,12 @@ "../../../../frontend/mina-signer/node_modules/symbol-tree": { "version": "3.2.4", "dev": true, - "license": "MIT", - "peer": true + "license": "MIT" }, "../../../../frontend/mina-signer/node_modules/terminal-link": { "version": "2.1.1", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "ansi-escapes": "^4.2.1", "supports-hyperlinks": "^2.0.0" @@ -6293,8 +6052,7 @@ "../../../../frontend/mina-signer/node_modules/throat": { "version": "6.0.1", "dev": true, - "license": "MIT", - "peer": true + "license": "MIT" }, "../../../../frontend/mina-signer/node_modules/tmpl": { "version": "1.0.5", @@ -6324,7 +6082,6 @@ "version": "4.0.0", "dev": true, "license": "BSD-3-Clause", - "peer": true, "dependencies": { "psl": "^1.1.33", "punycode": "^2.1.1", @@ -6338,7 +6095,6 @@ "version": "2.1.0", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "punycode": "^2.1.1" }, @@ -6451,7 +6207,6 @@ "version": "0.3.2", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "prelude-ls": "~1.1.2" }, @@ -6463,7 +6218,6 @@ "version": "4.0.8", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">=4" } @@ -6472,7 +6226,6 @@ "version": "0.21.3", "dev": true, "license": "(MIT OR CC0-1.0)", - "peer": true, "engines": { "node": ">=10" }, @@ -6540,7 +6293,6 @@ "version": "0.1.2", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">= 4.0.0" } @@ -6549,7 +6301,6 @@ "version": "8.1.0", "dev": true, "license": "ISC", - "peer": true, "dependencies": { "@types/istanbul-lib-coverage": "^2.0.1", "convert-source-map": "^1.6.0", @@ -6563,7 +6314,6 @@ "version": "0.7.3", "dev": true, "license": "BSD-3-Clause", - "peer": true, "engines": { "node": ">= 8" } @@ -6572,7 +6322,6 @@ "version": "1.0.2", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "browser-process-hrtime": "^1.0.0" } @@ -6581,7 +6330,6 @@ "version": "2.0.0", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "xml-name-validator": "^3.0.0" }, @@ -6601,7 +6349,6 @@ "version": "6.1.0", "dev": true, "license": "BSD-2-Clause", - "peer": true, "engines": { "node": ">=10.4" } @@ -6610,7 +6357,6 @@ "version": "1.0.5", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "iconv-lite": "0.4.24" } @@ -6618,14 +6364,12 @@ "../../../../frontend/mina-signer/node_modules/whatwg-mimetype": { "version": "2.3.0", "dev": true, - "license": "MIT", - "peer": true + "license": "MIT" }, "../../../../frontend/mina-signer/node_modules/whatwg-url": { "version": "8.7.0", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "lodash": "^4.7.0", "tr46": "^2.1.0", @@ -6639,7 +6383,6 @@ "version": "2.0.2", "dev": true, "license": "ISC", - "peer": true, "dependencies": { "isexe": "^2.0.0" }, @@ -6654,7 +6397,6 @@ "version": "1.2.3", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">=0.10.0" } @@ -6663,7 +6405,6 @@ "version": "7.0.0", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "ansi-styles": "^4.0.0", "string-width": "^4.1.0", @@ -6680,7 +6421,6 @@ "version": "4.3.0", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "color-convert": "^2.0.1" }, @@ -6695,7 +6435,6 @@ "version": "2.0.1", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "color-name": "~1.1.4" }, @@ -6706,8 +6445,7 @@ "../../../../frontend/mina-signer/node_modules/wrap-ansi/node_modules/color-name": { "version": "1.1.4", "dev": true, - "license": "MIT", - "peer": true + "license": "MIT" }, "../../../../frontend/mina-signer/node_modules/wrappy": { "version": "1.0.2", @@ -6729,7 +6467,6 @@ "version": "7.5.5", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">=8.3.0" }, @@ -6749,20 +6486,17 @@ "../../../../frontend/mina-signer/node_modules/xml-name-validator": { "version": "3.0.0", "dev": true, - "license": "Apache-2.0", - "peer": true + "license": "Apache-2.0" }, "../../../../frontend/mina-signer/node_modules/xmlchars": { "version": "2.2.0", "dev": true, - "license": "MIT", - "peer": true + "license": "MIT" }, "../../../../frontend/mina-signer/node_modules/y18n": { "version": "5.0.8", "dev": true, "license": "ISC", - "peer": true, "engines": { "node": ">=10" } @@ -6776,7 +6510,6 @@ "version": "16.2.0", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "cliui": "^7.0.2", "escalade": "^3.1.1", @@ -6807,10 +6540,11 @@ } }, "../snarkyjs": { - "version": "0.2.0", + "version": "0.5.2", "license": "Apache-2.0", "dependencies": { "env": "^0.0.2", + "isomorphic-fetch": "^3.0.0", "reflect-metadata": "^0.1.13", "tslib": "^2.3.0" }, @@ -6818,17 +6552,22 @@ "snarky-run": "src/build/run.js" }, "devDependencies": { + "@types/isomorphic-fetch": "^0.0.36", "@types/jest": "^27.0.0", + "@types/node": "^18.7.13", "@typescript-eslint/eslint-plugin": "^5.0.0", "esbuild": "^0.13.13", "eslint": "^8.0.0", + "expect": "^29.0.1", "fs-extra": "^10.0.0", - "jest": "^27.0.6", + "howslow": "^0.1.0", + "jest": "^28.1.3", "minimist": "^1.2.5", "prettier": "^2.3.2", - "ts-jest": "^27.0.4", - "typedoc": "^0.22.9", - "typescript": "^4.4.4" + "rimraf": "^3.0.2", + "ts-jest": "^28.0.8", + "typedoc": "^0.23.11", + "typescript": "^4.8.2" }, "engines": { "node": ">=16.4.0" @@ -13179,6 +12918,7 @@ "@types/node": "^13.7.0", "babel-jest": "^27.3.1", "env": "^0.0.2", + "jest": "^27.3.1", "ts-jest": "^27.0.7", "ts-node": "^10.4.0", "typescript": "^4.5.2" @@ -14094,8 +13834,7 @@ }, "@bcoe/v8-coverage": { "version": "0.2.3", - "dev": true, - "peer": true + "dev": true }, "@cspotcode/source-map-consumer": { "version": "0.8.0", @@ -14126,7 +13865,6 @@ "@jest/console": { "version": "27.3.1", "dev": true, - "peer": true, "requires": { "@jest/types": "^27.2.5", "@types/node": "*", @@ -14139,7 +13877,6 @@ "ansi-styles": { "version": "4.3.0", "dev": true, - "peer": true, "requires": { "color-convert": "^2.0.1" } @@ -14147,7 +13884,6 @@ "chalk": { "version": "4.1.2", "dev": true, - "peer": true, "requires": { "ansi-styles": "^4.1.0", "supports-color": "^7.1.0" @@ -14156,25 +13892,21 @@ "color-convert": { "version": "2.0.1", "dev": true, - "peer": true, "requires": { "color-name": "~1.1.4" } }, "color-name": { "version": "1.1.4", - "dev": true, - "peer": true + "dev": true }, "has-flag": { "version": "4.0.0", - "dev": true, - "peer": true + "dev": true }, "supports-color": { "version": "7.2.0", "dev": true, - "peer": true, "requires": { "has-flag": "^4.0.0" } @@ -14184,7 +13916,6 @@ "@jest/core": { "version": "27.3.1", "dev": true, - "peer": true, "requires": { "@jest/console": "^27.3.1", "@jest/reporters": "^27.3.1", @@ -14219,7 +13950,6 @@ "ansi-styles": { "version": "4.3.0", "dev": true, - "peer": true, "requires": { "color-convert": "^2.0.1" } @@ -14227,7 +13957,6 @@ "chalk": { "version": "4.1.2", "dev": true, - "peer": true, "requires": { "ansi-styles": "^4.1.0", "supports-color": "^7.1.0" @@ -14236,25 +13965,21 @@ "color-convert": { "version": "2.0.1", "dev": true, - "peer": true, "requires": { "color-name": "~1.1.4" } }, "color-name": { "version": "1.1.4", - "dev": true, - "peer": true + "dev": true }, "has-flag": { "version": "4.0.0", - "dev": true, - "peer": true + "dev": true }, "supports-color": { "version": "7.2.0", "dev": true, - "peer": true, "requires": { "has-flag": "^4.0.0" } @@ -14264,7 +13989,6 @@ "@jest/environment": { "version": "27.3.1", "dev": true, - "peer": true, "requires": { "@jest/fake-timers": "^27.3.1", "@jest/types": "^27.2.5", @@ -14275,7 +13999,6 @@ "@jest/fake-timers": { "version": "27.3.1", "dev": true, - "peer": true, "requires": { "@jest/types": "^27.2.5", "@sinonjs/fake-timers": "^8.0.1", @@ -14288,7 +14011,6 @@ "@jest/globals": { "version": "27.3.1", "dev": true, - "peer": true, "requires": { "@jest/environment": "^27.3.1", "@jest/types": "^27.2.5", @@ -14298,7 +14020,6 @@ "@jest/reporters": { "version": "27.3.1", "dev": true, - "peer": true, "requires": { "@bcoe/v8-coverage": "^0.2.3", "@jest/console": "^27.3.1", @@ -14330,7 +14051,6 @@ "ansi-styles": { "version": "4.3.0", "dev": true, - "peer": true, "requires": { "color-convert": "^2.0.1" } @@ -14338,7 +14058,6 @@ "chalk": { "version": "4.1.2", "dev": true, - "peer": true, "requires": { "ansi-styles": "^4.1.0", "supports-color": "^7.1.0" @@ -14347,25 +14066,21 @@ "color-convert": { "version": "2.0.1", "dev": true, - "peer": true, "requires": { "color-name": "~1.1.4" } }, "color-name": { "version": "1.1.4", - "dev": true, - "peer": true + "dev": true }, "has-flag": { "version": "4.0.0", - "dev": true, - "peer": true + "dev": true }, "istanbul-lib-instrument": { "version": "4.0.3", "dev": true, - "peer": true, "requires": { "@babel/core": "^7.7.5", "@istanbuljs/schema": "^0.1.2", @@ -14375,13 +14090,11 @@ }, "source-map": { "version": "0.6.1", - "dev": true, - "peer": true + "dev": true }, "supports-color": { "version": "7.2.0", "dev": true, - "peer": true, "requires": { "has-flag": "^4.0.0" } @@ -14391,7 +14104,6 @@ "@jest/source-map": { "version": "27.0.6", "dev": true, - "peer": true, "requires": { "callsites": "^3.0.0", "graceful-fs": "^4.2.4", @@ -14400,15 +14112,13 @@ "dependencies": { "source-map": { "version": "0.6.1", - "dev": true, - "peer": true + "dev": true } } }, "@jest/test-result": { "version": "27.3.1", "dev": true, - "peer": true, "requires": { "@jest/console": "^27.3.1", "@jest/types": "^27.2.5", @@ -14419,7 +14129,6 @@ "@jest/test-sequencer": { "version": "27.3.1", "dev": true, - "peer": true, "requires": { "@jest/test-result": "^27.3.1", "graceful-fs": "^4.2.4", @@ -14544,7 +14253,6 @@ "@sinonjs/commons": { "version": "1.8.3", "dev": true, - "peer": true, "requires": { "type-detect": "4.0.8" } @@ -14552,15 +14260,13 @@ "@sinonjs/fake-timers": { "version": "8.1.0", "dev": true, - "peer": true, "requires": { "@sinonjs/commons": "^1.7.0" } }, "@tootallnate/once": { "version": "1.1.2", - "dev": true, - "peer": true + "dev": true }, "@tsconfig/node10": { "version": "1.0.8", @@ -14649,13 +14355,11 @@ }, "@types/prettier": { "version": "2.4.2", - "dev": true, - "peer": true + "dev": true }, "@types/stack-utils": { "version": "2.0.1", - "dev": true, - "peer": true + "dev": true }, "@types/yargs": { "version": "16.0.4", @@ -14670,8 +14374,7 @@ }, "abab": { "version": "2.0.5", - "dev": true, - "peer": true + "dev": true }, "acorn": { "version": "8.6.0", @@ -14680,7 +14383,6 @@ "acorn-globals": { "version": "6.0.0", "dev": true, - "peer": true, "requires": { "acorn": "^7.1.1", "acorn-walk": "^7.1.1" @@ -14688,20 +14390,17 @@ "dependencies": { "acorn": { "version": "7.4.1", - "dev": true, - "peer": true + "dev": true } } }, "acorn-walk": { "version": "7.2.0", - "dev": true, - "peer": true + "dev": true }, "agent-base": { "version": "6.0.2", "dev": true, - "peer": true, "requires": { "debug": "4" } @@ -14709,7 +14408,6 @@ "ansi-escapes": { "version": "4.3.2", "dev": true, - "peer": true, "requires": { "type-fest": "^0.21.3" } @@ -14746,8 +14444,7 @@ }, "asynckit": { "version": "0.4.0", - "dev": true, - "peer": true + "dev": true }, "babel-jest": { "version": "27.3.1", @@ -14901,8 +14598,7 @@ }, "browser-process-hrtime": { "version": "1.0.0", - "dev": true, - "peer": true + "dev": true }, "browserslist": { "version": "4.18.1", @@ -14931,8 +14627,7 @@ }, "buffer-from": { "version": "1.1.2", - "dev": true, - "peer": true + "dev": true }, "call-bind": { "version": "1.0.2", @@ -14944,8 +14639,7 @@ }, "callsites": { "version": "3.1.0", - "dev": true, - "peer": true + "dev": true }, "camelcase": { "version": "5.3.1", @@ -14966,8 +14660,7 @@ }, "char-regex": { "version": "1.0.2", - "dev": true, - "peer": true + "dev": true }, "ci-info": { "version": "3.2.0", @@ -14975,13 +14668,11 @@ }, "cjs-module-lexer": { "version": "1.2.2", - "dev": true, - "peer": true + "dev": true }, "cliui": { "version": "7.0.4", "dev": true, - "peer": true, "requires": { "string-width": "^4.2.0", "strip-ansi": "^6.0.0", @@ -14990,13 +14681,11 @@ }, "co": { "version": "4.6.0", - "dev": true, - "peer": true + "dev": true }, "collect-v8-coverage": { "version": "1.0.1", - "dev": true, - "peer": true + "dev": true }, "color-convert": { "version": "1.9.3", @@ -15012,7 +14701,6 @@ "combined-stream": { "version": "1.0.8", "dev": true, - "peer": true, "requires": { "delayed-stream": "~1.0.0" } @@ -15049,7 +14737,6 @@ "cross-spawn": { "version": "7.0.3", "dev": true, - "peer": true, "requires": { "path-key": "^3.1.0", "shebang-command": "^2.0.0", @@ -15058,28 +14745,24 @@ }, "cssom": { "version": "0.4.4", - "dev": true, - "peer": true + "dev": true }, "cssstyle": { "version": "2.3.0", "dev": true, - "peer": true, "requires": { "cssom": "~0.3.6" }, "dependencies": { "cssom": { "version": "0.3.8", - "dev": true, - "peer": true + "dev": true } } }, "data-urls": { "version": "2.0.0", "dev": true, - "peer": true, "requires": { "abab": "^2.0.3", "whatwg-mimetype": "^2.3.0", @@ -15095,23 +14778,19 @@ }, "decimal.js": { "version": "10.3.1", - "dev": true, - "peer": true + "dev": true }, "dedent": { "version": "0.7.0", - "dev": true, - "peer": true + "dev": true }, "deep-is": { "version": "0.1.4", - "dev": true, - "peer": true + "dev": true }, "deepmerge": { "version": "4.2.2", - "dev": true, - "peer": true + "dev": true }, "define-properties": { "version": "1.1.3", @@ -15122,13 +14801,11 @@ }, "delayed-stream": { "version": "1.0.0", - "dev": true, - "peer": true + "dev": true }, "detect-newline": { "version": "3.1.0", - "dev": true, - "peer": true + "dev": true }, "diff": { "version": "4.0.2", @@ -15141,15 +14818,13 @@ "domexception": { "version": "2.0.1", "dev": true, - "peer": true, "requires": { "webidl-conversions": "^5.0.0" }, "dependencies": { "webidl-conversions": { "version": "5.0.0", - "dev": true, - "peer": true + "dev": true } } }, @@ -15159,13 +14834,11 @@ }, "emittery": { "version": "0.8.1", - "dev": true, - "peer": true + "dev": true }, "emoji-regex": { "version": "8.0.0", - "dev": true, - "peer": true + "dev": true }, "env": { "version": "0.0.2" @@ -15181,7 +14854,6 @@ "escodegen": { "version": "2.0.0", "dev": true, - "peer": true, "requires": { "esprima": "^4.0.1", "estraverse": "^5.2.0", @@ -15193,8 +14865,7 @@ "source-map": { "version": "0.6.1", "dev": true, - "optional": true, - "peer": true + "optional": true } } }, @@ -15204,8 +14875,7 @@ }, "estraverse": { "version": "5.3.0", - "dev": true, - "peer": true + "dev": true }, "esutils": { "version": "2.0.3", @@ -15214,7 +14884,6 @@ "execa": { "version": "5.1.1", "dev": true, - "peer": true, "requires": { "cross-spawn": "^7.0.3", "get-stream": "^6.0.0", @@ -15229,13 +14898,11 @@ }, "exit": { "version": "0.1.2", - "dev": true, - "peer": true + "dev": true }, "expect": { "version": "27.3.1", "dev": true, - "peer": true, "requires": { "@jest/types": "^27.2.5", "ansi-styles": "^5.0.0", @@ -15247,8 +14914,7 @@ "dependencies": { "ansi-styles": { "version": "5.2.0", - "dev": true, - "peer": true + "dev": true } } }, @@ -15258,8 +14924,7 @@ }, "fast-levenshtein": { "version": "2.0.6", - "dev": true, - "peer": true + "dev": true }, "fb-watchman": { "version": "2.0.1", @@ -15286,7 +14951,6 @@ "form-data": { "version": "3.0.1", "dev": true, - "peer": true, "requires": { "asynckit": "^0.4.0", "combined-stream": "^1.0.8", @@ -15307,8 +14971,7 @@ }, "get-caller-file": { "version": "2.0.5", - "dev": true, - "peer": true + "dev": true }, "get-intrinsic": { "version": "1.1.1", @@ -15325,8 +14988,7 @@ }, "get-stream": { "version": "6.0.1", - "dev": true, - "peer": true + "dev": true }, "glob": { "version": "7.2.0", @@ -15366,20 +15028,17 @@ "html-encoding-sniffer": { "version": "2.0.1", "dev": true, - "peer": true, "requires": { "whatwg-encoding": "^1.0.5" } }, "html-escaper": { "version": "2.0.2", - "dev": true, - "peer": true + "dev": true }, "http-proxy-agent": { "version": "4.0.1", "dev": true, - "peer": true, "requires": { "@tootallnate/once": "1", "agent-base": "6", @@ -15389,7 +15048,6 @@ "https-proxy-agent": { "version": "5.0.0", "dev": true, - "peer": true, "requires": { "agent-base": "6", "debug": "4" @@ -15397,13 +15055,11 @@ }, "human-signals": { "version": "2.1.0", - "dev": true, - "peer": true + "dev": true }, "iconv-lite": { "version": "0.4.24", "dev": true, - "peer": true, "requires": { "safer-buffer": ">= 2.1.2 < 3" } @@ -15411,7 +15067,6 @@ "import-local": { "version": "3.0.3", "dev": true, - "peer": true, "requires": { "pkg-dir": "^4.2.0", "resolve-cwd": "^3.0.0" @@ -15442,13 +15097,11 @@ }, "is-fullwidth-code-point": { "version": "3.0.0", - "dev": true, - "peer": true + "dev": true }, "is-generator-fn": { "version": "2.1.0", - "dev": true, - "peer": true + "dev": true }, "is-number": { "version": "7.0.0", @@ -15456,13 +15109,11 @@ }, "is-potential-custom-element-name": { "version": "1.0.1", - "dev": true, - "peer": true + "dev": true }, "is-stream": { "version": "2.0.1", - "dev": true, - "peer": true + "dev": true }, "is-typedarray": { "version": "1.0.0", @@ -15470,8 +15121,7 @@ }, "isexe": { "version": "2.0.0", - "dev": true, - "peer": true + "dev": true }, "istanbul-lib-coverage": { "version": "3.2.0", @@ -15491,7 +15141,6 @@ "istanbul-lib-report": { "version": "3.0.0", "dev": true, - "peer": true, "requires": { "istanbul-lib-coverage": "^3.0.0", "make-dir": "^3.0.0", @@ -15500,13 +15149,11 @@ "dependencies": { "has-flag": { "version": "4.0.0", - "dev": true, - "peer": true + "dev": true }, "supports-color": { "version": "7.2.0", "dev": true, - "peer": true, "requires": { "has-flag": "^4.0.0" } @@ -15516,7 +15163,6 @@ "istanbul-lib-source-maps": { "version": "4.0.1", "dev": true, - "peer": true, "requires": { "debug": "^4.1.1", "istanbul-lib-coverage": "^3.0.0", @@ -15525,15 +15171,13 @@ "dependencies": { "source-map": { "version": "0.6.1", - "dev": true, - "peer": true + "dev": true } } }, "istanbul-reports": { "version": "3.0.5", "dev": true, - "peer": true, "requires": { "html-escaper": "^2.0.0", "istanbul-lib-report": "^3.0.0" @@ -15542,7 +15186,6 @@ "jest": { "version": "27.3.1", "dev": true, - "peer": true, "requires": { "@jest/core": "^27.3.1", "import-local": "^3.0.2", @@ -15552,7 +15195,6 @@ "jest-changed-files": { "version": "27.3.0", "dev": true, - "peer": true, "requires": { "@jest/types": "^27.2.5", "execa": "^5.0.0", @@ -15562,7 +15204,6 @@ "jest-circus": { "version": "27.3.1", "dev": true, - "peer": true, "requires": { "@jest/environment": "^27.3.1", "@jest/test-result": "^27.3.1", @@ -15588,7 +15229,6 @@ "ansi-styles": { "version": "4.3.0", "dev": true, - "peer": true, "requires": { "color-convert": "^2.0.1" } @@ -15596,7 +15236,6 @@ "chalk": { "version": "4.1.2", "dev": true, - "peer": true, "requires": { "ansi-styles": "^4.1.0", "supports-color": "^7.1.0" @@ -15605,25 +15244,21 @@ "color-convert": { "version": "2.0.1", "dev": true, - "peer": true, "requires": { "color-name": "~1.1.4" } }, "color-name": { "version": "1.1.4", - "dev": true, - "peer": true + "dev": true }, "has-flag": { "version": "4.0.0", - "dev": true, - "peer": true + "dev": true }, "supports-color": { "version": "7.2.0", "dev": true, - "peer": true, "requires": { "has-flag": "^4.0.0" } @@ -15633,7 +15268,6 @@ "jest-cli": { "version": "27.3.1", "dev": true, - "peer": true, "requires": { "@jest/core": "^27.3.1", "@jest/test-result": "^27.3.1", @@ -15652,7 +15286,6 @@ "ansi-styles": { "version": "4.3.0", "dev": true, - "peer": true, "requires": { "color-convert": "^2.0.1" } @@ -15660,7 +15293,6 @@ "chalk": { "version": "4.1.2", "dev": true, - "peer": true, "requires": { "ansi-styles": "^4.1.0", "supports-color": "^7.1.0" @@ -15669,25 +15301,21 @@ "color-convert": { "version": "2.0.1", "dev": true, - "peer": true, "requires": { "color-name": "~1.1.4" } }, "color-name": { "version": "1.1.4", - "dev": true, - "peer": true + "dev": true }, "has-flag": { "version": "4.0.0", - "dev": true, - "peer": true + "dev": true }, "supports-color": { "version": "7.2.0", "dev": true, - "peer": true, "requires": { "has-flag": "^4.0.0" } @@ -15697,7 +15325,6 @@ "jest-config": { "version": "27.3.1", "dev": true, - "peer": true, "requires": { "@babel/core": "^7.1.0", "@jest/test-sequencer": "^27.3.1", @@ -15725,7 +15352,6 @@ "ansi-styles": { "version": "4.3.0", "dev": true, - "peer": true, "requires": { "color-convert": "^2.0.1" } @@ -15733,7 +15359,6 @@ "chalk": { "version": "4.1.2", "dev": true, - "peer": true, "requires": { "ansi-styles": "^4.1.0", "supports-color": "^7.1.0" @@ -15742,25 +15367,21 @@ "color-convert": { "version": "2.0.1", "dev": true, - "peer": true, "requires": { "color-name": "~1.1.4" } }, "color-name": { "version": "1.1.4", - "dev": true, - "peer": true + "dev": true }, "has-flag": { "version": "4.0.0", - "dev": true, - "peer": true + "dev": true }, "supports-color": { "version": "7.2.0", "dev": true, - "peer": true, "requires": { "has-flag": "^4.0.0" } @@ -15819,7 +15440,6 @@ "jest-docblock": { "version": "27.0.6", "dev": true, - "peer": true, "requires": { "detect-newline": "^3.0.0" } @@ -15827,7 +15447,6 @@ "jest-each": { "version": "27.3.1", "dev": true, - "peer": true, "requires": { "@jest/types": "^27.2.5", "chalk": "^4.0.0", @@ -15839,7 +15458,6 @@ "ansi-styles": { "version": "4.3.0", "dev": true, - "peer": true, "requires": { "color-convert": "^2.0.1" } @@ -15847,7 +15465,6 @@ "chalk": { "version": "4.1.2", "dev": true, - "peer": true, "requires": { "ansi-styles": "^4.1.0", "supports-color": "^7.1.0" @@ -15856,25 +15473,21 @@ "color-convert": { "version": "2.0.1", "dev": true, - "peer": true, "requires": { "color-name": "~1.1.4" } }, "color-name": { "version": "1.1.4", - "dev": true, - "peer": true + "dev": true }, "has-flag": { "version": "4.0.0", - "dev": true, - "peer": true + "dev": true }, "supports-color": { "version": "7.2.0", "dev": true, - "peer": true, "requires": { "has-flag": "^4.0.0" } @@ -15884,7 +15497,6 @@ "jest-environment-jsdom": { "version": "27.3.1", "dev": true, - "peer": true, "requires": { "@jest/environment": "^27.3.1", "@jest/fake-timers": "^27.3.1", @@ -15898,7 +15510,6 @@ "jest-environment-node": { "version": "27.3.1", "dev": true, - "peer": true, "requires": { "@jest/environment": "^27.3.1", "@jest/fake-timers": "^27.3.1", @@ -15934,7 +15545,6 @@ "jest-jasmine2": { "version": "27.3.1", "dev": true, - "peer": true, "requires": { "@babel/traverse": "^7.1.0", "@jest/environment": "^27.3.1", @@ -15959,7 +15569,6 @@ "ansi-styles": { "version": "4.3.0", "dev": true, - "peer": true, "requires": { "color-convert": "^2.0.1" } @@ -15967,7 +15576,6 @@ "chalk": { "version": "4.1.2", "dev": true, - "peer": true, "requires": { "ansi-styles": "^4.1.0", "supports-color": "^7.1.0" @@ -15976,25 +15584,21 @@ "color-convert": { "version": "2.0.1", "dev": true, - "peer": true, "requires": { "color-name": "~1.1.4" } }, "color-name": { "version": "1.1.4", - "dev": true, - "peer": true + "dev": true }, "has-flag": { "version": "4.0.0", - "dev": true, - "peer": true + "dev": true }, "supports-color": { "version": "7.2.0", "dev": true, - "peer": true, "requires": { "has-flag": "^4.0.0" } @@ -16004,7 +15608,6 @@ "jest-leak-detector": { "version": "27.3.1", "dev": true, - "peer": true, "requires": { "jest-get-type": "^27.3.1", "pretty-format": "^27.3.1" @@ -16013,7 +15616,6 @@ "jest-matcher-utils": { "version": "27.3.1", "dev": true, - "peer": true, "requires": { "chalk": "^4.0.0", "jest-diff": "^27.3.1", @@ -16024,7 +15626,6 @@ "ansi-styles": { "version": "4.3.0", "dev": true, - "peer": true, "requires": { "color-convert": "^2.0.1" } @@ -16032,7 +15633,6 @@ "chalk": { "version": "4.1.2", "dev": true, - "peer": true, "requires": { "ansi-styles": "^4.1.0", "supports-color": "^7.1.0" @@ -16041,25 +15641,21 @@ "color-convert": { "version": "2.0.1", "dev": true, - "peer": true, "requires": { "color-name": "~1.1.4" } }, "color-name": { "version": "1.1.4", - "dev": true, - "peer": true + "dev": true }, "has-flag": { "version": "4.0.0", - "dev": true, - "peer": true + "dev": true }, "supports-color": { "version": "7.2.0", "dev": true, - "peer": true, "requires": { "has-flag": "^4.0.0" } @@ -16069,7 +15665,6 @@ "jest-message-util": { "version": "27.3.1", "dev": true, - "peer": true, "requires": { "@babel/code-frame": "^7.12.13", "@jest/types": "^27.2.5", @@ -16085,7 +15680,6 @@ "ansi-styles": { "version": "4.3.0", "dev": true, - "peer": true, "requires": { "color-convert": "^2.0.1" } @@ -16093,7 +15687,6 @@ "chalk": { "version": "4.1.2", "dev": true, - "peer": true, "requires": { "ansi-styles": "^4.1.0", "supports-color": "^7.1.0" @@ -16102,25 +15695,21 @@ "color-convert": { "version": "2.0.1", "dev": true, - "peer": true, "requires": { "color-name": "~1.1.4" } }, "color-name": { "version": "1.1.4", - "dev": true, - "peer": true + "dev": true }, "has-flag": { "version": "4.0.0", - "dev": true, - "peer": true + "dev": true }, "supports-color": { "version": "7.2.0", "dev": true, - "peer": true, "requires": { "has-flag": "^4.0.0" } @@ -16130,7 +15719,6 @@ "jest-mock": { "version": "27.3.0", "dev": true, - "peer": true, "requires": { "@jest/types": "^27.2.5", "@types/node": "*" @@ -16139,7 +15727,6 @@ "jest-pnp-resolver": { "version": "1.2.2", "dev": true, - "peer": true, "requires": {} }, "jest-regex-util": { @@ -16149,7 +15736,6 @@ "jest-resolve": { "version": "27.3.1", "dev": true, - "peer": true, "requires": { "@jest/types": "^27.2.5", "chalk": "^4.0.0", @@ -16166,7 +15752,6 @@ "ansi-styles": { "version": "4.3.0", "dev": true, - "peer": true, "requires": { "color-convert": "^2.0.1" } @@ -16174,7 +15759,6 @@ "chalk": { "version": "4.1.2", "dev": true, - "peer": true, "requires": { "ansi-styles": "^4.1.0", "supports-color": "^7.1.0" @@ -16183,25 +15767,21 @@ "color-convert": { "version": "2.0.1", "dev": true, - "peer": true, "requires": { "color-name": "~1.1.4" } }, "color-name": { "version": "1.1.4", - "dev": true, - "peer": true + "dev": true }, "has-flag": { "version": "4.0.0", - "dev": true, - "peer": true + "dev": true }, "supports-color": { "version": "7.2.0", "dev": true, - "peer": true, "requires": { "has-flag": "^4.0.0" } @@ -16211,7 +15791,6 @@ "jest-resolve-dependencies": { "version": "27.3.1", "dev": true, - "peer": true, "requires": { "@jest/types": "^27.2.5", "jest-regex-util": "^27.0.6", @@ -16221,7 +15800,6 @@ "jest-runner": { "version": "27.3.1", "dev": true, - "peer": true, "requires": { "@jest/console": "^27.3.1", "@jest/environment": "^27.3.1", @@ -16250,7 +15828,6 @@ "ansi-styles": { "version": "4.3.0", "dev": true, - "peer": true, "requires": { "color-convert": "^2.0.1" } @@ -16258,7 +15835,6 @@ "chalk": { "version": "4.1.2", "dev": true, - "peer": true, "requires": { "ansi-styles": "^4.1.0", "supports-color": "^7.1.0" @@ -16267,25 +15843,21 @@ "color-convert": { "version": "2.0.1", "dev": true, - "peer": true, "requires": { "color-name": "~1.1.4" } }, "color-name": { "version": "1.1.4", - "dev": true, - "peer": true + "dev": true }, "has-flag": { "version": "4.0.0", - "dev": true, - "peer": true + "dev": true }, "supports-color": { "version": "7.2.0", "dev": true, - "peer": true, "requires": { "has-flag": "^4.0.0" } @@ -16295,7 +15867,6 @@ "jest-runtime": { "version": "27.3.1", "dev": true, - "peer": true, "requires": { "@jest/console": "^27.3.1", "@jest/environment": "^27.3.1", @@ -16328,7 +15899,6 @@ "ansi-styles": { "version": "4.3.0", "dev": true, - "peer": true, "requires": { "color-convert": "^2.0.1" } @@ -16336,7 +15906,6 @@ "chalk": { "version": "4.1.2", "dev": true, - "peer": true, "requires": { "ansi-styles": "^4.1.0", "supports-color": "^7.1.0" @@ -16345,25 +15914,21 @@ "color-convert": { "version": "2.0.1", "dev": true, - "peer": true, "requires": { "color-name": "~1.1.4" } }, "color-name": { "version": "1.1.4", - "dev": true, - "peer": true + "dev": true }, "has-flag": { "version": "4.0.0", - "dev": true, - "peer": true + "dev": true }, "supports-color": { "version": "7.2.0", "dev": true, - "peer": true, "requires": { "has-flag": "^4.0.0" } @@ -16381,7 +15946,6 @@ "jest-snapshot": { "version": "27.3.1", "dev": true, - "peer": true, "requires": { "@babel/core": "^7.7.2", "@babel/generator": "^7.7.2", @@ -16412,7 +15976,6 @@ "ansi-styles": { "version": "4.3.0", "dev": true, - "peer": true, "requires": { "color-convert": "^2.0.1" } @@ -16420,7 +15983,6 @@ "chalk": { "version": "4.1.2", "dev": true, - "peer": true, "requires": { "ansi-styles": "^4.1.0", "supports-color": "^7.1.0" @@ -16429,25 +15991,21 @@ "color-convert": { "version": "2.0.1", "dev": true, - "peer": true, "requires": { "color-name": "~1.1.4" } }, "color-name": { "version": "1.1.4", - "dev": true, - "peer": true + "dev": true }, "has-flag": { "version": "4.0.0", - "dev": true, - "peer": true + "dev": true }, "semver": { "version": "7.3.5", "dev": true, - "peer": true, "requires": { "lru-cache": "^6.0.0" } @@ -16455,7 +16013,6 @@ "supports-color": { "version": "7.2.0", "dev": true, - "peer": true, "requires": { "has-flag": "^4.0.0" } @@ -16516,7 +16073,6 @@ "jest-validate": { "version": "27.3.1", "dev": true, - "peer": true, "requires": { "@jest/types": "^27.2.5", "camelcase": "^6.2.0", @@ -16529,20 +16085,17 @@ "ansi-styles": { "version": "4.3.0", "dev": true, - "peer": true, "requires": { "color-convert": "^2.0.1" } }, "camelcase": { "version": "6.2.1", - "dev": true, - "peer": true + "dev": true }, "chalk": { "version": "4.1.2", "dev": true, - "peer": true, "requires": { "ansi-styles": "^4.1.0", "supports-color": "^7.1.0" @@ -16551,25 +16104,21 @@ "color-convert": { "version": "2.0.1", "dev": true, - "peer": true, "requires": { "color-name": "~1.1.4" } }, "color-name": { "version": "1.1.4", - "dev": true, - "peer": true + "dev": true }, "has-flag": { "version": "4.0.0", - "dev": true, - "peer": true + "dev": true }, "supports-color": { "version": "7.2.0", "dev": true, - "peer": true, "requires": { "has-flag": "^4.0.0" } @@ -16579,7 +16128,6 @@ "jest-watcher": { "version": "27.3.1", "dev": true, - "peer": true, "requires": { "@jest/test-result": "^27.3.1", "@jest/types": "^27.2.5", @@ -16593,7 +16141,6 @@ "ansi-styles": { "version": "4.3.0", "dev": true, - "peer": true, "requires": { "color-convert": "^2.0.1" } @@ -16601,7 +16148,6 @@ "chalk": { "version": "4.1.2", "dev": true, - "peer": true, "requires": { "ansi-styles": "^4.1.0", "supports-color": "^7.1.0" @@ -16610,25 +16156,21 @@ "color-convert": { "version": "2.0.1", "dev": true, - "peer": true, "requires": { "color-name": "~1.1.4" } }, "color-name": { "version": "1.1.4", - "dev": true, - "peer": true + "dev": true }, "has-flag": { "version": "4.0.0", - "dev": true, - "peer": true + "dev": true }, "supports-color": { "version": "7.2.0", "dev": true, - "peer": true, "requires": { "has-flag": "^4.0.0" } @@ -16672,7 +16214,6 @@ "jsdom": { "version": "16.7.0", "dev": true, - "peer": true, "requires": { "abab": "^2.0.5", "acorn": "^8.2.4", @@ -16716,18 +16257,15 @@ }, "kleur": { "version": "3.0.3", - "dev": true, - "peer": true + "dev": true }, "leven": { "version": "3.1.0", - "dev": true, - "peer": true + "dev": true }, "levn": { "version": "0.3.0", "dev": true, - "peer": true, "requires": { "prelude-ls": "~1.1.2", "type-check": "~0.3.2" @@ -16742,8 +16280,7 @@ }, "lodash": { "version": "4.17.21", - "dev": true, - "peer": true + "dev": true }, "lodash.debounce": { "version": "4.0.8", @@ -16763,7 +16300,6 @@ "make-dir": { "version": "3.1.0", "dev": true, - "peer": true, "requires": { "semver": "^6.0.0" } @@ -16793,21 +16329,18 @@ }, "mime-db": { "version": "1.51.0", - "dev": true, - "peer": true + "dev": true }, "mime-types": { "version": "2.1.34", "dev": true, - "peer": true, "requires": { "mime-db": "1.51.0" } }, "mimic-fn": { "version": "2.1.0", - "dev": true, - "peer": true + "dev": true }, "minimatch": { "version": "3.0.4", @@ -16826,8 +16359,7 @@ }, "natural-compare": { "version": "1.4.0", - "dev": true, - "peer": true + "dev": true }, "node-int64": { "version": "0.4.0", @@ -16848,15 +16380,13 @@ "npm-run-path": { "version": "4.0.1", "dev": true, - "peer": true, "requires": { "path-key": "^3.0.0" } }, "nwsapi": { "version": "2.2.0", - "dev": true, - "peer": true + "dev": true }, "object-keys": { "version": "1.1.1", @@ -16882,7 +16412,6 @@ "onetime": { "version": "5.1.2", "dev": true, - "peer": true, "requires": { "mimic-fn": "^2.1.0" } @@ -16890,7 +16419,6 @@ "optionator": { "version": "0.8.3", "dev": true, - "peer": true, "requires": { "deep-is": "~0.1.3", "fast-levenshtein": "~2.0.6", @@ -16920,8 +16448,7 @@ }, "parse5": { "version": "6.0.1", - "dev": true, - "peer": true + "dev": true }, "path-exists": { "version": "4.0.0", @@ -16933,8 +16460,7 @@ }, "path-key": { "version": "3.1.1", - "dev": true, - "peer": true + "dev": true }, "path-parse": { "version": "1.0.7", @@ -16958,15 +16484,13 @@ "pkg-dir": { "version": "4.2.0", "dev": true, - "peer": true, "requires": { "find-up": "^4.0.0" } }, "prelude-ls": { "version": "1.1.2", - "dev": true, - "peer": true + "dev": true }, "pretty-format": { "version": "27.3.1", @@ -16987,7 +16511,6 @@ "prompts": { "version": "2.4.2", "dev": true, - "peer": true, "requires": { "kleur": "^3.0.3", "sisteransi": "^1.0.5" @@ -16995,13 +16518,11 @@ }, "psl": { "version": "1.8.0", - "dev": true, - "peer": true + "dev": true }, "punycode": { "version": "2.1.1", - "dev": true, - "peer": true + "dev": true }, "react-is": { "version": "17.0.2", @@ -17060,8 +16581,7 @@ }, "require-directory": { "version": "2.1.1", - "dev": true, - "peer": true + "dev": true }, "resolve": { "version": "1.20.0", @@ -17074,7 +16594,6 @@ "resolve-cwd": { "version": "3.0.0", "dev": true, - "peer": true, "requires": { "resolve-from": "^5.0.0" } @@ -17085,13 +16604,11 @@ }, "resolve.exports": { "version": "1.1.0", - "dev": true, - "peer": true + "dev": true }, "rimraf": { "version": "3.0.2", "dev": true, - "peer": true, "requires": { "glob": "^7.1.3" } @@ -17102,13 +16619,11 @@ }, "safer-buffer": { "version": "2.1.2", - "dev": true, - "peer": true + "dev": true }, "saxes": { "version": "5.0.1", "dev": true, - "peer": true, "requires": { "xmlchars": "^2.2.0" } @@ -17120,15 +16635,13 @@ "shebang-command": { "version": "2.0.0", "dev": true, - "peer": true, "requires": { "shebang-regex": "^3.0.0" } }, "shebang-regex": { "version": "3.0.0", - "dev": true, - "peer": true + "dev": true }, "signal-exit": { "version": "3.0.6", @@ -17136,8 +16649,7 @@ }, "sisteransi": { "version": "1.0.5", - "dev": true, - "peer": true + "dev": true }, "slash": { "version": "3.0.0", @@ -17150,7 +16662,6 @@ "source-map-support": { "version": "0.5.21", "dev": true, - "peer": true, "requires": { "buffer-from": "^1.0.0", "source-map": "^0.6.0" @@ -17158,8 +16669,7 @@ "dependencies": { "source-map": { "version": "0.6.1", - "dev": true, - "peer": true + "dev": true } } }, @@ -17170,22 +16680,19 @@ "stack-utils": { "version": "2.0.5", "dev": true, - "peer": true, "requires": { "escape-string-regexp": "^2.0.0" }, "dependencies": { "escape-string-regexp": { "version": "2.0.0", - "dev": true, - "peer": true + "dev": true } } }, "string-length": { "version": "4.0.2", "dev": true, - "peer": true, "requires": { "char-regex": "^1.0.2", "strip-ansi": "^6.0.0" @@ -17194,7 +16701,6 @@ "string-width": { "version": "4.2.3", "dev": true, - "peer": true, "requires": { "emoji-regex": "^8.0.0", "is-fullwidth-code-point": "^3.0.0", @@ -17204,20 +16710,17 @@ "strip-ansi": { "version": "6.0.1", "dev": true, - "peer": true, "requires": { "ansi-regex": "^5.0.1" } }, "strip-bom": { "version": "4.0.0", - "dev": true, - "peer": true + "dev": true }, "strip-final-newline": { "version": "2.0.0", - "dev": true, - "peer": true + "dev": true }, "supports-color": { "version": "5.5.0", @@ -17229,7 +16732,6 @@ "supports-hyperlinks": { "version": "2.2.0", "dev": true, - "peer": true, "requires": { "has-flag": "^4.0.0", "supports-color": "^7.0.0" @@ -17237,13 +16739,11 @@ "dependencies": { "has-flag": { "version": "4.0.0", - "dev": true, - "peer": true + "dev": true }, "supports-color": { "version": "7.2.0", "dev": true, - "peer": true, "requires": { "has-flag": "^4.0.0" } @@ -17252,13 +16752,11 @@ }, "symbol-tree": { "version": "3.2.4", - "dev": true, - "peer": true + "dev": true }, "terminal-link": { "version": "2.1.1", "dev": true, - "peer": true, "requires": { "ansi-escapes": "^4.2.1", "supports-hyperlinks": "^2.0.0" @@ -17275,8 +16773,7 @@ }, "throat": { "version": "6.0.1", - "dev": true, - "peer": true + "dev": true }, "tmpl": { "version": "1.0.5", @@ -17296,7 +16793,6 @@ "tough-cookie": { "version": "4.0.0", "dev": true, - "peer": true, "requires": { "psl": "^1.1.33", "punycode": "^2.1.1", @@ -17306,7 +16802,6 @@ "tr46": { "version": "2.1.0", "dev": true, - "peer": true, "requires": { "punycode": "^2.1.1" } @@ -17361,20 +16856,17 @@ "type-check": { "version": "0.3.2", "dev": true, - "peer": true, "requires": { "prelude-ls": "~1.1.2" } }, "type-detect": { "version": "4.0.8", - "dev": true, - "peer": true + "dev": true }, "type-fest": { "version": "0.21.3", - "dev": true, - "peer": true + "dev": true }, "typedarray-to-buffer": { "version": "3.1.5", @@ -17409,13 +16901,11 @@ }, "universalify": { "version": "0.1.2", - "dev": true, - "peer": true + "dev": true }, "v8-to-istanbul": { "version": "8.1.0", "dev": true, - "peer": true, "requires": { "@types/istanbul-lib-coverage": "^2.0.1", "convert-source-map": "^1.6.0", @@ -17424,15 +16914,13 @@ "dependencies": { "source-map": { "version": "0.7.3", - "dev": true, - "peer": true + "dev": true } } }, "w3c-hr-time": { "version": "1.0.2", "dev": true, - "peer": true, "requires": { "browser-process-hrtime": "^1.0.0" } @@ -17440,7 +16928,6 @@ "w3c-xmlserializer": { "version": "2.0.0", "dev": true, - "peer": true, "requires": { "xml-name-validator": "^3.0.0" } @@ -17454,26 +16941,22 @@ }, "webidl-conversions": { "version": "6.1.0", - "dev": true, - "peer": true + "dev": true }, "whatwg-encoding": { "version": "1.0.5", "dev": true, - "peer": true, "requires": { "iconv-lite": "0.4.24" } }, "whatwg-mimetype": { "version": "2.3.0", - "dev": true, - "peer": true + "dev": true }, "whatwg-url": { "version": "8.7.0", "dev": true, - "peer": true, "requires": { "lodash": "^4.7.0", "tr46": "^2.1.0", @@ -17483,20 +16966,17 @@ "which": { "version": "2.0.2", "dev": true, - "peer": true, "requires": { "isexe": "^2.0.0" } }, "word-wrap": { "version": "1.2.3", - "dev": true, - "peer": true + "dev": true }, "wrap-ansi": { "version": "7.0.0", "dev": true, - "peer": true, "requires": { "ansi-styles": "^4.0.0", "string-width": "^4.1.0", @@ -17506,7 +16986,6 @@ "ansi-styles": { "version": "4.3.0", "dev": true, - "peer": true, "requires": { "color-convert": "^2.0.1" } @@ -17514,15 +16993,13 @@ "color-convert": { "version": "2.0.1", "dev": true, - "peer": true, "requires": { "color-name": "~1.1.4" } }, "color-name": { "version": "1.1.4", - "dev": true, - "peer": true + "dev": true } } }, @@ -17543,23 +17020,19 @@ "ws": { "version": "7.5.5", "dev": true, - "peer": true, "requires": {} }, "xml-name-validator": { "version": "3.0.0", - "dev": true, - "peer": true + "dev": true }, "xmlchars": { "version": "2.2.0", - "dev": true, - "peer": true + "dev": true }, "y18n": { "version": "5.0.8", - "dev": true, - "peer": true + "dev": true }, "yallist": { "version": "4.0.0", @@ -17568,7 +17041,6 @@ "yargs": { "version": "16.2.0", "dev": true, - "peer": true, "requires": { "cliui": "^7.0.2", "escalade": "^3.1.1", @@ -17592,20 +17064,26 @@ "snarkyjs": { "version": "file:../snarkyjs", "requires": { + "@types/isomorphic-fetch": "^0.0.36", "@types/jest": "^27.0.0", + "@types/node": "^18.7.13", "@typescript-eslint/eslint-plugin": "^5.0.0", "env": "^0.0.2", "esbuild": "^0.13.13", "eslint": "^8.0.0", + "expect": "^29.0.1", "fs-extra": "^10.0.0", - "jest": "^27.0.6", + "howslow": "^0.1.0", + "isomorphic-fetch": "^3.0.0", + "jest": "^28.1.3", "minimist": "^1.2.5", "prettier": "^2.3.2", "reflect-metadata": "^0.1.13", - "ts-jest": "^27.0.4", + "rimraf": "^3.0.2", + "ts-jest": "^28.0.8", "tslib": "^2.3.0", - "typedoc": "^0.22.9", - "typescript": "^4.4.4" + "typedoc": "^0.23.11", + "typescript": "^4.8.2" }, "dependencies": { "@babel/code-frame": { diff --git a/src/lib/snarky_js_bindings/test_module/to-hash-input.js b/src/lib/snarky_js_bindings/test_module/to-hash-input.js index c18f490f927..a1f023d7ccf 100644 --- a/src/lib/snarky_js_bindings/test_module/to-hash-input.js +++ b/src/lib/snarky_js_bindings/test_module/to-hash-input.js @@ -19,11 +19,11 @@ await isReady; let { asFieldsAndAux, jsLayout, packToFields } = Experimental; -let account_update = Account_update.defaultAccountUpdate(PrivateKey.random().toPublicKey()); +let account_update = AccountUpdate.defaultAccountUpdate(PrivateKey.random().toPublicKey()); // timing let Timing = asFieldsAndAux( - jsLayout.Account_update.entries.body.entries.update.entries.timing.inner + jsLayout.AccountUpdate.entries.body.entries.update.entries.timing.inner ); let timing = account_update.body.update.timing.value; timing.initialMinimumBalance = UInt64.one; @@ -33,7 +33,7 @@ testInput(Timing, Ledger.hashInputFromJson.timing, timing); // permissions let Permissions_ = asFieldsAndAux( - jsLayout.Account_update.entries.body.entries.update.entries.permissions.inner + jsLayout.AccountUpdate.entries.body.entries.update.entries.permissions.inner ); let permissions = account_update.body.update.permissions; permissions.isSome = Bool(true); @@ -50,7 +50,7 @@ testInput( ); // update -let Update = asFieldsAndAux(jsLayout.Account_update.entries.body.entries.update); +let Update = asFieldsAndAux(jsLayout.AccountUpdate.entries.body.entries.update); let update = account_update.body.update; update.timing.isSome = Bool(true); @@ -65,7 +65,7 @@ testInput(Update, Ledger.hashInputFromJson.update, update); // account precondition let AccountPrecondition = asFieldsAndAux( - jsLayout.Account_update.entries.body.entries.preconditions.entries.account + jsLayout.AccountUpdate.entries.body.entries.preconditions.entries.account ); let account = account_update.body.preconditions.account; account_update.account.balance.assertEquals(UInt64.from(1e9)); @@ -81,7 +81,7 @@ testInput( // network precondition let NetworkPrecondition = asFieldsAndAux( - jsLayout.Account_update.entries.body.entries.preconditions.entries.network + jsLayout.AccountUpdate.entries.body.entries.preconditions.entries.network ); let network = account_update.body.preconditions.network; account_update.network.stakingEpochData.ledger.hash.assertEquals(Field.random()); @@ -94,7 +94,7 @@ testInput( ); // body -let Body = asFieldsAndAux(jsLayout.Account_update.entries.body); +let Body = asFieldsAndAux(jsLayout.AccountUpdate.entries.body); let body = account_update.body; body.balanceChange.magnitude = UInt64.from(14197832); body.balanceChange.sgn = Sign.minusOne; From e262931311c44c77a6e312dbaaddebfda3bc9b92 Mon Sep 17 00:00:00 2001 From: Paul Steckler Date: Wed, 7 Sep 2022 19:53:59 -0700 Subject: [PATCH 068/144] fix some unit tests --- src/lib/mina_wire_types/test/type_equalities.ml | 4 ++-- src/lib/signature_lib/test/signature_lib_tests.ml | 4 ++-- .../transaction_snark/test/zkapp_tokens/zkapp_tokens.ml | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/lib/mina_wire_types/test/type_equalities.ml b/src/lib/mina_wire_types/test/type_equalities.ml index 7c6c44d89f0..8e77c938217 100644 --- a/src/lib/mina_wire_types/test/type_equalities.ml +++ b/src/lib/mina_wire_types/test/type_equalities.ml @@ -182,7 +182,7 @@ module Mina_base = struct include Assert_equal0V1 (O.Zkapp_command.Call_forest.Digest.Account_update.Stable) - (W.Zkapp_command.Call_forest.Digest.AccountUpdate) + (W.Zkapp_command.Call_forest.Digest.Account_update) include Assert_equal0V1 @@ -225,7 +225,7 @@ module Mina_base = struct (O.Zkapp_command.Call_forest.Stable) (W.Zkapp_command.Call_forest) include Assert_equal0V2 (O.Control.Stable) (W.Control) - include Assert_equal0V1 (O.Account_update.Stable) (W.AccountUpdate) + include Assert_equal0V1 (O.Account_update.Stable) (W.Account_update) include Assert_equal0V1 (O.Zkapp_command.Stable) (W.Zkapp_command) include Assert_equal0V1 (O.Zkapp_command.Valid.Stable) (W.Zkapp_command.Valid) include Assert_equal0V2 (O.User_command.Stable) (W.User_command) diff --git a/src/lib/signature_lib/test/signature_lib_tests.ml b/src/lib/signature_lib/test/signature_lib_tests.ml index 4f366aac6f0..16755f79b89 100644 --- a/src/lib/signature_lib/test/signature_lib_tests.ml +++ b/src/lib/signature_lib/test/signature_lib_tests.ml @@ -10,7 +10,7 @@ let%test_module "Signatures are unchanged test" = ( Snark_params.Tick.Field.of_string "22392589120931543014785073787084416773963960016576902579504636013984435243005" , Snark_params.Tock.Field.of_string - "21219227048859428590456415944357352158328885122224477074004768710152393114331" + "2880510450900546004447140148781343803870635677363906138559879238029531347198" ) let%test "signature of empty random oracle input matches" = @@ -32,7 +32,7 @@ let%test_module "Signatures are unchanged test" = ( Snark_params.Tick.Field.of_string "7379148532947400206038414977119655575287747480082205647969258483647762101030" , Snark_params.Tock.Field.of_string - "26901815964642131149392134713980873704065643302140817442239336405283236628658" + "23840926589844948581421814643113807136693203601746510040822205158347665110354" ) in Snark_params.Tick.Field.equal (fst signature_expected) (fst signature_got) diff --git a/src/lib/transaction_snark/test/zkapp_tokens/zkapp_tokens.ml b/src/lib/transaction_snark/test/zkapp_tokens/zkapp_tokens.ml index 908e35a7d6f..3eb6f67db73 100644 --- a/src/lib/transaction_snark/test/zkapp_tokens/zkapp_tokens.ml +++ b/src/lib/transaction_snark/test/zkapp_tokens/zkapp_tokens.ml @@ -102,7 +102,7 @@ let%test_module "Zkapp tokens tests" = (10 * account_creation_fee) ) [] ] - |> mk_zkapp_command_transaction ~fee:7 ~fee_payer_pk:pk + |> mk_zkapp_command ~fee:7 ~fee_payer_pk:pk ~fee_payer_nonce:nonce in replace_authorizations ~keymap with_dummy_signatures @@ -130,7 +130,7 @@ let%test_module "Zkapp tokens tests" = [] ] ] - |> mk_zkapp_command_transaction ~fee:7 ~fee_payer_pk:pk + |> mk_zkapp_command ~fee:7 ~fee_payer_pk:pk ~fee_payer_nonce:nonce in replace_authorizations ~keymap with_dummy_signatures @@ -159,7 +159,7 @@ let%test_module "Zkapp tokens tests" = ] ] ] - |> mk_zkapp_command_transaction ~fee:7 ~fee_payer_pk:pk + |> mk_zkapp_command ~fee:7 ~fee_payer_pk:pk ~fee_payer_nonce:nonce in replace_authorizations ~keymap with_dummy_signatures @@ -224,7 +224,7 @@ let%test_module "Zkapp tokens tests" = ] ] ] - |> mk_zkapp_command_transaction ~fee:7 ~fee_payer_pk:pk + |> mk_zkapp_command ~fee:7 ~fee_payer_pk:pk ~fee_payer_nonce:nonce in replace_authorizations ~keymap with_dummy_signatures From 96c98061d2319087c64b539aeab46e8de3c448b2 Mon Sep 17 00:00:00 2001 From: Serhii Shymkiv Date: Thu, 8 Sep 2022 11:20:54 +0300 Subject: [PATCH 069/144] Fix for go.mod hash mismatch --- nix/libp2p_helper.json | 2 +- src/app/libp2p_helper/README.md | 22 ++++++++++++---------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/nix/libp2p_helper.json b/nix/libp2p_helper.json index 4d0a512a5fc..a9c677f411a 100644 --- a/nix/libp2p_helper.json +++ b/nix/libp2p_helper.json @@ -1 +1 @@ -{"go.mod":"ebe735fd7b9f93a563c56dc31290b8b9200fb15e6fff98f7be248ffccee88c6c","go.sum":"930cea1dc3c81e8bc009bab4cc51703294bc6a4195bac387a11dda93bfa16a35","vendorSha256":"sha256-obKl4KUyisLrCFGfHZ7AX8e2uQicmnY2b1EflZq/I8E="} \ No newline at end of file +{"go.mod":"b6ae9a87b95e27779acf57dcd77fdcf1e7a0f093f1d86d716e6334ab77bfbf9c","go.sum":"91314d339b53b15a6896cbbfd914abf28248c3e5094185ee0a0acda877007fbc","vendorSha256":"sha256-hY3Ym19Bj5qFbjXukrt/2l39yUB1/9KehM2dMoBSXVQ="} \ No newline at end of file diff --git a/src/app/libp2p_helper/README.md b/src/app/libp2p_helper/README.md index e0536aff116..60b9b68fdfa 100644 --- a/src/app/libp2p_helper/README.md +++ b/src/app/libp2p_helper/README.md @@ -1,8 +1,10 @@ -# mina go-libp2p helper +# Mina `go-libp2p` Helper -## libp2p_helper hints +## Contrubution -## building +After changing the `go.mod` or `go.sum` please run the `nix build mina#libp2p_helper` and follow the instructions in order to resolve possible hash mismatch. + +## Building ### Makefile @@ -18,7 +20,7 @@ $ bazel build src:codanet $ bazel build src/libp2p_helper ``` -#### using as an external repo +#### Using as an external repo Add a repository rule to your root WORKSPACE(.bazel) file to import this repo. For example, if you embed this repo as a git submodule: @@ -34,7 +36,7 @@ file. Change the line: `load("//bzl/libp2p:deps.bzl", "libp2p_bootstrap")` to use the fully-qualified label, e.g. `load("@libp2p_helper//bzl/libp2p:deps.bzl", "libp2p_bootstrap")`. -#### maintenance +#### Maintenance Install [Gazelle](https://github.com/bazelbuild/bazel-gazelle). @@ -51,12 +53,12 @@ See [Go Protocol buffers - avoiding conflicts](https://github.com/bazelbuild/rules_go/blob/master/proto/core.rst#avoiding-conflicts): [Option 2: Use pre-generated .pb.go files](https://github.com/bazelbuild/rules_go/blob/master/proto/core.rst#option-2-use-pre-generated-pb-go-files). for more info. -# How it works +## How it works libp2p_helper serves as a middleware between libp2p and Ocaml process. They communicate using a number of internal messages. Below we enumerate all message types along with description of how Helper handles the message. -## config_msg.go +### config_msg.go Messages serving to configure libp2p helper. @@ -79,7 +81,7 @@ Messages serving to configure libp2p helper. * Sets a node status * Node status is a bytestring without particular structure (as of the libp2p_helper's view) -## peer_msg.go +### peer_msg.go Messages to add a new peer or get information about existing peers. @@ -96,7 +98,7 @@ Messages to add a new peer or get information about existing peers. * listPeers * Return a list of peer information for each open connection -## pubsub_msg.go +### pubsub_msg.go Messages to interact with pubsub protocol. @@ -119,7 +121,7 @@ Messages to interact with pubsub protocol. * Performs the action under app-global `ValidatorMutex` * Logs an error if validation has already timed out -## stream_msg.go +### stream_msg.go Messages to open, maintain and send messages to streams towards other peers (connected directly to our node). From 73d0dee204bf6df27b8fea4e11e7831c635706d5 Mon Sep 17 00:00:00 2001 From: Gregor Date: Thu, 8 Sep 2022 10:37:53 +0200 Subject: [PATCH 070/144] [snarkyjs] fix reading public keys which are vars --- .../snarky_js_bindings/lib/snarky_js_bindings_lib.ml | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/lib/snarky_js_bindings/lib/snarky_js_bindings_lib.ml b/src/lib/snarky_js_bindings/lib/snarky_js_bindings_lib.ml index cdc40c554be..90037cfe552 100644 --- a/src/lib/snarky_js_bindings/lib/snarky_js_bindings_lib.ml +++ b/src/lib/snarky_js_bindings/lib/snarky_js_bindings_lib.ml @@ -151,13 +151,6 @@ let field_constr = As_field.field_constr open Core_kernel -let bool_constant (b : Impl.Boolean.var) = - match (b :> Impl.Field.t) with - | Constant b -> - Some Impl.Field.Constant.(equal one b) - | _ -> - None - module As_bool = struct (* boolean | bool_class | Boolean.var *) type t @@ -271,6 +264,9 @@ let to_unchecked (x : Field.t) = let of_js_field_unchecked (x : field_class Js.t) = to_unchecked @@ of_js_field x +let bool_to_unchecked (x : Boolean.var) = + (x :> Field.t) |> to_unchecked |> Field.Constant.(equal one) + let () = let method_ name (f : field_class Js.t -> _) = method_ field_class name f in let to_string (x : Field.t) = @@ -2457,7 +2453,7 @@ module Ledger = struct let public_key (pk : public_key) : Signature_lib.Public_key.Compressed.t = { x = to_unchecked pk##.x##.value - ; is_odd = pk##.isOdd##.value |> bool_constant |> Option.value_exn + ; is_odd = bool_to_unchecked pk##.isOdd##.value } let private_key (key : private_key) : Signature_lib.Private_key.t = From 9c611468d41ddca0edfa9d1312029c61a9d794ef Mon Sep 17 00:00:00 2001 From: Gregor Date: Thu, 8 Sep 2022 10:45:12 +0200 Subject: [PATCH 071/144] bump snarkyjs --- src/lib/snarky_js_bindings/snarkyjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/snarky_js_bindings/snarkyjs b/src/lib/snarky_js_bindings/snarkyjs index b3990ce4e27..0f1e53ea912 160000 --- a/src/lib/snarky_js_bindings/snarkyjs +++ b/src/lib/snarky_js_bindings/snarkyjs @@ -1 +1 @@ -Subproject commit b3990ce4e273a7486689319098f7c97a2a0dc183 +Subproject commit 0f1e53ea91217d981538b97766009ad9c1eeac07 From 113705ec5ecb5cdfd86f9056c524ebb7ddfc2578 Mon Sep 17 00:00:00 2001 From: Gregor Date: Thu, 8 Sep 2022 10:53:12 +0200 Subject: [PATCH 072/144] bump snarkyjs --- src/lib/snarky_js_bindings/snarkyjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/snarky_js_bindings/snarkyjs b/src/lib/snarky_js_bindings/snarkyjs index 0f1e53ea912..0eb11271319 160000 --- a/src/lib/snarky_js_bindings/snarkyjs +++ b/src/lib/snarky_js_bindings/snarkyjs @@ -1 +1 @@ -Subproject commit 0f1e53ea91217d981538b97766009ad9c1eeac07 +Subproject commit 0eb1127131900326febe3d7f2b7d1b8414317c65 From 678100319ffacb4e7236ffc6a096088590a3184c Mon Sep 17 00:00:00 2001 From: Alexander Bantyev Date: Thu, 8 Sep 2022 12:59:17 +0400 Subject: [PATCH 073/144] flake.lock: Update MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Flake lock file updates: • Updated input 'nix-npm-buildPackage': 'github:serokell/nix-npm-buildpackage/ca922a16839ae62a568bcb0771e78e080b4d6059' (2022-06-09) → 'github:serokell/nix-npm-buildpackage/cab951dd024dd367511d48440de6f93664ee35aa' (2022-09-08) --- flake.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/flake.lock b/flake.lock index 67cb8cda5a4..7ff41c3f27a 100644 --- a/flake.lock +++ b/flake.lock @@ -137,11 +137,11 @@ ] }, "locked": { - "lastModified": 1654786772, - "narHash": "sha256-Qul9GG6EJ1IFfgnZ440KAxTEPfFpbnmf54EVFM9+iZA=", + "lastModified": 1662627485, + "narHash": "sha256-Kg8u2ekU0+MsuLzgKqiaus3HquLLo2Qq+oGbQfIppos=", "owner": "serokell", "repo": "nix-npm-buildpackage", - "rev": "ca922a16839ae62a568bcb0771e78e080b4d6059", + "rev": "cab951dd024dd367511d48440de6f93664ee35aa", "type": "github" }, "original": { From 640451c60fe177ab580f1df1f439c0c1071c6369 Mon Sep 17 00:00:00 2001 From: Yves-Stan Le Cornec Date: Thu, 8 Sep 2022 11:05:50 +0200 Subject: [PATCH 074/144] Update src/app/batch_txn_tool after GraphQL schema change --- src/app/batch_txn_tool/batch_txn_tool.ml | 2 +- src/app/batch_txn_tool/dune | 6 ++---- src/app/batch_txn_tool/txn_tool_graphql.ml | 2 +- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/app/batch_txn_tool/batch_txn_tool.ml b/src/app/batch_txn_tool/batch_txn_tool.ml index 27fa8d48ae5..04be6b892c1 100644 --- a/src/app/batch_txn_tool/batch_txn_tool.ml +++ b/src/app/batch_txn_tool/batch_txn_tool.ml @@ -206,7 +206,7 @@ let there_and_back_again ~num_txn_per_acct ~txns_per_block ~slot_time ~fill_rate in match querry_result with | Ok n -> - return (UInt32.of_int n) + return n | Error _ -> Format.printf "txn burst tool: could not get nonce of pk= %s@." (pk_to_str pk) ; diff --git a/src/app/batch_txn_tool/dune b/src/app/batch_txn_tool/dune index fbcc9ab305e..dd5c13d1002 100644 --- a/src/app/batch_txn_tool/dune +++ b/src/app/batch_txn_tool/dune @@ -25,11 +25,9 @@ mina_wire_types ) (instrumentation (backend bisect_ppx)) + (preprocessor_deps ../../../graphql_schema.json) (preprocess (pps ppx_version ppx_let - graphql_ppx -- - -extend-query Graphql_lib.Serializing.ExtendQuery - -extend-mutation Graphql_lib.Serializing.ExtendQuery - -future-added-value false + graphql_ppx -- %{read-lines:../../graphql-ppx-config.inc} ))) diff --git a/src/app/batch_txn_tool/txn_tool_graphql.ml b/src/app/batch_txn_tool/txn_tool_graphql.ml index fcbdabf2386..ad850dfdeaf 100644 --- a/src/app/batch_txn_tool/txn_tool_graphql.ml +++ b/src/app/batch_txn_tool/txn_tool_graphql.ml @@ -102,7 +102,7 @@ let get_account_data ~public_key ~graphql_target_node = | Some acc -> ( match acc.nonce with | Some s -> - return (int_of_string s) + return s | None -> Deferred.Or_error.errorf "Account with %s somehow doesnt have a nonce" (Public_key.Compressed.to_string pk) ) From e33d9d74597d10466173cb5d9f65a8daffe4f377 Mon Sep 17 00:00:00 2001 From: georgeee Date: Thu, 8 Sep 2022 15:05:31 +0200 Subject: [PATCH 075/144] Fix CLI unit test --- buildkite/scripts/unit-test.sh | 4 +- src/app/cli/src/init/client.ml | 51 ++++++++-------- .../command_line_tests/command_line_tests.ml | 59 ++++++++++++++----- src/lib/command_line_tests/dune | 2 + 4 files changed, 76 insertions(+), 40 deletions(-) diff --git a/buildkite/scripts/unit-test.sh b/buildkite/scripts/unit-test.sh index dcbbe66ab6b..ec7de98b8d6 100755 --- a/buildkite/scripts/unit-test.sh +++ b/buildkite/scripts/unit-test.sh @@ -12,8 +12,10 @@ path=$2 source ~/.profile +export MINA_LIBP2P_PASS="naughty blue worm" + echo "--- Make build" -export LIBP2P_NIXLESS=1 PATH=/usr/lib/go/bin:$PATH GO=/usr/lib/go/bin/go +export LIBP2P_NIXLESS=1 PATH=/usr/lib/go/bin:$PATH GO=/usr/lib/go/bin/go time make build # Note: By attempting a re-run on failure here, we can avoid rebuilding and diff --git a/src/app/cli/src/init/client.ml b/src/app/cli/src/init/client.ml index 08425c2dba8..9ae74c66f8b 100644 --- a/src/app/cli/src/init/client.ml +++ b/src/app/cli/src/init/client.ml @@ -1575,35 +1575,38 @@ let lock_account = in printf "🔒 Locked account!\nPublic key: %s\n" pk_string ) ) +let generate_libp2p_keypair_do privkey_path = + Cli_lib.Exceptions.handle_nicely + @@ fun () -> + Deferred.ignore_m + (let open Deferred.Let_syntax in + (* FIXME: I'd like to accumulate messages into this logger and only dump them out in failure paths. *) + let logger = Logger.null () in + (* Using the helper only for keypair generation requires no state. *) + File_system.with_temp_dir "mina-generate-libp2p-keypair" ~f:(fun tmpd -> + match%bind + Mina_net2.create ~logger ~conf_dir:tmpd ~all_peers_seen_metric:false + ~pids:(Child_processes.Termination.create_pid_table ()) + ~on_peer_connected:ignore ~on_peer_disconnected:ignore + with + | Ok net -> + let%bind me = Mina_net2.generate_random_keypair net in + let%bind () = Mina_net2.shutdown net in + let%map () = + Secrets.Libp2p_keypair.Terminal_stdin.write_exn ~privkey_path me + in + printf "libp2p keypair:\n%s\n" (Mina_net2.Keypair.to_string me) + | Error e -> + [%log fatal] "failed to generate libp2p keypair: $error" + ~metadata:[ ("error", Error_json.error_to_yojson e) ] ; + exit 20 )) + let generate_libp2p_keypair = Command.async ~summary:"Generate a new libp2p keypair and print out the peer ID" (let open Command.Let_syntax in let%map_open privkey_path = Cli_lib.Flag.privkey_write_path in - Cli_lib.Exceptions.handle_nicely - @@ fun () -> - Deferred.ignore_m - (let open Deferred.Let_syntax in - (* FIXME: I'd like to accumulate messages into this logger and only dump them out in failure paths. *) - let logger = Logger.null () in - (* Using the helper only for keypair generation requires no state. *) - File_system.with_temp_dir "mina-generate-libp2p-keypair" ~f:(fun tmpd -> - match%bind - Mina_net2.create ~logger ~conf_dir:tmpd ~all_peers_seen_metric:false - ~pids:(Child_processes.Termination.create_pid_table ()) - ~on_peer_connected:ignore ~on_peer_disconnected:ignore - with - | Ok net -> - let%bind me = Mina_net2.generate_random_keypair net in - let%bind () = Mina_net2.shutdown net in - let%map () = - Secrets.Libp2p_keypair.Terminal_stdin.write_exn ~privkey_path me - in - printf "libp2p keypair:\n%s\n" (Mina_net2.Keypair.to_string me) - | Error e -> - [%log fatal] "failed to generate libp2p keypair: $error" - ~metadata:[ ("error", Error_json.error_to_yojson e) ] ; - exit 20 ))) + generate_libp2p_keypair_do privkey_path) let trustlist_ip_flag = Command.Param.( diff --git a/src/lib/command_line_tests/command_line_tests.ml b/src/lib/command_line_tests/command_line_tests.ml index 087539cb0af..19ede94ee5f 100644 --- a/src/lib/command_line_tests/command_line_tests.ml +++ b/src/lib/command_line_tests/command_line_tests.ml @@ -21,7 +21,8 @@ let%test_module "Command line tests" = *) let coda_exe = "../../app/cli/src/mina.exe" - let create_daemon_process config_dir genesis_ledger_dir port = + let create_daemon_process config_dir genesis_ledger_dir libp2p_keypair_path + port = let%bind working_dir = Sys.getcwd () in Core.printf "Starting daemon inside %s\n" working_dir ; Process.create ~prog:coda_exe @@ -40,10 +41,12 @@ let%test_module "Command line tests" = ; "0.0.0" ; "-external-ip" ; "0.0.0.0" + ; "-libp2p-keypair" + ; libp2p_keypair_path ] () - let start_daemon config_dir genesis_ledger_dir port = + let start_daemon config_dir genesis_ledger_dir libp2p_keypair_path port = let%bind working_dir = Sys.getcwd () in Core.printf "Starting daemon inside %s\n" working_dir ; let%map _ = @@ -65,6 +68,8 @@ let%test_module "Command line tests" = ; "0.0.0" ; "-external-ip" ; "0.0.0.0" + ; "-libp2p-keypair" + ; libp2p_keypair_path ] () with @@ -84,16 +89,25 @@ let%test_module "Command line tests" = ~args:[ "client"; "status"; "-daemon-port"; sprintf "%d" port ] () - let create_config_directories () = + let libp2p_keypath dir = String.concat [ dir; "/privkey" ] + + let create_config_files_and_dirs () = (* create empty config dir to avoid any issues with the default config dir *) let conf = Filename.temp_dir ~in_dir:"/tmp" "coda_spun_test" "" in let genesis = Filename.temp_dir ~in_dir:"/tmp" "coda_genesis_state" "" in - (conf, genesis) + let libp2p_keypair_dir = + Filename.temp_dir ~in_dir:"/tmp" "mina_test_libp2p_keypair" "" + in + let libp2p_keypair_path = libp2p_keypath libp2p_keypair_dir in + let%map () = + Init.Client.generate_libp2p_keypair_do libp2p_keypair_path () + in + (conf, genesis, libp2p_keypair_dir) - let remove_config_directory config_dir genesis_dir = - let%bind _ = Process.run_exn ~prog:"rm" ~args:[ "-rf"; config_dir ] () in - Process.run_exn ~prog:"rm" ~args:[ "-rf"; genesis_dir ] () - |> Deferred.ignore_m + let remove_config_dirs dirs = + Deferred.List.iter dirs ~f:(fun dir -> + Deferred.ignore_m + @@ Process.run_exn ~prog:"rm" ~args:[ "-rf"; dir ] () ) let test_background_daemon () = let test_failed = ref false in @@ -101,7 +115,9 @@ let%test_module "Command line tests" = let client_delay = 40. in let retry_delay = 30. in let retry_attempts = 30 in - let config_dir, genesis_ledger_dir = create_config_directories () in + let%bind config_dir, genesis_ledger_dir, libp2p_keypair_dir = + create_config_files_and_dirs () + in Monitor.protect ~finally:(fun () -> ( if !test_failed then @@ -112,11 +128,16 @@ let%test_module "Command line tests" = Core.Printf.printf !"**** DAEMON CRASHED (OUTPUT BELOW) ****\n%s\n************\n%!" contents ) ; - remove_config_directory config_dir genesis_ledger_dir ) + remove_config_dirs + [ config_dir; genesis_ledger_dir; libp2p_keypair_dir ] ) (fun () -> match%map let open Deferred.Or_error.Let_syntax in - let%bind _ = start_daemon config_dir genesis_ledger_dir port in + let%bind _ = + start_daemon config_dir genesis_ledger_dir + (libp2p_keypath libp2p_keypair_dir) + port + in (* It takes a while for the daemon to become available. *) let%bind () = Deferred.map @@ -154,7 +175,9 @@ let%test_module "Command line tests" = let client_delay = 40. in let retry_delay = 30. in let retry_attempts = 5 in - let config_dir, genesis_ledger_dir = create_config_directories () in + let%bind config_dir, genesis_ledger_dir, libp2p_keypair_dir = + create_config_files_and_dirs () + in Monitor.protect ~finally:(fun () -> ( if !test_failed then @@ -165,12 +188,15 @@ let%test_module "Command line tests" = Core.Printf.printf !"**** DAEMON CRASHED (OUTPUT BELOW) ****\n%s\n************\n%!" contents ) ; - remove_config_directory config_dir genesis_ledger_dir ) + remove_config_dirs + [ config_dir; genesis_ledger_dir; libp2p_keypair_dir ] ) (fun () -> match%map let open Deferred.Or_error.Let_syntax in + let libp2p_keypair_path = libp2p_keypath libp2p_keypair_dir in let%bind p = - create_daemon_process config_dir genesis_ledger_dir port + create_daemon_process config_dir genesis_ledger_dir + libp2p_keypair_path port in let%bind () = Deferred.map @@ -195,7 +221,10 @@ let%test_module "Command line tests" = let%bind (_ : Unix.Exit_or_signal.t) = Deferred.map (Process.wait p) ~f:Or_error.return in - let%bind _ = start_daemon config_dir genesis_ledger_dir port in + let%bind _ = + start_daemon config_dir genesis_ledger_dir libp2p_keypair_path + port + in let%bind () = Deferred.map (after @@ Time.Span.of_sec client_delay) diff --git a/src/lib/command_line_tests/dune b/src/lib/command_line_tests/dune index 9000e6d8465..9c7d9e2e5c3 100644 --- a/src/lib/command_line_tests/dune +++ b/src/lib/command_line_tests/dune @@ -11,6 +11,8 @@ core async_unix stdio + ;; mina libraries + init ) (instrumentation (backend bisect_ppx)) (preprocess (pps ppx_version ppx_jane ppx_compare)) From 5cd70f3e13565cda9173204a52b158558ba2346f Mon Sep 17 00:00:00 2001 From: Paul Steckler Date: Thu, 8 Sep 2022 11:41:52 -0700 Subject: [PATCH 076/144] Fix grammar --- src/lib/mina_base/account_update.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/mina_base/account_update.ml b/src/lib/mina_base/account_update.ml index c505a6c9328..85efa77c8ac 100644 --- a/src/lib/mina_base/account_update.ml +++ b/src/lib/mina_base/account_update.ml @@ -1242,7 +1242,7 @@ module T = struct [%%versioned module Stable = struct module V1 = struct - (** A account_update to a zkApp transaction *) + (** An account update in a zkApp transaction *) type t = { body : Body.Graphql_repr.Stable.V1.t ; authorization : Control.Stable.V2.t From 2d8de77b2bdb496b829c2f6cd091330cbc7fc810 Mon Sep 17 00:00:00 2001 From: Paul Steckler Date: Thu, 8 Sep 2022 12:17:46 -0700 Subject: [PATCH 077/144] Bump snarkyjs --- src/lib/snarky_js_bindings/snarkyjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/snarky_js_bindings/snarkyjs b/src/lib/snarky_js_bindings/snarkyjs index 09685dc77b7..845c66e4e73 160000 --- a/src/lib/snarky_js_bindings/snarkyjs +++ b/src/lib/snarky_js_bindings/snarkyjs @@ -1 +1 @@ -Subproject commit 09685dc77b7fb82228e2f75b56e78f01c36b07c8 +Subproject commit 845c66e4e73cc46fac9528f55485f1fcb71ba6c6 From 755c350b24bdb7e64969cb5187699dbd1316f653 Mon Sep 17 00:00:00 2001 From: Fabrizio Date: Thu, 8 Sep 2022 16:38:08 -0300 Subject: [PATCH 078/144] finish --- .../common/kimchi_backend_common.mli | 52 +++++ .../common/scalar_challenge.mli | 99 +++++++++ src/lib/crypto/kimchi_backend/dune | 3 + .../crypto/kimchi_backend/kimchi_backend.ml | 18 +- .../crypto/kimchi_backend/kimchi_backend.mli | 190 +++++++++++++++++- .../kimchi_backend/pasta/kimchi_pasta.ml | 13 -- .../kimchi_backend/pasta/kimchi_pasta.mli | 64 ++++++ 7 files changed, 400 insertions(+), 39 deletions(-) create mode 100644 src/lib/crypto/kimchi_backend/common/kimchi_backend_common.mli create mode 100644 src/lib/crypto/kimchi_backend/common/scalar_challenge.mli create mode 100644 src/lib/crypto/kimchi_backend/pasta/kimchi_pasta.mli diff --git a/src/lib/crypto/kimchi_backend/common/kimchi_backend_common.mli b/src/lib/crypto/kimchi_backend/common/kimchi_backend_common.mli new file mode 100644 index 00000000000..cc3c10bd252 --- /dev/null +++ b/src/lib/crypto/kimchi_backend/common/kimchi_backend_common.mli @@ -0,0 +1,52 @@ +module Bigint = Bigint +module Field = Field +module Curve = Curve +module Poly_comm = Poly_comm +module Plonk_constraint_system = Plonk_constraint_system +module Dlog_plonk_based_keypair = Dlog_plonk_based_keypair +module Constants = Constants +module Plonk_dlog_proof = Plonk_dlog_proof +module Plonk_dlog_oracles = Plonk_dlog_oracles +module Var = Var + +module Scalar_challenge : sig + module Stable = Scalar_challenge.Stable + + type 'f t = 'f Kimchi_types.scalar_challenge = { inner : 'f } + + val to_yojson : ('f -> Yojson.Safe.t) -> 'f t -> Yojson.Safe.t + + val of_yojson : + (Yojson.Safe.t -> 'f Ppx_deriving_yojson_runtime.error_or) + -> Yojson.Safe.t + -> 'f t Ppx_deriving_yojson_runtime.error_or + + val t_of_sexp : + (Ppx_sexp_conv_lib.Sexp.t -> 'f) -> Ppx_sexp_conv_lib.Sexp.t -> 'f t + + val sexp_of_t : + ('f -> Ppx_sexp_conv_lib.Sexp.t) -> 'f t -> Ppx_sexp_conv_lib.Sexp.t + + val compare : ('f -> 'f -> int) -> 'f t -> 'f t -> int + + val equal : ('f -> 'f -> bool) -> 'f t -> 'f t -> bool + + val hash_fold_t : + (Base_internalhash_types.state -> 'f -> Base_internalhash_types.state) + -> Base_internalhash_types.state + -> 'f t + -> Base_internalhash_types.state + + val create : 'a -> 'a t + + val typ : + ('a, 'b, 'c) Snarky_backendless.Typ.t + -> ('a t, 'b t, 'c) Snarky_backendless.Typ.t + + val map : 'a t -> f:('a -> 'b) -> 'b t +end + +module Endoscale_round = Endoscale_round +module Scale_round = Scale_round +module Endoscale_scalar_round = Endoscale_scalar_round +module Intf = Intf diff --git a/src/lib/crypto/kimchi_backend/common/scalar_challenge.mli b/src/lib/crypto/kimchi_backend/common/scalar_challenge.mli new file mode 100644 index 00000000000..0ba55230e38 --- /dev/null +++ b/src/lib/crypto/kimchi_backend/common/scalar_challenge.mli @@ -0,0 +1,99 @@ +module Stable : sig + module V2 : sig + type 'f t = 'f Kimchi_types.scalar_challenge = { inner : 'f } + + (** pickles required *) + val to_yojson : ('f -> Yojson.Safe.t) -> 'f t -> Yojson.Safe.t + + (** pickles required *) + val of_yojson : + (Yojson.Safe.t -> 'f Ppx_deriving_yojson_runtime.error_or) + -> Yojson.Safe.t + -> 'f t Ppx_deriving_yojson_runtime.error_or + + (** pickles required *) + val bin_shape_t : Bin_prot.Shape.t -> Bin_prot.Shape.t + + (** pickles required *) + val bin_size_t : 'f Bin_prot.Size.sizer -> 'f t Bin_prot.Size.sizer + + (** pickles required *) + val bin_write_t : 'f Bin_prot.Write.writer -> 'f t Bin_prot.Write.writer + + (** pickles required *) + val bin_read_t : 'f Bin_prot.Read.reader -> 'f t Bin_prot.Read.reader + + (** pickles required *) + val __versioned__ : unit + + (** pickles required *) + val t_of_sexp : + (Ppx_sexp_conv_lib.Sexp.t -> 'f) -> Ppx_sexp_conv_lib.Sexp.t -> 'f t + + (** pickles required *) + val sexp_of_t : + ('weak5 -> Ppx_sexp_conv_lib.Sexp.t) + -> 'weak5 t + -> Ppx_sexp_conv_lib.Sexp.t + + (** pickles required *) + val compare : ('f -> 'f -> int) -> 'f t -> 'f t -> int + + (** pickles required *) + val equal : ('f -> 'f -> bool) -> 'f t -> 'f t -> bool + + (** pickles required *) + val hash_fold_t : + (Base_internalhash_types.state -> 'f -> Base_internalhash_types.state) + -> Base_internalhash_types.state + -> 'f t + -> Base_internalhash_types.state + end + + (** pickles required *) + module Latest = V2 +end + +(** pickles required *) +type 'f t = 'f Kimchi_types.scalar_challenge = { inner : 'f } + +(** pickles required *) +val to_yojson : ('f -> Yojson.Safe.t) -> 'f t -> Yojson.Safe.t + +(** pickles required *) +val of_yojson : + (Yojson.Safe.t -> 'f Ppx_deriving_yojson_runtime.error_or) + -> Yojson.Safe.t + -> 'f t Ppx_deriving_yojson_runtime.error_or + +(** pickles required *) +val t_of_sexp : + (Ppx_sexp_conv_lib.Sexp.t -> 'f) -> Ppx_sexp_conv_lib.Sexp.t -> 'f t + +(** pickles required *) +val sexp_of_t : + ('f -> Ppx_sexp_conv_lib.Sexp.t) -> 'f t -> Ppx_sexp_conv_lib.Sexp.t + +(** pickles required *) +val compare : ('f -> 'f -> int) -> 'f t -> 'f t -> int + +(** pickles required *) +val equal : ('f -> 'f -> bool) -> 'f t -> 'f t -> bool + +(** pickles required *) +val hash_fold_t : + (Base_internalhash_types.state -> 'f -> Base_internalhash_types.state) + -> Base_internalhash_types.state + -> 'f t + -> Base_internalhash_types.state + +(** pickles required *) +val create : 'a -> 'a t + +(** pickles required *) +val typ : + ('a, 'b, 'c) Snarky_backendless.Typ.t + -> ('a t, 'b t, 'c) Snarky_backendless.Typ.t + +(** pickles required *) +val map : 'a t -> f:('a -> 'b) -> 'b t diff --git a/src/lib/crypto/kimchi_backend/dune b/src/lib/crypto/kimchi_backend/dune index 5cf761973b5..990c0b88077 100644 --- a/src/lib/crypto/kimchi_backend/dune +++ b/src/lib/crypto/kimchi_backend/dune @@ -12,6 +12,9 @@ integers core_kernel ppx_inline_test.config + sexplib0 + bin_prot.shape + base.base_internalhash_types ;; local libraries kimchi_bindings kimchi_types diff --git a/src/lib/crypto/kimchi_backend/kimchi_backend.ml b/src/lib/crypto/kimchi_backend/kimchi_backend.ml index 25f236126a3..259995bbc9e 100644 --- a/src/lib/crypto/kimchi_backend/kimchi_backend.ml +++ b/src/lib/crypto/kimchi_backend/kimchi_backend.ml @@ -1,22 +1,6 @@ module Kimchi_backend_common = struct - (* module Bigint = Kimchi_backend_common.Bigint *) module Field = Kimchi_backend_common.Field - - (* module Curve = Kimchi_backend_common.Curve *) - (* module Poly_comm = Kimchi_backend_common.Poly_comm *) - (* module Plonk_constraint_system = Kimchi_backend_common.Plonk_constraint_system *) - (* module Dlog_plonk_based_keypair = *) - (* Kimchi_backend_common.Dlog_plonk_based_keypair *) - (* module Constants = Kimchi_backend_common.Constants *) - (* module Plonk_dlog_proof = Kimchi_backend_common.Plonk_dlog_proof *) - (* module Plonk_dlog_oracles = Kimchi_backend_common.Plonk_dlog_oracles *) - (* module Var = Kimchi_backend_common.Var *) - (* module Intf = Kimchi_backend_common.Intf *) - (* module Scalar_challenge = Kimchi_backend_common.Scalar_challenge *) module Scalar_challenge = Kimchi_backend_common.Scalar_challenge - (* module Endoscale_round = Kimchi_backend_common.Endoscale_round *) - (* module Scale_round = Kimchi_backend_common.Scale_round *) - (* module Endoscale_scalar_round = Kimchi_backend_common.Endoscale_scalar_round *) end module Field = Kimchi_backend_common.Field @@ -27,4 +11,4 @@ module Pasta = struct module Pasta = Kimchi_pasta.Pasta module Precomputed = Kimchi_pasta.Precomputed module Vesta_based_plonk = Kimchi_pasta.Vesta_based_plonk -end +end \ No newline at end of file diff --git a/src/lib/crypto/kimchi_backend/kimchi_backend.mli b/src/lib/crypto/kimchi_backend/kimchi_backend.mli index 4669c331290..f4869c7fa91 100644 --- a/src/lib/crypto/kimchi_backend/kimchi_backend.mli +++ b/src/lib/crypto/kimchi_backend/kimchi_backend.mli @@ -1,14 +1,134 @@ module Kimchi_backend_common : sig module Field : sig - (* module Bignum_bigint = Snarky_backendless.Backend_extended.Bignum_bigint *) + module type S = sig + type t - (* module type Input_intf = Kimchi_backend_common.Field.Input_intf *) + val to_yojson : t -> Yojson.Safe.t + val of_yojson : Yojson.Safe.t -> t Ppx_deriving_yojson_runtime.error_or + val t_of_sexp : Sexplib0.Sexp.t -> t + val sexp_of_t : t -> Sexplib0.Sexp.t + val compare : t -> t -> int + val bin_size_t : t Bin_prot.Size.sizer + val bin_write_t : t Bin_prot.Write.writer + val bin_read_t : t Bin_prot.Read.reader + val __bin_read_t__ : (int -> t) Bin_prot.Read.reader + val bin_shape_t : Bin_shape_lib.Bin_shape.t + val bin_writer_t : t Bin_prot.Type_class.writer0 + val bin_reader_t : t Bin_prot.Type_class.reader0 + val bin_t : t Bin_prot.Type_class.t0 + val hash_fold_t : + Base_internalhash_types.state -> t -> Base_internalhash_types.state + val hash : t -> Ppx_hash_lib.Std.Hash.hash_value - module type S = Kimchi_backend_common.Field.S + module Bigint : Kimchi_backend_common__.Bigint.Intf - (* module type S_with_version = Kimchi_backend_common.Field.S_with_version *) + val to_bigint : t -> Bigint.t + + val of_bigint : Bigint.t -> t + + val of_int : int -> t + + val add : t -> t -> t + + val sub : t -> t -> t + + val mul : t -> t -> t + + val div : t -> t -> t + + val negate : t -> t + + val square : t -> t + + val is_square : t -> bool + + val equal : t -> t -> bool + + val print : t -> unit + + val to_string : t -> string + + val of_string : string -> t + + val random : unit -> t + + val rng : int -> t + + val two_adic_root_of_unity : unit -> t + + val mut_add : t -> t -> unit + + val mut_mul : t -> t -> unit + + val mut_square : t -> unit + + val mut_sub : t -> t -> unit + + val copy : t -> t -> unit + + val to_bytes : t -> bytes + + val of_bytes : bytes -> t + + module Vector : sig + type elt = t + + type t + + val create : unit -> t + + val get : t -> int -> elt + + val emplace_back : t -> elt -> unit + + val length : t -> int + end + + val size : Bigint.t + + val domain_generator : log2_size:int -> t + + val one : t + + val zero : t + + val inv : t -> t + + val sqrt : t -> t + + val size_in_bits : int + + val to_bits : t -> bool list + + val of_bits : bool list -> t + + val ( + ) : t -> t -> t + + val ( - ) : t -> t -> t + + val ( * ) : t -> t -> t + + val ( / ) : t -> t -> t + + module Mutable : sig + val add : t -> other:t -> unit + + val mul : t -> other:t -> unit + + val square : t -> unit + + val sub : t -> other:t -> unit + + val copy : over:t -> t -> unit + end + + val ( += ) : t -> t -> unit + + val ( *= ) : t -> t -> unit + + val ( -= ) : t -> t -> unit + end - (* module Make = Kimchi_backend_common.Field.Make *) end module Scalar_challenge = Kimchi_backend_common.Scalar_challenge @@ -17,9 +137,61 @@ end module Field = Kimchi_backend_common.Field module Pasta : sig - module Basic = Kimchi_pasta.Basic - module Pallas_based_plonk = Kimchi_pasta.Pallas_based_plonk - module Pasta = Kimchi_pasta.Pasta + module Basic : sig + module Bigint256 = Kimchi_pasta.Basic.Bigint256 + module Fp = Kimchi_pasta.Basic.Fp + end + + + (** pickles required *) + module Pallas_based_plonk : sig + (* all pickles required *) + module Field = Kimchi_pasta.Pallas_based_plonk.Field + module Curve = Kimchi_pasta.Pallas_based_plonk.Curve + module Bigint = Kimchi_pasta.Pallas_based_plonk.Bigint + + val field_size : Pasta_bindings.BigInt256.t + + module Verification_key = Kimchi_pasta.Pallas_based_plonk.Verification_key + + module R1CS_constraint_system = + Kimchi_pasta.Pallas_based_plonk.R1CS_constraint_system + + module Var = Kimchi_pasta.Pallas_based_plonk.Var + module Rounds_vector = Kimchi_pasta.Pallas_based_plonk.Rounds_vector + module Rounds = Kimchi_pasta.Pallas_based_plonk.Rounds + module Keypair = Kimchi_pasta.Pallas_based_plonk.Keypair + module Proof = Kimchi_pasta.Pallas_based_plonk.Proof + module Proving_key = Kimchi_pasta.Pallas_based_plonk.Proving_key + module Oracles = Kimchi_pasta.Pallas_based_plonk.Oracles + end + + (* module Pasta = Kimchi_pasta.Pasta *) + module Pasta : sig + (** pickles required *) + module Vesta = Kimchi_pasta.Pasta.Vesta + (** pickles required *) + module Pallas = Kimchi_pasta.Pasta.Pallas + end + module Precomputed = Kimchi_pasta.Precomputed - module Vesta_based_plonk = Kimchi_pasta.Vesta_based_plonk + + (** pickles required *) + module Vesta_based_plonk : sig + (* all pickles required *) + module Field = Kimchi_pasta.Vesta_based_plonk.Field + module Curve = Kimchi_pasta.Vesta_based_plonk.Curve + module Bigint = Kimchi_pasta.Vesta_based_plonk.Bigint + val field_size : Pasta_bindings.BigInt256.t + module Verification_key = Kimchi_pasta.Vesta_based_plonk.Verification_key + module R1CS_constraint_system = + Kimchi_pasta.Vesta_based_plonk.R1CS_constraint_system + module Var = Kimchi_pasta.Vesta_based_plonk.Var + module Rounds_vector = Kimchi_pasta.Vesta_based_plonk.Rounds_vector + module Rounds = Kimchi_pasta.Vesta_based_plonk.Rounds + module Keypair = Kimchi_pasta.Vesta_based_plonk.Keypair + module Proof = Kimchi_pasta.Vesta_based_plonk.Proof + module Proving_key = Kimchi_pasta.Vesta_based_plonk.Proving_key + module Oracles = Kimchi_pasta.Vesta_based_plonk.Oracles + end end diff --git a/src/lib/crypto/kimchi_backend/pasta/kimchi_pasta.ml b/src/lib/crypto/kimchi_backend/pasta/kimchi_pasta.ml index e627940570a..cdac0ed80e2 100644 --- a/src/lib/crypto/kimchi_backend/pasta/kimchi_pasta.ml +++ b/src/lib/crypto/kimchi_backend/pasta/kimchi_pasta.ml @@ -5,10 +5,6 @@ module Pallas_based_plonk = struct let field_size = Pallas_based_plonk.field_size - (* let lagrange = Vesta_based_plonk.lagrange *) - (* let with_lagrange = Vesta_based_plonk.with_lagrange *) - (* let with_lagranges = Vesta_based_plonk.with_lagranges *) - module Verification_key = Pallas_based_plonk.Verification_key module R1CS_constraint_system = Pallas_based_plonk.R1CS_constraint_system module Var = Pallas_based_plonk.Var @@ -27,10 +23,6 @@ module Vesta_based_plonk = struct let field_size = Vesta_based_plonk.field_size - (* let lagrange = Vesta_based_plonk.lagrange *) - (* let with_lagrange = Vesta_based_plonk.with_lagrange *) - (* let with_lagranges = Vesta_based_plonk.with_lagranges *) - module Verification_key = Vesta_based_plonk.Verification_key module R1CS_constraint_system = Vesta_based_plonk.R1CS_constraint_system module Var = Vesta_based_plonk.Var @@ -56,11 +48,6 @@ module Basic = struct module Rounds = Basic.Rounds module Bigint256 = Basic.Bigint256 module Fp = Basic.Fp - (* module Fq = Basic.Fq *) - (* module Vesta = Basic.Vesta *) - (* module Pallas = Basic.Pallas *) - (* module Fq_poly_comm = Basic.Fq_poly_comm *) - (* module Fp_poly_comm = Basic.Fp_poly_comm *) end module Precomputed = Precomputed diff --git a/src/lib/crypto/kimchi_backend/pasta/kimchi_pasta.mli b/src/lib/crypto/kimchi_backend/pasta/kimchi_pasta.mli new file mode 100644 index 00000000000..3dc558020a4 --- /dev/null +++ b/src/lib/crypto/kimchi_backend/pasta/kimchi_pasta.mli @@ -0,0 +1,64 @@ +module Pallas_based_plonk : sig + module Field = Basic.Fq + module Curve = Basic.Pallas + module Bigint = Pallas_based_plonk.Bigint + + val field_size : Pasta_bindings.BigInt256.t + + module Verification_key = Pallas_based_plonk.Verification_key + module R1CS_constraint_system = Pallas_based_plonk.R1CS_constraint_system + module Var = Kimchi_backend_common.Var + module Rounds_vector = Pallas_based_plonk.Rounds_vector + module Rounds = Pallas_based_plonk.Rounds + module Keypair = Pallas_based_plonk.Keypair + module Proof = Pallas_based_plonk.Proof + module Proving_key = Pallas_based_plonk.Proving_key + module Oracles = Pallas_based_plonk.Oracles +end + +module Vesta_based_plonk : sig + module Field = Basic.Fp + module Curve = Basic.Vesta + module Bigint = Vesta_based_plonk.Bigint + + val field_size : Pasta_bindings.BigInt256.t + + module Verification_key = Vesta_based_plonk.Verification_key + module R1CS_constraint_system = Vesta_based_plonk.R1CS_constraint_system + module Var = Kimchi_backend_common.Var + module Rounds_vector = Vesta_based_plonk.Rounds_vector + module Rounds = Vesta_based_plonk.Rounds + module Keypair = Vesta_based_plonk.Keypair + module Proof = Vesta_based_plonk.Proof + module Proving_key = Vesta_based_plonk.Proving_key + module Oracles = Vesta_based_plonk.Oracles +end + +module Pasta : sig + module Rounds = Basic.Rounds + module Bigint256 = Basic.Bigint256 + module Fp = Basic.Fp + module Fq = Basic.Fq + module Vesta = Basic.Vesta + module Pallas = Basic.Pallas + module Precomputed = Precomputed +end + +module Basic : sig + module Rounds = Basic.Rounds + module Bigint256 = Basic.Bigint256 + module Fp = Basic.Fp +end + +module Precomputed : sig + module Lagrange_precomputations : sig + (** pickles required *) + val index_of_domain_log2 : int -> int + + (** pickles required *) + val vesta : (Pasta_bindings.Fq.t * Pasta_bindings.Fq.t) array array array + + (** pickles required *) + val pallas : (Pasta_bindings.Fp.t * Pasta_bindings.Fp.t) array array array + end +end From 5125c3d1d14d06aa5bfda36b21c2cf57b0348e03 Mon Sep 17 00:00:00 2001 From: Paul Steckler Date: Thu, 8 Sep 2022 12:57:58 -0700 Subject: [PATCH 079/144] fix GraphQL schema --- graphql_schema.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/graphql_schema.json b/graphql_schema.json index b4a769d6bee..edef1a9fa76 100644 --- a/graphql_schema.json +++ b/graphql_schema.json @@ -3225,7 +3225,7 @@ { "kind": "INPUT_OBJECT", "name": "ZkappAccountUpdateInput", - "description": "A account_update to a zkApp transaction", + "description": "An account update in a zkApp transaction", "fields": [ { "name": "body", @@ -7996,7 +7996,7 @@ { "kind": "OBJECT", "name": "ZkappAccountUpdate", - "description": "A account_update to a zkApp transaction", + "description": "An account update in a zkApp transaction", "fields": [ { "name": "body", From 0368980a8ff0f8e76de9ff1db3cafa93fd4b16e9 Mon Sep 17 00:00:00 2001 From: Gregor Date: Fri, 9 Sep 2022 10:51:50 +0200 Subject: [PATCH 080/144] [snarkyjs] fixup object key --- src/lib/snarky_js_bindings/lib/snarky_js_bindings_lib.ml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/lib/snarky_js_bindings/lib/snarky_js_bindings_lib.ml b/src/lib/snarky_js_bindings/lib/snarky_js_bindings_lib.ml index 660d255e2f5..a506c2db08b 100644 --- a/src/lib/snarky_js_bindings/lib/snarky_js_bindings_lib.ml +++ b/src/lib/snarky_js_bindings/lib/snarky_js_bindings_lib.ml @@ -2124,7 +2124,6 @@ let pickles_digest (choices : pickles_rule_js Js.js_array Js.t) ~auxiliary_typ:Typ.unit ~branches:(module Branches) ~max_proofs_verified:(module Pickles_types.Nat.N0) - (* ^ TODO make max_branching configurable -- needs refactor in account_update types *) ~name ~constraint_constants in failwith "Unexpected: The exception will always fire" @@ -2148,7 +2147,6 @@ let pickles_compile (choices : pickles_rule_js Js.js_array Js.t) ~auxiliary_typ:Typ.unit ~branches:(module Branches) ~max_proofs_verified:(module Max_proofs_verified) - (* ^ TODO make max_branching configurable -- needs refactor in account_update types *) ~name ~constraint_constants in let module Proof = (val p) in @@ -2709,7 +2707,7 @@ module Ledger = struct in let account_update = List.nth_exn tx.account_updates account_update_index in object%js - val account_update = + val accountUpdate = to_js_field_unchecked (account_update.elt.account_update_digest :> Impl.field) From 8bc4a9d6bf70c34e577f9a4db6781f8b05481071 Mon Sep 17 00:00:00 2001 From: Gregor Date: Fri, 9 Sep 2022 11:09:49 +0200 Subject: [PATCH 081/144] bump snarkyjs --- src/lib/snarky_js_bindings/snarkyjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/snarky_js_bindings/snarkyjs b/src/lib/snarky_js_bindings/snarkyjs index 845c66e4e73..1afdcb46cb4 160000 --- a/src/lib/snarky_js_bindings/snarkyjs +++ b/src/lib/snarky_js_bindings/snarkyjs @@ -1 +1 @@ -Subproject commit 845c66e4e73cc46fac9528f55485f1fcb71ba6c6 +Subproject commit 1afdcb46cb4d532caef8e233428441cb05140257 From c01a6bc0853d0692776d1bbeeaa5a0a090a2b3a2 Mon Sep 17 00:00:00 2001 From: Gregor Date: Fri, 9 Sep 2022 11:15:16 +0200 Subject: [PATCH 082/144] [mina-signer] remove console log --- frontend/mina-signer/src/MinaSigner.ts | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/frontend/mina-signer/src/MinaSigner.ts b/frontend/mina-signer/src/MinaSigner.ts index f65a09ea872..e33a0eaadaa 100644 --- a/frontend/mina-signer/src/MinaSigner.ts +++ b/frontend/mina-signer/src/MinaSigner.ts @@ -16,7 +16,12 @@ import type { SignableData, } from "./TSTypes"; -import { isPayment, isMessage, isStakeDelegation, isZkappCommand } from "./Utils"; +import { + isPayment, + isMessage, + isStakeDelegation, + isZkappCommand, +} from "./Utils"; const defaultValidUntil = "4294967295"; @@ -339,11 +344,19 @@ class Client { * @param privateKey The fee payer private key * @returns Signed ZkappCommand */ - public signZkappCommand(zkappCommand: ZkappCommand, privateKey: PrivateKey): Signed { - const account_updates = JSON.stringify(zkappCommand.zkappCommand.accountUpdates); + public signZkappCommand( + zkappCommand: ZkappCommand, + privateKey: PrivateKey + ): Signed { + const account_updates = JSON.stringify( + zkappCommand.zkappCommand.accountUpdates + ); if ( zkappCommand.feePayer.fee === undefined || - zkappCommand.feePayer.fee < this.getAccountUpdateMinimumFee(zkappCommand.zkappCommand.accountUpdates) + zkappCommand.feePayer.fee < + this.getAccountUpdateMinimumFee( + zkappCommand.zkappCommand.accountUpdates + ) ) { throw `Fee must be greater than ${this.getAccountUpdateMinimumFee( zkappCommand.zkappCommand.accountUpdates @@ -415,8 +428,7 @@ class Client { payload: SignableData, privateKey: PrivateKey ): Signed { - console.log (payload); - if (isMessage(payload)) { + if (isMessage(payload)) { return this.signMessage(payload.message, { publicKey: payload.publicKey, privateKey, From 90a7746b330d1e12eb11c0d000b03e1353edd2b2 Mon Sep 17 00:00:00 2001 From: Florian Date: Fri, 9 Sep 2022 13:17:06 +0200 Subject: [PATCH 083/144] add permission struct --- .../lib/snarky_js_bindings_lib.ml | 21 ++++++++++++++++--- src/lib/snarky_js_bindings/snarkyjs | 2 +- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/lib/snarky_js_bindings/lib/snarky_js_bindings_lib.ml b/src/lib/snarky_js_bindings/lib/snarky_js_bindings_lib.ml index 90037cfe552..7efeb590679 100644 --- a/src/lib/snarky_js_bindings/lib/snarky_js_bindings_lib.ml +++ b/src/lib/snarky_js_bindings/lib/snarky_js_bindings_lib.ml @@ -9,6 +9,7 @@ module Sc = (Pickles.Endo.Step_inner_curve) module Js = Js_of_ocaml.Js + let console_log_string s = Js_of_ocaml.Firebug.console##log (Js.string s) let console_log s = Js_of_ocaml.Firebug.console##log s @@ -2320,8 +2321,12 @@ module Ledger = struct ; provedState : bool_class Js.t Js.readonly_prop > Js.t + type permissions = + < editState : Mina_base.Permissions.Auth_required.t Js.readonly_prop > + Js.t + type account = - (* TODO: permissions, timing *) + (* TODO: timing *) < publicKey : public_key Js.readonly_prop ; tokenId : field_class Js.t Js.readonly_prop ; tokenSymbol : Js.js_string Js.t Js.readonly_prop @@ -2330,7 +2335,9 @@ module Ledger = struct ; receiptChainHash : field_class Js.t Js.readonly_prop ; delegate : public_key Js.optdef Js.readonly_prop ; votingFor : field_class Js.t Js.readonly_prop - ; zkapp : zkapp_account Js.optdef Js.readonly_prop > + ; zkapp : zkapp_account Js.optdef Js.readonly_prop + ; permissions : permissions Js.readonly_prop + > Js.t let ledger_class : < .. > Js.t = @@ -2572,6 +2579,11 @@ module Ledger = struct val hash = field (With_hash.hash vk) val data = With_hash.data vk + end + + let permissions (p : Mina_base.Permissions.t) : permissions = + object%js + val editState = p.edit_state (* I would like to get the type of p.edit_state and derive a string from it *) end let zkapp_account (a : Mina_base.Zkapp_account.t) : zkapp_account = @@ -2610,6 +2622,8 @@ module Ledger = struct val votingFor = field (a.voting_for :> Impl.field) val zkapp = option zkapp_account a.zkapp + + val permissions = permissions a.permissions end end @@ -2862,7 +2876,8 @@ module Ledger = struct account Js.optdef = let loc = L.location_of_account l##.value (account_id pk token) in let account = Option.bind loc ~f:(L.get l##.value) in - To_js.option To_js.account account + let acc = To_js.option To_js.account account in + acc let add_account l (pk : public_key) (balance : Js.js_string Js.t) = add_account_exn l##.value pk (Js.to_string balance) diff --git a/src/lib/snarky_js_bindings/snarkyjs b/src/lib/snarky_js_bindings/snarkyjs index 0eb11271319..4e8f94fa722 160000 --- a/src/lib/snarky_js_bindings/snarkyjs +++ b/src/lib/snarky_js_bindings/snarkyjs @@ -1 +1 @@ -Subproject commit 0eb1127131900326febe3d7f2b7d1b8414317c65 +Subproject commit 4e8f94fa722f2dc6ce743d0a3924cb68f0f77733 From 38e49b01fc576afca350660e76b5a16d89eaadd4 Mon Sep 17 00:00:00 2001 From: Fabrizio Date: Fri, 9 Sep 2022 10:25:37 -0300 Subject: [PATCH 084/144] dune fmt --- src/lib/crypto/kimchi_backend/common/dune | 53 +++++++++---------- .../common/kimchi_backend_common.ml | 2 +- .../crypto/kimchi_backend/kimchi_backend.ml | 2 +- 3 files changed, 28 insertions(+), 29 deletions(-) diff --git a/src/lib/crypto/kimchi_backend/common/dune b/src/lib/crypto/kimchi_backend/common/dune index 973396428b4..ba1a142dca5 100644 --- a/src/lib/crypto/kimchi_backend/common/dune +++ b/src/lib/crypto/kimchi_backend/common/dune @@ -14,33 +14,32 @@ ppx_deriving.std h_list.ppx)) (libraries - ;; opam libraries - result - async_kernel - sexplib0 - bin_prot.shape - integers - digestif - core_kernel - base.caml - ppx_inline_test.config - bignum.bigint - base.base_internalhash_types - ;; local libraries - tuple_lib - snarky.backendless - key_cache - pickles_types - hex - kimchi_bindings - kimchi_types - pasta_bindings - sponge - allocation_functor - snarky.intf - promise - ppx_version.runtime -)) + ;; opam libraries + result + async_kernel + sexplib0 + bin_prot.shape + integers + digestif + core_kernel + base.caml + ppx_inline_test.config + bignum.bigint + base.base_internalhash_types + ;; local libraries + tuple_lib + snarky.backendless + key_cache + pickles_types + hex + kimchi_bindings + kimchi_types + pasta_bindings + sponge + allocation_functor + snarky.intf + promise + ppx_version.runtime)) (rule (targets version.ml) diff --git a/src/lib/crypto/kimchi_backend/common/kimchi_backend_common.ml b/src/lib/crypto/kimchi_backend/common/kimchi_backend_common.ml index 8d36e7f64be..1242dab2ed0 100644 --- a/src/lib/crypto/kimchi_backend/common/kimchi_backend_common.ml +++ b/src/lib/crypto/kimchi_backend/common/kimchi_backend_common.ml @@ -12,4 +12,4 @@ module Scalar_challenge = Scalar_challenge module Endoscale_round = Endoscale_round module Scale_round = Scale_round module Endoscale_scalar_round = Endoscale_scalar_round -module Intf = Intf \ No newline at end of file +module Intf = Intf diff --git a/src/lib/crypto/kimchi_backend/kimchi_backend.ml b/src/lib/crypto/kimchi_backend/kimchi_backend.ml index 259995bbc9e..79be23f06ad 100644 --- a/src/lib/crypto/kimchi_backend/kimchi_backend.ml +++ b/src/lib/crypto/kimchi_backend/kimchi_backend.ml @@ -11,4 +11,4 @@ module Pasta = struct module Pasta = Kimchi_pasta.Pasta module Precomputed = Kimchi_pasta.Precomputed module Vesta_based_plonk = Kimchi_pasta.Vesta_based_plonk -end \ No newline at end of file +end From 884a488c92c7e056125b1b748c482064645ceba3 Mon Sep 17 00:00:00 2001 From: Fabrizio Date: Fri, 9 Sep 2022 10:39:17 -0300 Subject: [PATCH 085/144] fix comments --- .../common/scalar_challenge.mli | 48 +++++++++---------- .../crypto/kimchi_backend/kimchi_backend.mli | 27 ++++++++--- .../kimchi_backend/pasta/kimchi_pasta.mli | 6 +-- src/lib/crypto/kimchi_backend/pasta/pasta.mli | 4 -- .../kimchi_backend/pasta/precomputed.mli | 2 - 5 files changed, 48 insertions(+), 39 deletions(-) diff --git a/src/lib/crypto/kimchi_backend/common/scalar_challenge.mli b/src/lib/crypto/kimchi_backend/common/scalar_challenge.mli index 0ba55230e38..9f8eb111214 100644 --- a/src/lib/crypto/kimchi_backend/common/scalar_challenge.mli +++ b/src/lib/crypto/kimchi_backend/common/scalar_challenge.mli @@ -2,47 +2,47 @@ module Stable : sig module V2 : sig type 'f t = 'f Kimchi_types.scalar_challenge = { inner : 'f } - (** pickles required *) + (* pickles required *) val to_yojson : ('f -> Yojson.Safe.t) -> 'f t -> Yojson.Safe.t - (** pickles required *) + (* pickles required *) val of_yojson : (Yojson.Safe.t -> 'f Ppx_deriving_yojson_runtime.error_or) -> Yojson.Safe.t -> 'f t Ppx_deriving_yojson_runtime.error_or - (** pickles required *) + (* pickles required *) val bin_shape_t : Bin_prot.Shape.t -> Bin_prot.Shape.t - (** pickles required *) + (* pickles required *) val bin_size_t : 'f Bin_prot.Size.sizer -> 'f t Bin_prot.Size.sizer - (** pickles required *) + (* pickles required *) val bin_write_t : 'f Bin_prot.Write.writer -> 'f t Bin_prot.Write.writer - (** pickles required *) + (* pickles required *) val bin_read_t : 'f Bin_prot.Read.reader -> 'f t Bin_prot.Read.reader - (** pickles required *) + (* pickles required *) val __versioned__ : unit - (** pickles required *) + (* pickles required *) val t_of_sexp : (Ppx_sexp_conv_lib.Sexp.t -> 'f) -> Ppx_sexp_conv_lib.Sexp.t -> 'f t - (** pickles required *) + (* pickles required *) val sexp_of_t : ('weak5 -> Ppx_sexp_conv_lib.Sexp.t) -> 'weak5 t -> Ppx_sexp_conv_lib.Sexp.t - (** pickles required *) + (* pickles required *) val compare : ('f -> 'f -> int) -> 'f t -> 'f t -> int - (** pickles required *) + (* pickles required *) val equal : ('f -> 'f -> bool) -> 'f t -> 'f t -> bool - (** pickles required *) + (* pickles required *) val hash_fold_t : (Base_internalhash_types.state -> 'f -> Base_internalhash_types.state) -> Base_internalhash_types.state @@ -50,50 +50,50 @@ module Stable : sig -> Base_internalhash_types.state end - (** pickles required *) + (* pickles required *) module Latest = V2 end -(** pickles required *) +(* pickles required *) type 'f t = 'f Kimchi_types.scalar_challenge = { inner : 'f } -(** pickles required *) +(* pickles required *) val to_yojson : ('f -> Yojson.Safe.t) -> 'f t -> Yojson.Safe.t -(** pickles required *) +(* pickles required *) val of_yojson : (Yojson.Safe.t -> 'f Ppx_deriving_yojson_runtime.error_or) -> Yojson.Safe.t -> 'f t Ppx_deriving_yojson_runtime.error_or -(** pickles required *) +(* pickles required *) val t_of_sexp : (Ppx_sexp_conv_lib.Sexp.t -> 'f) -> Ppx_sexp_conv_lib.Sexp.t -> 'f t -(** pickles required *) +(* pickles required *) val sexp_of_t : ('f -> Ppx_sexp_conv_lib.Sexp.t) -> 'f t -> Ppx_sexp_conv_lib.Sexp.t -(** pickles required *) +(* pickles required *) val compare : ('f -> 'f -> int) -> 'f t -> 'f t -> int -(** pickles required *) +(* pickles required *) val equal : ('f -> 'f -> bool) -> 'f t -> 'f t -> bool -(** pickles required *) +(* pickles required *) val hash_fold_t : (Base_internalhash_types.state -> 'f -> Base_internalhash_types.state) -> Base_internalhash_types.state -> 'f t -> Base_internalhash_types.state -(** pickles required *) +(* pickles required *) val create : 'a -> 'a t -(** pickles required *) +(* pickles required *) val typ : ('a, 'b, 'c) Snarky_backendless.Typ.t -> ('a t, 'b t, 'c) Snarky_backendless.Typ.t -(** pickles required *) +(* pickles required *) val map : 'a t -> f:('a -> 'b) -> 'b t diff --git a/src/lib/crypto/kimchi_backend/kimchi_backend.mli b/src/lib/crypto/kimchi_backend/kimchi_backend.mli index f4869c7fa91..bd753d27b0f 100644 --- a/src/lib/crypto/kimchi_backend/kimchi_backend.mli +++ b/src/lib/crypto/kimchi_backend/kimchi_backend.mli @@ -4,20 +4,34 @@ module Kimchi_backend_common : sig type t val to_yojson : t -> Yojson.Safe.t + val of_yojson : Yojson.Safe.t -> t Ppx_deriving_yojson_runtime.error_or + val t_of_sexp : Sexplib0.Sexp.t -> t + val sexp_of_t : t -> Sexplib0.Sexp.t + val compare : t -> t -> int + val bin_size_t : t Bin_prot.Size.sizer + val bin_write_t : t Bin_prot.Write.writer + val bin_read_t : t Bin_prot.Read.reader + val __bin_read_t__ : (int -> t) Bin_prot.Read.reader + val bin_shape_t : Bin_shape_lib.Bin_shape.t + val bin_writer_t : t Bin_prot.Type_class.writer0 + val bin_reader_t : t Bin_prot.Type_class.reader0 + val bin_t : t Bin_prot.Type_class.t0 + val hash_fold_t : Base_internalhash_types.state -> t -> Base_internalhash_types.state + val hash : t -> Ppx_hash_lib.Std.Hash.hash_value module Bigint : Kimchi_backend_common__.Bigint.Intf @@ -128,7 +142,6 @@ module Kimchi_backend_common : sig val ( -= ) : t -> t -> unit end - end module Scalar_challenge = Kimchi_backend_common.Scalar_challenge @@ -142,8 +155,7 @@ module Pasta : sig module Fp = Kimchi_pasta.Basic.Fp end - - (** pickles required *) + (* pickles required *) module Pallas_based_plonk : sig (* all pickles required *) module Field = Kimchi_pasta.Pallas_based_plonk.Field @@ -168,21 +180,24 @@ module Pasta : sig (* module Pasta = Kimchi_pasta.Pasta *) module Pasta : sig - (** pickles required *) + (* pickles required *) module Vesta = Kimchi_pasta.Pasta.Vesta - (** pickles required *) + + (* pickles required *) module Pallas = Kimchi_pasta.Pasta.Pallas end module Precomputed = Kimchi_pasta.Precomputed - (** pickles required *) + (* pickles required *) module Vesta_based_plonk : sig (* all pickles required *) module Field = Kimchi_pasta.Vesta_based_plonk.Field module Curve = Kimchi_pasta.Vesta_based_plonk.Curve module Bigint = Kimchi_pasta.Vesta_based_plonk.Bigint + val field_size : Pasta_bindings.BigInt256.t + module Verification_key = Kimchi_pasta.Vesta_based_plonk.Verification_key module R1CS_constraint_system = Kimchi_pasta.Vesta_based_plonk.R1CS_constraint_system diff --git a/src/lib/crypto/kimchi_backend/pasta/kimchi_pasta.mli b/src/lib/crypto/kimchi_backend/pasta/kimchi_pasta.mli index 3dc558020a4..b6cd8aeeac8 100644 --- a/src/lib/crypto/kimchi_backend/pasta/kimchi_pasta.mli +++ b/src/lib/crypto/kimchi_backend/pasta/kimchi_pasta.mli @@ -52,13 +52,13 @@ end module Precomputed : sig module Lagrange_precomputations : sig - (** pickles required *) + (* pickles required *) val index_of_domain_log2 : int -> int - (** pickles required *) + (* pickles required *) val vesta : (Pasta_bindings.Fq.t * Pasta_bindings.Fq.t) array array array - (** pickles required *) + (* pickles required *) val pallas : (Pasta_bindings.Fp.t * Pasta_bindings.Fp.t) array array array end end diff --git a/src/lib/crypto/kimchi_backend/pasta/pasta.mli b/src/lib/crypto/kimchi_backend/pasta/pasta.mli index a8a8ac7404e..af9caa1b12a 100644 --- a/src/lib/crypto/kimchi_backend/pasta/pasta.mli +++ b/src/lib/crypto/kimchi_backend/pasta/pasta.mli @@ -4,8 +4,4 @@ module Fp = Basic.Fp module Fq = Basic.Fq module Vesta = Basic.Vesta module Pallas = Basic.Pallas - -(* module Fq_poly_comm = Basic.Fq_poly_comm *) -(* module Fp_poly_comm = Basic.Fp_poly_comm *) -(* module Pallas_based_plonk = Pallas_based_plonk *) module Precomputed = Precomputed diff --git a/src/lib/crypto/kimchi_backend/pasta/precomputed.mli b/src/lib/crypto/kimchi_backend/pasta/precomputed.mli index 4500e6c5d08..3ee1fc418ed 100644 --- a/src/lib/crypto/kimchi_backend/pasta/precomputed.mli +++ b/src/lib/crypto/kimchi_backend/pasta/precomputed.mli @@ -1,5 +1,3 @@ -(* val g : string -> string *) - module Lagrange_precomputations : sig val index_of_domain_log2 : int -> int From 2917c382499b4adc049e06d6b1cc44aa9e619138 Mon Sep 17 00:00:00 2001 From: Florian Date: Fri, 9 Sep 2022 16:40:17 +0200 Subject: [PATCH 086/144] move auth_required_of_string under Auth_required module --- src/lib/mina_base/permissions.ml | 53 ++++++++++++++++--------------- src/lib/mina_base/permissions.mli | 4 +++ 2 files changed, 31 insertions(+), 26 deletions(-) diff --git a/src/lib/mina_base/permissions.ml b/src/lib/mina_base/permissions.ml index cb83ee4193f..09fe3546d38 100644 --- a/src/lib/mina_base/permissions.ml +++ b/src/lib/mina_base/permissions.ml @@ -86,6 +86,32 @@ module Auth_required = struct let gen_for_none_given_authorization : t Quickcheck.Generator.t = Quickcheck.Generator.return None + let to_string = function + | None -> + "None" + | Either -> + "Either" + | Proof -> + "Proof" + | Signature -> + "Signature" + | Impossible -> + "Impossible" + + let of_string = function + | "None" -> + Stable.Latest.None + | "Either" -> + Either + | "Proof" -> + Proof + | "Signature" -> + Signature + | "Impossible" -> + Impossible + | _ -> + failwith "auth_required_of_string: unknown variant" + (* The encoding is chosen so that it is easy to write this function let spec_eval t ~signature_verifies = @@ -472,36 +498,11 @@ let empty : t = } (* deriving-fields-related stuff *) -let auth_required_to_string = function - | Auth_required.Stable.Latest.None -> - "None" - | Either -> - "Either" - | Proof -> - "Proof" - | Signature -> - "Signature" - | Impossible -> - "Impossible" - -let auth_required_of_string = function - | "None" -> - Auth_required.Stable.Latest.None - | "Either" -> - Either - | "Proof" -> - Proof - | "Signature" -> - Signature - | "Impossible" -> - Impossible - | _ -> - failwith "auth_required_of_string: unknown variant" let auth_required = Fields_derivers_zkapps.Derivers.iso_string ~name:"AuthRequired" ~js_type:(Custom "AuthRequired") ~doc:"Kind of authorization required" - ~to_string:auth_required_to_string ~of_string:auth_required_of_string + ~to_string:Auth_required.to_string ~of_string:Auth_required.of_string let deriver obj = let open Fields_derivers_zkapps.Derivers in diff --git a/src/lib/mina_base/permissions.mli b/src/lib/mina_base/permissions.mli index 536ef1e0582..e8d84e2a954 100644 --- a/src/lib/mina_base/permissions.mli +++ b/src/lib/mina_base/permissions.mli @@ -23,6 +23,10 @@ module Auth_required : sig val check : t -> Control.Tag.t -> bool + val to_string : t -> string + + val of_string : string -> t + [%%ifdef consensus_mechanism] module Checked : sig From edcdb99cb52b8f036e5526f4f73e2a9c675fd5fa Mon Sep 17 00:00:00 2001 From: Florian Date: Fri, 9 Sep 2022 16:41:06 +0200 Subject: [PATCH 087/144] expose account permissions to snarkyjs --- .../lib/snarky_js_bindings_lib.ml | 68 ++++++++++++++++--- 1 file changed, 58 insertions(+), 10 deletions(-) diff --git a/src/lib/snarky_js_bindings/lib/snarky_js_bindings_lib.ml b/src/lib/snarky_js_bindings/lib/snarky_js_bindings_lib.ml index 7efeb590679..b14a4c2e502 100644 --- a/src/lib/snarky_js_bindings/lib/snarky_js_bindings_lib.ml +++ b/src/lib/snarky_js_bindings/lib/snarky_js_bindings_lib.ml @@ -9,7 +9,6 @@ module Sc = (Pickles.Endo.Step_inner_curve) module Js = Js_of_ocaml.Js - let console_log_string s = Js_of_ocaml.Firebug.console##log (Js.string s) let console_log s = Js_of_ocaml.Firebug.console##log s @@ -2322,7 +2321,17 @@ module Ledger = struct Js.t type permissions = - < editState : Mina_base.Permissions.Auth_required.t Js.readonly_prop > + < editState : Js.js_string Js.t Js.readonly_prop + ; send : Js.js_string Js.t Js.readonly_prop + ; receive : Js.js_string Js.t Js.readonly_prop + ; setDelegate : Js.js_string Js.t Js.readonly_prop + ; setPermissions : Js.js_string Js.t Js.readonly_prop + ; setVerificationKey : Js.js_string Js.t Js.readonly_prop + ; setZkappUri : Js.js_string Js.t Js.readonly_prop + ; editSequenceState : Js.js_string Js.t Js.readonly_prop + ; setTokenSymbol : Js.js_string Js.t Js.readonly_prop + ; incrementNonce : Js.js_string Js.t Js.readonly_prop + ; setVotingFor : Js.js_string Js.t Js.readonly_prop > Js.t type account = @@ -2335,9 +2344,8 @@ module Ledger = struct ; receiptChainHash : field_class Js.t Js.readonly_prop ; delegate : public_key Js.optdef Js.readonly_prop ; votingFor : field_class Js.t Js.readonly_prop - ; zkapp : zkapp_account Js.optdef Js.readonly_prop - ; permissions : permissions Js.readonly_prop - > + ; zkapp : zkapp_account Js.optdef Js.readonly_prop + ; permissions : permissions Js.readonly_prop > Js.t let ledger_class : < .. > Js.t = @@ -2579,11 +2587,6 @@ module Ledger = struct val hash = field (With_hash.hash vk) val data = With_hash.data vk - end - - let permissions (p : Mina_base.Permissions.t) : permissions = - object%js - val editState = p.edit_state (* I would like to get the type of p.edit_state and derive a string from it *) end let zkapp_account (a : Mina_base.Zkapp_account.t) : zkapp_account = @@ -2603,6 +2606,51 @@ module Ledger = struct new%js bool_constr (As_bool.of_js_bool @@ Js.bool a.proved_state) end + let permissions (p : Mina_base.Permissions.t) : permissions = + object%js + val editState = + Js.string (Mina_base.Permissions.Auth_required.to_string p.edit_state) + + val send = + Js.string (Mina_base.Permissions.Auth_required.to_string p.send) + + val receive = + Js.string (Mina_base.Permissions.Auth_required.to_string p.receive) + + val setDelegate = + Js.string + (Mina_base.Permissions.Auth_required.to_string p.set_delegate) + + val setPermissions = + Js.string + (Mina_base.Permissions.Auth_required.to_string p.set_permissions) + + val setVerificationKey = + Js.string + (Mina_base.Permissions.Auth_required.to_string + p.set_verification_key ) + + val setZkappUri = + Js.string + (Mina_base.Permissions.Auth_required.to_string p.set_zkapp_uri) + + val editSequenceState = + Js.string + (Mina_base.Permissions.Auth_required.to_string p.edit_sequence_state) + + val setTokenSymbol = + Js.string + (Mina_base.Permissions.Auth_required.to_string p.set_token_symbol) + + val incrementNonce = + Js.string + (Mina_base.Permissions.Auth_required.to_string p.increment_nonce) + + val setVotingFor = + Js.string + (Mina_base.Permissions.Auth_required.to_string p.set_voting_for) + end + let account (a : Mina_base.Account.t) : account = object%js val publicKey = public_key a.public_key From bc74a4ab705f01894d029f094880b61fc3b5c006 Mon Sep 17 00:00:00 2001 From: Florian Date: Fri, 9 Sep 2022 17:06:39 +0200 Subject: [PATCH 088/144] remove dummy code --- src/lib/snarky_js_bindings/lib/snarky_js_bindings_lib.ml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/lib/snarky_js_bindings/lib/snarky_js_bindings_lib.ml b/src/lib/snarky_js_bindings/lib/snarky_js_bindings_lib.ml index b14a4c2e502..86fa4b9fb55 100644 --- a/src/lib/snarky_js_bindings/lib/snarky_js_bindings_lib.ml +++ b/src/lib/snarky_js_bindings/lib/snarky_js_bindings_lib.ml @@ -2924,8 +2924,7 @@ module Ledger = struct account Js.optdef = let loc = L.location_of_account l##.value (account_id pk token) in let account = Option.bind loc ~f:(L.get l##.value) in - let acc = To_js.option To_js.account account in - acc + To_js.option To_js.account account let add_account l (pk : public_key) (balance : Js.js_string Js.t) = add_account_exn l##.value pk (Js.to_string balance) From c81f763fff6c12b6293550cdb02b882e95ce8d29 Mon Sep 17 00:00:00 2001 From: Florian Date: Fri, 9 Sep 2022 17:21:08 +0200 Subject: [PATCH 089/144] bump snarkyjs --- src/lib/snarky_js_bindings/snarkyjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/snarky_js_bindings/snarkyjs b/src/lib/snarky_js_bindings/snarkyjs index 4e8f94fa722..729a9869526 160000 --- a/src/lib/snarky_js_bindings/snarkyjs +++ b/src/lib/snarky_js_bindings/snarkyjs @@ -1 +1 @@ -Subproject commit 4e8f94fa722f2dc6ce743d0a3924cb68f0f77733 +Subproject commit 729a98695268070d8e47d8e5a0eccfb4e640d511 From 6021c3b06f88ec9e6287ecb99c07d021ea0c294d Mon Sep 17 00:00:00 2001 From: Paul Steckler Date: Fri, 9 Sep 2022 10:32:46 -0700 Subject: [PATCH 090/144] cleanup per PR comments --- ...ansaction.sh => send-zkapp-transaction.sh} | 4 +- src/lib/mina_base/account_update.ml | 4 +- src/lib/mina_base/zkapp_command.ml | 103 +++++++++--------- src/lib/mina_graphql/mina_graphql.ml | 8 +- src/lib/snarky_js_bindings/snarkyjs | 2 +- 5 files changed, 59 insertions(+), 62 deletions(-) rename scripts/{send-parties-transaction.sh => send-zkapp-transaction.sh} (79%) diff --git a/scripts/send-parties-transaction.sh b/scripts/send-zkapp-transaction.sh similarity index 79% rename from scripts/send-parties-transaction.sh rename to scripts/send-zkapp-transaction.sh index 9960e9624c6..924bb6849af 100755 --- a/scripts/send-parties-transaction.sh +++ b/scripts/send-zkapp-transaction.sh @@ -1,7 +1,7 @@ #!/bin/bash # Argument 1: is the query selector for the zkapp_command -# Argument 2: is the zkapp_command json +# Argument 2: is the zkApp command json # Argument 3: is the GraphQL URI set -x @@ -9,4 +9,4 @@ set -x curl \ -X POST \ -H "Content-Type: application/json" \ - -d "$(printf '{ "query": "mutation($input: SendZkappInput!) { sendZkapp(input: $input) %s }" , "variables": { "input": { "zkapp_command": %s } } }' "$1" "$2")" $3 + -d "$(printf '{ "query": "mutation($input: SendZkappInput!) { sendZkapp(input: $input) %s }" , "variables": { "input": { "zkappCommand": %s } } }' "$1" "$2")" $3 diff --git a/src/lib/mina_base/account_update.ml b/src/lib/mina_base/account_update.ml index 85efa77c8ac..a941e3b1e2b 100644 --- a/src/lib/mina_base/account_update.ml +++ b/src/lib/mina_base/account_update.ml @@ -458,7 +458,7 @@ module Update = struct ~checked:(js_only (Js_layout.leaf_type (Custom "TokenSymbol"))) ~name:"TokenSymbol" string in - finish "AccountUpdateUpdate" ~t_toplevel_annots + finish "AccountUpdateModification" ~t_toplevel_annots @@ Fields.make_creator ~app_state:!.(Zkapp_state.deriver @@ Set_or_keep.deriver field) ~delegate:!.(Set_or_keep.deriver public_key) @@ -1392,7 +1392,7 @@ module Fee_payer = struct let ( !. ) = ( !. ) ~t_fields_annots in Fields.make_creator obj ~body:!.Body.Fee_payer.deriver ~authorization:!.Control.signature_deriver - |> finish "ZkappAccountUpdateFeePayer" ~t_toplevel_annots + |> finish "ZkappFeePayer" ~t_toplevel_annots let%test_unit "json roundtrip" = let dummy : t = diff --git a/src/lib/mina_base/zkapp_command.ml b/src/lib/mina_base/zkapp_command.ml index 78d6294f5f7..4cf9ae24bd1 100644 --- a/src/lib/mina_base/zkapp_command.ml +++ b/src/lib/mina_base/zkapp_command.ml @@ -393,10 +393,10 @@ module Call_forest = struct ; stack_hash = () } ) - let rec of_zkapp_command_list_map ~(f : 'p1 -> 'p2) - ~(account_update_depth : 'p1 -> int) (zkapp_command : 'p1 list) : + let rec of_account_updates_map ~(f : 'p1 -> 'p2) + ~(account_update_depth : 'p1 -> int) (account_updates : 'p1 list) : ('p2, unit, unit) t = - match zkapp_command with + match account_updates with | [] -> [] | p :: ps -> @@ -407,17 +407,16 @@ module Call_forest = struct { With_stack_hash.elt = { Tree.account_update = f p ; account_update_digest = () - ; calls = - of_zkapp_command_list_map ~f ~account_update_depth children + ; calls = of_account_updates_map ~f ~account_update_depth children } ; stack_hash = () } - :: of_zkapp_command_list_map ~f ~account_update_depth siblings + :: of_account_updates_map ~f ~account_update_depth siblings - let of_zkapp_command_list ~account_update_depth zkapp_command = - of_zkapp_command_list_map ~f:Fn.id ~account_update_depth zkapp_command + let of_account_updates ~account_update_depth account_updates = + of_account_updates_map ~f:Fn.id ~account_update_depth account_updates - let to_zkapp_command_list_map ~f (xs : _ t) = + let to_account_updates_map ~f (xs : _ t) = let rec collect depth (xs : _ t) acc = match xs with | [] -> @@ -432,10 +431,8 @@ module Call_forest = struct in List.rev (collect 0 xs []) - let to_zkapp_command_list xs = - to_zkapp_command_list_map - ~f:(fun ~depth:_ account_update -> account_update) - xs + let to_account_updates xs = + to_account_updates_map ~f:(fun ~depth:_ account_update -> account_update) xs let hd_account_update (xs : _ t) = match xs with @@ -469,19 +466,19 @@ module Call_forest = struct in let f_index = mapi ~f:(fun i _p -> i) in [%test_eq: (int, unit, unit) t] - (of_zkapp_command_list ~account_update_depth:Fn.id zkapp_command_list_1) + (of_account_updates ~account_update_depth:Fn.id zkapp_command_list_1) zkapp_command_list_1_res ; let zkapp_command_list1_index : (int, unit, unit) t = let n i = node i [] in [ n 0; n 1; n 2; n 3 ] in [%test_eq: (int, unit, unit) t] - ( of_zkapp_command_list ~account_update_depth:Fn.id zkapp_command_list_1 + ( of_account_updates ~account_update_depth:Fn.id zkapp_command_list_1 |> f_index ) zkapp_command_list1_index ; [%test_eq: int list] - (to_zkapp_command_list - (of_zkapp_command_list ~account_update_depth:Fn.id zkapp_command_list_1) ) + (to_account_updates + (of_account_updates ~account_update_depth:Fn.id zkapp_command_list_1) ) zkapp_command_list_1 ; let zkapp_command_list_2 = [ 0; 0; 1; 1 ] in let zkapp_command_list_2_res = @@ -491,15 +488,15 @@ module Call_forest = struct [ node 0 []; node 1 [ node 2 []; node 3 [] ] ] in [%test_eq: (int, unit, unit) t] - (of_zkapp_command_list ~account_update_depth:Fn.id zkapp_command_list_2) + (of_account_updates ~account_update_depth:Fn.id zkapp_command_list_2) zkapp_command_list_2_res ; [%test_eq: (int, unit, unit) t] - ( of_zkapp_command_list ~account_update_depth:Fn.id zkapp_command_list_2 + ( of_account_updates ~account_update_depth:Fn.id zkapp_command_list_2 |> f_index ) zkapp_command_list_2_index ; [%test_eq: int list] - (to_zkapp_command_list - (of_zkapp_command_list ~account_update_depth:Fn.id zkapp_command_list_2) ) + (to_account_updates + (of_account_updates ~account_update_depth:Fn.id zkapp_command_list_2) ) zkapp_command_list_2 ; let zkapp_command_list_3 = [ 0; 0; 1; 0 ] in let zkapp_command_list_3_res = @@ -509,15 +506,15 @@ module Call_forest = struct [ node 0 []; node 1 [ node 2 [] ]; node 3 [] ] in [%test_eq: (int, unit, unit) t] - (of_zkapp_command_list ~account_update_depth:Fn.id zkapp_command_list_3) + (of_account_updates ~account_update_depth:Fn.id zkapp_command_list_3) zkapp_command_list_3_res ; [%test_eq: (int, unit, unit) t] - ( of_zkapp_command_list ~account_update_depth:Fn.id zkapp_command_list_3 + ( of_account_updates ~account_update_depth:Fn.id zkapp_command_list_3 |> f_index ) zkapp_command_list_3_index ; [%test_eq: int list] - (to_zkapp_command_list - (of_zkapp_command_list ~account_update_depth:Fn.id zkapp_command_list_3) ) + (to_account_updates + (of_account_updates ~account_update_depth:Fn.id zkapp_command_list_3) ) zkapp_command_list_3 ; let zkapp_command_list_4 = [ 0; 1; 2; 3; 2; 1; 0 ] in let zkapp_command_list_4_res = @@ -531,15 +528,15 @@ module Call_forest = struct ] in [%test_eq: (int, unit, unit) t] - (of_zkapp_command_list ~account_update_depth:Fn.id zkapp_command_list_4) + (of_account_updates ~account_update_depth:Fn.id zkapp_command_list_4) zkapp_command_list_4_res ; [%test_eq: (int, unit, unit) t] - ( of_zkapp_command_list ~account_update_depth:Fn.id zkapp_command_list_4 + ( of_account_updates ~account_update_depth:Fn.id zkapp_command_list_4 |> f_index ) zkapp_command_list_4_index ; [%test_eq: int list] - (to_zkapp_command_list - (of_zkapp_command_list ~account_update_depth:Fn.id zkapp_command_list_4) ) + (to_account_updates + (of_account_updates ~account_update_depth:Fn.id zkapp_command_list_4) ) zkapp_command_list_4 let to_zkapp_command_with_hashes_list (xs : _ t) = @@ -808,7 +805,7 @@ module Call_forest = struct let of_zkapp_command_simple_list (xs : (Account_update.Simple.t * 'a) list) : _ t = - of_zkapp_command_list xs + of_account_updates xs ~account_update_depth:(fun ((p : Account_update.Simple.t), _) -> p.body.call_depth ) |> add_callers @@ -821,21 +818,21 @@ module Call_forest = struct ) |> accumulate_hashes - let of_zkapp_command_list (xs : (Account_update.Graphql_repr.t * 'a) list) : + let of_account_updates (xs : (Account_update.Graphql_repr.t * 'a) list) : _ t = - of_zkapp_command_list_map + of_account_updates_map ~account_update_depth:(fun ((p : Account_update.Graphql_repr.t), _) -> p.body.call_depth ) ~f:(fun (p, x) -> (Account_update.of_graphql_repr p, x)) xs |> accumulate_hashes - let to_zkapp_command_list (x : _ t) = to_zkapp_command_list x + let to_account_updates (x : _ t) = to_account_updates x let to_zkapp_command_with_hashes_list (x : _ t) = to_zkapp_command_with_hashes_list x - let account_updates_hash' xs = of_zkapp_command_list xs |> hash + let account_updates_hash' xs = of_account_updates xs |> hash let account_updates_hash xs = List.map ~f:(fun x -> (x, ())) xs |> account_updates_hash' @@ -864,7 +861,7 @@ module Call_forest = struct let accumulate_hashes xs : t = accumulate_hashes ~hash_account_update xs let of_zkapp_command_simple_list (xs : Account_update.Simple.t list) : t = - of_zkapp_command_list xs + of_account_updates xs ~account_update_depth:(fun (p : Account_update.Simple.t) -> p.body.call_depth ) |> add_callers @@ -877,20 +874,20 @@ module Call_forest = struct ) |> accumulate_hashes - let of_zkapp_command_list (xs : Account_update.Graphql_repr.t list) : t = - of_zkapp_command_list_map + let of_account_updates (xs : Account_update.Graphql_repr.t list) : t = + of_account_updates_map ~account_update_depth:(fun (p : Account_update.Graphql_repr.t) -> p.body.call_depth ) ~f:(fun p -> Account_update.of_graphql_repr p) xs |> accumulate_hashes - let to_zkapp_command_list (x : t) = to_zkapp_command_list x + let to_account_updates (x : t) = to_account_updates x let to_zkapp_command_with_hashes_list (x : t) = to_zkapp_command_with_hashes_list x - let account_updates_hash' xs = of_zkapp_command_list xs |> hash + let account_updates_hash' xs = of_account_updates xs |> hash let account_updates_hash xs = List.map ~f:(fun x -> x) xs |> account_updates_hash' @@ -992,7 +989,7 @@ module T = struct { fee_payer = t.fee_payer ; memo = t.memo ; account_updates = - Call_forest.of_zkapp_command_list_map t.account_updates + Call_forest.of_account_updates_map t.account_updates ~f:Account_update.of_graphql_repr ~account_update_depth:(fun (p : Account_update.Graphql_repr.t) -> p.body.call_depth ) @@ -1015,7 +1012,7 @@ module T = struct Account_id.( derive_token_id ~owner:(create p.body.public_key p.body.token_id)) ) - |> Call_forest.to_zkapp_command_list_map + |> Call_forest.to_account_updates_map ~f:(fun ~depth account_update -> Account_update.to_graphql_repr account_update ~call_depth:depth ) @@ -1120,7 +1117,7 @@ let of_simple (w : Simple.t) : t = { fee_payer = w.fee_payer ; memo = w.memo ; account_updates = - Call_forest.of_zkapp_command_list w.account_updates + Call_forest.of_account_updates w.account_updates ~account_update_depth:(fun (p : Account_update.Simple.t) -> p.body.call_depth ) |> Call_forest.add_callers @@ -1161,7 +1158,7 @@ let to_simple (t : t) : Simple.t = ~null_id:Token_id.default ~account_update_caller:(fun (p : Account_update.t) -> p.body.caller) t.account_updates - |> Call_forest.to_zkapp_command_list_map + |> Call_forest.to_account_updates_map ~f:(fun ~depth (p : Account_update.Simple.t) -> { p with body = { p.body with call_depth = depth } } ) } @@ -1527,7 +1524,7 @@ type account_updates = let account_updates_deriver obj = let of_zkapp_command_with_depth (ps : Account_update.Graphql_repr.t list) : account_updates = - Call_forest.of_zkapp_command_list ps + Call_forest.of_account_updates ps ~account_update_depth:(fun (p : Account_update.Graphql_repr.t) -> p.body.call_depth ) |> Call_forest.map ~f:Account_update.of_graphql_repr @@ -1535,7 +1532,7 @@ let account_updates_deriver obj = and to_zkapp_command_with_depth (ps : account_updates) : Account_update.Graphql_repr.t list = ps - |> Call_forest.to_zkapp_command_list_map ~f:(fun ~depth p -> + |> Call_forest.to_account_updates_map ~f:(fun ~depth p -> Account_update.to_graphql_repr ~call_depth:depth p ) in let open Fields_derivers_zkapps.Derivers in @@ -1550,7 +1547,7 @@ let deriver obj = ~fee_payer:!.Account_update.Fee_payer.deriver ~account_updates:!.account_updates_deriver ~memo:!.Signed_command_memo.deriver - |> finish "Zkapp_command" ~t_toplevel_annots + |> finish "ZkappCommand" ~t_toplevel_annots let arg_typ () = Fields_derivers_zkapps.(arg_typ (deriver @@ Derivers.o ())) @@ -1596,8 +1593,8 @@ let valid_size ~(genesis_constants : Genesis_constants.t) t : unit Or_error.t = let events_elements events = List.fold events ~init:0 ~f:(fun acc event -> acc + Array.length event) in - let ( num_proof_zkapp_command - , num_zkapp_command + let ( num_proof_updates + , num_updates , num_event_elements , num_sequence_event_elements ) = Call_forest.fold t.account_updates ~init:(0, 0, 0, 0) @@ -1628,9 +1625,9 @@ let valid_size ~(genesis_constants : Genesis_constants.t) t : unit Or_error.t = genesis_constants.max_sequence_event_elements in let valid_proof_zkapp_command = - num_proof_zkapp_command <= max_proof_zkapp_command + num_proof_updates <= max_proof_zkapp_command in - let valid_zkapp_command = num_zkapp_command <= max_zkapp_command in + let valid_zkapp_command = num_updates <= max_zkapp_command in let valid_event_elements = num_event_elements <= max_event_elements in let valid_sequence_event_elements = num_sequence_event_elements <= max_sequence_event_elements @@ -1645,14 +1642,14 @@ let valid_size ~(genesis_constants : Genesis_constants.t) t : unit Or_error.t = else Some (sprintf "too many proof zkapp_command (%d, max allowed is %d)" - num_proof_zkapp_command max_proof_zkapp_command ) + num_proof_updates max_proof_zkapp_command ) in let zkapp_command_err = if valid_zkapp_command then None else Some - (sprintf "too many zkapp_command (%d, max allowed is %d)" - num_zkapp_command max_zkapp_command ) + (sprintf "too many zkapp_command (%d, max allowed is %d)" num_updates + max_zkapp_command ) in let events_err = if valid_event_elements then None diff --git a/src/lib/mina_graphql/mina_graphql.ml b/src/lib/mina_graphql/mina_graphql.ml index 5bd2d9e31a1..9ad474a086f 100644 --- a/src/lib/mina_graphql/mina_graphql.ml +++ b/src/lib/mina_graphql/mina_graphql.ml @@ -2370,7 +2370,7 @@ module Types = struct type input = Mina_base.Zkapp_command.t let arg_typ = - scalar "SendTestZkappInput" ~doc:"Zkapp_command for a test zkApp" + scalar "SendTestZkappInput" ~doc:"zkApp command for a test zkApp" ~coerce:(fun json -> let json = to_yojson json in Result.try_with (fun () -> Mina_base.Zkapp_command.of_json json) @@ -2732,8 +2732,8 @@ module Types = struct obj "SendZkappInput" ~coerce:Fn.id ~split:(fun f (x : input) -> f x) ~fields: - [ arg "zkapp_command" - ~doc:"Zkapp_command structure representing the transaction" + [ arg "zkappCommand" + ~doc:"zkApp command structure representing the transaction" ~typ:arg_typ ] end @@ -3658,7 +3658,7 @@ module Mutations = struct ~doc:"Send a zkApp (for internal testing purposes)" ~args: Arg. - [ arg "zkapp_command" + [ arg "zkappCommand" ~typ:(non_null Types.Input.SendTestZkappInput.arg_typ) ] ~typ:(non_null Types.Payload.send_zkapp) diff --git a/src/lib/snarky_js_bindings/snarkyjs b/src/lib/snarky_js_bindings/snarkyjs index 1afdcb46cb4..845c66e4e73 160000 --- a/src/lib/snarky_js_bindings/snarkyjs +++ b/src/lib/snarky_js_bindings/snarkyjs @@ -1 +1 @@ -Subproject commit 1afdcb46cb4d532caef8e233428441cb05140257 +Subproject commit 845c66e4e73cc46fac9528f55485f1fcb71ba6c6 From fdb27154e3b77ea12efcbbac28ae26e46a868269 Mon Sep 17 00:00:00 2001 From: Paul Steckler Date: Fri, 9 Sep 2022 10:54:03 -0700 Subject: [PATCH 091/144] fix snarkyjs commit --- src/lib/snarky_js_bindings/snarkyjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/snarky_js_bindings/snarkyjs b/src/lib/snarky_js_bindings/snarkyjs index 845c66e4e73..1afdcb46cb4 160000 --- a/src/lib/snarky_js_bindings/snarkyjs +++ b/src/lib/snarky_js_bindings/snarkyjs @@ -1 +1 @@ -Subproject commit 845c66e4e73cc46fac9528f55485f1fcb71ba6c6 +Subproject commit 1afdcb46cb4d532caef8e233428441cb05140257 From 8d6c0c87ace09938a69ea8cfaf9797e2484543bc Mon Sep 17 00:00:00 2001 From: Paul Steckler Date: Fri, 9 Sep 2022 10:57:32 -0700 Subject: [PATCH 092/144] fix client SDK build --- src/app/client_sdk/client_sdk.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/client_sdk/client_sdk.ml b/src/app/client_sdk/client_sdk.ml index 08d02b7c1f8..21d193b9339 100644 --- a/src/app/client_sdk/client_sdk.ml +++ b/src/app/client_sdk/client_sdk.ml @@ -44,7 +44,7 @@ let _ = Zkapp_command.account_updates_of_json account_updates_json in let account_updates = - Zkapp_command.Call_forest.of_zkapp_command_list + Zkapp_command.Call_forest.of_account_updates ~account_update_depth:(fun (p : Account_update.Graphql_repr.t) -> p.body.call_depth ) account_updates From 9a850735a9f1d1532cdb70c79b1609ce4e3c79c6 Mon Sep 17 00:00:00 2001 From: georgeee Date: Fri, 9 Sep 2022 20:08:02 +0200 Subject: [PATCH 093/144] Update mina-local-network script --- .../mina-local-network/mina-local-network.sh | 24 ++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/scripts/mina-local-network/mina-local-network.sh b/scripts/mina-local-network/mina-local-network.sh index 400ac759d86..63d0b76f03c 100755 --- a/scripts/mina-local-network/mina-local-network.sh +++ b/scripts/mina-local-network/mina-local-network.sh @@ -14,6 +14,7 @@ ARCHIVE_EXE=_build/default/src/app/archive/archive.exe LOGPROC_EXE=_build/default/src/app/logproc/logproc.exe export MINA_PRIVKEY_PASS='naughty blue worm' +export MINA_LIBP2P_PASS="${MINA_PRIVKEY_PASS}" SEED_PEER_KEY="CAESQNf7ldToowe604aFXdZ76GqW/XVlDmnXmBT+otorvIekBmBaDWu/6ZwYkZzqfr+3IrEh6FLbHQ3VSmubV9I9Kpc=,CAESIAZgWg1rv+mcGJGc6n6/tyKxIehS2x0N1Uprm1fSPSqX,12D3KooWAFFq2yEQFFzhU5dt64AWqawRuomG9hL8rSmm5vxhAsgr" # ================================================ @@ -123,6 +124,10 @@ generate-keypair() { ${MINA_EXE} advanced generate-keypair -privkey-path ${1} } +generate-libp2p-keypair() { + ${MINA_EXE} libp2p generate-keypair -privkey-path ${1} +} + # Executes the Mina Daemon, exposing all 5 ports in # sequence starting with provided base port exec-daemon() { @@ -351,16 +356,24 @@ if [ ! -d "${LEDGER_FOLDER}" ]; then clean-dir ${LEDGER_FOLDER}/offline_fish_keys clean-dir ${LEDGER_FOLDER}/online_whale_keys clean-dir ${LEDGER_FOLDER}/online_fish_keys + clean-dir ${LEDGER_FOLDER}/libp2p_keys clean-dir ${LEDGER_FOLDER}/service-keys generate-keypair ${LEDGER_FOLDER}/snark_worker_keys/snark_worker_account for ((i = 0; i < ${FISH}; i++)); do generate-keypair ${LEDGER_FOLDER}/offline_fish_keys/offline_fish_account_${i} generate-keypair ${LEDGER_FOLDER}/online_fish_keys/online_fish_account_${i} + generate-libp2p-keypair ${LEDGER_FOLDER}/libp2p_keys/fish_${i} done for ((i = 0; i < ${WHALES}; i++)); do generate-keypair ${LEDGER_FOLDER}/offline_whale_keys/offline_whale_account_${i} generate-keypair ${LEDGER_FOLDER}/online_whale_keys/online_whale_account_${i} + generate-libp2p-keypair ${LEDGER_FOLDER}/libp2p_keys/whale_${i} + done + for ((i = 0; i < ${NODES}; i++)); do + generate-keypair ${LEDGER_FOLDER}/offline_whale_keys/offline_whale_account_${i} + generate-keypair ${LEDGER_FOLDER}/online_whale_keys/online_whale_account_${i} + generate-libp2p-keypair ${LEDGER_FOLDER}/libp2p_keys/node_${i} done if [ "$(uname)" != "Darwin" ] && [ ${FISH} -gt 0 ]; then @@ -372,6 +385,7 @@ if [ ! -d "${LEDGER_FOLDER}" ]; then sudo chown -R ${USER} ${LEDGER_FOLDER}/online_fish_keys sudo chown -R ${USER} ${LEDGER_FOLDER}/offline_whale_keys sudo chown -R ${USER} ${LEDGER_FOLDER}/online_whale_keys + sudo chown -R ${USER} ${LEDGER_FOLDER}/libp2p_keys fi fi @@ -379,6 +393,7 @@ if [ ! -d "${LEDGER_FOLDER}" ]; then chmod -R 0700 ${LEDGER_FOLDER}/online_fish_keys chmod -R 0700 ${LEDGER_FOLDER}/offline_whale_keys chmod -R 0700 ${LEDGER_FOLDER}/online_whale_keys + chmod -R 0700 ${LEDGER_FOLDER}/libp2p_keys python3 scripts/mina-local-network/generate-mina-local-network-ledger.py \ --num-whale-accounts ${WHALES} \ @@ -454,7 +469,8 @@ for ((i = 0; i < ${WHALES}; i++)); do FOLDER=${NODES_FOLDER}/whale_${i} KEY_FILE=${LEDGER_FOLDER}/online_whale_keys/online_whale_account_${i} mkdir -p ${FOLDER} - spawn-node ${FOLDER} $((${WHALE_START_PORT} + (${i} * 5))) -peer ${SEED_PEER_ID} -block-producer-key ${KEY_FILE} ${SNARK_WORKER_FLAGS} ${ARCHIVE_ADDRESS_CLI_ARG} + spawn-node ${FOLDER} $((${WHALE_START_PORT} + (${i} * 5))) -peer ${SEED_PEER_ID} -block-producer-key ${KEY_FILE} \ + -libp2p-keypair ${LEDGER_FOLDER}/libp2p_keys/whale_${i} ${SNARK_WORKER_FLAGS} ${ARCHIVE_ADDRESS_CLI_ARG} WHALE_PIDS[${i}]=$! done @@ -464,7 +480,8 @@ for ((i = 0; i < ${FISH}; i++)); do FOLDER=${NODES_FOLDER}/fish_${i} KEY_FILE=${LEDGER_FOLDER}/online_fish_keys/online_fish_account_${i} mkdir -p ${FOLDER} - spawn-node ${FOLDER} $((${FISH_START_PORT} + (${i} * 5))) -peer ${SEED_PEER_ID} -block-producer-key ${KEY_FILE} ${SNARK_WORKER_FLAGS} ${ARCHIVE_ADDRESS_CLI_ARG} + spawn-node ${FOLDER} $((${FISH_START_PORT} + (${i} * 5))) -peer ${SEED_PEER_ID} -block-producer-key ${KEY_FILE} \ + -libp2p-keypair ${LEDGER_FOLDER}/libp2p_keys/fish_${i} ${SNARK_WORKER_FLAGS} ${ARCHIVE_ADDRESS_CLI_ARG} FISH_PIDS[${i}]=$! done @@ -473,7 +490,8 @@ done for ((i = 0; i < ${NODES}; i++)); do FOLDER=${NODES_FOLDER}/node_${i} mkdir -p ${FOLDER} - spawn-node ${FOLDER} $((${NODE_START_PORT} + (${i} * 5))) -peer ${SEED_PEER_ID} ${ARCHIVE_ADDRESS_CLI_ARG} + spawn-node ${FOLDER} $((${NODE_START_PORT} + (${i} * 5))) -peer ${SEED_PEER_ID} \ + -libp2p-keypair ${LEDGER_FOLDER}/libp2p_keys/node_${i} ${ARCHIVE_ADDRESS_CLI_ARG} NODE_PIDS[${i}]=$! done From 067a72695a10de144da3983274f11ca4aa600ac2 Mon Sep 17 00:00:00 2001 From: Paul Steckler Date: Fri, 9 Sep 2022 14:46:53 -0700 Subject: [PATCH 094/144] GraphQL cleanup --- graphql_schema.json | 60 +++++++++---------- src/lib/generated_graphql_queries/gen/gen.ml | 23 +++---- src/lib/mina_base/account_update.ml | 4 +- .../zkapp_command_generators.ml | 2 +- src/lib/mina_graphql/mina_graphql.ml | 10 ++-- src/lib/network_pool/indexed_pool.ml | 2 +- .../transaction_snark/transaction_snark.ml | 2 +- 7 files changed, 52 insertions(+), 51 deletions(-) diff --git a/graphql_schema.json b/graphql_schema.json index edef1a9fa76..0fd3ea86041 100644 --- a/graphql_schema.json +++ b/graphql_schema.json @@ -667,7 +667,7 @@ { "kind": "SCALAR", "name": "SendTestZkappInput", - "description": "Zkapp_command for a test zkApp", + "description": "zkApp command for a test zkApp", "fields": null, "inputFields": null, "interfaces": null, @@ -676,7 +676,7 @@ }, { "kind": "INPUT_OBJECT", - "name": "FeePayerAccountUpdateBodyInput", + "name": "FeePayerBodyInput", "description": null, "fields": [ { @@ -784,7 +784,7 @@ }, { "kind": "INPUT_OBJECT", - "name": "ZkappAccountUpdateFeePayerInput", + "name": "ZkappFeePayerInput", "description": null, "fields": [ { @@ -796,7 +796,7 @@ "name": null, "ofType": { "kind": "INPUT_OBJECT", - "name": "FeePayerAccountUpdateBodyInput", + "name": "FeePayerBodyInput", "ofType": null } }, @@ -829,7 +829,7 @@ "name": null, "ofType": { "kind": "INPUT_OBJECT", - "name": "FeePayerAccountUpdateBodyInput", + "name": "FeePayerBodyInput", "ofType": null } }, @@ -1432,7 +1432,7 @@ }, { "kind": "INPUT_OBJECT", - "name": "AccountUpdateUpdateInput", + "name": "AccountUpdateModificationInput", "description": null, "fields": [ { @@ -2784,7 +2784,7 @@ "name": null, "ofType": { "kind": "INPUT_OBJECT", - "name": "AccountUpdateUpdateInput", + "name": "AccountUpdateModificationInput", "ofType": null } }, @@ -3001,7 +3001,7 @@ "name": null, "ofType": { "kind": "INPUT_OBJECT", - "name": "AccountUpdateUpdateInput", + "name": "AccountUpdateModificationInput", "ofType": null } }, @@ -3296,7 +3296,7 @@ }, { "kind": "INPUT_OBJECT", - "name": "Zkapp_commandInput", + "name": "ZkappCommandInput", "description": null, "fields": [ { @@ -3308,7 +3308,7 @@ "name": null, "ofType": { "kind": "INPUT_OBJECT", - "name": "ZkappAccountUpdateFeePayerInput", + "name": "ZkappFeePayerInput", "ofType": null } }, @@ -3365,7 +3365,7 @@ "name": null, "ofType": { "kind": "INPUT_OBJECT", - "name": "ZkappAccountUpdateFeePayerInput", + "name": "ZkappFeePayerInput", "ofType": null } }, @@ -3418,16 +3418,16 @@ "description": null, "fields": [ { - "name": "zkapp_command", + "name": "zkappCommand", "description": - "Zkapp_command structure representing the transaction", + "zkApp command structure representing the transaction", "args": [], "type": { "kind": "NON_NULL", "name": null, "ofType": { "kind": "INPUT_OBJECT", - "name": "Zkapp_commandInput", + "name": "ZkappCommandInput", "ofType": null } }, @@ -3437,15 +3437,15 @@ ], "inputFields": [ { - "name": "zkapp_command", + "name": "zkappCommand", "description": - "Zkapp_command structure representing the transaction", + "zkApp command structure representing the transaction", "type": { "kind": "NON_NULL", "name": null, "ofType": { "kind": "INPUT_OBJECT", - "name": "Zkapp_commandInput", + "name": "ZkappCommandInput", "ofType": null } }, @@ -3470,7 +3470,7 @@ "name": null, "ofType": { "kind": "OBJECT", - "name": "ZkappCommand", + "name": "ZkappCommandResult", "ofType": null } }, @@ -4808,7 +4808,7 @@ "description": "Send a zkApp (for internal testing purposes)", "args": [ { - "name": "zkapp_command", + "name": "zkappCommand", "description": null, "type": { "kind": "NON_NULL", @@ -7661,7 +7661,7 @@ }, { "kind": "OBJECT", - "name": "AccountUpdateUpdate", + "name": "AccountUpdateModification", "description": null, "fields": [ { @@ -7808,7 +7808,7 @@ "name": null, "ofType": { "kind": "OBJECT", - "name": "AccountUpdateUpdate", + "name": "AccountUpdateModification", "ofType": null } }, @@ -8048,7 +8048,7 @@ }, { "kind": "OBJECT", - "name": "FeePayerAccountUpdateBody", + "name": "FeePayerBody", "description": null, "fields": [ { @@ -8111,7 +8111,7 @@ }, { "kind": "OBJECT", - "name": "ZkappAccountUpdateFeePayer", + "name": "ZkappFeePayer", "description": null, "fields": [ { @@ -8123,7 +8123,7 @@ "name": null, "ofType": { "kind": "OBJECT", - "name": "FeePayerAccountUpdateBody", + "name": "FeePayerBody", "ofType": null } }, @@ -8154,7 +8154,7 @@ }, { "kind": "OBJECT", - "name": "Zkapp_command", + "name": "ZkappCommand", "description": null, "fields": [ { @@ -8166,7 +8166,7 @@ "name": null, "ofType": { "kind": "OBJECT", - "name": "ZkappAccountUpdateFeePayer", + "name": "ZkappFeePayer", "ofType": null } }, @@ -8231,7 +8231,7 @@ }, { "kind": "OBJECT", - "name": "ZkappCommand", + "name": "ZkappCommandResult", "description": null, "fields": [ { @@ -8275,7 +8275,7 @@ "name": null, "ofType": { "kind": "OBJECT", - "name": "Zkapp_command", + "name": "ZkappCommand", "ofType": null } }, @@ -9354,7 +9354,7 @@ "name": null, "ofType": { "kind": "OBJECT", - "name": "ZkappCommand", + "name": "ZkappCommandResult", "ofType": null } } @@ -13565,7 +13565,7 @@ "name": null, "ofType": { "kind": "OBJECT", - "name": "ZkappCommand", + "name": "ZkappCommandResult", "ofType": null } } diff --git a/src/lib/generated_graphql_queries/gen/gen.ml b/src/lib/generated_graphql_queries/gen/gen.ml index 689a247a846..2430298c75f 100644 --- a/src/lib/generated_graphql_queries/gen/gen.ml +++ b/src/lib/generated_graphql_queries/gen/gen.ml @@ -3,25 +3,25 @@ open Core_kernel module Zkapp_command_templates = struct let pooled_zkapp_commands = - Printf.sprintf + sprintf {graphql| query zkapp_commands($public_key: PublicKey) { pooledZkappCommands(publicKey: $public_key) { id hash failureReason { - index - failures - } + index + failures + } zkappCommand %s } }|graphql} let internal_send_zkapp = - Printf.sprintf - {| + sprintf + {graphql| mutation ($zkapp_command: SendTestZkappInput!) { - internalSendZkapp(zkapp_command: $zkapp_command) { + internalSendZkapp(zkappCommand: $zkapp_command) { zkapp { id hash failureReason { @@ -32,7 +32,7 @@ module Zkapp_command_templates = struct } } } - |} + |graphql} end let account_update_query_expr template ~loc = @@ -62,8 +62,9 @@ let structure ~loc = |> List.map ~f:E.pstr_module let main () = - Out_channel.with_file "generated_graphql_queries.ml" ~f:(fun ml_file -> - let fmt = Format.formatter_of_out_channel ml_file in - Pprintast.top_phrase fmt (Ptop_def (structure ~loc:Ppxlib.Location.none)) ) + Out_channel.with_file "generated_graphql_queries.ml" ~f:(fun oc -> + let fmt = Format.formatter_of_out_channel oc in + Pprintast.toplevel_phrase fmt + (Ptop_def (structure ~loc:Ppxlib.Location.none)) ) let () = main () diff --git a/src/lib/mina_base/account_update.ml b/src/lib/mina_base/account_update.ml index a941e3b1e2b..7148e0badef 100644 --- a/src/lib/mina_base/account_update.ml +++ b/src/lib/mina_base/account_update.ml @@ -1002,7 +1002,7 @@ module Body = struct !.Fields_derivers_zkapps.Derivers.( option ~js_type:`Or_undefined @@ uint32 @@ o ()) ~nonce:!.uint32 - |> finish "FeePayerAccountUpdateBody" ~t_toplevel_annots + |> finish "FeePayerBody" ~t_toplevel_annots let%test_unit "json roundtrip" = let open Fields_derivers_zkapps.Derivers in @@ -1373,7 +1373,7 @@ module Fee_payer = struct let quickcheck_generator : t Quickcheck.Generator.t = gen - let quickcheck_obserber : t Quickcheck.Observer.t = + let quickcheck_observer : t Quickcheck.Observer.t = Quickcheck.Observer.of_hash (module Stable.Latest) let quickcheck_shrinker : t Quickcheck.Shrinker.t = diff --git a/src/lib/mina_generators/zkapp_command_generators.ml b/src/lib/mina_generators/zkapp_command_generators.ml index 6f2c36862fe..cf0e2668c6a 100644 --- a/src/lib/mina_generators/zkapp_command_generators.ml +++ b/src/lib/mina_generators/zkapp_command_generators.ml @@ -1406,7 +1406,7 @@ let gen_zkapp_command_from ?failure ?(max_account_updates = max_account_updates) in ({ account with receipt_chain_hash }, `Fee_payer) ) ; let account_updates = - Zkapp_command.Call_forest.to_zkapp_command_list + Zkapp_command.Call_forest.to_account_updates zkapp_command_dummy_authorizations.account_updates in List.iteri account_updates ~f:(fun ndx account_update -> diff --git a/src/lib/mina_graphql/mina_graphql.ml b/src/lib/mina_graphql/mina_graphql.ml index 9ad474a086f..c2a3766e62d 100644 --- a/src/lib/mina_graphql/mina_graphql.ml +++ b/src/lib/mina_graphql/mina_graphql.ml @@ -1734,7 +1734,7 @@ module Types = struct : (Mina_lib.t, Zkapp_command.t) typ = Obj.magic x in - obj "ZkappCommand" ~fields:(fun _ -> + obj "ZkappCommandResult" ~fields:(fun _ -> [ field_no_status "id" ~doc:"A Base58Check string representing the command" ~typ: @@ -4317,13 +4317,13 @@ module Queries = struct let deserialize_txn serialized_txn = let res = match serialized_txn with - | `Signed_command x -> + | `Signed_command cmd -> Or_error.( - Signed_command.of_base58_check x + Signed_command.of_base58_check cmd >>| fun c -> User_command.Signed_command c) - | `Zkapp_command ps -> + | `Zkapp_command cmd -> Or_error.( - Zkapp_command.of_base58_check ps + Zkapp_command.of_base58_check cmd >>| fun c -> User_command.Zkapp_command c) in result_of_or_error res ~error:"Invalid transaction provided" diff --git a/src/lib/network_pool/indexed_pool.ml b/src/lib/network_pool/indexed_pool.ml index 7a3f00c1948..02823ec28eb 100644 --- a/src/lib/network_pool/indexed_pool.ml +++ b/src/lib/network_pool/indexed_pool.ml @@ -1931,7 +1931,7 @@ let%test_module _ = ; authorization = Signature.dummy } ; account_updates = - Zkapp_command.Call_forest.of_zkapp_command_list + Zkapp_command.Call_forest.of_account_updates ~account_update_depth:(Fn.const 0) [ { Account_update.Wire.body = { public_key = sender_pk diff --git a/src/lib/transaction_snark/transaction_snark.ml b/src/lib/transaction_snark/transaction_snark.ml index 891ba07c68d..273fd1cc4dc 100644 --- a/src/lib/transaction_snark/transaction_snark.ml +++ b/src/lib/transaction_snark/transaction_snark.ml @@ -4730,7 +4730,7 @@ module For_tests = struct |> Zkapp_command.Call_forest.With_hashes_and_data .of_zkapp_command_simple_list |> Zkapp_statement.zkapp_statements_of_forest - |> Zkapp_command.Call_forest.to_zkapp_command_list + |> Zkapp_command.Call_forest.to_account_updates in let snapp_zkapp_command_keypairs = List.zip_exn snapp_zkapp_command spec.zkapp_account_keypairs From 00b68352862b4f474629b9a3ab0c2a61f465f1d1 Mon Sep 17 00:00:00 2001 From: Paul Steckler Date: Fri, 9 Sep 2022 15:08:14 -0700 Subject: [PATCH 095/144] Rename fixes --- src/lib/snarky_js_bindings/lib/snarky_js_bindings_lib.ml | 4 ++-- .../test/multisig_account/multisig_account.ml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib/snarky_js_bindings/lib/snarky_js_bindings_lib.ml b/src/lib/snarky_js_bindings/lib/snarky_js_bindings_lib.ml index a506c2db08b..084c526f191 100644 --- a/src/lib/snarky_js_bindings/lib/snarky_js_bindings_lib.ml +++ b/src/lib/snarky_js_bindings/lib/snarky_js_bindings_lib.ml @@ -2675,7 +2675,7 @@ module Ledger = struct true | Other_account_update i -> (List.nth_exn - (Zkapp_command.Call_forest.to_zkapp_command_list account_updates) + (Zkapp_command.Call_forest.to_account_updates account_updates) i ) .body .use_full_commitment @@ -2786,7 +2786,7 @@ module Ledger = struct check_signature "fee payer" fee_payer.authorization fee_payer.body.public_key full_tx_commitment ; - List.iteri (Zkapp_command.Call_forest.to_zkapp_command_list account_updates) + List.iteri (Zkapp_command.Call_forest.to_account_updates account_updates) ~f:(fun i p -> let commitment = if p.body.use_full_commitment then full_tx_commitment diff --git a/src/lib/transaction_snark/test/multisig_account/multisig_account.ml b/src/lib/transaction_snark/test/multisig_account/multisig_account.ml index 7e454477674..441d56429ea 100644 --- a/src/lib/transaction_snark/test/multisig_account/multisig_account.ml +++ b/src/lib/transaction_snark/test/multisig_account/multisig_account.ml @@ -372,7 +372,7 @@ let%test_module "multisig_account" = in let memo = Signed_command_memo.empty in let ps = - Zkapp_command.Call_forest.of_zkapp_command_list + Zkapp_command.Call_forest.of_account_updates ~account_update_depth:(fun (p : Account_update.Simple.t) -> p.body.call_depth ) [ sender_account_update_data; snapp_account_update_data ] From 104578b1fc684a3695ea969b69a7affd88b2d371 Mon Sep 17 00:00:00 2001 From: Paul Steckler Date: Fri, 9 Sep 2022 15:36:22 -0700 Subject: [PATCH 096/144] fix arg name --- src/app/zkapp_test_transaction/lib/commands.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/zkapp_test_transaction/lib/commands.ml b/src/app/zkapp_test_transaction/lib/commands.ml index 9ad17896848..645106ce302 100644 --- a/src/app/zkapp_test_transaction/lib/commands.ml +++ b/src/app/zkapp_test_transaction/lib/commands.ml @@ -14,7 +14,7 @@ let graphql_zkapp_command (zkapp_command : Zkapp_command.t) = {| mutation MyMutation { __typename - sendZkapp(input: { zkapp_command: %s }) + sendZkapp(input: { zkappCommand: %s }) } |} (Zkapp_command.arg_query_string zkapp_command) From 17b9f6ae3e5e4e4e5df21e8806c44368277b89d8 Mon Sep 17 00:00:00 2001 From: Paul Steckler Date: Fri, 9 Sep 2022 17:15:23 -0700 Subject: [PATCH 097/144] Look for reload from given node --- graphql_schema.json | 4 +- .../test_executive/peers_reliability_test.ml | 15 +- .../kubernetes_network.ml | 4 +- src/lib/integration_test_lib/dune | 1 + src/lib/integration_test_lib/intf.ml | 2 +- .../integration_test_lib/wait_condition.ml | 19 +- src/lib/mina_graphql/mina_graphql.ml | 388 +++++++++--------- .../transition_frontier.ml | 6 +- 8 files changed, 228 insertions(+), 211 deletions(-) diff --git a/graphql_schema.json b/graphql_schema.json index b97af2ffc0a..1998f30b811 100644 --- a/graphql_schema.json +++ b/graphql_schema.json @@ -10215,7 +10215,7 @@ { "name": "consensusState", "description": - "State specific to the Codaboros Proof of Stake consensus algorithm", + "State specific to the minaboros Proof of Stake consensus algorithm", "args": [], "type": { "kind": "NON_NULL", @@ -13151,7 +13151,7 @@ { "name": "token", "description": - "Token of account being retrieved (defaults to CODA)", + "Token of account being retrieved (defaults to MINA)", "type": { "kind": "SCALAR", "name": "TokenId", diff --git a/src/app/test_executive/peers_reliability_test.ml b/src/app/test_executive/peers_reliability_test.ml index a5b5ae19c5c..ce6db360ff3 100644 --- a/src/app/test_executive/peers_reliability_test.ml +++ b/src/app/test_executive/peers_reliability_test.ml @@ -153,8 +153,21 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct "%s started again, will now wait for this node to initialize" (Node.id node_c) ; let%bind () = wait_for t @@ Wait_condition.node_to_initialize node_c in + (* if frontier load events from the other nodes, which would be generated + on initialization, that will cause a failure here + + earlier testing did not detect such events on initialization + + if we never see such events, using the node is sufficient to identify + that the event is triggered by the restart of node_c + + a more exacting alternative would be to issue an event on frontier closing, and capture + its snarked ledger hash, and compare that when the load event occurs; but the wait + mechanism does not appear to allow returning data in the event, like such a hash; + it could be added + *) let%bind () = - wait_for t @@ Wait_condition.persisted_frontier_loaded () + wait_for t @@ Wait_condition.persisted_frontier_loaded node_c in wait_for t ( Wait_condition.nodes_to_synchronize [ node_a; node_b; node_c ] diff --git a/src/lib/integration_test_cloud_engine/kubernetes_network.ml b/src/lib/integration_test_cloud_engine/kubernetes_network.ml index 4773d9ecec8..8f37a01ebc6 100644 --- a/src/lib/integration_test_cloud_engine/kubernetes_network.ml +++ b/src/lib/integration_test_cloud_engine/kubernetes_network.ml @@ -95,9 +95,9 @@ module Node = struct module Graphql = struct let ingress_uri node = let host = - Printf.sprintf "%s.graphql.test.o1test.net" node.config.testnet_name + sprintf "%s.graphql.test.o1test.net" node.config.testnet_name in - let path = Printf.sprintf "/%s/graphql" node.app_id in + let path = sprintf "/%s/graphql" node.app_id in Uri.make ~scheme:"http" ~host ~path ~port:80 () module Client = Graphql_lib.Client.Make (struct diff --git a/src/lib/integration_test_lib/dune b/src/lib/integration_test_lib/dune index 39ff494d04f..d9d1ff5f219 100644 --- a/src/lib/integration_test_lib/dune +++ b/src/lib/integration_test_lib/dune @@ -34,6 +34,7 @@ transition_frontier coda_runtime_config mina_base + mina_lib genesis_constants transition_router signature_lib diff --git a/src/lib/integration_test_lib/intf.ml b/src/lib/integration_test_lib/intf.ml index cbb2fbc8478..d8aa41bdf3e 100644 --- a/src/lib/integration_test_lib/intf.ml +++ b/src/lib/integration_test_lib/intf.ml @@ -385,7 +385,7 @@ module Dsl = struct val zkapp_to_be_included_in_frontier : has_failures:bool -> parties:Mina_base.Parties.t -> t - val persisted_frontier_loaded : unit -> t + val persisted_frontier_loaded : Engine.Network.Node.t -> t end module type Util_intf = sig diff --git a/src/lib/integration_test_lib/wait_condition.ml b/src/lib/integration_test_lib/wait_condition.ml index 792d6901cd8..1464d0f3ea8 100644 --- a/src/lib/integration_test_lib/wait_condition.ml +++ b/src/lib/integration_test_lib/wait_condition.ml @@ -265,15 +265,22 @@ struct ; hard_timeout = Slots (soft_timeout_in_slots * 2) } - let persisted_frontier_loaded () = - let check () _node + let persisted_frontier_loaded node = + let check () event_node (_frontier_loaded : Event_type.Persisted_frontier_loaded.t) = - (* the fact of loading is sufficient, nothing else to check *) - Predicate_passed + let event_node_id = Node.id event_node in + let node_id = Node.id node in + if String.equal event_node_id node_id then Predicate_passed + else + Predicate_failure + (Error.of_string + (sprintf + "Expected to load frontier for node %s, but got frontier for %s" + node_id event_node_id ) ) in - let soft_timeout_in_slots = 8 in + let soft_timeout_in_slots = 4 in { id = Persisted_frontier_loaded - ; description = "persisted transition frontier to load" + ; description = "persisted transition frontier loaded" ; predicate = Event_predicate (Event_type.Persisted_frontier_loaded, (), check) ; soft_timeout = Slots soft_timeout_in_slots diff --git a/src/lib/mina_graphql/mina_graphql.ml b/src/lib/mina_graphql/mina_graphql.ml index c781b657651..7046a4fb818 100644 --- a/src/lib/mina_graphql/mina_graphql.ml +++ b/src/lib/mina_graphql/mina_graphql.ml @@ -162,8 +162,8 @@ module Reflection = struct end end -let get_ledger_and_breadcrumb coda = - coda |> Mina_lib.best_tip |> Participating_state.active +let get_ledger_and_breadcrumb mina = + mina |> Mina_lib.best_tip |> Participating_state.active |> Option.map ~f:(fun tip -> ( Transition_frontier.Breadcrumb.staged_ledger tip |> Staged_ledger.ledger @@ -262,16 +262,16 @@ module Types = struct C.to_global_slot global_slot ) ; field "startTime" ~typ:(non_null block_time) ~args:Arg.[] - ~resolve:(fun { ctx = coda; _ } global_slot -> + ~resolve:(fun { ctx = mina; _ } global_slot -> let constants = - (Mina_lib.config coda).precomputed_values.consensus_constants + (Mina_lib.config mina).precomputed_values.consensus_constants in C.start_time ~constants global_slot ) ; field "endTime" ~typ:(non_null block_time) ~args:Arg.[] - ~resolve:(fun { ctx = coda; _ } global_slot -> + ~resolve:(fun { ctx = mina; _ } global_slot -> let constants = - (Mina_lib.config coda).precomputed_values.consensus_constants + (Mina_lib.config mina).precomputed_values.consensus_constants in C.end_time ~constants global_slot ) ] ) @@ -303,12 +303,12 @@ module Types = struct ~typ:(non_null @@ list @@ non_null consensus_time) ~doc:"Next block production time" ~args:Arg.[] - ~resolve:(fun { ctx = coda; _ } + ~resolve:(fun { ctx = mina; _ } { Daemon_rpcs.Types.Status.Next_producer_timing.timing ; _ } -> let consensus_constants = - (Mina_lib.config coda).precomputed_values.consensus_constants + (Mina_lib.config mina).precomputed_values.consensus_constants in match timing with | Daemon_rpcs.Types.Status.Next_producer_timing.Check_again _ -> @@ -342,14 +342,14 @@ module Types = struct "Consensus time of the block that was used to determine the next \ block production time" ~args:Arg.[] - ~resolve:(fun { ctx = coda; _ } + ~resolve:(fun { ctx = mina; _ } { Daemon_rpcs.Types.Status.Next_producer_timing .generated_from_consensus_at = { slot; global_slot_since_genesis } ; _ } -> let consensus_constants = - (Mina_lib.config coda).precomputed_values.consensus_constants + (Mina_lib.config mina).precomputed_values.consensus_constants in ( Consensus.Data.Consensus_time.of_global_slot ~constants:consensus_constants slot @@ -674,13 +674,13 @@ module Types = struct time instead of genesis time." "utcDate" ) ~args:Arg.[] - ~resolve:(fun { ctx = coda; _ } t -> + ~resolve:(fun { ctx = mina; _ } t -> let blockchain_state, _ = t in let timestamp = Mina_state.Blockchain_state.timestamp blockchain_state in Block_time.to_system_time - (Mina_lib.time_controller coda) + (Mina_lib.time_controller mina) timestamp ) ; field "snarkedLedgerHash" ~typ:(non_null ledger_hash) ~doc:"Base58Check-encoded hash of the snarked ledger" @@ -716,11 +716,11 @@ module Types = struct and included into this block's proof. If there is no transition \ frontier available or no block found, this will return null." ~args:Arg.[] - ~resolve:(fun { ctx = coda; _ } t -> + ~resolve:(fun { ctx = mina; _ } t -> let open Option.Let_syntax in let _, hash = t in let%bind frontier = - Mina_lib.transition_frontier coda + Mina_lib.transition_frontier mina |> Pipe_lib.Broadcast_pipe.Reader.peek in match Transition_frontier.find frontier hash with @@ -762,7 +762,7 @@ module Types = struct (protocol_state.blockchain_state, state_hash) ) ; field "consensusState" ~doc: - "State specific to the Codaboros Proof of Stake consensus \ + "State specific to the minaboros Proof of Stake consensus \ algorithm" ~typ:(non_null @@ Consensus.Data.Consensus_state.graphql_type ()) ~args:Arg.[] @@ -781,15 +781,15 @@ module Types = struct [ field "accountCreationFee" ~typ:(non_null fee) ~doc:"The fee charged to create a new account" ~args:Arg.[] - ~resolve:(fun { ctx = coda; _ } () -> - (Mina_lib.config coda).precomputed_values.constraint_constants + ~resolve:(fun { ctx = mina; _ } () -> + (Mina_lib.config mina).precomputed_values.constraint_constants .account_creation_fee ) ; field "coinbase" ~typ:(non_null amount) ~doc: "The amount received as a coinbase reward for producing a block" ~args:Arg.[] - ~resolve:(fun { ctx = coda; _ } () -> - (Mina_lib.config coda).precomputed_values.constraint_constants + ~resolve:(fun { ctx = mina; _ } () -> + (Mina_lib.config mina).precomputed_values.constraint_constants .coinbase_amount ) ] ) @@ -964,9 +964,9 @@ module Types = struct ; zkapp_uri = Some zkapp_uri } - let of_account_id coda account_id = + let of_account_id mina account_id = let account = - coda |> Mina_lib.best_tip |> Participating_state.active + mina |> Mina_lib.best_tip |> Participating_state.active |> Option.bind ~f:(fun tip -> let ledger = Transition_frontier.Breadcrumb.staged_ledger tip @@ -1001,8 +1001,8 @@ module Types = struct ; zkapp_uri = None } - let of_pk coda pk = - of_account_id coda (Account_id.create pk Token_id.default) + let of_pk mina pk = + of_account_id mina (Account_id.create pk Token_id.default) end type t = @@ -1027,10 +1027,10 @@ module Types = struct ; index : Account.Index.t option } - let lift coda pk account = - let block_production_pubkeys = Mina_lib.block_production_pubkeys coda in - let accounts = Mina_lib.wallets coda in - let best_tip_ledger = Mina_lib.best_ledger coda in + let lift mina pk account = + let block_production_pubkeys = Mina_lib.block_production_pubkeys mina in + let accounts = Mina_lib.wallets mina in + let best_tip_ledger = Mina_lib.best_ledger mina in { account ; locked = Secrets.Wallets.check_locked accounts ~needle:pk ; is_actively_staking = @@ -1049,13 +1049,13 @@ module Types = struct None ) } - let get_best_ledger_account coda aid = - lift coda + let get_best_ledger_account mina aid = + lift mina (Account_id.public_key aid) - (Partial_account.of_account_id coda aid) + (Partial_account.of_account_id mina aid) - let get_best_ledger_account_pk coda pk = - lift coda pk (Partial_account.of_pk coda pk) + let get_best_ledger_account_pk mina pk = + lift mina pk (Partial_account.of_pk mina pk) let account_id { Account.Poly.public_key; token_id; _ } = Account_id.create public_key token_id @@ -1185,11 +1185,11 @@ module Types = struct transactions (transactions not yet included in a block) \ (stringified uint32)" ~args:Arg.[] - ~resolve:(fun { ctx = coda; _ } { account; _ } -> + ~resolve:(fun { ctx = mina; _ } { account; _ } -> let account_id = account_id account in match Mina_lib - .get_inferred_nonce_from_transaction_pool_and_ledger coda + .get_inferred_nonce_from_transaction_pool_and_ledger mina account_id with | `Active n -> @@ -1201,10 +1201,10 @@ module Types = struct "The account that you delegated on the staking ledger of \ the current block's epoch" ~args:Arg.[] - ~resolve:(fun { ctx = coda; _ } { account; _ } -> + ~resolve:(fun { ctx = mina; _ } { account; _ } -> let open Option.Let_syntax in let account_id = account_id account in - match%bind Mina_lib.staking_ledger coda with + match%bind Mina_lib.staking_ledger mina with | Genesis_epoch_ledger staking_ledger -> ( match let open Option.Let_syntax in @@ -1214,9 +1214,9 @@ module Types = struct with | Some delegate_account -> let delegate_key = delegate_account.public_key in - Some (get_best_ledger_account_pk coda delegate_key) + Some (get_best_ledger_account_pk mina delegate_key) | None -> - [%log' warn (Mina_lib.top_level_logger coda)] + [%log' warn (Mina_lib.top_level_logger mina)] "Could not retrieve delegate account from the \ genesis ledger. The account was not present in \ the ledger." ; @@ -1231,9 +1231,9 @@ module Types = struct Ledger.Db.get_at_index_exn staking_ledger index in let delegate_key = delegate_account.public_key in - Some (get_best_ledger_account_pk coda delegate_key) + Some (get_best_ledger_account_pk mina delegate_key) with e -> - [%log' warn (Mina_lib.top_level_logger coda)] + [%log' warn (Mina_lib.top_level_logger mina)] ~metadata:[ ("error", `String (Exn.to_string e)) ] "Could not retrieve delegate account from sparse \ ledger. The account may not be in the ledger: \ @@ -1257,9 +1257,9 @@ module Types = struct "The account to which you are delegating - if you are not \ delegating to anybody, this would return your public key" ~args:Arg.[] - ~resolve:(fun { ctx = coda; _ } { account; _ } -> + ~resolve:(fun { ctx = mina; _ } { account; _ } -> Option.map - ~f:(get_best_ledger_account_pk coda) + ~f:(get_best_ledger_account_pk mina) account.Account.Poly.delegate ) ; field "delegators" ~typ:(list @@ non_null @@ Lazy.force account) @@ -1268,13 +1268,13 @@ module Types = struct that the info is recorded in the last epoch so it might \ not be up to date with the current account status)" ~args:Arg.[] - ~resolve:(fun { ctx = coda; _ } { account; _ } -> + ~resolve:(fun { ctx = mina; _ } { account; _ } -> let open Option.Let_syntax in let pk = account.Account.Poly.public_key in let%map delegators = - Mina_lib.current_epoch_delegators coda ~pk + Mina_lib.current_epoch_delegators mina ~pk in - let best_tip_ledger = Mina_lib.best_ledger coda in + let best_tip_ledger = Mina_lib.best_ledger mina in List.map ~f:(fun a -> { account = Partial_account.of_full_account a @@ -1299,13 +1299,13 @@ module Types = struct before last epoch epoch so it might not be up to date with \ the current account status)" ~args:Arg.[] - ~resolve:(fun { ctx = coda; _ } { account; _ } -> + ~resolve:(fun { ctx = mina; _ } { account; _ } -> let open Option.Let_syntax in let pk = account.Account.Poly.public_key in let%map delegators = - Mina_lib.last_epoch_delegators coda ~pk + Mina_lib.last_epoch_delegators mina ~pk in - let best_tip_ledger = Mina_lib.best_ledger coda in + let best_tip_ledger = Mina_lib.best_ledger mina in List.map ~f:(fun a -> { account = Partial_account.of_full_account a @@ -1585,18 +1585,18 @@ module Types = struct |> Account.Nonce.to_int ) ; field_no_status "source" ~typ:(non_null AccountObj.account) ~args:[] ~doc:"Account that the command is sent from" - ~resolve:(fun { ctx = coda; _ } cmd -> - AccountObj.get_best_ledger_account coda + ~resolve:(fun { ctx = mina; _ } cmd -> + AccountObj.get_best_ledger_account mina (Signed_command.source cmd.With_hash.data) ) ; field_no_status "receiver" ~typ:(non_null AccountObj.account) ~args:[] ~doc:"Account that the command applies to" - ~resolve:(fun { ctx = coda; _ } cmd -> - AccountObj.get_best_ledger_account coda + ~resolve:(fun { ctx = mina; _ } cmd -> + AccountObj.get_best_ledger_account mina (Signed_command.receiver cmd.With_hash.data) ) ; field_no_status "feePayer" ~typ:(non_null AccountObj.account) ~args:[] ~doc:"Account that pays the fees for the command" - ~resolve:(fun { ctx = coda; _ } cmd -> - AccountObj.get_best_ledger_account coda + ~resolve:(fun { ctx = mina; _ } cmd -> + AccountObj.get_best_ledger_account mina (Signed_command.fee_payer cmd.With_hash.data) ) ; field_no_status "validUntil" ~typ:(non_null global_slot) ~args:[] ~doc: @@ -1653,8 +1653,8 @@ module Types = struct ; field_no_status "fromAccount" ~typ:(non_null AccountObj.account) ~args:[] ~doc:"Account of the sender" ~deprecated:(Deprecated (Some "use feePayer field instead")) - ~resolve:(fun { ctx = coda; _ } payment -> - AccountObj.get_best_ledger_account coda + ~resolve:(fun { ctx = mina; _ } payment -> + AccountObj.get_best_ledger_account mina @@ Signed_command.fee_payer payment.With_hash.data ) ; field_no_status "to" ~typ:(non_null public_key) ~args:[] ~doc:"Public key of the receiver" @@ -1665,8 +1665,8 @@ module Types = struct ~doc:"Account of the receiver" ~deprecated:(Deprecated (Some "use receiver field instead")) ~args:Arg.[] - ~resolve:(fun { ctx = coda; _ } cmd -> - AccountObj.get_best_ledger_account coda + ~resolve:(fun { ctx = mina; _ } cmd -> + AccountObj.get_best_ledger_account mina @@ Signed_command.receiver cmd.With_hash.data ) ; field "failureReason" ~typ:(Mina_base_unix.Graphql_scalars.TransactionStatusFailure.typ ()) @@ -1689,12 +1689,12 @@ module Types = struct let stake_delegation = obj "UserCommandDelegation" ~fields:(fun _ -> field_no_status "delegator" ~typ:(non_null AccountObj.account) - ~args:[] ~resolve:(fun { ctx = coda; _ } cmd -> - AccountObj.get_best_ledger_account coda + ~args:[] ~resolve:(fun { ctx = mina; _ } cmd -> + AccountObj.get_best_ledger_account mina (Signed_command.source cmd.With_hash.data) ) :: field_no_status "delegatee" ~typ:(non_null AccountObj.account) - ~args:[] ~resolve:(fun { ctx = coda; _ } cmd -> - AccountObj.get_best_ledger_account coda + ~args:[] ~resolve:(fun { ctx = mina; _ } cmd -> + AccountObj.get_best_ledger_account mina (Signed_command.receiver cmd.With_hash.data) ) :: user_command_shared_fields ) @@ -1821,9 +1821,9 @@ module Types = struct ; field "coinbaseReceiverAccount" ~typ:AccountObj.account ~doc:"Account to which the coinbase for this block was granted" ~args:Arg.[] - ~resolve:(fun { ctx = coda; _ } { coinbase_receiver; _ } -> + ~resolve:(fun { ctx = mina; _ } { coinbase_receiver; _ } -> Option.map - ~f:(AccountObj.get_best_ledger_account_pk coda) + ~f:(AccountObj.get_best_ledger_account_pk mina) coinbase_receiver ) ] ) @@ -1856,14 +1856,14 @@ module Types = struct ~typ:(non_null AccountObj.account) ~doc:"Account that produced this block" ~args:Arg.[] - ~resolve:(fun { ctx = coda; _ } { With_hash.data; _ } -> - AccountObj.get_best_ledger_account_pk coda data.creator ) + ~resolve:(fun { ctx = mina; _ } { With_hash.data; _ } -> + AccountObj.get_best_ledger_account_pk mina data.creator ) ; field "winnerAccount" ~typ:(non_null AccountObj.account) ~doc:"Account that won the slot (Delegator/Staker)" ~args:Arg.[] - ~resolve:(fun { ctx = coda; _ } { With_hash.data; _ } -> - AccountObj.get_best_ledger_account_pk coda data.winner ) + ~resolve:(fun { ctx = mina; _ } { With_hash.data; _ } -> + AccountObj.get_best_ledger_account_pk mina data.winner ) ; field "stateHash" ~typ:(non_null state_hash) ~doc:"Base58Check-encoded hash of the state after this block" ~args:Arg.[] @@ -1910,8 +1910,8 @@ module Types = struct ~typ:(non_null AccountObj.account) ~doc:"Account of the current snark worker" ~args:Arg.[] - ~resolve:(fun { ctx = coda; _ } (key, _) -> - AccountObj.get_best_ledger_account_pk coda key ) + ~resolve:(fun { ctx = mina; _ } (key, _) -> + AccountObj.get_best_ledger_account_pk mina key ) ; field "fee" ~typ:(non_null fee) ~doc:"Fee that snark worker is charging to generate a snark proof" ~args:Arg.[] @@ -1944,8 +1944,8 @@ module Types = struct ~typ:(non_null AccountObj.account) ~doc:"Details of created account" ~args:Arg.[] - ~resolve:(fun { ctx = coda; _ } key -> - AccountObj.get_best_ledger_account_pk coda key ) + ~resolve:(fun { ctx = mina; _ } key -> + AccountObj.get_best_ledger_account_pk mina key ) ] ) let unlock_account : (Mina_lib.t, Account.key option) typ = @@ -1959,8 +1959,8 @@ module Types = struct ~typ:(non_null AccountObj.account) ~doc:"Details of unlocked account" ~args:Arg.[] - ~resolve:(fun { ctx = coda; _ } key -> - AccountObj.get_best_ledger_account_pk coda key ) + ~resolve:(fun { ctx = mina; _ } key -> + AccountObj.get_best_ledger_account_pk mina key ) ] ) let lock_account : (Mina_lib.t, Account.key option) typ = @@ -1973,8 +1973,8 @@ module Types = struct ~typ:(non_null AccountObj.account) ~doc:"Details of locked account" ~args:Arg.[] - ~resolve:(fun { ctx = coda; _ } key -> - AccountObj.get_best_ledger_account_pk coda key ) + ~resolve:(fun { ctx = mina; _ } key -> + AccountObj.get_best_ledger_account_pk mina key ) ] ) let delete_account = @@ -3108,8 +3108,8 @@ module Subscriptions = struct ~deprecated:NotDeprecated ~typ:(non_null Types.sync_status) ~args:Arg.[] - ~resolve:(fun { ctx = coda; _ } -> - Mina_lib.sync_status coda |> Mina_incremental.Status.to_pipe + ~resolve:(fun { ctx = mina; _ } -> + Mina_lib.sync_status mina |> Mina_incremental.Status.to_pipe |> Deferred.Result.return ) let new_block = @@ -3125,9 +3125,9 @@ module Subscriptions = struct [ arg "publicKey" ~doc:"Public key that is included in the block" ~typ:Types.Input.PublicKey.arg_typ ] - ~resolve:(fun { ctx = coda; _ } public_key -> + ~resolve:(fun { ctx = mina; _ } public_key -> Deferred.Result.return - @@ Mina_commands.Subscriptions.new_block coda public_key ) + @@ Mina_commands.Subscriptions.new_block mina public_key ) let chain_reorganization = subscription_field "chainReorganization" @@ -3136,9 +3136,9 @@ module Subscriptions = struct trivial extension of the existing one" ~typ:(non_null Types.chain_reorganization_status) ~args:Arg.[] - ~resolve:(fun { ctx = coda; _ } -> + ~resolve:(fun { ctx = mina; _ } -> Deferred.Result.return - @@ Mina_commands.Subscriptions.reorganization coda ) + @@ Mina_commands.Subscriptions.reorganization mina ) let commands = [ new_sync_update; new_block; chain_reorganization ] end @@ -3181,8 +3181,8 @@ module Mutations = struct Arg. [ arg "input" ~typ:(non_null Types.Input.CreateHDAccountInput.arg_typ) ] - ~resolve:(fun { ctx = coda; _ } () hd_index -> - Mina_lib.wallets coda |> Secrets.Wallets.create_hd_account ~hd_index ) + ~resolve:(fun { ctx = mina; _ } () hd_index -> + Mina_lib.wallets mina |> Secrets.Wallets.create_hd_account ~hd_index ) let unlock_account_resolver { ctx = t; _ } () (password, pk) = let password = lazy (return (Bytes.of_string password)) in @@ -3234,9 +3234,9 @@ module Mutations = struct ~args:Arg.[ arg "input" ~typ:(non_null Types.Input.LockInput.arg_typ) ] ~resolve:lock_account_resolver - let delete_account_resolver { ctx = coda; _ } () public_key = + let delete_account_resolver { ctx = mina; _ } () public_key = let open Deferred.Result.Let_syntax in - let wallets = Mina_lib.wallets coda in + let wallets = Mina_lib.wallets mina in let%map () = Deferred.Result.map_error ~f:(fun `Not_found -> "Could not find account with specified public key") @@ -3263,9 +3263,9 @@ module Mutations = struct [ arg "input" ~typ:(non_null Types.Input.DeleteAccountInput.arg_typ) ] ~resolve:delete_account_resolver - let reload_account_resolver { ctx = coda; _ } () = + let reload_account_resolver { ctx = mina; _ } () = let%map _ = - Secrets.Wallets.reload ~logger:(Logger.create ()) (Mina_lib.wallets coda) + Secrets.Wallets.reload ~logger:(Logger.create ()) (Mina_lib.wallets mina) in Ok true @@ -3296,7 +3296,7 @@ module Mutations = struct ; arg "password" ~doc:"Password for the account to import" ~typ:(non_null string) ] - ~resolve:(fun { ctx = coda; _ } () privkey_path password -> + ~resolve:(fun { ctx = mina; _ } () privkey_path password -> let open Deferred.Result.Let_syntax in (* the Keypair.read zeroes the password, so copy for use in import step below *) let saved_password = @@ -3310,7 +3310,7 @@ module Mutations = struct |> Deferred.Result.map_error ~f:Secrets.Privkey_error.to_string in let pk = Public_key.compress public_key in - let wallets = Mina_lib.wallets coda in + let wallets = Mina_lib.wallets mina in match Secrets.Wallets.check_locked wallets ~needle:pk with | Some _ -> return (pk, true) @@ -3330,17 +3330,17 @@ module Mutations = struct [ arg "input" ~typ:(non_null Types.Input.ResetTrustStatusInput.arg_typ) ] - ~resolve:(fun { ctx = coda; _ } () ip_address_input -> + ~resolve:(fun { ctx = mina; _ } () ip_address_input -> let open Deferred.Result.Let_syntax in let%map ip_address = Deferred.return @@ Types.Arguments.ip_address ~name:"ip_address" ip_address_input in - Some (Mina_commands.reset_trust_status coda ip_address) ) + Some (Mina_commands.reset_trust_status mina ip_address) ) - let send_user_command coda user_command_input = + let send_user_command mina user_command_input = match - Mina_commands.setup_and_submit_user_command coda user_command_input + Mina_commands.setup_and_submit_user_command mina user_command_input with | `Active f -> ( match%map f with @@ -3480,9 +3480,9 @@ module Mutations = struct | `Bootstrapping -> return (Error "Daemon is bootstrapping") - let find_identity ~public_key coda = + let find_identity ~public_key mina = Result.of_option - (Secrets.Wallets.find_identity (Mina_lib.wallets coda) ~needle:public_key) + (Secrets.Wallets.find_identity (Mina_lib.wallets mina) ~needle:public_key) ~error: "Couldn't find an unlocked key for specified `sender`. Did you unlock \ the account you're making a transaction from?" @@ -3530,26 +3530,26 @@ module Mutations = struct in user_command_input - let send_signed_user_command ~signature ~coda ~nonce_opt ~signer ~memo ~fee + let send_signed_user_command ~signature ~mina ~nonce_opt ~signer ~memo ~fee ~fee_payer_pk ~valid_until ~body = let open Deferred.Result.Let_syntax in let%bind user_command_input = make_signed_user_command ~signature ~nonce_opt ~signer ~memo ~fee ~fee_payer_pk ~valid_until ~body in - let%map cmd = send_user_command coda user_command_input in + let%map cmd = send_user_command mina user_command_input in Types.User_command.With_status.map cmd ~f:(fun cmd -> { With_hash.data = cmd ; hash = Transaction_hash.hash_command (Signed_command cmd) } ) - let send_unsigned_user_command ~coda ~nonce_opt ~signer ~memo ~fee + let send_unsigned_user_command ~mina ~nonce_opt ~signer ~memo ~fee ~fee_payer_pk ~valid_until ~body = let open Deferred.Result.Let_syntax in let%bind user_command_input = (let open Result.Let_syntax in let%bind sign_choice = - match%map find_identity ~public_key:signer coda with + match%map find_identity ~public_key:signer mina with | `Keypair sender_kp -> User_command_input.Sign_choice.Keypair sender_kp | `Hd_index hd_index -> @@ -3559,15 +3559,15 @@ module Mutations = struct ~valid_until ~body ~sign_choice) |> Deferred.return in - let%map cmd = send_user_command coda user_command_input in + let%map cmd = send_user_command mina user_command_input in Types.User_command.With_status.map cmd ~f:(fun cmd -> { With_hash.data = cmd ; hash = Transaction_hash.hash_command (Signed_command cmd) } ) - let export_logs ~coda basename_opt = + let export_logs ~mina basename_opt = let open Mina_lib in - let Config.{ conf_dir; _ } = Mina_lib.config coda in + let Config.{ conf_dir; _ } = Mina_lib.config mina in Conf_dir.export_logs_to_tar ?basename:basename_opt ~conf_dir let send_delegation = @@ -3579,7 +3579,7 @@ module Mutations = struct [ arg "input" ~typ:(non_null Types.Input.SendDelegationInput.arg_typ) ; Types.Input.Fields.signature ] - ~resolve:(fun { ctx = coda; _ } () + ~resolve:(fun { ctx = mina; _ } () (from, to_, fee, valid_until, memo, nonce_opt) signature -> let body = Signed_command_payload.Body.Stake_delegation @@ -3587,12 +3587,12 @@ module Mutations = struct in match signature with | None -> - send_unsigned_user_command ~coda ~nonce_opt ~signer:from ~memo ~fee + send_unsigned_user_command ~mina ~nonce_opt ~signer:from ~memo ~fee ~fee_payer_pk:from ~valid_until ~body |> Deferred.Result.map ~f:Types.User_command.mk_user_command | Some signature -> let%bind signature = signature |> Deferred.return in - send_signed_user_command ~coda ~nonce_opt ~signer:from ~memo ~fee + send_signed_user_command ~mina ~nonce_opt ~signer:from ~memo ~fee ~fee_payer_pk:from ~valid_until ~body ~signature |> Deferred.Result.map ~f:Types.User_command.mk_user_command ) @@ -3604,7 +3604,7 @@ module Mutations = struct [ arg "input" ~typ:(non_null Types.Input.SendPaymentInput.arg_typ) ; Types.Input.Fields.signature ] - ~resolve:(fun { ctx = coda; _ } () + ~resolve:(fun { ctx = mina; _ } () (from, to_, amount, fee, valid_until, memo, nonce_opt) signature -> let body = @@ -3616,11 +3616,11 @@ module Mutations = struct in match signature with | None -> - send_unsigned_user_command ~coda ~nonce_opt ~signer:from ~memo ~fee + send_unsigned_user_command ~mina ~nonce_opt ~signer:from ~memo ~fee ~fee_payer_pk:from ~valid_until ~body |> Deferred.Result.map ~f:Types.User_command.mk_user_command | Some signature -> - send_signed_user_command ~coda ~nonce_opt ~signer:from ~memo ~fee + send_signed_user_command ~mina ~nonce_opt ~signer:from ~memo ~fee ~fee_payer_pk:from ~valid_until ~body ~signature |> Deferred.Result.map ~f:Types.User_command.mk_user_command ) @@ -3629,8 +3629,8 @@ module Mutations = struct ~typ:(non_null Types.Payload.send_zkapp) ~args: Arg.[ arg "input" ~typ:(non_null Types.Input.SendZkappInput.arg_typ) ] - ~resolve:(fun { ctx = coda; _ } () parties -> - f coda parties (* TODO: error handling? *) ) + ~resolve:(fun { ctx = mina; _ } () parties -> + f mina parties (* TODO: error handling? *) ) let send_zkapp = make_zkapp_endpoint ~name:"sendZkapp" ~doc:"Send a zkApp transaction" @@ -3664,7 +3664,7 @@ module Mutations = struct ; repeat_count ; repeat_delay_ms ] - ~resolve:(fun { ctx = coda; _ } () senders_list receiver_pk amount fee + ~resolve:(fun { ctx = mina; _ } () senders_list receiver_pk amount fee repeat_count repeat_delay_ms -> let dumb_password = lazy (return (Bytes.of_string "dumb")) in let senders = Array.of_list senders_list in @@ -3693,10 +3693,10 @@ module Mutations = struct } in let%bind _ = - Secrets.Wallets.import_keypair (Mina_lib.wallets coda) kp + Secrets.Wallets.import_keypair (Mina_lib.wallets mina) kp ~password:dumb_password in - send_unsigned_user_command ~coda ~nonce_opt:None ~signer:source_pk + send_unsigned_user_command ~mina ~nonce_opt:None ~signer:source_pk ~memo:(Some memo) ~fee ~fee_payer_pk:source_pk ~valid_until:None ~body |> Deferred.Result.map ~f:(const 0) @@ -3759,8 +3759,8 @@ module Mutations = struct io_field "exportLogs" ~doc:"Export daemon logs to tar archive" ~args:Arg.[ arg "basename" ~typ:string ] ~typ:(non_null Types.Payload.export_logs) - ~resolve:(fun { ctx = coda; _ } () basename_opt -> - let%map result = export_logs ~coda basename_opt in + ~resolve:(fun { ctx = mina; _ } () basename_opt -> + let%map result = export_logs ~mina basename_opt in Result.map_error result ~f:(Fn.compose Yojson.Safe.to_string Error_json.error_to_yojson) ) @@ -3798,9 +3798,9 @@ module Mutations = struct [ arg "input" ~typ:(non_null Types.Input.SetSnarkWorkerInput.arg_typ) ] ~typ:(non_null Types.Payload.set_snark_worker) - ~resolve:(fun { ctx = coda; _ } () pk -> - let old_snark_worker_key = Mina_lib.snark_worker_key coda in - let%map () = Mina_lib.replace_snark_worker_key coda pk in + ~resolve:(fun { ctx = mina; _ } () pk -> + let old_snark_worker_key = Mina_lib.snark_worker_key mina in + let%map () = Mina_lib.replace_snark_worker_key mina pk in Ok old_snark_worker_key ) let set_snark_work_fee = @@ -3809,14 +3809,14 @@ module Mutations = struct ~args: Arg.[ arg "input" ~typ:(non_null Types.Input.SetSnarkWorkFee.arg_typ) ] ~typ:(non_null Types.Payload.set_snark_work_fee) - ~resolve:(fun { ctx = coda; _ } () raw_fee -> + ~resolve:(fun { ctx = mina; _ } () raw_fee -> let open Result.Let_syntax in let%map fee = result_of_exn Currency.Fee.of_uint64 raw_fee ~error:"Invalid snark work `fee` provided." in - let last_fee = Mina_lib.snark_work_fee coda in - Mina_lib.set_snark_work_fee coda fee ; + let last_fee = Mina_lib.snark_work_fee mina in + Mina_lib.set_snark_work_fee mina fee ; last_fee ) let set_connection_gating_config = @@ -3830,11 +3830,11 @@ module Mutations = struct "Set the connection gating config, returning the current config after \ the application (which may have failed)" ~typ:(non_null Types.Payload.set_connection_gating_config) - ~resolve:(fun { ctx = coda; _ } () config -> + ~resolve:(fun { ctx = mina; _ } () config -> let open Deferred.Result.Let_syntax in let%bind config = Deferred.return config in let open Deferred.Let_syntax in - Mina_networking.set_connection_gating_config (Mina_lib.net coda) config + Mina_networking.set_connection_gating_config (Mina_lib.net mina) config >>| Result.return ) let add_peer = @@ -3848,7 +3848,7 @@ module Mutations = struct ] ~doc:"Connect to the given peers" ~typ:(non_null @@ list @@ non_null Types.DaemonStatus.peer) - ~resolve:(fun { ctx = coda; _ } () peers seed -> + ~resolve:(fun { ctx = mina; _ } () peers seed -> let open Deferred.Result.Let_syntax in let%bind peers = Result.combine_errors peers @@ -3856,7 +3856,7 @@ module Mutations = struct Option.value ~default:"Empty peers list" (List.hd errs) ) |> Deferred.return in - let net = Mina_lib.net coda in + let net = Mina_lib.net mina in let is_seed = Option.value ~default:true seed in let%bind.Async.Deferred maybe_failure = (* Add peers until we find an error *) @@ -3892,10 +3892,10 @@ module Mutations = struct ~args:Arg.[] ~resolve:(fun _ _ -> true) ] ) ) ) - ~resolve:(fun { ctx = coda; _ } () block -> + ~resolve:(fun { ctx = mina; _ } () block -> let open Deferred.Result.Let_syntax in let%bind archive_location = - match (Mina_lib.config coda).archive_process_location with + match (Mina_lib.config mina).archive_process_location with | Some archive_location -> return archive_location | None -> @@ -3923,10 +3923,10 @@ module Mutations = struct ~args:Arg.[] ~resolve:(fun _ _ -> true) ] ) ) ) - ~resolve:(fun { ctx = coda; _ } () block -> + ~resolve:(fun { ctx = mina; _ } () block -> let open Deferred.Result.Let_syntax in let%bind archive_location = - match (Mina_lib.config coda).archive_process_location with + match (Mina_lib.config mina).archive_process_location with | Some archive_location -> return archive_location | None -> @@ -4050,8 +4050,8 @@ module Queries = struct ~typ:(list (non_null string)) ; arg "ids" ~typ:(list (non_null guid)) ~doc:"Ids of User commands" ] - ~resolve:(fun { ctx = coda; _ } () pk_opt hashes_opt txns_opt -> - let transaction_pool = Mina_lib.transaction_pool coda in + ~resolve:(fun { ctx = mina; _ } () pk_opt hashes_opt txns_opt -> + let transaction_pool = Mina_lib.transaction_pool mina in let resource_pool = Network_pool.Transaction_pool.resource_pool transaction_pool in @@ -4088,8 +4088,8 @@ module Queries = struct ~typ:(list (non_null string)) ; arg "ids" ~typ:(list (non_null guid)) ~doc:"Ids of zkApp commands" ] - ~resolve:(fun { ctx = coda; _ } () pk_opt hashes_opt txns_opt -> - let transaction_pool = Mina_lib.transaction_pool coda in + ~resolve:(fun { ctx = mina; _ } () pk_opt hashes_opt txns_opt -> + let transaction_pool = Mina_lib.transaction_pool mina in let resource_pool = Network_pool.Transaction_pool.resource_pool transaction_pool in @@ -4112,30 +4112,30 @@ module Queries = struct let sync_status = io_field "syncStatus" ~doc:"Network sync status" ~args:[] - ~typ:(non_null Types.sync_status) ~resolve:(fun { ctx = coda; _ } () -> + ~typ:(non_null Types.sync_status) ~resolve:(fun { ctx = mina; _ } () -> let open Deferred.Let_syntax in (* pull out sync status from status, so that result here agrees with status; see issue #8251 *) let%map { sync_status; _ } = - Mina_commands.get_status ~flag:`Performance coda + Mina_commands.get_status ~flag:`Performance mina in Ok sync_status ) let daemon_status = io_field "daemonStatus" ~doc:"Get running daemon status" ~args:[] - ~typ:(non_null Types.DaemonStatus.t) ~resolve:(fun { ctx = coda; _ } () -> - Mina_commands.get_status ~flag:`Performance coda >>| Result.return ) + ~typ:(non_null Types.DaemonStatus.t) ~resolve:(fun { ctx = mina; _ } () -> + Mina_commands.get_status ~flag:`Performance mina >>| Result.return ) let trust_status = field "trustStatus" ~typ:(list (non_null Types.Payload.trust_status)) ~args:Arg.[ arg "ipAddress" ~typ:(non_null string) ] ~doc:"Trust status for an IPv4 or IPv6 address" - ~resolve:(fun { ctx = coda; _ } () (ip_addr_string : string) -> + ~resolve:(fun { ctx = mina; _ } () (ip_addr_string : string) -> match Types.Arguments.ip_address ~name:"ipAddress" ip_addr_string with | Ok ip_addr -> - Some (Mina_commands.get_trust_status coda ip_addr) + Some (Mina_commands.get_trust_status mina ip_addr) | Error _ -> None ) @@ -4144,8 +4144,8 @@ module Queries = struct ~typ:(non_null @@ list @@ non_null Types.Payload.trust_status) ~args:Arg.[] ~doc:"IP address and trust status for all peers" - ~resolve:(fun { ctx = coda; _ } () -> - Mina_commands.get_trust_status_all coda ) + ~resolve:(fun { ctx = mina; _ } () -> + Mina_commands.get_trust_status_all mina ) let version = field "version" ~typ:string @@ -4153,14 +4153,14 @@ module Queries = struct ~doc:"The version of the node (git commit hash)" ~resolve:(fun _ _ -> Some Mina_version.commit_id) - let tracked_accounts_resolver { ctx = coda; _ } () = - let wallets = Mina_lib.wallets coda in - let block_production_pubkeys = Mina_lib.block_production_pubkeys coda in - let best_tip_ledger = Mina_lib.best_ledger coda in + let tracked_accounts_resolver { ctx = mina; _ } () = + let wallets = Mina_lib.wallets mina in + let block_production_pubkeys = Mina_lib.block_production_pubkeys mina in + let best_tip_ledger = Mina_lib.best_ledger mina in wallets |> Secrets.Wallets.pks |> List.map ~f:(fun pk -> { Types.AccountObj.account = - Types.AccountObj.Partial_account.of_pk coda pk + Types.AccountObj.Partial_account.of_pk mina pk ; locked = Secrets.Wallets.check_locked wallets ~needle:pk ; is_actively_staking = Public_key.Compressed.Set.mem block_production_pubkeys pk @@ -4190,10 +4190,10 @@ module Queries = struct ~args:Arg.[] ~resolve:tracked_accounts_resolver - let account_resolver { ctx = coda; _ } () pk = + let account_resolver { ctx = mina; _ } () pk = Some - (Types.AccountObj.lift coda pk - (Types.AccountObj.Partial_account.of_pk coda pk) ) + (Types.AccountObj.lift mina pk + (Types.AccountObj.Partial_account.of_pk mina pk) ) let wallet = field "wallet" ~doc:"Find any wallet via a public key" @@ -4214,11 +4214,11 @@ module Queries = struct [ arg "publicKey" ~doc:"Public key of account being retrieved" ~typ:(non_null Types.Input.PublicKey.arg_typ) ; arg' "token" - ~doc:"Token of account being retrieved (defaults to CODA)" + ~doc:"Token of account being retrieved (defaults to MINA)" ~typ:Types.Input.TokenId.arg_typ ~default:Token_id.default ] - ~resolve:(fun { ctx = coda; _ } () pk token -> - Option.bind (get_ledger_and_breadcrumb coda) + ~resolve:(fun { ctx = mina; _ } () pk token -> + Option.bind (get_ledger_and_breadcrumb mina) ~f:(fun (ledger, breadcrumb) -> let open Option.Let_syntax in let%bind location = @@ -4226,7 +4226,7 @@ module Queries = struct in let%map account = Ledger.get ledger location in Types.AccountObj.Partial_account.of_full_account ~breadcrumb account - |> Types.AccountObj.lift coda pk ) ) + |> Types.AccountObj.lift mina pk ) ) let accounts_for_pk = field "accounts" ~doc:"Find all accounts for a public key" @@ -4236,8 +4236,8 @@ module Queries = struct [ arg "publicKey" ~doc:"Public key to find accounts for" ~typ:(non_null Types.Input.PublicKey.arg_typ) ] - ~resolve:(fun { ctx = coda; _ } () pk -> - match get_ledger_and_breadcrumb coda with + ~resolve:(fun { ctx = mina; _ } () pk -> + match get_ledger_and_breadcrumb mina with | Some (ledger, breadcrumb) -> let tokens = Ledger.tokens ledger pk |> Set.to_list in List.filter_map tokens ~f:(fun token -> @@ -4248,7 +4248,7 @@ module Queries = struct let%map account = Ledger.get ledger location in Types.AccountObj.Partial_account.of_full_account ~breadcrumb account - |> Types.AccountObj.lift coda pk ) + |> Types.AccountObj.lift mina pk ) | None -> [] ) @@ -4260,8 +4260,8 @@ module Queries = struct [ arg "tokenId" ~doc:"Token ID to find accounts for" ~typ:(non_null Types.Input.TokenId.arg_typ) ] - ~resolve:(fun { ctx = coda; _ } () token_id -> - match get_ledger_and_breadcrumb coda with + ~resolve:(fun { ctx = mina; _ } () token_id -> + match get_ledger_and_breadcrumb mina with | Some (ledger, breadcrumb) -> List.filter_map (Ledger.to_list ledger) ~f:(fun acc -> let open Option.Let_syntax in @@ -4269,7 +4269,7 @@ module Queries = struct Option.some_if (Token_id.equal token_id acc.token_id) () in Types.AccountObj.Partial_account.of_full_account ~breadcrumb acc - |> Types.AccountObj.lift coda acc.public_key ) + |> Types.AccountObj.lift mina acc.public_key ) | None -> [] ) @@ -4281,8 +4281,8 @@ module Queries = struct [ arg "token" ~doc:"Token to find the owner for" ~typ:(non_null Types.Input.TokenId.arg_typ) ] - ~resolve:(fun { ctx = coda; _ } () token -> - coda |> Mina_lib.best_tip |> Participating_state.active + ~resolve:(fun { ctx = mina; _ } () token -> + mina |> Mina_lib.best_tip |> Participating_state.active |> Option.bind ~f:(fun tip -> let ledger = Transition_frontier.Breadcrumb.staged_ledger tip @@ -4298,7 +4298,7 @@ module Queries = struct [ arg "payment" ~typ:guid ~doc:"Id of a Payment" ; arg "zkappTransaction" ~typ:guid ~doc:"Id of a zkApp transaction" ] - ~resolve:(fun { ctx = coda; _ } () (serialized_payment : string option) + ~resolve:(fun { ctx = mina; _ } () (serialized_payment : string option) (serialized_zkapp : string option) -> let open Result.Let_syntax in let deserialize_txn serialized_txn = @@ -4329,8 +4329,8 @@ module Queries = struct | None, Some zkapp_txn -> deserialize_txn (`Parties zkapp_txn) in - let frontier_broadcast_pipe = Mina_lib.transition_frontier coda in - let transaction_pool = Mina_lib.transaction_pool coda in + let frontier_broadcast_pipe = Mina_lib.transition_frontier mina in + let transaction_pool = Mina_lib.transaction_pool mina in Transaction_inclusion_status.get_status ~frontier_broadcast_pipe ~transaction_pool txn.data ) @@ -4338,13 +4338,13 @@ module Queries = struct field "currentSnarkWorker" ~typ:Types.snark_worker ~args:Arg.[] ~doc:"Get information about the current snark worker" - ~resolve:(fun { ctx = coda; _ } _ -> - Option.map (Mina_lib.snark_worker_key coda) ~f:(fun k -> - (k, Mina_lib.snark_work_fee coda) ) ) + ~resolve:(fun { ctx = mina; _ } _ -> + Option.map (Mina_lib.snark_worker_key mina) ~f:(fun k -> + (k, Mina_lib.snark_work_fee mina) ) ) let genesis_block = field "genesisBlock" ~typ:(non_null Types.block) ~args:[] - ~doc:"Get the genesis block" ~resolve:(fun { ctx = coda; _ } () -> + ~doc:"Get the genesis block" ~resolve:(fun { ctx = mina; _ } () -> let open Mina_state in let { Precomputed_values.genesis_ledger ; constraint_constants @@ -4353,7 +4353,7 @@ module Queries = struct ; proof_data ; _ } = - (Mina_lib.config coda).precomputed_values + (Mina_lib.config mina).precomputed_values in let { With_hash.data = genesis_state ; hash = { State_hash.State_hashes.state_hash = hash; _ } @@ -4400,13 +4400,13 @@ module Queries = struct } ) (* used by best_chain, block below *) - let block_of_breadcrumb coda breadcrumb = + let block_of_breadcrumb mina breadcrumb = let hash = Transition_frontier.Breadcrumb.state_hash breadcrumb in let block = Transition_frontier.Breadcrumb.block breadcrumb in let transactions = Mina_block.transactions ~constraint_constants: - (Mina_lib.config coda).precomputed_values.constraint_constants block + (Mina_lib.config mina).precomputed_values.constraint_constants block in { With_hash.Stable.Latest.data = Filtered_external_transition.of_transition block `All transactions @@ -4428,12 +4428,12 @@ module Queries = struct blocks closest to the best tip will be returned" ~typ:int ] - ~resolve:(fun { ctx = coda; _ } () max_length -> - match Mina_lib.best_chain ?max_length coda with + ~resolve:(fun { ctx = mina; _ } () max_length -> + match Mina_lib.best_chain ?max_length mina with | Some best_chain -> let%map blocks = Deferred.List.map best_chain ~f:(fun bc -> - Deferred.return @@ block_of_breadcrumb coda bc ) + Deferred.return @@ block_of_breadcrumb mina bc ) in Ok (Some blocks) | None -> @@ -4453,11 +4453,11 @@ module Queries = struct ; arg "height" ~doc:"The height of the desired block in the best chain" ~typ:int ] - ~resolve:(fun { ctx = coda; _ } () (state_hash_base58_opt : string option) + ~resolve:(fun { ctx = mina; _ } () (state_hash_base58_opt : string option) (height_opt : int option) -> let open Result.Let_syntax in let get_transition_frontier () = - let transition_frontier_pipe = Mina_lib.transition_frontier coda in + let transition_frontier_pipe = Mina_lib.transition_frontier mina in Pipe_lib.Broadcast_pipe.Reader.peek transition_frontier_pipe |> Result.of_option ~error:"Could not obtain transition frontier" in @@ -4476,7 +4476,7 @@ module Queries = struct frontier" state_hash_base58 ) in - block_of_breadcrumb coda breadcrumb + block_of_breadcrumb mina breadcrumb in let block_from_height height = let height_uint32 = @@ -4509,7 +4509,7 @@ module Queries = struct %d" height ) in - block_of_breadcrumb coda desired_breadcrumb + block_of_breadcrumb mina desired_breadcrumb in match (state_hash_base58_opt, height_opt) with | Some state_hash_base58, None -> @@ -4524,8 +4524,8 @@ module Queries = struct ~doc:"List of peers that the daemon first used to connect to the network" ~args:Arg.[] ~typ:(non_null @@ list @@ non_null string) - ~resolve:(fun { ctx = coda; _ } () -> - List.map (Mina_lib.initial_peers coda) ~f:Mina_net2.Multiaddr.to_string + ~resolve:(fun { ctx = mina; _ } () -> + List.map (Mina_lib.initial_peers mina) ~f:Mina_net2.Multiaddr.to_string ) let get_peers = @@ -4533,8 +4533,8 @@ module Queries = struct ~doc:"List of peers that the daemon is currently connected to" ~args:Arg.[] ~typ:(non_null @@ list @@ non_null Types.DaemonStatus.peer) - ~resolve:(fun { ctx = coda; _ } () -> - let%map peers = Mina_networking.peers (Mina_lib.net coda) in + ~resolve:(fun { ctx = mina; _ } () -> + let%map peers = Mina_networking.peers (Mina_lib.net mina) in Ok (List.map ~f:Network_peer.Peer.to_display peers) ) let snark_pool = @@ -4542,22 +4542,22 @@ module Queries = struct ~doc:"List of completed snark works that have the lowest fee so far" ~args:Arg.[] ~typ:(non_null @@ list @@ non_null Types.completed_work) - ~resolve:(fun { ctx = coda; _ } () -> - Mina_lib.snark_pool coda |> Network_pool.Snark_pool.resource_pool + ~resolve:(fun { ctx = mina; _ } () -> + Mina_lib.snark_pool mina |> Network_pool.Snark_pool.resource_pool |> Network_pool.Snark_pool.Resource_pool.all_completed_work ) let pending_snark_work = field "pendingSnarkWork" ~doc:"List of snark works that are yet to be done" ~args:Arg.[] ~typ:(non_null @@ list @@ non_null Types.pending_work) - ~resolve:(fun { ctx = coda; _ } () -> - let snark_job_state = Mina_lib.snark_job_state coda in - let snark_pool = Mina_lib.snark_pool coda in + ~resolve:(fun { ctx = mina; _ } () -> + let snark_job_state = Mina_lib.snark_job_state mina in + let snark_pool = Mina_lib.snark_pool mina in let fee_opt = Mina_lib.( - Option.map (snark_worker_key coda) ~f:(fun _ -> snark_work_fee coda)) + Option.map (snark_worker_key mina) ~f:(fun _ -> snark_work_fee mina)) in - let (module S) = Mina_lib.work_selection_method coda in + let (module S) = Mina_lib.work_selection_method mina in S.pending_work_statements ~snark_pool ~fee_opt snark_job_state ) let genesis_constants = @@ -4576,9 +4576,9 @@ module Queries = struct times" ~args:Arg.[] ~typ:(non_null int) - ~resolve:(fun { ctx = coda; _ } () -> + ~resolve:(fun { ctx = mina; _ } () -> Block_time.Controller.get_time_offset - ~logger:(Mina_lib.config coda).logger + ~logger:(Mina_lib.config mina).logger |> Time.Span.to_sec |> Float.to_int ) let connection_gating_config = @@ -4588,8 +4588,8 @@ module Queries = struct connections to permit" ~args:Arg.[] ~typ:(non_null Types.Payload.set_connection_gating_config) - ~resolve:(fun { ctx = coda; _ } _ -> - let net = Mina_lib.net coda in + ~resolve:(fun { ctx = mina; _ } _ -> + let net = Mina_lib.net mina in let%map config = Mina_networking.connection_gating_config net in Ok config ) diff --git a/src/lib/transition_frontier/transition_frontier.ml b/src/lib/transition_frontier/transition_frontier.ml index 26fbf98f698..7ace231fb3f 100644 --- a/src/lib/transition_frontier/transition_frontier.ml +++ b/src/lib/transition_frontier/transition_frontier.ml @@ -215,8 +215,7 @@ let rec load_with_max_length : ~persistent_frontier_instance ignore_consensus_local_state with | Ok _ as result -> - [%str_log trace] Persisted_frontier_loaded - ~metadata:[ ("snarked_ledger_hash", snarked_ledger_hash_json) ] ; + [%str_log trace] Persisted_frontier_loaded ; return result | Error err as err_result -> let err_str = @@ -425,9 +424,6 @@ let add_breadcrumb_exn t breadcrumb = Mina_block.Validated.valid_commands @@ Breadcrumb.validated_transition breadcrumb in - (* N.B.: surprisingly, the JSON does not contain a tag indicating whether we have a signed - command or snapp command - *) [%str_log' trace t.logger] Added_breadcrumb_user_commands ~metadata: [ ( "user_commands" From 3435ad81c7b355958fbe1287b8bd78f73095923c Mon Sep 17 00:00:00 2001 From: Paul Steckler Date: Fri, 9 Sep 2022 18:24:06 -0700 Subject: [PATCH 098/144] revert wording --- src/lib/integration_test_lib/wait_condition.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/integration_test_lib/wait_condition.ml b/src/lib/integration_test_lib/wait_condition.ml index 1464d0f3ea8..53d278c77f8 100644 --- a/src/lib/integration_test_lib/wait_condition.ml +++ b/src/lib/integration_test_lib/wait_condition.ml @@ -280,7 +280,7 @@ struct in let soft_timeout_in_slots = 4 in { id = Persisted_frontier_loaded - ; description = "persisted transition frontier loaded" + ; description = "persisted transition frontier to load" ; predicate = Event_predicate (Event_type.Persisted_frontier_loaded, (), check) ; soft_timeout = Slots soft_timeout_in_slots From 9af29b645dfc059c3619fc06837ec8b09bd20f5c Mon Sep 17 00:00:00 2001 From: Serhii Shymkiv Date: Sat, 10 Sep 2022 17:53:14 +0300 Subject: [PATCH 099/144] Fix for Docker image Demo-mode (Develop). --- dockerfiles/auxiliary_entrypoints/01-run-demo.sh | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/dockerfiles/auxiliary_entrypoints/01-run-demo.sh b/dockerfiles/auxiliary_entrypoints/01-run-demo.sh index ffdf0fdbc34..92ed33ef1d4 100755 --- a/dockerfiles/auxiliary_entrypoints/01-run-demo.sh +++ b/dockerfiles/auxiliary_entrypoints/01-run-demo.sh @@ -15,10 +15,10 @@ if [[ -n ${RUN_DEMO} ]]; then mkdir /root/keys && chmod go-rwx /root/keys mkdir -p --mode=700 ${MINA_CONFIG_DIR}/wallets/store/ - echo "$PK" > ${MINA_CONFIG_DIR}/wallets/store/$PK.pub - echo '{"box_primitive":"xsalsa20poly1305","pw_primitive":"argon2i","nonce":"6pcvpWSLkMi393dT5VSLR6ft56AWKkCYRqJoYia","pwsalt":"ASoBkV3NsY7ZRuxztyPJdmJCiz3R","pwdiff":[134217728,6],"ciphertext":"Dmq1Qd8uNbZRT1NT7zVbn3eubpn9Myx9Je9ZQGTKDxUv4BoPNmZAGox18qVfbbEUSuhT4ZGDt"}' > ${MINA_CONFIG_DIR}/wallets/store/${PK} + echo "$PK" >${MINA_CONFIG_DIR}/wallets/store/$PK.pub + echo '{"box_primitive":"xsalsa20poly1305","pw_primitive":"argon2i","nonce":"6pcvpWSLkMi393dT5VSLR6ft56AWKkCYRqJoYia","pwsalt":"ASoBkV3NsY7ZRuxztyPJdmJCiz3R","pwdiff":[134217728,6],"ciphertext":"Dmq1Qd8uNbZRT1NT7zVbn3eubpn9Myx9Je9ZQGTKDxUv4BoPNmZAGox18qVfbbEUSuhT4ZGDt"}' >${MINA_CONFIG_DIR}/wallets/store/${PK} chmod go-rwx ${MINA_CONFIG_DIR}/wallets/store/${PK} - echo '{"genesis": {"genesis_state_timestamp": "${GENESIS_STATE_TIMESTAMP}"},"ledger":{"name":"mina-demo","accounts":[{"pk":"'${PK}'","balance":"66000","sk":null,"delegate":null}]}}' > ${CONFIG_TEMPLATE} + echo '{"genesis": {"genesis_state_timestamp": "${GENESIS_STATE_TIMESTAMP}"},"ledger":{"name":"mina-demo","accounts":[{"pk":"'${PK}'","balance":"66000","sk":null,"delegate":null}]}}' >${CONFIG_TEMPLATE} if [ -z "$GENESIS_STATE_TIMESTAMP" ]; then export GENESIS_STATE_TIMESTAMP=$(date -u +"%Y-%m-%dT%H:%M:%SZ") @@ -26,18 +26,15 @@ if [[ -n ${RUN_DEMO} ]]; then echo "Genesis State Timestamp for this run is: ${GENESIS_STATE_TIMESTAMP}" echo "Rewriting config file from template ${CONFIG_TEMPLATE} to ${MINA_CONFIG_FILE}" - envsubst < ${CONFIG_TEMPLATE} > ${MINA_CONFIG_FILE} + envsubst <${CONFIG_TEMPLATE} >${MINA_CONFIG_FILE} echo "Contents of config file ${MINA_CONFIG_FILE}:" cat "${MINA_CONFIG_FILE}" MINA_TIME_OFFSET=${MINA_TIME_OFFSET:-0} - MINA_TIME_OFFSET=${MINA_TIME_OFFSET:-0} - - MINA_PRIVKEY_PASS=${MINA_PRIVKEY_PASS:-""} MINA_PRIVKEY_PASS=${MINA_PRIVKEY_PASS:-""} - exec mina daemon --generate-genesis-proof true --seed --demo-mode --proof-level none --config-dir ${MINA_CONFIG_DIR} --block-producer-pubkey ${PK} --run-snark-worker ${SNARK_PK} -insecure-rest-server $@ + exec MINA_PRIVKEY_PASS mina daemon --generate-genesis-proof true --seed --demo-mode --proof-level none --config-dir ${MINA_CONFIG_DIR} --block-producer-pubkey ${PK} --run-snark-worker ${SNARK_PK} -insecure-rest-server $@ rc=$? echo "Exiting Mina demo." && exit $rc From 8921622429b7cb103062f0697b6c430004747a0d Mon Sep 17 00:00:00 2001 From: Deepthi S Kumar Date: Sat, 10 Sep 2022 17:10:29 -0700 Subject: [PATCH 100/144] changes gauges to counters --- src/app/cli/src/init/coda_run.ml | 55 ++++++++++++------- src/lib/mina_metrics/mina_metrics.mli | 20 +++++-- .../mina_metrics/no_metrics/mina_metrics.ml | 20 +++++-- .../prometheus_metrics/mina_metrics.ml | 49 ++++++++++++----- src/lib/network_pool/indexed_pool.ml | 8 ++- src/lib/snark_worker/functor.ml | 23 +++++--- 6 files changed, 120 insertions(+), 55 deletions(-) diff --git a/src/app/cli/src/init/coda_run.ml b/src/app/cli/src/init/coda_run.ml index 6d48b88ff72..3a7c0179c8d 100644 --- a/src/app/cli/src/init/coda_run.ml +++ b/src/app/cli/src/init/coda_run.ml @@ -412,20 +412,30 @@ let setup_local_server ?(client_trustlist = []) ?rest_server_port (One_or_two.zip_exn work.metrics (Snark_worker.Work.Result.transactions work) ) ~f:(fun ((total, tag), transaction_opt) -> - match tag with + ( match tag with | `Merge -> Perf_histograms.add_span ~name:"snark_worker_merge_time" total ; Mina_metrics.( Cryptography.Snark_work_histogram.observe Cryptography.snark_work_merge_time_sec (Time.Span.to_sec total)) - | `Transition -> - let parties_count, proof_parties_count = - (*should be Some in the case of `Transition*) - match Option.value_exn transaction_opt with - | Mina_transaction.Transaction.Command - (Mina_base.User_command.Parties parties) -> - Mina_base.Parties.Call_forest.fold parties.other_parties - ~init:(1, 0) ~f:(fun (count, proof_parties_count) party -> + | `Transition -> ( + (*should be Some in the case of `Transition*) + match Option.value_exn transaction_opt with + | Mina_transaction.Transaction.Command + (Mina_base.User_command.Parties parties) -> + let init = + match + (Mina_base.Party.of_fee_payer parties.fee_payer) + .authorization + with + | Proof _ -> + (1, 1) + | _ -> + (1, 0) + in + let parties_count, proof_parties_count = + Mina_base.Parties.Call_forest.fold parties.other_parties ~init + ~f:(fun (count, proof_parties_count) party -> ( count + 1 , if Mina_base.Control.( @@ -433,16 +443,23 @@ let setup_local_server ?(client_trustlist = []) ?rest_server_port (tag (Mina_base.Party.authorization party))) then proof_parties_count + 1 else proof_parties_count ) ) - | _ -> - (1, 0) - in - Perf_histograms.add_span ~name:"snark_worker_transition_time" total ; - Mina_metrics.( - Cryptography.( - Gauge.set snark_work_base_time_sec (Time.Span.to_sec total) ; - Gauge.set transaction_length (Float.of_int parties_count) ; - Gauge.set zkapp_proof_updates (Float.of_int proof_parties_count))) - ) + in + Mina_metrics.( + Cryptography.( + Counter.inc snark_work_zkapp_base_time_sec + (Time.Span.to_sec total) ; + Counter.inc_one snark_work_zkapp_base_submissions ; + Counter.inc zkapp_transaction_length + (Float.of_int parties_count) ; + Counter.inc zkapp_proof_updates + (Float.of_int proof_parties_count))) + | _ -> + Mina_metrics.( + Cryptography.( + Counter.inc_one snark_work_base_submissions ; + Counter.inc snark_work_base_time_sec + (Time.Span.to_sec total))) ) ) ; + Perf_histograms.add_span ~name:"snark_worker_transition_time" total ) in let snark_worker_impls = [ implement Snark_worker.Rpcs_versioned.Get_work.Latest.rpc (fun () () -> diff --git a/src/lib/mina_metrics/mina_metrics.mli b/src/lib/mina_metrics/mina_metrics.mli index 002d705141e..705c8f2e8c1 100644 --- a/src/lib/mina_metrics/mina_metrics.mli +++ b/src/lib/mina_metrics/mina_metrics.mli @@ -58,11 +58,17 @@ module Cryptography : sig val snark_work_merge_time_sec : Snark_work_histogram.t - val snark_work_base_time_sec : Gauge.t + val snark_work_zkapp_base_time_sec : Counter.t - val transaction_length : Gauge.t + val snark_work_base_time_sec : Counter.t - val zkapp_proof_updates : Gauge.t + val snark_work_zkapp_base_submissions : Counter.t + + val snark_work_base_submissions : Counter.t + + val zkapp_transaction_length : Counter.t + + val zkapp_proof_updates : Counter.t end module Bootstrap : sig @@ -84,11 +90,13 @@ module Transaction_pool : sig val transactions_added_to_pool : Counter.t - val zkapp_transaction_size : Gauge.t + val zkapp_transactions_added_to_pool : Counter.t + + val zkapp_transaction_size : Counter.t - val zkapp_updates : Gauge.t + val zkapp_updates : Counter.t - val zkapp_proof_updates : Gauge.t + val zkapp_proof_updates : Counter.t end module Network : sig diff --git a/src/lib/mina_metrics/no_metrics/mina_metrics.ml b/src/lib/mina_metrics/no_metrics/mina_metrics.ml index e2a3e8f3cd4..00bec9d9ebe 100644 --- a/src/lib/mina_metrics/no_metrics/mina_metrics.ml +++ b/src/lib/mina_metrics/no_metrics/mina_metrics.ml @@ -68,11 +68,17 @@ module Cryptography = struct let snark_work_merge_time_sec : Snark_work_histogram.t = () - let snark_work_base_time_sec : Gauge.t = () + let snark_work_zkapp_base_time_sec : Counter.t = () - let transaction_length : Gauge.t = () + let snark_work_base_time_sec : Counter.t = () - let zkapp_proof_updates : Gauge.t = () + let snark_work_zkapp_base_submissions : Counter.t = () + + let snark_work_base_submissions : Counter.t = () + + let zkapp_proof_updates : Counter.t = () + + let zkapp_proof_updates : Counter.t = () end module Bootstrap = struct @@ -94,11 +100,13 @@ module Transaction_pool = struct let transactions_added_to_pool : Counter.t = () - let zkapp_transaction_size : Gauge.t = () + let zkapp_transactions_added_to_pool : Counter.t = () + + let zkapp_transaction_size : Counter.t = () - let zkapp_updates : Gauge.t = () + let zkapp_updates : Counter.t = () - let zkapp_proof_updates : Guage.t = () + let zkapp_proof_updates : Counter.t = () end module Network = struct diff --git a/src/lib/mina_metrics/prometheus_metrics/mina_metrics.ml b/src/lib/mina_metrics/prometheus_metrics/mina_metrics.ml index b3f861b02b1..6994d804a73 100644 --- a/src/lib/mina_metrics/prometheus_metrics/mina_metrics.ml +++ b/src/lib/mina_metrics/prometheus_metrics/mina_metrics.ml @@ -274,22 +274,37 @@ module Cryptography = struct Snark_work_histogram.v "snark_work_merge_time_sec" ~help ~namespace ~subsystem + let snark_work_zkapp_base_time_sec = + let help = "time elapsed while doing base proof for a zkapp transaction" in + Counter.v "snark_work_zkapp_base_time_sec" ~help ~namespace ~subsystem + let snark_work_base_time_sec = - let help = "time elapsed while doing base proof" in - Gauge.v "snark_work_base_time_sec" ~help ~namespace ~subsystem + let help = + "time elapsed while doing base proof for a non-zkapp transaction" + in + Counter.v "snark_work_base_time_sec" ~help ~namespace ~subsystem + + let snark_work_zkapp_base_submissions = + let help = + "Number of base transactions snarks for zkapp transactions submitted" + in + Counter.v "snark_work_zkapp_base_submissions" ~help ~namespace ~subsystem - let transaction_length = + let snark_work_base_submissions = let help = - "Number of parties in a parties transaction (1 for simple transactions)" + "Number of base transactions snarks for non-zkapp transactions submitted" in - Gauge.v "transaction_length" ~help ~namespace ~subsystem + Counter.v "snark_work_base_submissions" ~help ~namespace ~subsystem + + let zkapp_transaction_length = + let help = "Number of updates in a zkapp transaction" in + Counter.v "zkapp_transaction_length" ~help ~namespace ~subsystem let zkapp_proof_updates = let help = - "Number of parties with proof authorization in a parties transaction (0 \ - for simple transactions)" + "Number of updates with proof authorization in a parties transaction" in - Gauge.v "zkapp_proof_updates" ~help ~namespace ~subsystem + Counter.v "zkapp_proof_updates" ~help ~namespace ~subsystem (* TODO: let transaction_proving_time_ms = @@ -343,20 +358,26 @@ module Transaction_pool = struct in Counter.v "transactions_added_to_pool" ~help ~namespace ~subsystem - let zkapp_transaction_size : Gauge.t = + let zkapp_transactions_added_to_pool : Counter.t = + let help = + "Number of zkapp transactions added to the pool since the node start" + in + Counter.v "zkapp_transactions_added_to_pool" ~help ~namespace ~subsystem + + let zkapp_transaction_size : Counter.t = let help = "Size of valid parties transaction received (bin_size_t)" in - Gauge.v "zkapp_transaction_size" ~help ~namespace ~subsystem + Counter.v "zkapp_transaction_size" ~help ~namespace ~subsystem - let zkapp_updates : Gauge.t = + let zkapp_updates : Counter.t = let help = "Number of parties in a valid transaction received" in - Gauge.v "zkapp_updates" ~help ~namespace ~subsystem + Counter.v "zkapp_updates" ~help ~namespace ~subsystem - let zkapp_proof_updates : Gauge.t = + let zkapp_proof_updates : Counter.t = let help = "Number of parties with proof authorization in a parties transaction (0 \ for simple transactions)" in - Gauge.v "zkapp_proof_updates" ~help ~namespace ~subsystem + Counter.v "zkapp_proof_updates" ~help ~namespace ~subsystem end module Metric_map (Metric : sig diff --git a/src/lib/network_pool/indexed_pool.ml b/src/lib/network_pool/indexed_pool.ml index 9a2fc8841a9..008bddbfb6c 100644 --- a/src/lib/network_pool/indexed_pool.ml +++ b/src/lib/network_pool/indexed_pool.ml @@ -531,12 +531,14 @@ module Update = struct then proof_parties_count + 1 else proof_parties_count ) ) in - Mina_metrics.Gauge.set + Mina_metrics.Counter.inc_one + Mina_metrics.Transaction_pool.zkapp_transactions_added_to_pool ; + Mina_metrics.Counter.inc Mina_metrics.Transaction_pool.zkapp_transaction_size (Parties.Stable.Latest.bin_size_t p |> Float.of_int) ; - Mina_metrics.Gauge.set Mina_metrics.Transaction_pool.zkapp_updates + Mina_metrics.Counter.inc Mina_metrics.Transaction_pool.zkapp_updates (Float.of_int updates) ; - Mina_metrics.Gauge.set + Mina_metrics.Counter.inc Mina_metrics.Transaction_pool.zkapp_proof_updates (Float.of_int proof_updates) | Signed_command _ -> diff --git a/src/lib/snark_worker/functor.ml b/src/lib/snark_worker/functor.ml index 5b3451873e8..569cc645f1f 100644 --- a/src/lib/snark_worker/functor.ml +++ b/src/lib/snark_worker/functor.ml @@ -187,21 +187,30 @@ module Make (Inputs : Intf.Inputs_intf) : then proof_parties_count + 1 else proof_parties_count ) ) in + Mina_metrics.( + Cryptography.( + Counter.inc snark_work_zkapp_base_time_sec + (Time.Span.to_sec time) ; + Counter.inc_one snark_work_zkapp_base_submissions ; + Counter.inc zkapp_transaction_length (Float.of_int c) ; + Counter.inc zkapp_proof_updates (Float.of_int p))) ; ("parties", c, p) | Command (Signed_command _) -> + Mina_metrics.( + Counter.inc Cryptography.snark_work_base_time_sec + (Time.Span.to_sec time)) ; ("signed command", 1, 0) | Coinbase _ -> + Mina_metrics.( + Counter.inc Cryptography.snark_work_base_time_sec + (Time.Span.to_sec time)) ; ("coinbase", 1, 0) | Fee_transfer _ -> + Mina_metrics.( + Counter.inc Cryptography.snark_work_base_time_sec + (Time.Span.to_sec time)) ; ("fee_transfer", 1, 0) in - Mina_metrics.( - Gauge.set Cryptography.snark_work_base_time_sec - (Time.Span.to_sec time) ; - Gauge.set Cryptography.transaction_length - (Float.of_int parties_count) ; - Gauge.set Cryptography.zkapp_proof_updates - (Float.of_int proof_parties_count)) ; [%str_log info] (Base_snark_generated { time; transaction_type; parties_count; proof_parties_count } From 2a27f0294c06c3cf2941e5488160d445ac685b08 Mon Sep 17 00:00:00 2001 From: Serhii Shymkiv Date: Sun, 11 Sep 2022 15:30:31 +0300 Subject: [PATCH 101/144] Fix for Docker image Demo-mode (Develop). --- dockerfiles/auxiliary_entrypoints/01-run-demo.sh | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/dockerfiles/auxiliary_entrypoints/01-run-demo.sh b/dockerfiles/auxiliary_entrypoints/01-run-demo.sh index 92ed33ef1d4..2f187035f88 100755 --- a/dockerfiles/auxiliary_entrypoints/01-run-demo.sh +++ b/dockerfiles/auxiliary_entrypoints/01-run-demo.sh @@ -31,10 +31,7 @@ if [[ -n ${RUN_DEMO} ]]; then echo "Contents of config file ${MINA_CONFIG_FILE}:" cat "${MINA_CONFIG_FILE}" - MINA_TIME_OFFSET=${MINA_TIME_OFFSET:-0} - MINA_PRIVKEY_PASS=${MINA_PRIVKEY_PASS:-""} - - exec MINA_PRIVKEY_PASS mina daemon --generate-genesis-proof true --seed --demo-mode --proof-level none --config-dir ${MINA_CONFIG_DIR} --block-producer-pubkey ${PK} --run-snark-worker ${SNARK_PK} -insecure-rest-server $@ + exec MINA_PRIVKEY_PASS=${MINA_PRIVKEY_PASS:-""} MINA_TIME_OFFSET=${MINA_TIME_OFFSET:-0} mina daemon --generate-genesis-proof true --seed --demo-mode --proof-level none --config-dir ${MINA_CONFIG_DIR} --block-producer-pubkey ${PK} --run-snark-worker ${SNARK_PK} -insecure-rest-server $@ rc=$? echo "Exiting Mina demo." && exit $rc From a75cd833413eeb3696f441a467e900419338b30d Mon Sep 17 00:00:00 2001 From: Florian Date: Mon, 12 Sep 2022 14:30:30 +0200 Subject: [PATCH 102/144] bump snarkyjs --- src/lib/snarky_js_bindings/snarkyjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/snarky_js_bindings/snarkyjs b/src/lib/snarky_js_bindings/snarkyjs index 729a9869526..f5c144b91f2 160000 --- a/src/lib/snarky_js_bindings/snarkyjs +++ b/src/lib/snarky_js_bindings/snarkyjs @@ -1 +1 @@ -Subproject commit 729a98695268070d8e47d8e5a0eccfb4e640d511 +Subproject commit f5c144b91f2dea7bfecd16bf1a0e99445bba1593 From 98a25193523a1093f0d0f4c2f4a3b27c50a7dd05 Mon Sep 17 00:00:00 2001 From: Paul Steckler Date: Mon, 12 Sep 2022 09:27:03 -0700 Subject: [PATCH 103/144] revert snarkyjs --- src/lib/snarky_js_bindings/snarkyjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/snarky_js_bindings/snarkyjs b/src/lib/snarky_js_bindings/snarkyjs index f5c144b91f2..1afdcb46cb4 160000 --- a/src/lib/snarky_js_bindings/snarkyjs +++ b/src/lib/snarky_js_bindings/snarkyjs @@ -1 +1 @@ -Subproject commit f5c144b91f2dea7bfecd16bf1a0e99445bba1593 +Subproject commit 1afdcb46cb4d532caef8e233428441cb05140257 From 4eac063d2451a12b51dd5614282ec475aa26e388 Mon Sep 17 00:00:00 2001 From: Paul Steckler Date: Mon, 12 Sep 2022 10:35:08 -0700 Subject: [PATCH 104/144] wait for frontier loading twice --- .../test_executive/peers_reliability_test.ml | 18 ++++++------------ src/lib/integration_test_lib/wait_condition.ml | 8 ++------ 2 files changed, 8 insertions(+), 18 deletions(-) diff --git a/src/app/test_executive/peers_reliability_test.ml b/src/app/test_executive/peers_reliability_test.ml index ce6db360ff3..bd838cc115d 100644 --- a/src/app/test_executive/peers_reliability_test.ml +++ b/src/app/test_executive/peers_reliability_test.ml @@ -41,6 +41,10 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct let[@warning "-8"] [ node_a; node_b; node_c ] = Network.block_producers network in + (* witness the node_c frontier load on initialization *) + let%bind () = + wait_for t @@ Wait_condition.persisted_frontier_loaded node_c + in let%bind initial_connectivity_data = Util.fetch_connectivity_data ~logger all_nodes in @@ -153,18 +157,8 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct "%s started again, will now wait for this node to initialize" (Node.id node_c) ; let%bind () = wait_for t @@ Wait_condition.node_to_initialize node_c in - (* if frontier load events from the other nodes, which would be generated - on initialization, that will cause a failure here - - earlier testing did not detect such events on initialization - - if we never see such events, using the node is sufficient to identify - that the event is triggered by the restart of node_c - - a more exacting alternative would be to issue an event on frontier closing, and capture - its snarked ledger hash, and compare that when the load event occurs; but the wait - mechanism does not appear to allow returning data in the event, like such a hash; - it could be added + (* we've already waited for the loading of the node_c frontier on initialization + so the event here must be the frontier loading on the node_c restart *) let%bind () = wait_for t @@ Wait_condition.persisted_frontier_loaded node_c diff --git a/src/lib/integration_test_lib/wait_condition.ml b/src/lib/integration_test_lib/wait_condition.ml index 53d278c77f8..d21cf41cdae 100644 --- a/src/lib/integration_test_lib/wait_condition.ml +++ b/src/lib/integration_test_lib/wait_condition.ml @@ -270,13 +270,9 @@ struct (_frontier_loaded : Event_type.Persisted_frontier_loaded.t) = let event_node_id = Node.id event_node in let node_id = Node.id node in + Format.eprintf "EVENT NODE: %s DESIRED NODE: %s@." event_node_id node_id ; if String.equal event_node_id node_id then Predicate_passed - else - Predicate_failure - (Error.of_string - (sprintf - "Expected to load frontier for node %s, but got frontier for %s" - node_id event_node_id ) ) + else Predicate_continuation () in let soft_timeout_in_slots = 4 in { id = Persisted_frontier_loaded From b5e18e245b4f4829a733752949f0b525d0531dce Mon Sep 17 00:00:00 2001 From: Paul Steckler Date: Mon, 12 Sep 2022 11:01:49 -0700 Subject: [PATCH 105/144] address PR comments --- scripts/mina-local-network/README.md | 6 +++--- src/app/archive/archive_lib/extensional.ml | 2 +- src/lib/hash_prefixes/hash_prefixes.ml | 3 ++- src/lib/mina_net2/libp2p_stream.ml | 6 +++--- src/lib/string_sign/string_sign.ml | 3 +-- src/lib/zkapps_examples/add_events/zkapps_add_events.ml | 2 +- src/lib/zkapps_examples/zkapps_examples.ml | 2 +- 7 files changed, 12 insertions(+), 12 deletions(-) diff --git a/scripts/mina-local-network/README.md b/scripts/mina-local-network/README.md index f7b6e184995..cd2efd7856e 100644 --- a/scripts/mina-local-network/README.md +++ b/scripts/mina-local-network/README.md @@ -60,7 +60,7 @@ ## SnarkyJS and zkApps - Now, if you’d like to work with the `zkApps` locally, you need to update the `SnarkyJS` reference for your `zkApp` project (e.g. created using the `zkApp-CLI` like this: `zk project foo`). - - Suppose you’ve created `zkApp` at following path: + - Suppose you’ve created `zkApp` at following path: - `~/projcts/zkapps/foo` - Go to `zkApp` project root (☝️). - Remove old `SnarkyJS` Node Module: @@ -82,7 +82,7 @@ - [http://localhost:4001/graphql](http://localhost:4001/graphql) - [http://localhost:4006/graphql](http://localhost:4006/graphql) - Etc. - - Depending on you environment configuration (amount of zkapp_command, starting port of ranges, etc.) + - Depending on you environment configuration (number of zkApp commands, starting port of ranges, etc.) - You might want to get `encoded private key` instead of the raw data generated for you. You can do this using the following command: ```shell @@ -97,7 +97,7 @@ ``` - In order to start sending payments or anything else account related, you first need to import and unlock the account: - + ```shell _build/default/src/app/cli/src/mina.exe \ accounts import \ diff --git a/src/app/archive/archive_lib/extensional.ml b/src/app/archive/archive_lib/extensional.ml index 5743c7ae15c..45e48923264 100644 --- a/src/app/archive/archive_lib/extensional.ml +++ b/src/app/archive/archive_lib/extensional.ml @@ -72,7 +72,7 @@ module Internal_command = struct end] end -(* for fee payer, other zkapp_command, authorizations are omitted; signatures, proofs not in archive db *) +(* for fee payer and account updates, authorizations are omitted; signatures, proofs not in archive db *) module Zkapp_command = struct [%%versioned module Stable = struct diff --git a/src/lib/hash_prefixes/hash_prefixes.ml b/src/lib/hash_prefixes/hash_prefixes.ml index 353719923c7..f5a31218e18 100644 --- a/src/lib/hash_prefixes/hash_prefixes.ml +++ b/src/lib/hash_prefixes/hash_prefixes.ml @@ -50,7 +50,8 @@ let signature_mainnet = create "MinaSignatureMainnet" let receipt_chain_user_command = create "MinaReceiptUC" -let receipt_chain_zkapp = create "MinaReceiptZkapp" +(* leaving this one with "Coda", to preserve the existing hashes *) +let receipt_chain_zkapp = create "CodaReceiptZkapp" let epoch_seed = create "MinaEpochSeed" diff --git a/src/lib/mina_net2/libp2p_stream.ml b/src/lib/mina_net2/libp2p_stream.ml index 77e09f06cdf..dd44cf75b40 100644 --- a/src/lib/mina_net2/libp2p_stream.ml +++ b/src/lib/mina_net2/libp2p_stream.ml @@ -15,7 +15,7 @@ type state = | HalfClosed of participant (** Streams move from [FullyOpen] to [HalfClosed `Us] when the write pipe is closed. Streams move from [FullyOpen] to [HalfClosed `Them] when [Stream.reset] is called or the remote host closes their write stream. *) | FullyClosed - (** Streams move from [HalfClosed peer] to FullyClosed once the account_update that isn't peer has their "close write" event. Once a stream is FullyClosed, its resources are released. *) + (** Streams move from [HalfClosed peer] to FullyClosed once the party that isn't peer has their "close write" event. Once a stream is FullyClosed, its resources are released. *) [@@deriving equal, show] type t = @@ -97,10 +97,10 @@ let stream_closed ~logger ~who_closed t = if equal_participant who_closed Them then Pipe.close t.incoming_w ; let new_state = let log_double_close () = - [%log error] "stream with index $index closed twice by $account_update" + [%log error] "stream with index $index closed twice by $party" ~metadata: [ ("index", `String (Libp2p_ipc.stream_id_to_string t.id)) - ; ("account_update", `String (name_of_participant who_closed)) + ; ("party", `String (name_of_participant who_closed)) ] in match t.state with diff --git a/src/lib/string_sign/string_sign.ml b/src/lib/string_sign/string_sign.ml index c3598edc39a..3ee62d6aa78 100644 --- a/src/lib/string_sign/string_sign.ml +++ b/src/lib/string_sign/string_sign.ml @@ -77,8 +77,7 @@ let%test_module "Sign_string tests" = let%test "Sign, verify with default network" = let s = - "Now is the time for all good men to come to the aid of their \ - account_update" + "Now is the time for all good men to come to the aid of their party" in let signature = sign keypair.private_key s in verify signature keypair.public_key s diff --git a/src/lib/zkapps_examples/add_events/zkapps_add_events.ml b/src/lib/zkapps_examples/add_events/zkapps_add_events.ml index 015e5c343ba..a5ce3303f12 100644 --- a/src/lib/zkapps_examples/add_events/zkapps_add_events.ml +++ b/src/lib/zkapps_examples/add_events/zkapps_add_events.ml @@ -5,7 +5,7 @@ open Zkapps_examples let initialize public_key = Zkapps_examples.wrap_main (fun () -> - AccountUpdate_under_construction.In_circuit.create + Account_update_under_construction.In_circuit.create ~public_key:(Public_key.Compressed.var_of_t public_key) ~token_id:Token_id.(Checked.constant default) () ) diff --git a/src/lib/zkapps_examples/zkapps_examples.ml b/src/lib/zkapps_examples/zkapps_examples.ml index 04ce35990be..324c3f5053f 100644 --- a/src/lib/zkapps_examples/zkapps_examples.ml +++ b/src/lib/zkapps_examples/zkapps_examples.ml @@ -5,7 +5,7 @@ open Currency open Signature_lib open Mina_base -module AccountUpdate_under_construction = struct +module Account_update_under_construction = struct module Account_condition = struct type t = { state_proved : bool option } From 27c7e58df1afb692f575663688af1e21feb874df Mon Sep 17 00:00:00 2001 From: Paul Steckler Date: Mon, 12 Sep 2022 11:10:13 -0700 Subject: [PATCH 106/144] more Account_update_under_construction renames --- .../add_events/zkapps_add_events.ml | 4 +-- .../empty_update/zkapps_empty_update.ml | 8 ++--- .../zkapps_initialize_state.ml | 32 +++++++++---------- .../sequence_events/zkapps_sequence_events.ml | 6 ++-- src/lib/zkapps_examples/zkapps_examples.ml | 6 ++-- 5 files changed, 28 insertions(+), 28 deletions(-) diff --git a/src/lib/zkapps_examples/add_events/zkapps_add_events.ml b/src/lib/zkapps_examples/add_events/zkapps_add_events.ml index a5ce3303f12..343c8fd484e 100644 --- a/src/lib/zkapps_examples/add_events/zkapps_add_events.ml +++ b/src/lib/zkapps_examples/add_events/zkapps_add_events.ml @@ -28,7 +28,7 @@ let event_length = 7 let update_events public_key = Zkapps_examples.wrap_main (fun () -> let account_update = - AccountUpdate_under_construction.In_circuit.create + Account_update_under_construction.In_circuit.create ~public_key:(Public_key.Compressed.var_of_t public_key) ~token_id:Token_id.(Checked.constant default) () @@ -39,7 +39,7 @@ let update_events public_key = (Typ.list ~length:num_events (Typ.array ~length:event_length Field.typ) ) in - AccountUpdate_under_construction.In_circuit.add_events events + Account_update_under_construction.In_circuit.add_events events account_update ) let initialize_rule public_key : _ Pickles.Inductive_rule.t = diff --git a/src/lib/zkapps_examples/empty_update/zkapps_empty_update.ml b/src/lib/zkapps_examples/empty_update/zkapps_empty_update.ml index 727d367c409..b024637c029 100644 --- a/src/lib/zkapps_examples/empty_update/zkapps_empty_update.ml +++ b/src/lib/zkapps_examples/empty_update/zkapps_empty_update.ml @@ -7,7 +7,7 @@ open Zkapps_examples *) let main public_key = Zkapps_examples.wrap_main (fun () -> - AccountUpdate_under_construction.In_circuit.create + Account_update_under_construction.In_circuit.create ~public_key:(Public_key.Compressed.var_of_t public_key) ~token_id:Token_id.(Checked.constant default) () ) @@ -23,6 +23,6 @@ let rule public_key : _ Pickles.Inductive_rule.t = value. *) let generate_account_update public_key = - AccountUpdate_under_construction.create ~public_key ~token_id:Token_id.default - () - |> AccountUpdate_under_construction.to_account_update + Account_update_under_construction.create ~public_key + ~token_id:Token_id.default () + |> Account_update_under_construction.to_account_update diff --git a/src/lib/zkapps_examples/initialize_state/zkapps_initialize_state.ml b/src/lib/zkapps_examples/initialize_state/zkapps_initialize_state.ml index 9fb16bb10e5..ed3e4a8d993 100644 --- a/src/lib/zkapps_examples/initialize_state/zkapps_initialize_state.ml +++ b/src/lib/zkapps_examples/initialize_state/zkapps_initialize_state.ml @@ -19,7 +19,7 @@ let initial_state = let initialize public_key = Zkapps_examples.wrap_main (fun () -> let account_update = - AccountUpdate_under_construction.In_circuit.create + Account_update_under_construction.In_circuit.create ~public_key:(Public_key.Compressed.var_of_t public_key) ~token_id:Token_id.(Checked.constant default) () @@ -28,8 +28,8 @@ let initialize public_key = List.map ~f:Field.constant (Lazy.force initial_state) in account_update - |> AccountUpdate_under_construction.In_circuit.assert_state_unproved - |> AccountUpdate_under_construction.In_circuit.set_full_state + |> Account_update_under_construction.In_circuit.assert_state_unproved + |> Account_update_under_construction.In_circuit.set_full_state initial_state ) type _ Snarky_backendless.Request.t += @@ -46,7 +46,7 @@ let update_state_handler (new_state : Field.Constant.t list) let update_state public_key = Zkapps_examples.wrap_main (fun () -> let account_update = - AccountUpdate_under_construction.In_circuit.create + Account_update_under_construction.In_circuit.create ~public_key:(Public_key.Compressed.var_of_t public_key) ~token_id:Token_id.(Checked.constant default) () @@ -55,8 +55,8 @@ let update_state public_key = exists (Typ.list ~length:8 Field.typ) ~request:(fun () -> New_state) in account_update - |> AccountUpdate_under_construction.In_circuit.assert_state_proved - |> AccountUpdate_under_construction.In_circuit.set_full_state new_state ) + |> Account_update_under_construction.In_circuit.assert_state_proved + |> Account_update_under_construction.In_circuit.set_full_state new_state ) let initialize_rule public_key : _ Pickles.Inductive_rule.t = { identifier = "Initialize snapp" @@ -73,15 +73,15 @@ let update_state_rule public_key : _ Pickles.Inductive_rule.t = } let generate_initialize_account_update public_key = - AccountUpdate_under_construction.create ~public_key ~token_id:Token_id.default - () - |> AccountUpdate_under_construction.assert_state_unproved - |> AccountUpdate_under_construction.set_full_state (Lazy.force initial_state) - |> AccountUpdate_under_construction.to_account_update + Account_update_under_construction.create ~public_key + ~token_id:Token_id.default () + |> Account_update_under_construction.assert_state_unproved + |> Account_update_under_construction.set_full_state (Lazy.force initial_state) + |> Account_update_under_construction.to_account_update let generate_update_state_account_update public_key new_state = - AccountUpdate_under_construction.create ~public_key ~token_id:Token_id.default - () - |> AccountUpdate_under_construction.assert_state_proved - |> AccountUpdate_under_construction.set_full_state new_state - |> AccountUpdate_under_construction.to_account_update + Account_update_under_construction.create ~public_key + ~token_id:Token_id.default () + |> Account_update_under_construction.assert_state_proved + |> Account_update_under_construction.set_full_state new_state + |> Account_update_under_construction.to_account_update diff --git a/src/lib/zkapps_examples/sequence_events/zkapps_sequence_events.ml b/src/lib/zkapps_examples/sequence_events/zkapps_sequence_events.ml index 1d177ffda87..cdeee5ea60a 100644 --- a/src/lib/zkapps_examples/sequence_events/zkapps_sequence_events.ml +++ b/src/lib/zkapps_examples/sequence_events/zkapps_sequence_events.ml @@ -5,7 +5,7 @@ open Zkapps_examples let initialize public_key = Zkapps_examples.wrap_main (fun () -> - AccountUpdate_under_construction.In_circuit.create + Account_update_under_construction.In_circuit.create ~public_key:(Public_key.Compressed.var_of_t public_key) ~token_id:Token_id.(Checked.constant default) () ) @@ -30,7 +30,7 @@ let event_length = 13 let update_sequence_events public_key = Zkapps_examples.wrap_main (fun () -> let account_update = - AccountUpdate_under_construction.In_circuit.create + Account_update_under_construction.In_circuit.create ~public_key:(Public_key.Compressed.var_of_t public_key) ~token_id:Token_id.(Checked.constant default) () @@ -41,7 +41,7 @@ let update_sequence_events public_key = (Typ.list ~length:num_events (Typ.array ~length:event_length Field.typ) ) in - AccountUpdate_under_construction.In_circuit.add_sequence_events + Account_update_under_construction.In_circuit.add_sequence_events sequence_events account_update ) let initialize_rule public_key : _ Pickles.Inductive_rule.t = diff --git a/src/lib/zkapps_examples/zkapps_examples.ml b/src/lib/zkapps_examples/zkapps_examples.ml index 324c3f5053f..35d486d7de9 100644 --- a/src/lib/zkapps_examples/zkapps_examples.ml +++ b/src/lib/zkapps_examples/zkapps_examples.ml @@ -503,7 +503,7 @@ let to_account_update account_update : Zkapp_statement.Checked.t * return_type Prover_value.t = dummy_constraints () ; let account_update, calls = - AccountUpdate_under_construction.In_circuit.to_account_update_and_calls + Account_update_under_construction.In_circuit.to_account_update_and_calls account_update in let account_update_digest = @@ -567,7 +567,7 @@ let compile : , heightss , unit , unit - , AccountUpdate_under_construction.In_circuit.t + , Account_update_under_construction.In_circuit.t , unit (* TODO: Remove? *) , auxiliary_var , auxiliary_value ) @@ -606,7 +606,7 @@ let compile : , heightss , unit , unit - , AccountUpdate_under_construction.In_circuit.t + , Account_update_under_construction.In_circuit.t , unit , auxiliary_var , auxiliary_value ) From ee2ac51b6773a4e9551dbe92a3fe8ada9bfa3a96 Mon Sep 17 00:00:00 2001 From: Paul Steckler Date: Mon, 12 Sep 2022 11:48:36 -0700 Subject: [PATCH 107/144] post-merge format --- src/lib/mina_base/zkapp_call_forest.ml | 32 +++++++++++----- .../test/zkapp_fuzzy/zkapp_fuzzy.ml | 4 +- .../zkapps_initialize_state.ml | 6 ++- src/lib/zkapps_examples/zkapps_examples.ml | 38 +++++++++++++------ 4 files changed, 54 insertions(+), 26 deletions(-) diff --git a/src/lib/mina_base/zkapp_call_forest.ml b/src/lib/mina_base/zkapp_call_forest.ml index 195cdf23cbf..2a47b625e9f 100644 --- a/src/lib/mina_base/zkapp_call_forest.ml +++ b/src/lib/mina_base/zkapp_call_forest.ml @@ -7,7 +7,8 @@ type t = , Zkapp_command.Digest.Forest.t ) Zkapp_command.Call_forest.t -type account_update = (Account_update.t, Zkapp_command.Digest.Account_update.t) With_hash.t +type account_update = + (Account_update.t, Zkapp_command.Digest.Account_update.t) With_hash.t let empty () = [] @@ -44,29 +45,40 @@ module Checked = struct } let account_update_typ () : - (account_update, (Account_update.t, Zkapp_command.Digest.Account_update.t) With_hash.t) Typ.t = + ( account_update + , (Account_update.t, Zkapp_command.Digest.Account_update.t) With_hash.t + ) + Typ.t = let (Typ typ) = - Typ.(Account_update.Body.typ () * Prover_value.typ () * Zkapp_command.Digest.Account_update.typ) + Typ.( + Account_update.Body.typ () * Prover_value.typ () + * Zkapp_command.Digest.Account_update.typ) |> Typ.transport ~back:(fun ((body, authorization), hash) -> - { With_hash.data = { Account_update.body; authorization }; hash } ) - ~there:(fun { With_hash.data = { Account_update.body; authorization }; hash } -> - ((body, authorization), hash) ) + { With_hash.data = { Account_update.body; authorization }; hash } + ) + ~there:(fun { With_hash.data = { Account_update.body; authorization } + ; hash + } -> ((body, authorization), hash) ) |> Typ.transport_var ~back:(fun ((account_update, control), hash) -> { account_update = { hash; data = account_update }; control } ) - ~there:(fun { account_update = { hash; data = account_update }; control } -> - ((account_update, control), hash) ) + ~there:(fun { account_update = { hash; data = account_update } + ; control + } -> ((account_update, control), hash) ) in Typ { typ with check = - (fun ({ account_update = { hash; data = account_update }; control = _ } as x) -> + (fun ( { account_update = { hash; data = account_update } + ; control = _ + } as x ) -> make_checked (fun () -> run_checked (typ.check x) ; Field.Assert.equal (hash :> Field.t) - ( Zkapp_command.Call_forest.Digest.Account_update.Checked.create account_update + ( Zkapp_command.Call_forest.Digest.Account_update.Checked + .create account_update :> Field.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 93c1d2118d4..fb7ed415ad7 100644 --- a/src/lib/transaction_snark/test/zkapp_fuzzy/zkapp_fuzzy.ml +++ b/src/lib/transaction_snark/test/zkapp_fuzzy/zkapp_fuzzy.ml @@ -91,8 +91,8 @@ let mk_ledgers_and_fee_payers ?(is_timed = false) ~num_of_fee_payers () = in (ledger, fee_payer_keypairs, keymap) -let generate_zkapp_commands_and_apply_them_consecutively ~trials ~max_account_updates () - = +let generate_zkapp_commands_and_apply_them_consecutively ~trials + ~max_account_updates () = let num_of_fee_payers = 5 in let ledger, fee_payer_keypairs, keymap = mk_ledgers_and_fee_payers ~num_of_fee_payers () diff --git a/src/lib/zkapps_examples/initialize_state/zkapps_initialize_state.ml b/src/lib/zkapps_examples/initialize_state/zkapps_initialize_state.ml index 303300427f7..e5c425dd3ca 100644 --- a/src/lib/zkapps_examples/initialize_state/zkapps_initialize_state.ml +++ b/src/lib/zkapps_examples/initialize_state/zkapps_initialize_state.ml @@ -6,7 +6,8 @@ let initial_state = lazy (List.init 8 ~f:(fun _ -> Field.Constant.zero)) let initialize public_key = Zkapps_examples.wrap_main - ~public_key:(Public_key.Compressed.var_of_t public_key) (fun account_update -> + ~public_key:(Public_key.Compressed.var_of_t public_key) + (fun account_update -> let initial_state = List.map ~f:Field.constant (Lazy.force initial_state) in @@ -26,7 +27,8 @@ let update_state_handler (new_state : Field.Constant.t list) let update_state public_key = Zkapps_examples.wrap_main - ~public_key:(Public_key.Compressed.var_of_t public_key) (fun account_update -> + ~public_key:(Public_key.Compressed.var_of_t public_key) + (fun account_update -> let new_state = exists (Typ.list ~length:8 Field.typ) ~request:(fun () -> New_state) in diff --git a/src/lib/zkapps_examples/zkapps_examples.ml b/src/lib/zkapps_examples/zkapps_examples.ml index 44357a3b432..2db6c08de10 100644 --- a/src/lib/zkapps_examples/zkapps_examples.ml +++ b/src/lib/zkapps_examples/zkapps_examples.ml @@ -184,7 +184,9 @@ module Account_update_under_construction = struct ; account_condition : Account_condition.t ; update : Update.t ; rev_calls : - (Zkapp_call_forest.Checked.account_update * Zkapp_call_forest.Checked.t) list + ( Zkapp_call_forest.Checked.account_update + * Zkapp_call_forest.Checked.t ) + list ; call_data : Field.t option ; events : Events.t ; sequence_events : Sequence_events.t @@ -306,36 +308,48 @@ end class account_update ~public_key ?token_id = object val mutable account_update = - Account_update_under_construction.In_circuit.create ~public_key ?token_id () + Account_update_under_construction.In_circuit.create ~public_key ?token_id + () method assert_state_proved = - account_update <- Account_update_under_construction.In_circuit.assert_state_proved account_update + account_update <- + Account_update_under_construction.In_circuit.assert_state_proved + account_update method assert_state_unproved = - account_update <- Account_update_under_construction.In_circuit.assert_state_unproved account_update + account_update <- + Account_update_under_construction.In_circuit.assert_state_unproved + account_update method set_state idx data = - account_update <- Account_update_under_construction.In_circuit.set_state idx data account_update + account_update <- + Account_update_under_construction.In_circuit.set_state idx data + account_update method set_full_state app_state = account_update <- - Account_update_under_construction.In_circuit.set_full_state app_state account_update + Account_update_under_construction.In_circuit.set_full_state app_state + account_update method set_call_data call_data = - account_update <- Account_update_under_construction.In_circuit.set_call_data call_data account_update + account_update <- + Account_update_under_construction.In_circuit.set_call_data call_data + account_update method register_call called_account_update sub_calls = account_update <- - Account_update_under_construction.In_circuit.register_call called_account_update sub_calls - account_update + Account_update_under_construction.In_circuit.register_call + called_account_update sub_calls account_update method add_events events = - account_update <- Account_update_under_construction.In_circuit.add_events events account_update + account_update <- + Account_update_under_construction.In_circuit.add_events events + account_update method add_sequence_events sequence_events = account_update <- - Account_update_under_construction.In_circuit.add_sequence_events sequence_events - account_update + Account_update_under_construction.In_circuit.add_sequence_events + sequence_events account_update method account_update_under_construction = account_update end From a1a79521abedbfcf058c150487043b8f499153bd Mon Sep 17 00:00:00 2001 From: Paul Steckler Date: Mon, 12 Sep 2022 12:00:14 -0700 Subject: [PATCH 108/144] log node ids --- src/app/test_executive/peers_reliability_test.ml | 4 ++-- src/lib/integration_test_lib/wait_condition.ml | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/app/test_executive/peers_reliability_test.ml b/src/app/test_executive/peers_reliability_test.ml index bd838cc115d..881fa41f62b 100644 --- a/src/app/test_executive/peers_reliability_test.ml +++ b/src/app/test_executive/peers_reliability_test.ml @@ -37,7 +37,6 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct ~metadata: [ ("peers", `List (List.map all_nodes ~f:(fun n -> `String (Node.id n)))) ] ; - let%bind () = wait_for t (Wait_condition.nodes_to_initialize all_nodes) in let[@warning "-8"] [ node_a; node_b; node_c ] = Network.block_producers network in @@ -45,6 +44,7 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct let%bind () = wait_for t @@ Wait_condition.persisted_frontier_loaded node_c in + let%bind () = wait_for t (Wait_condition.nodes_to_initialize all_nodes) in let%bind initial_connectivity_data = Util.fetch_connectivity_data ~logger all_nodes in @@ -156,13 +156,13 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct [%log info] "%s started again, will now wait for this node to initialize" (Node.id node_c) ; - let%bind () = wait_for t @@ Wait_condition.node_to_initialize node_c in (* we've already waited for the loading of the node_c frontier on initialization so the event here must be the frontier loading on the node_c restart *) let%bind () = wait_for t @@ Wait_condition.persisted_frontier_loaded node_c in + let%bind () = wait_for t @@ Wait_condition.node_to_initialize node_c in wait_for t ( Wait_condition.nodes_to_synchronize [ node_a; node_b; node_c ] |> Wait_condition.with_timeouts diff --git a/src/lib/integration_test_lib/wait_condition.ml b/src/lib/integration_test_lib/wait_condition.ml index d21cf41cdae..0e21943e338 100644 --- a/src/lib/integration_test_lib/wait_condition.ml +++ b/src/lib/integration_test_lib/wait_condition.ml @@ -270,7 +270,8 @@ struct (_frontier_loaded : Event_type.Persisted_frontier_loaded.t) = let event_node_id = Node.id event_node in let node_id = Node.id node in - Format.eprintf "EVENT NODE: %s DESIRED NODE: %s@." event_node_id node_id ; + let logger = Logger.create () in + [%log info] "EVENT NODE: %s DESIRED NODE: %s@." event_node_id node_id ; if String.equal event_node_id node_id then Predicate_passed else Predicate_continuation () in From fa65c534458519ed0410db6bcba4b8c895d15261 Mon Sep 17 00:00:00 2001 From: Paul Steckler Date: Mon, 12 Sep 2022 12:55:10 -0700 Subject: [PATCH 109/144] more name fixes --- .../test/zkapps_examples/calls/calls.ml | 97 +++++++++++-------- src/lib/zkapps_examples/calls/zkapps_calls.ml | 45 ++++----- src/lib/zkapps_examples/zkapps_examples.ml | 4 + 3 files changed, 81 insertions(+), 65 deletions(-) diff --git a/src/lib/transaction_snark/test/zkapps_examples/calls/calls.ml b/src/lib/transaction_snark/test/zkapps_examples/calls/calls.ml index 51a0fb5cea3..8063e909bbb 100644 --- a/src/lib/transaction_snark/test/zkapps_examples/calls/calls.ml +++ b/src/lib/transaction_snark/test/zkapps_examples/calls/calls.ml @@ -6,7 +6,7 @@ module Impl = Pickles.Impls.Step module Inner_curve = Snark_params.Tick.Inner_curve module Nat = Pickles_types.Nat module Local_state = Mina_state.Local_state -module Parties_segment = Transaction_snark.Parties_segment +module Zkapp_command_segment = Transaction_snark.Zkapp_command_segment module Statement = Transaction_snark.Statement let%test_module "Composability test" = @@ -90,12 +90,12 @@ let%test_module "Composability test" = let vk = Pickles.Side_loaded.Verification_key.of_compiled tag - module Deploy_party = struct - let party_body : Party.Body.t = - { Party.Body.dummy with + module Deploy_account_update = struct + let account_update_body : Account_update.Body.t = + { Account_update.Body.dummy with public_key = pk_compressed ; update = - { Party.Update.dummy with + { Account_update.Update.dummy with verification_key = Set { data = vk @@ -122,29 +122,31 @@ let%test_module "Composability test" = } ; use_full_commitment = true ; preconditions = - { Party.Preconditions.network = + { Account_update.Preconditions.network = Zkapp_precondition.Protocol_state.accept ; account = Accept } } - let party : Party.t = + let account_update : Account_update.t = (* TODO: This is a pain. *) - { body = party_body; authorization = Signature Signature.dummy } + { body = account_update_body + ; authorization = Signature Signature.dummy + } end - module Initialize_party = struct - let party, _ = + module Initialize_account_update = struct + let account_update, _ = Async.Thread_safe.block_on_async_exn (initialize_prover ~handler: (Zkapps_calls.Rules.Initialize_state.handler pk_compressed) ) end - module Update_state_party = struct + module Update_state_account_update = struct let old_state = Snark_params.Tick.Field.zero - (** The request handler to use when running this party. + (** The request handler to use when running this account_update. This handler accepts a [calls_kind] and fills in the [Execute_call] handlers with either the 'add' prover or the 'add-and-call' prover, @@ -157,7 +159,7 @@ let%test_module "Composability test" = let handler (calls_kind : calls_kind) old_state = let rec make_call calls_kind input : Zkapps_calls.Call_data.Output.Constant.t - * Zkapp_call_forest.party + * Zkapp_call_forest.account_update * Zkapp_call_forest.t = match calls_kind with | Add increase_amount -> @@ -170,7 +172,9 @@ let%test_module "Composability test" = Async.Thread_safe.block_on_async_exn (add_prover ~handler) in ( Option.value_exn aux - , { data = tree.party; hash = tree.party_digest } + , { data = tree.account_update + ; hash = tree.account_update_digest + } , tree.calls ) | Add_and_call (increase_amount, calls_kind) -> (* Execute the 'add-and-call' rule *) @@ -188,28 +192,32 @@ let%test_module "Composability test" = (add_and_call_prover ~handler) in ( Option.value_exn aux - , { data = tree.party; hash = tree.party_digest } + , { data = tree.account_update + ; hash = tree.account_update_digest + } , tree.calls ) in Zkapps_calls.Rules.Update_state.handler pk_compressed old_state (make_call calls_kind) - let party calls_kind = + let account_update calls_kind = Async.Thread_safe.block_on_async_exn (update_state_call_prover ~handler:(handler calls_kind old_state)) |> fst end - let test_parties ?expected_failure parties = + let test_zkapp_command ?expected_failure zkapp_command = let memo = Signed_command_memo.empty in - let transaction_commitment : Parties.Transaction_commitment.t = + let transaction_commitment : Zkapp_command.Transaction_commitment.t = (* TODO: This is a pain. *) - let other_parties_hash = Parties.Call_forest.hash parties in - Parties.Transaction_commitment.create ~other_parties_hash + let account_updates_hash = + Zkapp_command.Call_forest.hash zkapp_command + in + Zkapp_command.Transaction_commitment.create ~account_updates_hash in - let fee_payer : Party.Fee_payer.t = + let fee_payer : Account_update.Fee_payer.t = { body = - { Party.Body.Fee_payer.dummy with + { Account_update.Body.Fee_payer.dummy with public_key = pk_compressed ; fee = Currency.Fee.(of_int 100) } @@ -218,14 +226,14 @@ let%test_module "Composability test" = in let memo_hash = Signed_command_memo.hash memo in let full_commitment = - Parties.Transaction_commitment.create_complete transaction_commitment - ~memo_hash + Zkapp_command.Transaction_commitment.create_complete + transaction_commitment ~memo_hash ~fee_payer_hash: - (Parties.Call_forest.Digest.Party.create - (Party.of_fee_payer fee_payer) ) + (Zkapp_command.Call_forest.Digest.Account_update.create + (Account_update.of_fee_payer fee_payer) ) in - let sign_all ({ fee_payer; other_parties; memo } : Parties.t) : Parties.t - = + let sign_all ({ fee_payer; account_updates; memo } : Zkapp_command.t) : + Zkapp_command.t = let fee_payer = match fee_payer with | { body = { public_key; _ }; _ } @@ -238,30 +246,30 @@ let%test_module "Composability test" = | fee_payer -> fee_payer in - let other_parties = - Parties.Call_forest.map other_parties ~f:(function + let account_updates = + Zkapp_command.Call_forest.map account_updates ~f:(function | ({ body = { public_key; use_full_commitment; _ } ; authorization = Signature _ - } as party : - Party.t ) + } as account_update : + Account_update.t ) when Public_key.Compressed.equal public_key pk_compressed -> let commitment = if use_full_commitment then full_commitment else transaction_commitment in - { party with + { account_update with authorization = Signature (Schnorr.Chunked.sign sk (Random_oracle.Input.Chunked.field commitment) ) } - | party -> - party ) + | account_update -> + account_update ) in - { fee_payer; other_parties; memo } + { fee_payer; account_updates; memo } in - let parties : Parties.t = - sign_all { fee_payer; other_parties = parties; memo } + let zkapp_command : Zkapp_command.t = + sign_all { fee_payer; account_updates = zkapp_command; memo } in Ledger.with_ledger ~depth:ledger_depth ~f:(fun ledger -> let account = @@ -274,7 +282,8 @@ let%test_module "Composability test" = |> Or_error.ok_exn in Async.Thread_safe.block_on_async_exn (fun () -> - check_parties_with_merges_exn ?expected_failure ledger [ parties ] ) ; + check_zkapp_command_with_merges_exn ?expected_failure ledger + [ zkapp_command ] ) ; Ledger.get ledger loc ) let test_recursive num_calls = @@ -294,10 +303,12 @@ let%test_module "Composability test" = in let account = [] - |> Parties.Call_forest.cons_tree (Update_state_party.party calls_kind) - |> Parties.Call_forest.cons_tree Initialize_party.party - |> Parties.Call_forest.cons Deploy_party.party - |> test_parties + |> Zkapp_command.Call_forest.cons_tree + (Update_state_account_update.account_update calls_kind) + |> Zkapp_command.Call_forest.cons_tree + Initialize_account_update.account_update + |> Zkapp_command.Call_forest.cons Deploy_account_update.account_update + |> test_zkapp_command in let (first_state :: zkapp_state) = (Option.value_exn (Option.value_exn account).zkapp).app_state diff --git a/src/lib/zkapps_examples/calls/zkapps_calls.ml b/src/lib/zkapps_examples/calls/zkapps_calls.ml index e8beada9c30..3f9f406bb09 100644 --- a/src/lib/zkapps_examples/calls/zkapps_calls.ml +++ b/src/lib/zkapps_examples/calls/zkapps_calls.ml @@ -120,34 +120,35 @@ type _ Snarky_backendless.Request.t += | Execute_call : Call_data.Input.Constant.t -> ( Call_data.Output.Constant.t - * Zkapp_call_forest.party + * Zkapp_call_forest.account_update * Zkapp_call_forest.t ) Snarky_backendless.Request.t (** Helper function for executing zkApp calls. - The particular details of the called party are determined by the handler + The particular details of the called account update are determined by the handler for the [Execute_call] request. *) -let execute_call party old_state = +let execute_call account_update old_state = let call_inputs = { Call_data.Input.Circuit.old_state } in - let call_outputs, called_party, sub_calls = + let call_outputs, called_account_update, sub_calls = exists (Typ.tuple3 Call_data.Output.typ - (Zkapp_call_forest.Checked.party_typ ()) + (Zkapp_call_forest.Checked.account_update_typ ()) Zkapp_call_forest.typ ) ~request:(fun () -> let input = As_prover.read Call_data.Input.typ call_inputs in Execute_call input ) in let () = - (* Check that previous party's call data is consistent. *) + (* Check that previous account update's call data is consistent. *) let call_data_digest = Call_data.Circuit.digest { input = call_inputs; output = call_outputs } in - Field.Assert.equal call_data_digest called_party.party.data.call_data + Field.Assert.equal call_data_digest + called_account_update.account_update.data.call_data in - party#register_call called_party sub_calls ; + account_update#register_call called_account_update sub_calls ; call_outputs.new_state module Rules = struct @@ -176,12 +177,12 @@ module Rules = struct exists Public_key.Compressed.typ ~request:(fun () -> Public_key) in Zkapps_examples.wrap_main ~public_key - (fun party -> + (fun account_update -> let initial_state = List.map ~f:Field.constant (Lazy.force initial_state) in - party#assert_state_unproved ; - party#set_full_state initial_state ; + account_update#assert_state_unproved ; + account_update#set_full_state initial_state ; None ) input @@ -205,7 +206,7 @@ module Rules = struct (execute_call : Call_data.Input.Constant.t -> Call_data.Output.Constant.t - * Zkapp_call_forest.party + * Zkapp_call_forest.account_update * Zkapp_call_forest.t ) (Snarky_backendless.Request.With { request; respond }) = match request with @@ -223,11 +224,11 @@ module Rules = struct exists Public_key.Compressed.typ ~request:(fun () -> Public_key) in Zkapps_examples.wrap_main ~public_key - (fun party -> + (fun account_update -> let old_state = exists Field.typ ~request:(fun () -> Old_state) in - let new_state = execute_call party old_state in - party#assert_state_proved ; - party#set_state 0 new_state ; + let new_state = execute_call account_update old_state in + account_update#assert_state_proved ; + account_update#set_state 0 new_state ; None ) input @@ -270,7 +271,7 @@ module Rules = struct exists Public_key.Compressed.typ ~request:(fun () -> Public_key) in Zkapps_examples.wrap_main ~public_key - (fun party -> + (fun account_update -> let input = exists Call_data.Input.typ ~request:(fun () -> Get_call_input) in @@ -283,7 +284,7 @@ module Rules = struct let new_state = Field.add input.old_state increase_amount in let output = { Call_data.Output.Circuit.blinding_value; new_state } in let call_data_digest = Call_data.Circuit.digest { input; output } in - party#set_call_data call_data_digest ; + account_update#set_call_data call_data_digest ; Some output ) input @@ -316,7 +317,7 @@ module Rules = struct (execute_call : Call_data.Input.Constant.t -> Call_data.Output.Constant.t - * Zkapp_call_forest.party + * Zkapp_call_forest.account_update * Zkapp_call_forest.t ) (Snarky_backendless.Request.With { request; respond }) = match request with @@ -336,7 +337,7 @@ module Rules = struct exists Public_key.Compressed.typ ~request:(fun () -> Public_key) in Zkapps_examples.wrap_main ~public_key - (fun party -> + (fun account_update -> let ({ Call_data.Input.Circuit.old_state } as call_inputs) = exists Call_data.Input.typ ~request:(fun () -> Get_call_input) in @@ -347,7 +348,7 @@ module Rules = struct exists Field.typ ~request:(fun () -> Increase_amount) in let intermediate_state = Field.add old_state increase_amount in - let new_state = execute_call party intermediate_state in + let new_state = execute_call account_update intermediate_state in let call_outputs = { Call_data.Output.Circuit.blinding_value; new_state } in @@ -355,7 +356,7 @@ module Rules = struct Call_data.Circuit.digest { input = call_inputs; output = call_outputs } in - party#set_call_data call_data_hash ; + account_update#set_call_data call_data_hash ; Some call_outputs ) input diff --git a/src/lib/zkapps_examples/zkapps_examples.ml b/src/lib/zkapps_examples/zkapps_examples.ml index 2db6c08de10..6f827a2fd00 100644 --- a/src/lib/zkapps_examples/zkapps_examples.ml +++ b/src/lib/zkapps_examples/zkapps_examples.ml @@ -395,6 +395,10 @@ let to_account_update (account_update : account_update) : Account_update_under_construction.In_circuit.to_account_update_and_calls account_update#account_update_under_construction in + let account_update_digest = + Zkapp_command.Call_forest.Digest.Account_update.Checked.create + account_update + in let public_output : Zkapp_statement.Checked.t = { account_update = (account_update_digest :> Field.t) ; calls = (Zkapp_call_forest.Checked.hash calls :> Field.t) From 12059e64423d34af8fd2a90cd79f9e5e02627f4b Mon Sep 17 00:00:00 2001 From: Paul Steckler Date: Mon, 12 Sep 2022 13:05:59 -0700 Subject: [PATCH 110/144] rm debug code --- src/app/test_executive/peers_reliability_test.ml | 2 +- src/lib/integration_test_lib/wait_condition.ml | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/app/test_executive/peers_reliability_test.ml b/src/app/test_executive/peers_reliability_test.ml index 881fa41f62b..f8c796ac225 100644 --- a/src/app/test_executive/peers_reliability_test.ml +++ b/src/app/test_executive/peers_reliability_test.ml @@ -156,7 +156,7 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct [%log info] "%s started again, will now wait for this node to initialize" (Node.id node_c) ; - (* we've already waited for the loading of the node_c frontier on initialization + (* we've witnessed the loading of the node_c frontier on initialization so the event here must be the frontier loading on the node_c restart *) let%bind () = diff --git a/src/lib/integration_test_lib/wait_condition.ml b/src/lib/integration_test_lib/wait_condition.ml index 0e21943e338..631fb451ee1 100644 --- a/src/lib/integration_test_lib/wait_condition.ml +++ b/src/lib/integration_test_lib/wait_condition.ml @@ -270,8 +270,6 @@ struct (_frontier_loaded : Event_type.Persisted_frontier_loaded.t) = let event_node_id = Node.id event_node in let node_id = Node.id node in - let logger = Logger.create () in - [%log info] "EVENT NODE: %s DESIRED NODE: %s@." event_node_id node_id ; if String.equal event_node_id node_id then Predicate_passed else Predicate_continuation () in From afa493b4527b85d1991ad8dfab2bdc781db38597 Mon Sep 17 00:00:00 2001 From: Paul Steckler Date: Mon, 12 Sep 2022 17:02:58 -0700 Subject: [PATCH 111/144] fix test exec build --- src/app/test_executive/peers_reliability_test.ml | 6 +++--- src/lib/integration_test_lib/intf.ml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/app/test_executive/peers_reliability_test.ml b/src/app/test_executive/peers_reliability_test.ml index f8c796ac225..8e79acdc8a6 100644 --- a/src/app/test_executive/peers_reliability_test.ml +++ b/src/app/test_executive/peers_reliability_test.ml @@ -76,11 +76,11 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct in let zkapp_account_keypair = Signature_lib.Keypair.create () in let%bind () = - let wait_for_zkapp parties = + let wait_for_zkapp zkapp_command = let%map () = wait_for t @@ Wait_condition.zkapp_to_be_included_in_frontier ~has_failures:false - ~parties + ~zkapp_command in [%log info] "ZkApp transaction included in transition frontier" in @@ -105,7 +105,7 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct ; zkapp_account_keypairs = [ zkapp_account_keypair ] ; memo ; new_zkapp_account = true - ; snapp_update = Mina_base.Party.Update.dummy + ; snapp_update = Mina_base.Account_update.Update.dummy ; current_auth = Mina_base.Permissions.Auth_required.Signature ; call_data = Snark_params.Tick.Field.zero ; events = [] diff --git a/src/lib/integration_test_lib/intf.ml b/src/lib/integration_test_lib/intf.ml index bc218969490..50cd9faf01e 100644 --- a/src/lib/integration_test_lib/intf.ml +++ b/src/lib/integration_test_lib/intf.ml @@ -383,7 +383,7 @@ module Dsl = struct val ledger_proofs_emitted_since_genesis : num_proofs:int -> t val zkapp_to_be_included_in_frontier : - has_failures:bool -> parties:Mina_base.Zkapp_command.t -> t + has_failures:bool -> zkapp_command:Mina_base.Zkapp_command.t -> t val persisted_frontier_loaded : Engine.Network.Node.t -> t end From 939ff08b6303f08c287743df07897ca77416db6c Mon Sep 17 00:00:00 2001 From: Deepthi S Kumar Date: Mon, 12 Sep 2022 18:07:25 -0700 Subject: [PATCH 112/144] fix build --- src/lib/mina_metrics/no_metrics/mina_metrics.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/mina_metrics/no_metrics/mina_metrics.ml b/src/lib/mina_metrics/no_metrics/mina_metrics.ml index 00bec9d9ebe..a65c96f5677 100644 --- a/src/lib/mina_metrics/no_metrics/mina_metrics.ml +++ b/src/lib/mina_metrics/no_metrics/mina_metrics.ml @@ -78,7 +78,7 @@ module Cryptography = struct let zkapp_proof_updates : Counter.t = () - let zkapp_proof_updates : Counter.t = () + let zkapp_transaction_length : Counter.t = () end module Bootstrap = struct From d3e63b2075b49f420af8244593f13b187a5c0626 Mon Sep 17 00:00:00 2001 From: Deepthi S Kumar Date: Tue, 13 Sep 2022 11:18:46 -0700 Subject: [PATCH 113/144] revert snarkyjs changes --- src/lib/snarky_js_bindings/snarkyjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/snarky_js_bindings/snarkyjs b/src/lib/snarky_js_bindings/snarkyjs index 0eb11271319..1afdcb46cb4 160000 --- a/src/lib/snarky_js_bindings/snarkyjs +++ b/src/lib/snarky_js_bindings/snarkyjs @@ -1 +1 @@ -Subproject commit 0eb1127131900326febe3d7f2b7d1b8414317c65 +Subproject commit 1afdcb46cb4d532caef8e233428441cb05140257 From 63611c5e6e9e214061b2e5158ba96be6bee4cd48 Mon Sep 17 00:00:00 2001 From: Paul Steckler Date: Tue, 13 Sep 2022 13:06:46 -0700 Subject: [PATCH 114/144] Add transaction_id type in GraphQL --- graphql_schema.json | 42 +++++++++++-------- src/lib/codable/codable.ml | 25 +++++++++++ src/lib/codable/dune | 1 + .../graphql_basic_scalars.ml | 23 ++++++++++ src/lib/mina_base/signed_command.ml | 2 + src/lib/mina_base/signed_command_intf.ml | 2 + src/lib/mina_base/user_command.ml | 22 ++++++++++ src/lib/mina_base/zkapp_command.ml | 2 + src/lib/mina_graphql/mina_graphql.ml | 18 ++++---- src/lib/transaction/transaction_id.ml | 7 ++++ src/lib/transaction/unix/graphql_scalars.ml | 9 ++++ 11 files changed, 127 insertions(+), 26 deletions(-) create mode 100644 src/lib/transaction/transaction_id.ml diff --git a/graphql_schema.json b/graphql_schema.json index d34d11f91df..48368fe978c 100644 --- a/graphql_schema.json +++ b/graphql_schema.json @@ -6389,6 +6389,16 @@ ], "possibleTypes": null }, + { + "kind": "SCALAR", + "name": "ID", + "description": null, + "fields": null, + "inputFields": null, + "interfaces": null, + "enumValues": null, + "possibleTypes": null + }, { "kind": "OBJECT", "name": "CompletedWork", @@ -8219,16 +8229,6 @@ "enumValues": null, "possibleTypes": null }, - { - "kind": "SCALAR", - "name": "ZkappCommandBase58", - "description": "A Base58Check string representing the command", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, { "kind": "OBJECT", "name": "ZkappCommandResult", @@ -8236,14 +8236,14 @@ "fields": [ { "name": "id", - "description": "A Base58Check string representing the command", + "description": "A Base64 string representing the zkApp command", "args": [], "type": { "kind": "NON_NULL", "name": null, "ofType": { "kind": "SCALAR", - "name": "ZkappCommandBase58", + "name": "TransactionId", "ofType": null } }, @@ -8317,7 +8317,11 @@ "type": { "kind": "NON_NULL", "name": null, - "ofType": { "kind": "SCALAR", "name": "ID", "ofType": null } + "ofType": { + "kind": "SCALAR", + "name": "TransactionId", + "ofType": null + } }, "isDeprecated": false, "deprecationReason": null @@ -8645,8 +8649,8 @@ }, { "kind": "SCALAR", - "name": "ID", - "description": null, + "name": "TransactionId", + "description": "Base64-encoded transaction id", "fields": null, "inputFields": null, "interfaces": null, @@ -8697,7 +8701,11 @@ "type": { "kind": "NON_NULL", "name": null, - "ofType": { "kind": "SCALAR", "name": "ID", "ofType": null } + "ofType": { + "kind": "SCALAR", + "name": "TransactionId", + "ofType": null + } }, "isDeprecated": false, "deprecationReason": null @@ -11377,7 +11385,7 @@ }, { "name": "receiptChainHash", - "description": "Top hash of the receipt chain merkle-list", + "description": "Top hash of the receipt chain Merkle-list", "args": [], "type": { "kind": "SCALAR", diff --git a/src/lib/codable/codable.ml b/src/lib/codable/codable.ml index 6595b6cb708..2a5a58919fd 100644 --- a/src/lib/codable/codable.ml +++ b/src/lib/codable/codable.ml @@ -125,3 +125,28 @@ module type Base58_check_intf = sig include Base58_check_base_intf with type t := t end + +module Make_base64 (T : sig + type t [@@deriving bin_io] +end) = +struct + let to_base64 (t : T.t) : string = + Binable.to_string (module T) t + |> (* raises only on errors from invalid optional arguments *) + Base64.encode_exn + + let of_base64 b64 : T.t Or_error.t = + match Base64.decode b64 with + | Ok s -> + Ok (Binable.of_string (module T) s) + | Error (`Msg msg) -> + Error (Error.of_string msg) +end + +module type Base64_intf = sig + type t + + val to_base64 : t -> string + + val of_base64 : string -> t Or_error.t +end diff --git a/src/lib/codable/dune b/src/lib/codable/dune index 76337b6f0dc..8826acbbbc7 100644 --- a/src/lib/codable/dune +++ b/src/lib/codable/dune @@ -6,6 +6,7 @@ (libraries ;; opam libraries core_kernel + base64 ppx_deriving_yojson.runtime yojson result diff --git a/src/lib/graphql_basic_scalars/graphql_basic_scalars.ml b/src/lib/graphql_basic_scalars/graphql_basic_scalars.ml index 458c2ca8a54..b978d8e63e2 100644 --- a/src/lib/graphql_basic_scalars/graphql_basic_scalars.ml +++ b/src/lib/graphql_basic_scalars/graphql_basic_scalars.ml @@ -145,6 +145,29 @@ end) : Json_intf with type t = T.t = struct Graphql_async.Schema.scalar Scalar.name ~doc:Scalar.doc ~coerce:serialize end +module Make_scalar_using_base64 (T : sig + type t + + val to_base64 : t -> string + + val of_base64 : string -> t Core_kernel.Or_error.t +end) (Scalar : sig + val name : string + + val doc : string +end) : Json_intf with type t = T.t = struct + type t = T.t + + let parse json = + Yojson.Basic.Util.to_string json + |> T.of_base64 |> Core_kernel.Or_error.ok_exn + + let serialize x = `String (T.to_base64 x) + + let typ () = + Graphql_async.Schema.scalar Scalar.name ~doc:Scalar.doc ~coerce:serialize +end + module InetAddr = Make_scalar_using_to_string (Core.Unix.Inet_addr) diff --git a/src/lib/mina_base/signed_command.ml b/src/lib/mina_base/signed_command.ml index 4f9bfd85c70..bfc8a0a6d22 100644 --- a/src/lib/mina_base/signed_command.ml +++ b/src/lib/mina_base/signed_command.ml @@ -354,6 +354,8 @@ module Make_str (_ : Wire_types.Concrete) = struct [%%define_locally Base58_check.(to_base58_check, of_base58_check, of_base58_check_exn)] + include Codable.Make_base64 (Stable.Latest) + let check_signature ?signature_kind ({ payload; signer; signature } : t) = Signature_lib.Schnorr.Legacy.verify ?signature_kind signature (Snark_params.Tick.Inner_curve.of_affine signer) diff --git a/src/lib/mina_base/signed_command_intf.ml b/src/lib/mina_base/signed_command_intf.ml index df5b13a2c2a..abc845ac8a8 100644 --- a/src/lib/mina_base/signed_command_intf.ml +++ b/src/lib/mina_base/signed_command_intf.ml @@ -198,6 +198,8 @@ module type S = sig val filter_by_participant : t list -> Public_key.Compressed.t -> t list include Codable.Base58_check_intf with type t := t + + include Codable.Base64_intf with type t := t end module type Full = sig diff --git a/src/lib/mina_base/user_command.ml b/src/lib/mina_base/user_command.ml index 14bebcde77a..d03d6359c9d 100644 --- a/src/lib/mina_base/user_command.ml +++ b/src/lib/mina_base/user_command.ml @@ -72,6 +72,28 @@ module Stable = struct end end] +let to_base64 : t -> string = function + | Signed_command sc -> + Signed_command.to_base64 sc + | Zkapp_command zc -> + Zkapp_command.to_base64 zc + +let of_base64 s : t Or_error.t = + match Signed_command.of_base64 s with + | Ok sc -> + Ok (Signed_command sc) + | Error err1 -> ( + match Zkapp_command.of_base64 s with + | Ok zc -> + Ok (Zkapp_command zc) + | Error err2 -> + Error + (Error.of_string + (sprintf + "Could decode Base64 neither to signed command (%s), nor to \ + zkApp (%s)" + (Error.to_string_hum err1) (Error.to_string_hum err2) ) ) ) + (* include Allocation_functor.Make.Versioned_v1.Full_compare_eq_hash (struct let id = "user_command" diff --git a/src/lib/mina_base/zkapp_command.ml b/src/lib/mina_base/zkapp_command.ml index 4cf9ae24bd1..43d75fcca62 100644 --- a/src/lib/mina_base/zkapp_command.ml +++ b/src/lib/mina_base/zkapp_command.ml @@ -1518,6 +1518,8 @@ include Codable.Make_base58_check (Stable.Latest) (* shadow the definitions from Make_base58_check *) [%%define_locally Stable.Latest.(of_yojson, to_yojson)] +include Codable.Make_base64 (Stable.Latest) + type account_updates = (Account_update.t, Digest.Account_update.t, Digest.Forest.t) Call_forest.t diff --git a/src/lib/mina_graphql/mina_graphql.ml b/src/lib/mina_graphql/mina_graphql.ml index 2f736abeb1c..13645d3e7ec 100644 --- a/src/lib/mina_graphql/mina_graphql.ml +++ b/src/lib/mina_graphql/mina_graphql.ml @@ -209,6 +209,8 @@ module Types = struct let transaction_hash = TransactionHash.typ () + let transaction_id = TransactionId.typ () + let precomputed_block_proof = PrecomputedBlockProof.typ () end @@ -1240,7 +1242,7 @@ module Types = struct $error" ; None ) ) ; field "receiptChainHash" ~typ:chain_hash - ~doc:"Top hash of the receipt chain merkle-list" + ~doc:"Top hash of the receipt chain Merkle-list" ~args:Arg.[] ~resolve:(fun _ { account; _ } -> account.Account.Poly.receipt_chain_hash ) @@ -1572,9 +1574,9 @@ module Types = struct , (Signed_command.t, Transaction_hash.t) With_hash.t With_status.t ) field list = - [ field_no_status "id" ~typ:(non_null guid) ~args:[] + [ field_no_status "id" ~typ:(non_null transaction_id) ~args:[] ~resolve:(fun _ user_command -> - Signed_command.to_base58_check user_command.With_hash.data ) + Signed_command user_command.With_hash.data ) ; field_no_status "hash" ~typ:(non_null transaction_hash) ~args:[] ~resolve:(fun _ user_command -> user_command.With_hash.hash) ; field_no_status "kind" ~typ:(non_null kind) ~args:[] @@ -1736,12 +1738,10 @@ module Types = struct in obj "ZkappCommandResult" ~fields:(fun _ -> [ field_no_status "id" - ~doc:"A Base58Check string representing the command" - ~typ: - ( non_null - @@ Mina_base_unix.Graphql_scalars.ZkappCommandBase58.typ () ) - ~args:[] - ~resolve:(fun _ zkapp_command -> zkapp_command.With_hash.data) + ~doc:"A Base64 string representing the zkApp command" + ~typ:(non_null transaction_id) ~args:[] + ~resolve:(fun _ zkapp_command -> + Zkapp_command zkapp_command.With_hash.data ) ; field_no_status "hash" ~doc:"A cryptographic hash of the zkApp command" ~typ:(non_null transaction_hash) ~args:[] diff --git a/src/lib/transaction/transaction_id.ml b/src/lib/transaction/transaction_id.ml new file mode 100644 index 00000000000..56e20faed09 --- /dev/null +++ b/src/lib/transaction/transaction_id.ml @@ -0,0 +1,7 @@ +(* transaction_id.ml : type and Base64 conversions for GraphQL *) + +module User_command = Mina_base.User_command + +type t = User_command.t + +[%%define_locally User_command.(to_base64, of_base64)] diff --git a/src/lib/transaction/unix/graphql_scalars.ml b/src/lib/transaction/unix/graphql_scalars.ml index 3a2de0f1e00..70a23ca29b0 100644 --- a/src/lib/transaction/unix/graphql_scalars.ml +++ b/src/lib/transaction/unix/graphql_scalars.ml @@ -8,3 +8,12 @@ module TransactionHash = let doc = "Base58Check-encoded transaction hash" end) + +module TransactionId = + Make_scalar_using_base64 + (Mina_transaction.Transaction_id) + (struct + let name = "TransactionId" + + let doc = "Base64-encoded transaction id" + end) From 3bcf93db101d7acdd511db290e9d8861a371b87f Mon Sep 17 00:00:00 2001 From: Paul Steckler Date: Tue, 13 Sep 2022 14:03:29 -0700 Subject: [PATCH 115/144] fix test exec build --- graphql_schema.json | 8 ++++++-- .../kubernetes_network.ml | 15 ++++++++++----- src/lib/mina_graphql/mina_graphql.ml | 2 +- src/lib/transaction/unix/graphql_scalars.ml | 2 +- 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/graphql_schema.json b/graphql_schema.json index 48368fe978c..cf2421512f6 100644 --- a/graphql_schema.json +++ b/graphql_schema.json @@ -8650,7 +8650,7 @@ { "kind": "SCALAR", "name": "TransactionId", - "description": "Base64-encoded transaction id", + "description": "Base64-encoded transaction", "fields": null, "inputFields": null, "interfaces": null, @@ -9013,7 +9013,11 @@ "type": { "kind": "NON_NULL", "name": null, - "ofType": { "kind": "SCALAR", "name": "ID", "ofType": null } + "ofType": { + "kind": "SCALAR", + "name": "TransactionId", + "ofType": null + } }, "isDeprecated": false, "deprecationReason": null diff --git a/src/lib/integration_test_cloud_engine/kubernetes_network.ml b/src/lib/integration_test_cloud_engine/kubernetes_network.ml index 7ebd8f52470..31ea371c65e 100644 --- a/src/lib/integration_test_cloud_engine/kubernetes_network.ml +++ b/src/lib/integration_test_cloud_engine/kubernetes_network.ml @@ -645,6 +645,12 @@ module Node = struct ; nonce : Mina_numbers.Account_nonce.t } + let transaction_id_to_string = function + | `String s -> + s + | _ -> + failwith "Unexpected JSON for transaction ID" + (* if we expect failure, might want retry_on_graphql_error to be false *) let send_payment ~logger t ~sender_pub_key ~receiver_pub_key ~amount ~fee = [%log info] "Sending a payment" ~metadata:(logger_metadata t) ; @@ -678,7 +684,7 @@ module Node = struct let%map sent_payment_obj = send_payment_graphql () in let return_obj = sent_payment_obj.sendPayment.payment in let res = - { id = return_obj.id + { id = transaction_id_to_string return_obj.id ; hash = return_obj.hash ; nonce = Mina_numbers.Account_nonce.of_int return_obj.nonce } @@ -733,8 +739,7 @@ module Node = struct |> Yojson.Safe.to_string ) in let zkapp_id = - Mina_base.Zkapp_command.to_base58_check - sent_zkapp_obj.internalSendZkapp.zkapp.id + transaction_id_to_string sent_zkapp_obj.internalSendZkapp.zkapp.id in [%log info] "Sent zkapp" ~metadata:[ ("zkapp_id", `String zkapp_id) ] ; return zkapp_id @@ -772,7 +777,7 @@ module Node = struct let%map result_obj = send_delegation_graphql () in let return_obj = result_obj.sendDelegation.delegation in let res = - { id = return_obj.id + { id = transaction_id_to_string return_obj.id ; hash = return_obj.hash ; nonce = Mina_numbers.Account_nonce.of_int return_obj.nonce } @@ -816,7 +821,7 @@ module Node = struct let%map sent_payment_obj = send_payment_graphql () in let return_obj = sent_payment_obj.sendPayment.payment in let res = - { id = return_obj.id + { id = transaction_id_to_string return_obj.id ; hash = return_obj.hash ; nonce = Mina_numbers.Account_nonce.of_int return_obj.nonce } diff --git a/src/lib/mina_graphql/mina_graphql.ml b/src/lib/mina_graphql/mina_graphql.ml index 13645d3e7ec..aebc47e2a28 100644 --- a/src/lib/mina_graphql/mina_graphql.ml +++ b/src/lib/mina_graphql/mina_graphql.ml @@ -1501,7 +1501,7 @@ module Types = struct typ = interface "UserCommand" ~doc:"Common interface for user commands" ~fields:(fun _ -> - [ abstract_field "id" ~typ:(non_null guid) ~args:[] + [ abstract_field "id" ~typ:(non_null transaction_id) ~args:[] ; abstract_field "hash" ~typ:(non_null transaction_hash) ~args:[] ; abstract_field "kind" ~typ:(non_null kind) ~args:[] ~doc:"String describing the kind of user command" diff --git a/src/lib/transaction/unix/graphql_scalars.ml b/src/lib/transaction/unix/graphql_scalars.ml index 70a23ca29b0..1f530a6e082 100644 --- a/src/lib/transaction/unix/graphql_scalars.ml +++ b/src/lib/transaction/unix/graphql_scalars.ml @@ -15,5 +15,5 @@ module TransactionId = (struct let name = "TransactionId" - let doc = "Base64-encoded transaction id" + let doc = "Base64-encoded transaction" end) From fb803dd83197e42c42d35cc8f8deeae913c1ad61 Mon Sep 17 00:00:00 2001 From: David Wong Date: Thu, 28 Jul 2022 22:47:12 +0200 Subject: [PATCH 116/144] [crypto] document wasm --- src/lib/crypto/kimchi_bindings/wasm/README.md | 29 +++++++++++++++++++ .../wasm/src/wasm_flat_vector.rs | 7 +++++ 2 files changed, 36 insertions(+) create mode 100644 src/lib/crypto/kimchi_bindings/wasm/README.md diff --git a/src/lib/crypto/kimchi_bindings/wasm/README.md b/src/lib/crypto/kimchi_bindings/wasm/README.md new file mode 100644 index 00000000000..0701b35ab74 --- /dev/null +++ b/src/lib/crypto/kimchi_bindings/wasm/README.md @@ -0,0 +1,29 @@ +# Kimchi WASM + +This code allows us to compile parts of Kimchi into [Web Assembly (WASM)](https://webassembly.org/). + +## Requirements + +For this to work, you will need to install the following dependencies: + +* [wasm-pack](https://rustwasm.github.io/wasm-pack/installer/) +* [wasm-bindgen-cli](https://rustwasm.github.io/docs/wasm-bindgen/reference/cli.html) + +## Usage + +To build for nodejs: + +```console +$ wasm-pack build --mode no-install --target nodejs --out-dir ./nodejs ./. -- --features nodejs +``` + +To build for web browsers: + +```console +$ wasm-pack build --mode no-install --target web --out-dir ./web ./. +``` + +## Resources + +* [Rust WASM book](https://rustwasm.github.io/docs/book/game-of-life/hello-world.html) +* [WASM-bindgen book](https://rustwasm.github.io/docs/wasm-bindgen/) diff --git a/src/lib/crypto/kimchi_bindings/wasm/src/wasm_flat_vector.rs b/src/lib/crypto/kimchi_bindings/wasm/src/wasm_flat_vector.rs index 921fa9baa65..900298efd7a 100644 --- a/src/lib/crypto/kimchi_bindings/wasm/src/wasm_flat_vector.rs +++ b/src/lib/crypto/kimchi_bindings/wasm/src/wasm_flat_vector.rs @@ -1,3 +1,10 @@ +//! The flat vector is a vector of fixed-size elements that we want to expose directly to js-of-ocaml +//! (so that we can access a `Vec` cheaply, +//! by just passing a pointer to a continuous memory region instead of copying. +//! The wasmvector is a normal heap-allocated vector, +//! where we leave it on the rust heap and just keep a pointer around. +//! We use flat for fields, normal for gates etc. + use wasm_bindgen::convert::{FromWasmAbi, IntoWasmAbi, OptionFromWasmAbi, OptionIntoWasmAbi}; use std::convert::From; From 892be7d4e10d9368bd497b157eaf8d08037212a1 Mon Sep 17 00:00:00 2001 From: Alexander Bantyev Date: Wed, 14 Sep 2022 01:25:52 +0400 Subject: [PATCH 117/144] Fix tests by passing MINA_LIBP2P_PASS to mina --- nix/ocaml.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/nix/ocaml.nix b/nix/ocaml.nix index db135a6fee8..492f84dbf4b 100644 --- a/nix/ocaml.nix +++ b/nix/ocaml.nix @@ -221,6 +221,8 @@ let name = "tests"; extraArgs = { MINA_LIBP2P_HELPER_PATH = "${pkgs.libp2p_helper}/bin/libp2p_helper"; + MINA_LIBP2P_PASS = "naughty blue worm"; + MINA_PRIVKEY_PASS = "naughty blue worm"; TZDIR = "${pkgs.tzdata}/share/zoneinfo"; }; extraInputs = [ pkgs.ephemeralpg ]; From 27e2e0892715042e5757854b7e2ca3e230e9f168 Mon Sep 17 00:00:00 2001 From: Paul Steckler Date: Tue, 13 Sep 2022 14:27:39 -0700 Subject: [PATCH 118/144] fix client build --- src/app/cli/src/init/client.ml | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/app/cli/src/init/client.ml b/src/app/cli/src/init/client.ml index 9905dfe0f75..7e89fc8d9be 100644 --- a/src/app/cli/src/init/client.ml +++ b/src/app/cli/src/init/client.ml @@ -496,6 +496,12 @@ let batch_send_payments = (Args.zip2 Cli_lib.Flag.privkey_read_path payment_path_flag) ~f:main ) +let transaction_id_to_string = function + | `String s -> + s + | _ -> + "Unexpected JSON for transaction id" + let send_payment_graphql = let open Command.Param in let open Cli_lib.Arg_type in @@ -527,7 +533,7 @@ let send_payment_graphql = graphql_endpoint in printf "Dispatched payment with ID %s\n" - response.sendPayment.payment.id ) ) + (transaction_id_to_string response.sendPayment.payment.id) ) ) let delegate_stake_graphql = let open Command.Param in @@ -554,7 +560,7 @@ let delegate_stake_graphql = graphql_endpoint in printf "Dispatched stake delegation with ID %s\n" - response.sendDelegation.delegation.id ) ) + (transaction_id_to_string response.sendDelegation.delegation.id) ) ) let cancel_transaction_graphql = let txn_id_flag = @@ -596,7 +602,8 @@ let cancel_transaction_graphql = Graphql_client.query_exn cancel_query graphql_endpoint in printf "🛑 Cancelled transaction! Cancel ID: %s\n" - cancel_response.sendPayment.payment.id ) ) + (transaction_id_to_string cancel_response.sendPayment.payment.id) ) + ) let send_rosetta_transactions_graphql = Command.async @@ -621,7 +628,8 @@ let send_rosetta_transactions_graphql = graphql_endpoint in printf "Dispatched command with TRANSACTION_ID %s\n" - response.sendRosettaTransaction.userCommand.id ; + (transaction_id_to_string + response.sendRosettaTransaction.userCommand.id ) ; `Repeat () with Yojson.End_of_input -> return (`Finished ()) ) ) with From 25fed9e4d8a8900c4b8d1350dd38874a9a0dd046 Mon Sep 17 00:00:00 2001 From: Matheus Santana Lima Date: Tue, 13 Sep 2022 19:23:38 -0300 Subject: [PATCH 119/144] adding $githash value to docker image tags --- scripts/release-docker.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scripts/release-docker.sh b/scripts/release-docker.sh index 55c0a687659..deec33a3763 100755 --- a/scripts/release-docker.sh +++ b/scripts/release-docker.sh @@ -130,3 +130,7 @@ if [ -z "$NOUPLOAD" ] || [ "$NOUPLOAD" -eq 0 ]; then tag-and-push "gcr.io/o1labs-192920/$SERVICE:$VERSION" fi + +export GITHASH=$(git rev-parse --short=7 HEAD) +docker tag "${GITHASH}" "gcr.io/o1labs-192920/$SERVICE:$VERSION" +docker push "gcr.io/o1labs-192920/$SERVICE:$VERSION" From 7b9c0296f54163154adcd728ac87144ae8849530 Mon Sep 17 00:00:00 2001 From: Paul Steckler Date: Tue, 13 Sep 2022 16:57:28 -0700 Subject: [PATCH 120/144] change some base58 -> base64 --- src/app/cli/src/init/client.ml | 12 +++++++----- src/lib/cli_lib/arg_type.ml | 9 +++++---- src/lib/mina_graphql/mina_graphql.ml | 6 +++--- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/app/cli/src/init/client.ml b/src/app/cli/src/init/client.ml index 7e89fc8d9be..c5512de54cd 100644 --- a/src/app/cli/src/init/client.ml +++ b/src/app/cli/src/init/client.ml @@ -684,7 +684,7 @@ let get_transaction_status = (Cli_lib.Background_daemon.rpc_init Command.Param.(anon @@ ("txn-id" %: string)) ~f:(fun port serialized_transaction -> - match Signed_command.of_base58_check serialized_transaction with + match Signed_command.of_base64 serialized_transaction with | Ok user_command -> Daemon_rpcs.Client.dispatch_with_message Daemon_rpcs.Get_transaction_status.rpc user_command port @@ -2033,20 +2033,22 @@ let receipt_chain_hash = ~doc:"Previous receipt chain hash, base58check encoded" (required string) and transaction_id = - flag "--transaction-id" ~doc:"Transaction ID, base58check encoded" + flag "--transaction-id" ~doc:"Transaction ID, base64-encoded" (required string) in fun () -> let previous_hash = Receipt.Chain_hash.of_base58_check_exn previous_hash in - (* What we call transaction IDs in GraphQL are just base58_check-encoded + (* What we call transaction IDs in GraphQL are just base64-encoded transactions. It's easy to handle, and we return it from the transaction commands above, so lets use this format. TODO: handle zkApps, issue #11431 *) - let transaction = Signed_command.of_base58_check_exn transaction_id in + let transaction = + Signed_command.of_base64 transaction_id |> Or_error.ok_exn + in let hash = Receipt.Chain_hash.cons_signed_command_payload (Signed_command_payload transaction.payload) previous_hash @@ -2097,7 +2099,7 @@ let hash_transaction = in fun () -> let signed_command = - Signed_command.of_base58_check transaction |> Or_error.ok_exn + Signed_command.of_base64 transaction |> Or_error.ok_exn in let hash = Transaction_hash.hash_command (Signed_command signed_command) diff --git a/src/lib/cli_lib/arg_type.ml b/src/lib/cli_lib/arg_type.ml index f693706a923..ddd19ccd123 100644 --- a/src/lib/cli_lib/arg_type.ml +++ b/src/lib/cli_lib/arg_type.ml @@ -111,10 +111,11 @@ let log_level = let user_command = Command.Arg_type.create (fun s -> - try Mina_base.Signed_command.of_base58_check_exn s - with e -> - Error.tag (Error.of_exn e) ~tag:"Couldn't decode transaction id" - |> Error.raise ) + match Mina_base.Signed_command.of_base64 s with + | Ok s -> + s + | Error err -> + Error.tag err ~tag:"Couldn't decode transaction id" |> Error.raise ) module Work_selection_method = struct [%%versioned diff --git a/src/lib/mina_graphql/mina_graphql.ml b/src/lib/mina_graphql/mina_graphql.ml index aebc47e2a28..6a1842e71d3 100644 --- a/src/lib/mina_graphql/mina_graphql.ml +++ b/src/lib/mina_graphql/mina_graphql.ml @@ -4018,7 +4018,7 @@ module Queries = struct match txns_opt with | Some txns -> List.filter_map txns ~f:(fun serialized_txn -> - Signed_command.of_base58_check serialized_txn + Signed_command.of_base64 serialized_txn |> Result.map ~f:(fun signed_command -> (* These commands get piped through [forget_check] below; this is just to make the types work @@ -4319,11 +4319,11 @@ module Queries = struct match serialized_txn with | `Signed_command cmd -> Or_error.( - Signed_command.of_base58_check cmd + Signed_command.of_base64 cmd >>| fun c -> User_command.Signed_command c) | `Zkapp_command cmd -> Or_error.( - Zkapp_command.of_base58_check cmd + Zkapp_command.of_base64 cmd >>| fun c -> User_command.Zkapp_command c) in result_of_or_error res ~error:"Invalid transaction provided" From b58811f9f48b0abfd8ec9773da4295ea7033fe8a Mon Sep 17 00:00:00 2001 From: Paul Steckler Date: Tue, 13 Sep 2022 17:00:41 -0700 Subject: [PATCH 121/144] rm get-transaction-status --- src/app/cli/src/init/client.ml | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/src/app/cli/src/init/client.ml b/src/app/cli/src/init/client.ml index c5512de54cd..3418d626ebc 100644 --- a/src/app/cli/src/init/client.ml +++ b/src/app/cli/src/init/client.ml @@ -679,26 +679,6 @@ module Export_logs = struct run ~tarfile ~conf_dir ) end -let get_transaction_status = - Command.async ~summary:"Get the status of a transaction" - (Cli_lib.Background_daemon.rpc_init - Command.Param.(anon @@ ("txn-id" %: string)) - ~f:(fun port serialized_transaction -> - match Signed_command.of_base64 serialized_transaction with - | Ok user_command -> - Daemon_rpcs.Client.dispatch_with_message - Daemon_rpcs.Get_transaction_status.rpc user_command port - ~success:(fun status -> - sprintf !"Transaction status : %s\n" - @@ Transaction_inclusion_status.State.to_string status ) - ~error:(fun e -> - sprintf "Failed to get transaction status : %s" - (Error.to_string_hum e) ) - ~join_error:Or_error.join - | Error _e -> - eprintf "Could not deserialize user command" ; - exit 16 ) ) - let wrap_key = Command.async ~summary:"Wrap a private key into a private key file" (let open Command.Let_syntax in From add19b67420248c9e75468f2fa7c18f9cd008c4e Mon Sep 17 00:00:00 2001 From: Paul Steckler Date: Tue, 13 Sep 2022 17:20:30 -0700 Subject: [PATCH 122/144] Use serialized value for hashing signed commands --- src/lib/transaction/transaction_hash.ml | 15 +++++++++------ .../test/account_timing/account_timing.ml | 16 ++++++++-------- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/src/lib/transaction/transaction_hash.ml b/src/lib/transaction/transaction_hash.ml index bfed3bf278e..aa6af4973d8 100644 --- a/src/lib/transaction/transaction_hash.ml +++ b/src/lib/transaction/transaction_hash.ml @@ -31,11 +31,14 @@ let of_yojson = function | _ -> Error "Transaction_hash.of_yojson: Expected a string" -let hash_signed_command cmd = - cmd |> Signed_command.to_base58_check |> digest_string - -let hash_zkapp_command_command cmd = - cmd |> Binable.to_string (module Zkapp_command.Stable.Latest) |> digest_string +let hash_signed_command, hash_zkapp_command = + let mk_hasher (type a) (module M : Bin_prot.Binable.S with type t = a) + (cmd : a) = + cmd |> Binable.to_string (module M) |> digest_string + in + let hash_signed_command = mk_hasher (module Signed_command.Stable.Latest) in + let hash_zkapp_command = mk_hasher (module Zkapp_command.Stable.Latest) in + (hash_signed_command, hash_zkapp_command) [%%ifdef consensus_mechanism] @@ -44,7 +47,7 @@ let hash_command cmd = | User_command.Signed_command s -> hash_signed_command s | User_command.Zkapp_command p -> - hash_zkapp_command_command p + hash_zkapp_command p let hash_fee_transfer fee_transfer = fee_transfer |> Fee_transfer.Single.to_base58_check |> digest_string diff --git a/src/lib/transaction_snark/test/account_timing/account_timing.ml b/src/lib/transaction_snark/test/account_timing/account_timing.ml index ee4c2bbcf0d..cfdec826e52 100644 --- a/src/lib/transaction_snark/test/account_timing/account_timing.ml +++ b/src/lib/transaction_snark/test/account_timing/account_timing.ml @@ -957,7 +957,7 @@ let%test_module "account timing check" = (keypair, balance_as_amount, nonce, timing) ) |> Array.of_list in - let zkapp_command_command = + let zkapp_command = let open Mina_base in let fee = Currency.Fee.of_int 1_000_000 in let amount = Currency.Amount.of_int 10_000_000_000_000 in @@ -990,7 +990,7 @@ let%test_module "account timing check" = in Transaction_snark.For_tests.multiple_transfers zkapp_command_spec in - return (ledger_init_state, zkapp_command_command) + return (ledger_init_state, zkapp_command) in (* slot 1, well before cliffs *) Quickcheck.test ~seed:(`Deterministic "zkapp command, before cliff") @@ -1036,7 +1036,7 @@ let%test_module "account timing check" = (keypair, balance_as_amount, nonce, timing) ) |> Array.of_list in - let zkapp_command_command = + let zkapp_command = let open Mina_base in let fee = Currency.Fee.of_int 1_000_000 in let amount = Currency.Amount.of_int 10_000_000_000_000 in @@ -1069,7 +1069,7 @@ let%test_module "account timing check" = in Transaction_snark.For_tests.multiple_transfers zkapp_command_spec in - return (ledger_init_state, zkapp_command_command) + return (ledger_init_state, zkapp_command) in (* slot 1, well before cliffs *) Quickcheck.test ~seed:(`Deterministic "zkapp command, before cliff") @@ -1246,7 +1246,7 @@ let%test_module "account timing check" = |> Array.of_list in (* min balance = balance, spending anything before cliff should trigger min balance violation *) - let zkapp_command_command = + let zkapp_command = let open Mina_base in let fee = Currency.Fee.of_int 1_000_000 in let amount = Currency.Amount.of_int 10_000_000_000_000 in @@ -1279,7 +1279,7 @@ let%test_module "account timing check" = in Transaction_snark.For_tests.multiple_transfers zkapp_command_spec in - return (ledger_init_state, zkapp_command_command) + return (ledger_init_state, zkapp_command) in Quickcheck.test ~seed:(`Deterministic "zkapp command, just before cliff") ~sexp_of:[%sexp_of: Mina_ledger.Ledger.init_state * Zkapp_command.t] @@ -1632,7 +1632,7 @@ let%test_module "account timing check" = let fee_int = 1_000_000 in (* the + 1 makes the balance insufficient *) let amount_int = balance_int - fee_int + 1 in - let zkapp_command_command = + let zkapp_command = let open Mina_base in let fee = Currency.Fee.of_int fee_int in let amount = Currency.Amount.of_int amount_int in @@ -1665,7 +1665,7 @@ let%test_module "account timing check" = in Transaction_snark.For_tests.multiple_transfers zkapp_command_spec in - return (ledger_init_state, zkapp_command_command) + return (ledger_init_state, zkapp_command) in Quickcheck.test ~seed:(`Deterministic "zkapp command, after vesting") ~sexp_of:[%sexp_of: Mina_ledger.Ledger.init_state * Zkapp_command.t] From 6fac7acb24405bbc8759f2768d2cec1599b088a2 Mon Sep 17 00:00:00 2001 From: Deepthi S Kumar Date: Tue, 13 Sep 2022 17:53:11 -0700 Subject: [PATCH 123/144] rename zkapp_precondition_accounts -> account_precondition_values --- src/app/archive/archive_lib/load_data.ml | 2 +- src/app/archive/archive_lib/processor.ml | 6 +-- src/app/archive/drop_tables.sql | 2 +- src/app/archive/zkapp_tables.sql | 4 +- src/app/replayer/test/archive_db.sql | 62 ++++++++++++------------ 5 files changed, 38 insertions(+), 38 deletions(-) diff --git a/src/app/archive/archive_lib/load_data.ml b/src/app/archive/archive_lib/load_data.ml index 41cc83da32b..eceb0883337 100644 --- a/src/app/archive/archive_lib/load_data.ml +++ b/src/app/archive/archive_lib/load_data.ml @@ -504,7 +504,7 @@ let get_account_update_body ~pool body_id = ; is_new } = query_db ~f:(fun db -> - Processor.Zkapp_precondition_account.load db + Processor.Account_precondition_values.load db (Option.value_exn precondition_account_id) ) in let%bind balance = diff --git a/src/app/archive/archive_lib/processor.ml b/src/app/archive/archive_lib/processor.ml index ab089ebb022..cbf7cf379c7 100644 --- a/src/app/archive/archive_lib/processor.ml +++ b/src/app/archive/archive_lib/processor.ml @@ -792,7 +792,7 @@ module Zkapp_nonce_bounds = struct id end -module Zkapp_precondition_account = struct +module Account_precondition_values = struct type t = { balance_id : int option ; nonce_id : int option @@ -818,7 +818,7 @@ module Zkapp_precondition_account = struct ; option bool ] - let table_name = "zkapp_precondition_accounts" + let table_name = "account_precondition_values" let add_if_doesn't_exist (module Conn : CONNECTION) (acct : Zkapp_precondition.Account.t) = @@ -918,7 +918,7 @@ module Zkapp_account_precondition = struct let%bind precondition_account_id = match account_precondition with | Account_update.Account_precondition.Full acct -> - Zkapp_precondition_account.add_if_doesn't_exist (module Conn) acct + Account_precondition_values.add_if_doesn't_exist (module Conn) acct >>| Option.some | _ -> return None diff --git a/src/app/archive/drop_tables.sql b/src/app/archive/drop_tables.sql index 98182165903..ce4ced411af 100644 --- a/src/app/archive/drop_tables.sql +++ b/src/app/archive/drop_tables.sql @@ -48,7 +48,7 @@ DROP TABLE zkapp_network_precondition; DROP TABLE zkapp_account_precondition; -DROP TABLE zkapp_precondition_accounts; +DROP TABLE account_precondition_values; DROP TABLE zkapp_accounts; diff --git a/src/app/archive/zkapp_tables.sql b/src/app/archive/zkapp_tables.sql index e45f54e5238..2c465e3bba7 100644 --- a/src/app/archive/zkapp_tables.sql +++ b/src/app/archive/zkapp_tables.sql @@ -146,7 +146,7 @@ CREATE TABLE zkapp_nonce_bounds CREATE TYPE zkapp_precondition_type AS ENUM ('full', 'nonce', 'accept'); /* NULL convention */ -CREATE TABLE zkapp_precondition_accounts +CREATE TABLE account_precondition_values ( id serial PRIMARY KEY , balance_id int REFERENCES zkapp_balance_bounds(id) , nonce_id int REFERENCES zkapp_nonce_bounds(id) @@ -164,7 +164,7 @@ CREATE TABLE zkapp_precondition_accounts CREATE TABLE zkapp_account_precondition ( id serial PRIMARY KEY , kind zkapp_precondition_type NOT NULL -, precondition_account_id int REFERENCES zkapp_precondition_accounts(id) +, account_precondition_values_id int REFERENCES account_precondition_values(id) , nonce bigint ); diff --git a/src/app/replayer/test/archive_db.sql b/src/app/replayer/test/archive_db.sql index 972d53d61dc..21c495e2f95 100644 --- a/src/app/replayer/test/archive_db.sql +++ b/src/app/replayer/test/archive_db.sql @@ -1272,10 +1272,10 @@ ALTER SEQUENCE public.zkapp_permissions_id_seq OWNED BY public.zkapp_permissions -- --- Name: zkapp_precondition_accounts; Type: TABLE; Schema: public; +-- Name: account_precondition_values; Type: TABLE; Schema: public; -- -CREATE TABLE public.zkapp_precondition_accounts ( +CREATE TABLE public.account_precondition_values ( id integer NOT NULL, balance_id integer, nonce_id integer, @@ -1291,10 +1291,10 @@ CREATE TABLE public.zkapp_precondition_accounts ( -- --- Name: zkapp_precondition_accounts_id_seq; Type: SEQUENCE; Schema: public; +-- Name: account_precondition_values_id_seq; Type: SEQUENCE; Schema: public; -- -CREATE SEQUENCE public.zkapp_precondition_accounts_id_seq +CREATE SEQUENCE public.account_precondition_values_id_seq AS integer START WITH 1 INCREMENT BY 1 @@ -1306,10 +1306,10 @@ CREATE SEQUENCE public.zkapp_precondition_accounts_id_seq -- --- Name: zkapp_precondition_accounts_id_seq; Type: SEQUENCE OWNED BY; Schema: public; +-- Name: account_precondition_values_id_seq; Type: SEQUENCE OWNED BY; Schema: public; -- -ALTER SEQUENCE public.zkapp_precondition_accounts_id_seq OWNED BY public.zkapp_precondition_accounts.id; +ALTER SEQUENCE public.account_precondition_values_id_seq OWNED BY public.account_precondition_values.id; -- @@ -1914,10 +1914,10 @@ ALTER TABLE ONLY public.zkapp_permissions ALTER COLUMN id SET DEFAULT nextval('p -- --- Name: zkapp_precondition_accounts id; Type: DEFAULT; Schema: public; +-- Name: account_precondition_values id; Type: DEFAULT; Schema: public; -- -ALTER TABLE ONLY public.zkapp_precondition_accounts ALTER COLUMN id SET DEFAULT nextval('public.zkapp_precondition_accounts_id_seq'::regclass); +ALTER TABLE ONLY public.account_precondition_values ALTER COLUMN id SET DEFAULT nextval('public.account_precondition_values_id_seq'::regclass); -- @@ -2609,10 +2609,10 @@ COPY public.zkapp_permissions (id, edit_state, send, receive, set_delegate, set_ -- --- Data for Name: zkapp_precondition_accounts; Type: TABLE DATA; Schema: public; +-- Data for Name: account_precondition_values; Type: TABLE DATA; Schema: public; -- -COPY public.zkapp_precondition_accounts (id, balance_id, nonce_id, receipt_chain_hash, delegate_id, state_id, sequence_state_id, proved_state, is_new) FROM stdin; +COPY public.account_precondition_values (id, balance_id, nonce_id, receipt_chain_hash, delegate_id, state_id, sequence_state_id, proved_state, is_new) FROM stdin; \. @@ -2922,10 +2922,10 @@ SELECT pg_catalog.setval('public.zkapp_permissions_id_seq', 5, true); -- --- Name: zkapp_precondition_accounts_id_seq; Type: SEQUENCE SET; Schema: public; +-- Name: account_precondition_values_id_seq; Type: SEQUENCE SET; Schema: public; -- -SELECT pg_catalog.setval('public.zkapp_precondition_accounts_id_seq', 1, false); +SELECT pg_catalog.setval('public.account_precondition_values_id_seq', 1, false); -- @@ -3342,11 +3342,11 @@ ALTER TABLE ONLY public.zkapp_permissions -- --- Name: zkapp_precondition_accounts zkapp_precondition_accounts_pkey; Type: CONSTRAINT; Schema: public; +-- Name: account_precondition_values account_precondition_values_pkey; Type: CONSTRAINT; Schema: public; -- -ALTER TABLE ONLY public.zkapp_precondition_accounts - ADD CONSTRAINT zkapp_precondition_accounts_pkey PRIMARY KEY (id); +ALTER TABLE ONLY public.account_precondition_values + ADD CONSTRAINT account_precondition_values_pkey PRIMARY KEY (id); -- @@ -3870,7 +3870,7 @@ ALTER TABLE ONLY public.user_commands -- ALTER TABLE ONLY public.zkapp_account_precondition - ADD CONSTRAINT zkapp_account_precondition_precondition_account_id_fkey FOREIGN KEY (precondition_account_id) REFERENCES public.zkapp_precondition_accounts(id); + ADD CONSTRAINT zkapp_account_precondition_precondition_account_id_fkey FOREIGN KEY (precondition_account_id) REFERENCES public.account_precondition_values(id); -- @@ -4090,43 +4090,43 @@ ALTER TABLE ONLY public.zkapp_account_update_body -- --- Name: zkapp_precondition_accounts zkapp_precondition_accounts_balance_id_fkey; Type: FK CONSTRAINT; Schema: public; +-- Name: account_precondition_values account_precondition_values_balance_id_fkey; Type: FK CONSTRAINT; Schema: public; -- -ALTER TABLE ONLY public.zkapp_precondition_accounts - ADD CONSTRAINT zkapp_precondition_accounts_balance_id_fkey FOREIGN KEY (balance_id) REFERENCES public.zkapp_balance_bounds(id); +ALTER TABLE ONLY public.account_precondition_values + ADD CONSTRAINT account_precondition_values_balance_id_fkey FOREIGN KEY (balance_id) REFERENCES public.zkapp_balance_bounds(id); -- --- Name: zkapp_precondition_accounts zkapp_precondition_accounts_delegate_id_fkey; Type: FK CONSTRAINT; Schema: public; +-- Name: account_precondition_values account_precondition_values_delegate_id_fkey; Type: FK CONSTRAINT; Schema: public; -- -ALTER TABLE ONLY public.zkapp_precondition_accounts - ADD CONSTRAINT zkapp_precondition_accounts_delegate_id_fkey FOREIGN KEY (delegate_id) REFERENCES public.public_keys(id); +ALTER TABLE ONLY public.account_precondition_values + ADD CONSTRAINT account_precondition_values_delegate_id_fkey FOREIGN KEY (delegate_id) REFERENCES public.public_keys(id); -- --- Name: zkapp_precondition_accounts zkapp_precondition_accounts_nonce_id_fkey; Type: FK CONSTRAINT; Schema: public; +-- Name: account_precondition_values account_precondition_values_nonce_id_fkey; Type: FK CONSTRAINT; Schema: public; -- -ALTER TABLE ONLY public.zkapp_precondition_accounts - ADD CONSTRAINT zkapp_precondition_accounts_nonce_id_fkey FOREIGN KEY (nonce_id) REFERENCES public.zkapp_nonce_bounds(id); +ALTER TABLE ONLY public.account_precondition_values + ADD CONSTRAINT account_precondition_values_nonce_id_fkey FOREIGN KEY (nonce_id) REFERENCES public.zkapp_nonce_bounds(id); -- --- Name: zkapp_precondition_accounts zkapp_precondition_accounts_sequence_state_id_fkey; Type: FK CONSTRAINT; Schema: public; +-- Name: account_precondition_values account_precondition_values_sequence_state_id_fkey; Type: FK CONSTRAINT; Schema: public; -- -ALTER TABLE ONLY public.zkapp_precondition_accounts - ADD CONSTRAINT zkapp_precondition_accounts_sequence_state_id_fkey FOREIGN KEY (sequence_state_id) REFERENCES public.zkapp_state_data(id); +ALTER TABLE ONLY public.account_precondition_values + ADD CONSTRAINT account_precondition_values_sequence_state_id_fkey FOREIGN KEY (sequence_state_id) REFERENCES public.zkapp_state_data(id); -- --- Name: zkapp_precondition_accounts zkapp_precondition_accounts_state_id_fkey; Type: FK CONSTRAINT; Schema: public; +-- Name: account_precondition_values account_precondition_values_state_id_fkey; Type: FK CONSTRAINT; Schema: public; -- -ALTER TABLE ONLY public.zkapp_precondition_accounts - ADD CONSTRAINT zkapp_precondition_accounts_state_id_fkey FOREIGN KEY (state_id) REFERENCES public.zkapp_states_nullable(id); +ALTER TABLE ONLY public.account_precondition_values + ADD CONSTRAINT account_precondition_values_state_id_fkey FOREIGN KEY (state_id) REFERENCES public.zkapp_states_nullable(id); -- From 226d2c556cd2c6bedeb580ba0fdb76f1032c1a16 Mon Sep 17 00:00:00 2001 From: Deepthi S Kumar Date: Wed, 14 Sep 2022 00:13:17 -0700 Subject: [PATCH 124/144] rename call_type_type -> call_type; zkapp_precondition_accounts -> zkapp_account_precondition_values --- src/app/archive/archive_lib/load_data.ml | 6 +- src/app/archive/archive_lib/processor.ml | 10 ++-- src/app/archive/drop_tables.sql | 4 +- src/app/archive/zkapp_tables.sql | 8 +-- src/app/replayer/test/archive_db.sql | 74 ++++++++++++------------ 5 files changed, 51 insertions(+), 51 deletions(-) diff --git a/src/app/archive/archive_lib/load_data.ml b/src/app/archive/archive_lib/load_data.ml index eceb0883337..5044decc013 100644 --- a/src/app/archive/archive_lib/load_data.ml +++ b/src/app/archive/archive_lib/load_data.ml @@ -476,7 +476,7 @@ let get_account_update_body ~pool body_id = protocol_state_precondition_of_id pool zkapp_network_precondition_id in let%bind account_precondition = - let%bind ({ kind; precondition_account_id; nonce } + let%bind ({ kind; account_precondition_values_id; nonce } : Processor.Zkapp_account_precondition.t ) = query_db ~f:(fun db -> Processor.Zkapp_account_precondition.load db @@ -493,7 +493,7 @@ let get_account_update_body ~pool body_id = | Accept -> return Account_update.Account_precondition.Accept | Full -> - assert (Option.is_some precondition_account_id) ; + assert (Option.is_some account_precondition_values_id) ; let%bind { balance_id ; nonce_id ; receipt_chain_hash @@ -505,7 +505,7 @@ let get_account_update_body ~pool body_id = } = query_db ~f:(fun db -> Processor.Account_precondition_values.load db - (Option.value_exn precondition_account_id) ) + (Option.value_exn account_precondition_values_id) ) in let%bind balance = let%map balance_opt = diff --git a/src/app/archive/archive_lib/processor.ml b/src/app/archive/archive_lib/processor.ml index cbf7cf379c7..c848152fd78 100644 --- a/src/app/archive/archive_lib/processor.ml +++ b/src/app/archive/archive_lib/processor.ml @@ -818,7 +818,7 @@ module Account_precondition_values = struct ; option bool ] - let table_name = "account_precondition_values" + let table_name = "zkapp_account_precondition_values" let add_if_doesn't_exist (module Conn : CONNECTION) (acct : Zkapp_precondition.Account.t) = @@ -879,7 +879,7 @@ end module Zkapp_account_precondition = struct type t = { kind : Account_update.Account_precondition.Tag.t - ; precondition_account_id : int option + ; account_precondition_values_id : int option ; nonce : int64 option } [@@deriving fields, hlist] @@ -915,7 +915,7 @@ module Zkapp_account_precondition = struct let add_if_doesn't_exist (module Conn : CONNECTION) (account_precondition : Account_update.Account_precondition.t) = let open Deferred.Result.Let_syntax in - let%bind precondition_account_id = + let%bind account_precondition_values_id = match account_precondition with | Account_update.Account_precondition.Full acct -> Account_precondition_values.add_if_doesn't_exist (module Conn) acct @@ -934,7 +934,7 @@ module Zkapp_account_precondition = struct Mina_caqti.select_insert_into_cols ~select:("id", Caqti_type.int) ~table_name ~cols:(Fields.names, typ) (module Conn) - { kind; precondition_account_id; nonce } + { kind; account_precondition_values_id; nonce } let load (module Conn : CONNECTION) id = Conn.find @@ -1547,7 +1547,7 @@ module Zkapp_account_update_body = struct | "events_ids" | "sequence_events_ids" -> Some "int[]" | "caller" -> - Some "call_type_type" + Some "call_type" | _ -> None ) (module Conn) diff --git a/src/app/archive/drop_tables.sql b/src/app/archive/drop_tables.sql index ce4ced411af..8666d56f960 100644 --- a/src/app/archive/drop_tables.sql +++ b/src/app/archive/drop_tables.sql @@ -40,7 +40,7 @@ DROP TABLE zkapp_account_update; DROP TABLE zkapp_account_update_body; -DROP TYPE call_type_type; +DROP TYPE call_type; DROP TABLE zkapp_updates; @@ -48,7 +48,7 @@ DROP TABLE zkapp_network_precondition; DROP TABLE zkapp_account_precondition; -DROP TABLE account_precondition_values; +DROP TABLE zkapp_account_precondition_values; DROP TABLE zkapp_accounts; diff --git a/src/app/archive/zkapp_tables.sql b/src/app/archive/zkapp_tables.sql index 2c465e3bba7..a367f48942c 100644 --- a/src/app/archive/zkapp_tables.sql +++ b/src/app/archive/zkapp_tables.sql @@ -146,7 +146,7 @@ CREATE TABLE zkapp_nonce_bounds CREATE TYPE zkapp_precondition_type AS ENUM ('full', 'nonce', 'accept'); /* NULL convention */ -CREATE TABLE account_precondition_values +CREATE TABLE zkapp_account_precondition_values ( id serial PRIMARY KEY , balance_id int REFERENCES zkapp_balance_bounds(id) , nonce_id int REFERENCES zkapp_nonce_bounds(id) @@ -164,7 +164,7 @@ CREATE TABLE account_precondition_values CREATE TABLE zkapp_account_precondition ( id serial PRIMARY KEY , kind zkapp_precondition_type NOT NULL -, account_precondition_values_id int REFERENCES account_precondition_values(id) +, account_precondition_values_id int REFERENCES zkapp_account_precondition_values(id) , nonce bigint ); @@ -254,7 +254,7 @@ CREATE TABLE zkapp_fee_payer_body , nonce bigint NOT NULL ); -CREATE TYPE call_type_type AS ENUM ('call', 'delegate_call'); +CREATE TYPE call_type AS ENUM ('call', 'delegate_call'); /* events_ids and sequence_events_ids indicate a list of ids in zkapp_state_data_array. @@ -272,7 +272,7 @@ CREATE TABLE zkapp_account_update_body , zkapp_network_precondition_id int NOT NULL REFERENCES zkapp_network_precondition(id) , zkapp_account_precondition_id int NOT NULL REFERENCES zkapp_account_precondition(id) , use_full_commitment boolean NOT NULL -, caller call_type_type NOT NULL +, caller call_type NOT NULL ); CREATE TABLE zkapp_account_update diff --git a/src/app/replayer/test/archive_db.sql b/src/app/replayer/test/archive_db.sql index 21c495e2f95..6096bb2871d 100644 --- a/src/app/replayer/test/archive_db.sql +++ b/src/app/replayer/test/archive_db.sql @@ -39,10 +39,10 @@ SET client_min_messages = warning; SET row_security = off; -- --- Name: call_type_type; Type: TYPE; Schema: public; +-- Name: call_type; Type: TYPE; Schema: public; -- -CREATE TYPE public.call_type_type AS ENUM ( +CREATE TYPE public.call_type AS ENUM ( 'call', 'delegate_call' ); @@ -645,7 +645,7 @@ ALTER SEQUENCE public.voting_for_id_seq OWNED BY public.voting_for.id; CREATE TABLE public.zkapp_account_precondition ( id integer NOT NULL, kind public.zkapp_precondition_type NOT NULL, - precondition_account_id integer, + account_precondition_values_id integer, nonce bigint ); @@ -1142,7 +1142,7 @@ CREATE TABLE public.zkapp_account_update_body ( zkapp_network_precondition_id integer NOT NULL, zkapp_account_precondition_id integer NOT NULL, use_full_commitment boolean NOT NULL, - caller public.call_type_type NOT NULL + caller public.call_type NOT NULL ); @@ -1272,10 +1272,10 @@ ALTER SEQUENCE public.zkapp_permissions_id_seq OWNED BY public.zkapp_permissions -- --- Name: account_precondition_values; Type: TABLE; Schema: public; +-- Name: zkapp_account_precondition_values; Type: TABLE; Schema: public; -- -CREATE TABLE public.account_precondition_values ( +CREATE TABLE public.zkapp_account_precondition_values ( id integer NOT NULL, balance_id integer, nonce_id integer, @@ -1291,10 +1291,10 @@ CREATE TABLE public.account_precondition_values ( -- --- Name: account_precondition_values_id_seq; Type: SEQUENCE; Schema: public; +-- Name: zkapp_account_precondition_values_id_seq; Type: SEQUENCE; Schema: public; -- -CREATE SEQUENCE public.account_precondition_values_id_seq +CREATE SEQUENCE public.zkapp_account_precondition_values_id_seq AS integer START WITH 1 INCREMENT BY 1 @@ -1306,10 +1306,10 @@ CREATE SEQUENCE public.account_precondition_values_id_seq -- --- Name: account_precondition_values_id_seq; Type: SEQUENCE OWNED BY; Schema: public; +-- Name: zkapp_account_precondition_values_id_seq; Type: SEQUENCE OWNED BY; Schema: public; -- -ALTER SEQUENCE public.account_precondition_values_id_seq OWNED BY public.account_precondition_values.id; +ALTER SEQUENCE public.zkapp_account_precondition_values_id_seq OWNED BY public.zkapp_account_precondition_values.id; -- @@ -1914,10 +1914,10 @@ ALTER TABLE ONLY public.zkapp_permissions ALTER COLUMN id SET DEFAULT nextval('p -- --- Name: account_precondition_values id; Type: DEFAULT; Schema: public; +-- Name: zkapp_account_precondition_values id; Type: DEFAULT; Schema: public; -- -ALTER TABLE ONLY public.account_precondition_values ALTER COLUMN id SET DEFAULT nextval('public.account_precondition_values_id_seq'::regclass); +ALTER TABLE ONLY public.zkapp_account_precondition_values ALTER COLUMN id SET DEFAULT nextval('public.zkapp_account_precondition_values_id_seq'::regclass); -- @@ -2453,7 +2453,7 @@ COPY public.voting_for (id, value) FROM stdin; -- Data for Name: zkapp_account_precondition; Type: TABLE DATA; Schema: public; -- -COPY public.zkapp_account_precondition (id, kind, precondition_account_id, nonce) FROM stdin; +COPY public.zkapp_account_precondition (id, kind, account_precondition_values_id, nonce) FROM stdin; 1 nonce \N 1 2 accept \N \N \. @@ -2609,10 +2609,10 @@ COPY public.zkapp_permissions (id, edit_state, send, receive, set_delegate, set_ -- --- Data for Name: account_precondition_values; Type: TABLE DATA; Schema: public; +-- Data for Name: zkapp_account_precondition_values; Type: TABLE DATA; Schema: public; -- -COPY public.account_precondition_values (id, balance_id, nonce_id, receipt_chain_hash, delegate_id, state_id, sequence_state_id, proved_state, is_new) FROM stdin; +COPY public.zkapp_account_precondition_values (id, balance_id, nonce_id, receipt_chain_hash, delegate_id, state_id, sequence_state_id, proved_state, is_new) FROM stdin; \. @@ -2922,10 +2922,10 @@ SELECT pg_catalog.setval('public.zkapp_permissions_id_seq', 5, true); -- --- Name: account_precondition_values_id_seq; Type: SEQUENCE SET; Schema: public; +-- Name: zkapp_account_precondition_values_id_seq; Type: SEQUENCE SET; Schema: public; -- -SELECT pg_catalog.setval('public.account_precondition_values_id_seq', 1, false); +SELECT pg_catalog.setval('public.zkapp_account_precondition_values_id_seq', 1, false); -- @@ -3342,11 +3342,11 @@ ALTER TABLE ONLY public.zkapp_permissions -- --- Name: account_precondition_values account_precondition_values_pkey; Type: CONSTRAINT; Schema: public; +-- Name: zkapp_account_precondition_values zkapp_account_precondition_values_pkey; Type: CONSTRAINT; Schema: public; -- -ALTER TABLE ONLY public.account_precondition_values - ADD CONSTRAINT account_precondition_values_pkey PRIMARY KEY (id); +ALTER TABLE ONLY public.zkapp_account_precondition_values + ADD CONSTRAINT zkapp_account_precondition_values_pkey PRIMARY KEY (id); -- @@ -3866,11 +3866,11 @@ ALTER TABLE ONLY public.user_commands -- --- Name: zkapp_account_precondition zkapp_account_precondition_precondition_account_id_fkey; Type: FK CONSTRAINT; Schema: public; +-- Name: zkapp_account_precondition zkapp_account_precondition_account_precondition_values_id_fkey; Type: FK CONSTRAINT; Schema: public; -- ALTER TABLE ONLY public.zkapp_account_precondition - ADD CONSTRAINT zkapp_account_precondition_precondition_account_id_fkey FOREIGN KEY (precondition_account_id) REFERENCES public.account_precondition_values(id); + ADD CONSTRAINT zkapp_account_precondition_account_precondition_values_id_fkey FOREIGN KEY (account_precondition_values_id) REFERENCES public.zkapp_account_precondition_values(id); -- @@ -4090,43 +4090,43 @@ ALTER TABLE ONLY public.zkapp_account_update_body -- --- Name: account_precondition_values account_precondition_values_balance_id_fkey; Type: FK CONSTRAINT; Schema: public; +-- Name: zkapp_account_precondition_values zkapp_account_precondition_values_balance_id_fkey; Type: FK CONSTRAINT; Schema: public; -- -ALTER TABLE ONLY public.account_precondition_values - ADD CONSTRAINT account_precondition_values_balance_id_fkey FOREIGN KEY (balance_id) REFERENCES public.zkapp_balance_bounds(id); +ALTER TABLE ONLY public.zkapp_account_precondition_values + ADD CONSTRAINT zkapp_account_precondition_values_balance_id_fkey FOREIGN KEY (balance_id) REFERENCES public.zkapp_balance_bounds(id); -- --- Name: account_precondition_values account_precondition_values_delegate_id_fkey; Type: FK CONSTRAINT; Schema: public; +-- Name: zkapp_account_precondition_values zkapp_account_precondition_values_delegate_id_fkey; Type: FK CONSTRAINT; Schema: public; -- -ALTER TABLE ONLY public.account_precondition_values - ADD CONSTRAINT account_precondition_values_delegate_id_fkey FOREIGN KEY (delegate_id) REFERENCES public.public_keys(id); +ALTER TABLE ONLY public.zkapp_account_precondition_values + ADD CONSTRAINT zkapp_account_precondition_values_delegate_id_fkey FOREIGN KEY (delegate_id) REFERENCES public.public_keys(id); -- --- Name: account_precondition_values account_precondition_values_nonce_id_fkey; Type: FK CONSTRAINT; Schema: public; +-- Name: zkapp_account_precondition_values zkapp_account_precondition_values_nonce_id_fkey; Type: FK CONSTRAINT; Schema: public; -- -ALTER TABLE ONLY public.account_precondition_values - ADD CONSTRAINT account_precondition_values_nonce_id_fkey FOREIGN KEY (nonce_id) REFERENCES public.zkapp_nonce_bounds(id); +ALTER TABLE ONLY public.zkapp_account_precondition_values + ADD CONSTRAINT zkapp_account_precondition_values_nonce_id_fkey FOREIGN KEY (nonce_id) REFERENCES public.zkapp_nonce_bounds(id); -- --- Name: account_precondition_values account_precondition_values_sequence_state_id_fkey; Type: FK CONSTRAINT; Schema: public; +-- Name: zkapp_account_precondition_values zkapp_account_precondition_values_sequence_state_id_fkey; Type: FK CONSTRAINT; Schema: public; -- -ALTER TABLE ONLY public.account_precondition_values - ADD CONSTRAINT account_precondition_values_sequence_state_id_fkey FOREIGN KEY (sequence_state_id) REFERENCES public.zkapp_state_data(id); +ALTER TABLE ONLY public.zkapp_account_precondition_values + ADD CONSTRAINT zkapp_account_precondition_values_sequence_state_id_fkey FOREIGN KEY (sequence_state_id) REFERENCES public.zkapp_state_data(id); -- --- Name: account_precondition_values account_precondition_values_state_id_fkey; Type: FK CONSTRAINT; Schema: public; +-- Name: zkapp_account_precondition_values zkapp_account_precondition_values_state_id_fkey; Type: FK CONSTRAINT; Schema: public; -- -ALTER TABLE ONLY public.account_precondition_values - ADD CONSTRAINT account_precondition_values_state_id_fkey FOREIGN KEY (state_id) REFERENCES public.zkapp_states_nullable(id); +ALTER TABLE ONLY public.zkapp_account_precondition_values + ADD CONSTRAINT zkapp_account_precondition_values_state_id_fkey FOREIGN KEY (state_id) REFERENCES public.zkapp_states_nullable(id); -- From 6bad5e71cb0cff2b5479bdbecb60ea78db0e0cd9 Mon Sep 17 00:00:00 2001 From: Gregor Date: Wed, 14 Sep 2022 16:24:32 +0200 Subject: [PATCH 125/144] [snarkyjs] move zkprogram under experimental --- src/lib/snarky_js_bindings/test_module/inductive-proofs.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/snarky_js_bindings/test_module/inductive-proofs.js b/src/lib/snarky_js_bindings/test_module/inductive-proofs.js index 22488a818f2..1e63e612196 100644 --- a/src/lib/snarky_js_bindings/test_module/inductive-proofs.js +++ b/src/lib/snarky_js_bindings/test_module/inductive-proofs.js @@ -1,9 +1,9 @@ -import { SelfProof, Field, ZkProgram, isReady, shutdown } from "snarkyjs"; +import { SelfProof, Field, Experimental, isReady, shutdown } from "snarkyjs"; import { tic, toc } from "./tictoc.js"; await isReady; -let MyProgram = ZkProgram({ +let MyProgram = Experimental.ZkProgram({ publicInput: Field, methods: { From 5ca5044a67d344e22e51cb4171bce24c6d8c4b4b Mon Sep 17 00:00:00 2001 From: Gregor Date: Wed, 14 Sep 2022 16:53:40 +0200 Subject: [PATCH 126/144] bump snarkyjs --- src/lib/snarky_js_bindings/snarkyjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/snarky_js_bindings/snarkyjs b/src/lib/snarky_js_bindings/snarkyjs index 1afdcb46cb4..65b711d38ea 160000 --- a/src/lib/snarky_js_bindings/snarkyjs +++ b/src/lib/snarky_js_bindings/snarkyjs @@ -1 +1 @@ -Subproject commit 1afdcb46cb4d532caef8e233428441cb05140257 +Subproject commit 65b711d38ea3160a6c7c0e6cc8f80a5b1210ab95 From 15d10054699bf406eeb37fcf2c8d7d98522d1cc8 Mon Sep 17 00:00:00 2001 From: Matheus Santana Lima Date: Wed, 14 Sep 2022 13:40:41 -0300 Subject: [PATCH 127/144] fix logic --- scripts/release-docker.sh | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/scripts/release-docker.sh b/scripts/release-docker.sh index deec33a3763..4239ee10798 100755 --- a/scripts/release-docker.sh +++ b/scripts/release-docker.sh @@ -122,6 +122,9 @@ fi tag-and-push() { docker tag "${TAG}" "$1" + + export GITHASH=$(git rev-parse --short=7 HEAD) + docker tag "${GITHASH}" "$1" docker push "$1" } @@ -129,8 +132,3 @@ if [ -z "$NOUPLOAD" ] || [ "$NOUPLOAD" -eq 0 ]; then docker push "${TAG}" tag-and-push "gcr.io/o1labs-192920/$SERVICE:$VERSION" fi - - -export GITHASH=$(git rev-parse --short=7 HEAD) -docker tag "${GITHASH}" "gcr.io/o1labs-192920/$SERVICE:$VERSION" -docker push "gcr.io/o1labs-192920/$SERVICE:$VERSION" From f9b000a2c6a0c8b82eadacf4754f90fde7c03f7f Mon Sep 17 00:00:00 2001 From: Deepthi S Kumar Date: Wed, 14 Sep 2022 09:59:54 -0700 Subject: [PATCH 128/144] Update module name Account_precondition_values --- src/app/archive/archive_lib/load_data.ml | 2 +- src/app/archive/archive_lib/processor.ml | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/app/archive/archive_lib/load_data.ml b/src/app/archive/archive_lib/load_data.ml index 5044decc013..4b6dec21c0b 100644 --- a/src/app/archive/archive_lib/load_data.ml +++ b/src/app/archive/archive_lib/load_data.ml @@ -504,7 +504,7 @@ let get_account_update_body ~pool body_id = ; is_new } = query_db ~f:(fun db -> - Processor.Account_precondition_values.load db + Processor.Zkapp_account_precondition_values.load db (Option.value_exn account_precondition_values_id) ) in let%bind balance = diff --git a/src/app/archive/archive_lib/processor.ml b/src/app/archive/archive_lib/processor.ml index c848152fd78..ee308447bbc 100644 --- a/src/app/archive/archive_lib/processor.ml +++ b/src/app/archive/archive_lib/processor.ml @@ -792,7 +792,7 @@ module Zkapp_nonce_bounds = struct id end -module Account_precondition_values = struct +module Zkapp_account_precondition_values = struct type t = { balance_id : int option ; nonce_id : int option @@ -918,7 +918,9 @@ module Zkapp_account_precondition = struct let%bind account_precondition_values_id = match account_precondition with | Account_update.Account_precondition.Full acct -> - Account_precondition_values.add_if_doesn't_exist (module Conn) acct + Zkapp_account_precondition_values.add_if_doesn't_exist + (module Conn) + acct >>| Option.some | _ -> return None From 065155fb3f0277ca09e1de09b506a21b335c4c7a Mon Sep 17 00:00:00 2001 From: Paul Steckler Date: Wed, 14 Sep 2022 10:39:30 -0700 Subject: [PATCH 129/144] Dummy proofs, signatures when transaction hashing --- src/lib/transaction/transaction_hash.ml | 33 +++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/src/lib/transaction/transaction_hash.ml b/src/lib/transaction/transaction_hash.ml index aa6af4973d8..d21f965515b 100644 --- a/src/lib/transaction/transaction_hash.ml +++ b/src/lib/transaction/transaction_hash.ml @@ -36,8 +36,37 @@ let hash_signed_command, hash_zkapp_command = (cmd : a) = cmd |> Binable.to_string (module M) |> digest_string in - let hash_signed_command = mk_hasher (module Signed_command.Stable.Latest) in - let hash_zkapp_command = mk_hasher (module Zkapp_command.Stable.Latest) in + let signed_cmd_hasher = mk_hasher (module Signed_command.Stable.Latest) in + let zkapp_cmd_hasher = mk_hasher (module Zkapp_command.Stable.Latest) in + (* replace actual signatures, proofs with dummies for hashing, so we can + reproduce the transaction hashes if signatures, proofs omitted in + archive db + *) + let hash_signed_command (cmd : Signed_command.t) = + let cmd_dummy_signature = { cmd with signature = Signature.dummy } in + signed_cmd_hasher cmd_dummy_signature + in + let hash_zkapp_command (cmd : Zkapp_command.t) = + let cmd_dummy_signatures_and_proofs = + { cmd with + fee_payer = { cmd.fee_payer with authorization = Signature.dummy } + ; account_updates = + Zkapp_command.Call_forest.map cmd.account_updates + ~f:(fun (acct_update : Account_update.t) -> + let dummy_auth = + match acct_update.authorization with + | Control.Proof _ -> + Control.Proof Proof.transaction_dummy + | Control.Signature _ -> + Control.Signature Signature.dummy + | Control.None_given -> + Control.None_given + in + { acct_update with authorization = dummy_auth } ) + } + in + zkapp_cmd_hasher cmd_dummy_signatures_and_proofs + in (hash_signed_command, hash_zkapp_command) [%%ifdef consensus_mechanism] From 2c34f5624920dd1932db3637b3a61b4df00952b2 Mon Sep 17 00:00:00 2001 From: Paul Steckler Date: Wed, 14 Sep 2022 15:52:42 -0700 Subject: [PATCH 130/144] Lazy verification key and prover in zkapp_test_transaction --- src/app/zkapp_test_transaction/lib/commands.ml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/app/zkapp_test_transaction/lib/commands.ml b/src/app/zkapp_test_transaction/lib/commands.ml index 645106ce302..f8bf6801c86 100644 --- a/src/app/zkapp_test_transaction/lib/commands.ml +++ b/src/app/zkapp_test_transaction/lib/commands.ml @@ -26,8 +26,9 @@ let parse_field_element_or_hash_string s ~f = | Error e1 -> Error.raise (Error.tag ~tag:"Expected a field element" e1) -let `VK vk, `Prover zkapp_prover = - Transaction_snark.For_tests.create_trivial_snapp ~constraint_constants () +let vk_and_prover = + lazy + (Transaction_snark.For_tests.create_trivial_snapp ~constraint_constants ()) let gen_proof ?(zkapp_account = None) (zkapp_command : Zkapp_command.t) = let ledger = Ledger.create ~depth:constraint_constants.ledger_depth () in @@ -42,6 +43,7 @@ let gen_proof ?(zkapp_account = None) (zkapp_command : Zkapp_command.t) = in let _v = Option.value_map zkapp_account ~default:() ~f:(fun pk -> + let `VK vk, `Prover _ = Lazy.force vk_and_prover in let id = Account_id.create pk Token_id.default in Ledger.get_or_create_account ledger id { (Account.create id Currency.Balance.(of_int 1000000000000)) with @@ -357,6 +359,7 @@ let upgrade_zkapp ~debug ~keyfile ~fee ~nonce ~memo ~zkapp_keyfile } in let%bind zkapp_command = + let `VK _, `Prover zkapp_prover = Lazy.force vk_and_prover in Transaction_snark.For_tests.update_states ~zkapp_prover ~constraint_constants spec in @@ -425,6 +428,7 @@ let update_state ~debug ~keyfile ~fee ~nonce ~memo ~zkapp_keyfile ~app_state = } in let%bind zkapp_command = + let `VK _, `Prover zkapp_prover = Lazy.force vk_and_prover in Transaction_snark.For_tests.update_states ~zkapp_prover ~constraint_constants spec in @@ -461,6 +465,7 @@ let update_zkapp_uri ~debug ~keyfile ~fee ~nonce ~memo ~snapp_keyfile ~zkapp_uri } in let%bind zkapp_command = + let `VK _, `Prover zkapp_prover = Lazy.force vk_and_prover in Transaction_snark.For_tests.update_states ~zkapp_prover ~constraint_constants spec in @@ -499,6 +504,7 @@ let update_sequence_state ~debug ~keyfile ~fee ~nonce ~memo ~zkapp_keyfile } in let%bind zkapp_command = + let `VK _, `Prover zkapp_prover = Lazy.force vk_and_prover in Transaction_snark.For_tests.update_states ~zkapp_prover ~constraint_constants spec in @@ -535,6 +541,7 @@ let update_token_symbol ~debug ~keyfile ~fee ~nonce ~memo ~snapp_keyfile } in let%bind zkapp_command = + let `VK _, `Prover zkapp_prover = Lazy.force vk_and_prover in Transaction_snark.For_tests.update_states ~zkapp_prover ~constraint_constants spec in @@ -572,6 +579,7 @@ let update_permissions ~debug ~keyfile ~fee ~nonce ~memo ~zkapp_keyfile } in let%bind zkapp_command = + let `VK _, `Prover zkapp_prover = Lazy.force vk_and_prover in Transaction_snark.For_tests.update_states ~zkapp_prover ~constraint_constants spec in From 4408338f3f87c38a586a77344842da5d81164bd7 Mon Sep 17 00:00:00 2001 From: Oghenevwogaga Ebresafe Date: Thu, 15 Sep 2022 00:11:39 +0100 Subject: [PATCH 131/144] Basic fix --- .../graphql_basic_scalars/graphql_basic_scalars.ml | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/lib/graphql_basic_scalars/graphql_basic_scalars.ml b/src/lib/graphql_basic_scalars/graphql_basic_scalars.ml index b978d8e63e2..637aff9168b 100644 --- a/src/lib/graphql_basic_scalars/graphql_basic_scalars.ml +++ b/src/lib/graphql_basic_scalars/graphql_basic_scalars.ml @@ -27,10 +27,19 @@ let unsigned_scalar_scalar ~to_string typ_name = (Stdlib.String.lowercase_ascii typ_name) ) ~coerce:(fun num -> `String (to_string num)) +(* guard against negative wrap around behaviour from + the `integers` library *) +let parse_uinteger json ~f = + let s = Yojson.Basic.Util.to_string json in + let neg = String.starts_with ~prefix:"-" s in + if neg then + failwith "Cannot parse string starting with a minus as an unsigned integer" + else f s + module UInt32 : Json_intf with type t = Unsigned.UInt32.t = struct type t = Unsigned.UInt32.t - let parse json = Yojson.Basic.Util.to_string json |> Unsigned.UInt32.of_string + let parse = parse_uinteger ~f:Unsigned.UInt32.of_string let serialize value = `String (Unsigned.UInt32.to_string value) @@ -41,7 +50,7 @@ end module UInt64 : Json_intf with type t = Unsigned.UInt64.t = struct type t = Unsigned.UInt64.t - let parse json = Yojson.Basic.Util.to_string json |> Unsigned.UInt64.of_string + let parse = parse_uinteger ~f:Unsigned.UInt64.of_string let serialize value = `String (Unsigned.UInt64.to_string value) From 0daf97879b56d4200bc628e07f30b8ff91438b69 Mon Sep 17 00:00:00 2001 From: David Wong Date: Wed, 14 Sep 2022 17:43:58 -0700 Subject: [PATCH 132/144] [crypto][wasm] add more to the README --- src/lib/crypto/kimchi_bindings/wasm/README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/lib/crypto/kimchi_bindings/wasm/README.md b/src/lib/crypto/kimchi_bindings/wasm/README.md index 0701b35ab74..8ae65018ef4 100644 --- a/src/lib/crypto/kimchi_bindings/wasm/README.md +++ b/src/lib/crypto/kimchi_bindings/wasm/README.md @@ -7,7 +7,7 @@ This code allows us to compile parts of Kimchi into [Web Assembly (WASM)](https: For this to work, you will need to install the following dependencies: * [wasm-pack](https://rustwasm.github.io/wasm-pack/installer/) -* [wasm-bindgen-cli](https://rustwasm.github.io/docs/wasm-bindgen/reference/cli.html) +* [wasm-bindgen-cli](https://rustwasm.github.io/docs/wasm-bindgen/reference/cli.html) (optional) ## Usage @@ -23,6 +23,11 @@ To build for web browsers: $ wasm-pack build --mode no-install --target web --out-dir ./web ./. ``` +Note that optimized versions of these commands are available in: + +* [/src/lib/crypto/kimchi_bindings/js/node_js/build.sh](/src/lib/crypto/kimchi_bindings/js/node_js/build.sh) (also called from the `dune` file in the same folder) +* [/src/lib/crypto/kimchi_bindings/js/chrome/build.sh](/src/lib/crypto/kimchi_bindings/js/chrome/build.sh) (also called from the `dune` file in the same folder) + ## Resources * [Rust WASM book](https://rustwasm.github.io/docs/book/game-of-life/hello-world.html) From e5881bc6c410ccf7723c22a242aba8034ab032a0 Mon Sep 17 00:00:00 2001 From: Yves-Stan Le Cornec Date: Thu, 15 Sep 2022 11:31:45 +0200 Subject: [PATCH 133/144] graphql_ppx decode TransactionId automatically --- src/app/cli/src/init/client.ml | 7 ++----- src/graphql-ppx-config.inc | 3 +++ .../integration_test_cloud_engine/kubernetes_network.ml | 7 ++----- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/app/cli/src/init/client.ml b/src/app/cli/src/init/client.ml index 8d383858271..05e007de3fe 100644 --- a/src/app/cli/src/init/client.ml +++ b/src/app/cli/src/init/client.ml @@ -496,11 +496,8 @@ let batch_send_payments = (Args.zip2 Cli_lib.Flag.privkey_read_path payment_path_flag) ~f:main ) -let transaction_id_to_string = function - | `String s -> - s - | _ -> - "Unexpected JSON for transaction id" +let transaction_id_to_string id = + Yojson.Basic.to_string (Graphql_lib.Scalars.TransactionId.serialize id) let send_payment_graphql = let open Command.Param in diff --git a/src/graphql-ppx-config.inc b/src/graphql-ppx-config.inc index 181231a5e8d..e0de8c99ade 100644 --- a/src/graphql-ppx-config.inc +++ b/src/graphql-ppx-config.inc @@ -97,6 +97,9 @@ Graphql_lib.Scalars.StagedLedgerAuxHash -custom-field PendingCoinbaseHash Graphql_lib.Scalars.PendingCoinbaseHash +-custom-field +TransactionId +Graphql_lib.Scalars.TransactionId -extend-query=Graphql_lib.Serializing.ExtendQuery -extend-mutation=Graphql_lib.Serializing.ExtendQuery -future-added-value=false diff --git a/src/lib/integration_test_cloud_engine/kubernetes_network.ml b/src/lib/integration_test_cloud_engine/kubernetes_network.ml index 31ea371c65e..05d55963194 100644 --- a/src/lib/integration_test_cloud_engine/kubernetes_network.ml +++ b/src/lib/integration_test_cloud_engine/kubernetes_network.ml @@ -645,11 +645,8 @@ module Node = struct ; nonce : Mina_numbers.Account_nonce.t } - let transaction_id_to_string = function - | `String s -> - s - | _ -> - failwith "Unexpected JSON for transaction ID" + let transaction_id_to_string id = + Yojson.Basic.to_string (Graphql_lib.Scalars.TransactionId.serialize id) (* if we expect failure, might want retry_on_graphql_error to be false *) let send_payment ~logger t ~sender_pub_key ~receiver_pub_key ~amount ~fee = From 551b2cb84726f3dbd0e5c726df39006f4defee6e Mon Sep 17 00:00:00 2001 From: Yves-Stan Le Cornec Date: Thu, 15 Sep 2022 11:34:49 +0200 Subject: [PATCH 134/144] Convert bin_prot Read_error exception into Error in of_base64 --- src/lib/codable/codable.ml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/lib/codable/codable.ml b/src/lib/codable/codable.ml index 2a5a58919fd..bb7c1df5ae3 100644 --- a/src/lib/codable/codable.ml +++ b/src/lib/codable/codable.ml @@ -137,8 +137,10 @@ struct let of_base64 b64 : T.t Or_error.t = match Base64.decode b64 with - | Ok s -> - Ok (Binable.of_string (module T) s) + | Ok s -> ( + try Ok (Binable.of_string (module T) s) + with Bin_prot.Common.Read_error _ as e -> + Error (Error.of_exn ~backtrace:`Get e) ) | Error (`Msg msg) -> Error (Error.of_string msg) end From 59deedce59f2b2c2e09e2a44e56bce8514dca242 Mon Sep 17 00:00:00 2001 From: Paul Steckler Date: Mon, 19 Sep 2022 13:25:51 -0700 Subject: [PATCH 135/144] Make Base64 coding available for verification keys --- src/app/archive/archive_lib/processor.ml | 5 +---- src/lib/pickles/pickles_intf.ml | 6 ++---- src/lib/pickles/side_loaded_verification_key.ml | 3 +++ 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/app/archive/archive_lib/processor.ml b/src/app/archive/archive_lib/processor.ml index ee308447bbc..a2515d57cd4 100644 --- a/src/app/archive/archive_lib/processor.ml +++ b/src/app/archive/archive_lib/processor.ml @@ -464,10 +464,7 @@ module Zkapp_verification_keys = struct , Pickles.Backend.Tick.Field.t ) With_hash.t ) = let verification_key = - Binable.to_string - (module Pickles.Side_loaded.Verification_key.Stable.Latest) - vk.data - |> Base64.encode_exn + Pickles.Side_loaded.Verification_key.to_base64 vk.data in let hash = Pickles.Backend.Tick.Field.to_string vk.hash in let value = { hash; verification_key } in diff --git a/src/lib/pickles/pickles_intf.ml b/src/lib/pickles/pickles_intf.ml index 974b0cfb767..44135e73701 100644 --- a/src/lib/pickles/pickles_intf.ml +++ b/src/lib/pickles/pickles_intf.ml @@ -283,11 +283,9 @@ module type S = sig end end] - val to_base58_check : t -> string + include Codable.Base58_check_intf with type t := t - val of_base58_check : string -> t Or_error.t - - val of_base58_check_exn : string -> t + include Codable.Base64_intf with type t := t val dummy : t diff --git a/src/lib/pickles/side_loaded_verification_key.ml b/src/lib/pickles/side_loaded_verification_key.ml index d1a337fd32b..b1f8135652d 100644 --- a/src/lib/pickles/side_loaded_verification_key.ml +++ b/src/lib/pickles/side_loaded_verification_key.ml @@ -277,6 +277,7 @@ module Stable = struct include T include Codable.Make_base58_check (T) + include Codable.Make_base64 (T) end end] @@ -285,6 +286,8 @@ Stable.Latest. ( to_base58_check , of_base58_check , of_base58_check_exn + , to_base64 + , of_base64 , sexp_of_t , t_of_sexp , to_yojson From 3295f666cf49de88aa654c1e4a4b14ac6d557864 Mon Sep 17 00:00:00 2001 From: Paul Steckler Date: Mon, 19 Sep 2022 13:46:10 -0700 Subject: [PATCH 136/144] Use of_base64 when loading vk --- src/app/archive/archive_lib/load_data.ml | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/app/archive/archive_lib/load_data.ml b/src/app/archive/archive_lib/load_data.ml index 4b6dec21c0b..8ab70354485 100644 --- a/src/app/archive/archive_lib/load_data.ml +++ b/src/app/archive/archive_lib/load_data.ml @@ -160,18 +160,16 @@ let update_of_id pool update_id = in Set_or_keep.of_option (Option.map vk_opt ~f:(fun { verification_key; hash } -> - match Base64.decode verification_key with - | Ok s -> - let data = - Binable.of_string - (module Pickles.Side_loaded.Verification_key.Stable.Latest) - s - in + match + Pickles.Side_loaded.Verification_key.of_base64 verification_key + with + | Ok vk -> + let data = vk in let hash = Pickles.Backend.Tick.Field.of_string hash in { With_hash.data; hash } - | Error (`Msg err) -> - failwithf "Could not Base64-decode verification key: %s" err () ) - ) + | Error err -> + failwithf "Could not Base64-decode verification key: %s" + (Error.to_string_hum err) () ) ) in let%bind permissions = let%map perms_opt = From b0a502f5c468eaa4b43d85bb9802119b2015479d Mon Sep 17 00:00:00 2001 From: Paul Steckler Date: Mon, 19 Sep 2022 16:36:08 -0700 Subject: [PATCH 137/144] fix tag with git hash --- scripts/release-docker.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/scripts/release-docker.sh b/scripts/release-docker.sh index 4239ee10798..2bde9f9b331 100755 --- a/scripts/release-docker.sh +++ b/scripts/release-docker.sh @@ -110,7 +110,11 @@ if [[ -z "${BUILDKITE_PULL_REQUEST_REPO}" ]]; then REPO="--build-arg MINA_REPO=https://github.com/MinaProtocol/mina" fi -TAG="minaprotocol/$SERVICE:$VERSION" +MINAPROTOCOL="minaprotocol" +TAG="$MINAPROTOCOL/$SERVICE:$VERSION" + +GITHASH=$(git rev-parse --short=7 HEAD) +HASHTAG="$MINAPROTOCOL/$SERVICE:$GITHASH" # If DOCKER_CONTEXT is not specified, assume none and just pipe the dockerfile into docker build extra_build_args=$(echo ${EXTRA} | tr -d '"') @@ -122,9 +126,7 @@ fi tag-and-push() { docker tag "${TAG}" "$1" - - export GITHASH=$(git rev-parse --short=7 HEAD) - docker tag "${GITHASH}" "$1" + docker tag "${HASHTAG}" "$1" docker push "$1" } From cc8b24cd4e9382419a708edd002a3b6aad0d52cb Mon Sep 17 00:00:00 2001 From: Paul Steckler Date: Mon, 19 Sep 2022 17:07:20 -0700 Subject: [PATCH 138/144] another tag try --- scripts/release-docker.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/release-docker.sh b/scripts/release-docker.sh index 2bde9f9b331..98a541cfc13 100755 --- a/scripts/release-docker.sh +++ b/scripts/release-docker.sh @@ -126,7 +126,7 @@ fi tag-and-push() { docker tag "${TAG}" "$1" - docker tag "${HASHTAG}" "$1" + docker tag "${TAG}" "${HASHTAG}" docker push "$1" } From 0268c84e3b4bbf32a4fc0893736a827d7dd84139 Mon Sep 17 00:00:00 2001 From: Paul Steckler Date: Mon, 19 Sep 2022 17:37:00 -0700 Subject: [PATCH 139/144] push tag w/ hash separately --- scripts/release-docker.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/release-docker.sh b/scripts/release-docker.sh index 98a541cfc13..d06519b2a59 100755 --- a/scripts/release-docker.sh +++ b/scripts/release-docker.sh @@ -128,6 +128,7 @@ tag-and-push() { docker tag "${TAG}" "$1" docker tag "${TAG}" "${HASHTAG}" docker push "$1" + docker push "${HASHTAG}" } if [ -z "$NOUPLOAD" ] || [ "$NOUPLOAD" -eq 0 ]; then From 2a167662bbbe5b96dccd1d7dbb28ad004702902f Mon Sep 17 00:00:00 2001 From: Paul Steckler Date: Mon, 19 Sep 2022 18:09:29 -0700 Subject: [PATCH 140/144] add network qualifier --- scripts/release-docker.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/release-docker.sh b/scripts/release-docker.sh index d06519b2a59..b14c101ac00 100755 --- a/scripts/release-docker.sh +++ b/scripts/release-docker.sh @@ -114,7 +114,7 @@ MINAPROTOCOL="minaprotocol" TAG="$MINAPROTOCOL/$SERVICE:$VERSION" GITHASH=$(git rev-parse --short=7 HEAD) -HASHTAG="$MINAPROTOCOL/$SERVICE:$GITHASH" +HASHTAG="$MINAPROTOCOL/$SERVICE:$GITHASH-${NETWORK##*=}" # If DOCKER_CONTEXT is not specified, assume none and just pipe the dockerfile into docker build extra_build_args=$(echo ${EXTRA} | tr -d '"') From 9cc2210a79e112faa85b2ec0d6569a32a6d05e9c Mon Sep 17 00:00:00 2001 From: Paul Steckler Date: Mon, 19 Sep 2022 19:35:25 -0700 Subject: [PATCH 141/144] echo VERSION --- scripts/release-docker.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/release-docker.sh b/scripts/release-docker.sh index b14c101ac00..7b4dbb813c8 100755 --- a/scripts/release-docker.sh +++ b/scripts/release-docker.sh @@ -114,7 +114,9 @@ MINAPROTOCOL="minaprotocol" TAG="$MINAPROTOCOL/$SERVICE:$VERSION" GITHASH=$(git rev-parse --short=7 HEAD) -HASHTAG="$MINAPROTOCOL/$SERVICE:$GITHASH-${NETWORK##*=}" +HASHTAG="$MINAPROTOCOL/$SERVICE:$GITHASH-$VERSION" + +echo "VERSION IS" $VERSION # If DOCKER_CONTEXT is not specified, assume none and just pipe the dockerfile into docker build extra_build_args=$(echo ${EXTRA} | tr -d '"') From 0a057a6806b36819cd5eb3c6e6643375ba1e6476 Mon Sep 17 00:00:00 2001 From: Paul Steckler Date: Mon, 19 Sep 2022 20:31:21 -0700 Subject: [PATCH 142/144] Build HASHTAG --- scripts/release-docker.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/release-docker.sh b/scripts/release-docker.sh index 7b4dbb813c8..7df9df9a6bf 100755 --- a/scripts/release-docker.sh +++ b/scripts/release-docker.sh @@ -114,9 +114,9 @@ MINAPROTOCOL="minaprotocol" TAG="$MINAPROTOCOL/$SERVICE:$VERSION" GITHASH=$(git rev-parse --short=7 HEAD) -HASHTAG="$MINAPROTOCOL/$SERVICE:$GITHASH-$VERSION" +HASHTAG="$MINAPROTOCOL/$SERVICE:$GITHASH-$DEB_RELEASE-$NETWORK" -echo "VERSION IS" $VERSION +echo "HASHTAG IS" $HASHTAG # If DOCKER_CONTEXT is not specified, assume none and just pipe the dockerfile into docker build extra_build_args=$(echo ${EXTRA} | tr -d '"') From 6af6694e26fb457afeb1f9c5b478da1daecac196 Mon Sep 17 00:00:00 2001 From: Paul Steckler Date: Mon, 19 Sep 2022 21:10:09 -0700 Subject: [PATCH 143/144] another try at HASHTAG --- scripts/release-docker.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/release-docker.sh b/scripts/release-docker.sh index 7df9df9a6bf..6db101bbb46 100755 --- a/scripts/release-docker.sh +++ b/scripts/release-docker.sh @@ -114,7 +114,7 @@ MINAPROTOCOL="minaprotocol" TAG="$MINAPROTOCOL/$SERVICE:$VERSION" GITHASH=$(git rev-parse --short=7 HEAD) -HASHTAG="$MINAPROTOCOL/$SERVICE:$GITHASH-$DEB_RELEASE-$NETWORK" +HASHTAG="$MINAPROTOCOL/$SERVICE:$GITHASH-${DEB_CODENAME##*=}-${NETWORK##*=}" echo "HASHTAG IS" $HASHTAG From 74ce0b55ef34d60db8298b57bcb879617a5eefe5 Mon Sep 17 00:00:00 2001 From: Paul Steckler Date: Mon, 19 Sep 2022 21:40:48 -0700 Subject: [PATCH 144/144] rm debug print --- scripts/release-docker.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/release-docker.sh b/scripts/release-docker.sh index 6db101bbb46..bf847ff30e2 100755 --- a/scripts/release-docker.sh +++ b/scripts/release-docker.sh @@ -113,11 +113,10 @@ fi MINAPROTOCOL="minaprotocol" TAG="$MINAPROTOCOL/$SERVICE:$VERSION" +# friendly, predictable tag GITHASH=$(git rev-parse --short=7 HEAD) HASHTAG="$MINAPROTOCOL/$SERVICE:$GITHASH-${DEB_CODENAME##*=}-${NETWORK##*=}" -echo "HASHTAG IS" $HASHTAG - # If DOCKER_CONTEXT is not specified, assume none and just pipe the dockerfile into docker build extra_build_args=$(echo ${EXTRA} | tr -d '"') if [[ -z "${DOCKER_CONTEXT}" ]]; then