From b8f5e977fdeb04c2b1fdc88203fb6086327b070a Mon Sep 17 00:00:00 2001 From: martyall Date: Wed, 25 Sep 2024 00:14:45 -0700 Subject: [PATCH] reapply test configuration changes to constants value --- .../block_production_priority.ml | 14 +- src/app/test_executive/epoch_ledger.ml | 2 +- src/app/test_executive/hard_fork.ml | 20 +-- src/app/test_executive/payments_test.ml | 15 +- .../test_executive/peers_reliability_test.ml | 5 +- src/app/test_executive/slot_end_test.ml | 18 +-- src/app/test_executive/test_executive.ml | 3 + .../test_executive/verification_key_update.ml | 3 +- src/app/test_executive/zkapps.ml | 17 +- src/app/test_executive/zkapps_nonce_test.ml | 15 +- src/app/test_executive/zkapps_timing.ml | 3 +- .../genesis_constants/genesis_constants.ml | 8 + .../kubernetes_network.ml | 6 - .../mina_automation.ml | 109 ++++++------- src/lib/integration_test_lib/intf.ml | 6 - src/lib/integration_test_lib/test_config.ml | 149 +++++++++++------- .../docker_network.ml | 6 - .../mina_docker.ml | 83 ++++++---- 18 files changed, 247 insertions(+), 235 deletions(-) diff --git a/src/app/test_executive/block_production_priority.ml b/src/app/test_executive/block_production_priority.ml index 4af15868188..c7179ab9f65 100644 --- a/src/app/test_executive/block_production_priority.ml +++ b/src/app/test_executive/block_production_priority.ml @@ -50,12 +50,8 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct } ; txpool_max_size = 10_000_000 ; snark_worker_fee = "0.0001" - ; proof_config = - { proof_config_default with - work_delay = Some 1 - ; transaction_capacity = - Some Runtime_config.Proof_keys.Transaction_capacity.small - } + ; work_delay = 1 + ; transaction_capacity_log_2 = 2 } let fee = Currency.Fee.of_nanomina_int_exn 10_000_000 @@ -71,6 +67,8 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct let run network t = let open Malleable_error.Let_syntax in let logger = Logger.create () in + let constants = Network.constants network in + let constraint_constants = constants.constraint_constants in let receiver = Core.String.Map.find_exn (Network.block_producers network) "receiver" in @@ -107,9 +105,7 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct let pk = s.keypair.public_key |> Signature_lib.Public_key.compress in return ([%log info] "sender: %s" (pk_to_string pk)) ) in - let window_ms = - (Network.constraint_constants network).block_window_duration_ms - in + let window_ms = constraint_constants.block_window_duration_ms in let all_mina_nodes = Network.all_mina_nodes network in let%bind () = wait_for t diff --git a/src/app/test_executive/epoch_ledger.ml b/src/app/test_executive/epoch_ledger.ml index 2abe6f5cf19..9108d08905c 100644 --- a/src/app/test_executive/epoch_ledger.ml +++ b/src/app/test_executive/epoch_ledger.ml @@ -57,7 +57,7 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct [ { node_name = "node-a"; account_name = "node-a-key" } ; { node_name = "node-b"; account_name = "node-b-key" } ] - ; proof_config = { proof_config_default with fork = Some fork_config } + ; fork = Some fork_config } let run network t = diff --git a/src/app/test_executive/hard_fork.ml b/src/app/test_executive/hard_fork.ml index 672bfce34cc..8282c70eed4 100644 --- a/src/app/test_executive/hard_fork.ml +++ b/src/app/test_executive/hard_fork.ml @@ -201,19 +201,17 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct } ; snark_worker_fee = "0.0002" ; num_archive_nodes = 1 - ; proof_config = - { proof_config_default with - work_delay = Some 1 - ; transaction_capacity = - Some Runtime_config.Proof_keys.Transaction_capacity.small - ; fork = Some fork_config - } + ; work_delay = 1 + ; transaction_capacity_log_2 = 2 + ; fork = Some fork_config } let run network t = let open Malleable_error.Let_syntax in let logger = Logger.create () in let all_mina_nodes = Network.all_mina_nodes network in + let constants = Network.constants network in + let constraint_constants = constants.constraint_constants in let%bind () = wait_for t (Wait_condition.nodes_to_initialize @@ -301,7 +299,6 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct let zkapp_keypairs = List.init 3 ~f:(fun _ -> Signature_lib.Keypair.create ()) in - let constraint_constants = Network.constraint_constants network in let amount = Currency.Amount.of_mina_int_exn 10 in let nonce = Account.Nonce.zero in let memo = @@ -362,7 +359,6 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct ; sender = (fish1.keypair, Account.Nonce.(succ one)) } in - let constraint_constants = Network.constraint_constants network in let%bind vk_proof = Malleable_error.lift @@ Transaction_snark.For_tests.update_states ~constraint_constants @@ -480,12 +476,6 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct send_payments ~logger ~sender_pub_key ~receiver_pub_key ~amount:Currency.Amount.one ~fee ~node:sender 10 in - let constants : Test_config.constants = - { genesis_constants = Network.genesis_constants network - ; constraint_constants = Network.constraint_constants network - ; compile_config = Network.compile_config network - } - in wait_for t (Wait_condition.ledger_proofs_emitted_since_genesis ~test_config:(config ~constants) ~num_proofs:1 ) ) diff --git a/src/app/test_executive/payments_test.ml b/src/app/test_executive/payments_test.ml index ec00c49bebb..8090874fbc3 100644 --- a/src/app/test_executive/payments_test.ml +++ b/src/app/test_executive/payments_test.ml @@ -52,17 +52,14 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct } ; snark_worker_fee = "0.0002" ; num_archive_nodes = 1 - ; proof_config = - { proof_config_default with - work_delay = Some 1 - ; transaction_capacity = - Some Runtime_config.Proof_keys.Transaction_capacity.small - } + ; work_delay = 1 + ; transaction_capacity_log_2 = 2 } let run network t = let open Malleable_error.Let_syntax in let logger = Logger.create () in + let constants = Network.constants network in let all_mina_nodes = Network.all_mina_nodes network in let%bind () = wait_for t @@ -378,12 +375,6 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct Malleable_error.soft_error_format ~value:() "Payment failed for unexpected reason: %s" err_str ) ) in - let constants : Test_config.constants = - { genesis_constants = Network.genesis_constants network - ; constraint_constants = Network.constraint_constants network - ; compile_config = Network.compile_config network - } - in let config = config ~constants in let%bind () = section_hard diff --git a/src/app/test_executive/peers_reliability_test.ml b/src/app/test_executive/peers_reliability_test.ml index 2c9f305f0cb..e2ae3d6eb4d 100644 --- a/src/app/test_executive/peers_reliability_test.ml +++ b/src/app/test_executive/peers_reliability_test.ml @@ -37,6 +37,8 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct let open Network in let open Malleable_error.Let_syntax in let logger = Logger.create () in + let constants = Network.constants network in + let constraint_constants = constants.constraint_constants in let all_mina_nodes = Network.all_mina_nodes network in [%log info] "peers_list" ~metadata: @@ -139,8 +141,7 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct } in Malleable_error.lift - @@ Transaction_snark.For_tests.deploy_snapp - ~constraint_constants:(Network.constraint_constants network) + @@ Transaction_snark.For_tests.deploy_snapp ~constraint_constants parties_spec in let%bind () = diff --git a/src/app/test_executive/slot_end_test.ml b/src/app/test_executive/slot_end_test.ml index 5cdf8d49486..1014798ee3b 100644 --- a/src/app/test_executive/slot_end_test.ml +++ b/src/app/test_executive/slot_end_test.ml @@ -54,12 +54,8 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct ; txpool_max_size = 10_000_000 ; snark_worker_fee = "0.0002" ; num_archive_nodes = 0 - ; proof_config = - { proof_config_default with - work_delay = Some 1 - ; transaction_capacity = - Some Runtime_config.Proof_keys.Transaction_capacity.small - } + ; work_delay = 1 + ; transaction_capacity_log_2 = 2 ; slot_tx_end = Some slot_tx_end ; slot_chain_end = Some slot_chain_end } @@ -73,6 +69,9 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct let run network t = let open Malleable_error.Let_syntax in let logger = Logger.create () in + let { Test_config.genesis_constants; constraint_constants; _ } = + Network.constants network + in let num_slots = slot_chain_end + 2 in let receiver = String.Map.find_exn (Network.block_producers network) "receiver" @@ -98,9 +97,7 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct let pk = s.keypair.public_key |> Signature_lib.Public_key.compress in return ([%log info] "sender: %s" (pk_to_string pk)) ) in - let window_ms = - (Network.constraint_constants network).block_window_duration_ms - in + let window_ms = constraint_constants.block_window_duration_ms in let all_nodes = Network.all_mina_nodes network in let%bind () = wait_for t @@ -108,8 +105,7 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct in let genesis_timestamp = Block_time.to_time_exn - @@ Block_time.of_int64 - (Network.genesis_constants network).protocol.genesis_state_timestamp + @@ Block_time.of_int64 genesis_constants.protocol.genesis_state_timestamp in let end_t = Time.add genesis_timestamp diff --git a/src/app/test_executive/test_executive.ml b/src/app/test_executive/test_executive.ml index e5474e3b4ab..e7563fbd62c 100644 --- a/src/app/test_executive/test_executive.ml +++ b/src/app/test_executive/test_executive.ml @@ -284,6 +284,7 @@ let main inputs = } ; constraint_constants = Genesis_constants.Compiled.constraint_constants ; compile_config = Mina_compile_config.Compiled.t + ; proof_level = Genesis_constants.Compiled.proof_level } in let images = @@ -296,6 +297,8 @@ let main inputs = } in let test_config = T.config ~constants in + (* This value for constants is what gets stored in the network, it's important to apply any configuration patching here as well for coherence *) + let constants = Test_config.apply_config ~test_config ~constants in let%bind () = validate_inputs ~logger inputs test_config in [%log trace] "expanding network config" ; let network_config = diff --git a/src/app/test_executive/verification_key_update.ml b/src/app/test_executive/verification_key_update.ml index ddcfbc8c697..9d42effa619 100644 --- a/src/app/test_executive/verification_key_update.ml +++ b/src/app/test_executive/verification_key_update.ml @@ -98,6 +98,8 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct let logger = Logger.create () let run network t = + let constants = Network.constants network in + let constraint_constants = constants.constraint_constants in let open Malleable_error.Let_syntax in let%bind () = section_hard "Wait for nodes to initialize" @@ -110,7 +112,6 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct in let%bind whale1_pk = pub_key_of_node whale1 in let%bind whale1_sk = priv_key_of_node whale1 in - let constraint_constants = Network.constraint_constants network in let (whale1_kp : Keypair.t) = { public_key = whale1_pk |> Public_key.decompress_exn ; private_key = whale1_sk diff --git a/src/app/test_executive/zkapps.ml b/src/app/test_executive/zkapps.ml index 4ef2a658dd0..b4d0805338b 100644 --- a/src/app/test_executive/zkapps.ml +++ b/src/app/test_executive/zkapps.ml @@ -40,12 +40,8 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct ; worker_nodes = 2 } ; snark_worker_fee = "0.0001" - ; proof_config = - { proof_config_default with - work_delay = Some 1 - ; transaction_capacity = - Some Runtime_config.Proof_keys.Transaction_capacity.small - } + ; work_delay = 1 + ; transaction_capacity_log_2 = 2 } let transactions_sent = ref 0 @@ -123,12 +119,8 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct let run network t = let open Malleable_error.Let_syntax in let logger = Logger.create () in - let constants : Test_config.constants = - { genesis_constants = Network.genesis_constants network - ; constraint_constants = Network.constraint_constants network - ; compile_config = Network.compile_config network - } - in + let constants = Network.constants network in + let constraint_constants = constants.constraint_constants in let block_producer_nodes = Network.block_producers network |> Core.String.Map.data in @@ -142,7 +134,6 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct let node = Core.String.Map.find_exn (Network.block_producers network) "node-a" in - let constraint_constants = Network.constraint_constants network in let fish1_kp = (Core.String.Map.find_exn (Network.genesis_keypairs network) "fish1") .keypair diff --git a/src/app/test_executive/zkapps_nonce_test.ml b/src/app/test_executive/zkapps_nonce_test.ml index 1398a182685..82f94a28615 100644 --- a/src/app/test_executive/zkapps_nonce_test.ml +++ b/src/app/test_executive/zkapps_nonce_test.ml @@ -40,12 +40,8 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct ; worker_nodes = 5 } ; snark_worker_fee = "0.0001" - ; proof_config = - { proof_config_default with - work_delay = Some 1 - ; transaction_capacity = - Some Runtime_config.Proof_keys.Transaction_capacity.medium - } + ; work_delay = 1 + ; transaction_capacity_log_2 = 3 } let transactions_sent = ref 0 @@ -89,12 +85,7 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct let run network t = let open Malleable_error.Let_syntax in - let constants : Test_config.constants = - { genesis_constants = Network.genesis_constants network - ; constraint_constants = Network.constraint_constants network - ; compile_config = Network.compile_config network - } - in + let constants = Network.constants network in let logger = Logger.create () in let block_producer_nodes = Network.block_producers network |> Core.String.Map.data diff --git a/src/app/test_executive/zkapps_timing.ml b/src/app/test_executive/zkapps_timing.ml index 6f657ef8b23..2f4916dc6dd 100644 --- a/src/app/test_executive/zkapps_timing.ml +++ b/src/app/test_executive/zkapps_timing.ml @@ -36,6 +36,8 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct let run network t = let open Malleable_error.Let_syntax in let logger = Logger.create () in + let constants = Network.constants network in + let constraint_constants = constants.constraint_constants in let all_mina_nodes = Network.all_mina_nodes network in let%bind () = wait_for t @@ -46,7 +48,6 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct Network.block_producers network |> Core.String.Map.data in let node = List.hd_exn block_producer_nodes in - let constraint_constants = Network.constraint_constants network in let block_window_duration_ms = constraint_constants.block_window_duration_ms in diff --git a/src/lib/genesis_constants/genesis_constants.ml b/src/lib/genesis_constants/genesis_constants.ml index 1f96fda1902..33749ea531c 100644 --- a/src/lib/genesis_constants/genesis_constants.ml +++ b/src/lib/genesis_constants/genesis_constants.ml @@ -20,6 +20,14 @@ module Proof_level = struct No_check | s -> failwithf "unrecognised proof level %s" s () + + let to_yojson t = `String (to_string t) + + let of_yojson = function + | `String s -> + Ok (of_string s) + | _ -> + Error "expected string" end module Fork_constants = struct diff --git a/src/lib/integration_test_cloud_engine/kubernetes_network.ml b/src/lib/integration_test_cloud_engine/kubernetes_network.ml index 47773a049ff..39f77322092 100644 --- a/src/lib/integration_test_cloud_engine/kubernetes_network.ml +++ b/src/lib/integration_test_cloud_engine/kubernetes_network.ml @@ -346,12 +346,6 @@ type t = let constants { constants; _ } = constants -let constraint_constants { constants; _ } = constants.constraint_constants - -let genesis_constants { constants; _ } = constants.genesis_constants - -let compile_config { constants; _ } = constants.compile_config - let seeds { seeds; _ } = seeds let block_producers { block_producers; _ } = block_producers diff --git a/src/lib/integration_test_cloud_engine/mina_automation.ml b/src/lib/integration_test_cloud_engine/mina_automation.ml index 5a5491d4ac2..e9cab18d712 100644 --- a/src/lib/integration_test_cloud_engine/mina_automation.ml +++ b/src/lib/integration_test_cloud_engine/mina_automation.ml @@ -108,7 +108,7 @@ module Network_config = struct in assoc - let expand ~logger ~test_name ~(cli_inputs : Cli_inputs.t) ~(debug : bool) + let expand ~logger:_ ~test_name ~(cli_inputs : Cli_inputs.t) ~(debug : bool) ~(images : Test_config.Container_images.t) ~test_config ~(constants : Test_config.constants) = let ({ requires_graphql @@ -120,7 +120,7 @@ module Network_config = struct ; num_archive_nodes ; log_precomputed_blocks (* ; num_plain_nodes *) ; start_filtered_logs - ; proof_config + ; work_delay ; k ; delta ; slots_per_epoch @@ -130,7 +130,9 @@ module Network_config = struct ; slot_tx_end ; slot_chain_end ; network_id - ; _ + ; block_window_duration_ms + ; transaction_capacity_log_2 + ; fork } : Test_config.t ) = test_config @@ -219,10 +221,6 @@ module Network_config = struct let genesis_accounts_and_keys = List.zip_exn genesis_ledger keypairs in let genesis_ledger_accounts = add_accounts genesis_accounts_and_keys in (* DAEMON CONFIG *) - let constraint_constants = - Genesis_ledger_helper.make_constraint_constants - ~default:constants.constraint_constants proof_config - in let ledger_is_prefix ledger1 ledger2 = List.is_prefix ledger2 ~prefix:ledger1 ~equal:(fun @@ -233,19 +231,30 @@ module Network_config = struct let runtime_config = { Runtime_config.daemon = Some - { txpool_max_size = Some txpool_max_size - ; peer_list_url = None - ; zkapp_proof_update_cost = None - ; zkapp_signed_single_update_cost = None - ; zkapp_signed_pair_update_cost = None - ; zkapp_transaction_cost_limit = None - ; max_event_elements = None - ; max_action_elements = None - ; zkapp_cmd_limit_hardcap = None + { network_id = + Some + (Option.value ~default:constants.compile_config.network_id + network_id ) ; slot_tx_end ; slot_chain_end - ; minimum_user_command_fee = None - ; network_id + ; txpool_max_size = Some txpool_max_size + ; zkapp_proof_update_cost = + Some constants.compile_config.zkapp_proof_update_cost + ; zkapp_signed_single_update_cost = + Some constants.compile_config.zkapp_signed_single_update_cost + ; zkapp_signed_pair_update_cost = + Some constants.compile_config.zkapp_signed_pair_update_cost + ; zkapp_transaction_cost_limit = + Some constants.compile_config.zkapp_transaction_cost_limit + ; max_action_elements = + Some constants.compile_config.max_action_elements + ; max_event_elements = + Some constants.compile_config.max_event_elements + ; zkapp_cmd_limit_hardcap = + Some constants.compile_config.zkapp_cmd_limit_hardcap + ; minimum_user_command_fee = + Some constants.compile_config.minimum_user_command_fee + ; peer_list_url = None } ; genesis = Some @@ -257,7 +266,34 @@ module Network_config = struct ; genesis_state_timestamp = Some Core.Time.(to_string_abs ~zone:Zone.utc (now ())) } - ; proof = Some proof_config (* TODO: prebake ledger and only set hash *) + ; proof = + Some + { level = + Some + ( match constants.proof_level with + | Full -> + Full + | Check -> + Check + | No_check -> + No_check ) + ; sub_windows_per_window = + Some constants.constraint_constants.sub_windows_per_window + ; ledger_depth = Some constants.constraint_constants.ledger_depth + ; work_delay = Some work_delay + ; block_window_duration_ms = Some block_window_duration_ms + ; transaction_capacity = + Some + (Runtime_config.Proof_keys.Transaction_capacity.Log_2 + transaction_capacity_log_2 ) + ; coinbase_amount = + Some constants.constraint_constants.coinbase_amount + ; supercharged_coinbase_factor = + Some constants.constraint_constants.supercharged_coinbase_factor + ; account_creation_fee = + Some constants.constraint_constants.account_creation_fee + ; fork + } ; ledger = Some { base = @@ -375,14 +411,6 @@ module Network_config = struct ({ staking; next } : Runtime_config.Epoch_data.t) ) } in - let genesis_constants = - Or_error.ok_exn - (Genesis_ledger_helper.make_genesis_constants ~logger - ~default:constants.genesis_constants runtime_config ) - in - let constants : Test_config.constants = - { constants with genesis_constants; constraint_constants } - in (* BLOCK PRODUCER CONFIG *) let mk_net_keypair keypair_name (pk, sk) = let keypair = @@ -679,33 +707,6 @@ module Network_manager = struct | None -> (Core.String.Map.of_alist_exn [], Core.String.Map.of_alist_exn []) in - (* - let snark_coordinator_id = - String.lowercase - (String.sub network_config.terraform.snark_worker_public_key - ~pos: - (String.length network_config.terraform.snark_worker_public_key - 6) - ~len:6 ) - in - let snark_coordinator_workloads = - if network_config.terraform.snark_worker_replicas > 0 then - [ Kubernetes_network.Workload_to_deploy.construct_workload - ("snark-coordinator-" ^ snark_coordinator_id) - [ Kubernetes_network.Workload_to_deploy.cons_pod_info "mina" ] - ] - else [] - in - let snark_worker_workloads = - if network_config.terraform.snark_worker_replicas > 0 then - [ Kubernetes_network.Workload_to_deploy.construct_workload - ("snark-worker-" ^ snark_coordinator_id) - (List.init network_config.terraform.snark_worker_replicas - ~f:(fun _i -> - Kubernetes_network.Workload_to_deploy.cons_pod_info "worker" ) - ) - ] - else [] - in *) let block_producer_workloads = List.map network_config.terraform.block_producer_configs ~f:(fun bp_config -> diff --git a/src/lib/integration_test_lib/intf.ml b/src/lib/integration_test_lib/intf.ml index 0fa9687f858..8815d32316b 100644 --- a/src/lib/integration_test_lib/intf.ml +++ b/src/lib/integration_test_lib/intf.ml @@ -84,12 +84,6 @@ module Engine = struct val constants : t -> Test_config.constants - val constraint_constants : t -> Genesis_constants.Constraint_constants.t - - val genesis_constants : t -> Genesis_constants.t - - val compile_config : t -> Mina_compile_config.t - val seeds : t -> Node.t Core.String.Map.t val all_non_seed_nodes : t -> Node.t Core.String.Map.t diff --git a/src/lib/integration_test_lib/test_config.ml b/src/lib/integration_test_lib/test_config.ml index fa06f656fc3..77f42b4c150 100644 --- a/src/lib/integration_test_lib/test_config.ml +++ b/src/lib/integration_test_lib/test_config.ml @@ -18,6 +18,7 @@ module Test_account = struct ; permissions : Mina_base.Permissions.t option ; zkapp : Mina_base.Zkapp_account.t option } + [@@deriving to_yojson] let create ~account_name ~balance ?timing ?permissions ?zkapp () = { account_name @@ -37,13 +38,14 @@ module Epoch_data = struct module Data = struct (* the seed is a field value in Base58Check format *) type t = { epoch_ledger : Test_account.t list; epoch_seed : string } + [@@deriving to_yojson] end - type t = { staking : Data.t; next : Data.t option } + type t = { staking : Data.t; next : Data.t option } [@@deriving to_yojson] end module Block_producer_node = struct - type t = { node_name : string; account_name : string } + type t = { node_name : string; account_name : string } [@@deriving to_yojson] end module Snark_coordinator_node = struct @@ -55,6 +57,7 @@ type constants = { constraint_constants : Genesis_constants.Constraint_constants.t ; genesis_constants : Genesis_constants.t ; compile_config : Mina_compile_config.t + ; proof_level : Genesis_constants.Proof_level.t } [@@deriving to_yojson] @@ -70,34 +73,21 @@ type t = ; num_archive_nodes : int ; log_precomputed_blocks : bool ; start_filtered_logs : string list - (* ; num_plain_nodes : int *) - (* blockchain constants *) - ; proof_config : Runtime_config.Proof_keys.t ; k : int ; delta : int ; slots_per_epoch : int ; slots_per_sub_window : int ; grace_period_slots : int ; txpool_max_size : int + ; work_delay : int ; slot_tx_end : int option ; slot_chain_end : int option ; network_id : string option ; block_window_duration_ms : int ; transaction_capacity_log_2 : int + ; fork : Runtime_config.Fork_config.t option } - -let proof_config_default : Runtime_config.Proof_keys.t = - { level = Some Full - ; sub_windows_per_window = None - ; ledger_depth = None - ; work_delay = None - ; block_window_duration_ms = Some 120000 - ; transaction_capacity = None - ; coinbase_amount = None - ; supercharged_coinbase_factor = None - ; account_creation_fee = None - ; fork = None - } +[@@deriving to_yojson] let log_filter_of_event_type ev_existential = let open Event_type in @@ -110,10 +100,11 @@ let log_filter_of_event_type ev_existential = [ Structured_log_events.string_of_id struct_id ] | From_puppeteer_log _ -> [] -(* TODO: Do we need this? *) -let default ~(constants : constants) = - let { constraint_constants; genesis_constants; _ } = constants in +let default ~constants = + let { constraint_constants; genesis_constants; compile_config; _ } = + constants + in { requires_graphql = true (* require_graphql maybe should just be phased out, because it always needs to be enable. Now with the graphql polling engine, everything will definitely fail if graphql is not enabled. But even before that, most tests relied on some sort of graphql interaction *) @@ -126,7 +117,6 @@ let default ~(constants : constants) = ; log_precomputed_blocks = false (* ; num_plain_nodes = 0 *) ; start_filtered_logs = List.bind ~f:log_filter_of_event_type Event_type.all_event_types - ; proof_config = proof_config_default ; k = genesis_constants.protocol.k ; slots_per_epoch = genesis_constants.protocol.slots_per_epoch ; slots_per_sub_window = genesis_constants.protocol.slots_per_sub_window @@ -135,49 +125,90 @@ let default ~(constants : constants) = ; txpool_max_size = genesis_constants.txpool_max_size ; slot_tx_end = None ; slot_chain_end = None - ; network_id = None + ; network_id = Some compile_config.network_id ; block_window_duration_ms = constraint_constants.block_window_duration_ms ; transaction_capacity_log_2 = constraint_constants.transaction_capacity_log_2 + ; work_delay = constraint_constants.work_delay + ; fork = + Option.map constraint_constants.fork ~f:(fun fork_constants -> + { Runtime_config.Fork_config.state_hash = + Pickles.Backend.Tick.Field.to_string fork_constants.state_hash + ; blockchain_length = + Mina_numbers.Length.to_int fork_constants.blockchain_length + ; global_slot_since_genesis = + Mina_numbers.Global_slot_since_genesis.to_int + fork_constants.global_slot_since_genesis + } ) } -let transaction_capacity_log_2 (config : t) = - match config.proof_config.transaction_capacity with - | None -> - config.transaction_capacity_log_2 - | Some (Log_2 i) -> - i - | Some (Txns_per_second_x10 tps_goal_x10) -> - let max_coinbases = 2 in - let block_window_duration_ms = - Option.value ~default:config.block_window_duration_ms - config.proof_config.block_window_duration_ms - in - let max_user_commands_per_block = - (* block_window_duration is in milliseconds, so divide by 1000 divide - by 10 again because we have tps * 10 - *) - tps_goal_x10 * block_window_duration_ms / (1000 * 10) - in - (* Log of the capacity of transactions per transition. - - 1 will only work if we don't have prover fees. - - 2 will work with prover fees, but not if we want a transaction - included in every block. - - At least 3 ensures a transaction per block and the staged-ledger - unit tests pass. - *) - 1 + Core_kernel.Int.ceil_log2 (max_user_commands_per_block + max_coinbases) - -let transaction_capacity config = - let i = transaction_capacity_log_2 config in - Int.pow 2 i +let apply_config ~test_config ~constants : constants = + let { requires_graphql = _ + ; genesis_ledger = _ + ; epoch_data = _ + ; block_producers = _ + ; snark_coordinator = _ + ; snark_worker_fee = _ + ; num_archive_nodes = _ + ; log_precomputed_blocks = _ + ; start_filtered_logs = _ + ; k + ; delta + ; slots_per_epoch + ; slots_per_sub_window + ; grace_period_slots + ; txpool_max_size + ; work_delay + ; slot_tx_end = _ + ; slot_chain_end = _ + ; network_id + ; block_window_duration_ms + ; transaction_capacity_log_2 + ; fork + } = + test_config + in + { constants with + genesis_constants = + { constants.genesis_constants with + protocol = + { constants.genesis_constants.protocol with + k + ; slots_per_epoch + ; slots_per_sub_window + ; grace_period_slots + ; delta + } + ; txpool_max_size + } + ; constraint_constants = + { constants.constraint_constants with + work_delay + ; transaction_capacity_log_2 + ; block_window_duration_ms + ; fork = + Option.map fork ~f:(fun fork_constants -> + { Genesis_constants.Fork_constants.state_hash = + Pickles.Backend.Tick.Field.of_string fork_constants.state_hash + ; blockchain_length = + Mina_numbers.Length.of_int fork_constants.blockchain_length + ; global_slot_since_genesis = + Mina_numbers.Global_slot_since_genesis.of_int + fork_constants.global_slot_since_genesis + } ) + } + ; compile_config = + { constants.compile_config with + network_id = + Option.value network_id ~default:constants.compile_config.network_id + ; block_window_duration = + Time.Span.of_ms @@ Float.of_int block_window_duration_ms + } + } + +let transaction_capacity config = Int.pow 2 config.transaction_capacity_log_2 let blocks_for_first_ledger_proof (config : t) = - let work_delay = - Option.value ~default:config.block_window_duration_ms - config.proof_config.work_delay - in - let transaction_capacity_log_2 = transaction_capacity_log_2 config in - ((work_delay + 1) * (transaction_capacity_log_2 + 1)) + 1 + ((config.work_delay + 1) * (config.transaction_capacity_log_2 + 1)) + 1 let slots_for_blocks blocks = (*Given 0.75 slots are filled*) diff --git a/src/lib/integration_test_local_engine/docker_network.ml b/src/lib/integration_test_local_engine/docker_network.ml index e12e4be354f..11eb213446d 100644 --- a/src/lib/integration_test_local_engine/docker_network.ml +++ b/src/lib/integration_test_local_engine/docker_network.ml @@ -281,12 +281,6 @@ type t = let constants { constants; _ } = constants -let constraint_constants { constants; _ } = constants.constraint_constants - -let genesis_constants { constants; _ } = constants.genesis_constants - -let compile_config { constants; _ } = constants.compile_config - let seeds { seeds; _ } = seeds let block_producers { block_producers; _ } = block_producers diff --git a/src/lib/integration_test_local_engine/mina_docker.ml b/src/lib/integration_test_local_engine/mina_docker.ml index 9a92fe18304..41d3bc1e314 100644 --- a/src/lib/integration_test_local_engine/mina_docker.ml +++ b/src/lib/integration_test_local_engine/mina_docker.ml @@ -46,7 +46,7 @@ module Network_config = struct } [@@deriving to_yojson] - let expand ~logger ~test_name ~(cli_inputs : Cli_inputs.t) ~(debug : bool) + let expand ~logger:_ ~test_name ~(cli_inputs : Cli_inputs.t) ~(debug : bool) ~(images : Test_config.Container_images.t) ~(test_config : Test_config.t) ~(constants : Test_config.constants) = let _ = cli_inputs in @@ -58,7 +58,6 @@ module Network_config = struct ; num_archive_nodes ; log_precomputed_blocks (* ; num_plain_nodes *) ; start_filtered_logs - ; proof_config ; k ; delta ; slots_per_epoch @@ -68,7 +67,11 @@ module Network_config = struct ; slot_tx_end ; slot_chain_end ; network_id - ; _ + ; requires_graphql = _ + ; work_delay + ; transaction_capacity_log_2 + ; block_window_duration_ms + ; fork } : Test_config.t ) = test_config @@ -142,10 +145,6 @@ module Network_config = struct in let genesis_accounts_and_keys = List.zip_exn genesis_ledger keypairs in let genesis_ledger_accounts = add_accounts genesis_accounts_and_keys in - let constraint_constants = - Genesis_ledger_helper.make_constraint_constants - ~default:constants.constraint_constants proof_config - in let ledger_is_prefix ledger1 ledger2 = List.is_prefix ledger2 ~prefix:ledger1 ~equal:(fun @@ -156,19 +155,30 @@ module Network_config = struct let runtime_config = { Runtime_config.daemon = Some - { txpool_max_size = Some txpool_max_size - ; peer_list_url = None - ; zkapp_proof_update_cost = None - ; zkapp_signed_single_update_cost = None - ; zkapp_signed_pair_update_cost = None - ; zkapp_transaction_cost_limit = None - ; max_event_elements = None - ; max_action_elements = None - ; zkapp_cmd_limit_hardcap = None + { network_id = + Some + (Option.value ~default:constants.compile_config.network_id + network_id ) ; slot_tx_end ; slot_chain_end - ; minimum_user_command_fee = None - ; network_id + ; txpool_max_size = Some txpool_max_size + ; zkapp_proof_update_cost = + Some constants.compile_config.zkapp_proof_update_cost + ; zkapp_signed_single_update_cost = + Some constants.compile_config.zkapp_signed_single_update_cost + ; zkapp_signed_pair_update_cost = + Some constants.compile_config.zkapp_signed_pair_update_cost + ; zkapp_transaction_cost_limit = + Some constants.compile_config.zkapp_transaction_cost_limit + ; max_action_elements = + Some constants.compile_config.max_action_elements + ; max_event_elements = + Some constants.compile_config.max_event_elements + ; zkapp_cmd_limit_hardcap = + Some constants.compile_config.zkapp_cmd_limit_hardcap + ; minimum_user_command_fee = + Some constants.compile_config.minimum_user_command_fee + ; peer_list_url = None } ; genesis = Some @@ -180,7 +190,34 @@ module Network_config = struct ; genesis_state_timestamp = Some Core.Time.(to_string_abs ~zone:Zone.utc (now ())) } - ; proof = Some proof_config (* TODO: prebake ledger and only set hash *) + ; proof = + Some + { level = + Some + ( match constants.proof_level with + | Full -> + Full + | Check -> + Check + | No_check -> + No_check ) + ; sub_windows_per_window = + Some constants.constraint_constants.sub_windows_per_window + ; ledger_depth = Some constants.constraint_constants.ledger_depth + ; work_delay = Some work_delay + ; block_window_duration_ms = Some block_window_duration_ms + ; transaction_capacity = + Some + (Runtime_config.Proof_keys.Transaction_capacity.Log_2 + transaction_capacity_log_2 ) + ; coinbase_amount = + Some constants.constraint_constants.coinbase_amount + ; supercharged_coinbase_factor = + Some constants.constraint_constants.supercharged_coinbase_factor + ; account_creation_fee = + Some constants.constraint_constants.account_creation_fee + ; fork + } ; ledger = Some { base = @@ -278,14 +315,6 @@ module Network_config = struct ({ staking; next } : Runtime_config.Epoch_data.t) ) } in - let genesis_constants = - Or_error.ok_exn - (Genesis_ledger_helper.make_genesis_constants ~logger - ~default:constants.genesis_constants runtime_config ) - in - let constants : Test_config.constants = - { constants with genesis_constants; constraint_constants } - in let mk_net_keypair keypair_name (pk, sk) = let keypair = { Keypair.public_key = Public_key.decompress_exn pk; private_key = sk }