diff --git a/etherlink/bin_node/lib_dev/observer.ml b/etherlink/bin_node/lib_dev/observer.ml index b0ad1562e1f85a62553054f68273a21e31d59a7c..555894127d9ca252aa921ff1d04690d116009ccb 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 @@ -121,9 +127,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 +173,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 () = @@ -209,22 +226,38 @@ 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* 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 - ( (fun ~tx_pool_parameters:_ -> - start ~config:tx_queue_config ~keep_alive:config.keep_alive ()), - tx_container, - false ) + 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 ()), + tx_container, + false ) | None -> if config.finalized_view then - ( (fun ~tx_pool_parameters:_ -> return_unit), + let* tx_container = container_forward_tx + ~chain_family ~keep_alive:config.keep_alive - ~evm_node_endpoint, - false ) - else (Tx_pool.start, Tx_pool.tx_container, true) + ~evm_node_endpoint + in + return + ( (fun ~tx_pool_parameters:_ -> Lwt_result_syntax.return_unit), + tx_container, + false ) + else + let* tx_container = Tx_pool.tx_container ~chain_family in + return (Tx_pool.start, tx_container, true) in let* _loaded = @@ -253,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 19bab2ce033456b20b86db79c9a50a0e8b08c9fe..23678da476f34947d7468508a6952a7b23b0d759 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,14 +73,30 @@ 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 : - 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 @@ -188,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 @@ -215,13 +232,16 @@ 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 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 - return @@ (None, container_forward_tx ~evm_node_endpoint ~keep_alive) + let*? tx_container = + container_forward_tx ~chain_family ~evm_node_endpoint ~keep_alive + in + return (None, tx_container) in let () = Rollup_node_follower.start diff --git a/etherlink/bin_node/lib_dev/rpc.ml b/etherlink/bin_node/lib_dev/rpc.ml index affdb48026aaf96e6f537546e07b04036dc1da38..768d1880533e921df1c5031ec43523b19ce3a8d8 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 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 6b1c54d9a135bbdc8d84cb02012d429ff5e33879..9e26a04c3587a7de11d24fa8b5a8bffb51b96048 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/sequencer.ml b/etherlink/bin_node/lib_dev/sequencer.ml index 9594369540c349acea281cd27ebd78b23ddcef0c..fc814569f51a284c209cfb682a853ac9f59d509e 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/services.ml b/etherlink/bin_node/lib_dev/services.ml index e0cba86ef3394df3e559770d9f702e670afb9e44..d4a1aaef7db2c6e4faedeabefc9a4a3a78901ecf 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 diff --git a/etherlink/bin_node/lib_dev/tx_pool.ml b/etherlink/bin_node/lib_dev/tx_pool.ml index d1eac3019ccc62e33ea9e7337aa2468938ed6e18..025dfff3b8659dbe967a959c4a5920646fb70ff8 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 d84a76baad61fd67e332fae02d4b5a320d90ec4f..e6f9fbf3965f42bb8fee1fec30569f2017c796a1 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 diff --git a/etherlink/tezt/tests/evm_sequencer.ml b/etherlink/tezt/tests/evm_sequencer.ml index 796118875bf32ad8b0811da71958268760e5d410..fa8a4b17affe3bb3385c6bd62b4b968749883b38 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 ())