diff --git a/.prettierignore b/.prettierignore deleted file mode 100644 index 66279798c55..00000000000 --- a/.prettierignore +++ /dev/null @@ -1,2 +0,0 @@ -src/lib/crypto/**/*.js -src/lib/snarkyjs/src/bindings/kimchi/js/**/*.js diff --git a/genesis_ledgers/berkeley.json b/genesis_ledgers/berkeley.json index 28e78c3bd9b..7e5a8f1e025 100644 --- a/genesis_ledgers/berkeley.json +++ b/genesis_ledgers/berkeley.json @@ -1,6 +1,6 @@ { "genesis": { - "genesis_state_timestamp": "2023-04-06T23:30:01Z" + "genesis_state_timestamp": "2023-07-05T19:01:01Z" }, "ledger": { "name": "berkeley", diff --git a/scripts/mina-local-network/mina-local-network.sh b/scripts/mina-local-network/mina-local-network.sh old mode 100755 new mode 100644 diff --git a/src/app/heap_usage/values.ml b/src/app/heap_usage/values.ml index 03bdaa00e2f..04bf844668a 100644 --- a/src/app/heap_usage/values.ml +++ b/src/app/heap_usage/values.ml @@ -244,7 +244,7 @@ let scan_state_merge_node : let sok_msg : Mina_base.Sok_message.t = { fee = Currency.Fee.zero; prover = sample_pk_compressed } in - let proof = Mina_base.Proof.transaction_dummy in + let proof = Lazy.force Mina_base.Proof.transaction_dummy in let statement = let without_sok = Quickcheck.random_value ~seed:(`Deterministic "no sok left") @@ -260,7 +260,7 @@ let scan_state_merge_node : { fee = Currency.Fee.zero; prover = sample_pk_compressed } in (* so the left, right proofs differ, don't want sharing *) - let proof = Mina_base.Proof.blockchain_dummy in + let proof = Lazy.force Mina_base.Proof.blockchain_dummy in let statement = let without_sok = Quickcheck.random_value ~seed:(`Deterministic "no sok right") diff --git a/src/app/replayer/replayer.ml b/src/app/replayer/replayer.ml index e707ddbeb01..0ced4861e99 100644 --- a/src/app/replayer/replayer.ml +++ b/src/app/replayer/replayer.ml @@ -530,7 +530,7 @@ let zkapp_command_to_transaction ~logger ~pool (cmd : Sql.Zkapp_command.t) : let (authorization : Control.t) = match body.authorization_kind with | Proof _ -> - Proof Proof.transaction_dummy + Proof (Lazy.force Proof.transaction_dummy) | Signature -> Signature Signature.dummy | None_given -> diff --git a/src/app/test_executive/zkapps.ml b/src/app/test_executive/zkapps.ml index d92f2f14647..a8f63773db6 100644 --- a/src/app/test_executive/zkapps.ml +++ b/src/app/test_executive/zkapps.ml @@ -363,7 +363,8 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct | Proof _ -> { other_p with authorization = - Control.Proof Mina_base.Proof.blockchain_dummy + Control.Proof + (Lazy.force Mina_base.Proof.blockchain_dummy) } | _ -> other_p ) diff --git a/src/dune-project b/src/dune-project index aeaeae71671..5969c24462c 100644 --- a/src/dune-project +++ b/src/dune-project @@ -60,6 +60,7 @@ (package (name graphql_wrapper)) (package (name hash_prefixes)) (package (name hash_prefix_states)) +(package (name hash_prefix_create)) (package (name heap_usage)) (package (name hex)) (package (name immutable_array)) diff --git a/src/lib/crypto/kimchi_backend/pasta/basic/kimchi_pasta_basic.ml b/src/lib/crypto/kimchi_backend/pasta/basic/kimchi_pasta_basic.ml index 8caba494c7f..245a7c0ad83 100644 --- a/src/lib/crypto/kimchi_backend/pasta/basic/kimchi_pasta_basic.ml +++ b/src/lib/crypto/kimchi_backend/pasta/basic/kimchi_pasta_basic.ml @@ -147,3 +147,9 @@ module Fp_poly_comm = Kimchi_backend_common.Poly_comm.Make (struct fun unshifted shifted : t -> { shifted; unshifted } end end) + +(* poseidon params *) + +let poseidon_params_fp = Sponge.Params.(map pasta_p_kimchi ~f:Fp.of_string) + +let poseidon_params_fq = Sponge.Params.(map pasta_q_kimchi ~f:Fq.of_string) diff --git a/src/lib/crypto/kimchi_backend/pasta/constraint_system/caml/pallas_constraint_system.ml b/src/lib/crypto/kimchi_backend/pasta/constraint_system/caml/pallas_constraint_system.ml index cb59e2d0344..1cec41aa925 100644 --- a/src/lib/crypto/kimchi_backend/pasta/constraint_system/caml/pallas_constraint_system.ml +++ b/src/lib/crypto/kimchi_backend/pasta/constraint_system/caml/pallas_constraint_system.ml @@ -4,8 +4,5 @@ open Kimchi_pasta_basic include Plonk_constraint_system.Make (Fq) (Kimchi_bindings.Protocol.Gates.Vector.Fq) (struct - let params = - Sponge.Params.( - map pasta_q_kimchi ~f:(fun x -> - Fq.of_bigint (Bigint256.of_decimal_string x) )) + let params = poseidon_params_fq end) diff --git a/src/lib/crypto/kimchi_backend/pasta/constraint_system/caml/vesta_constraint_system.ml b/src/lib/crypto/kimchi_backend/pasta/constraint_system/caml/vesta_constraint_system.ml index 364673a5b85..0fff63228cd 100644 --- a/src/lib/crypto/kimchi_backend/pasta/constraint_system/caml/vesta_constraint_system.ml +++ b/src/lib/crypto/kimchi_backend/pasta/constraint_system/caml/vesta_constraint_system.ml @@ -4,8 +4,5 @@ open Kimchi_pasta_basic include Plonk_constraint_system.Make (Fp) (Kimchi_bindings.Protocol.Gates.Vector.Fp) (struct - let params = - Sponge.Params.( - map pasta_p_kimchi ~f:(fun x -> - Fp.of_bigint (Bigint256.of_decimal_string x) )) + let params = poseidon_params_fp end) diff --git a/src/lib/dummy_values/gen_values/gen_values.ml b/src/lib/dummy_values/gen_values/gen_values.ml index c468d60cfc8..83c6c506ee0 100644 --- a/src/lib/dummy_values/gen_values/gen_values.ml +++ b/src/lib/dummy_values/gen_values/gen_values.ml @@ -17,13 +17,15 @@ let str ~loc = end) in let open E in [%str - let blockchain_proof, transaction_proof = - ( Core_kernel.Binable.of_string - (module Pickles.Proof.Proofs_verified_2.Stable.Latest) - [%e estring blockchain_proof_string] - , Core_kernel.Binable.of_string - (module Pickles.Proof.Proofs_verified_2.Stable.Latest) - [%e estring transaction_proof_string] )] + let blockchain_proof () = + Core_kernel.Binable.of_string + (module Pickles.Proof.Proofs_verified_2.Stable.Latest) + [%e estring blockchain_proof_string] + + let transaction_proof () = + Core_kernel.Binable.of_string + (module Pickles.Proof.Proofs_verified_2.Stable.Latest) + [%e estring transaction_proof_string]] let main () = let fmt = diff --git a/src/lib/genesis_ledger_helper/genesis_ledger_helper.ml b/src/lib/genesis_ledger_helper/genesis_ledger_helper.ml index f9cadb3e8c8..6111e0ebe18 100644 --- a/src/lib/genesis_ledger_helper/genesis_ledger_helper.ml +++ b/src/lib/genesis_ledger_helper/genesis_ledger_helper.ml @@ -84,7 +84,8 @@ module Ledger = struct ; List.to_string balances ~f:(fun (i, balance) -> sprintf "%i %s" i (Currency.Balance.to_string balance) ) ; (* Distinguish ledgers when the hash function is different. *) - Snark_params.Tick.Field.to_string Mina_base.Account.empty_digest + Snark_params.Tick.Field.to_string + (Lazy.force Mina_base.Account.empty_digest) ; (* Distinguish ledgers when the account record layout has changed. *) Bin_prot.Writer.to_string Mina_base.Account.Stable.Latest.bin_writer_t Mina_base.Account.empty diff --git a/src/lib/hash_prefix_states/dune b/src/lib/hash_prefix_states/dune index 6bc34f49e0d..bcf00effb71 100644 --- a/src/lib/hash_prefix_states/dune +++ b/src/lib/hash_prefix_states/dune @@ -12,6 +12,7 @@ random_oracle mina_signature_kind hash_prefixes + hash_prefix_create pickles ) (preprocessor_deps ../../config.mlh) diff --git a/src/lib/hash_prefix_states/hash_prefix_create/dune b/src/lib/hash_prefix_states/hash_prefix_create/dune new file mode 100644 index 00000000000..7d88aa2b5d8 --- /dev/null +++ b/src/lib/hash_prefix_states/hash_prefix_create/dune @@ -0,0 +1,10 @@ +(library + (name hash_prefix_create) + (public_name hash_prefix_create) + (libraries hash_prefixes random_oracle) + (instrumentation + (backend bisect_ppx)) + (preprocess + (pps ppx_version)) + (virtual_modules hash_prefix_create) + (default_implementation hash_prefix_create.native)) diff --git a/src/lib/hash_prefix_states/hash_prefix_create/hash_prefix_create.mli b/src/lib/hash_prefix_states/hash_prefix_create/hash_prefix_create.mli new file mode 100644 index 00000000000..5854bb9998f --- /dev/null +++ b/src/lib/hash_prefix_states/hash_prefix_create/hash_prefix_create.mli @@ -0,0 +1,3 @@ +val salt : string -> Random_oracle.Digest.t Random_oracle.State.t + +val salt_legacy : string -> Random_oracle.Digest.t Random_oracle.Legacy.State.t diff --git a/src/lib/hash_prefix_states/hash_prefix_create/js/dune b/src/lib/hash_prefix_states/hash_prefix_create/js/dune new file mode 100644 index 00000000000..2c9f199a7b6 --- /dev/null +++ b/src/lib/hash_prefix_states/hash_prefix_create/js/dune @@ -0,0 +1,9 @@ +(library + (public_name hash_prefix_create.js) + (name hash_prefix_create_js) + (libraries pickles random_oracle js_of_ocaml base core_kernel) + (instrumentation + (backend bisect_ppx)) + (preprocess + (pps ppx_version)) + (implements hash_prefix_create)) diff --git a/src/lib/hash_prefix_states/hash_prefix_create/js/hash_prefix_create.ml b/src/lib/hash_prefix_states/hash_prefix_create/js/hash_prefix_create.ml new file mode 100644 index 00000000000..ad5335830d5 --- /dev/null +++ b/src/lib/hash_prefix_states/hash_prefix_create/js/hash_prefix_create.ml @@ -0,0 +1,31 @@ +open Core_kernel +module Js = Js_of_ocaml.Js +module Field = Pickles.Impls.Step.Field.Constant + +external get_ts_bindings : unit -> Js.Unsafe.any Js.Optdef.t = "getTsBindings" + +(* the ?. operator from JS *) +let ( |. ) (value : _ Js.Optdef.t) (key : string) = + Js.( + if phys_equal value undefined then undefined + else Unsafe.get value (string key)) + +let lookup kind prefix = + get_ts_bindings () |. kind |. prefix |> Js.Optdef.to_option + +let of_js x = + Js.to_array x |> Array.map ~f:(Fn.compose Field.of_string Js.to_string) + +let salt s = + match lookup "prefixHashes" s with + | Some state -> + of_js state |> Random_oracle.State.of_array + | None -> + Random_oracle.salt s + +let salt_legacy s = + match lookup "prefixHashesLegacy" s with + | Some state -> + of_js state |> Random_oracle.Legacy.State.of_array + | None -> + Random_oracle.Legacy.salt s diff --git a/src/lib/hash_prefix_states/hash_prefix_create/native/dune b/src/lib/hash_prefix_states/hash_prefix_create/native/dune new file mode 100644 index 00000000000..5f4d54d917c --- /dev/null +++ b/src/lib/hash_prefix_states/hash_prefix_create/native/dune @@ -0,0 +1,9 @@ +(library + (public_name hash_prefix_create.native) + (name hash_prefix_create_native) + (libraries random_oracle) + (instrumentation + (backend bisect_ppx)) + (preprocess + (pps ppx_version)) + (implements hash_prefix_create)) diff --git a/src/lib/hash_prefix_states/hash_prefix_create/native/hash_prefix_create.ml b/src/lib/hash_prefix_states/hash_prefix_create/native/hash_prefix_create.ml new file mode 100644 index 00000000000..05e667338e5 --- /dev/null +++ b/src/lib/hash_prefix_states/hash_prefix_create/native/hash_prefix_create.ml @@ -0,0 +1,3 @@ +let salt = Random_oracle.salt + +let salt_legacy = Random_oracle.Legacy.salt diff --git a/src/lib/hash_prefix_states/hash_prefix_states.ml b/src/lib/hash_prefix_states/hash_prefix_states.ml index 4b1ecfcfb31..2e37421de63 100644 --- a/src/lib/hash_prefix_states/hash_prefix_states.ml +++ b/src/lib/hash_prefix_states/hash_prefix_states.ml @@ -1,9 +1,10 @@ open Core_kernel open Hash_prefixes -let salt (s : Hash_prefixes.t) = Random_oracle.salt (s :> string) +let salt (s : Hash_prefixes.t) = Hash_prefix_create.salt (s :> string) -let salt_legacy (s : Hash_prefixes.t) = Random_oracle.Legacy.salt (s :> string) +let salt_legacy (s : Hash_prefixes.t) = + Hash_prefix_create.salt_legacy (s :> string) let receipt_chain_signed_command = salt_legacy receipt_chain_user_command diff --git a/src/lib/ledger_proof/ledger_proof.ml b/src/lib/ledger_proof/ledger_proof.ml index d2d21435abc..cdc807ed22c 100644 --- a/src/lib/ledger_proof/ledger_proof.ml +++ b/src/lib/ledger_proof/ledger_proof.ml @@ -37,5 +37,5 @@ include Prod module For_tests = struct let mk_dummy_proof statement = create ~statement ~sok_digest:Sok_message.Digest.default - ~proof:Proof.transaction_dummy + ~proof:(Lazy.force Proof.transaction_dummy) end diff --git a/src/lib/mina_base/account.ml b/src/lib/mina_base/account.ml index 7f7cece5802..51b46d25629 100644 --- a/src/lib/mina_base/account.ml +++ b/src/lib/mina_base/account.ml @@ -626,7 +626,7 @@ let empty = ; zkapp = None } -let empty_digest = digest empty +let empty_digest = lazy (digest empty) let create account_id balance = let public_key = Account_id.public_key account_id in diff --git a/src/lib/mina_base/account_update.ml b/src/lib/mina_base/account_update.ml index 75a99702a19..8b47a941964 100644 --- a/src/lib/mina_base/account_update.ml +++ b/src/lib/mina_base/account_update.ml @@ -908,8 +908,8 @@ module Update = struct } ) ) ; Set_or_keep.typ ~dummy:Permissions.empty Permissions.typ ; Set_or_keep.optional_typ - (Data_as_hash.optional_typ ~hash:Zkapp_account.hash_zkapp_uri - ~non_preimage:(Zkapp_account.hash_zkapp_uri_opt None) + (Data_as_hash.lazy_optional_typ ~hash:Zkapp_account.hash_zkapp_uri + ~non_preimage:(lazy (Zkapp_account.hash_zkapp_uri_opt None)) ~dummy_value:"" ) ~to_option:Fn.id ~of_option:Fn.id ; Set_or_keep.typ ~dummy:Account.Token_symbol.default diff --git a/src/lib/mina_base/data_as_hash.ml b/src/lib/mina_base/data_as_hash.ml index 97561357d3b..e0d956857c2 100644 --- a/src/lib/mina_base/data_as_hash.ml +++ b/src/lib/mina_base/data_as_hash.ml @@ -20,6 +20,14 @@ let optional_typ ~hash ~non_preimage ~dummy_value = | None -> (non_preimage, dummy_value) | Some s -> (hash s, s) ) ~back:(fun (_, s) -> Some s) +let lazy_optional_typ ~hash ~non_preimage ~dummy_value = + Typ.transport + Typ.(Field.typ * Internal.ref ()) + ~there:(function + | None -> (Lazy.force non_preimage, dummy_value) | Some s -> (hash s, s) + ) + ~back:(fun (_, s) -> Some s) + let to_input (x, _) = Random_oracle_input.Chunked.field x let if_ b ~then_ ~else_ = diff --git a/src/lib/mina_base/data_as_hash.mli b/src/lib/mina_base/data_as_hash.mli index 332e2c9fcd8..90f15db1ccb 100644 --- a/src/lib/mina_base/data_as_hash.mli +++ b/src/lib/mina_base/data_as_hash.mli @@ -36,6 +36,12 @@ val optional_typ : -> dummy_value:'value -> ('value t, 'value option) Typ.t +val lazy_optional_typ : + hash:('value -> Field.t) + -> non_preimage:Field.t lazy_t + -> dummy_value:'value + -> ('value t, 'value option) Typ.t + val to_input : _ t -> Field.Var.t Random_oracle_input.Chunked.t val if_ : Boolean.var -> then_:'value t -> else_:'value t -> 'value t diff --git a/src/lib/mina_base/dune b/src/lib/mina_base/dune index c62f5209a38..793ab63a815 100644 --- a/src/lib/mina_base/dune +++ b/src/lib/mina_base/dune @@ -40,6 +40,7 @@ rosetta_coding random_oracle hash_prefix_states + hash_prefix_create dummy_values currency mina_numbers diff --git a/src/lib/mina_base/pending_coinbase.ml b/src/lib/mina_base/pending_coinbase.ml index dc8639181ba..c4a6b81d99c 100644 --- a/src/lib/mina_base/pending_coinbase.ml +++ b/src/lib/mina_base/pending_coinbase.ml @@ -181,7 +181,7 @@ module Make_str (A : Wire_types.Concrete) = struct (Input.Chunked.append (Coinbase_data.to_input coinbase) (to_input h)) ) |> of_hash - let empty = Random_oracle.salt "CoinbaseStack" |> Random_oracle.digest + let empty = Hash_prefix_create.salt "CoinbaseStack" |> Random_oracle.digest module Checked = struct type t = var @@ -394,7 +394,8 @@ module Make_str (A : Wire_types.Concrete) = struct |> of_hash let empty_hash = - Random_oracle.(digest (salt "PendingCoinbaseMerkleTree")) |> of_hash + Hash_prefix_create.salt "PendingCoinbaseMerkleTree" + |> Random_oracle.digest |> of_hash let of_digest = Fn.compose Fn.id of_hash end @@ -1018,12 +1019,16 @@ module Make_str (A : Wire_types.Concrete) = struct type t = (Merkle_tree.t, Stack_id.t) Poly.t [@@deriving sexp, to_yojson] - let init_hash = Stack.data_hash Stack.empty - let hash_at_level = - let cached = ref [| init_hash |] in + let cached = ref [||] in fun i -> let len = Array.length !cached in + let len = + if len = 0 then ( + cached := [| Stack.data_hash Stack.empty |] ; + 1 ) + else len + in ( if i >= len then let cur_hash = ref (Array.last !cached) in cached := diff --git a/src/lib/mina_base/proof.ml b/src/lib/mina_base/proof.ml index 3404770ad40..dbf7296c661 100644 --- a/src/lib/mina_base/proof.ml +++ b/src/lib/mina_base/proof.ml @@ -2,9 +2,9 @@ open Core_kernel -let blockchain_dummy = Dummy_values.blockchain_proof +let blockchain_dummy = lazy (Dummy_values.blockchain_proof ()) -let transaction_dummy = Dummy_values.transaction_proof +let transaction_dummy = lazy (Dummy_values.transaction_proof ()) [%%versioned module Stable = struct diff --git a/src/lib/mina_base/proof.mli b/src/lib/mina_base/proof.mli index 469a7d6efc3..813a2b1883f 100644 --- a/src/lib/mina_base/proof.mli +++ b/src/lib/mina_base/proof.mli @@ -2,9 +2,9 @@ open Pickles_types type t = (Nat.N2.n, Nat.N2.n) Pickles.Proof.t [@@deriving sexp, compare, yojson] -val blockchain_dummy : t +val blockchain_dummy : t lazy_t -val transaction_dummy : t +val transaction_dummy : t lazy_t [%%versioned: module Stable : sig diff --git a/src/lib/mina_base/receipt.ml b/src/lib/mina_base/receipt.ml index 863d6273096..040ae48093b 100644 --- a/src/lib/mina_base/receipt.ml +++ b/src/lib/mina_base/receipt.ml @@ -47,7 +47,8 @@ module Chain_hash = struct let equal = Stable.Latest.equal - let empty = of_hash Random_oracle.(salt "CodaReceiptEmpty" |> digest) + let empty = + of_hash (Hash_prefix_create.salt "CodaReceiptEmpty" |> Random_oracle.digest) let cons_signed_command_payload (e : Signed_command_elt.t) (t : t) = let open Random_oracle.Legacy in diff --git a/src/lib/mina_base/test/zkapp_command_test.ml b/src/lib/mina_base/test/zkapp_command_test.ml index b21e243cac6..2deb78a2c70 100644 --- a/src/lib/mina_base/test/zkapp_command_test.ml +++ b/src/lib/mina_base/test/zkapp_command_test.ml @@ -119,9 +119,10 @@ end = struct let full = deriver @@ Fd.o () let json_roundtrip_dummy () = + let dummy = Lazy.force dummy in [%test_eq: t] dummy (dummy |> Fd.to_json full |> Fd.of_json full) let full_circuit () = Run_in_thread.block_on_async_exn - @@ fun () -> Fields_derivers_zkapps.Test.Loop.run full dummy + @@ fun () -> Fields_derivers_zkapps.Test.Loop.run full (Lazy.force dummy) end diff --git a/src/lib/mina_base/zkapp_account.ml b/src/lib/mina_base/zkapp_account.ml index 395aa049ba3..0218f9dce6c 100644 --- a/src/lib/mina_base/zkapp_account.ml +++ b/src/lib/mina_base/zkapp_account.ml @@ -34,7 +34,8 @@ end) = struct type t = Event.t list [@@deriving compare, sexp] - let empty_hash = Random_oracle.(salt Inputs.salt_phrase |> digest) + let empty_hash = + Hash_prefix_create.salt Inputs.salt_phrase |> Random_oracle.digest let push_hash acc hash = Random_oracle.hash ~init:Inputs.hash_prefix [| acc; hash |] @@ -126,7 +127,7 @@ module Actions = struct let empty_state_element = let salt_phrase = "MinaZkappActionStateEmptyElt" in - Random_oracle.(salt salt_phrase |> digest) + Hash_prefix_create.salt salt_phrase |> Random_oracle.digest let push_events (acc : Field.t) (events : t) : Field.t = push_hash acc (hash events) @@ -344,8 +345,8 @@ let typ : (Checked.t, t) Typ.t = let open Poly in Typ.of_hlistable [ Zkapp_state.typ Field.typ - ; Flagged_option.option_typ - ~default:{ With_hash.data = None; hash = dummy_vk_hash () } + ; Flagged_option.lazy_option_typ + ~default:(lazy { With_hash.data = None; hash = dummy_vk_hash () }) (Data_as_hash.typ ~hash:With_hash.hash) |> Typ.transport ~there:(Option.map ~f:(With_hash.map ~f:Option.some)) diff --git a/src/lib/mina_base/zkapp_basic.ml b/src/lib/mina_base/zkapp_basic.ml index 1b14b041006..37d96cfb5a2 100644 --- a/src/lib/mina_base/zkapp_basic.ml +++ b/src/lib/mina_base/zkapp_basic.ml @@ -90,6 +90,11 @@ module Flagged_option = struct let option_typ ~default t = Typ.transport (typ t) ~there:(of_option ~default) ~back:to_option + let lazy_option_typ ~default t = + Typ.transport (typ t) + ~there:(fun t -> of_option t ~default:(Lazy.force default)) + ~back:to_option + [%%endif] end diff --git a/src/lib/mina_base/zkapp_command.ml b/src/lib/mina_base/zkapp_command.ml index 29a7e8a1638..fcbc424d3e2 100644 --- a/src/lib/mina_base/zkapp_command.ml +++ b/src/lib/mina_base/zkapp_command.ml @@ -1482,20 +1482,21 @@ let arg_query_string x = Fields_derivers_zkapps.Test.Loop.json_to_string_gql @@ to_json x let dummy = - let account_update : Account_update.t = - { body = Account_update.Body.dummy - ; authorization = Control.dummy_of_tag Signature - } - in - let fee_payer : Account_update.Fee_payer.t = - { body = Account_update.Body.Fee_payer.dummy - ; authorization = Signature.dummy - } - in - { fee_payer - ; account_updates = Call_forest.cons account_update [] - ; memo = Signed_command_memo.empty - } + lazy + (let account_update : Account_update.t = + { body = Account_update.Body.dummy + ; authorization = Control.dummy_of_tag Signature + } + in + let fee_payer : Account_update.Fee_payer.t = + { body = Account_update.Body.Fee_payer.dummy + ; authorization = Signature.dummy + } + in + { fee_payer + ; account_updates = Call_forest.cons account_update [] + ; memo = Signed_command_memo.empty + } ) module Make_update_group (Input : sig type global_state diff --git a/src/lib/mina_block/mina_block.ml b/src/lib/mina_block/mina_block.ml index 22fc412bd12..9a5bd100730 100644 --- a/src/lib/mina_block/mina_block.ml +++ b/src/lib/mina_block/mina_block.ml @@ -24,7 +24,8 @@ let genesis ~precomputed_values : Block.with_hash * Validation.fully_valid = let block_with_hash = let body = Staged_ledger_diff.Body.create Staged_ledger_diff.empty_diff in let header = - Header.create ~protocol_state ~protocol_state_proof:Proof.blockchain_dummy + Header.create ~protocol_state + ~protocol_state_proof:(Lazy.force Proof.blockchain_dummy) ~delta_block_chain_proof: (Protocol_state.previous_state_hash protocol_state, []) () diff --git a/src/lib/mina_graphql/mina_graphql.ml b/src/lib/mina_graphql/mina_graphql.ml index 04f63623c55..86d7dfb0d71 100644 --- a/src/lib/mina_graphql/mina_graphql.ml +++ b/src/lib/mina_graphql/mina_graphql.ml @@ -5661,7 +5661,7 @@ module Queries = struct expensive proof generation step if we don't have one available. *) - Proof.blockchain_dummy ) + Lazy.force Proof.blockchain_dummy ) } ; hash } ) diff --git a/src/lib/mina_ledger/ledger.ml b/src/lib/mina_ledger/ledger.ml index 7e00c45d6c8..a84fcde5d27 100644 --- a/src/lib/mina_ledger/ledger.ml +++ b/src/lib/mina_ledger/ledger.ml @@ -56,7 +56,8 @@ module Ledger_inner = struct let hash_account = Fn.compose Ledger_hash.of_digest Account.digest - let empty_account = Ledger_hash.of_digest Account.empty_digest + let empty_account = + Ledger_hash.of_digest (Lazy.force Account.empty_digest) end end] end diff --git a/src/lib/mina_ledger/sync_ledger.ml b/src/lib/mina_ledger/sync_ledger.ml index 7a2360dc91d..a0c1b125dda 100644 --- a/src/lib/mina_ledger/sync_ledger.ml +++ b/src/lib/mina_ledger/sync_ledger.ml @@ -10,7 +10,7 @@ module Hash = struct let hash_account = Fn.compose Ledger_hash.of_digest Account.digest - let empty_account = Ledger_hash.of_digest Account.empty_digest + let empty_account = Ledger_hash.of_digest (Lazy.force Account.empty_digest) end module Root_hash = struct diff --git a/src/lib/network_pool/batcher.ml b/src/lib/network_pool/batcher.ml index 349de2d1f9f..06af016fbf6 100644 --- a/src/lib/network_pool/batcher.ml +++ b/src/lib/network_pool/batcher.ml @@ -533,7 +533,7 @@ module Snark_pool = struct let message = Mina_base.Sok_message.create ~fee ~prover in ( One_or_two.map statements ~f:(fun statement -> Ledger_proof.create ~statement ~sok_digest - ~proof:Proof.transaction_dummy ) + ~proof:(Lazy.force Proof.transaction_dummy) ) , message ) in Envelope.Incoming.gen data_gen diff --git a/src/lib/network_pool/snark_pool.ml b/src/lib/network_pool/snark_pool.ml index 897a32f6ce4..c22f1e2ab69 100644 --- a/src/lib/network_pool/snark_pool.ml +++ b/src/lib/network_pool/snark_pool.ml @@ -680,7 +680,7 @@ let%test_module "random set test" = , One_or_two.map work ~f:(fun statement -> Ledger_proof.create ~statement ~sok_digest:invalid_sok_digest - ~proof:Proof.transaction_dummy ) + ~proof:(Lazy.force Proof.transaction_dummy) ) , fee , some_other_pk ) :: acc ) diff --git a/src/lib/pickles/dummy.ml b/src/lib/pickles/dummy.ml index 47cea717510..b1145479371 100644 --- a/src/lib/pickles/dummy.ml +++ b/src/lib/pickles/dummy.ml @@ -7,22 +7,24 @@ open Common let wrap_domains = Common.wrap_domains let evals = - let open Plonk_types in - let e = - Evals.map (Evaluation_lengths.create ~of_int:Fn.id) ~f:(fun n -> - let a () = Array.create ~len:n (Ro.tock ()) in - (a (), a ()) ) - in - let ex = - { All_evals.With_public_input.evals = e - ; public_input = (Ro.tock (), Ro.tock ()) - } - in - { All_evals.ft_eval1 = Ro.tock (); evals = ex } + lazy + (let open Plonk_types in + let e = + Evals.map (Evaluation_lengths.create ~of_int:Fn.id) ~f:(fun n -> + let a () = Array.create ~len:n (Ro.tock ()) in + (a (), a ()) ) + in + let ex = + { All_evals.With_public_input.evals = e + ; public_input = (Ro.tock (), Ro.tock ()) + } + in + { All_evals.ft_eval1 = Ro.tock (); evals = ex }) let evals_combined = - Plonk_types.All_evals.map evals ~f1:Fn.id - ~f2:(Array.reduce_exn ~f:Backend.Tock.Field.( + )) + lazy + (Plonk_types.All_evals.map (Lazy.force evals) ~f1:Fn.id + ~f2:(Array.reduce_exn ~f:Backend.Tock.Field.( + )) ) module Ipa = struct module Wrap = struct @@ -32,8 +34,9 @@ module Ipa = struct { Bulletproof_challenge.prechallenge } ) let challenges_computed = - Vector.map challenges ~f:(fun { prechallenge } : Tock.Field.t -> - Ipa.Wrap.compute_challenge prechallenge ) + lazy + (Vector.map challenges ~f:(fun { prechallenge } : Tock.Field.t -> + Ipa.Wrap.compute_challenge prechallenge ) ) let sg = lazy (time "dummy wrap sg" (fun () -> Ipa.Wrap.compute_sg challenges)) @@ -46,8 +49,9 @@ module Ipa = struct { Bulletproof_challenge.prechallenge } ) let challenges_computed = - Vector.map challenges ~f:(fun { prechallenge } : Tick.Field.t -> - Ipa.Step.compute_challenge prechallenge ) + lazy + (Vector.map challenges ~f:(fun { prechallenge } : Tick.Field.t -> + Ipa.Step.compute_challenge prechallenge ) ) let sg = lazy (time "dummy wrap sg" (fun () -> Ipa.Step.compute_sg challenges)) diff --git a/src/lib/pickles/dummy.mli b/src/lib/pickles/dummy.mli index 00a3adbfe49..710446b1026 100644 --- a/src/lib/pickles/dummy.mli +++ b/src/lib/pickles/dummy.mli @@ -12,6 +12,7 @@ module Ipa : sig ( Backend.Tock.Field.t , Pickles_types.Nat.z Backend.Tock.Rounds.plus_n ) Pickles_types.Vector.t + lazy_t val sg : (Pasta_bindings.Fp.t * Pasta_bindings.Fp.t) lazy_t end @@ -28,6 +29,7 @@ module Ipa : sig ( Backend.Tick.Field.t , Pickles_types.Nat.z Backend.Tick.Rounds.plus_n ) Pickles_types.Vector.t + lazy_t val sg : (Pasta_bindings.Fq.t * Pasta_bindings.Fq.t) lazy_t end @@ -43,9 +45,11 @@ val evals : ( Backend.Tock.Field.t , Backend.Tock.Field.t array ) Pickles_types.Plonk_types.All_evals.t + lazy_t (** [evals_combined] is a constant *) val evals_combined : ( Backend.Tock.Field.t , Backend.Tock.Field.t ) Pickles_types.Plonk_types.All_evals.t + lazy_t diff --git a/src/lib/pickles/impls.ml b/src/lib/pickles/impls.ml index bc7fabb8c68..64355227fb4 100644 --- a/src/lib/pickles/impls.ml +++ b/src/lib/pickles/impls.ml @@ -57,21 +57,24 @@ module Step = struct Field.t * Boolean.var let forbidden_shifted_values = - let size_in_bits = Constant.size_in_bits in - let other_mod = Wrap_impl.Bigint.to_bignum_bigint Constant.size in - let values = forbidden_shifted_values ~size_in_bits ~modulus:other_mod in - let f x = - let open Option.Let_syntax in - let hi = test_bit x (Field.size_in_bits - 1) in - let lo = B.shift_right x 1 in - let%map lo = - let modulus = Impl.Field.size in - if B.compare modulus lo <= 0 then None - else Some Impl.Bigint.(to_field (of_bignum_bigint lo)) - in - (lo, hi) - in - values |> List.filter_map ~f + lazy + (let size_in_bits = Constant.size_in_bits in + let other_mod = Wrap_impl.Bigint.to_bignum_bigint Constant.size in + let values = + forbidden_shifted_values ~size_in_bits ~modulus:other_mod + in + let f x = + let open Option.Let_syntax in + let hi = test_bit x (Field.size_in_bits - 1) in + let lo = B.shift_right x 1 in + let%map lo = + let modulus = Impl.Field.size in + if B.compare modulus lo <= 0 then None + else Some Impl.Bigint.(to_field (of_bignum_bigint lo)) + in + (lo, hi) + in + values |> List.filter_map ~f ) let%test_unit "preserve circuit behavior for Step" = let expected_list = @@ -84,7 +87,7 @@ module Step = struct ] in let str_list = - List.map forbidden_shifted_values ~f:(fun (a, b) -> + List.map (Lazy.force forbidden_shifted_values) ~f:(fun (a, b) -> (Tick.Field.to_string a, b) ) in assert ([%equal: (string * bool) list] str_list expected_list) @@ -112,7 +115,7 @@ module Step = struct in let (Typ typ_unchecked) = typ_unchecked in let%bind () = typ_unchecked.check t in - Checked.List.map forbidden_shifted_values ~f:(equal t) + Checked.List.map (Lazy.force forbidden_shifted_values) ~f:(equal t) >>= Boolean.any >>| Boolean.not >>= Boolean.Assert.is_true let typ : _ Snarky_backendless.Typ.t = @@ -171,15 +174,18 @@ module Wrap = struct type t = Field.t let forbidden_shifted_values = - let other_mod = Step.Impl.Bigint.to_bignum_bigint Constant.size in - let size_in_bits = Constant.size_in_bits in - let values = forbidden_shifted_values ~size_in_bits ~modulus:other_mod in - let f x = - let modulus = Impl.Field.size in - if B.compare modulus x <= 0 then None - else Some Impl.Bigint.(to_field (of_bignum_bigint x)) - in - values |> List.filter_map ~f + lazy + (let other_mod = Step.Impl.Bigint.to_bignum_bigint Constant.size in + let size_in_bits = Constant.size_in_bits in + let values = + forbidden_shifted_values ~size_in_bits ~modulus:other_mod + in + let f x = + let modulus = Impl.Field.size in + if B.compare modulus x <= 0 then None + else Some Impl.Bigint.(to_field (of_bignum_bigint x)) + in + values |> List.filter_map ~f ) let%test_unit "preserve circuit behavior for Wrap" = let expected_list = @@ -188,7 +194,7 @@ module Wrap = struct ] in let str_list = - List.map forbidden_shifted_values ~f:Wrap_field.to_string + List.map (Lazy.force forbidden_shifted_values) ~f:Wrap_field.to_string in assert ([%equal: string list] str_list expected_list) @@ -204,7 +210,7 @@ module Wrap = struct let open Let_syntax in let equal x1 x2 = Field.Checked.equal x1 (Field.Var.constant x2) in let%bind () = t0.check t in - Checked.List.map forbidden_shifted_values ~f:(equal t) + Checked.List.map (Lazy.force forbidden_shifted_values) ~f:(equal t) >>= Boolean.any >>| Boolean.not >>= Boolean.Assert.is_true in (typ_unchecked, check) diff --git a/src/lib/pickles/proof.ml b/src/lib/pickles/proof.ml index d276d8325aa..5e59b7fddb2 100644 --- a/src/lib/pickles/proof.ml +++ b/src/lib/pickles/proof.ml @@ -184,18 +184,19 @@ let dummy (type w h r) (_w : w Nat.t) (h : h Nat.t) ; lookup = None } ; openings = - { proof = - { lr = - Array.init (Nat.to_int Tock.Rounds.n) ~f:(fun _ -> - (g0, g0) ) - ; z_1 = Ro.tock () - ; z_2 = Ro.tock () - ; delta = g0 - ; challenge_polynomial_commitment = g0 - } - ; evals = Dummy.evals.evals.evals - ; ft_eval1 = Dummy.evals.ft_eval1 - } + (let evals = Lazy.force Dummy.evals in + { proof = + { lr = + Array.init (Nat.to_int Tock.Rounds.n) ~f:(fun _ -> + (g0, g0) ) + ; z_1 = Ro.tock () + ; z_2 = Ro.tock () + ; delta = g0 + ; challenge_polynomial_commitment = g0 + } + ; evals = evals.evals.evals + ; ft_eval1 = evals.ft_eval1 + } ) } ; prev_evals = (let e = diff --git a/src/lib/pickles/step.ml b/src/lib/pickles/step.ml index ebcc850c867..2756149b915 100644 --- a/src/lib/pickles/step.ml +++ b/src/lib/pickles/step.ml @@ -416,7 +416,8 @@ struct (Vector.map t.statement.messages_for_next_step_proof .old_bulletproof_challenges ~f:Ipa.Step.compute_challenges ) - Local_max_proofs_verified.n Dummy.Ipa.Step.challenges_computed + Local_max_proofs_verified.n + (Lazy.force Dummy.Ipa.Step.challenges_computed) ; wrap_proof = { opening = { proof.openings.proof with challenge_polynomial_commitment } @@ -720,7 +721,7 @@ struct { challenge_polynomial_commitment = Lazy.force Dummy.Ipa.Step.sg ; old_bulletproof_challenges = Vector.init Max_proofs_verified.n ~f:(fun _ -> - Dummy.Ipa.Wrap.challenges_computed ) + Lazy.force Dummy.Ipa.Wrap.challenges_computed ) } in Wrap_hack.hash_messages_for_next_wrap_proof Max_proofs_verified.n t @@ -890,7 +891,7 @@ struct ; evals = { With_public_input.evals = es; public_input = x_hat } } ) ) - lte Max_proofs_verified.n Dummy.evals + lte Max_proofs_verified.n (Lazy.force Dummy.evals) } , Option.value_exn !return_value , Option.value_exn !auxiliary_value diff --git a/src/lib/pickles/step_main_inputs.ml b/src/lib/pickles/step_main_inputs.ml index 5ea29d5bf9e..4865beb0ce6 100644 --- a/src/lib/pickles/step_main_inputs.ml +++ b/src/lib/pickles/step_main_inputs.ml @@ -7,8 +7,7 @@ open Import let high_entropy_bits = 128 -let sponge_params_constant = - Sponge.Params.(map pasta_p_kimchi ~f:Impl.Field.Constant.of_string) +let sponge_params_constant = Kimchi_pasta_basic.poseidon_params_fp let tick_field_random_oracle ?(length = Tick.Field.size_in_bits - 1) s = Tick.Field.of_bits (Ro.bits_random_oracle ~length s) diff --git a/src/lib/pickles/tick_field_sponge.ml b/src/lib/pickles/tick_field_sponge.ml index a0a5216196f..752b71d1418 100644 --- a/src/lib/pickles/tick_field_sponge.ml +++ b/src/lib/pickles/tick_field_sponge.ml @@ -1,10 +1,3 @@ include Make_sponge.Make (Backend.Tick.Field) -let params = - (* HACK *) - Sponge.Params.( - let testbit n i = Bigint.(equal (shift_right n i land one) one) in - map pasta_p_kimchi ~f:(fun s -> - Backend.Tick.Field.of_bits - (List.init Backend.Tick.Field.size_in_bits - (testbit (Bigint.of_string s)) ) )) +let params = Kimchi_pasta_basic.poseidon_params_fp diff --git a/src/lib/pickles/tock_field_sponge.ml b/src/lib/pickles/tock_field_sponge.ml index 35d8a3444e8..22b02f96d06 100644 --- a/src/lib/pickles/tock_field_sponge.ml +++ b/src/lib/pickles/tock_field_sponge.ml @@ -1,10 +1,3 @@ include Make_sponge.Make (Backend.Tock.Field) -let params = - (* HACK *) - Sponge.Params.( - let testbit n i = Bigint.(equal (shift_right n i land one) one) in - map pasta_q_kimchi ~f:(fun s -> - Backend.Tock.Field.of_bits - (List.init Backend.Tock.Field.size_in_bits - (testbit (Bigint.of_string s)) ) )) +let params = Kimchi_pasta_basic.poseidon_params_fq diff --git a/src/lib/pickles/unfinalized.ml b/src/lib/pickles/unfinalized.ml index 88640bf362c..0ea274e76b4 100644 --- a/src/lib/pickles/unfinalized.ml +++ b/src/lib/pickles/unfinalized.ml @@ -60,7 +60,8 @@ module Constant = struct } in let evals = - Plonk_types.Evals.to_in_circuit Dummy.evals_combined.evals.evals + Plonk_types.Evals.to_in_circuit + (Lazy.force Dummy.evals_combined).evals.evals in let env = let module Env_bool = struct diff --git a/src/lib/pickles/wrap_hack.ml b/src/lib/pickles/wrap_hack.ml index f99ad11f876..92d68f7384a 100644 --- a/src/lib/pickles/wrap_hack.ml +++ b/src/lib/pickles/wrap_hack.ml @@ -29,7 +29,7 @@ let pad_vector (type a) ~dummy (v : (a, _) Vector.t) = (* Specialized padding function. *) let pad_challenges (chalss : (_ Vector.t, _) Vector.t) = - pad_vector ~dummy:Dummy.Ipa.Wrap.challenges_computed chalss + pad_vector ~dummy:(Lazy.force Dummy.Ipa.Wrap.challenges_computed) chalss (* Specialized padding function. *) let pad_accumulator (xs : (Tock.Proof.Challenge_polynomial.t, _) Vector.t) = @@ -37,7 +37,8 @@ let pad_accumulator (xs : (Tock.Proof.Challenge_polynomial.t, _) Vector.t) = ~dummy: { Tock.Proof.Challenge_polynomial.commitment = Lazy.force Dummy.Ipa.Wrap.sg - ; challenges = Vector.to_array Dummy.Ipa.Wrap.challenges_computed + ; challenges = + Vector.to_array (Lazy.force Dummy.Ipa.Wrap.challenges_computed) } |> Vector.to_list @@ -83,7 +84,7 @@ module Checked = struct pad_vector ~dummy: (Vector.map ~f:Impls.Wrap.Field.constant - Dummy.Ipa.Wrap.challenges_computed ) + (Lazy.force Dummy.Ipa.Wrap.challenges_computed) ) chalss let pad_commitments (commitments : _ Vector.t) = @@ -102,9 +103,10 @@ module Checked = struct let full_state s = (S.state s, s.sponge_state) in let sponge = S.create Tock_field_sponge.params in let s0 = full_state sponge in - Vector.iter ~f:(S.absorb sponge) Dummy.Ipa.Wrap.challenges_computed ; + let chals = Lazy.force Dummy.Ipa.Wrap.challenges_computed in + Vector.iter ~f:(S.absorb sponge) chals ; let s1 = full_state sponge in - Vector.iter ~f:(S.absorb sponge) Dummy.Ipa.Wrap.challenges_computed ; + Vector.iter ~f:(S.absorb sponge) chals ; let s2 = full_state sponge in [| s0; s1; s2 |] ) diff --git a/src/lib/pickles/wrap_main_inputs.ml b/src/lib/pickles/wrap_main_inputs.ml index 94620c70150..93481d1cadb 100644 --- a/src/lib/pickles/wrap_main_inputs.ml +++ b/src/lib/pickles/wrap_main_inputs.ml @@ -9,8 +9,7 @@ open Import let high_entropy_bits = 128 -let sponge_params_constant = - Sponge.Params.(map pasta_q_kimchi ~f:Impl.Field.Constant.of_string) +let sponge_params_constant = Kimchi_pasta_basic.poseidon_params_fq let field_random_oracle ?(length = Me.Field.size_in_bits - 1) s = Me.Field.of_bits (Ro.bits_random_oracle ~length s) diff --git a/src/lib/precomputed_values/gen_values/gen_values.ml b/src/lib/precomputed_values/gen_values/gen_values.ml index 5be91a9731f..0f75d0f78cb 100644 --- a/src/lib/precomputed_values/gen_values/gen_values.ml +++ b/src/lib/precomputed_values/gen_values/gen_values.ml @@ -84,7 +84,7 @@ module Dummy = struct let base_proof_expr = if generate_genesis_proof then - Some (Async.return [%expr Mina_base.Proof.blockchain_dummy]) + Some (Async.return [%expr Lazy.force Mina_base.Proof.blockchain_dummy]) else None let compiled_values = diff --git a/src/lib/prover/prover.ml b/src/lib/prover/prover.ml index 303fceef8bc..fad083a17df 100644 --- a/src/lib/prover/prover.ml +++ b/src/lib/prover/prover.ml @@ -80,7 +80,7 @@ module Worker_state = struct with sok_digest = Sok_message.Digest.default } - , Proof.transaction_dummy ) + , Lazy.force Proof.transaction_dummy ) let create { logger; proof_level; constraint_constants; _ } : t Deferred.t = Deferred.return @@ -175,9 +175,11 @@ module Worker_state = struct ~constraint_constants { transition = block ; prev_state = Blockchain_snark.Blockchain.state chain - ; prev_state_proof = Mina_base.Proof.blockchain_dummy + ; prev_state_proof = + Lazy.force Mina_base.Proof.blockchain_dummy ; txn_snark = t - ; txn_snark_proof = Mina_base.Proof.transaction_dummy + ; txn_snark_proof = + Lazy.force Mina_base.Proof.transaction_dummy } ~handler: (Consensus.Data.Prover_state.handler state_for_handler @@ -185,7 +187,7 @@ module Worker_state = struct next_state |> Or_error.map ~f:(fun () -> Blockchain_snark.Blockchain.create ~state:next_state - ~proof:Mina_base.Proof.blockchain_dummy ) + ~proof:(Lazy.force Mina_base.Proof.blockchain_dummy) ) in Or_error.iter_error res ~f:(fun e -> [%log error] @@ -208,7 +210,7 @@ module Worker_state = struct Deferred.return @@ Ok (Blockchain_snark.Blockchain.create - ~proof:Mina_base.Proof.blockchain_dummy + ~proof:(Lazy.force Mina_base.Proof.blockchain_dummy) ~state:next_state ) let verify _ _ = Deferred.return (Ok ()) diff --git a/src/lib/random_oracle/permutation/external/random_oracle_permutation.ml b/src/lib/random_oracle/permutation/external/random_oracle_permutation.ml index c72162f3707..deb96da5b70 100644 --- a/src/lib/random_oracle/permutation/external/random_oracle_permutation.ml +++ b/src/lib/random_oracle/permutation/external/random_oracle_permutation.ml @@ -17,7 +17,7 @@ let block_cipher _params (s : Field.t array) = let%test_unit "check rust implementation of block-cipher" = let params' : Field.t Sponge.Params.t = - Sponge.Params.(map pasta_p_kimchi ~f:Field.of_string) + Kimchi_pasta_basic.poseidon_params_fp in let open Pickles.Impls.Step in let module T = Internal_Basic in diff --git a/src/lib/random_oracle/random_oracle.ml b/src/lib/random_oracle/random_oracle.ml index f474727b83d..c976871a4cb 100644 --- a/src/lib/random_oracle/random_oracle.ml +++ b/src/lib/random_oracle/random_oracle.ml @@ -16,12 +16,15 @@ module State = struct include Array let map2 = map2_exn + + let to_array t = t + + let of_array t = t end module Input = Random_oracle_input -let params : Field.t Sponge.Params.t = - Sponge.Params.(map pasta_p_kimchi ~f:Field.of_string) +let params : Field.t Sponge.Params.t = Kimchi_pasta_basic.poseidon_params_fp module Operations = struct let add_assign ~state i x = Field.(state.(i) <- state.(i) + x) @@ -143,7 +146,7 @@ module Legacy = struct module State = State let params : Field.t Sponge.Params.t = - Sponge.Params.(map pasta_p_legacy ~f:Field.of_string) + Sponge.Params.(map pasta_p_legacy ~f:Kimchi_pasta_basic.Fp.of_string) module Rounds = struct let rounds_full = 63 diff --git a/src/lib/random_oracle/random_oracle.mli b/src/lib/random_oracle/random_oracle.mli index c865afe9465..3fe30566dd8 100644 --- a/src/lib/random_oracle/random_oracle.mli +++ b/src/lib/random_oracle/random_oracle.mli @@ -18,6 +18,10 @@ module State : sig val map : 'a t -> f:('a -> 'b) -> 'b t val map2 : 'a t -> 'b t -> f:('a -> 'b -> 'c) -> 'c t + + val to_array : 'a t -> 'a array + + val of_array : 'a array -> 'a t end include @@ -71,6 +75,10 @@ module Legacy : sig val map : 'a t -> f:('a -> 'b) -> 'b t val map2 : 'a t -> 'b t -> f:('a -> 'b -> 'c) -> 'c t + + val to_array : 'a t -> 'a array + + val of_array : 'a array -> 'a t end include diff --git a/src/lib/snark_worker/debug.ml b/src/lib/snark_worker/debug.ml index d5130a4323e..f1e329001bc 100644 --- a/src/lib/snark_worker/debug.ml +++ b/src/lib/snark_worker/debug.ml @@ -29,6 +29,6 @@ module Inputs = struct let sok_digest = Sok_message.digest message in Deferred.Or_error.return @@ ( Transaction_snark.create ~statement:{ stmt with sok_digest } - ~proof:Proof.transaction_dummy + ~proof:(Lazy.force Proof.transaction_dummy) , Time.Span.zero ) end diff --git a/src/lib/snark_worker/prod.ml b/src/lib/snark_worker/prod.ml index 03a0ed74fd6..ae6551d3280 100644 --- a/src/lib/snark_worker/prod.ml +++ b/src/lib/snark_worker/prod.ml @@ -284,6 +284,6 @@ module Inputs = struct in Deferred.Or_error.return @@ ( Transaction_snark.create ~statement:{ stmt with sok_digest } - ~proof:Proof.transaction_dummy + ~proof:(Lazy.force Proof.transaction_dummy) , Time.Span.zero ) end diff --git a/src/lib/snarky b/src/lib/snarky index 7edf1362887..1671e9d8bbd 160000 --- a/src/lib/snarky +++ b/src/lib/snarky @@ -1 +1 @@ -Subproject commit 7edf13628872081fd7cad154de257dad8b9ba621 +Subproject commit 1671e9d8bbdf2e0a31bd7c3c045fb73dd11dd742 diff --git a/src/lib/snarkyjs b/src/lib/snarkyjs index cc9f1495070..e4f330c7348 160000 --- a/src/lib/snarkyjs +++ b/src/lib/snarkyjs @@ -1 +1 @@ -Subproject commit cc9f1495070ad8da66938a8f6e023d671228e4c0 +Subproject commit e4f330c73484495d46d850f81de61dd7fcb9c6ae diff --git a/src/lib/staged_ledger/staged_ledger.ml b/src/lib/staged_ledger/staged_ledger.ml index cac2a16f263..7c2fba007d9 100644 --- a/src/lib/staged_ledger/staged_ledger.ml +++ b/src/lib/staged_ledger/staged_ledger.ml @@ -2415,7 +2415,7 @@ let%test_module "staged ledger tests" = let sok_digest = Sok_message.Digest.default in One_or_two.map stmts ~f:(fun statement -> Ledger_proof.create ~statement ~sok_digest - ~proof:Proof.transaction_dummy ) + ~proof:(Lazy.force Proof.transaction_dummy) ) let stmt_to_work_random_prover (stmts : Transaction_snark_work.Statement.t) : Transaction_snark_work.Checked.t option = diff --git a/src/lib/transaction/transaction_hash.ml b/src/lib/transaction/transaction_hash.ml index 7b30e1bcab7..2e4879eb93d 100644 --- a/src/lib/transaction/transaction_hash.ml +++ b/src/lib/transaction/transaction_hash.ml @@ -69,7 +69,7 @@ let ( hash_signed_command_v1 let dummy_auth = match acct_update.authorization with | Control.Proof _ -> - Control.Proof Proof.transaction_dummy + Control.Proof (Lazy.force Proof.transaction_dummy) | Control.Signature _ -> Control.Signature Signature.dummy | Control.None_given -> @@ -263,7 +263,7 @@ let%test_module "Transaction hashes" = * Run dune in this library's directory dune utop src/lib/transaction * Generate a zkapp transaction: - let txn = let txn = Mina_base.Zkapp_command.dummy in {txn with account_updates = Mina_base.Zkapp_command.Call_forest.map txn.account_updates ~f:(fun x -> {x with Mina_base.Account_update.authorization= Proof Mina_base.Proof.blockchain_dummy})};; + let txn = let txn = (Lazy.force Mina_base.Zkapp_command.dummy) in {txn with account_updates = Mina_base.Zkapp_command.Call_forest.map txn.account_updates ~f:(fun x -> {x with Mina_base.Account_update.authorization= Proof (Lazy.force Mina_base.Proof.blockchain_dummy)})};; * Print the transaction: Core_kernel.Out_channel.with_file "txn_id" ~f:(fun file -> Out_channel.output_string file (Core_kernel.Binable.to_string (module Mina_base.User_command.Stable.V2) (Zkapp_command txn) |> Base64.encode |> (function Ok x -> x | Error _ -> "")));; * Get the hash: diff --git a/src/lib/transaction_consistency_tests/transaction_consistency_tests.ml b/src/lib/transaction_consistency_tests/transaction_consistency_tests.ml index 254edf0711f..b95368a27a1 100644 --- a/src/lib/transaction_consistency_tests/transaction_consistency_tests.ml +++ b/src/lib/transaction_consistency_tests/transaction_consistency_tests.ml @@ -11,7 +11,7 @@ module Hash = struct let hash_account = Fn.compose Ledger_hash.of_digest Account.digest - let empty_account = Ledger_hash.of_digest Account.empty_digest + let empty_account = Ledger_hash.of_digest (Lazy.force Account.empty_digest) end let%test_module "transaction logic consistency" = diff --git a/src/lib/transaction_logic/mina_transaction_logic.ml b/src/lib/transaction_logic/mina_transaction_logic.ml index 63af1e58bad..3410ab5024a 100644 --- a/src/lib/transaction_logic/mina_transaction_logic.ml +++ b/src/lib/transaction_logic/mina_transaction_logic.ml @@ -2769,7 +2769,7 @@ module For_tests = struct } ; authorization = ( if use_full_commitment then Signature Signature.dummy - else Proof Mina_base.Proof.transaction_dummy ) + else Proof (Lazy.force Mina_base.Proof.transaction_dummy) ) } ; { body = { public_key = receiver 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 932b250c814..86ddd297e2a 100644 --- a/src/lib/transaction_snark/test/multisig_account/multisig_account.ml +++ b/src/lib/transaction_snark/test/multisig_account/multisig_account.ml @@ -373,7 +373,8 @@ let%test_module "multisig_account" = ; may_use_token = No ; authorization_kind = Proof (With_hash.hash vk) } - ; authorization = Proof Mina_base.Proof.transaction_dummy + ; authorization = + Proof (Lazy.force Mina_base.Proof.transaction_dummy) } in let memo = Signed_command_memo.empty in diff --git a/src/lib/transaction_snark/test/ring_sig.ml b/src/lib/transaction_snark/test/ring_sig.ml index f9e45755cb3..ae23fda9cce 100644 --- a/src/lib/transaction_snark/test/ring_sig.ml +++ b/src/lib/transaction_snark/test/ring_sig.ml @@ -234,7 +234,8 @@ let%test_unit "ring-signature zkapp tx with 3 zkapp_command" = ; use_full_commitment = false ; authorization_kind = Proof (With_hash.hash vk) } - ; authorization = Proof Mina_base.Proof.transaction_dummy + ; authorization = + Proof (Lazy.force Mina_base.Proof.transaction_dummy) } in let protocol_state = Zkapp_precondition.Protocol_state.accept in diff --git a/src/lib/transaction_snark/transaction_snark.ml b/src/lib/transaction_snark/transaction_snark.ml index 173ed018f99..c96463a090b 100644 --- a/src/lib/transaction_snark/transaction_snark.ml +++ b/src/lib/transaction_snark/transaction_snark.ml @@ -4925,7 +4925,7 @@ module Make_str (A : Wire_types.Concrete) = struct ; may_use_token = No ; authorization_kind = Proof (With_hash.hash vk) } - ; authorization = Proof Mina_base.Proof.transaction_dummy + ; authorization = Proof (Lazy.force Mina_base.Proof.transaction_dummy) } in let memo = Signed_command_memo.empty in diff --git a/src/lib/transition_frontier/frontier_base/breadcrumb.ml b/src/lib/transition_frontier/frontier_base/breadcrumb.ml index 2cbdf107207..c43b3b4c983 100644 --- a/src/lib/transition_frontier/frontier_base/breadcrumb.ml +++ b/src/lib/transition_frontier/frontier_base/breadcrumb.ml @@ -361,7 +361,7 @@ module For_tests = struct One_or_two.map stmts ~f:(fun statement -> Ledger_proof.create ~statement ~sok_digest:Sok_message.Digest.default - ~proof:Proof.transaction_dummy ) + ~proof:(Lazy.force Proof.transaction_dummy) ) ; prover } in @@ -459,7 +459,7 @@ module For_tests = struct let next_block = let header = Mina_block.Header.create ~protocol_state - ~protocol_state_proof:Proof.blockchain_dummy + ~protocol_state_proof:(Lazy.force Proof.blockchain_dummy) ~delta_block_chain_proof:(previous_state_hashes.state_hash, []) () in diff --git a/src/lib/zkapp_command_builder/zkapp_command_builder.ml b/src/lib/zkapp_command_builder/zkapp_command_builder.ml index f28bd44ed72..a6a0a178aee 100644 --- a/src/lib/zkapp_command_builder/zkapp_command_builder.ml +++ b/src/lib/zkapp_command_builder/zkapp_command_builder.ml @@ -70,7 +70,7 @@ let mk_zkapp_command ?memo ~fee ~fee_payer_pk ~fee_payer_nonce account_updates : | None_given -> Control.None_given | Proof _ -> - Control.Proof Mina_base.Proof.blockchain_dummy + Control.Proof (Lazy.force Mina_base.Proof.blockchain_dummy) | Signature -> Control.Signature Signature.dummy in