From 7dfb2acbdbfc01d1d4f93952cb15a123f2c45e31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Cauderlier?= Date: Wed, 11 Jun 2025 22:38:21 +0200 Subject: [PATCH 1/4] Etherlink/Node/Tx_queue: tx_container also returns the start function --- etherlink/bin_node/lib_dev/observer.ml | 51 +++++++++---------- etherlink/bin_node/lib_dev/proxy.ml | 28 +++++----- etherlink/bin_node/lib_dev/rpc.ml | 36 ++++++------- etherlink/bin_node/lib_dev/sequencer.ml | 47 +++++++++-------- etherlink/bin_node/lib_dev/services.ml | 9 ++-- etherlink/bin_node/lib_dev/tx_pool.ml | 4 +- etherlink/bin_node/lib_dev/tx_pool.mli | 2 +- etherlink/bin_node/lib_dev/tx_queue.ml | 5 +- etherlink/bin_node/lib_dev/tx_queue.mli | 17 +++---- etherlink/bin_node/main.ml | 15 ++++-- .../fa-bridge-watchtower/etherlink_monitor.ml | 2 +- 11 files changed, 112 insertions(+), 104 deletions(-) diff --git a/etherlink/bin_node/lib_dev/observer.ml b/etherlink/bin_node/lib_dev/observer.ml index e26bf8fb6479..8acbd60449f2 100644 --- a/etherlink/bin_node/lib_dev/observer.ml +++ b/etherlink/bin_node/lib_dev/observer.ml @@ -206,18 +206,22 @@ let main ?network ?kernel_path ~data_dir ~(config : Configuration.t) ~no_sync init_from_snapshot in - let tx_container, ping_tx_pool = + let start_tx_container, tx_container, ping_tx_pool = match config.experimental_features.enable_tx_queue with - | Some _tx_queue_config -> (Tx_queue.tx_container, false) + | Some tx_queue_config -> + let start, tx_container = Tx_queue.tx_container in + ( (fun ~tx_pool_parameters:_ -> + start ~config:tx_queue_config ~keep_alive:config.keep_alive ()), + tx_container, + false ) | None -> if config.finalized_view then - let tx_container = + ( (fun ~tx_pool_parameters:_ -> return_unit), container_forward_tx ~keep_alive:config.keep_alive - ~evm_node_endpoint - in - (tx_container, false) - else (Tx_pool.tx_container, true) + ~evm_node_endpoint, + false ) + else (Tx_pool.start, Tx_pool.tx_container, true) in let* _loaded = @@ -253,25 +257,20 @@ let main ?network ?kernel_path ~data_dir ~(config : Configuration.t) ~no_sync in let* () = - match config.experimental_features.enable_tx_queue with - | Some tx_queue_config -> - Tx_queue.start ~config:tx_queue_config ~keep_alive:config.keep_alive () - | None -> - if config.finalized_view then return_unit - else - Tx_pool.start - { - backend = observer_backend; - smart_rollup_address = - Tezos_crypto.Hashed.Smart_rollup_address.to_b58check - smart_rollup_address; - mode = Relay; - tx_timeout_limit = config.tx_pool_timeout_limit; - tx_pool_addr_limit = Int64.to_int config.tx_pool_addr_limit; - tx_pool_tx_per_addr_limit = - Int64.to_int config.tx_pool_tx_per_addr_limit; - chain_family = Ex_chain_family chain_family; - } + start_tx_container + ~tx_pool_parameters: + { + backend = observer_backend; + smart_rollup_address = + Tezos_crypto.Hashed.Smart_rollup_address.to_b58check + smart_rollup_address; + mode = Relay; + tx_timeout_limit = config.tx_pool_timeout_limit; + tx_pool_addr_limit = Int64.to_int config.tx_pool_addr_limit; + tx_pool_tx_per_addr_limit = + Int64.to_int config.tx_pool_tx_per_addr_limit; + chain_family = Ex_chain_family chain_family; + } in Metrics.init diff --git a/etherlink/bin_node/lib_dev/proxy.ml b/etherlink/bin_node/lib_dev/proxy.ml index f6a7354ac719..58e718502af6 100644 --- a/etherlink/bin_node/lib_dev/proxy.ml +++ b/etherlink/bin_node/lib_dev/proxy.ml @@ -188,13 +188,10 @@ let main config.experimental_features.enable_tx_queue ) with | true, None, Some tx_queue_config -> + let start, tx_container = Tx_queue.tx_container in let* () = - Tx_queue.start - ~config:tx_queue_config - ~keep_alive:config.keep_alive - () + start ~config:tx_queue_config ~keep_alive:config.keep_alive () in - let tx_container = Tx_queue.tx_container in return @@ ( Some (fun () -> @@ -206,16 +203,17 @@ let main | true, None, None -> let* () = Tx_pool.start - { - backend = (module Rollup_node_rpc); - smart_rollup_address; - mode = Proxy; - tx_timeout_limit = config.tx_pool_timeout_limit; - tx_pool_addr_limit = Int64.to_int config.tx_pool_addr_limit; - tx_pool_tx_per_addr_limit = - Int64.to_int config.tx_pool_tx_per_addr_limit; - chain_family = Ex_chain_family chain_family; - } + ~tx_pool_parameters: + { + backend = (module Rollup_node_rpc); + smart_rollup_address; + mode = Proxy; + tx_timeout_limit = config.tx_pool_timeout_limit; + tx_pool_addr_limit = Int64.to_int config.tx_pool_addr_limit; + tx_pool_tx_per_addr_limit = + Int64.to_int config.tx_pool_tx_per_addr_limit; + chain_family = Ex_chain_family chain_family; + } in return (Some Tx_pool.pop_and_inject_transactions_lazy, Tx_pool.tx_container) diff --git a/etherlink/bin_node/lib_dev/rpc.ml b/etherlink/bin_node/lib_dev/rpc.ml index c10924dd36fe..c08629340d34 100644 --- a/etherlink/bin_node/lib_dev/rpc.ml +++ b/etherlink/bin_node/lib_dev/rpc.ml @@ -214,30 +214,30 @@ 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 in let* () = - Tx_queue.start - ~config:tx_queue_config - ~keep_alive:config.keep_alive - () + start ~config:tx_queue_config ~keep_alive:config.keep_alive () in - return (false, Tx_queue.tx_container) + return (false, tx_container) | None, None -> + let tx_container = Tx_pool.tx_container in let* () = Tx_pool.start - { - backend = rpc_backend; - smart_rollup_address = - Tezos_crypto.Hashed.Smart_rollup_address.to_b58check - ctxt.smart_rollup_address; - mode = Relay; - tx_timeout_limit = config.tx_pool_timeout_limit; - tx_pool_addr_limit = Int64.to_int config.tx_pool_addr_limit; - tx_pool_tx_per_addr_limit = - Int64.to_int config.tx_pool_tx_per_addr_limit; - chain_family = Ex_chain_family chain_family; - } + ~tx_pool_parameters: + { + backend = rpc_backend; + smart_rollup_address = + Tezos_crypto.Hashed.Smart_rollup_address.to_b58check + ctxt.smart_rollup_address; + mode = Relay; + tx_timeout_limit = config.tx_pool_timeout_limit; + tx_pool_addr_limit = Int64.to_int config.tx_pool_addr_limit; + tx_pool_tx_per_addr_limit = + Int64.to_int config.tx_pool_tx_per_addr_limit; + chain_family = Ex_chain_family chain_family; + } in - return (true, Tx_pool.tx_container) + return (true, tx_container) in let* () = set_metrics_level ctxt in diff --git a/etherlink/bin_node/lib_dev/sequencer.ml b/etherlink/bin_node/lib_dev/sequencer.ml index 05f805f6d3ca..2df737e56f5d 100644 --- a/etherlink/bin_node/lib_dev/sequencer.ml +++ b/etherlink/bin_node/lib_dev/sequencer.ml @@ -181,10 +181,21 @@ let main ~data_dir ?(genesis_timestamp = Misc.now ()) ~cctxt init_from_snapshot | None -> Result.return_none in - let* tx_container = + (* The Tx_pool parameters are ignored by the start function when a + Tx_queue is configured. + + TODO: simplify start_tx_container when removing the Tx_pool. *) + let start_tx_container, tx_container = match configuration.experimental_features.enable_tx_queue with - | Some _tx_queue_config -> return Tx_queue.tx_container - | None -> return Tx_pool.tx_container + | Some tx_queue_config -> + let start, tx_container = Tx_queue.tx_container 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) in let (module Tx_container) = Services_backend_sig.tx_container_module tx_container @@ -338,24 +349,18 @@ let main ~data_dir ?(genesis_timestamp = Misc.now ()) ~cctxt Backend.single_chain_id_and_family ~config:configuration ~enable_multichain in let* () = - match configuration.experimental_features.enable_tx_queue with - | Some tx_queue_config -> - Tx_queue.start - ~config:tx_queue_config - ~keep_alive:configuration.keep_alive - () - | None -> - Tx_pool.start - { - backend; - smart_rollup_address = smart_rollup_address_b58; - mode = Sequencer; - tx_timeout_limit = configuration.tx_pool_timeout_limit; - tx_pool_addr_limit = Int64.to_int configuration.tx_pool_addr_limit; - tx_pool_tx_per_addr_limit = - Int64.to_int configuration.tx_pool_tx_per_addr_limit; - chain_family = Ex_chain_family chain_family; - } + start_tx_container + ~tx_pool_parameters: + { + backend; + smart_rollup_address = smart_rollup_address_b58; + mode = Sequencer; + tx_timeout_limit = configuration.tx_pool_timeout_limit; + tx_pool_addr_limit = Int64.to_int configuration.tx_pool_addr_limit; + tx_pool_tx_per_addr_limit = + Int64.to_int configuration.tx_pool_tx_per_addr_limit; + chain_family = Ex_chain_family chain_family; + } in Metrics.init ~mode:"sequencer" diff --git a/etherlink/bin_node/lib_dev/services.ml b/etherlink/bin_node/lib_dev/services.ml index 311bd6fe8bb5..7f9cb2249f20 100644 --- a/etherlink/bin_node/lib_dev/services.ml +++ b/etherlink/bin_node/lib_dev/services.ml @@ -1429,9 +1429,8 @@ let dispatch_websocket_private (type f) "/private/ws" (dispatch_private_websocket rpc_server_family ~block_production rpc) -let directory (type f) ~rpc_server_family ?delegate_health_check_to rpc - validation config (tx_container : f Services_backend_sig.tx_container) - backend dir = +let directory ~rpc_server_family ?delegate_health_check_to rpc validation config + (tx_container : _ Services_backend_sig.tx_container) backend dir = dir |> version |> configuration config |> health_check ?delegate_to:delegate_health_check_to |> dispatch_public @@ -1449,8 +1448,8 @@ let directory (type f) ~rpc_server_family ?delegate_health_check_to rpc tx_container backend -let private_directory (type f) ~rpc_server_family rpc config - (tx_container : f Services_backend_sig.tx_container) backend +let private_directory ~rpc_server_family rpc config + (tx_container : _ Services_backend_sig.tx_container) backend ~block_production = Evm_directory.empty config.experimental_features.rpc_server |> version diff --git a/etherlink/bin_node/lib_dev/tx_pool.ml b/etherlink/bin_node/lib_dev/tx_pool.ml index c9d8deaa6077..d1eac3019ccc 100644 --- a/etherlink/bin_node/lib_dev/tx_pool.ml +++ b/etherlink/bin_node/lib_dev/tx_pool.ml @@ -803,9 +803,9 @@ let handle_request_error rq = | Error (Closed (Some errs)) -> Lwt.return_error errs | Error (Any exn) -> Lwt.return_error [Exn exn] -let start parameters = +let start ~tx_pool_parameters = let open Lwt_result_syntax in - let+ worker = Worker.launch table () parameters (module Handlers) in + let+ worker = Worker.launch table () tx_pool_parameters (module Handlers) in Lwt.wakeup worker_waker worker let add transaction_object raw_tx = diff --git a/etherlink/bin_node/lib_dev/tx_pool.mli b/etherlink/bin_node/lib_dev/tx_pool.mli index 3d8fc89ced37..d84a76baad61 100644 --- a/etherlink/bin_node/lib_dev/tx_pool.mli +++ b/etherlink/bin_node/lib_dev/tx_pool.mli @@ -24,7 +24,7 @@ type parameters = { } (** [start parameters] starts the tx-pool *) -val start : parameters -> unit tzresult Lwt.t +val start : tx_pool_parameters:parameters -> unit tzresult Lwt.t (** [pop_transactions chain_family maximum_cumulative_size] pops as much valid transactions as possible from the pool, until their cumulative diff --git a/etherlink/bin_node/lib_dev/tx_queue.ml b/etherlink/bin_node/lib_dev/tx_queue.ml index d672117f1bd4..bb4f2adcf611 100644 --- a/etherlink/bin_node/lib_dev/tx_queue.ml +++ b/etherlink/bin_node/lib_dev/tx_queue.ml @@ -1209,10 +1209,9 @@ module Eth_tx_container = let chain_name = "etherlink" end) -let start = Eth_tx_container.start - let tx_container = - Services_backend_sig.Evm_tx_container (module Eth_tx_container) + ( Eth_tx_container.start, + Services_backend_sig.Evm_tx_container (module Eth_tx_container) ) module Internal_for_tests = struct module Nonce_bitset = Nonce_bitset diff --git a/etherlink/bin_node/lib_dev/tx_queue.mli b/etherlink/bin_node/lib_dev/tx_queue.mli index 1c3f7a149460..d4e75b7e5c92 100644 --- a/etherlink/bin_node/lib_dev/tx_queue.mli +++ b/etherlink/bin_node/lib_dev/tx_queue.mli @@ -24,18 +24,17 @@ [callback] is called with [`Dropped].}} *) type callback = [`Accepted | `Confirmed | `Dropped | `Refused] -> unit Lwt.t -(** [start ~config ~max_transaction_batch_length ()] starts the +(** [tx_container] is a pair [(start, container)] where + [start ~config ~max_transaction_batch_length ()] starts the worker, meaning it is possible to call {!inject}, {!confirm} and - {!beacon}. *) -val start : - config:Configuration.tx_queue -> + {!beacon} and [container] is a wrapper of the Tx_queue to be + compatible with the Tx_container signature for the services. *) +val tx_container : + (config:Configuration.tx_queue -> keep_alive:bool -> unit -> - unit tzresult Lwt.t - -(** wrapper of the Tx_queue to be compatible with the Tx_container - signature for the services. *) -val tx_container : L2_types.evm_chain_family Services_backend_sig.tx_container + unit tzresult Lwt.t) + * L2_types.evm_chain_family Services_backend_sig.tx_container (**/*) diff --git a/etherlink/bin_node/main.ml b/etherlink/bin_node/main.ml index b0899e1e2229..1116cc41719f 100644 --- a/etherlink/bin_node/main.ml +++ b/etherlink/bin_node/main.ml @@ -1582,12 +1582,15 @@ let init_from_rollup_node_command = let config_file = config_filename ~data_dir config_file in let* configuration = Cli.create_or_read_config ~data_dir config_file in let*! () = init_logs ~daily_logs:false ~data_dir configuration in + let _start_tx_queue, tx_container = + Evm_node_lib_dev.Tx_queue.tx_container + in Evm_node_lib_dev.Evm_context.init_from_rollup_node ~configuration ~omit_delayed_tx_events ~data_dir ~rollup_node_data_dir - ~tx_container:Evm_node_lib_dev.Tx_queue.tx_container + ~tx_container ()) let dump_to_rlp_command = @@ -1797,12 +1800,15 @@ let patch_kernel_command = to interact with an upstream EVM node. *) let configuration = {configuration with observer = None} in if force then + let _start_tx_queue, tx_container = + Evm_node_lib_dev.Tx_queue.tx_container + in let* _status = Evm_context.start ~configuration ~data_dir ~store_perm:Read_write - ~tx_container:Evm_node_lib_dev.Tx_queue.tx_container + ~tx_container () in Evm_context.patch_kernel ?block_number (On_disk kernel_path) @@ -3058,12 +3064,15 @@ let patch_state_command = (* We remove the [observer] configuration. This [patch] should not need to interact with an upstream EVM node. *) let configuration = {configuration with observer = None} in + let _start_tx_queue, tx_container = + Evm_node_lib_dev.Tx_queue.tx_container + in let* _status = Evm_context.start ~configuration ~data_dir ~store_perm:Read_write - ~tx_container:Evm_node_lib_dev.Tx_queue.tx_container + ~tx_container () in Evm_context.patch_state ?block_number ~key ~value () diff --git a/etherlink/fa-bridge-watchtower/etherlink_monitor.ml b/etherlink/fa-bridge-watchtower/etherlink_monitor.ml index c79456f673dc..e13f6b4131c8 100644 --- a/etherlink/fa-bridge-watchtower/etherlink_monitor.ml +++ b/etherlink/fa-bridge-watchtower/etherlink_monitor.ml @@ -54,7 +54,7 @@ end module Tx_queue = struct include Tx_queue - let (Services_backend_sig.Evm_tx_container tx_container) = tx_container + let start, Services_backend_sig.Evm_tx_container tx_container = tx_container let ( let**? ) v f = let open Lwt_result_syntax in -- GitLab From eff9bb14ff7e064de08950afd142d3df18d5edc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Cauderlier?= Date: Sun, 18 May 2025 01:57:50 +0200 Subject: [PATCH 2/4] Tezlink/Node: define Tezlink operations --- .../bin_node/lib_dev/tezlink/tezos_types.ml | 16 ++++++++++++++++ .../bin_node/lib_dev/tezlink/tezos_types.mli | 11 +++++++++++ 2 files changed, 27 insertions(+) diff --git a/etherlink/bin_node/lib_dev/tezlink/tezos_types.ml b/etherlink/bin_node/lib_dev/tezlink/tezos_types.ml index 44cf253e998a..49b5e26be5c0 100644 --- a/etherlink/bin_node/lib_dev/tezlink/tezos_types.ml +++ b/etherlink/bin_node/lib_dev/tezlink/tezos_types.ml @@ -59,6 +59,22 @@ module Contract = struct @@ Tezlink_imports.Alpha_context.Contract.of_b58check s end +module Operation = struct + module ImportedOperation = Tezlink_imports.Alpha_context.Operation + + type t = { + source : Signature.V1.public_key_hash; + counter : Z.t; + op : Tezlink_imports.Alpha_context.packed_operation; + raw : bytes; + } + + let hash_operation {source = _; counter = _; op; raw = _} = + let hash = ImportedOperation.hash_packed op in + let (`Hex hex) = Operation_hash.to_hex hash in + Ethereum_types.Hash (Ethereum_types.Hex hex) +end + module Tez = struct include Tezlink_imports.Alpha_context.Tez diff --git a/etherlink/bin_node/lib_dev/tezlink/tezos_types.mli b/etherlink/bin_node/lib_dev/tezlink/tezos_types.mli index 0f9e836bddfb..2e0ca089f0c3 100644 --- a/etherlink/bin_node/lib_dev/tezlink/tezos_types.mli +++ b/etherlink/bin_node/lib_dev/tezlink/tezos_types.mli @@ -44,6 +44,17 @@ module Contract : sig val of_implicit : Signature.V1.public_key_hash -> t end +module Operation : sig + type t = { + source : Signature.V1.public_key_hash; + counter : Z.t; + op : Tezlink_imports.Alpha_context.packed_operation; + raw : bytes; + } + + val hash_operation : t -> Ethereum_types.hash +end + module Tez : sig include module type of Tezlink_imports.Alpha_context.Tez -- GitLab From 92431eb1d54cc0ba6e9a2414ec39bb5e806dfd9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Cauderlier?= Date: Fri, 13 Jun 2025 14:15:06 +0200 Subject: [PATCH 3/4] Tezlink/Node: Tezlink implementation of L2_transaction --- etherlink/bin_node/lib_dev/tx_queue_types.ml | 34 +++++++++++++++++++ etherlink/bin_node/lib_dev/tx_queue_types.mli | 3 ++ 2 files changed, 37 insertions(+) diff --git a/etherlink/bin_node/lib_dev/tx_queue_types.ml b/etherlink/bin_node/lib_dev/tx_queue_types.ml index bc3d418a8e30..0bb6bc9190bd 100644 --- a/etherlink/bin_node/lib_dev/tx_queue_types.ml +++ b/etherlink/bin_node/lib_dev/tx_queue_types.ml @@ -65,3 +65,37 @@ module Eth_transaction_object : let make_txpool ~pending ~queued = {pending; queued} end + +module Tezlink_operation : + L2_transaction + with type t = Tezos_types.Operation.t + and type legacy = Tezos_types.Operation.t = struct + open Ethereum_types + + type t = Tezos_types.Operation.t + + type legacy = Tezos_types.Operation.t + + type address = Signature.V1.public_key_hash + + let address_encoding = Signature.V1.Public_key_hash.encoding + + let hash_of_tx_object = Tezos_types.Operation.hash_operation + + let address_to_string = Signature.V1.Public_key_hash.to_string + + let from_address_of_tx_object (op : Tezos_types.Operation.t) = op.source + + let nonce_of_tx_object (op : Tezos_types.Operation.t) = + Ethereum_types.Qty op.counter + + let transaction_object_from_legacy op = op + + module AddressMap = Map.Make (Signature.V1.Public_key_hash) + + let make_txpool ~pending:_ ~queued:_ = + { + pending = Ethereum_types.AddressMap.empty; + queued = Ethereum_types.AddressMap.empty; + } +end diff --git a/etherlink/bin_node/lib_dev/tx_queue_types.mli b/etherlink/bin_node/lib_dev/tx_queue_types.mli index d00734a2e4d2..a9fd58b1804c 100644 --- a/etherlink/bin_node/lib_dev/tx_queue_types.mli +++ b/etherlink/bin_node/lib_dev/tx_queue_types.mli @@ -38,3 +38,6 @@ module Eth_transaction_object : and type legacy = Ethereum_types.legacy_transaction_object and type address = Ethereum_types.address and module AddressMap = Ethereum_types.AddressMap + +module Tezlink_operation : + L2_transaction with type legacy = Tezos_types.Operation.t -- GitLab From f8c44574423049d6f68603926d14a1a7d4a08f33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Cauderlier?= Date: Tue, 29 Apr 2025 14:19:55 +0200 Subject: [PATCH 4/4] Tezlink/Node/Tx_queue: support Tezlink --- etherlink/bin_node/lib_dev/observer.ml | 2 +- etherlink/bin_node/lib_dev/proxy.ml | 2 +- etherlink/bin_node/lib_dev/rpc.ml | 4 +++- etherlink/bin_node/lib_dev/sequencer.ml | 2 +- etherlink/bin_node/lib_dev/tx_queue.ml | 20 ++++++++++++++++--- etherlink/bin_node/lib_dev/tx_queue.mli | 5 +++-- etherlink/bin_node/main.ml | 6 +++--- .../fa-bridge-watchtower/etherlink_monitor.ml | 3 ++- 8 files changed, 31 insertions(+), 13 deletions(-) diff --git a/etherlink/bin_node/lib_dev/observer.ml b/etherlink/bin_node/lib_dev/observer.ml index 8acbd60449f2..b4faabd2aa06 100644 --- a/etherlink/bin_node/lib_dev/observer.ml +++ b/etherlink/bin_node/lib_dev/observer.ml @@ -209,7 +209,7 @@ let main ?network ?kernel_path ~data_dir ~(config : Configuration.t) ~no_sync let start_tx_container, tx_container, ping_tx_pool = match config.experimental_features.enable_tx_queue with | Some tx_queue_config -> - let start, tx_container = Tx_queue.tx_container in + 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, diff --git a/etherlink/bin_node/lib_dev/proxy.ml b/etherlink/bin_node/lib_dev/proxy.ml index 58e718502af6..19bab2ce0334 100644 --- a/etherlink/bin_node/lib_dev/proxy.ml +++ b/etherlink/bin_node/lib_dev/proxy.ml @@ -188,7 +188,7 @@ let main config.experimental_features.enable_tx_queue ) with | true, None, Some tx_queue_config -> - let start, tx_container = Tx_queue.tx_container in + let start, tx_container = Tx_queue.tx_container ~chain_family:EVM in let* () = start ~config:tx_queue_config ~keep_alive:config.keep_alive () in diff --git a/etherlink/bin_node/lib_dev/rpc.ml b/etherlink/bin_node/lib_dev/rpc.ml index c08629340d34..cee90c95f339 100644 --- a/etherlink/bin_node/lib_dev/rpc.ml +++ b/etherlink/bin_node/lib_dev/rpc.ml @@ -214,7 +214,9 @@ 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 in + let start, tx_container = + Tx_queue.tx_container ~chain_family:L2_types.EVM + in let* () = start ~config:tx_queue_config ~keep_alive:config.keep_alive () in diff --git a/etherlink/bin_node/lib_dev/sequencer.ml b/etherlink/bin_node/lib_dev/sequencer.ml index 2df737e56f5d..a7bf86e30573 100644 --- a/etherlink/bin_node/lib_dev/sequencer.ml +++ b/etherlink/bin_node/lib_dev/sequencer.ml @@ -188,7 +188,7 @@ let main ~data_dir ?(genesis_timestamp = Misc.now ()) ~cctxt let start_tx_container, tx_container = match configuration.experimental_features.enable_tx_queue with | Some tx_queue_config -> - let start, tx_container = Tx_queue.tx_container in + let start, tx_container = Tx_queue.tx_container ~chain_family:EVM in ( (fun ~tx_pool_parameters:_ -> start ~config:tx_queue_config diff --git a/etherlink/bin_node/lib_dev/tx_queue.ml b/etherlink/bin_node/lib_dev/tx_queue.ml index bb4f2adcf611..43bf1224797b 100644 --- a/etherlink/bin_node/lib_dev/tx_queue.ml +++ b/etherlink/bin_node/lib_dev/tx_queue.ml @@ -1209,9 +1209,23 @@ module Eth_tx_container = let chain_name = "etherlink" end) -let tx_container = - ( Eth_tx_container.start, - Services_backend_sig.Evm_tx_container (module Eth_tx_container) ) +module Tezlink_tx_container = + Tx_container + (Tx_queue_types.Tezlink_operation) + (struct + let chain_name = "tezlink" + end) + +let tx_container (type f) ~(chain_family : f L2_types.chain_family) : + _ * f Services_backend_sig.tx_container = + match chain_family with + | EVM -> + ( Eth_tx_container.start, + Services_backend_sig.Evm_tx_container (module Eth_tx_container) ) + | Michelson -> + ( Tezlink_tx_container.start, + Services_backend_sig.Michelson_tx_container + (module Tezlink_tx_container) ) module Internal_for_tests = struct module Nonce_bitset = Nonce_bitset diff --git a/etherlink/bin_node/lib_dev/tx_queue.mli b/etherlink/bin_node/lib_dev/tx_queue.mli index d4e75b7e5c92..d6290bac58f7 100644 --- a/etherlink/bin_node/lib_dev/tx_queue.mli +++ b/etherlink/bin_node/lib_dev/tx_queue.mli @@ -24,17 +24,18 @@ [callback] is called with [`Dropped].}} *) type callback = [`Accepted | `Confirmed | `Dropped | `Refused] -> unit Lwt.t -(** [tx_container] is a pair [(start, container)] where +(** [tx_container ~chain_family] is a pair [(start, container)] where [start ~config ~max_transaction_batch_length ()] starts the worker, meaning it is possible to call {!inject}, {!confirm} and {!beacon} and [container] is a wrapper of the Tx_queue to be compatible with the Tx_container signature for the services. *) val tx_container : + chain_family:'f L2_types.chain_family -> (config:Configuration.tx_queue -> keep_alive:bool -> unit -> unit tzresult Lwt.t) - * L2_types.evm_chain_family Services_backend_sig.tx_container + * 'f Services_backend_sig.tx_container (**/*) diff --git a/etherlink/bin_node/main.ml b/etherlink/bin_node/main.ml index 1116cc41719f..661130567c6f 100644 --- a/etherlink/bin_node/main.ml +++ b/etherlink/bin_node/main.ml @@ -1583,7 +1583,7 @@ let init_from_rollup_node_command = let* configuration = Cli.create_or_read_config ~data_dir config_file in let*! () = init_logs ~daily_logs:false ~data_dir configuration in let _start_tx_queue, tx_container = - Evm_node_lib_dev.Tx_queue.tx_container + Evm_node_lib_dev.Tx_queue.tx_container ~chain_family:EVM in Evm_node_lib_dev.Evm_context.init_from_rollup_node ~configuration @@ -1801,7 +1801,7 @@ let patch_kernel_command = let configuration = {configuration with observer = None} in if force then let _start_tx_queue, tx_container = - Evm_node_lib_dev.Tx_queue.tx_container + Evm_node_lib_dev.Tx_queue.tx_container ~chain_family:EVM in let* _status = Evm_context.start @@ -3065,7 +3065,7 @@ let patch_state_command = to interact with an upstream EVM node. *) let configuration = {configuration with observer = None} in let _start_tx_queue, tx_container = - Evm_node_lib_dev.Tx_queue.tx_container + Evm_node_lib_dev.Tx_queue.tx_container ~chain_family:EVM in let* _status = Evm_context.start diff --git a/etherlink/fa-bridge-watchtower/etherlink_monitor.ml b/etherlink/fa-bridge-watchtower/etherlink_monitor.ml index e13f6b4131c8..27989d1876c1 100644 --- a/etherlink/fa-bridge-watchtower/etherlink_monitor.ml +++ b/etherlink/fa-bridge-watchtower/etherlink_monitor.ml @@ -54,7 +54,8 @@ end module Tx_queue = struct include Tx_queue - let start, Services_backend_sig.Evm_tx_container tx_container = tx_container + let start, Services_backend_sig.Evm_tx_container tx_container = + tx_container ~chain_family:EVM let ( let**? ) v f = let open Lwt_result_syntax in -- GitLab