From 31c52c44b261e4a3e60b6cc8f86b449276156fd4 Mon Sep 17 00:00:00 2001 From: ejMina226 <118474890+ejMina226@users.noreply.github.com> Date: Tue, 9 Jan 2024 09:51:49 +0000 Subject: [PATCH 01/17] Add in varibale to runtime config --- src/lib/genesis_constants/genesis_constants.ml | 2 ++ .../genesis_ledger_helper/lib/genesis_ledger_helper_lib.ml | 5 +++++ src/lib/mina_compile_config/mina_compile_config.ml | 2 ++ src/lib/runtime_config/runtime_config.ml | 4 ++++ 4 files changed, 13 insertions(+) diff --git a/src/lib/genesis_constants/genesis_constants.ml b/src/lib/genesis_constants/genesis_constants.ml index 203a81356d5..1a65fc01bdd 100644 --- a/src/lib/genesis_constants/genesis_constants.ml +++ b/src/lib/genesis_constants/genesis_constants.ml @@ -337,6 +337,7 @@ module T = struct ; zkapp_transaction_cost_limit : float ; max_event_elements : int ; max_action_elements : int + ; zkapp_command_limit : int } [@@deriving to_yojson, sexp_of, bin_io_unversioned] @@ -394,6 +395,7 @@ let compiled : t = Mina_compile_config.zkapp_transaction_cost_limit ; max_event_elements = Mina_compile_config.max_event_elements ; max_action_elements = Mina_compile_config.max_action_elements + ; zkapp_command_limit = Mina_compile_config.zkapp_command_limit } let for_unit_tests = compiled 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 fd8c59e669e..b488ea00fb8 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 @@ -570,6 +570,9 @@ let make_genesis_constants ~logger ~(default : Genesis_constants.t) Option.value_map ~default:default.num_accounts (config.ledger >>= fun cfg -> cfg.num_accounts) ~f:(fun num_accounts -> Some num_accounts) + ; zkapp_command_limit = + Option.value ~default:default.zkapp_command_limit + (config.daemon >>= fun cfg -> cfg.zkapp_command_limit) } let runtime_config_of_genesis_constants (genesis_constants : Genesis_constants.t) @@ -610,6 +613,8 @@ let runtime_config_of_precomputed_values (precomputed_values : Genesis_proof.t) Some precomputed_values.genesis_constants.max_event_elements ; max_action_elements = Some precomputed_values.genesis_constants.max_action_elements + ; zkapp_command_limit = + Some precomputed_values.genesis_constants.zkapp_command_limit } ; genesis = Some diff --git a/src/lib/mina_compile_config/mina_compile_config.ml b/src/lib/mina_compile_config/mina_compile_config.ml index 9650cb8e848..e0370102d36 100644 --- a/src/lib/mina_compile_config/mina_compile_config.ml +++ b/src/lib/mina_compile_config/mina_compile_config.ml @@ -66,3 +66,5 @@ let zkapp_transaction_cost_limit = 69.45 let max_event_elements = 100 let max_action_elements = 100 + +let zkapp_command_limit = 128 diff --git a/src/lib/runtime_config/runtime_config.ml b/src/lib/runtime_config/runtime_config.ml index 72d18880719..b50f9580858 100644 --- a/src/lib/runtime_config/runtime_config.ml +++ b/src/lib/runtime_config/runtime_config.ml @@ -414,6 +414,7 @@ module Json_layout = struct ; zkapp_transaction_cost_limit : float option [@default None] ; max_event_elements : int option [@default None] ; max_action_elements : int option [@default None] + ; zkapp_command_limit : int option [@default None] } [@@deriving yojson, fields, dhall_type] @@ -887,6 +888,7 @@ module Daemon = struct ; zkapp_transaction_cost_limit : float option [@default None] ; max_event_elements : int option [@default None] ; max_action_elements : int option [@default None] + ; zkapp_command_limit : int option [@default None] } [@@deriving bin_io_unversioned] @@ -920,6 +922,8 @@ module Daemon = struct opt_fallthrough ~default:t1.max_event_elements t2.max_event_elements ; max_action_elements = opt_fallthrough ~default:t1.max_action_elements t2.max_action_elements + ; zkapp_command_limit = + opt_fallthrough ~default:t1.zkapp_command_limit t2.zkapp_command_limit } end From 23fcc70a77f6eb73126bd1392e0f90cc8adb7598 Mon Sep 17 00:00:00 2001 From: ejMina226 <118474890+ejMina226@users.noreply.github.com> Date: Tue, 9 Jan 2024 19:14:40 +0000 Subject: [PATCH 02/17] Add in code to Staged ledger and move limit to constraint constant --- .../genesis_constants/genesis_constants.ml | 7 ++++-- .../lib/genesis_ledger_helper_lib.ml | 7 ++---- .../mina_compile_config.ml | 2 -- src/lib/pickles/compile.ml | 2 ++ src/lib/pickles/pickles.ml | 17 +++++++++++++ src/lib/runtime_config/runtime_config.ml | 16 ++++++++---- .../snark_keys_header/snark_keys_header.ml | 2 ++ src/lib/staged_ledger/staged_ledger.ml | 25 +++++++++++++++++++ 8 files changed, 64 insertions(+), 14 deletions(-) diff --git a/src/lib/genesis_constants/genesis_constants.ml b/src/lib/genesis_constants/genesis_constants.ml index 1a65fc01bdd..4346a3986b1 100644 --- a/src/lib/genesis_constants/genesis_constants.ml +++ b/src/lib/genesis_constants/genesis_constants.ml @@ -53,6 +53,7 @@ module Constraint_constants = struct ; supercharged_coinbase_factor : int ; account_creation_fee : Currency.Fee.Stable.Latest.t ; fork : Fork_constants.t option + ; zkapps_per_block : int } [@@deriving bin_io_unversioned, sexp, equal, compare, yojson] @@ -80,6 +81,7 @@ module Constraint_constants = struct } | None -> None ) + ; zkapps_per_block = t.zkapps_per_block } (* Generate the compile-time constraint constants, using a signature to hide @@ -180,6 +182,8 @@ module Constraint_constants = struct [%%endif] + let zkapps_per_block = 1 + let compiled = { sub_windows_per_window ; ledger_depth @@ -193,6 +197,7 @@ module Constraint_constants = struct ; account_creation_fee = Currency.Fee.of_mina_string_exn account_creation_fee_string ; fork + ; zkapps_per_block } end : sig @@ -337,7 +342,6 @@ module T = struct ; zkapp_transaction_cost_limit : float ; max_event_elements : int ; max_action_elements : int - ; zkapp_command_limit : int } [@@deriving to_yojson, sexp_of, bin_io_unversioned] @@ -395,7 +399,6 @@ let compiled : t = Mina_compile_config.zkapp_transaction_cost_limit ; max_event_elements = Mina_compile_config.max_event_elements ; max_action_elements = Mina_compile_config.max_action_elements - ; zkapp_command_limit = Mina_compile_config.zkapp_command_limit } let for_unit_tests = compiled 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 b488ea00fb8..c0d845c7c94 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 @@ -467,6 +467,7 @@ let make_constraint_constants Mina_numbers.Global_slot_since_genesis.of_int previous_global_slot } ) + ; zkapps_per_block = default.zkapps_per_block } let runtime_config_of_constraint_constants @@ -502,6 +503,7 @@ let runtime_config_of_constraint_constants ; previous_global_slot = Mina_numbers.Global_slot_since_genesis.to_int previous_global_slot } ) + ; zkapps_per_block = Some constraint_constants.zkapps_per_block } let make_genesis_constants ~logger ~(default : Genesis_constants.t) @@ -570,9 +572,6 @@ let make_genesis_constants ~logger ~(default : Genesis_constants.t) Option.value_map ~default:default.num_accounts (config.ledger >>= fun cfg -> cfg.num_accounts) ~f:(fun num_accounts -> Some num_accounts) - ; zkapp_command_limit = - Option.value ~default:default.zkapp_command_limit - (config.daemon >>= fun cfg -> cfg.zkapp_command_limit) } let runtime_config_of_genesis_constants (genesis_constants : Genesis_constants.t) @@ -613,8 +612,6 @@ let runtime_config_of_precomputed_values (precomputed_values : Genesis_proof.t) Some precomputed_values.genesis_constants.max_event_elements ; max_action_elements = Some precomputed_values.genesis_constants.max_action_elements - ; zkapp_command_limit = - Some precomputed_values.genesis_constants.zkapp_command_limit } ; genesis = Some diff --git a/src/lib/mina_compile_config/mina_compile_config.ml b/src/lib/mina_compile_config/mina_compile_config.ml index e0370102d36..9650cb8e848 100644 --- a/src/lib/mina_compile_config/mina_compile_config.ml +++ b/src/lib/mina_compile_config/mina_compile_config.ml @@ -66,5 +66,3 @@ let zkapp_transaction_cost_limit = 69.45 let max_event_elements = 100 let max_action_elements = 100 - -let zkapp_command_limit = 128 diff --git a/src/lib/pickles/compile.ml b/src/lib/pickles/compile.ml index 1a77cc1d01f..ac5831c1a58 100644 --- a/src/lib/pickles/compile.ml +++ b/src/lib/pickles/compile.ml @@ -1298,6 +1298,7 @@ struct ; supercharged_coinbase_factor = 0 ; account_creation_fee = Unsigned.UInt64.of_int 0 ; fork = None + ; zkapps_per_block = 128 } let rule self : _ Inductive_rule.t = @@ -1348,6 +1349,7 @@ struct ; supercharged_coinbase_factor = 0 ; account_creation_fee = Unsigned.UInt64.of_int 0 ; fork = None + ; zkapps_per_block = 128 } ~choices:(fun ~self -> [ rule self ]) diff --git a/src/lib/pickles/pickles.ml b/src/lib/pickles/pickles.ml index 1b7cfbc4cc2..68d32658e4c 100644 --- a/src/lib/pickles/pickles.ml +++ b/src/lib/pickles/pickles.ml @@ -168,6 +168,7 @@ module Make_str (_ : Wire_types.Concrete) = struct ; supercharged_coinbase_factor = 0 ; account_creation_fee = Unsigned.UInt64.of_int 0 ; fork = None + ; zkapps_per_block = 128 } ; commits = { mina = ""; marlin = "" } ; length = 0 @@ -431,6 +432,7 @@ module Make_str (_ : Wire_types.Concrete) = struct ; supercharged_coinbase_factor = 0 ; account_creation_fee = Unsigned.UInt64.of_int 0 ; fork = None + ; zkapps_per_block = 128 } ~choices:(fun ~self:_ -> [ { identifier = "main" @@ -494,6 +496,7 @@ module Make_str (_ : Wire_types.Concrete) = struct ; supercharged_coinbase_factor = 0 ; account_creation_fee = Unsigned.UInt64.of_int 0 ; fork = None + ; zkapps_per_block = 128 } ~choices:(fun ~self:_ -> [ { identifier = "main" @@ -561,6 +564,7 @@ module Make_str (_ : Wire_types.Concrete) = struct ; supercharged_coinbase_factor = 0 ; account_creation_fee = Unsigned.UInt64.of_int 0 ; fork = None + ; zkapps_per_block = 128 } ~choices:(fun ~self -> [ { identifier = "main" @@ -669,6 +673,7 @@ module Make_str (_ : Wire_types.Concrete) = struct ; supercharged_coinbase_factor = 0 ; account_creation_fee = Unsigned.UInt64.of_int 0 ; fork = None + ; zkapps_per_block = 128 } ~choices:(fun ~self -> [ { identifier = "main" @@ -803,6 +808,7 @@ module Make_str (_ : Wire_types.Concrete) = struct ; supercharged_coinbase_factor = 0 ; account_creation_fee = Unsigned.UInt64.of_int 0 ; fork = None + ; zkapps_per_block = 128 } ~choices:(fun ~self -> [ { identifier = "main" @@ -927,6 +933,7 @@ module Make_str (_ : Wire_types.Concrete) = struct ; supercharged_coinbase_factor = 0 ; account_creation_fee = Unsigned.UInt64.of_int 0 ; fork = None + ; zkapps_per_block = 128 } ~choices:(fun ~self:_ -> [ { identifier = "main" @@ -992,6 +999,7 @@ module Make_str (_ : Wire_types.Concrete) = struct ; supercharged_coinbase_factor = 0 ; account_creation_fee = Unsigned.UInt64.of_int 0 ; fork = None + ; zkapps_per_block = 128 } ~choices:(fun ~self:_ -> [ { identifier = "main" @@ -1073,6 +1081,7 @@ module Make_str (_ : Wire_types.Concrete) = struct ; supercharged_coinbase_factor = 0 ; account_creation_fee = Unsigned.UInt64.of_int 0 ; fork = None + ; zkapps_per_block = 128 } let tag = @@ -2104,6 +2113,7 @@ module Make_str (_ : Wire_types.Concrete) = struct ; supercharged_coinbase_factor = 0 ; account_creation_fee = Unsigned.UInt64.of_int 0 ; fork = None + ; zkapps_per_block = 128 } ~choices:(fun ~self:_ -> [ { identifier = "main" @@ -2157,6 +2167,7 @@ module Make_str (_ : Wire_types.Concrete) = struct ; supercharged_coinbase_factor = 0 ; account_creation_fee = Unsigned.UInt64.of_int 0 ; fork = None + ; zkapps_per_block = 128 } ~choices:(fun ~self:_ -> [ { identifier = "main" @@ -2211,6 +2222,7 @@ module Make_str (_ : Wire_types.Concrete) = struct ; supercharged_coinbase_factor = 0 ; account_creation_fee = Unsigned.UInt64.of_int 0 ; fork = None + ; zkapps_per_block = 128 } ~choices:(fun ~self:_ -> [ { identifier = "main" @@ -2288,6 +2300,7 @@ module Make_str (_ : Wire_types.Concrete) = struct ; supercharged_coinbase_factor = 0 ; account_creation_fee = Unsigned.UInt64.of_int 0 ; fork = None + ; zkapps_per_block = 128 } ~choices:(fun ~self:_ -> [ { identifier = "main" @@ -2452,6 +2465,7 @@ module Make_str (_ : Wire_types.Concrete) = struct ; supercharged_coinbase_factor = 0 ; account_creation_fee = Unsigned.UInt64.of_int 0 ; fork = None + ; zkapps_per_block = 128 } ~choices:(fun ~self:_ -> [ { identifier = "main" @@ -2505,6 +2519,7 @@ module Make_str (_ : Wire_types.Concrete) = struct ; supercharged_coinbase_factor = 0 ; account_creation_fee = Unsigned.UInt64.of_int 0 ; fork = None + ; zkapps_per_block = 128 } ~choices:(fun ~self:_ -> [ { identifier = "main" @@ -2559,6 +2574,7 @@ module Make_str (_ : Wire_types.Concrete) = struct ; supercharged_coinbase_factor = 0 ; account_creation_fee = Unsigned.UInt64.of_int 0 ; fork = None + ; zkapps_per_block = 128 } ~choices:(fun ~self:_ -> [ { identifier = "main" @@ -2640,6 +2656,7 @@ module Make_str (_ : Wire_types.Concrete) = struct ; supercharged_coinbase_factor = 0 ; account_creation_fee = Unsigned.UInt64.of_int 0 ; fork = None + ; zkapps_per_block = 128 } ~choices:(fun ~self:_ -> [ { identifier = "main" diff --git a/src/lib/runtime_config/runtime_config.ml b/src/lib/runtime_config/runtime_config.ml index b50f9580858..898c96ad0e8 100644 --- a/src/lib/runtime_config/runtime_config.ml +++ b/src/lib/runtime_config/runtime_config.ml @@ -381,6 +381,7 @@ module Json_layout = struct ; supercharged_coinbase_factor : int option [@default None] ; account_creation_fee : Currency.Fee.t option [@default None] ; fork : Fork_config.t option [@default None] + ; zkapps_per_block : int option [@default None] } [@@deriving yojson, fields, dhall_type] @@ -414,7 +415,6 @@ module Json_layout = struct ; zkapp_transaction_cost_limit : float option [@default None] ; max_event_elements : int option [@default None] ; max_action_elements : int option [@default None] - ; zkapp_command_limit : int option [@default None] } [@@deriving yojson, fields, dhall_type] @@ -745,12 +745,14 @@ module Proof_keys = struct ; supercharged_coinbase_factor : int option ; account_creation_fee : Currency.Fee.Stable.Latest.t option ; fork : Fork_config.t option + ; zkapps_per_block : int option } [@@deriving bin_io_unversioned] let make ?level ?sub_windows_per_window ?ledger_depth ?work_delay ?block_window_duration_ms ?transaction_capacity ?coinbase_amount - ?supercharged_coinbase_factor ?account_creation_fee ?fork () = + ?supercharged_coinbase_factor ?account_creation_fee ?zkapps_per_block + ?fork () = { level ; sub_windows_per_window ; ledger_depth @@ -761,6 +763,7 @@ module Proof_keys = struct ; supercharged_coinbase_factor ; account_creation_fee ; fork + ; zkapps_per_block } let to_json_layout @@ -774,6 +777,7 @@ module Proof_keys = struct ; supercharged_coinbase_factor ; account_creation_fee ; fork + ; zkapps_per_block } = { Json_layout.Proof_keys.level = Option.map ~f:Level.to_json_layout level ; sub_windows_per_window @@ -786,6 +790,7 @@ module Proof_keys = struct ; supercharged_coinbase_factor ; account_creation_fee ; fork + ; zkapps_per_block } let of_json_layout @@ -799,6 +804,7 @@ module Proof_keys = struct ; supercharged_coinbase_factor ; account_creation_fee ; fork + ; zkapps_per_block } = let open Result.Let_syntax in let%map level = result_opt ~f:Level.of_json_layout level @@ -815,6 +821,7 @@ module Proof_keys = struct ; supercharged_coinbase_factor ; account_creation_fee ; fork + ; zkapps_per_block } let to_yojson x = Json_layout.Proof_keys.to_yojson (to_json_layout x) @@ -842,6 +849,8 @@ module Proof_keys = struct ; account_creation_fee = opt_fallthrough ~default:t1.account_creation_fee t2.account_creation_fee ; fork = opt_fallthrough ~default:t1.fork t2.fork + ; zkapps_per_block = + opt_fallthrough ~default:t1.zkapps_per_block t2.zkapps_per_block } end @@ -888,7 +897,6 @@ module Daemon = struct ; zkapp_transaction_cost_limit : float option [@default None] ; max_event_elements : int option [@default None] ; max_action_elements : int option [@default None] - ; zkapp_command_limit : int option [@default None] } [@@deriving bin_io_unversioned] @@ -922,8 +930,6 @@ module Daemon = struct opt_fallthrough ~default:t1.max_event_elements t2.max_event_elements ; max_action_elements = opt_fallthrough ~default:t1.max_action_elements t2.max_action_elements - ; zkapp_command_limit = - opt_fallthrough ~default:t1.zkapp_command_limit t2.zkapp_command_limit } end diff --git a/src/lib/snark_keys_header/snark_keys_header.ml b/src/lib/snark_keys_header/snark_keys_header.ml index e34b387c773..91ba49c6484 100644 --- a/src/lib/snark_keys_header/snark_keys_header.ml +++ b/src/lib/snark_keys_header/snark_keys_header.ml @@ -119,6 +119,7 @@ module Constraint_constants = struct (Fork_config.t option [@to_yojson Fork_config.opt_to_yojson] [@of_yojson Fork_config.opt_of_yojson] ) + ; zkapps_per_block : int } [@@deriving yojson, sexp, ord, equal] end @@ -232,6 +233,7 @@ let%test_module "Check parsing of header" = ; supercharged_coinbase_factor = 1 ; account_creation_fee = Unsigned.UInt64.of_int 1 ; fork = None + ; zkapps_per_block = 128 } ; commits = { mina = "7e1fb2cd9138af1d0f24e78477efd40a2a0fcd07" diff --git a/src/lib/staged_ledger/staged_ledger.ml b/src/lib/staged_ledger/staged_ledger.ml index 7753294341f..ce91cce50c3 100644 --- a/src/lib/staged_ledger/staged_ledger.ml +++ b/src/lib/staged_ledger/staged_ledger.ml @@ -59,6 +59,7 @@ module T = struct | Mismatched_statuses of Transaction.t With_status.t * Transaction_status.t | Invalid_public_key of Public_key.Compressed.t + | ZkApps_exceed_limit of int * int | Unexpected of Error.t [@@deriving sexp] @@ -102,6 +103,11 @@ module T = struct !"A transaction contained an invalid public key %{sexp: \ Public_key.Compressed.t}" pk + | ZkApps_exceed_limit (count, limit) -> + Format.asprintf + !"There are %{sexp: int} ZkApps in the block when there is a \ + configured limit of %{sexp: int}" + count limit | Unexpected e -> Error.to_string_hum e @@ -965,6 +971,25 @@ module T = struct let new_mask = Ledger.Mask.create ~depth:(Ledger.depth t.ledger) () in let new_ledger = Ledger.register_mask t.ledger new_mask in let transactions, works, commands_count, coinbases = pre_diff_info in + [%log internal] "Check #zkApp does not exceed hardcap" ; + let%bind () = + O1trace.thread "Check #zkApp does not exceed hardcap" (fun () -> + let zkAppCount = + transactions + |> List.filter ~f:(fun (txn, _) -> + match txn with + | Transaction.Command (User_command.Zkapp_command _) -> + true + | _ -> + false ) + |> List.length + in + if zkAppCount > constraint_constants.zkapps_per_block then + Deferred.Result.fail + (Staged_ledger_error.ZkApps_exceed_limit + (zkAppCount, constraint_constants.zkapps_per_block) ) + else Deferred.Result.return () ) + in [%log internal] "Update_coinbase_stack" ~metadata: [ ("transactions", `Int (List.length transactions)) From 6f5c004ce6288dedef4d616d01ec2e3f87223d45 Mon Sep 17 00:00:00 2001 From: ejMina226 <118474890+ejMina226@users.noreply.github.com> Date: Wed, 10 Jan 2024 17:51:27 +0000 Subject: [PATCH 03/17] Add hardcap check into apply_diff --- src/lib/staged_ledger/staged_ledger.ml | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/lib/staged_ledger/staged_ledger.ml b/src/lib/staged_ledger/staged_ledger.ml index ce91cce50c3..cb546e20243 100644 --- a/src/lib/staged_ledger/staged_ledger.ml +++ b/src/lib/staged_ledger/staged_ledger.ml @@ -974,20 +974,24 @@ module T = struct [%log internal] "Check #zkApp does not exceed hardcap" ; let%bind () = O1trace.thread "Check #zkApp does not exceed hardcap" (fun () -> + let zkAppCountGetter : Transaction.t With_status.t -> bool = function + | { With_status.data = + Transaction.Command (Mina_base.User_command.Zkapp_command _) + ; status = _ + } -> + true + | _ -> + false + in let zkAppCount = transactions - |> List.filter ~f:(fun (txn, _) -> - match txn with - | Transaction.Command (User_command.Zkapp_command _) -> - true - | _ -> - false ) + |> List.filter ~f:(fun txn -> zkAppCountGetter txn) |> List.length in - if zkAppCount > constraint_constants.zkapps_per_block then + if zkAppCount > t.constraint_constants.zkapps_per_block then Deferred.Result.fail (Staged_ledger_error.ZkApps_exceed_limit - (zkAppCount, constraint_constants.zkapps_per_block) ) + (zkAppCount, t.constraint_constants.zkapps_per_block) ) else Deferred.Result.return () ) in [%log internal] "Update_coinbase_stack" From e3977b89c0531c995f10395a4c620dbd14cf2a60 Mon Sep 17 00:00:00 2001 From: ejMina226 <118474890+ejMina226@users.noreply.github.com> Date: Wed, 10 Jan 2024 20:51:42 +0000 Subject: [PATCH 04/17] Move variable from Constraint_constants to Protocol constants --- src/config/devnet.mlh | 1 + src/lib/consensus/constants.ml | 6 ++++++ src/lib/genesis_constants/genesis_constants.ml | 14 +++++++++----- .../lib/genesis_ledger_helper_lib.ml | 6 ++++-- src/lib/integration_test_lib/test_config.ml | 2 ++ src/lib/mina_base/protocol_constants_checked.ml | 9 ++++++++- src/lib/mina_base/test/valid_size.ml | 1 + src/lib/mina_wire_types/genesis_constants.ml | 1 + src/lib/pickles/compile.ml | 2 -- src/lib/pickles/pickles.ml | 17 ----------------- src/lib/runtime_config/runtime_config.ml | 16 +++++----------- src/lib/snark_keys_header/snark_keys_header.ml | 2 -- 12 files changed, 37 insertions(+), 40 deletions(-) diff --git a/src/config/devnet.mlh b/src/config/devnet.mlh index 4ead97ed46b..dad7f0afcef 100644 --- a/src/config/devnet.mlh +++ b/src/config/devnet.mlh @@ -17,6 +17,7 @@ [%%define slots_per_epoch 7140] [%%define slots_per_sub_window 7] [%%define sub_windows_per_window 11] +[%%define zkapps_per_block 128] [%%define record_async_backtraces false] [%%define time_offsets true] diff --git a/src/lib/consensus/constants.ml b/src/lib/consensus/constants.ml index c2a6f029825..ed19aaeff77 100644 --- a/src/lib/consensus/constants.ml +++ b/src/lib/consensus/constants.ml @@ -23,6 +23,7 @@ module Poly = struct ; epoch_duration : 'timespan ; delta_duration : 'timespan ; genesis_state_timestamp : 'time + ; zkapps_per_block : 'length } [@@deriving equal, compare, hash, sexp, to_yojson, hlist] end @@ -258,6 +259,7 @@ let create' (type a b c) ; checkpoint_window_size_in_slots = to_length zero ; delta_duration = to_timespan delta_duration ; genesis_state_timestamp = protocol_constants.genesis_state_timestamp + ; zkapps_per_block = protocol_constants.zkapps_per_block } in res @@ -301,6 +303,7 @@ let to_protocol_constants ; genesis_state_timestamp ; slots_per_sub_window ; slots_per_epoch + ; zkapps_per_block ; _ } : _ Poly.t ) = @@ -309,6 +312,7 @@ let to_protocol_constants ; genesis_state_timestamp ; slots_per_sub_window ; slots_per_epoch + ; zkapps_per_block } let typ = @@ -327,6 +331,7 @@ let typ = ; Block_time.Span.Checked.typ ; Block_time.Span.Checked.typ ; Block_time.Checked.typ + ; Length.Checked.typ ] ~var_to_hlist:Poly.to_hlist ~var_of_hlist:Poly.of_hlist ~value_to_hlist:Poly.to_hlist ~value_of_hlist:Poly.of_hlist @@ -383,6 +388,7 @@ module Checked = struct ; t.grace_period_end ; t.checkpoint_window_slots_per_year ; t.checkpoint_window_size_in_slots + ; t.zkapps_per_block |] ; Array.map ~f:Block_time.Span.Checked.to_input [| t.block_window_duration_ms diff --git a/src/lib/genesis_constants/genesis_constants.ml b/src/lib/genesis_constants/genesis_constants.ml index 4346a3986b1..c4f85c67adb 100644 --- a/src/lib/genesis_constants/genesis_constants.ml +++ b/src/lib/genesis_constants/genesis_constants.ml @@ -53,7 +53,6 @@ module Constraint_constants = struct ; supercharged_coinbase_factor : int ; account_creation_fee : Currency.Fee.Stable.Latest.t ; fork : Fork_constants.t option - ; zkapps_per_block : int } [@@deriving bin_io_unversioned, sexp, equal, compare, yojson] @@ -81,7 +80,6 @@ module Constraint_constants = struct } | None -> None ) - ; zkapps_per_block = t.zkapps_per_block } (* Generate the compile-time constraint constants, using a signature to hide @@ -182,8 +180,6 @@ module Constraint_constants = struct [%%endif] - let zkapps_per_block = 1 - let compiled = { sub_windows_per_window ; ledger_depth @@ -197,7 +193,6 @@ module Constraint_constants = struct ; account_creation_fee = Currency.Fee.of_mina_string_exn account_creation_fee_string ; fork - ; zkapps_per_block } end : sig @@ -254,6 +249,7 @@ module Protocol = struct ; slots_per_sub_window : 'length ; delta : 'delta ; genesis_state_timestamp : 'genesis_state_timestamp + ; zkapps_per_block : 'length } [@@deriving equal, ord, hash, sexp, yojson, hlist, fields] end @@ -281,6 +277,7 @@ module Protocol = struct (Time.Span.of_ms (Int64.to_float t.genesis_state_timestamp) ) ) ~zone:Time.Zone.utc ) ) + ; ("zkapps_per_block", `Int t.zkapps_per_block) ] let of_yojson = function @@ -290,6 +287,7 @@ module Protocol = struct ; ("slots_per_sub_window", `Int slots_per_sub_window) ; ("delta", `Int delta) ; ("genesis_state_timestamp", `String time_str) + ; ("zkapps_per_block", `Int zkapps_per_block) ] -> ( match validate_time time_str with | Ok genesis_state_timestamp -> @@ -299,6 +297,7 @@ module Protocol = struct ; slots_per_sub_window ; delta ; genesis_state_timestamp + ; zkapps_per_block } | Error e -> Error (sprintf !"Genesis_constants.Protocol.of_yojson: %s" e) ) @@ -321,6 +320,7 @@ module Protocol = struct (Time.of_span_since_epoch (Time.Span.of_ms (Int64.to_float t.genesis_state_timestamp)) ) ~zone:Time.Zone.utc + ; zkapps_per_block = t.zkapps_per_block } in T.sexp_of_t t' @@ -354,6 +354,7 @@ module T = struct ; t.protocol.slots_per_sub_window ; t.protocol.delta ; t.txpool_max_size + ; t.protocol.zkapps_per_block ] ~f:Int.to_string |> String.concat ~sep:"" ) @@ -379,6 +380,8 @@ include T [%%inject "pool_max_size", pool_max_size] +[%%inject "zkapps_per_block", zkapps_per_block] + let compiled : t = { protocol = { k @@ -387,6 +390,7 @@ let compiled : t = ; delta ; genesis_state_timestamp = genesis_timestamp_of_string genesis_state_timestamp_string |> of_time + ; zkapps_per_block } ; txpool_max_size = pool_max_size ; num_accounts = None 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 c0d845c7c94..7e2057881a3 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 @@ -467,7 +467,6 @@ let make_constraint_constants Mina_numbers.Global_slot_since_genesis.of_int previous_global_slot } ) - ; zkapps_per_block = default.zkapps_per_block } let runtime_config_of_constraint_constants @@ -503,7 +502,6 @@ let runtime_config_of_constraint_constants ; previous_global_slot = Mina_numbers.Global_slot_since_genesis.to_int previous_global_slot } ) - ; zkapps_per_block = Some constraint_constants.zkapps_per_block } let make_genesis_constants ~logger ~(default : Genesis_constants.t) @@ -546,6 +544,9 @@ let make_genesis_constants ~logger ~(default : Genesis_constants.t) ; genesis_state_timestamp = Option.value ~default:default.protocol.genesis_state_timestamp genesis_state_timestamp + ; zkapps_per_block = + Option.value ~default:default.protocol.zkapps_per_block + (config.genesis >>= fun cfg -> cfg.zkapps_per_block) } ; txpool_max_size = Option.value ~default:default.txpool_max_size @@ -584,6 +585,7 @@ let runtime_config_of_genesis_constants (genesis_constants : Genesis_constants.t Some (Genesis_constants.genesis_timestamp_to_string genesis_constants.protocol.genesis_state_timestamp ) + ; zkapps_per_block = Some genesis_constants.protocol.zkapps_per_block } let runtime_config_of_precomputed_values (precomputed_values : Genesis_proof.t) diff --git a/src/lib/integration_test_lib/test_config.ml b/src/lib/integration_test_lib/test_config.ml index 104aca2dc7c..faa4e607dcd 100644 --- a/src/lib/integration_test_lib/test_config.ml +++ b/src/lib/integration_test_lib/test_config.ml @@ -61,6 +61,7 @@ type t = ; slots_per_epoch : int ; slots_per_sub_window : int ; txpool_max_size : int + ; zkapps_per_block : int } let proof_config_default : Runtime_config.Proof_keys.t = @@ -93,6 +94,7 @@ let default = ; slots_per_sub_window = 2 ; delta = 0 ; txpool_max_size = 3000 + ; zkapps_per_block = 128 } let transaction_capacity_log_2 (config : t) = diff --git a/src/lib/mina_base/protocol_constants_checked.ml b/src/lib/mina_base/protocol_constants_checked.ml index 12b758f6634..318d0bbb813 100644 --- a/src/lib/mina_base/protocol_constants_checked.ml +++ b/src/lib/mina_base/protocol_constants_checked.ml @@ -31,6 +31,7 @@ module Value = struct let open Quickcheck.Let_syntax in let%bind k = Int.gen_incl 1 5000 in let%bind delta = Int.gen_incl 0 5000 in + let%bind zkapps_per_block = Int.gen_incl 1 128 in let%bind slots_per_epoch = Int.gen_incl k (8 * k) >>| ( * ) 3 >>| T.of_int and slots_per_sub_window = Int.gen_incl 1 ((k + 9) / 9) in (*TODO: Bug -> Block_time.(to_time x |> of_time) != x for certain values. @@ -45,6 +46,7 @@ module Value = struct ; slots_per_epoch ; slots_per_sub_window = T.of_int slots_per_sub_window ; genesis_state_timestamp + ; zkapps_per_block = T.of_int zkapps_per_block } end @@ -56,6 +58,7 @@ let value_of_t (t : Genesis_constants.Protocol.t) : value = ; slots_per_epoch = T.of_int t.slots_per_epoch ; slots_per_sub_window = T.of_int t.slots_per_sub_window ; genesis_state_timestamp = Block_time.of_int64 t.genesis_state_timestamp + ; zkapps_per_block = T.of_int t.zkapps_per_block } let t_of_value (v : value) : Genesis_constants.Protocol.t = @@ -64,6 +67,7 @@ let t_of_value (v : value) : Genesis_constants.Protocol.t = ; slots_per_epoch = T.to_int v.slots_per_epoch ; slots_per_sub_window = T.to_int v.slots_per_sub_window ; genesis_state_timestamp = Block_time.to_int64 v.genesis_state_timestamp + ; zkapps_per_block = T.to_int v.zkapps_per_block } let to_input (t : value) = @@ -86,6 +90,7 @@ let typ = ; T.Checked.typ ; T.Checked.typ ; Block_time.Checked.typ + ; T.Checked.typ ] ~var_to_hlist:Poly.to_hlist ~var_of_hlist:Poly.of_hlist ~value_to_hlist:Poly.to_hlist ~value_of_hlist:Poly.of_hlist @@ -94,7 +99,8 @@ let var_to_input (var : var) = let k = T.Checked.to_input var.k and delta = T.Checked.to_input var.delta and slots_per_epoch = T.Checked.to_input var.slots_per_epoch - and slots_per_sub_window = T.Checked.to_input var.slots_per_sub_window in + and slots_per_sub_window = T.Checked.to_input var.slots_per_sub_window + and zkapps_per_block = T.Checked.to_input var.zkapps_per_block in let genesis_state_timestamp = Block_time.Checked.to_input var.genesis_state_timestamp in @@ -104,6 +110,7 @@ let var_to_input (var : var) = ; slots_per_epoch ; slots_per_sub_window ; genesis_state_timestamp + ; zkapps_per_block |] let%test_unit "value = var" = diff --git a/src/lib/mina_base/test/valid_size.ml b/src/lib/mina_base/test/valid_size.ml index c0451d6f511..450c8d2c490 100644 --- a/src/lib/mina_base/test/valid_size.ml +++ b/src/lib/mina_base/test/valid_size.ml @@ -35,6 +35,7 @@ let genesis_constant_error limit events actions : Genesis_constants.t = ; slots_per_sub_window = 5 ; delta = 5 ; genesis_state_timestamp = Genesis_constants.of_time (Time.now ()) + ; zkapps_per_block = 128 } ; txpool_max_size = 5 ; num_accounts = Some 1 diff --git a/src/lib/mina_wire_types/genesis_constants.ml b/src/lib/mina_wire_types/genesis_constants.ml index b56306151bd..1d18273accb 100644 --- a/src/lib/mina_wire_types/genesis_constants.ml +++ b/src/lib/mina_wire_types/genesis_constants.ml @@ -7,6 +7,7 @@ module Protocol = struct ; slots_per_sub_window : 'length ; delta : 'delta ; genesis_state_timestamp : 'genesis_state_timestamp + ; zkapps_per_block : 'length } end end diff --git a/src/lib/pickles/compile.ml b/src/lib/pickles/compile.ml index ac5831c1a58..1a77cc1d01f 100644 --- a/src/lib/pickles/compile.ml +++ b/src/lib/pickles/compile.ml @@ -1298,7 +1298,6 @@ struct ; supercharged_coinbase_factor = 0 ; account_creation_fee = Unsigned.UInt64.of_int 0 ; fork = None - ; zkapps_per_block = 128 } let rule self : _ Inductive_rule.t = @@ -1349,7 +1348,6 @@ struct ; supercharged_coinbase_factor = 0 ; account_creation_fee = Unsigned.UInt64.of_int 0 ; fork = None - ; zkapps_per_block = 128 } ~choices:(fun ~self -> [ rule self ]) diff --git a/src/lib/pickles/pickles.ml b/src/lib/pickles/pickles.ml index 68d32658e4c..1b7cfbc4cc2 100644 --- a/src/lib/pickles/pickles.ml +++ b/src/lib/pickles/pickles.ml @@ -168,7 +168,6 @@ module Make_str (_ : Wire_types.Concrete) = struct ; supercharged_coinbase_factor = 0 ; account_creation_fee = Unsigned.UInt64.of_int 0 ; fork = None - ; zkapps_per_block = 128 } ; commits = { mina = ""; marlin = "" } ; length = 0 @@ -432,7 +431,6 @@ module Make_str (_ : Wire_types.Concrete) = struct ; supercharged_coinbase_factor = 0 ; account_creation_fee = Unsigned.UInt64.of_int 0 ; fork = None - ; zkapps_per_block = 128 } ~choices:(fun ~self:_ -> [ { identifier = "main" @@ -496,7 +494,6 @@ module Make_str (_ : Wire_types.Concrete) = struct ; supercharged_coinbase_factor = 0 ; account_creation_fee = Unsigned.UInt64.of_int 0 ; fork = None - ; zkapps_per_block = 128 } ~choices:(fun ~self:_ -> [ { identifier = "main" @@ -564,7 +561,6 @@ module Make_str (_ : Wire_types.Concrete) = struct ; supercharged_coinbase_factor = 0 ; account_creation_fee = Unsigned.UInt64.of_int 0 ; fork = None - ; zkapps_per_block = 128 } ~choices:(fun ~self -> [ { identifier = "main" @@ -673,7 +669,6 @@ module Make_str (_ : Wire_types.Concrete) = struct ; supercharged_coinbase_factor = 0 ; account_creation_fee = Unsigned.UInt64.of_int 0 ; fork = None - ; zkapps_per_block = 128 } ~choices:(fun ~self -> [ { identifier = "main" @@ -808,7 +803,6 @@ module Make_str (_ : Wire_types.Concrete) = struct ; supercharged_coinbase_factor = 0 ; account_creation_fee = Unsigned.UInt64.of_int 0 ; fork = None - ; zkapps_per_block = 128 } ~choices:(fun ~self -> [ { identifier = "main" @@ -933,7 +927,6 @@ module Make_str (_ : Wire_types.Concrete) = struct ; supercharged_coinbase_factor = 0 ; account_creation_fee = Unsigned.UInt64.of_int 0 ; fork = None - ; zkapps_per_block = 128 } ~choices:(fun ~self:_ -> [ { identifier = "main" @@ -999,7 +992,6 @@ module Make_str (_ : Wire_types.Concrete) = struct ; supercharged_coinbase_factor = 0 ; account_creation_fee = Unsigned.UInt64.of_int 0 ; fork = None - ; zkapps_per_block = 128 } ~choices:(fun ~self:_ -> [ { identifier = "main" @@ -1081,7 +1073,6 @@ module Make_str (_ : Wire_types.Concrete) = struct ; supercharged_coinbase_factor = 0 ; account_creation_fee = Unsigned.UInt64.of_int 0 ; fork = None - ; zkapps_per_block = 128 } let tag = @@ -2113,7 +2104,6 @@ module Make_str (_ : Wire_types.Concrete) = struct ; supercharged_coinbase_factor = 0 ; account_creation_fee = Unsigned.UInt64.of_int 0 ; fork = None - ; zkapps_per_block = 128 } ~choices:(fun ~self:_ -> [ { identifier = "main" @@ -2167,7 +2157,6 @@ module Make_str (_ : Wire_types.Concrete) = struct ; supercharged_coinbase_factor = 0 ; account_creation_fee = Unsigned.UInt64.of_int 0 ; fork = None - ; zkapps_per_block = 128 } ~choices:(fun ~self:_ -> [ { identifier = "main" @@ -2222,7 +2211,6 @@ module Make_str (_ : Wire_types.Concrete) = struct ; supercharged_coinbase_factor = 0 ; account_creation_fee = Unsigned.UInt64.of_int 0 ; fork = None - ; zkapps_per_block = 128 } ~choices:(fun ~self:_ -> [ { identifier = "main" @@ -2300,7 +2288,6 @@ module Make_str (_ : Wire_types.Concrete) = struct ; supercharged_coinbase_factor = 0 ; account_creation_fee = Unsigned.UInt64.of_int 0 ; fork = None - ; zkapps_per_block = 128 } ~choices:(fun ~self:_ -> [ { identifier = "main" @@ -2465,7 +2452,6 @@ module Make_str (_ : Wire_types.Concrete) = struct ; supercharged_coinbase_factor = 0 ; account_creation_fee = Unsigned.UInt64.of_int 0 ; fork = None - ; zkapps_per_block = 128 } ~choices:(fun ~self:_ -> [ { identifier = "main" @@ -2519,7 +2505,6 @@ module Make_str (_ : Wire_types.Concrete) = struct ; supercharged_coinbase_factor = 0 ; account_creation_fee = Unsigned.UInt64.of_int 0 ; fork = None - ; zkapps_per_block = 128 } ~choices:(fun ~self:_ -> [ { identifier = "main" @@ -2574,7 +2559,6 @@ module Make_str (_ : Wire_types.Concrete) = struct ; supercharged_coinbase_factor = 0 ; account_creation_fee = Unsigned.UInt64.of_int 0 ; fork = None - ; zkapps_per_block = 128 } ~choices:(fun ~self:_ -> [ { identifier = "main" @@ -2656,7 +2640,6 @@ module Make_str (_ : Wire_types.Concrete) = struct ; supercharged_coinbase_factor = 0 ; account_creation_fee = Unsigned.UInt64.of_int 0 ; fork = None - ; zkapps_per_block = 128 } ~choices:(fun ~self:_ -> [ { identifier = "main" diff --git a/src/lib/runtime_config/runtime_config.ml b/src/lib/runtime_config/runtime_config.ml index 898c96ad0e8..fd0bba477d4 100644 --- a/src/lib/runtime_config/runtime_config.ml +++ b/src/lib/runtime_config/runtime_config.ml @@ -381,7 +381,6 @@ module Json_layout = struct ; supercharged_coinbase_factor : int option [@default None] ; account_creation_fee : Currency.Fee.t option [@default None] ; fork : Fork_config.t option [@default None] - ; zkapps_per_block : int option [@default None] } [@@deriving yojson, fields, dhall_type] @@ -397,6 +396,7 @@ module Json_layout = struct ; slots_per_epoch : int option [@default None] ; slots_per_sub_window : int option [@default None] ; genesis_state_timestamp : string option [@default None] + ; zkapps_per_block : int option [@default None] } [@@deriving yojson, fields, dhall_type] @@ -745,14 +745,12 @@ module Proof_keys = struct ; supercharged_coinbase_factor : int option ; account_creation_fee : Currency.Fee.Stable.Latest.t option ; fork : Fork_config.t option - ; zkapps_per_block : int option } [@@deriving bin_io_unversioned] let make ?level ?sub_windows_per_window ?ledger_depth ?work_delay ?block_window_duration_ms ?transaction_capacity ?coinbase_amount - ?supercharged_coinbase_factor ?account_creation_fee ?zkapps_per_block - ?fork () = + ?supercharged_coinbase_factor ?account_creation_fee ?fork () = { level ; sub_windows_per_window ; ledger_depth @@ -763,7 +761,6 @@ module Proof_keys = struct ; supercharged_coinbase_factor ; account_creation_fee ; fork - ; zkapps_per_block } let to_json_layout @@ -777,7 +774,6 @@ module Proof_keys = struct ; supercharged_coinbase_factor ; account_creation_fee ; fork - ; zkapps_per_block } = { Json_layout.Proof_keys.level = Option.map ~f:Level.to_json_layout level ; sub_windows_per_window @@ -790,7 +786,6 @@ module Proof_keys = struct ; supercharged_coinbase_factor ; account_creation_fee ; fork - ; zkapps_per_block } let of_json_layout @@ -804,7 +799,6 @@ module Proof_keys = struct ; supercharged_coinbase_factor ; account_creation_fee ; fork - ; zkapps_per_block } = let open Result.Let_syntax in let%map level = result_opt ~f:Level.of_json_layout level @@ -821,7 +815,6 @@ module Proof_keys = struct ; supercharged_coinbase_factor ; account_creation_fee ; fork - ; zkapps_per_block } let to_yojson x = Json_layout.Proof_keys.to_yojson (to_json_layout x) @@ -849,8 +842,6 @@ module Proof_keys = struct ; account_creation_fee = opt_fallthrough ~default:t1.account_creation_fee t2.account_creation_fee ; fork = opt_fallthrough ~default:t1.fork t2.fork - ; zkapps_per_block = - opt_fallthrough ~default:t1.zkapps_per_block t2.zkapps_per_block } end @@ -861,6 +852,7 @@ module Genesis = struct ; slots_per_epoch : int option ; slots_per_sub_window : int option ; genesis_state_timestamp : string option + ; zkapps_per_block : int option } [@@deriving bin_io_unversioned] @@ -884,6 +876,8 @@ module Genesis = struct ; genesis_state_timestamp = opt_fallthrough ~default:t1.genesis_state_timestamp t2.genesis_state_timestamp + ; zkapps_per_block = + opt_fallthrough ~default:t1.zkapps_per_block t2.zkapps_per_block } end diff --git a/src/lib/snark_keys_header/snark_keys_header.ml b/src/lib/snark_keys_header/snark_keys_header.ml index 91ba49c6484..e34b387c773 100644 --- a/src/lib/snark_keys_header/snark_keys_header.ml +++ b/src/lib/snark_keys_header/snark_keys_header.ml @@ -119,7 +119,6 @@ module Constraint_constants = struct (Fork_config.t option [@to_yojson Fork_config.opt_to_yojson] [@of_yojson Fork_config.opt_of_yojson] ) - ; zkapps_per_block : int } [@@deriving yojson, sexp, ord, equal] end @@ -233,7 +232,6 @@ let%test_module "Check parsing of header" = ; supercharged_coinbase_factor = 1 ; account_creation_fee = Unsigned.UInt64.of_int 1 ; fork = None - ; zkapps_per_block = 128 } ; commits = { mina = "7e1fb2cd9138af1d0f24e78477efd40a2a0fcd07" From 74367fceb4d61f8a355fe35f77d7a671c1cf70b6 Mon Sep 17 00:00:00 2001 From: ejMina226 <118474890+ejMina226@users.noreply.github.com> Date: Wed, 10 Jan 2024 22:11:25 +0000 Subject: [PATCH 05/17] Access Protocol Constant for Staged ledger --- src/lib/staged_ledger/staged_ledger.ml | 4 ++-- src/lib/staged_ledger/staged_ledger.mli | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/lib/staged_ledger/staged_ledger.ml b/src/lib/staged_ledger/staged_ledger.ml index cb546e20243..6776c1f03c5 100644 --- a/src/lib/staged_ledger/staged_ledger.ml +++ b/src/lib/staged_ledger/staged_ledger.ml @@ -988,10 +988,10 @@ module T = struct |> List.filter ~f:(fun txn -> zkAppCountGetter txn) |> List.length in - if zkAppCount > t.constraint_constants.zkapps_per_block then + if zkAppCount > Genesis_constants.zkapps_per_block then Deferred.Result.fail (Staged_ledger_error.ZkApps_exceed_limit - (zkAppCount, t.constraint_constants.zkapps_per_block) ) + (zkAppCount, Genesis_constants.zkapps_per_block) ) else Deferred.Result.return () ) in [%log internal] "Update_coinbase_stack" diff --git a/src/lib/staged_ledger/staged_ledger.mli b/src/lib/staged_ledger/staged_ledger.mli index 2bd6326475e..17347b2979e 100644 --- a/src/lib/staged_ledger/staged_ledger.mli +++ b/src/lib/staged_ledger/staged_ledger.mli @@ -143,6 +143,7 @@ module Staged_ledger_error : sig | Insufficient_work of string | Mismatched_statuses of Transaction.t With_status.t * Transaction_status.t | Invalid_public_key of Public_key.Compressed.t + | ZkApps_exceed_limit of int * int | Unexpected of Error.t [@@deriving sexp] From 3a4a2841efbabb07ca5c5b2af450e087d02ae92b Mon Sep 17 00:00:00 2001 From: ejMina226 <118474890+ejMina226@users.noreply.github.com> Date: Thu, 11 Jan 2024 16:17:59 +0000 Subject: [PATCH 06/17] Add in new variable to function so it can be passed down to staged ledger --- src/lib/block_producer/block_producer.ml | 8 ++++--- src/lib/mina_lib/mina_lib.ml | 4 +++- src/lib/staged_ledger/staged_ledger.ml | 23 +++++++++++-------- src/lib/staged_ledger/staged_ledger.mli | 2 ++ .../frontier_base/breadcrumb.ml | 3 +++ 5 files changed, 27 insertions(+), 13 deletions(-) diff --git a/src/lib/block_producer/block_producer.ml b/src/lib/block_producer/block_producer.ml index c897b84c807..426f406f52c 100644 --- a/src/lib/block_producer/block_producer.ml +++ b/src/lib/block_producer/block_producer.ml @@ -163,7 +163,7 @@ let report_transaction_inclusion_failures ~logger failed_txns = let generate_next_state ~constraint_constants ~previous_protocol_state ~time_controller ~staged_ledger ~transactions ~get_completed_work ~logger ~(block_data : Consensus.Data.Block_data.t) ~winner_pk ~scheduled_time - ~log_block_creation ~block_reward_threshold = + ~log_block_creation ~block_reward_threshold ~zkapps_per_block = let open Interruptible.Let_syntax in let previous_protocol_state_body_hash = Protocol_state.body previous_protocol_state |> Protocol_state.Body.hash @@ -241,7 +241,7 @@ let generate_next_state ~constraint_constants ~previous_protocol_state ~global_slot diff ~logger ~current_state_view:previous_state_view ~state_and_body_hash: (previous_protocol_state_hash, previous_protocol_state_body_hash) - ~coinbase_receiver ~supercharge_coinbase + ~coinbase_receiver ~supercharge_coinbase ~zkapps_per_block with | Ok ( `Hash_after_applying next_staged_ledger_hash @@ -610,7 +610,8 @@ let run ~context:(module Context : CONTEXT) ~vrf_evaluator ~prover ~verifier ~trust_system ~get_completed_work ~transaction_resource_pool ~time_controller ~consensus_local_state ~coinbase_receiver ~frontier_reader ~transition_writer ~set_next_producer_timing ~log_block_creation - ~block_reward_threshold ~block_produced_bvar ~vrf_evaluation_state ~net = + ~block_reward_threshold ~block_produced_bvar ~vrf_evaluation_state ~net + ~zkapps_per_block = let open Context in O1trace.sync_thread "produce_blocks" (fun () -> let genesis_breadcrumb = @@ -745,6 +746,7 @@ let run ~context:(module Context : CONTEXT) ~vrf_evaluator ~prover ~verifier ~staged_ledger:(Breadcrumb.staged_ledger crumb) ~transactions ~get_completed_work ~logger ~log_block_creation ~winner_pk:winner_pubkey ~block_reward_threshold + ~zkapps_per_block in [%log internal] "Generate_next_state_done" ; match next_state_opt with diff --git a/src/lib/mina_lib/mina_lib.ml b/src/lib/mina_lib/mina_lib.ml index 236bdaeebae..077f76b1f2e 100644 --- a/src/lib/mina_lib/mina_lib.ml +++ b/src/lib/mina_lib/mina_lib.ml @@ -1380,7 +1380,9 @@ let start t = ~log_block_creation:t.config.log_block_creation ~block_reward_threshold:t.config.block_reward_threshold ~block_produced_bvar:t.components.block_produced_bvar - ~vrf_evaluation_state:t.vrf_evaluation_state ~net:t.components.net ; + ~vrf_evaluation_state:t.vrf_evaluation_state ~net:t.components.net + ~zkapps_per_block: + t.config.precomputed_values.genesis_constants.protocol.zkapps_per_block ; perform_compaction t ; let () = match t.config.node_status_url with diff --git a/src/lib/staged_ledger/staged_ledger.ml b/src/lib/staged_ledger/staged_ledger.ml index 6776c1f03c5..16e143c576b 100644 --- a/src/lib/staged_ledger/staged_ledger.ml +++ b/src/lib/staged_ledger/staged_ledger.ml @@ -958,7 +958,7 @@ module T = struct let apply_diff ?(skip_verification = false) ~logger ~constraint_constants ~global_slot t pre_diff_info ~current_state_view ~state_and_body_hash - ~log_prefix = + ~log_prefix ~zkapps_per_block = let open Deferred.Result.Let_syntax in let max_throughput = Int.pow 2 t.constraint_constants.transaction_capacity_log_2 @@ -988,10 +988,10 @@ module T = struct |> List.filter ~f:(fun txn -> zkAppCountGetter txn) |> List.length in - if zkAppCount > Genesis_constants.zkapps_per_block then + if zkAppCount > zkapps_per_block then Deferred.Result.fail (Staged_ledger_error.ZkApps_exceed_limit - (zkAppCount, Genesis_constants.zkapps_per_block) ) + (zkAppCount, zkapps_per_block) ) else Deferred.Result.return () ) in [%log internal] "Update_coinbase_stack" @@ -1193,7 +1193,8 @@ module T = struct let apply ?skip_verification ~constraint_constants ~global_slot t (witness : Staged_ledger_diff.t) ~logger ~verifier ~current_state_view - ~state_and_body_hash ~coinbase_receiver ~supercharge_coinbase = + ~state_and_body_hash ~coinbase_receiver ~supercharge_coinbase + ~zkapps_per_block = let open Deferred.Result.Let_syntax in let work = Staged_ledger_diff.completed_works witness in let%bind () = @@ -1225,7 +1226,7 @@ module T = struct ~constraint_constants ~global_slot t (forget_prediff_info prediff) ~logger ~current_state_view ~state_and_body_hash - ~log_prefix:"apply_diff" + ~log_prefix:"apply_diff" ~zkapps_per_block in [%log internal] "Diff_applied" ; [%log debug] @@ -1247,7 +1248,7 @@ module T = struct let apply_diff_unchecked ~constraint_constants ~global_slot t (sl_diff : Staged_ledger_diff.With_valid_signatures_and_proofs.t) ~logger ~current_state_view ~state_and_body_hash ~coinbase_receiver - ~supercharge_coinbase = + ~supercharge_coinbase ~zkapps_per_block = let open Deferred.Result.Let_syntax in let%bind prediff = Result.map_error ~f:(fun error -> Staged_ledger_error.Pre_diff error) @@ -1258,7 +1259,7 @@ module T = struct apply_diff t (forget_prediff_info prediff) ~constraint_constants ~global_slot ~logger ~current_state_view - ~state_and_body_hash ~log_prefix:"apply_diff_unchecked" + ~state_and_body_hash ~log_prefix:"apply_diff_unchecked" ~zkapps_per_block module Resources = struct module Discarded = struct @@ -2187,6 +2188,8 @@ let%test_module "staged ledger tests" = let constraint_constants = Genesis_constants.Constraint_constants.for_unit_tests + let zkapps_per_block = 1 + let logger = Logger.null () let `VK vk, `Prover zkapp_prover = @@ -2238,7 +2241,7 @@ let%test_module "staged ledger tests" = match%map Sl.apply ~constraint_constants ~global_slot !sl diff' ~logger ~verifier ~current_state_view ~state_and_body_hash - ~coinbase_receiver ~supercharge_coinbase + ~coinbase_receiver ~supercharge_coinbase ~zkapps_per_block with | Ok x -> x @@ -3223,6 +3226,7 @@ let%test_module "staged ledger tests" = ( state_hashes.state_hash , state_hashes.state_body_hash |> Option.value_exn ) ~coinbase_receiver ~supercharge_coinbase:true + ~zkapps_per_block in let checked', diff' = match apply_res with @@ -4247,6 +4251,7 @@ let%test_module "staged ledger tests" = (Staged_ledger_diff.forget diff) ~logger ~verifier ~current_state_view ~state_and_body_hash ~coinbase_receiver ~supercharge_coinbase:false + ~zkapps_per_block with | Ok _x -> assert false @@ -4539,7 +4544,7 @@ let%test_module "staged ledger tests" = (Staged_ledger_diff.forget diff) ~logger ~verifier:verifier_full ~current_state_view ~state_and_body_hash ~coinbase_receiver - ~supercharge_coinbase:false + ~supercharge_coinbase:false ~zkapps_per_block with | Ok _ -> failwith "invalid block should be rejected" diff --git a/src/lib/staged_ledger/staged_ledger.mli b/src/lib/staged_ledger/staged_ledger.mli index 17347b2979e..1e3bdd5ed2b 100644 --- a/src/lib/staged_ledger/staged_ledger.mli +++ b/src/lib/staged_ledger/staged_ledger.mli @@ -190,6 +190,7 @@ val apply : -> state_and_body_hash:State_hash.t * State_body_hash.t -> coinbase_receiver:Public_key.Compressed.t -> supercharge_coinbase:bool + -> zkapps_per_block:int -> ( [ `Hash_after_applying of Staged_ledger_hash.t ] * [ `Ledger_proof of ( Ledger_proof.t @@ -214,6 +215,7 @@ val apply_diff_unchecked : -> state_and_body_hash:State_hash.t * State_body_hash.t -> coinbase_receiver:Public_key.Compressed.t -> supercharge_coinbase:bool + -> zkapps_per_block:int -> ( [ `Hash_after_applying of Staged_ledger_hash.t ] * [ `Ledger_proof of ( Ledger_proof.t diff --git a/src/lib/transition_frontier/frontier_base/breadcrumb.ml b/src/lib/transition_frontier/frontier_base/breadcrumb.ml index 2cbdf107207..5b4b5168808 100644 --- a/src/lib/transition_frontier/frontier_base/breadcrumb.ml +++ b/src/lib/transition_frontier/frontier_base/breadcrumb.ml @@ -189,6 +189,7 @@ let build ?skip_staged_ledger_verification ~logger ~precomputed_values ~verifier | Insufficient_work _ | Mismatched_statuses _ | Invalid_public_key _ + | ZkApps_exceed_limit _ | Unexpected _ -> make_actions Gossiped_invalid_transition in @@ -401,6 +402,8 @@ module For_tests = struct ~coinbase_receiver ~logger staged_ledger_diff ~constraint_constants:precomputed_values.constraint_constants ~current_state_view ~state_and_body_hash ~supercharge_coinbase + ~zkapps_per_block: + precomputed_values.genesis_constants.protocol.zkapps_per_block with | Ok r -> return r From 8346fc7614ad8305aad522f3e285f3bc1abcd76e Mon Sep 17 00:00:00 2001 From: ejMina226 <118474890+ejMina226@users.noreply.github.com> Date: Thu, 11 Jan 2024 16:34:57 +0000 Subject: [PATCH 07/17] Add in validation change --- src/lib/mina_block/validation.ml | 3 +++ src/lib/staged_ledger/staged_ledger.ml | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/lib/mina_block/validation.ml b/src/lib/mina_block/validation.ml index e28db75b705..16818a130f3 100644 --- a/src/lib/mina_block/validation.ml +++ b/src/lib/mina_block/validation.ml @@ -503,6 +503,9 @@ let validate_staged_ledger_diff ?skip_staged_ledger_verification ~logger ~coinbase_receiver:(Consensus_state.coinbase_receiver consensus_state) ~supercharge_coinbase: (Consensus_state.supercharge_coinbase consensus_state) + ~zkapps_per_block: + precomputed_values.Precomputed_values.genesis_constants.protocol + .zkapps_per_block |> Deferred.Result.map_error ~f:(fun e -> `Staged_ledger_application_failed e ) in diff --git a/src/lib/staged_ledger/staged_ledger.ml b/src/lib/staged_ledger/staged_ledger.ml index 2b5f67cd8d1..9de72df61dc 100644 --- a/src/lib/staged_ledger/staged_ledger.ml +++ b/src/lib/staged_ledger/staged_ledger.ml @@ -4609,7 +4609,7 @@ let%test_module "staged ledger tests" = (Staged_ledger_diff.forget diff) ~logger ~verifier ~get_completed_work:(Fn.const None) ~current_state_view ~state_and_body_hash ~coinbase_receiver - ~supercharge_coinbase:false + ~supercharge_coinbase:false ~zkapps_per_block with | Ok _x -> ( let valid_command_1_with_status = @@ -4656,6 +4656,7 @@ let%test_module "staged ledger tests" = ~logger ~verifier ~get_completed_work:(Fn.const None) ~current_state_view ~state_and_body_hash ~coinbase_receiver ~supercharge_coinbase:false + ~zkapps_per_block with | Ok _x -> assert false From 977333789ad9eab1d59b65f5c1321ae6dbb5deec Mon Sep 17 00:00:00 2001 From: ejMina226 <118474890+ejMina226@users.noreply.github.com> Date: Thu, 11 Jan 2024 17:54:53 +0000 Subject: [PATCH 08/17] Moved variable to daemon --- src/lib/consensus/constants.ml | 6 ------ src/lib/genesis_constants/genesis_constants.ml | 11 ++--------- .../lib/genesis_ledger_helper_lib.ml | 9 +++++---- src/lib/mina_base/protocol_constants_checked.ml | 9 +-------- src/lib/mina_base/test/valid_size.ml | 2 +- src/lib/mina_block/validation.ml | 3 +-- src/lib/mina_compile_config/mina_compile_config.ml | 2 ++ src/lib/mina_lib/mina_lib.ml | 2 +- src/lib/mina_wire_types/genesis_constants.ml | 1 - src/lib/runtime_config/runtime_config.ml | 8 ++++---- src/lib/staged_ledger/staged_ledger.ml | 6 +++--- .../transition_frontier/frontier_base/breadcrumb.ml | 2 +- 12 files changed, 21 insertions(+), 40 deletions(-) diff --git a/src/lib/consensus/constants.ml b/src/lib/consensus/constants.ml index f287a79bdb2..2c67f951a6f 100644 --- a/src/lib/consensus/constants.ml +++ b/src/lib/consensus/constants.ml @@ -23,7 +23,6 @@ module Poly = struct ; epoch_duration : 'timespan ; delta_duration : 'timespan ; genesis_state_timestamp : 'time - ; zkapps_per_block : 'length } [@@deriving equal, compare, hash, sexp, to_yojson, hlist] end @@ -258,7 +257,6 @@ let create' (type a b c) ; checkpoint_window_size_in_slots = to_length zero ; delta_duration = to_timespan delta_duration ; genesis_state_timestamp = protocol_constants.genesis_state_timestamp - ; zkapps_per_block = protocol_constants.zkapps_per_block } in res @@ -302,7 +300,6 @@ let to_protocol_constants ; genesis_state_timestamp ; slots_per_sub_window ; slots_per_epoch - ; zkapps_per_block ; _ } : _ Poly.t ) = @@ -311,7 +308,6 @@ let to_protocol_constants ; genesis_state_timestamp ; slots_per_sub_window ; slots_per_epoch - ; zkapps_per_block } let typ = @@ -330,7 +326,6 @@ let typ = ; Block_time.Span.Checked.typ ; Block_time.Span.Checked.typ ; Block_time.Checked.typ - ; Length.Checked.typ ] ~var_to_hlist:Poly.to_hlist ~var_of_hlist:Poly.of_hlist ~value_to_hlist:Poly.to_hlist ~value_of_hlist:Poly.of_hlist @@ -387,7 +382,6 @@ module Checked = struct ; t.grace_period_end ; t.checkpoint_window_slots_per_year ; t.checkpoint_window_size_in_slots - ; t.zkapps_per_block |] ; Array.map ~f:Block_time.Span.Checked.to_input [| t.block_window_duration_ms diff --git a/src/lib/genesis_constants/genesis_constants.ml b/src/lib/genesis_constants/genesis_constants.ml index 4b4fbdd23e7..e2901404979 100644 --- a/src/lib/genesis_constants/genesis_constants.ml +++ b/src/lib/genesis_constants/genesis_constants.ml @@ -247,7 +247,6 @@ module Protocol = struct ; slots_per_sub_window : 'length ; delta : 'delta ; genesis_state_timestamp : 'genesis_state_timestamp - ; zkapps_per_block : 'length } [@@deriving equal, ord, hash, sexp, yojson, hlist, fields] end @@ -275,7 +274,6 @@ module Protocol = struct (Time.Span.of_ms (Int64.to_float t.genesis_state_timestamp) ) ) ~zone:Time.Zone.utc ) ) - ; ("zkapps_per_block", `Int t.zkapps_per_block) ] let of_yojson = function @@ -285,7 +283,6 @@ module Protocol = struct ; ("slots_per_sub_window", `Int slots_per_sub_window) ; ("delta", `Int delta) ; ("genesis_state_timestamp", `String time_str) - ; ("zkapps_per_block", `Int zkapps_per_block) ] -> ( match validate_time time_str with | Ok genesis_state_timestamp -> @@ -295,7 +292,6 @@ module Protocol = struct ; slots_per_sub_window ; delta ; genesis_state_timestamp - ; zkapps_per_block } | Error e -> Error (sprintf !"Genesis_constants.Protocol.of_yojson: %s" e) ) @@ -318,7 +314,6 @@ module Protocol = struct (Time.of_span_since_epoch (Time.Span.of_ms (Int64.to_float t.genesis_state_timestamp)) ) ~zone:Time.Zone.utc - ; zkapps_per_block = t.zkapps_per_block } in T.sexp_of_t t' @@ -340,6 +335,7 @@ module T = struct ; zkapp_transaction_cost_limit : float ; max_event_elements : int ; max_action_elements : int + ; zkapps_per_block : int } [@@deriving to_yojson, sexp_of, bin_io_unversioned] @@ -352,7 +348,6 @@ module T = struct ; t.protocol.slots_per_sub_window ; t.protocol.delta ; t.txpool_max_size - ; t.protocol.zkapps_per_block ] ~f:Int.to_string |> String.concat ~sep:"" ) @@ -378,8 +373,6 @@ include T [%%inject "pool_max_size", pool_max_size] -[%%inject "zkapps_per_block", zkapps_per_block] - let compiled : t = { protocol = { k @@ -388,7 +381,6 @@ let compiled : t = ; delta ; genesis_state_timestamp = genesis_timestamp_of_string genesis_state_timestamp_string |> of_time - ; zkapps_per_block } ; txpool_max_size = pool_max_size ; num_accounts = None @@ -401,6 +393,7 @@ let compiled : t = Mina_compile_config.zkapp_transaction_cost_limit ; max_event_elements = Mina_compile_config.max_event_elements ; max_action_elements = Mina_compile_config.max_action_elements + ; zkapps_per_block = Mina_compile_config.zkapps_per_block } let for_unit_tests = compiled 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 e2d7f62f902..4b8c6b508b7 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 @@ -542,9 +542,6 @@ let make_genesis_constants ~logger ~(default : Genesis_constants.t) ; genesis_state_timestamp = Option.value ~default:default.protocol.genesis_state_timestamp genesis_state_timestamp - ; zkapps_per_block = - Option.value ~default:default.protocol.zkapps_per_block - (config.genesis >>= fun cfg -> cfg.zkapps_per_block) } ; txpool_max_size = Option.value ~default:default.txpool_max_size @@ -571,6 +568,9 @@ let make_genesis_constants ~logger ~(default : Genesis_constants.t) Option.value_map ~default:default.num_accounts (config.ledger >>= fun cfg -> cfg.num_accounts) ~f:(fun num_accounts -> Some num_accounts) + ; zkapps_per_block = + Option.value ~default:default.zkapps_per_block + (config.daemon >>= fun cfg -> cfg.zkapps_per_block) } let runtime_config_of_genesis_constants (genesis_constants : Genesis_constants.t) @@ -583,7 +583,6 @@ let runtime_config_of_genesis_constants (genesis_constants : Genesis_constants.t Some (Genesis_constants.genesis_timestamp_to_string genesis_constants.protocol.genesis_state_timestamp ) - ; zkapps_per_block = Some genesis_constants.protocol.zkapps_per_block } let runtime_config_of_precomputed_values (precomputed_values : Genesis_proof.t) @@ -612,6 +611,8 @@ let runtime_config_of_precomputed_values (precomputed_values : Genesis_proof.t) Some precomputed_values.genesis_constants.max_event_elements ; max_action_elements = Some precomputed_values.genesis_constants.max_action_elements + ; zkapps_per_block = + Some precomputed_values.genesis_constants.zkapps_per_block } ; genesis = Some diff --git a/src/lib/mina_base/protocol_constants_checked.ml b/src/lib/mina_base/protocol_constants_checked.ml index 318d0bbb813..12b758f6634 100644 --- a/src/lib/mina_base/protocol_constants_checked.ml +++ b/src/lib/mina_base/protocol_constants_checked.ml @@ -31,7 +31,6 @@ module Value = struct let open Quickcheck.Let_syntax in let%bind k = Int.gen_incl 1 5000 in let%bind delta = Int.gen_incl 0 5000 in - let%bind zkapps_per_block = Int.gen_incl 1 128 in let%bind slots_per_epoch = Int.gen_incl k (8 * k) >>| ( * ) 3 >>| T.of_int and slots_per_sub_window = Int.gen_incl 1 ((k + 9) / 9) in (*TODO: Bug -> Block_time.(to_time x |> of_time) != x for certain values. @@ -46,7 +45,6 @@ module Value = struct ; slots_per_epoch ; slots_per_sub_window = T.of_int slots_per_sub_window ; genesis_state_timestamp - ; zkapps_per_block = T.of_int zkapps_per_block } end @@ -58,7 +56,6 @@ let value_of_t (t : Genesis_constants.Protocol.t) : value = ; slots_per_epoch = T.of_int t.slots_per_epoch ; slots_per_sub_window = T.of_int t.slots_per_sub_window ; genesis_state_timestamp = Block_time.of_int64 t.genesis_state_timestamp - ; zkapps_per_block = T.of_int t.zkapps_per_block } let t_of_value (v : value) : Genesis_constants.Protocol.t = @@ -67,7 +64,6 @@ let t_of_value (v : value) : Genesis_constants.Protocol.t = ; slots_per_epoch = T.to_int v.slots_per_epoch ; slots_per_sub_window = T.to_int v.slots_per_sub_window ; genesis_state_timestamp = Block_time.to_int64 v.genesis_state_timestamp - ; zkapps_per_block = T.to_int v.zkapps_per_block } let to_input (t : value) = @@ -90,7 +86,6 @@ let typ = ; T.Checked.typ ; T.Checked.typ ; Block_time.Checked.typ - ; T.Checked.typ ] ~var_to_hlist:Poly.to_hlist ~var_of_hlist:Poly.of_hlist ~value_to_hlist:Poly.to_hlist ~value_of_hlist:Poly.of_hlist @@ -99,8 +94,7 @@ let var_to_input (var : var) = let k = T.Checked.to_input var.k and delta = T.Checked.to_input var.delta and slots_per_epoch = T.Checked.to_input var.slots_per_epoch - and slots_per_sub_window = T.Checked.to_input var.slots_per_sub_window - and zkapps_per_block = T.Checked.to_input var.zkapps_per_block in + and slots_per_sub_window = T.Checked.to_input var.slots_per_sub_window in let genesis_state_timestamp = Block_time.Checked.to_input var.genesis_state_timestamp in @@ -110,7 +104,6 @@ let var_to_input (var : var) = ; slots_per_epoch ; slots_per_sub_window ; genesis_state_timestamp - ; zkapps_per_block |] let%test_unit "value = var" = diff --git a/src/lib/mina_base/test/valid_size.ml b/src/lib/mina_base/test/valid_size.ml index 450c8d2c490..2a52d698fab 100644 --- a/src/lib/mina_base/test/valid_size.ml +++ b/src/lib/mina_base/test/valid_size.ml @@ -35,7 +35,6 @@ let genesis_constant_error limit events actions : Genesis_constants.t = ; slots_per_sub_window = 5 ; delta = 5 ; genesis_state_timestamp = Genesis_constants.of_time (Time.now ()) - ; zkapps_per_block = 128 } ; txpool_max_size = 5 ; num_accounts = Some 1 @@ -45,6 +44,7 @@ let genesis_constant_error limit events actions : Genesis_constants.t = ; zkapp_transaction_cost_limit = limit ; max_event_elements = events ; max_action_elements = actions + ; zkapps_per_block = 1 } (* Note that in the following tests the generated zkapp_type will have an account_updates (i.e. a call_forest) diff --git a/src/lib/mina_block/validation.ml b/src/lib/mina_block/validation.ml index 16818a130f3..9dd52bf4d77 100644 --- a/src/lib/mina_block/validation.ml +++ b/src/lib/mina_block/validation.ml @@ -504,8 +504,7 @@ let validate_staged_ledger_diff ?skip_staged_ledger_verification ~logger ~supercharge_coinbase: (Consensus_state.supercharge_coinbase consensus_state) ~zkapps_per_block: - precomputed_values.Precomputed_values.genesis_constants.protocol - .zkapps_per_block + precomputed_values.Precomputed_values.genesis_constants.zkapps_per_block |> Deferred.Result.map_error ~f:(fun e -> `Staged_ledger_application_failed e ) in diff --git a/src/lib/mina_compile_config/mina_compile_config.ml b/src/lib/mina_compile_config/mina_compile_config.ml index 7de63fc0396..27b6962a247 100644 --- a/src/lib/mina_compile_config/mina_compile_config.ml +++ b/src/lib/mina_compile_config/mina_compile_config.ml @@ -80,3 +80,5 @@ let zkapp_cmd_limit = None let zkapp_cmd_limit = Some zkapp_cmd_limit [%%endif] + +let zkapps_per_block = 100 diff --git a/src/lib/mina_lib/mina_lib.ml b/src/lib/mina_lib/mina_lib.ml index 63bb0d52110..2d47a69e424 100644 --- a/src/lib/mina_lib/mina_lib.ml +++ b/src/lib/mina_lib/mina_lib.ml @@ -1382,7 +1382,7 @@ let start t = ~block_produced_bvar:t.components.block_produced_bvar ~vrf_evaluation_state:t.vrf_evaluation_state ~net:t.components.net ~zkapps_per_block: - t.config.precomputed_values.genesis_constants.protocol.zkapps_per_block ; + t.config.precomputed_values.genesis_constants.zkapps_per_block ; perform_compaction t ; let () = match t.config.node_status_url with diff --git a/src/lib/mina_wire_types/genesis_constants.ml b/src/lib/mina_wire_types/genesis_constants.ml index 1d18273accb..b56306151bd 100644 --- a/src/lib/mina_wire_types/genesis_constants.ml +++ b/src/lib/mina_wire_types/genesis_constants.ml @@ -7,7 +7,6 @@ module Protocol = struct ; slots_per_sub_window : 'length ; delta : 'delta ; genesis_state_timestamp : 'genesis_state_timestamp - ; zkapps_per_block : 'length } end end diff --git a/src/lib/runtime_config/runtime_config.ml b/src/lib/runtime_config/runtime_config.ml index 67290d46c22..98dfbfdf68d 100644 --- a/src/lib/runtime_config/runtime_config.ml +++ b/src/lib/runtime_config/runtime_config.ml @@ -393,7 +393,6 @@ module Json_layout = struct ; slots_per_epoch : int option [@default None] ; slots_per_sub_window : int option [@default None] ; genesis_state_timestamp : string option [@default None] - ; zkapps_per_block : int option [@default None] } [@@deriving yojson, fields, dhall_type] @@ -412,6 +411,7 @@ module Json_layout = struct ; zkapp_transaction_cost_limit : float option [@default None] ; max_event_elements : int option [@default None] ; max_action_elements : int option [@default None] + ; zkapps_per_block : int option [@default None] } [@@deriving yojson, fields, dhall_type] @@ -849,7 +849,6 @@ module Genesis = struct ; slots_per_epoch : int option ; slots_per_sub_window : int option ; genesis_state_timestamp : string option - ; zkapps_per_block : int option } [@@deriving bin_io_unversioned] @@ -873,8 +872,6 @@ module Genesis = struct ; genesis_state_timestamp = opt_fallthrough ~default:t1.genesis_state_timestamp t2.genesis_state_timestamp - ; zkapps_per_block = - opt_fallthrough ~default:t1.zkapps_per_block t2.zkapps_per_block } end @@ -888,6 +885,7 @@ module Daemon = struct ; zkapp_transaction_cost_limit : float option [@default None] ; max_event_elements : int option [@default None] ; max_action_elements : int option [@default None] + ; zkapps_per_block : int option [@default None] } [@@deriving bin_io_unversioned] @@ -921,6 +919,8 @@ module Daemon = struct opt_fallthrough ~default:t1.max_event_elements t2.max_event_elements ; max_action_elements = opt_fallthrough ~default:t1.max_action_elements t2.max_action_elements + ; zkapps_per_block = + opt_fallthrough ~default:t1.zkapps_per_block t2.zkapps_per_block } end diff --git a/src/lib/staged_ledger/staged_ledger.ml b/src/lib/staged_ledger/staged_ledger.ml index 9de72df61dc..b936068b6aa 100644 --- a/src/lib/staged_ledger/staged_ledger.ml +++ b/src/lib/staged_ledger/staged_ledger.ml @@ -1033,9 +1033,9 @@ module T = struct |> Set.to_list in Ledger.unsafe_preload_accounts_from_parent new_ledger accounts_accessed ; - [%log internal] "Check #zkApp does not exceed hardcap" ; let%bind () = - O1trace.thread "Check #zkApp does not exceed hardcap" (fun () -> + O1trace.thread "Check number of zkApps in a block does not exceed hardcap" + (fun () -> let zkAppCountGetter : Transaction.t With_status.t -> bool = function | { With_status.data = Transaction.Command (Mina_base.User_command.Zkapp_command _) @@ -2376,7 +2376,7 @@ let%test_module "staged ledger tests" = let constraint_constants = Genesis_constants.Constraint_constants.for_unit_tests - let zkapps_per_block = 1 + let zkapps_per_block = 200 let logger = Logger.null () diff --git a/src/lib/transition_frontier/frontier_base/breadcrumb.ml b/src/lib/transition_frontier/frontier_base/breadcrumb.ml index e09900859c3..04d5837f37a 100644 --- a/src/lib/transition_frontier/frontier_base/breadcrumb.ml +++ b/src/lib/transition_frontier/frontier_base/breadcrumb.ml @@ -404,7 +404,7 @@ module For_tests = struct ~constraint_constants:precomputed_values.constraint_constants ~current_state_view ~state_and_body_hash ~supercharge_coinbase ~zkapps_per_block: - precomputed_values.genesis_constants.protocol.zkapps_per_block + precomputed_values.genesis_constants.zkapps_per_block with | Ok r -> return r From 7d499383ef2ba3fe8b767c64eee8b6cd010e8fb8 Mon Sep 17 00:00:00 2001 From: ejMina226 <118474890+ejMina226@users.noreply.github.com> Date: Thu, 11 Jan 2024 17:58:30 +0000 Subject: [PATCH 09/17] Remove change to mlh --- src/config/devnet.mlh | 1 - 1 file changed, 1 deletion(-) diff --git a/src/config/devnet.mlh b/src/config/devnet.mlh index bcccacd244b..5e0db186f23 100644 --- a/src/config/devnet.mlh +++ b/src/config/devnet.mlh @@ -17,7 +17,6 @@ [%%define slots_per_epoch 7140] [%%define slots_per_sub_window 7] [%%define sub_windows_per_window 11] -[%%define zkapps_per_block 128] [%%define record_async_backtraces false] [%%define time_offsets true] From 02d2748d85ee7b00ff57ac2a5a5e354054299003 Mon Sep 17 00:00:00 2001 From: ejMina226 <118474890+ejMina226@users.noreply.github.com> Date: Thu, 11 Jan 2024 18:49:46 +0000 Subject: [PATCH 10/17] Fix automation --- src/lib/integration_test_cloud_engine/mina_automation.ml | 1 + 1 file changed, 1 insertion(+) diff --git a/src/lib/integration_test_cloud_engine/mina_automation.ml b/src/lib/integration_test_cloud_engine/mina_automation.ml index d1b2881546e..9a412ae03ff 100644 --- a/src/lib/integration_test_cloud_engine/mina_automation.ml +++ b/src/lib/integration_test_cloud_engine/mina_automation.ml @@ -221,6 +221,7 @@ module Network_config = struct ; zkapp_transaction_cost_limit = None ; max_event_elements = None ; max_action_elements = None + ; zkapps_per_block = None } ; genesis = Some From 3af8e090e60ff92eee08a6c7963f335f7c950309 Mon Sep 17 00:00:00 2001 From: ejMina226 <118474890+ejMina226@users.noreply.github.com> Date: Thu, 11 Jan 2024 18:53:59 +0000 Subject: [PATCH 11/17] Remove change --- src/lib/integration_test_lib/test_config.ml | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/lib/integration_test_lib/test_config.ml b/src/lib/integration_test_lib/test_config.ml index faa4e607dcd..104aca2dc7c 100644 --- a/src/lib/integration_test_lib/test_config.ml +++ b/src/lib/integration_test_lib/test_config.ml @@ -61,7 +61,6 @@ type t = ; slots_per_epoch : int ; slots_per_sub_window : int ; txpool_max_size : int - ; zkapps_per_block : int } let proof_config_default : Runtime_config.Proof_keys.t = @@ -94,7 +93,6 @@ let default = ; slots_per_sub_window = 2 ; delta = 0 ; txpool_max_size = 3000 - ; zkapps_per_block = 128 } let transaction_capacity_log_2 (config : t) = From a9228f5d36cda9edc9f887887b7a7b41102c12d3 Mon Sep 17 00:00:00 2001 From: ejMina226 <118474890+ejMina226@users.noreply.github.com> Date: Thu, 11 Jan 2024 18:55:38 +0000 Subject: [PATCH 12/17] Change valid size --- src/lib/mina_base/test/valid_size.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/mina_base/test/valid_size.ml b/src/lib/mina_base/test/valid_size.ml index 2a52d698fab..ee1ca24653a 100644 --- a/src/lib/mina_base/test/valid_size.ml +++ b/src/lib/mina_base/test/valid_size.ml @@ -44,7 +44,7 @@ let genesis_constant_error limit events actions : Genesis_constants.t = ; zkapp_transaction_cost_limit = limit ; max_event_elements = events ; max_action_elements = actions - ; zkapps_per_block = 1 + ; zkapps_per_block = 128 } (* Note that in the following tests the generated zkapp_type will have an account_updates (i.e. a call_forest) From 81213450947596f42457954c3faf09489e434c61 Mon Sep 17 00:00:00 2001 From: ejMina226 <118474890+ejMina226@users.noreply.github.com> Date: Thu, 11 Jan 2024 19:00:30 +0000 Subject: [PATCH 13/17] Change value in mina_compile_config --- src/lib/mina_compile_config/mina_compile_config.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/mina_compile_config/mina_compile_config.ml b/src/lib/mina_compile_config/mina_compile_config.ml index 27b6962a247..230d8c73509 100644 --- a/src/lib/mina_compile_config/mina_compile_config.ml +++ b/src/lib/mina_compile_config/mina_compile_config.ml @@ -81,4 +81,4 @@ let zkapp_cmd_limit = Some zkapp_cmd_limit [%%endif] -let zkapps_per_block = 100 +let zkapps_per_block = 128 From 72fe8241aecc7e20ad0d4488e8f72327da66063f Mon Sep 17 00:00:00 2001 From: ejMina226 <118474890+ejMina226@users.noreply.github.com> Date: Thu, 11 Jan 2024 23:47:28 +0000 Subject: [PATCH 14/17] Changed variable name --- src/lib/block_producer/block_producer.ml | 8 ++--- .../genesis_constants/genesis_constants.ml | 4 +-- .../lib/genesis_ledger_helper_lib.ml | 11 +++---- .../mina_automation.ml | 2 +- src/lib/mina_base/test/valid_size.ml | 2 +- src/lib/mina_block/validation.ml | 5 ++-- .../mina_compile_config.ml | 2 +- src/lib/mina_lib/mina_lib.ml | 4 +-- src/lib/runtime_config/runtime_config.ml | 9 +++--- src/lib/staged_ledger/staged_ledger.ml | 29 ++++++++++--------- src/lib/staged_ledger/staged_ledger.mli | 4 +-- .../frontier_base/breadcrumb.ml | 4 +-- 12 files changed, 44 insertions(+), 40 deletions(-) diff --git a/src/lib/block_producer/block_producer.ml b/src/lib/block_producer/block_producer.ml index aea3fd790ab..593e062c1bc 100644 --- a/src/lib/block_producer/block_producer.ml +++ b/src/lib/block_producer/block_producer.ml @@ -166,7 +166,7 @@ let generate_next_state ~zkapp_cmd_limit ~constraint_constants ~previous_protocol_state ~time_controller ~staged_ledger ~transactions ~get_completed_work ~logger ~(block_data : Consensus.Data.Block_data.t) ~winner_pk ~scheduled_time ~log_block_creation ~block_reward_threshold - ~zkapps_per_block = + ~zkapps_per_block_hard_cap = let open Interruptible.Let_syntax in let previous_protocol_state_body_hash = Protocol_state.body previous_protocol_state |> Protocol_state.Body.hash @@ -244,7 +244,7 @@ let generate_next_state ~zkapp_cmd_limit ~constraint_constants ~global_slot diff ~logger ~current_state_view:previous_state_view ~state_and_body_hash: (previous_protocol_state_hash, previous_protocol_state_body_hash) - ~coinbase_receiver ~supercharge_coinbase ~zkapps_per_block + ~coinbase_receiver ~supercharge_coinbase ~zkapps_per_block_hard_cap with | Ok ( `Hash_after_applying next_staged_ledger_hash @@ -615,7 +615,7 @@ let run ~context:(module Context : CONTEXT) ~vrf_evaluator ~prover ~verifier ~time_controller ~consensus_local_state ~coinbase_receiver ~frontier_reader ~transition_writer ~set_next_producer_timing ~log_block_creation ~block_reward_threshold ~block_produced_bvar ~vrf_evaluation_state ~net - ~zkapps_per_block = + ~zkapps_per_block_hard_cap = let open Context in O1trace.sync_thread "produce_blocks" (fun () -> let genesis_breadcrumb = @@ -756,7 +756,7 @@ let run ~context:(module Context : CONTEXT) ~vrf_evaluator ~prover ~verifier ~staged_ledger:(Breadcrumb.staged_ledger crumb) ~transactions ~get_completed_work ~logger ~log_block_creation ~winner_pk:winner_pubkey ~block_reward_threshold - ~zkapp_cmd_limit:!zkapp_cmd_limit ~zkapps_per_block + ~zkapp_cmd_limit:!zkapp_cmd_limit ~zkapps_per_block_hard_cap in [%log internal] "Generate_next_state_done" ; match next_state_opt with diff --git a/src/lib/genesis_constants/genesis_constants.ml b/src/lib/genesis_constants/genesis_constants.ml index e2901404979..264fd6c20fe 100644 --- a/src/lib/genesis_constants/genesis_constants.ml +++ b/src/lib/genesis_constants/genesis_constants.ml @@ -335,7 +335,7 @@ module T = struct ; zkapp_transaction_cost_limit : float ; max_event_elements : int ; max_action_elements : int - ; zkapps_per_block : int + ; zkapps_per_block_hard_cap : int } [@@deriving to_yojson, sexp_of, bin_io_unversioned] @@ -393,7 +393,7 @@ let compiled : t = Mina_compile_config.zkapp_transaction_cost_limit ; max_event_elements = Mina_compile_config.max_event_elements ; max_action_elements = Mina_compile_config.max_action_elements - ; zkapps_per_block = Mina_compile_config.zkapps_per_block + ; zkapps_per_block_hard_cap = Mina_compile_config.zkapps_per_block_hard_cap } let for_unit_tests = compiled 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 4b8c6b508b7..d3d29d54cae 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 @@ -568,9 +568,9 @@ let make_genesis_constants ~logger ~(default : Genesis_constants.t) Option.value_map ~default:default.num_accounts (config.ledger >>= fun cfg -> cfg.num_accounts) ~f:(fun num_accounts -> Some num_accounts) - ; zkapps_per_block = - Option.value ~default:default.zkapps_per_block - (config.daemon >>= fun cfg -> cfg.zkapps_per_block) + ; zkapps_per_block_hard_cap = + Option.value ~default:default.zkapps_per_block_hard_cap + (config.daemon >>= fun cfg -> cfg.zkapps_per_block_hard_cap) } let runtime_config_of_genesis_constants (genesis_constants : Genesis_constants.t) @@ -611,8 +611,9 @@ let runtime_config_of_precomputed_values (precomputed_values : Genesis_proof.t) Some precomputed_values.genesis_constants.max_event_elements ; max_action_elements = Some precomputed_values.genesis_constants.max_action_elements - ; zkapps_per_block = - Some precomputed_values.genesis_constants.zkapps_per_block + ; zkapps_per_block_hard_cap = + Some + precomputed_values.genesis_constants.zkapps_per_block_hard_cap } ; genesis = Some diff --git a/src/lib/integration_test_cloud_engine/mina_automation.ml b/src/lib/integration_test_cloud_engine/mina_automation.ml index 9a412ae03ff..5aeabde5c5e 100644 --- a/src/lib/integration_test_cloud_engine/mina_automation.ml +++ b/src/lib/integration_test_cloud_engine/mina_automation.ml @@ -221,7 +221,7 @@ module Network_config = struct ; zkapp_transaction_cost_limit = None ; max_event_elements = None ; max_action_elements = None - ; zkapps_per_block = None + ; zkapps_per_block_hard_cap = None } ; genesis = Some diff --git a/src/lib/mina_base/test/valid_size.ml b/src/lib/mina_base/test/valid_size.ml index ee1ca24653a..d5295e00899 100644 --- a/src/lib/mina_base/test/valid_size.ml +++ b/src/lib/mina_base/test/valid_size.ml @@ -44,7 +44,7 @@ let genesis_constant_error limit events actions : Genesis_constants.t = ; zkapp_transaction_cost_limit = limit ; max_event_elements = events ; max_action_elements = actions - ; zkapps_per_block = 128 + ; zkapps_per_block_hard_cap = 128 } (* Note that in the following tests the generated zkapp_type will have an account_updates (i.e. a call_forest) diff --git a/src/lib/mina_block/validation.ml b/src/lib/mina_block/validation.ml index 9dd52bf4d77..b1a784429d5 100644 --- a/src/lib/mina_block/validation.ml +++ b/src/lib/mina_block/validation.ml @@ -503,8 +503,9 @@ let validate_staged_ledger_diff ?skip_staged_ledger_verification ~logger ~coinbase_receiver:(Consensus_state.coinbase_receiver consensus_state) ~supercharge_coinbase: (Consensus_state.supercharge_coinbase consensus_state) - ~zkapps_per_block: - precomputed_values.Precomputed_values.genesis_constants.zkapps_per_block + ~zkapps_per_block_hard_cap: + precomputed_values.Precomputed_values.genesis_constants + .zkapps_per_block_hard_cap |> Deferred.Result.map_error ~f:(fun e -> `Staged_ledger_application_failed e ) in diff --git a/src/lib/mina_compile_config/mina_compile_config.ml b/src/lib/mina_compile_config/mina_compile_config.ml index 230d8c73509..ef72fe052c6 100644 --- a/src/lib/mina_compile_config/mina_compile_config.ml +++ b/src/lib/mina_compile_config/mina_compile_config.ml @@ -81,4 +81,4 @@ let zkapp_cmd_limit = Some zkapp_cmd_limit [%%endif] -let zkapps_per_block = 128 +let zkapps_per_block_hard_cap = 128 diff --git a/src/lib/mina_lib/mina_lib.ml b/src/lib/mina_lib/mina_lib.ml index 2d47a69e424..e99151e32af 100644 --- a/src/lib/mina_lib/mina_lib.ml +++ b/src/lib/mina_lib/mina_lib.ml @@ -1381,8 +1381,8 @@ let start t = ~block_reward_threshold:t.config.block_reward_threshold ~block_produced_bvar:t.components.block_produced_bvar ~vrf_evaluation_state:t.vrf_evaluation_state ~net:t.components.net - ~zkapps_per_block: - t.config.precomputed_values.genesis_constants.zkapps_per_block ; + ~zkapps_per_block_hard_cap: + t.config.precomputed_values.genesis_constants.zkapps_per_block_hard_cap ; perform_compaction t ; let () = match t.config.node_status_url with diff --git a/src/lib/runtime_config/runtime_config.ml b/src/lib/runtime_config/runtime_config.ml index 98dfbfdf68d..032e6e908cb 100644 --- a/src/lib/runtime_config/runtime_config.ml +++ b/src/lib/runtime_config/runtime_config.ml @@ -411,7 +411,7 @@ module Json_layout = struct ; zkapp_transaction_cost_limit : float option [@default None] ; max_event_elements : int option [@default None] ; max_action_elements : int option [@default None] - ; zkapps_per_block : int option [@default None] + ; zkapps_per_block_hard_cap : int option [@default None] } [@@deriving yojson, fields, dhall_type] @@ -885,7 +885,7 @@ module Daemon = struct ; zkapp_transaction_cost_limit : float option [@default None] ; max_event_elements : int option [@default None] ; max_action_elements : int option [@default None] - ; zkapps_per_block : int option [@default None] + ; zkapps_per_block_hard_cap : int option [@default None] } [@@deriving bin_io_unversioned] @@ -919,8 +919,9 @@ module Daemon = struct opt_fallthrough ~default:t1.max_event_elements t2.max_event_elements ; max_action_elements = opt_fallthrough ~default:t1.max_action_elements t2.max_action_elements - ; zkapps_per_block = - opt_fallthrough ~default:t1.zkapps_per_block t2.zkapps_per_block + ; zkapps_per_block_hard_cap = + opt_fallthrough ~default:t1.zkapps_per_block_hard_cap + t2.zkapps_per_block_hard_cap } end diff --git a/src/lib/staged_ledger/staged_ledger.ml b/src/lib/staged_ledger/staged_ledger.ml index b936068b6aa..f7e185751dd 100644 --- a/src/lib/staged_ledger/staged_ledger.ml +++ b/src/lib/staged_ledger/staged_ledger.ml @@ -1012,7 +1012,7 @@ module T = struct let apply_diff ?(skip_verification = false) ~logger ~constraint_constants ~global_slot t pre_diff_info ~current_state_view ~state_and_body_hash - ~log_prefix ~zkapps_per_block = + ~log_prefix ~zkapps_per_block_hard_cap = let open Deferred.Result.Let_syntax in let max_throughput = Int.pow 2 t.constraint_constants.transaction_capacity_log_2 @@ -1050,10 +1050,10 @@ module T = struct |> List.filter ~f:(fun txn -> zkAppCountGetter txn) |> List.length in - if zkAppCount > zkapps_per_block then + if zkAppCount > zkapps_per_block_hard_cap then Deferred.Result.fail (Staged_ledger_error.ZkApps_exceed_limit - (zkAppCount, zkapps_per_block) ) + (zkAppCount, zkapps_per_block_hard_cap) ) else Deferred.Result.return () ) in [%log internal] "Update_coinbase_stack" @@ -1256,7 +1256,7 @@ module T = struct let apply ?skip_verification ~constraint_constants ~global_slot t ~get_completed_work (witness : Staged_ledger_diff.t) ~logger ~verifier ~current_state_view ~state_and_body_hash ~coinbase_receiver - ~supercharge_coinbase ~zkapps_per_block = + ~supercharge_coinbase ~zkapps_per_block_hard_cap = let open Deferred.Result.Let_syntax in let work = Staged_ledger_diff.completed_works witness in let%bind () = @@ -1289,7 +1289,7 @@ module T = struct ~constraint_constants ~global_slot t (forget_prediff_info prediff) ~logger ~current_state_view ~state_and_body_hash - ~log_prefix:"apply_diff" ~zkapps_per_block + ~log_prefix:"apply_diff" ~zkapps_per_block_hard_cap in [%log internal] "Diff_applied" ; [%log debug] @@ -1311,7 +1311,7 @@ module T = struct let apply_diff_unchecked ~constraint_constants ~global_slot t (sl_diff : Staged_ledger_diff.With_valid_signatures_and_proofs.t) ~logger ~current_state_view ~state_and_body_hash ~coinbase_receiver - ~supercharge_coinbase ~zkapps_per_block = + ~supercharge_coinbase ~zkapps_per_block_hard_cap = let open Deferred.Result.Let_syntax in let%bind prediff = Result.map_error ~f:(fun error -> Staged_ledger_error.Pre_diff error) @@ -1322,7 +1322,8 @@ module T = struct apply_diff t (forget_prediff_info prediff) ~constraint_constants ~global_slot ~logger ~current_state_view - ~state_and_body_hash ~log_prefix:"apply_diff_unchecked" ~zkapps_per_block + ~state_and_body_hash ~log_prefix:"apply_diff_unchecked" + ~zkapps_per_block_hard_cap module Resources = struct module Discarded = struct @@ -2376,7 +2377,7 @@ let%test_module "staged ledger tests" = let constraint_constants = Genesis_constants.Constraint_constants.for_unit_tests - let zkapps_per_block = 200 + let zkapps_per_block_hard_cap = 200 let logger = Logger.null () @@ -2430,7 +2431,7 @@ let%test_module "staged ledger tests" = Sl.apply ~constraint_constants ~global_slot !sl diff' ~logger ~verifier ~get_completed_work:(Fn.const None) ~current_state_view ~state_and_body_hash ~coinbase_receiver ~supercharge_coinbase - ~zkapps_per_block + ~zkapps_per_block_hard_cap with | Ok x -> x @@ -3368,7 +3369,7 @@ let%test_module "staged ledger tests" = ( state_hashes.state_hash , state_hashes.state_body_hash |> Option.value_exn ) ~coinbase_receiver ~supercharge_coinbase:true - ~zkapps_per_block + ~zkapps_per_block_hard_cap in let checked', diff' = match apply_res with @@ -4396,7 +4397,7 @@ let%test_module "staged ledger tests" = ~logger ~verifier ~get_completed_work:(Fn.const None) ~current_state_view ~state_and_body_hash ~coinbase_receiver ~supercharge_coinbase:false - ~zkapps_per_block + ~zkapps_per_block_hard_cap with | Ok _x -> assert false @@ -4609,7 +4610,7 @@ let%test_module "staged ledger tests" = (Staged_ledger_diff.forget diff) ~logger ~verifier ~get_completed_work:(Fn.const None) ~current_state_view ~state_and_body_hash ~coinbase_receiver - ~supercharge_coinbase:false ~zkapps_per_block + ~supercharge_coinbase:false ~zkapps_per_block_hard_cap with | Ok _x -> ( let valid_command_1_with_status = @@ -4656,7 +4657,7 @@ let%test_module "staged ledger tests" = ~logger ~verifier ~get_completed_work:(Fn.const None) ~current_state_view ~state_and_body_hash ~coinbase_receiver ~supercharge_coinbase:false - ~zkapps_per_block + ~zkapps_per_block_hard_cap with | Ok _x -> assert false @@ -4934,7 +4935,7 @@ let%test_module "staged ledger tests" = ~get_completed_work:(Fn.const None) ~logger ~verifier:verifier_full ~current_state_view ~state_and_body_hash ~coinbase_receiver - ~supercharge_coinbase:false ~zkapps_per_block + ~supercharge_coinbase:false ~zkapps_per_block_hard_cap with | Ok _ -> failwith "invalid block should be rejected" diff --git a/src/lib/staged_ledger/staged_ledger.mli b/src/lib/staged_ledger/staged_ledger.mli index 32b496ab477..9d24a2289bd 100644 --- a/src/lib/staged_ledger/staged_ledger.mli +++ b/src/lib/staged_ledger/staged_ledger.mli @@ -193,7 +193,7 @@ val apply : -> state_and_body_hash:State_hash.t * State_body_hash.t -> coinbase_receiver:Public_key.Compressed.t -> supercharge_coinbase:bool - -> zkapps_per_block:int + -> zkapps_per_block_hard_cap:int -> ( [ `Hash_after_applying of Staged_ledger_hash.t ] * [ `Ledger_proof of ( Ledger_proof.t @@ -218,7 +218,7 @@ val apply_diff_unchecked : -> state_and_body_hash:State_hash.t * State_body_hash.t -> coinbase_receiver:Public_key.Compressed.t -> supercharge_coinbase:bool - -> zkapps_per_block:int + -> zkapps_per_block_hard_cap:int -> ( [ `Hash_after_applying of Staged_ledger_hash.t ] * [ `Ledger_proof of ( Ledger_proof.t diff --git a/src/lib/transition_frontier/frontier_base/breadcrumb.ml b/src/lib/transition_frontier/frontier_base/breadcrumb.ml index 04d5837f37a..d2e67751db7 100644 --- a/src/lib/transition_frontier/frontier_base/breadcrumb.ml +++ b/src/lib/transition_frontier/frontier_base/breadcrumb.ml @@ -403,8 +403,8 @@ module For_tests = struct ~coinbase_receiver ~logger staged_ledger_diff ~constraint_constants:precomputed_values.constraint_constants ~current_state_view ~state_and_body_hash ~supercharge_coinbase - ~zkapps_per_block: - precomputed_values.genesis_constants.zkapps_per_block + ~zkapps_per_block_hard_cap: + precomputed_values.genesis_constants.zkapps_per_block_hard_cap with | Ok r -> return r From 0ad88608b65cc38207d73a98bbc3d410ff356302 Mon Sep 17 00:00:00 2001 From: ejMina226 <118474890+ejMina226@users.noreply.github.com> Date: Mon, 22 Jan 2024 18:08:33 +0000 Subject: [PATCH 15/17] Code review changes --- src/lib/block_producer/block_producer.ml | 8 ++-- .../genesis_constants/genesis_constants.ml | 4 +- .../lib/genesis_ledger_helper_lib.ml | 11 +++-- .../mina_automation.ml | 2 +- src/lib/mina_base/test/valid_size.ml | 2 +- src/lib/mina_block/validation.ml | 4 +- .../mina_compile_config.ml | 2 +- src/lib/mina_lib/mina_lib.ml | 4 +- src/lib/runtime_config/runtime_config.ml | 10 ++--- src/lib/staged_ledger/staged_ledger.ml | 40 +++++++++---------- src/lib/staged_ledger/staged_ledger.mli | 4 +- .../frontier_base/breadcrumb.ml | 4 +- 12 files changed, 45 insertions(+), 50 deletions(-) diff --git a/src/lib/block_producer/block_producer.ml b/src/lib/block_producer/block_producer.ml index 593e062c1bc..b16f9dbdcbb 100644 --- a/src/lib/block_producer/block_producer.ml +++ b/src/lib/block_producer/block_producer.ml @@ -166,7 +166,7 @@ let generate_next_state ~zkapp_cmd_limit ~constraint_constants ~previous_protocol_state ~time_controller ~staged_ledger ~transactions ~get_completed_work ~logger ~(block_data : Consensus.Data.Block_data.t) ~winner_pk ~scheduled_time ~log_block_creation ~block_reward_threshold - ~zkapps_per_block_hard_cap = + ~zkapp_cmd_limit_hardcap = let open Interruptible.Let_syntax in let previous_protocol_state_body_hash = Protocol_state.body previous_protocol_state |> Protocol_state.Body.hash @@ -244,7 +244,7 @@ let generate_next_state ~zkapp_cmd_limit ~constraint_constants ~global_slot diff ~logger ~current_state_view:previous_state_view ~state_and_body_hash: (previous_protocol_state_hash, previous_protocol_state_body_hash) - ~coinbase_receiver ~supercharge_coinbase ~zkapps_per_block_hard_cap + ~coinbase_receiver ~supercharge_coinbase ~zkapp_cmd_limit_hardcap with | Ok ( `Hash_after_applying next_staged_ledger_hash @@ -615,7 +615,7 @@ let run ~context:(module Context : CONTEXT) ~vrf_evaluator ~prover ~verifier ~time_controller ~consensus_local_state ~coinbase_receiver ~frontier_reader ~transition_writer ~set_next_producer_timing ~log_block_creation ~block_reward_threshold ~block_produced_bvar ~vrf_evaluation_state ~net - ~zkapps_per_block_hard_cap = + ~zkapp_cmd_limit_hardcap = let open Context in O1trace.sync_thread "produce_blocks" (fun () -> let genesis_breadcrumb = @@ -756,7 +756,7 @@ let run ~context:(module Context : CONTEXT) ~vrf_evaluator ~prover ~verifier ~staged_ledger:(Breadcrumb.staged_ledger crumb) ~transactions ~get_completed_work ~logger ~log_block_creation ~winner_pk:winner_pubkey ~block_reward_threshold - ~zkapp_cmd_limit:!zkapp_cmd_limit ~zkapps_per_block_hard_cap + ~zkapp_cmd_limit:!zkapp_cmd_limit ~zkapp_cmd_limit_hardcap in [%log internal] "Generate_next_state_done" ; match next_state_opt with diff --git a/src/lib/genesis_constants/genesis_constants.ml b/src/lib/genesis_constants/genesis_constants.ml index 264fd6c20fe..bf4bde53760 100644 --- a/src/lib/genesis_constants/genesis_constants.ml +++ b/src/lib/genesis_constants/genesis_constants.ml @@ -335,7 +335,7 @@ module T = struct ; zkapp_transaction_cost_limit : float ; max_event_elements : int ; max_action_elements : int - ; zkapps_per_block_hard_cap : int + ; zkapp_cmd_limit_hardcap : int } [@@deriving to_yojson, sexp_of, bin_io_unversioned] @@ -393,7 +393,7 @@ let compiled : t = Mina_compile_config.zkapp_transaction_cost_limit ; max_event_elements = Mina_compile_config.max_event_elements ; max_action_elements = Mina_compile_config.max_action_elements - ; zkapps_per_block_hard_cap = Mina_compile_config.zkapps_per_block_hard_cap + ; zkapp_cmd_limit_hardcap = Mina_compile_config.zkapp_cmd_limit_hardcap } let for_unit_tests = compiled 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 d3d29d54cae..2d33d3c7ea6 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 @@ -568,9 +568,9 @@ let make_genesis_constants ~logger ~(default : Genesis_constants.t) Option.value_map ~default:default.num_accounts (config.ledger >>= fun cfg -> cfg.num_accounts) ~f:(fun num_accounts -> Some num_accounts) - ; zkapps_per_block_hard_cap = - Option.value ~default:default.zkapps_per_block_hard_cap - (config.daemon >>= fun cfg -> cfg.zkapps_per_block_hard_cap) + ; zkapp_cmd_limit_hardcap = + Option.value ~default:default.zkapp_cmd_limit_hardcap + (config.daemon >>= fun cfg -> cfg.zkapp_cmd_limit_hardcap) } let runtime_config_of_genesis_constants (genesis_constants : Genesis_constants.t) @@ -611,9 +611,8 @@ let runtime_config_of_precomputed_values (precomputed_values : Genesis_proof.t) Some precomputed_values.genesis_constants.max_event_elements ; max_action_elements = Some precomputed_values.genesis_constants.max_action_elements - ; zkapps_per_block_hard_cap = - Some - precomputed_values.genesis_constants.zkapps_per_block_hard_cap + ; zkapp_cmd_limit_hardcap = + Some precomputed_values.genesis_constants.zkapp_cmd_limit_hardcap } ; genesis = Some diff --git a/src/lib/integration_test_cloud_engine/mina_automation.ml b/src/lib/integration_test_cloud_engine/mina_automation.ml index 5aeabde5c5e..d979feb1739 100644 --- a/src/lib/integration_test_cloud_engine/mina_automation.ml +++ b/src/lib/integration_test_cloud_engine/mina_automation.ml @@ -221,7 +221,7 @@ module Network_config = struct ; zkapp_transaction_cost_limit = None ; max_event_elements = None ; max_action_elements = None - ; zkapps_per_block_hard_cap = None + ; zkapp_cmd_limit_hardcap = None } ; genesis = Some diff --git a/src/lib/mina_base/test/valid_size.ml b/src/lib/mina_base/test/valid_size.ml index d5295e00899..4d2ac508b41 100644 --- a/src/lib/mina_base/test/valid_size.ml +++ b/src/lib/mina_base/test/valid_size.ml @@ -44,7 +44,7 @@ let genesis_constant_error limit events actions : Genesis_constants.t = ; zkapp_transaction_cost_limit = limit ; max_event_elements = events ; max_action_elements = actions - ; zkapps_per_block_hard_cap = 128 + ; zkapp_cmd_limit_hardcap = 128 } (* Note that in the following tests the generated zkapp_type will have an account_updates (i.e. a call_forest) diff --git a/src/lib/mina_block/validation.ml b/src/lib/mina_block/validation.ml index b1a784429d5..74c3e1e3e6a 100644 --- a/src/lib/mina_block/validation.ml +++ b/src/lib/mina_block/validation.ml @@ -503,9 +503,9 @@ let validate_staged_ledger_diff ?skip_staged_ledger_verification ~logger ~coinbase_receiver:(Consensus_state.coinbase_receiver consensus_state) ~supercharge_coinbase: (Consensus_state.supercharge_coinbase consensus_state) - ~zkapps_per_block_hard_cap: + ~zkapp_cmd_limit_hardcap: precomputed_values.Precomputed_values.genesis_constants - .zkapps_per_block_hard_cap + .zkapp_cmd_limit_hardcap |> Deferred.Result.map_error ~f:(fun e -> `Staged_ledger_application_failed e ) in diff --git a/src/lib/mina_compile_config/mina_compile_config.ml b/src/lib/mina_compile_config/mina_compile_config.ml index ef72fe052c6..9151ff9718d 100644 --- a/src/lib/mina_compile_config/mina_compile_config.ml +++ b/src/lib/mina_compile_config/mina_compile_config.ml @@ -81,4 +81,4 @@ let zkapp_cmd_limit = Some zkapp_cmd_limit [%%endif] -let zkapps_per_block_hard_cap = 128 +let zkapp_cmd_limit_hardcap = 128 diff --git a/src/lib/mina_lib/mina_lib.ml b/src/lib/mina_lib/mina_lib.ml index e99151e32af..1f5cf552629 100644 --- a/src/lib/mina_lib/mina_lib.ml +++ b/src/lib/mina_lib/mina_lib.ml @@ -1381,8 +1381,8 @@ let start t = ~block_reward_threshold:t.config.block_reward_threshold ~block_produced_bvar:t.components.block_produced_bvar ~vrf_evaluation_state:t.vrf_evaluation_state ~net:t.components.net - ~zkapps_per_block_hard_cap: - t.config.precomputed_values.genesis_constants.zkapps_per_block_hard_cap ; + ~zkapp_cmd_limit_hardcap: + t.config.precomputed_values.genesis_constants.zkapp_cmd_limit_hardcap ; perform_compaction t ; let () = match t.config.node_status_url with diff --git a/src/lib/runtime_config/runtime_config.ml b/src/lib/runtime_config/runtime_config.ml index 032e6e908cb..1d7197c5930 100644 --- a/src/lib/runtime_config/runtime_config.ml +++ b/src/lib/runtime_config/runtime_config.ml @@ -411,7 +411,7 @@ module Json_layout = struct ; zkapp_transaction_cost_limit : float option [@default None] ; max_event_elements : int option [@default None] ; max_action_elements : int option [@default None] - ; zkapps_per_block_hard_cap : int option [@default None] + ; zkapp_cmd_limit_hardcap : int option [@default None] } [@@deriving yojson, fields, dhall_type] @@ -885,7 +885,7 @@ module Daemon = struct ; zkapp_transaction_cost_limit : float option [@default None] ; max_event_elements : int option [@default None] ; max_action_elements : int option [@default None] - ; zkapps_per_block_hard_cap : int option [@default None] + ; zkapp_cmd_limit_hardcap : int option [@default None] } [@@deriving bin_io_unversioned] @@ -919,9 +919,9 @@ module Daemon = struct opt_fallthrough ~default:t1.max_event_elements t2.max_event_elements ; max_action_elements = opt_fallthrough ~default:t1.max_action_elements t2.max_action_elements - ; zkapps_per_block_hard_cap = - opt_fallthrough ~default:t1.zkapps_per_block_hard_cap - t2.zkapps_per_block_hard_cap + ; zkapp_cmd_limit_hardcap = + opt_fallthrough ~default:t1.zkapp_cmd_limit_hardcap + t2.zkapp_cmd_limit_hardcap } end diff --git a/src/lib/staged_ledger/staged_ledger.ml b/src/lib/staged_ledger/staged_ledger.ml index f7e185751dd..5b2e4261784 100644 --- a/src/lib/staged_ledger/staged_ledger.ml +++ b/src/lib/staged_ledger/staged_ledger.ml @@ -1012,7 +1012,7 @@ module T = struct let apply_diff ?(skip_verification = false) ~logger ~constraint_constants ~global_slot t pre_diff_info ~current_state_view ~state_and_body_hash - ~log_prefix ~zkapps_per_block_hard_cap = + ~log_prefix ~zkapp_cmd_limit_hardcap = let open Deferred.Result.Let_syntax in let max_throughput = Int.pow 2 t.constraint_constants.transaction_capacity_log_2 @@ -1034,9 +1034,9 @@ module T = struct in Ledger.unsafe_preload_accounts_from_parent new_ledger accounts_accessed ; let%bind () = - O1trace.thread "Check number of zkApps in a block does not exceed hardcap" - (fun () -> - let zkAppCountGetter : Transaction.t With_status.t -> bool = function + (* Check number of zkApps in a block does not exceed hardcap *) + O1trace.thread "zkapp_hardcap_check" (fun () -> + let is_zkapp : Transaction.t With_status.t -> bool = function | { With_status.data = Transaction.Command (Mina_base.User_command.Zkapp_command _) ; status = _ @@ -1045,15 +1045,11 @@ module T = struct | _ -> false in - let zkAppCount = - transactions - |> List.filter ~f:(fun txn -> zkAppCountGetter txn) - |> List.length - in - if zkAppCount > zkapps_per_block_hard_cap then + let zk_app_count = List.count ~f:is_zkapp transactions in + if zk_app_count > zkapp_cmd_limit_hardcap then Deferred.Result.fail (Staged_ledger_error.ZkApps_exceed_limit - (zkAppCount, zkapps_per_block_hard_cap) ) + (zk_app_count, zkapp_cmd_limit_hardcap) ) else Deferred.Result.return () ) in [%log internal] "Update_coinbase_stack" @@ -1256,7 +1252,7 @@ module T = struct let apply ?skip_verification ~constraint_constants ~global_slot t ~get_completed_work (witness : Staged_ledger_diff.t) ~logger ~verifier ~current_state_view ~state_and_body_hash ~coinbase_receiver - ~supercharge_coinbase ~zkapps_per_block_hard_cap = + ~supercharge_coinbase ~zkapp_cmd_limit_hardcap = let open Deferred.Result.Let_syntax in let work = Staged_ledger_diff.completed_works witness in let%bind () = @@ -1289,7 +1285,7 @@ module T = struct ~constraint_constants ~global_slot t (forget_prediff_info prediff) ~logger ~current_state_view ~state_and_body_hash - ~log_prefix:"apply_diff" ~zkapps_per_block_hard_cap + ~log_prefix:"apply_diff" ~zkapp_cmd_limit_hardcap in [%log internal] "Diff_applied" ; [%log debug] @@ -1311,7 +1307,7 @@ module T = struct let apply_diff_unchecked ~constraint_constants ~global_slot t (sl_diff : Staged_ledger_diff.With_valid_signatures_and_proofs.t) ~logger ~current_state_view ~state_and_body_hash ~coinbase_receiver - ~supercharge_coinbase ~zkapps_per_block_hard_cap = + ~supercharge_coinbase ~zkapp_cmd_limit_hardcap = let open Deferred.Result.Let_syntax in let%bind prediff = Result.map_error ~f:(fun error -> Staged_ledger_error.Pre_diff error) @@ -1323,7 +1319,7 @@ module T = struct (forget_prediff_info prediff) ~constraint_constants ~global_slot ~logger ~current_state_view ~state_and_body_hash ~log_prefix:"apply_diff_unchecked" - ~zkapps_per_block_hard_cap + ~zkapp_cmd_limit_hardcap module Resources = struct module Discarded = struct @@ -2377,7 +2373,7 @@ let%test_module "staged ledger tests" = let constraint_constants = Genesis_constants.Constraint_constants.for_unit_tests - let zkapps_per_block_hard_cap = 200 + let zkapp_cmd_limit_hardcap = 200 let logger = Logger.null () @@ -2431,7 +2427,7 @@ let%test_module "staged ledger tests" = Sl.apply ~constraint_constants ~global_slot !sl diff' ~logger ~verifier ~get_completed_work:(Fn.const None) ~current_state_view ~state_and_body_hash ~coinbase_receiver ~supercharge_coinbase - ~zkapps_per_block_hard_cap + ~zkapp_cmd_limit_hardcap with | Ok x -> x @@ -3369,7 +3365,7 @@ let%test_module "staged ledger tests" = ( state_hashes.state_hash , state_hashes.state_body_hash |> Option.value_exn ) ~coinbase_receiver ~supercharge_coinbase:true - ~zkapps_per_block_hard_cap + ~zkapp_cmd_limit_hardcap in let checked', diff' = match apply_res with @@ -4397,7 +4393,7 @@ let%test_module "staged ledger tests" = ~logger ~verifier ~get_completed_work:(Fn.const None) ~current_state_view ~state_and_body_hash ~coinbase_receiver ~supercharge_coinbase:false - ~zkapps_per_block_hard_cap + ~zkapp_cmd_limit_hardcap with | Ok _x -> assert false @@ -4610,7 +4606,7 @@ let%test_module "staged ledger tests" = (Staged_ledger_diff.forget diff) ~logger ~verifier ~get_completed_work:(Fn.const None) ~current_state_view ~state_and_body_hash ~coinbase_receiver - ~supercharge_coinbase:false ~zkapps_per_block_hard_cap + ~supercharge_coinbase:false ~zkapp_cmd_limit_hardcap with | Ok _x -> ( let valid_command_1_with_status = @@ -4657,7 +4653,7 @@ let%test_module "staged ledger tests" = ~logger ~verifier ~get_completed_work:(Fn.const None) ~current_state_view ~state_and_body_hash ~coinbase_receiver ~supercharge_coinbase:false - ~zkapps_per_block_hard_cap + ~zkapp_cmd_limit_hardcap with | Ok _x -> assert false @@ -4935,7 +4931,7 @@ let%test_module "staged ledger tests" = ~get_completed_work:(Fn.const None) ~logger ~verifier:verifier_full ~current_state_view ~state_and_body_hash ~coinbase_receiver - ~supercharge_coinbase:false ~zkapps_per_block_hard_cap + ~supercharge_coinbase:false ~zkapp_cmd_limit_hardcap with | Ok _ -> failwith "invalid block should be rejected" diff --git a/src/lib/staged_ledger/staged_ledger.mli b/src/lib/staged_ledger/staged_ledger.mli index 9d24a2289bd..147bceca8d3 100644 --- a/src/lib/staged_ledger/staged_ledger.mli +++ b/src/lib/staged_ledger/staged_ledger.mli @@ -193,7 +193,7 @@ val apply : -> state_and_body_hash:State_hash.t * State_body_hash.t -> coinbase_receiver:Public_key.Compressed.t -> supercharge_coinbase:bool - -> zkapps_per_block_hard_cap:int + -> zkapp_cmd_limit_hardcap:int -> ( [ `Hash_after_applying of Staged_ledger_hash.t ] * [ `Ledger_proof of ( Ledger_proof.t @@ -218,7 +218,7 @@ val apply_diff_unchecked : -> state_and_body_hash:State_hash.t * State_body_hash.t -> coinbase_receiver:Public_key.Compressed.t -> supercharge_coinbase:bool - -> zkapps_per_block_hard_cap:int + -> zkapp_cmd_limit_hardcap:int -> ( [ `Hash_after_applying of Staged_ledger_hash.t ] * [ `Ledger_proof of ( Ledger_proof.t diff --git a/src/lib/transition_frontier/frontier_base/breadcrumb.ml b/src/lib/transition_frontier/frontier_base/breadcrumb.ml index d2e67751db7..25ec3aacf0b 100644 --- a/src/lib/transition_frontier/frontier_base/breadcrumb.ml +++ b/src/lib/transition_frontier/frontier_base/breadcrumb.ml @@ -403,8 +403,8 @@ module For_tests = struct ~coinbase_receiver ~logger staged_ledger_diff ~constraint_constants:precomputed_values.constraint_constants ~current_state_view ~state_and_body_hash ~supercharge_coinbase - ~zkapps_per_block_hard_cap: - precomputed_values.genesis_constants.zkapps_per_block_hard_cap + ~zkapp_cmd_limit_hardcap: + precomputed_values.genesis_constants.zkapp_cmd_limit_hardcap with | Ok r -> return r From 2dca09d60b35907b52dd8f2e401cc77ac1529c0e Mon Sep 17 00:00:00 2001 From: ejMina226 <118474890+ejMina226@users.noreply.github.com> Date: Mon, 22 Jan 2024 19:22:49 +0000 Subject: [PATCH 16/17] Build error --- src/lib/runtime_config/runtime_config.ml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/lib/runtime_config/runtime_config.ml b/src/lib/runtime_config/runtime_config.ml index ce85e6a8514..39adfaf7140 100644 --- a/src/lib/runtime_config/runtime_config.ml +++ b/src/lib/runtime_config/runtime_config.ml @@ -1148,6 +1148,7 @@ module Daemon = struct let%bind zkapp_signed_pair_update_cost = Float.gen_incl 0.0 100.0 in let%bind zkapp_transaction_cost_limit = Float.gen_incl 0.0 100.0 in let%bind max_event_elements = Int.gen_incl 0 100 in + let%bind zkapp_cmd_limit_hardcap = Int.gen_incl 0 1000 in let%map max_action_elements = Int.gen_incl 0 1000 in { txpool_max_size = Some txpool_max_size ; peer_list_url = None @@ -1157,6 +1158,7 @@ module Daemon = struct ; zkapp_transaction_cost_limit = Some zkapp_transaction_cost_limit ; max_event_elements = Some max_event_elements ; max_action_elements = Some max_action_elements + ; zkapp_cmd_limit_hardcap = Some zkapp_cmd_limit_hardcap } end From 0a85ae542dfa964e0aad192b9405236fef8a30ad Mon Sep 17 00:00:00 2001 From: ejMina226 <118474890+ejMina226@users.noreply.github.com> Date: Wed, 24 Jan 2024 18:03:03 +0000 Subject: [PATCH 17/17] Fix broken test --- src/lib/staged_ledger/staged_ledger.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/staged_ledger/staged_ledger.ml b/src/lib/staged_ledger/staged_ledger.ml index ae46064afe1..494abd4366f 100644 --- a/src/lib/staged_ledger/staged_ledger.ml +++ b/src/lib/staged_ledger/staged_ledger.ml @@ -4750,7 +4750,7 @@ let%test_module "staged ledger tests" = apply ~logger ~constraint_constants ~global_slot ~get_completed_work:(Fn.const None) ~verifier ~current_state_view ~state_and_body_hash ~coinbase_receiver - ~supercharge_coinbase:false sl diff + ~supercharge_coinbase:false sl diff ~zkapp_cmd_limit_hardcap in match (expectation, result) with | `Accept, Ok _ | `Reject, Error _ ->