diff --git a/etherlink/tezt/lib/setup.ml b/etherlink/tezt/lib/setup.ml index 268985adb5b8f8f1ca4f686089567998ab3d8595..acfc3b8f489b4a007c941d66c15dc060f51ce4bd 100644 --- a/etherlink/tezt/lib/setup.ml +++ b/etherlink/tezt/lib/setup.ml @@ -3,7 +3,7 @@ (* SPDX-License-Identifier: MIT *) (* Copyright (c) 2024 Nomadic Labs *) (* Copyright (c) 2024 Trilitech *) -(* Copyright (c) 2024 Functori *) +(* Copyright (c) 2024-2025 Functori *) (* *) (*****************************************************************************) @@ -19,6 +19,21 @@ type l1_contracts = { ticket_router_tester : string; } +type multichain_sequencer_setup = { + node : Node.t; + client : Client.t; + sc_rollup_address : string; + sc_rollup_node : Sc_rollup_node.t; + observers : Evm_node.t list; + sequencer : Evm_node.t; + proxys : Evm_node.t list; + l1_contracts : l1_contracts; + boot_sector : string; + kernel : Uses.t; + enable_dal : bool; + enable_multichain : bool; +} + type sequencer_setup = { node : Node.t; client : Client.t; @@ -34,6 +49,47 @@ type sequencer_setup = { enable_multichain : bool; } +type l2_setup = { + l2_chain_id : int; + world_state_path : string option; + bootstrap_accounts : string list option; + sequencer_pool_address : string option; + minimum_base_fee_per_gas : Wei.t option; + da_fee_per_byte : Wei.t option; + maximum_gas_per_transaction : int64 option; +} + +let default_l2_setup ~l2_chain_id = + { + l2_chain_id; + world_state_path = None; + bootstrap_accounts = None; + sequencer_pool_address = None; + minimum_base_fee_per_gas = None; + da_fee_per_byte = None; + maximum_gas_per_transaction = None; + } + +let multichain_setup_to_single ~(setup : multichain_sequencer_setup) = + let observer = + match setup.observers with [observer] -> observer | _ -> assert false + in + let proxy = match setup.proxys with [proxy] -> proxy | _ -> assert false in + { + node = setup.node; + client = setup.client; + sc_rollup_address = setup.sc_rollup_address; + sc_rollup_node = setup.sc_rollup_node; + observer; + sequencer = setup.sequencer; + proxy; + l1_contracts = setup.l1_contracts; + boot_sector = setup.boot_sector; + kernel = setup.kernel; + enable_dal = setup.enable_dal; + enable_multichain = setup.enable_multichain; + } + let uses _protocol = [ Constant.octez_smart_rollup_node; @@ -187,24 +243,165 @@ let run_new_observer_node ?(finalized_view = false) ?(patch_config = Fun.id) in return observer -let setup_sequencer ?max_delayed_inbox_blueprint_length ?next_wasm_runtime - ?sequencer_rpc_port ?sequencer_private_rpc_port ~mainnet_compat - ?genesis_timestamp ?time_between_blocks ?max_blueprints_lag - ?max_blueprints_ahead ?max_blueprints_catchup ?catchup_cooldown - ?delayed_inbox_timeout ?delayed_inbox_min_levels ?max_number_of_chunks - ?commitment_period ?challenge_window +let setup_kernel_singlechain ~l1_contracts ?max_delayed_inbox_blueprint_length + ~mainnet_compat ?delayed_inbox_timeout ?delayed_inbox_min_levels ?(bootstrap_accounts = List.map (fun account -> account.Eth_account.address) - (Array.to_list Eth_account.bootstrap_accounts)) - ?(sequencer = Constant.bootstrap1) ?sequencer_pool_address - ?(kernel = Constant.WASM.evm_kernel) ?da_fee ?minimum_base_fee_per_gas - ?preimages_dir ?maximum_allowed_ticks ?maximum_gas_per_transaction + (Array.to_list Eth_account.bootstrap_accounts)) ?sequencer_pool_address + ?da_fee_per_byte ?minimum_base_fee_per_gas ?maximum_allowed_ticks + ?maximum_gas_per_transaction ?max_blueprint_lookahead_in_seconds + ?enable_fa_bridge ?enable_fast_withdrawal ~enable_dal ?dal_slots ~sequencer + ~preimages_dir ~kernel () = + let output_config = Temp.file "config.yaml" in + let*! () = + Evm_node.make_kernel_installer_config + ?max_delayed_inbox_blueprint_length + ~mainnet_compat + ~sequencer + ~delayed_bridge:l1_contracts.delayed_transaction_bridge + ~ticketer:l1_contracts.exchanger + ~administrator:l1_contracts.admin + ~sequencer_governance:l1_contracts.sequencer_governance + ?minimum_base_fee_per_gas + ?da_fee_per_byte + ?delayed_inbox_timeout + ?delayed_inbox_min_levels + ?sequencer_pool_address + ?maximum_allowed_ticks + ?maximum_gas_per_transaction + ~enable_dal + ?enable_fast_withdrawal + ?dal_slots + ~enable_multichain:false + ?max_blueprint_lookahead_in_seconds + ~bootstrap_accounts + ~output:output_config + ?enable_fa_bridge + () + in + let* {output; _} = + prepare_installer_kernel ~preimages_dir ~config:(`Path output_config) kernel + in + return output + +let generate_l2_kernel_config l2_setup = + let l2_config = + Temp.file (Format.sprintf "l2-%d-config.yaml" l2_setup.l2_chain_id) + in + let*! () = + Evm_node.make_l2_kernel_installer_config + ~chain_id:l2_setup.l2_chain_id + ?maximum_gas_per_transaction:l2_setup.maximum_gas_per_transaction + ?sequencer_pool_address:l2_setup.sequencer_pool_address + ?minimum_base_fee_per_gas:l2_setup.minimum_base_fee_per_gas + ?da_fee_per_byte:l2_setup.da_fee_per_byte + ?bootstrap_accounts:l2_setup.bootstrap_accounts + ?world_state_path:l2_setup.world_state_path + ~output:l2_config + () + in + return l2_config + +let setup_kernel_multichain ~l2_setups ~l1_contracts + ?max_delayed_inbox_blueprint_length ~mainnet_compat ?delayed_inbox_timeout + ?delayed_inbox_min_levels ?maximum_allowed_ticks + ?max_blueprint_lookahead_in_seconds ?enable_fa_bridge + ?enable_fast_withdrawal ~enable_dal ?dal_slots ~sequencer ~preimages_dir + ~kernel () = + let l2_chain_ids = List.map (fun l2 -> l2.l2_chain_id) l2_setups in + let* l2_configs = Lwt_list.map_s generate_l2_kernel_config l2_setups in + let rollup_config = Temp.file "rollup-config.yaml" in + let*! () = + Evm_node.make_kernel_installer_config + ~l2_chain_ids + ?max_delayed_inbox_blueprint_length + ~mainnet_compat + ~sequencer + ~delayed_bridge:l1_contracts.delayed_transaction_bridge + ~ticketer:l1_contracts.exchanger + ~administrator:l1_contracts.admin + ~sequencer_governance:l1_contracts.sequencer_governance + ?delayed_inbox_timeout + ?delayed_inbox_min_levels + ?maximum_allowed_ticks + ~enable_dal + ?enable_fast_withdrawal + ?dal_slots + ~enable_multichain:true + ?max_blueprint_lookahead_in_seconds + ~output:rollup_config + ?enable_fa_bridge + () + in + let* {output; _} = + prepare_installer_kernel_with_multiple_setup_file + ~preimages_dir + ~configs:(rollup_config :: l2_configs) + (Uses.path kernel) + in + return output + +let setup_kernel ~enable_multichain ~l2_chains ~l1_contracts + ?max_delayed_inbox_blueprint_length ~mainnet_compat ~sequencer + ?delayed_inbox_timeout ?delayed_inbox_min_levels ?maximum_allowed_ticks + ~enable_dal ?enable_fast_withdrawal ?dal_slots + ?max_blueprint_lookahead_in_seconds ?enable_fa_bridge ~preimages_dir ~kernel + () = + if not enable_multichain then ( + assert (List.length l2_chains = 1) ; + let chain_config = List.hd l2_chains in + setup_kernel_singlechain + ~l1_contracts + ?max_delayed_inbox_blueprint_length + ~mainnet_compat + ~sequencer:sequencer.Account.public_key + ?minimum_base_fee_per_gas:chain_config.minimum_base_fee_per_gas + ?da_fee_per_byte:chain_config.da_fee_per_byte + ?delayed_inbox_timeout + ?delayed_inbox_min_levels + ?sequencer_pool_address:chain_config.sequencer_pool_address + ?maximum_allowed_ticks + ?maximum_gas_per_transaction:chain_config.maximum_gas_per_transaction + ~enable_dal + ?enable_fast_withdrawal + ?dal_slots + ?max_blueprint_lookahead_in_seconds + ?bootstrap_accounts:chain_config.bootstrap_accounts + ?enable_fa_bridge + ~preimages_dir + ~kernel + ()) + else + setup_kernel_multichain + ~l2_setups:l2_chains + ~l1_contracts + ?max_delayed_inbox_blueprint_length + ~mainnet_compat + ~sequencer:sequencer.Account.public_key + ?delayed_inbox_timeout + ?delayed_inbox_min_levels + ?maximum_allowed_ticks + ~enable_dal + ?enable_fast_withdrawal + ?dal_slots + ?max_blueprint_lookahead_in_seconds + ~preimages_dir + ~kernel + () + +let setup_sequencer_internal ?max_delayed_inbox_blueprint_length + ?next_wasm_runtime ?sequencer_rpc_port ?sequencer_private_rpc_port + ~mainnet_compat ?genesis_timestamp ?time_between_blocks ?max_blueprints_lag + ?max_blueprints_ahead ?max_blueprints_catchup ?catchup_cooldown + ?delayed_inbox_timeout ?delayed_inbox_min_levels ?max_number_of_chunks + ?commitment_period ?challenge_window ?(sequencer = Constant.bootstrap1) + ?(kernel = Constant.WASM.evm_kernel) ?preimages_dir ?maximum_allowed_ticks ?max_blueprint_lookahead_in_seconds ?enable_fa_bridge ?enable_fast_withdrawal ?(threshold_encryption = false) ?(drop_duplicate_when_injection = true) ?(blueprints_publisher_order_enabled = true) ?rollup_history_mode - ~enable_dal ?dal_slots ~enable_multichain ?rpc_server ?websockets + ~enable_dal ?dal_slots ~enable_multichain ~l2_chains ?rpc_server ?websockets ?history_mode ?enable_tx_queue ?spawn_rpc ?periodic_snapshot_path protocol = let* node, client = setup_l1 @@ -239,36 +436,26 @@ let setup_sequencer ?max_delayed_inbox_blueprint_length ?next_wasm_runtime ~default:(Sc_rollup_node.data_dir sc_rollup_node // "wasm_2_0_0") preimages_dir in - let output_config = Temp.file "config.yaml" in - let*! () = - Evm_node.make_kernel_installer_config + let* output = + setup_kernel + ~l1_contracts ?max_delayed_inbox_blueprint_length ~mainnet_compat - ~sequencer:sequencer.public_key - ~delayed_bridge:l1_contracts.delayed_transaction_bridge - ~ticketer:l1_contracts.exchanger - ~administrator:l1_contracts.admin - ~sequencer_governance:l1_contracts.sequencer_governance - ?minimum_base_fee_per_gas - ?da_fee_per_byte:da_fee + ~sequencer ?delayed_inbox_timeout ?delayed_inbox_min_levels - ?sequencer_pool_address ?maximum_allowed_ticks - ?maximum_gas_per_transaction ~enable_dal ?enable_fast_withdrawal ?dal_slots ~enable_multichain + ~l2_chains ?max_blueprint_lookahead_in_seconds - ~bootstrap_accounts - ~output:output_config ?enable_fa_bridge + ~preimages_dir + ~kernel () in - let* {output; _} = - prepare_installer_kernel ~preimages_dir ~config:(`Path output_config) kernel - in let* sc_rollup_address = originate_sc_rollup ~keys:[] @@ -364,28 +551,34 @@ let setup_sequencer ?max_delayed_inbox_blueprint_length ?next_wasm_runtime ?spawn_rpc (Sc_rollup_node.endpoint sc_rollup_node) in - let* observer = - run_new_observer_node - ~patch_config:obs_patch_config - ~sc_rollup_node - ?rpc_server - ?websockets - ?history_mode - sequencer + let* observers = + Lwt_list.map_s + (fun _l2 -> + run_new_observer_node + ~patch_config:obs_patch_config + ~sc_rollup_node + ?rpc_server + ?websockets + ?history_mode + sequencer) + l2_chains in - let* proxy = - Evm_node.init - ~patch_config:obs_patch_config - ~mode:Proxy - (Sc_rollup_node.endpoint sc_rollup_node) + let* proxys = + Lwt_list.map_s + (fun _l2 -> + Evm_node.init + ~patch_config:obs_patch_config + ~mode:Proxy + (Sc_rollup_node.endpoint sc_rollup_node)) + l2_chains in return { node; client; sequencer; - proxy; - observer; + proxys; + observers; l1_contracts; sc_rollup_address; sc_rollup_node; @@ -395,8 +588,76 @@ let setup_sequencer ?max_delayed_inbox_blueprint_length ?next_wasm_runtime enable_multichain; } -(* Register a single variant of a test but for all protocols. *) -let register_test ~__FILE__ ?max_delayed_inbox_blueprint_length +let setup_sequencer ?max_delayed_inbox_blueprint_length ?next_wasm_runtime + ?sequencer_rpc_port ?sequencer_private_rpc_port ~mainnet_compat + ?genesis_timestamp ?time_between_blocks ?max_blueprints_lag + ?max_blueprints_ahead ?max_blueprints_catchup ?catchup_cooldown + ?delayed_inbox_timeout ?delayed_inbox_min_levels ?max_number_of_chunks + ?commitment_period ?challenge_window ?bootstrap_accounts ?sequencer + ?sequencer_pool_address ?kernel ?da_fee ?minimum_base_fee_per_gas + ?preimages_dir ?maximum_allowed_ticks ?maximum_gas_per_transaction + ?max_blueprint_lookahead_in_seconds ?enable_fa_bridge + ?enable_fast_withdrawal ?threshold_encryption ?drop_duplicate_when_injection + ?blueprints_publisher_order_enabled ?rollup_history_mode ~enable_dal + ?dal_slots ~enable_multichain ?rpc_server ?websockets ?history_mode + ?enable_tx_queue ?spawn_rpc ?periodic_snapshot_path protocol = + (* Note that the chain_id is not important (it will become important later) *) + let l2_chains = + [ + { + (default_l2_setup ~l2_chain_id:1) with + sequencer_pool_address; + bootstrap_accounts; + da_fee_per_byte = da_fee; + minimum_base_fee_per_gas; + maximum_gas_per_transaction; + }; + ] + in + let* sequencer_setup = + setup_sequencer_internal + ?max_delayed_inbox_blueprint_length + ?next_wasm_runtime + ?sequencer_rpc_port + ?sequencer_private_rpc_port + ~mainnet_compat + ?commitment_period + ?challenge_window + ?genesis_timestamp + ?time_between_blocks + ?max_blueprints_lag + ?max_blueprints_ahead + ?max_blueprints_catchup + ?catchup_cooldown + ?delayed_inbox_timeout + ?delayed_inbox_min_levels + ?max_number_of_chunks + ?sequencer + ?kernel + ?preimages_dir + ?maximum_allowed_ticks + ?max_blueprint_lookahead_in_seconds + ?enable_fa_bridge + ?enable_fast_withdrawal + ?blueprints_publisher_order_enabled + ?drop_duplicate_when_injection + ?threshold_encryption + ?rollup_history_mode + ?websockets + ?history_mode + ~enable_dal + ?dal_slots + ~enable_multichain + ~l2_chains + ?rpc_server + ?enable_tx_queue + ?spawn_rpc + ?periodic_snapshot_path + protocol + in + return (multichain_setup_to_single ~setup:sequencer_setup) + +let register_multichain_test ~__FILE__ ?max_delayed_inbox_blueprint_length ?sequencer_rpc_port ?sequencer_private_rpc_port ?genesis_timestamp ?time_between_blocks ?max_blueprints_lag ?max_blueprints_ahead ?max_blueprints_catchup ?catchup_cooldown ?delayed_inbox_timeout @@ -408,8 +669,9 @@ let register_test ~__FILE__ ?max_delayed_inbox_blueprint_length ?(threshold_encryption = false) ?(uses = uses) ?(additional_uses = []) ?rollup_history_mode ~enable_dal ?(dal_slots = if enable_dal then Some [0; 1; 2; 3] else None) - ~enable_multichain ?rpc_server ?websockets ?history_mode ?enable_tx_queue - ?spawn_rpc ?periodic_snapshot_path body ~title ~tags protocols = + ~enable_multichain ~number_of_chains ?rpc_server ?websockets ?history_mode + ?enable_tx_queue ?spawn_rpc ?periodic_snapshot_path body ~title ~tags + protocols = let kernel_tag, kernel_use = Kernel.to_uses_and_tags kernel in let tags = kernel_tag :: tags in let additional_uses = @@ -424,9 +686,20 @@ let register_test ~__FILE__ ?max_delayed_inbox_blueprint_length | _, (Mainnet | Ghostnet) -> None (* default *) | _, Latest -> Some Evm_node.Dream (* test with Dream for latest kernel *) in + let l2_chains = + List.init number_of_chains (fun l2_chain_id -> + { + (default_l2_setup ~l2_chain_id) with + sequencer_pool_address; + da_fee_per_byte = da_fee; + minimum_base_fee_per_gas; + maximum_gas_per_transaction; + bootstrap_accounts; + }) + in let body protocol = let* sequencer_setup = - setup_sequencer + setup_sequencer_internal ?max_delayed_inbox_blueprint_length ?sequencer_rpc_port ?sequencer_private_rpc_port @@ -442,15 +715,10 @@ let register_test ~__FILE__ ?max_delayed_inbox_blueprint_length ?delayed_inbox_timeout ?delayed_inbox_min_levels ?max_number_of_chunks - ?bootstrap_accounts ?sequencer - ?sequencer_pool_address ~kernel:kernel_use - ?da_fee - ?minimum_base_fee_per_gas ?preimages_dir ?maximum_allowed_ticks - ?maximum_gas_per_transaction ?max_blueprint_lookahead_in_seconds ?enable_fa_bridge ?enable_fast_withdrawal @@ -461,6 +729,7 @@ let register_test ~__FILE__ ?max_delayed_inbox_blueprint_length ~enable_dal ?dal_slots ~enable_multichain + ~l2_chains ?rpc_server ?enable_tx_queue ?spawn_rpc @@ -498,6 +767,70 @@ let register_test ~__FILE__ ?max_delayed_inbox_blueprint_length ~tags protocols +(* Register a single variant of a test but for all protocols. *) +let register_test ~__FILE__ ?max_delayed_inbox_blueprint_length + ?sequencer_rpc_port ?sequencer_private_rpc_port ?genesis_timestamp + ?time_between_blocks ?max_blueprints_lag ?max_blueprints_ahead + ?max_blueprints_catchup ?catchup_cooldown ?delayed_inbox_timeout + ?delayed_inbox_min_levels ?max_number_of_chunks ?bootstrap_accounts + ?sequencer ?sequencer_pool_address ~kernel ?da_fee ?minimum_base_fee_per_gas + ?preimages_dir ?maximum_allowed_ticks ?maximum_gas_per_transaction + ?max_blueprint_lookahead_in_seconds ?enable_fa_bridge + ?enable_fast_withdrawal ?commitment_period ?challenge_window + ?threshold_encryption ?uses ?additional_uses ?rollup_history_mode + ~enable_dal ?dal_slots ~enable_multichain ?rpc_server ?websockets + ?history_mode ?enable_tx_queue ?spawn_rpc ?periodic_snapshot_path body + ~title ~tags protocols = + let body sequencer_setup = + body (multichain_setup_to_single ~setup:sequencer_setup) + in + register_multichain_test + ~__FILE__ + ?max_delayed_inbox_blueprint_length + ?sequencer_rpc_port + ?sequencer_private_rpc_port + ?genesis_timestamp + ?time_between_blocks + ?max_blueprints_lag + ?max_blueprints_ahead + ?max_blueprints_catchup + ?catchup_cooldown + ?delayed_inbox_timeout + ?delayed_inbox_min_levels + ?max_number_of_chunks + ?bootstrap_accounts + ?sequencer + ?sequencer_pool_address + ~kernel + ?da_fee + ?minimum_base_fee_per_gas + ?preimages_dir + ?maximum_allowed_ticks + ?maximum_gas_per_transaction + ?max_blueprint_lookahead_in_seconds + ?enable_fa_bridge + ?enable_fast_withdrawal + ?commitment_period + ?challenge_window + ?threshold_encryption + ?uses + ?additional_uses + ?rollup_history_mode + ~enable_dal + ?dal_slots + ~enable_multichain + ~number_of_chains:1 + ?rpc_server + ?websockets + ?history_mode + ?enable_tx_queue + ?spawn_rpc + ?periodic_snapshot_path + body + ~title + ~tags + protocols + let register_test_for_kernels ~__FILE__ ?max_delayed_inbox_blueprint_length ?sequencer_rpc_port ?sequencer_private_rpc_port ?genesis_timestamp ?time_between_blocks ?max_blueprints_lag ?max_blueprints_ahead diff --git a/etherlink/tezt/lib/setup.mli b/etherlink/tezt/lib/setup.mli index 1c70699d6f8164f40cb7759239d046026e60e478..fae2cbcd02c89b15e47b4a2d7fb7bebc2a80c1e4 100644 --- a/etherlink/tezt/lib/setup.mli +++ b/etherlink/tezt/lib/setup.mli @@ -16,6 +16,21 @@ type l1_contracts = { ticket_router_tester : string; } +type multichain_sequencer_setup = { + node : Node.t; + client : Client.t; + sc_rollup_address : string; + sc_rollup_node : Sc_rollup_node.t; + observers : Evm_node.t list; + sequencer : Evm_node.t; + proxys : Evm_node.t list; + l1_contracts : l1_contracts; + boot_sector : string; + kernel : Uses.t; + enable_dal : bool; + enable_multichain : bool; +} + type sequencer_setup = { node : Node.t; client : Client.t; @@ -104,6 +119,54 @@ val register_test : Protocol.t list -> unit +val register_multichain_test : + __FILE__:string -> + ?max_delayed_inbox_blueprint_length:int -> + ?sequencer_rpc_port:int -> + ?sequencer_private_rpc_port:int -> + ?genesis_timestamp:Client.timestamp -> + ?time_between_blocks:Evm_node.time_between_blocks -> + ?max_blueprints_lag:int -> + ?max_blueprints_ahead:int -> + ?max_blueprints_catchup:int -> + ?catchup_cooldown:int -> + ?delayed_inbox_timeout:int -> + ?delayed_inbox_min_levels:int -> + ?max_number_of_chunks:int -> + ?bootstrap_accounts:string list -> + ?sequencer:Account.key -> + ?sequencer_pool_address:string -> + kernel:Kernel.t -> + ?da_fee:Wei.t -> + ?minimum_base_fee_per_gas:Wei.t -> + ?preimages_dir:string -> + ?maximum_allowed_ticks:int64 -> + ?maximum_gas_per_transaction:int64 -> + ?max_blueprint_lookahead_in_seconds:int64 -> + ?enable_fa_bridge:bool -> + ?enable_fast_withdrawal:bool -> + ?commitment_period:int -> + ?challenge_window:int -> + ?threshold_encryption:bool -> + ?uses:(Protocol.t -> Uses.t list) -> + ?additional_uses:Uses.t list -> + ?rollup_history_mode:Sc_rollup_node.history_mode -> + enable_dal:bool -> + ?dal_slots:int list option -> + enable_multichain:bool -> + number_of_chains:int -> + ?rpc_server:Evm_node.rpc_server -> + ?websockets:bool -> + ?history_mode:Evm_node.history_mode -> + ?enable_tx_queue:bool -> + ?spawn_rpc:int -> + ?periodic_snapshot_path:string -> + (multichain_sequencer_setup -> Protocol.t -> unit Lwt.t) -> + title:string -> + tags:string list -> + Protocol.t list -> + unit + (** [register_test_for_kernels] setups the full sequencer environment for the tests and starts the test. For each of the parameters, please refer to [Evm_node]. The test is registered for each kernel. *) diff --git a/etherlink/tezt/tests/evm_sequencer.ml b/etherlink/tezt/tests/evm_sequencer.ml index a0e68f84efeefe033d53449520dbdfe66d0b59ac..42af06e1a1b04a7c66cad3f344a3e2bde9527fd6 100644 --- a/etherlink/tezt/tests/evm_sequencer.ml +++ b/etherlink/tezt/tests/evm_sequencer.ml @@ -337,6 +337,83 @@ let register_all ?max_delayed_inbox_blueprint_length ?sequencer_rpc_port dal_cases) threshold_encryption_cases +(* Register all variants of a test. *) +let register_multichain_all ?max_delayed_inbox_blueprint_length + ?sequencer_rpc_port ?sequencer_private_rpc_port ?genesis_timestamp + ?time_between_blocks ?max_blueprints_lag ?max_blueprints_ahead + ?max_blueprints_catchup ?catchup_cooldown ?delayed_inbox_timeout + ?delayed_inbox_min_levels ?max_number_of_chunks ?bootstrap_accounts + ?sequencer ?sequencer_pool_address ?da_fee ?minimum_base_fee_per_gas + ?preimages_dir ?maximum_allowed_ticks ?maximum_gas_per_transaction + ?max_blueprint_lookahead_in_seconds ?enable_fa_bridge ?rollup_history_mode + ?commitment_period ?challenge_window ?additional_uses ?rpc_server + ?websockets ?enable_fast_withdrawal ?history_mode ~number_of_chains + ?(use_threshold_encryption = default_threshold_encryption_registration) + ?(use_dal = default_dal_registration) ~title ~tags body protocols = + let dal_cases = + match use_dal with + | Register_both {extra_tags_with; extra_tags_without} -> + [(false, extra_tags_without); (true, extra_tags_with)] + | Register_with_feature -> [(true, [])] + | Register_without_feature -> [(false, [])] + in + let threshold_encryption_cases = + match use_threshold_encryption with + | Register_both {extra_tags_with; extra_tags_without} -> + [(false, extra_tags_without); (true, extra_tags_with)] + | Register_with_feature -> [(true, [])] + | Register_without_feature -> [(false, [])] + in + (* TODO: https://gitlab.com/tezos/tezos/-/issues/7367 + Also register the tests with and without FA bridge feature flag. *) + List.iter + (fun (threshold_encryption, te_tags) -> + List.iter + (fun (enable_dal, dal_tags) -> + register_multichain_test + ~__FILE__ + ?max_delayed_inbox_blueprint_length + ?sequencer_rpc_port + ?sequencer_private_rpc_port + ?commitment_period + ?challenge_window + ?genesis_timestamp + ?time_between_blocks + ?max_blueprints_lag + ?max_blueprints_ahead + ?max_blueprints_catchup + ?catchup_cooldown + ?delayed_inbox_timeout + ?delayed_inbox_min_levels + ?max_number_of_chunks + ?bootstrap_accounts + ?sequencer + ?sequencer_pool_address + ?da_fee + ?minimum_base_fee_per_gas + ?preimages_dir + ?maximum_allowed_ticks + ?maximum_gas_per_transaction + ?max_blueprint_lookahead_in_seconds + ?enable_fa_bridge + ?enable_fast_withdrawal + ?additional_uses + ?rpc_server + ?websockets + ?history_mode + ~threshold_encryption + ?rollup_history_mode + ~enable_dal + ~enable_multichain:true + ~title + ~tags:(te_tags @ dal_tags @ tags) + ~kernel:Kernel.Latest + ~number_of_chains + body + protocols) + dal_cases) + threshold_encryption_cases + let register_upgrade_all ~title ~tags ~genesis_timestamp ?(time_between_blocks = Evm_node.Nothing) ?(kernels = Kernel.all) ?(upgrade_to = Kernel.upgrade_to) ?(additional_uses = []) scenario protocols @@ -1494,6 +1571,38 @@ let test_rpc_produceBlock = ~error_msg:"Expected new block number to be %L, but got: %R" ; unit +let block_number_multichain observers = + let* block_numbers = + Lwt_list.map_s + (fun observer -> + let*@ block_number = Rpc.block_number observer in + return block_number) + observers + in + match block_numbers with + | hd :: block_numbers when List.for_all (Int32.equal hd) block_numbers -> + return hd + | _ -> Test.fail "Every block numbers are not equal" + +let test_multichain_produceBlock = + register_multichain_all + ~time_between_blocks:Nothing + ~tags:[Tag.flaky; "evm"; "multichain"; "produce_block"] + ~title:"RPC method produceBlock in a multichain environment" + @@ fun {sequencer; observers; sc_rollup_node; client; proxys; _} _protocol -> + let* start_block_number = block_number_multichain observers in + let*@ _ = produce_block sequencer in + let* () = + Lwt_list.iter_s + (fun proxy -> + bake_until_sync ~sc_rollup_node ~client ~sequencer ~proxy ()) + proxys + in + let* new_block_number = block_number_multichain observers in + Check.((Int32.succ start_block_number = new_block_number) int32) + ~error_msg:"Expected new block number to be %L, but got: %R" ; + unit + let wait_for_event ?(timeout = 30.) ?(levels = 10) event_watcher ~sequencer ~sc_rollup_node ~client ~error_msg = let event_value = ref None in @@ -11592,6 +11701,7 @@ let () = test_multichain_feature_flag protocols ; test_make_l2_kernel_installer_config "EVM" protocols ; test_make_l2_kernel_installer_config "Michelson" protocols ; + test_multichain_produceBlock ~number_of_chains:2 protocols ; test_fast_withdrawal_feature_flag protocols ; test_deposit_and_fast_withdraw protocols ; test_fast_withdraw_feature_flag_deactivated protocols ;