From 5263710145af52553809d27e59d9723f83129f23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Cauderlier?= Date: Wed, 4 Jun 2025 00:10:40 +0200 Subject: [PATCH 1/5] Tezlink/Node/Tx_pool: fail if chain family is Michelson --- etherlink/bin_node/lib_dev/observer.ml | 27 +++++++++++++++---------- etherlink/bin_node/lib_dev/proxy.ml | 4 ++-- etherlink/bin_node/lib_dev/rpc.ml | 2 +- etherlink/bin_node/lib_dev/sequencer.ml | 20 ++++++++++-------- etherlink/bin_node/lib_dev/tx_pool.ml | 7 ++++++- etherlink/bin_node/lib_dev/tx_pool.mli | 4 +++- 6 files changed, 40 insertions(+), 24 deletions(-) diff --git a/etherlink/bin_node/lib_dev/observer.ml b/etherlink/bin_node/lib_dev/observer.ml index b0ad1562e1f8..719d8d2a241f 100644 --- a/etherlink/bin_node/lib_dev/observer.ml +++ b/etherlink/bin_node/lib_dev/observer.ml @@ -209,22 +209,27 @@ let main ?network ?kernel_path ~data_dir ~(config : Configuration.t) ~no_sync init_from_snapshot in - let start_tx_container, tx_container, ping_tx_pool = + let*? start_tx_container, tx_container, ping_tx_pool = + let open Result_syntax in match config.experimental_features.enable_tx_queue with | Some tx_queue_config -> let start, tx_container = Tx_queue.tx_container ~chain_family:EVM in - ( (fun ~tx_pool_parameters:_ -> - start ~config:tx_queue_config ~keep_alive:config.keep_alive ()), - tx_container, - false ) + return + ( (fun ~tx_pool_parameters:_ -> + start ~config:tx_queue_config ~keep_alive:config.keep_alive ()), + tx_container, + false ) | None -> if config.finalized_view then - ( (fun ~tx_pool_parameters:_ -> return_unit), - container_forward_tx - ~keep_alive:config.keep_alive - ~evm_node_endpoint, - false ) - else (Tx_pool.start, Tx_pool.tx_container, true) + return + ( (fun ~tx_pool_parameters:_ -> Lwt_result_syntax.return_unit), + container_forward_tx + ~keep_alive:config.keep_alive + ~evm_node_endpoint, + false ) + else + let* tx_container = Tx_pool.tx_container ~chain_family:EVM in + return (Tx_pool.start, tx_container, true) in let* _loaded = diff --git a/etherlink/bin_node/lib_dev/proxy.ml b/etherlink/bin_node/lib_dev/proxy.ml index 19bab2ce0334..394ef5d28fcc 100644 --- a/etherlink/bin_node/lib_dev/proxy.ml +++ b/etherlink/bin_node/lib_dev/proxy.ml @@ -215,8 +215,8 @@ let main chain_family = Ex_chain_family chain_family; } in - return - (Some Tx_pool.pop_and_inject_transactions_lazy, Tx_pool.tx_container) + let*? tx_container = Tx_pool.tx_container ~chain_family:EVM in + return (Some Tx_pool.pop_and_inject_transactions_lazy, tx_container) | enable_send_raw_transaction, evm_node_endpoint, _ -> let evm_node_endpoint = if enable_send_raw_transaction then evm_node_endpoint else None diff --git a/etherlink/bin_node/lib_dev/rpc.ml b/etherlink/bin_node/lib_dev/rpc.ml index affdb48026aa..92f7a4bb6689 100644 --- a/etherlink/bin_node/lib_dev/rpc.ml +++ b/etherlink/bin_node/lib_dev/rpc.ml @@ -304,7 +304,7 @@ let main ~data_dir ~evm_node_endpoint ?evm_node_private_endpoint in return (false, tx_container) | None, None -> - let tx_container = Tx_pool.tx_container in + let*? tx_container = Tx_pool.tx_container ~chain_family:EVM in let* () = Tx_pool.start ~tx_pool_parameters: diff --git a/etherlink/bin_node/lib_dev/sequencer.ml b/etherlink/bin_node/lib_dev/sequencer.ml index 9594369540c3..fc814569f51a 100644 --- a/etherlink/bin_node/lib_dev/sequencer.ml +++ b/etherlink/bin_node/lib_dev/sequencer.ml @@ -188,17 +188,21 @@ let main ~data_dir ?(genesis_timestamp = Misc.now ()) ~cctxt Tx_queue is configured. TODO: simplify start_tx_container when removing the Tx_pool. *) - let start_tx_container, tx_container = + let*? start_tx_container, tx_container = + let open Result_syntax in match configuration.experimental_features.enable_tx_queue with | Some tx_queue_config -> let start, tx_container = Tx_queue.tx_container ~chain_family:EVM in - ( (fun ~tx_pool_parameters:_ -> - start - ~config:tx_queue_config - ~keep_alive:configuration.keep_alive - ()), - tx_container ) - | None -> (Tx_pool.start, Tx_pool.tx_container) + return + ( (fun ~tx_pool_parameters:_ -> + start + ~config:tx_queue_config + ~keep_alive:configuration.keep_alive + ()), + tx_container ) + | None -> + let* tx_container = Tx_pool.tx_container ~chain_family:EVM in + return (Tx_pool.start, tx_container) in let (module Tx_container) = Services_backend_sig.tx_container_module tx_container diff --git a/etherlink/bin_node/lib_dev/tx_pool.ml b/etherlink/bin_node/lib_dev/tx_pool.ml index d1eac3019ccc..025dfff3b865 100644 --- a/etherlink/bin_node/lib_dev/tx_pool.ml +++ b/etherlink/bin_node/lib_dev/tx_pool.ml @@ -992,4 +992,9 @@ module Tx_container = struct pop_transactions ~maximum_cumulative_size end -let tx_container = Services_backend_sig.Evm_tx_container (module Tx_container) +let tx_container (type f) ~(chain_family : f L2_types.chain_family) : + f Services_backend_sig.tx_container tzresult = + let open Result_syntax in + match chain_family with + | EVM -> return @@ Services_backend_sig.Evm_tx_container (module Tx_container) + | Michelson -> error_with "Tx pool not supported in Tezlink" diff --git a/etherlink/bin_node/lib_dev/tx_pool.mli b/etherlink/bin_node/lib_dev/tx_pool.mli index d84a76baad61..e6f9fbf3965f 100644 --- a/etherlink/bin_node/lib_dev/tx_pool.mli +++ b/etherlink/bin_node/lib_dev/tx_pool.mli @@ -53,4 +53,6 @@ val mode : unit -> mode tzresult Lwt.t (** wrapper of the Tx_pool to be compatible with the Tx_container signature for the services. *) -val tx_container : L2_types.evm_chain_family Services_backend_sig.tx_container +val tx_container : + chain_family:'f L2_types.chain_family -> + 'f Services_backend_sig.tx_container tzresult -- GitLab From 9210966dfd15d4c1248d640abd4b060fc5f919ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Cauderlier?= Date: Tue, 29 Apr 2025 14:48:02 +0200 Subject: [PATCH 2/5] Tezlink/Node/Observer/Forward_container: fail if chain family is Michelson --- etherlink/bin_node/lib_dev/observer.ml | 29 +++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/etherlink/bin_node/lib_dev/observer.ml b/etherlink/bin_node/lib_dev/observer.ml index 719d8d2a241f..0d5765574996 100644 --- a/etherlink/bin_node/lib_dev/observer.ml +++ b/etherlink/bin_node/lib_dev/observer.ml @@ -121,9 +121,10 @@ let install_finalizer_observer ~rollup_node_tracking let* () = Evm_context.shutdown () in when_ rollup_node_tracking @@ fun () -> Evm_events_follower.shutdown () -let container_forward_tx ~keep_alive ~evm_node_endpoint : - L2_types.evm_chain_family Services_backend_sig.tx_container = - Services_backend_sig.Evm_tx_container +let container_forward_tx (type f) ~(chain_family : f L2_types.chain_family) + ~keep_alive ~evm_node_endpoint : + f Services_backend_sig.tx_container tzresult = + let (module Tx_container) = (module struct type address = Ethereum_types.address @@ -166,7 +167,17 @@ let container_forward_tx ~keep_alive ~evm_node_endpoint : let pop_transactions ~maximum_cumulative_size:_ ~validate_tx:_ ~initial_validation_state:_ = Lwt_result_syntax.return_nil - end) + end : Services_backend_sig.Tx_container + with type address = Ethereum_types.address + and type legacy_transaction_object = + Ethereum_types.legacy_transaction_object + and type transaction_object = Transaction_object.t) + in + let open Result_syntax in + match chain_family with + | EVM -> return @@ Services_backend_sig.Evm_tx_container (module Tx_container) + | Michelson -> + error_with "Observer.container_forward_tx not implemented for Tezlink" let main ?network ?kernel_path ~data_dir ~(config : Configuration.t) ~no_sync ~init_from_snapshot () = @@ -221,11 +232,15 @@ let main ?network ?kernel_path ~data_dir ~(config : Configuration.t) ~no_sync false ) | None -> if config.finalized_view then + let* tx_container = + container_forward_tx + ~chain_family:EVM + ~keep_alive:config.keep_alive + ~evm_node_endpoint + in return ( (fun ~tx_pool_parameters:_ -> Lwt_result_syntax.return_unit), - container_forward_tx - ~keep_alive:config.keep_alive - ~evm_node_endpoint, + tx_container, false ) else let* tx_container = Tx_pool.tx_container ~chain_family:EVM in -- GitLab From 498a6bda5991240c3dc5cacd8bfdbfa4cf7bd62c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Cauderlier?= Date: Wed, 4 Jun 2025 00:17:00 +0200 Subject: [PATCH 3/5] Tezlink/Node/Proxy/Forward_container: fail if chain family is Michelson --- etherlink/bin_node/lib_dev/proxy.ml | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/etherlink/bin_node/lib_dev/proxy.ml b/etherlink/bin_node/lib_dev/proxy.ml index 394ef5d28fcc..4c6fdc86f480 100644 --- a/etherlink/bin_node/lib_dev/proxy.ml +++ b/etherlink/bin_node/lib_dev/proxy.ml @@ -21,9 +21,10 @@ let install_finalizer ~(tx_container : _ Services_backend_sig.tx_container) let* () = Tx_container.shutdown () in Evm_context.shutdown () -let container_forward_tx ~evm_node_endpoint ~keep_alive : - L2_types.evm_chain_family Services_backend_sig.tx_container = - Services_backend_sig.Evm_tx_container +let container_forward_tx (type f) ~(chain_family : f L2_types.chain_family) + ~evm_node_endpoint ~keep_alive : + f Services_backend_sig.tx_container tzresult = + let (module Tx_container) = (module struct type address = Ethereum_types.address @@ -72,7 +73,17 @@ let container_forward_tx ~evm_node_endpoint ~keep_alive : let confirm_transactions ~clear_pending_queue_after:_ ~confirmed_txs:_ = Lwt_result_syntax.return_unit - end) + end : Services_backend_sig.Tx_container + with type address = Ethereum_types.address + and type legacy_transaction_object = + Ethereum_types.legacy_transaction_object + and type transaction_object = Transaction_object.t) + in + let open Result_syntax in + match chain_family with + | EVM -> return @@ Services_backend_sig.Evm_tx_container (module Tx_container) + | Michelson -> + error_with "Proxy.container_forward_tx not implemented for Tezlink" let tx_queue_pop_and_inject (module Rollup_node_rpc : Services_backend_sig.S) ~(tx_container : @@ -221,7 +232,10 @@ let main let evm_node_endpoint = if enable_send_raw_transaction then evm_node_endpoint else None in - return @@ (None, container_forward_tx ~evm_node_endpoint ~keep_alive) + let*? tx_container = + container_forward_tx ~chain_family:EVM ~evm_node_endpoint ~keep_alive + in + return (None, tx_container) in let () = Rollup_node_follower.start -- GitLab From 9586532eb0b49393b3899f6d517171cff665f0e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Cauderlier?= Date: Tue, 29 Apr 2025 14:48:02 +0200 Subject: [PATCH 4/5] Etherlink/Node: match chain family and tx container family --- etherlink/bin_node/lib_dev/observer.ml | 31 +++++++++++++++++------ etherlink/bin_node/lib_dev/proxy.ml | 22 ++++++++++------ etherlink/bin_node/lib_dev/rpc.ml | 8 +++--- etherlink/bin_node/lib_dev/rpc_server.mli | 8 +++--- etherlink/bin_node/lib_dev/services.ml | 4 +-- 5 files changed, 46 insertions(+), 27 deletions(-) diff --git a/etherlink/bin_node/lib_dev/observer.ml b/etherlink/bin_node/lib_dev/observer.ml index 0d5765574996..555894127d9c 100644 --- a/etherlink/bin_node/lib_dev/observer.ml +++ b/etherlink/bin_node/lib_dev/observer.ml @@ -21,13 +21,19 @@ open Ethereum_types into a forced blueprint. The sequencer has performed a reorganization and starts submitting blocks from the new branch. *) -let on_new_blueprint - (tx_container : L2_types.evm_chain_family Services_backend_sig.tx_container) - evm_node_endpoint next_blueprint_number +let on_new_blueprint (type f) + (tx_container : f Services_backend_sig.tx_container) evm_node_endpoint + next_blueprint_number (({delayed_transactions; blueprint; _} : Blueprint_types.with_events) as blueprint_with_events) = let open Lwt_result_syntax in - let (Evm_tx_container (module Tx_container)) = tx_container in + let*? (module Tx_container) = + let open Result_syntax in + match tx_container with + | Evm_tx_container m -> return m + | Michelson_tx_container _ -> + error_with "Observer mode is not supported for Tezlink" + in let (Qty level) = blueprint.number in let (Qty number) = next_blueprint_number in if Z.(equal level number) then @@ -220,11 +226,18 @@ let main ?network ?kernel_path ~data_dir ~(config : Configuration.t) ~no_sync init_from_snapshot in + let* l2_chain_id, Ex_chain_family chain_family = + match config.experimental_features.l2_chains with + | None -> return (None, L2_types.Ex_chain_family EVM) + | Some [l2_chain] -> return (Some l2_chain.chain_id, l2_chain.chain_family) + | _ -> tzfail Node_error.Unexpected_multichain + in + let*? start_tx_container, tx_container, ping_tx_pool = let open Result_syntax in match config.experimental_features.enable_tx_queue with | Some tx_queue_config -> - let start, tx_container = Tx_queue.tx_container ~chain_family:EVM in + let start, tx_container = Tx_queue.tx_container ~chain_family in return ( (fun ~tx_pool_parameters:_ -> start ~config:tx_queue_config ~keep_alive:config.keep_alive ()), @@ -234,7 +247,7 @@ let main ?network ?kernel_path ~data_dir ~(config : Configuration.t) ~no_sync if config.finalized_view then let* tx_container = container_forward_tx - ~chain_family:EVM + ~chain_family ~keep_alive:config.keep_alive ~evm_node_endpoint in @@ -243,7 +256,7 @@ let main ?network ?kernel_path ~data_dir ~(config : Configuration.t) ~no_sync tx_container, false ) else - let* tx_container = Tx_pool.tx_container ~chain_family:EVM in + let* tx_container = Tx_pool.tx_container ~chain_family in return (Tx_pool.start, tx_container, true) in @@ -273,8 +286,10 @@ let main ?network ?kernel_path ~data_dir ~(config : Configuration.t) ~no_sync Evm_ro_context.ro_backend ro_ctxt config ~evm_node_endpoint in + (* Check that the multichain configuration is consistent with the + kernel config. *) let* enable_multichain = Evm_ro_context.read_enable_multichain_flag ro_ctxt in - let* l2_chain_id, Ex_chain_family chain_family = + let* _l2_chain_id, _chain_family = let (module Backend) = observer_backend in Backend.single_chain_id_and_family ~config ~enable_multichain in diff --git a/etherlink/bin_node/lib_dev/proxy.ml b/etherlink/bin_node/lib_dev/proxy.ml index 4c6fdc86f480..23678da476f3 100644 --- a/etherlink/bin_node/lib_dev/proxy.ml +++ b/etherlink/bin_node/lib_dev/proxy.ml @@ -85,12 +85,18 @@ let container_forward_tx (type f) ~(chain_family : f L2_types.chain_family) | Michelson -> error_with "Proxy.container_forward_tx not implemented for Tezlink" -let tx_queue_pop_and_inject (module Rollup_node_rpc : Services_backend_sig.S) - ~(tx_container : - L2_types.evm_chain_family Services_backend_sig.tx_container) - ~smart_rollup_address = +let tx_queue_pop_and_inject (type f) + (module Rollup_node_rpc : Services_backend_sig.S) + ~(tx_container : f Services_backend_sig.tx_container) ~smart_rollup_address + = let open Lwt_result_syntax in - let (Evm_tx_container (module Tx_container)) = tx_container in + let*? (module Tx_container) = + let open Result_syntax in + match tx_container with + | Evm_tx_container m -> return m + | Michelson_tx_container _ -> + error_with "Unsupported: Tezlink + Tx_queue + Proxy mode" + in let maximum_cumulative_size = Sequencer_blueprint.maximum_usable_space_in_blueprint Sequencer_blueprint.maximum_chunks_per_l1_level @@ -199,7 +205,7 @@ let main config.experimental_features.enable_tx_queue ) with | true, None, Some tx_queue_config -> - let start, tx_container = Tx_queue.tx_container ~chain_family:EVM in + let start, tx_container = Tx_queue.tx_container ~chain_family in let* () = start ~config:tx_queue_config ~keep_alive:config.keep_alive () in @@ -226,14 +232,14 @@ let main chain_family = Ex_chain_family chain_family; } in - let*? tx_container = Tx_pool.tx_container ~chain_family:EVM in + let*? tx_container = Tx_pool.tx_container ~chain_family in return (Some Tx_pool.pop_and_inject_transactions_lazy, tx_container) | enable_send_raw_transaction, evm_node_endpoint, _ -> let evm_node_endpoint = if enable_send_raw_transaction then evm_node_endpoint else None in let*? tx_container = - container_forward_tx ~chain_family:EVM ~evm_node_endpoint ~keep_alive + container_forward_tx ~chain_family ~evm_node_endpoint ~keep_alive in return (None, tx_container) in diff --git a/etherlink/bin_node/lib_dev/rpc.ml b/etherlink/bin_node/lib_dev/rpc.ml index 92f7a4bb6689..768d1880533e 100644 --- a/etherlink/bin_node/lib_dev/rpc.ml +++ b/etherlink/bin_node/lib_dev/rpc.ml @@ -288,7 +288,7 @@ let main ~data_dir ~evm_node_endpoint ?evm_node_private_endpoint | Some private_endpoint, _ -> let forward_request = container_forward_request - ~chain_family:L2_types.EVM + ~chain_family ~keep_alive:config.keep_alive ~public_endpoint:evm_node_endpoint ~private_endpoint @@ -296,15 +296,13 @@ let main ~data_dir ~evm_node_endpoint ?evm_node_private_endpoint return (false, forward_request) | None, Some tx_queue_config -> - let start, tx_container = - Tx_queue.tx_container ~chain_family:L2_types.EVM - in + let start, tx_container = Tx_queue.tx_container ~chain_family in let* () = start ~config:tx_queue_config ~keep_alive:config.keep_alive () in return (false, tx_container) | None, None -> - let*? tx_container = Tx_pool.tx_container ~chain_family:EVM in + let*? tx_container = Tx_pool.tx_container ~chain_family in let* () = Tx_pool.start ~tx_pool_parameters: diff --git a/etherlink/bin_node/lib_dev/rpc_server.mli b/etherlink/bin_node/lib_dev/rpc_server.mli index 6b1c54d9a135..9e26a04c3587 100644 --- a/etherlink/bin_node/lib_dev/rpc_server.mli +++ b/etherlink/bin_node/lib_dev/rpc_server.mli @@ -32,10 +32,10 @@ type block_production = [`Single_node | `Disabled] sequencer setup, [`Disabled] means no block production method is available. *) val start_private_server : - rpc_server_family:_ Rpc_types.rpc_server_family -> + rpc_server_family:'f Rpc_types.rpc_server_family -> ?block_production:block_production -> Configuration.t -> - _ Services_backend_sig.tx_container -> + 'f Services_backend_sig.tx_container -> (module Services_backend_sig.S) * 'a -> finalizer tzresult Lwt.t @@ -48,13 +48,13 @@ val start_private_server : If [data_dir] is provided and the host provides the necessary binaries, performance metrics are enabled. *) val start_public_server : - rpc_server_family:_ Rpc_types.rpc_server_family -> + rpc_server_family:'f Rpc_types.rpc_server_family -> l2_chain_id:L2_types.chain_id option -> ?delegate_health_check_to:Uri.t -> ?evm_services:evm_services_methods -> ?data_dir:string -> Validate.validation_mode -> Configuration.t -> - _ Services_backend_sig.tx_container -> + 'f Services_backend_sig.tx_container -> (module Services_backend_sig.S) * 'a -> finalizer tzresult Lwt.t diff --git a/etherlink/bin_node/lib_dev/services.ml b/etherlink/bin_node/lib_dev/services.ml index e0cba86ef339..d4a1aaef7db2 100644 --- a/etherlink/bin_node/lib_dev/services.ml +++ b/etherlink/bin_node/lib_dev/services.ml @@ -488,7 +488,7 @@ let process_trace_result trace = rpc_error (Rpc_errors.internal_error msg) let dispatch_request (type f) ~websocket - (rpc_server_family : _ Rpc_types.rpc_server_family) + (rpc_server_family : f Rpc_types.rpc_server_family) (rpc : Configuration.rpc) (validation : Validate.validation_mode) (config : Configuration.t) (tx_container : f Services_backend_sig.tx_container) @@ -1065,7 +1065,7 @@ let dispatch_request (type f) ~websocket Lwt.return JSONRPC.{value; id} let dispatch_private_request (type f) ~websocket - (rpc_server_family : _ Rpc_types.rpc_server_family) + (rpc_server_family : f Rpc_types.rpc_server_family) (rpc : Configuration.rpc) (config : Configuration.t) (tx_container : f Services_backend_sig.tx_container) ((module Backend_rpc : Services_backend_sig.S), _) ~block_production -- GitLab From cf1d1a7076c4af73e830f497b1c0e951f40872c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Cauderlier?= Date: Fri, 20 Jun 2025 10:47:36 +0200 Subject: [PATCH 5/5] Tezlink/Tests: enable the tx-queue --- etherlink/tezt/tests/evm_sequencer.ml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/etherlink/tezt/tests/evm_sequencer.ml b/etherlink/tezt/tests/evm_sequencer.ml index 796118875bf3..fa8a4b17affe 100644 --- a/etherlink/tezt/tests/evm_sequencer.ml +++ b/etherlink/tezt/tests/evm_sequencer.ml @@ -371,8 +371,6 @@ let register_upgrade_all ~title ~tags ~genesis_timestamp let register_tezlink_test ~title ~tags ?tez_bootstrap_accounts ?tez_bootstrap_contracts scenario protocols = register_all - ~enable_tx_queue:Evm_node.(Enable false) - (*Tx queue is not yet compatible with tezlink *) ~kernels:[Kernel.Latest] ~title ~tags:("tezlink" :: tags) @@ -748,8 +746,6 @@ let test_tezlink_constants = ~mainnet_compat:false ~enable_dal:false ~enable_multichain:true - ~enable_tx_queue:(Enable false) - (* Tezlink is not yet compatible with the tx_queue *) ~l2_chains ~rpc_server:Evm_node.Resto ~spawn_rpc:(Port.fresh ()) @@ -10871,8 +10867,6 @@ let test_describe_endpoint = ~mainnet_compat:false ~enable_dal:false ~enable_multichain:true - ~enable_tx_queue:(Enable false) - (* Tezlink is not yet compatible with the tx_queue *) ~l2_chains ~rpc_server:Evm_node.Resto ~spawn_rpc:(Port.fresh ()) -- GitLab