From 865ea1f017012ce2d6698d76331cb814e1321772 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Thir=C3=A9?= Date: Wed, 17 Jul 2024 14:23:10 +0200 Subject: [PATCH 1/6] Tezt/Cloud/DAL: add a network --- tezt/tests/cloud/dal.ml | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/tezt/tests/cloud/dal.ml b/tezt/tests/cloud/dal.ml index 807a0c2a6b04..b0a526e2cd54 100644 --- a/tezt/tests/cloud/dal.ml +++ b/tezt/tests/cloud/dal.ml @@ -73,6 +73,12 @@ module Disconnect = struct Lwt.return {t with disconnected_bakers = bakers_to_keep_disconnected} end +module Network = struct + type t = Ghostnet | Sandbox + + let to_string = function Ghostnet -> "ghostnet" | Sandbox -> "sandbox" +end + module Cli = struct let section = Clap.section @@ -80,6 +86,23 @@ module Cli = struct "All the options related to running DAL scenarions onto the cloud" "Cloud DAL" + let network_typ = + Clap.typ + ~name:"network" + ~dummy:Network.Ghostnet + ~parse:(function + | "ghostnet" -> Some Ghostnet | "sandbox" -> Some Sandbox | _ -> None) + ~show:Network.to_string + + let network = + Clap.default + ~section + ~long:"network" + ~placeholder:" (sandbox,ghostnet,...)" + ~description:"Allow to specify a network to use for the scenario" + network_typ + Sandbox + let stake = let stake_typ = let parse string = @@ -100,7 +123,7 @@ module Cli = struct shares old by one baker. The total stake is given by the sum of all \ shares." stake_typ - [100] + (match network with Sandbox -> [100] | Ghostnet -> []) let stake_machine_type = let stake_machine_type_typ = @@ -229,6 +252,7 @@ type configuration = { (* The first argument is the deconnection frequency, the second is the reconnection delay *) disconnect : (int * int) option; + network : Network.t; } type bootstrap = {node : Node.t; dal_node : Dal_node.t; client : Client.t} @@ -1285,7 +1309,9 @@ let init ~(configuration : configuration) cloud next_agent = baker_accounts, producer_accounts, etherlink_rollup_operator_key ) = - init_bootstrap cloud configuration bootstrap_agent + match configuration.network with + | Network.Sandbox -> init_bootstrap cloud configuration bootstrap_agent + | Ghostnet -> assert false in let* bakers = Lwt_list.mapi_p @@ -1487,6 +1513,7 @@ let configuration = let etherlink_sequencer = Cli.etherlink_sequencer in let etherlink_producers = Cli.etherlink_producers in let disconnect = Cli.disconnect in + let network = Cli.network in { stake; stake_machine_type; @@ -1498,6 +1525,7 @@ let configuration = etherlink_sequencer; etherlink_producers; disconnect; + network; } let benchmark () = -- GitLab From 44c72e3c3ddfa976cd280b7b31f8bc1d928f74c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Thir=C3=A9?= Date: Wed, 17 Jul 2024 14:30:30 +0200 Subject: [PATCH 2/6] Tezt/Cloud/DAL: Add a bootstrap option --- tezt/tests/cloud/dal.ml | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/tezt/tests/cloud/dal.ml b/tezt/tests/cloud/dal.ml index b0a526e2cd54..026b96726cfb 100644 --- a/tezt/tests/cloud/dal.ml +++ b/tezt/tests/cloud/dal.ml @@ -103,6 +103,12 @@ module Cli = struct network_typ Sandbox + let bootstrap = + Clap.flag + ~section + ~set_long:"bootstrap" + (match network with Sandbox -> true | Ghostnet -> false) + let stake = let stake_typ = let parse string = @@ -253,6 +259,7 @@ type configuration = { reconnection delay *) disconnect : (int * int) option; network : Network.t; + bootstrap : bool; } type bootstrap = {node : Node.t; dal_node : Dal_node.t; client : Client.t} @@ -797,7 +804,8 @@ let add_etherlink_source cloud agent ~job_name node sc_rollup_node evm_node = ~job_name [node_metric_target; sc_rollup_metric_target; evm_node_metric_target] -let init_bootstrap cloud (configuration : configuration) agent = +let init_bootstrap_and_activate_protocol cloud (configuration : configuration) + agent = let* bootstrap_node = Node.Agent.create ~name:"bootstrap-node" agent in let* dal_bootstrap_node = Dal_node.Agent.create ~name:"bootstrap-dal-node" agent ~node:bootstrap_node @@ -1310,7 +1318,8 @@ let init ~(configuration : configuration) cloud next_agent = producer_accounts, etherlink_rollup_operator_key ) = match configuration.network with - | Network.Sandbox -> init_bootstrap cloud configuration bootstrap_agent + | Network.Sandbox -> + init_bootstrap_and_activate_protocol cloud configuration bootstrap_agent | Ghostnet -> assert false in let* bakers = @@ -1514,6 +1523,7 @@ let configuration = let etherlink_producers = Cli.etherlink_producers in let disconnect = Cli.disconnect in let network = Cli.network in + let bootstrap = Cli.bootstrap in { stake; stake_machine_type; @@ -1526,12 +1536,13 @@ let configuration = etherlink_producers; disconnect; network; + bootstrap; } let benchmark () = let vms = [ - [`Bootstrap]; + (if configuration.bootstrap then [`Bootstrap] else []); List.map (fun i -> `Baker i) configuration.stake; List.init configuration.dal_node_producer (fun _ -> `Producer); List.map (fun _ -> `Observer) configuration.observer_slot_indices; -- GitLab From 4618ba3a89e1313bffc7fd3465aae2b480482a6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Thir=C3=A9?= Date: Wed, 17 Jul 2024 15:23:03 +0200 Subject: [PATCH 3/6] Tezt/Cloud/DAL: Remove unecessary keys --- tezt/tests/cloud/dal.ml | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/tezt/tests/cloud/dal.ml b/tezt/tests/cloud/dal.ml index 026b96726cfb..9e1216f73966 100644 --- a/tezt/tests/cloud/dal.ml +++ b/tezt/tests/cloud/dal.ml @@ -844,12 +844,6 @@ let init_bootstrap_and_activate_protocol cloud (configuration : configuration) let* etherlink_rollup_operator_key = Client.stresstest_gen_keys ~alias_prefix:"etherlink_operator" 1 client in - let* etherlink_rollup_producers_key = - Client.stresstest_gen_keys - ~alias_prefix:"etherlink_producer" - Cli.etherlink_producers - client - in let* parameter_file = let base = Either.right (configuration.protocol, Some Protocol.Constants_mainnet) @@ -863,8 +857,7 @@ let init_bootstrap_and_activate_protocol cloud (configuration : configuration) let additional_bootstrap_accounts = List.map (fun key -> (key, Some 1_000_000_000_000, false)) - (producer_accounts @ etherlink_rollup_operator_key - @ etherlink_rollup_producers_key) + (producer_accounts @ etherlink_rollup_operator_key) in Protocol.write_parameter_file ~bootstrap_accounts -- GitLab From 4a2840ab58ac96996e898e9c1374a38d459cdb61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Thir=C3=A9?= Date: Wed, 17 Jul 2024 15:28:11 +0200 Subject: [PATCH 4/6] Tezt/Cloud/DAL: Generate etherlink key when needed --- tezt/tests/cloud/dal.ml | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/tezt/tests/cloud/dal.ml b/tezt/tests/cloud/dal.ml index 9e1216f73966..64f3fad7c813 100644 --- a/tezt/tests/cloud/dal.ml +++ b/tezt/tests/cloud/dal.ml @@ -842,7 +842,9 @@ let init_bootstrap_and_activate_protocol cloud (configuration : configuration) client in let* etherlink_rollup_operator_key = - Client.stresstest_gen_keys ~alias_prefix:"etherlink_operator" 1 client + if configuration.etherlink then + Client.stresstest_gen_keys ~alias_prefix:"etherlink_operator" 1 client + else Lwt.return [] in let* parameter_file = let base = @@ -865,6 +867,9 @@ let init_bootstrap_and_activate_protocol cloud (configuration : configuration) ~base [] in + let etherlink_rollup_operator_key = + match etherlink_rollup_operator_key with [key] -> Some key | _ -> None + in let* () = Client.activate_protocol_and_wait ~timestamp:Client.Now @@ -891,10 +896,7 @@ let init_bootstrap_and_activate_protocol cloud (configuration : configuration) {node = bootstrap_node; dal_node = dal_bootstrap_node; client} in Lwt.return - ( bootstrap, - baker_accounts, - producer_accounts, - List.hd etherlink_rollup_operator_key ) + (bootstrap, baker_accounts, producer_accounts, etherlink_rollup_operator_key) let init_baker cloud (configuration : configuration) ~bootstrap_node ~dal_bootstrap_node account i agent = @@ -1356,6 +1358,9 @@ let init ~(configuration : configuration) cloud next_agent = in let* etherlink = if Cli.etherlink then + let etherlink_rollup_operator_key = + Option.get etherlink_rollup_operator_key + in let* etherlink = init_etherlink cloud -- GitLab From 204066a906a170462e44ac24f7c8fa1a740bbfcb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Thir=C3=A9?= Date: Wed, 17 Jul 2024 16:14:37 +0200 Subject: [PATCH 5/6] Tezt/Cloud/DAL: Bootstrap nodes are optional --- tezt/tests/cloud/dal.ml | 119 ++++++++++++++++++++-------------------- 1 file changed, 61 insertions(+), 58 deletions(-) diff --git a/tezt/tests/cloud/dal.ml b/tezt/tests/cloud/dal.ml index 64f3fad7c813..b6ebadc8f8d0 100644 --- a/tezt/tests/cloud/dal.ml +++ b/tezt/tests/cloud/dal.ml @@ -262,7 +262,14 @@ type configuration = { bootstrap : bool; } -type bootstrap = {node : Node.t; dal_node : Dal_node.t; client : Client.t} +type bootstrap = { + node : Node.t option; + dal_node : Dal_node.t option; + node_p2p_endpoint : string; + node_rpc_endpoint : Endpoint.t; + dal_node_p2p_endpoint : string; + client : Client.t; +} type baker = { node : Node.t; @@ -892,20 +899,34 @@ let init_bootstrap_and_activate_protocol cloud (configuration : configuration) bootstrap_node dal_bootstrap_node in + let node_rpc_endpoint = + Endpoint. + { + scheme = "http"; + host = Agent.point agent |> fst; + port = Node.rpc_port bootstrap_node; + } + in let (bootstrap : bootstrap) = - {node = bootstrap_node; dal_node = dal_bootstrap_node; client} + { + node = Some bootstrap_node; + dal_node = Some dal_bootstrap_node; + node_p2p_endpoint = Node.point_str bootstrap_node; + node_rpc_endpoint; + dal_node_p2p_endpoint = Dal_node.point_str dal_bootstrap_node; + client; + } in Lwt.return (bootstrap, baker_accounts, producer_accounts, etherlink_rollup_operator_key) -let init_baker cloud (configuration : configuration) ~bootstrap_node - ~dal_bootstrap_node account i agent = +let init_baker cloud (configuration : configuration) ~bootstrap account i agent + = let stake = List.nth configuration.stake i in let* node = Node.Agent.init ~name:(Format.asprintf "baker-node-%d" i) - ~arguments: - [Peer (Node.point_str bootstrap_node); Synchronisation_threshold 0] + ~arguments:[Peer bootstrap.node_p2p_endpoint; Synchronisation_threshold 0] agent in let* dal_node = @@ -919,7 +940,7 @@ let init_baker cloud (configuration : configuration) ~bootstrap_node Dal_node.init_config ~expected_pow:0. ~attester_profiles:[account.Account.public_key_hash] - ~peers:[Dal_node.point_str dal_bootstrap_node] (* no need for peer *) + ~peers:[bootstrap.dal_node_p2p_endpoint] (* no need for peer *) dal_node in let* () = Dal_node.run ~event_level:`Notice dal_node in @@ -952,13 +973,11 @@ let init_baker cloud (configuration : configuration) ~bootstrap_node in Lwt.return {node; dal_node; baker; account; stake} -let init_producer cloud ~bootstrap_node ~dal_bootstrap_node ~number_of_slots - account i agent = +let init_producer cloud ~bootstrap ~number_of_slots account i agent = let* node = Node.Agent.init ~name:(Format.asprintf "producer-node-%i" i) - ~arguments: - [Peer (Node.point_str bootstrap_node); Synchronisation_threshold 0] + ~arguments:[Peer bootstrap.node_p2p_endpoint; Synchronisation_threshold 0] agent in let* client = Client.Agent.create ~node agent in @@ -982,7 +1001,7 @@ let init_producer cloud ~bootstrap_node ~dal_bootstrap_node ~number_of_slots Dal_node.init_config ~expected_pow:0. ~producer_profiles:[i mod number_of_slots] - ~peers:[Dal_node.point_str dal_bootstrap_node] + ~peers:[bootstrap.dal_node_p2p_endpoint] dal_node in let* () = @@ -998,13 +1017,11 @@ let init_producer cloud ~bootstrap_node ~dal_bootstrap_node ~number_of_slots let is_ready = Dal_node.run ~event_level:`Notice dal_node in Lwt.return {client; node; dal_node; account; is_ready} -let init_observer cloud ~bootstrap_node ~dal_bootstrap_node ~slot_index i agent - = +let init_observer cloud ~bootstrap ~slot_index i agent = let* node = Node.Agent.init ~name:(Format.asprintf "observer-node-%i" i) - ~arguments: - [Peer (Node.point_str bootstrap_node); Synchronisation_threshold 0] + ~arguments:[Peer bootstrap.node_p2p_endpoint; Synchronisation_threshold 0] agent in let* dal_node = @@ -1017,7 +1034,7 @@ let init_observer cloud ~bootstrap_node ~dal_bootstrap_node ~slot_index i agent Dal_node.init_config ~expected_pow:0. ~observer_profiles:[slot_index] - ~peers:[Dal_node.point_str dal_bootstrap_node] + ~peers:[bootstrap.dal_node_p2p_endpoint] dal_node in let* () = @@ -1031,15 +1048,14 @@ let init_observer cloud ~bootstrap_node ~dal_bootstrap_node ~slot_index i agent let* () = Dal_node.run ~event_level:`Notice dal_node in Lwt.return {node; dal_node; slot_index} -let init_etherlink_operator_setup cloud is_sequencer name ~bootstrap_node - account agent = +let init_etherlink_operator_setup cloud is_sequencer name ~bootstrap account + agent = let open Sc_rollup_helpers in let open Tezt_etherlink in let* node = Node.Agent.init ~name:(Format.asprintf "etherlink-%s-node" name) - ~arguments: - [Peer (Node.point_str bootstrap_node); Synchronisation_threshold 0] + ~arguments:[Peer bootstrap.node_p2p_endpoint; Synchronisation_threshold 0] agent in let* client = Client.Agent.create ~node agent in @@ -1162,15 +1178,13 @@ let init_etherlink_operator_setup cloud is_sequencer name ~bootstrap_node in return operator -let init_etherlink_producer_setup cloud operator name account ~bootstrap_node - agent = +let init_etherlink_producer_setup cloud operator name account ~bootstrap agent = let open Sc_rollup_helpers in let open Tezt_etherlink in let* node = Node.Agent.init ~name:(Format.asprintf "etherlink-%s-node" name) - ~arguments: - [Peer (Node.point_str bootstrap_node); Synchronisation_threshold 0] + ~arguments:[Peer bootstrap.node_p2p_endpoint; Synchronisation_threshold 0] agent in let* client = Client.Agent.create ~node agent in @@ -1252,15 +1266,14 @@ let init_etherlink_producer_setup cloud operator name account ~bootstrap_node in return operator -let init_etherlink cloud ~bootstrap_node etherlink_rollup_operator_key - next_agent = +let init_etherlink cloud ~bootstrap etherlink_rollup_operator_key next_agent = let* operator_agent = next_agent ~name:"etherlink-operator-agent" in let* operator = init_etherlink_operator_setup cloud Cli.etherlink_sequencer "operator" - ~bootstrap_node + ~bootstrap etherlink_rollup_operator_key operator_agent in @@ -1280,7 +1293,7 @@ let init_etherlink cloud ~bootstrap_node etherlink_rollup_operator_key operator (Format.asprintf "producer-%d" i) accounts.(i) - ~bootstrap_node + ~bootstrap agent) |> Lwt.all in @@ -1320,25 +1333,19 @@ let init ~(configuration : configuration) cloud next_agent = let* bakers = Lwt_list.mapi_p (fun i (agent, account) -> - init_baker - cloud - configuration - ~bootstrap_node:bootstrap.node - ~dal_bootstrap_node:bootstrap.dal_node - account - i - agent) + init_baker cloud configuration ~bootstrap account i agent) (List.combine attesters_agents baker_accounts) in - let client = Client.create ~endpoint:(Node bootstrap.node) () in + let client = + Client.create ~endpoint:(Foreign_endpoint bootstrap.node_rpc_endpoint) () + in let* parameters = Dal_common.Parameters.from_client client in let* producers = Lwt_list.mapi_p (fun i (agent, account) -> init_producer cloud - ~bootstrap_node:bootstrap.node - ~dal_bootstrap_node:bootstrap.dal_node + ~bootstrap ~number_of_slots:parameters.number_of_slots account i @@ -1347,13 +1354,7 @@ let init ~(configuration : configuration) cloud next_agent = and* observers = Lwt_list.mapi_p (fun i (agent, slot_index) -> - init_observer - cloud - ~bootstrap_node:bootstrap.node - ~dal_bootstrap_node:bootstrap.dal_node - ~slot_index - i - agent) + init_observer cloud ~bootstrap ~slot_index i agent) (List.combine observers_agents configuration.observer_slot_indices) in let* etherlink = @@ -1362,11 +1363,7 @@ let init ~(configuration : configuration) cloud next_agent = Option.get etherlink_rollup_operator_key in let* etherlink = - init_etherlink - cloud - ~bootstrap_node:bootstrap.node - etherlink_rollup_operator_key - next_agent + init_etherlink cloud ~bootstrap etherlink_rollup_operator_key next_agent in some etherlink else none @@ -1392,13 +1389,18 @@ let init ~(configuration : configuration) cloud next_agent = disconnection_state; } +let wait_for_level (bootstrap : bootstrap) level = + match bootstrap.node with + | None -> + (* Implemented in a future commit. *) + assert false + | Some node -> + let* _ = Node.wait_for_level node level in + Lwt.return_unit + let on_new_level t level = - let node = t.bootstrap.node in let client = t.bootstrap.client in - let* () = - let* _ = Node.wait_for_level node level in - Lwt.return_unit - in + let* () = wait_for_level t.bootstrap level in Log.info "Start process level %d" level ; let* infos_per_level = get_infos_per_level client ~level in Hashtbl.replace t.infos level infos_per_level ; @@ -1425,7 +1427,8 @@ let on_new_level t level = (List.nth t.bakers (b mod nb_bakers)).dal_node in Dal_common.Helpers.connect_nodes_via_p2p - t.bootstrap.dal_node + (* TODO: Fix this! *) + (Option.get t.bootstrap.dal_node) baker_to_reconnect) in Lwt.return {t with disconnection_state = Some disconnection_state} -- GitLab From 29a39f3a7ea87cf7d6ca307307521d1a3b6d0de2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Thir=C3=A9?= Date: Wed, 17 Jul 2024 16:25:35 +0200 Subject: [PATCH 6/6] Tezt/Cloud/DAL: Don't wait reconnection of baker on reconnection --- tezt/tests/cloud/dal.ml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/tezt/tests/cloud/dal.ml b/tezt/tests/cloud/dal.ml index b6ebadc8f8d0..966d458b82da 100644 --- a/tezt/tests/cloud/dal.ml +++ b/tezt/tests/cloud/dal.ml @@ -1426,10 +1426,7 @@ let on_new_level t level = let baker_to_reconnect = (List.nth t.bakers (b mod nb_bakers)).dal_node in - Dal_common.Helpers.connect_nodes_via_p2p - (* TODO: Fix this! *) - (Option.get t.bootstrap.dal_node) - baker_to_reconnect) + Dal_node.run baker_to_reconnect) in Lwt.return {t with disconnection_state = Some disconnection_state} -- GitLab