From dedd070a5549b2c6f4cb1b2cc766347dff3031c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Cauderlier?= Date: Fri, 16 May 2025 19:59:26 +0200 Subject: [PATCH 01/14] EVM node: factorize code reading and checking l2_chain id and family --- etherlink/bin_node/lib_dev/observer.ml | 24 +--------- etherlink/bin_node/lib_dev/proxy.ml | 21 +-------- etherlink/bin_node/lib_dev/rpc.ml | 23 +--------- .../bin_node/lib_dev/services_backend_sig.ml | 46 +++++++++++++++++++ 4 files changed, 51 insertions(+), 63 deletions(-) diff --git a/etherlink/bin_node/lib_dev/observer.ml b/etherlink/bin_node/lib_dev/observer.ml index ed6433468b44..d030d874074d 100644 --- a/etherlink/bin_node/lib_dev/observer.ml +++ b/etherlink/bin_node/lib_dev/observer.ml @@ -7,7 +7,6 @@ (*****************************************************************************) open Ethereum_types -open L2_types let confirm_txs config confirmed_txs = let open Lwt_result_syntax in @@ -248,28 +247,9 @@ let main ?network ?kernel_path ~data_dir ~(config : Configuration.t) ~no_sync ~smart_rollup_address ; let* enable_multichain = Evm_ro_context.read_enable_multichain_flag ro_ctxt in - let* l2_chain_id, chain_family = - match (config.experimental_features.l2_chains, enable_multichain) with - | None, false -> return (None, EVM) - | None, true -> tzfail Node_error.Singlechain_node_multichain_kernel - | Some [l2_chain], false -> - let*! () = Events.multichain_node_singlechain_kernel () in - return (Some l2_chain.chain_id, EVM) - | Some [l2_chain], true -> - let chain_id = l2_chain.chain_id in - let* chain_family = Evm_ro_context.read_chain_family ro_ctxt chain_id in - if l2_chain.chain_family = chain_family then - return (Some chain_id, chain_family) - else - tzfail - (Node_error.Mismatched_chain_family - { - chain_id; - node_family = l2_chain.chain_family; - kernel_family = chain_family; - }) - | _ -> tzfail Node_error.Unexpected_multichain + let (module Backend) = observer_backend in + Backend.single_chain_id_and_family ~config ~enable_multichain in let* finalizer_public_server = diff --git a/etherlink/bin_node/lib_dev/proxy.ml b/etherlink/bin_node/lib_dev/proxy.ml index 570a96c0aed7..fbe600f49f4e 100644 --- a/etherlink/bin_node/lib_dev/proxy.ml +++ b/etherlink/bin_node/lib_dev/proxy.ml @@ -204,26 +204,7 @@ let main else return (None, L2_types.EVM) else let* enable_multichain = Rollup_node_rpc.is_multichain_enabled () in - match (config.experimental_features.l2_chains, enable_multichain) with - | None, false -> return (None, L2_types.EVM) - | None, true -> tzfail Node_error.Singlechain_node_multichain_kernel - | Some [l2_chain], false -> - let*! () = Events.multichain_node_singlechain_kernel () in - return (Some l2_chain.chain_id, L2_types.EVM) - | Some [l2_chain], true -> - let chain_id = l2_chain.chain_id in - let* chain_family = Rollup_node_rpc.chain_family chain_id in - if l2_chain.chain_family = chain_family then - return (Some chain_id, chain_family) - else - tzfail - (Node_error.Mismatched_chain_family - { - chain_id; - node_family = l2_chain.chain_family; - kernel_family = chain_family; - }) - | _ -> tzfail Node_error.Unexpected_multichain + Rollup_node_rpc.single_chain_id_and_family ~config ~enable_multichain in let* server_finalizer = diff --git a/etherlink/bin_node/lib_dev/rpc.ml b/etherlink/bin_node/lib_dev/rpc.ml index c394e3dd0dc3..dd08d7fceeaa 100644 --- a/etherlink/bin_node/lib_dev/rpc.ml +++ b/etherlink/bin_node/lib_dev/rpc.ml @@ -230,28 +230,9 @@ let main ~data_dir ~evm_node_endpoint ?evm_node_private_endpoint in let* enable_multichain = Evm_ro_context.read_enable_multichain_flag ctxt in - let* l2_chain_id, chain_family = - match (config.experimental_features.l2_chains, enable_multichain) with - | None, false -> return (None, L2_types.EVM) - | None, true -> tzfail Node_error.Singlechain_node_multichain_kernel - | Some [l2_chain], false -> - let*! () = Events.multichain_node_singlechain_kernel () in - return (Some l2_chain.chain_id, L2_types.EVM) - | Some [l2_chain], true -> - let chain_id = l2_chain.chain_id in - let* chain_family = Evm_ro_context.read_chain_family ctxt chain_id in - if l2_chain.chain_family = chain_family then - return (Some chain_id, chain_family) - else - tzfail - (Node_error.Mismatched_chain_family - { - chain_id; - node_family = l2_chain.chain_family; - kernel_family = chain_family; - }) - | _ -> tzfail Node_error.Unexpected_multichain + let (module Backend) = rpc_backend in + Backend.single_chain_id_and_family ~config ~enable_multichain in let* server_public_finalizer = diff --git a/etherlink/bin_node/lib_dev/services_backend_sig.ml b/etherlink/bin_node/lib_dev/services_backend_sig.ml index a81e5d95240e..eb9ece55145e 100644 --- a/etherlink/bin_node/lib_dev/services_backend_sig.ml +++ b/etherlink/bin_node/lib_dev/services_backend_sig.ml @@ -52,6 +52,28 @@ module type S = sig (** [chain_family chain_id] returns chain family defined for the chain with id chain_id. *) val chain_family : L2_types.chain_id -> L2_types.chain_family tzresult Lwt.t + (** [single_chain_id_and_family] should only be called if the + node is expected to follow a single chain. It compares the + configuration of the node and the one of the kernel regarding the + chain id and chain family. + + If the multichain feature is disabled in both the kernel and the + node, the default value [(None, EVM)] is returned. + + If the multichain feature is enabled in the kernel, check that it + is also enabled in the node, that the node is configured to follow + exactly one of the chains, that its chain id is among the + configured ones in the kernel, and that the chain families for + this chain agree in the node and the kernel. + + If the multichain feature is disabled in the kernel but enabled in + the node, a warning is emmitted, the configured chain family is + ignored and the returned chain family is the default [EVM]. *) + val single_chain_id_and_family : + config:Configuration.t -> + enable_multichain:bool -> + (L2_types.chain_id option * L2_types.chain_family) tzresult Lwt.t + (** [base_fee_per_gas ()] returns base fee defined by the rollup. *) val base_fee_per_gas : unit -> Ethereum_types.quantity tzresult Lwt.t @@ -189,6 +211,30 @@ module Make (Backend : Backend) (Executor : Evm_execution.S) : S = struct let list_l1_l2_levels = Backend.list_l1_l2_levels let l2_levels_of_l1_level = Backend.l2_levels_of_l1_level + + let single_chain_id_and_family ~(config : Configuration.t) ~enable_multichain + = + let open Lwt_result_syntax in + match (config.experimental_features.l2_chains, enable_multichain) with + | None, false -> return (None, L2_types.EVM) + | None, true -> tzfail Node_error.Singlechain_node_multichain_kernel + | Some [l2_chain], false -> + let*! () = Events.multichain_node_singlechain_kernel () in + return (Some l2_chain.chain_id, L2_types.EVM) + | Some [l2_chain], true -> + let chain_id = l2_chain.chain_id in + let* chain_family = chain_family chain_id in + if l2_chain.chain_family = chain_family then + return (Some chain_id, chain_family) + else + tzfail + (Node_error.Mismatched_chain_family + { + chain_id; + node_family = l2_chain.chain_family; + kernel_family = chain_family; + }) + | _ -> tzfail Node_error.Unexpected_multichain end (** Inject transactions with either RPCs or on a websocket connection. *) -- GitLab From 90bc1b0efb60b3c95c7ba3bf8a9847dcca349b81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Cauderlier?= Date: Mon, 19 May 2025 11:39:46 +0200 Subject: [PATCH 02/14] EVM node/Sequencer: assert that there is only one chain Until now, we avoided to assert that the sequencer was handling a single chain to avoid going against future multichain support. This lead us in an hybrid system in which some workers expect a single chain (and a single tx container) and some other don't. Assuming everywhere that there is, for now, only one chain does however simplify the refactoring code needed to plug the tx queue in Tezlink so in this commit we finally byte this bullet. --- etherlink/bin_node/lib_dev/sequencer.ml | 31 ++++--------------------- 1 file changed, 4 insertions(+), 27 deletions(-) diff --git a/etherlink/bin_node/lib_dev/sequencer.ml b/etherlink/bin_node/lib_dev/sequencer.ml index 46d5f268257f..123f31eeef2f 100644 --- a/etherlink/bin_node/lib_dev/sequencer.ml +++ b/etherlink/bin_node/lib_dev/sequencer.ml @@ -338,36 +338,13 @@ let main ~data_dir ?(genesis_timestamp = Misc.now ()) ~cctxt return_unit in let* enable_multichain = Evm_ro_context.read_enable_multichain_flag ro_ctxt in - let* () = - match - (configuration.experimental_features.l2_chains, enable_multichain) - with - | None, false -> return_unit - | None, true -> tzfail Node_error.Singlechain_node_multichain_kernel - | Some _, false -> - let*! () = Events.multichain_node_singlechain_kernel () in - return_unit - | Some l2_chains, true -> - List.iter_es - (fun l2_chain -> - let chain_id = l2_chain.chain_id in - let* chain_family = - Evm_ro_context.read_chain_family ro_ctxt chain_id - in - if chain_family = l2_chain.chain_family then return_unit - else - tzfail - (Node_error.Mismatched_chain_family - { - chain_id; - node_family = l2_chain.chain_family; - kernel_family = chain_family; - })) - l2_chains + let* l2_chain_id, _chain_family = + let (module Backend) = backend in + Backend.single_chain_id_and_family ~config:configuration ~enable_multichain in let* finalizer_public_server = Rpc_server.start_public_server - ~l2_chain_id:None + ~l2_chain_id ~evm_services: Evm_ro_context.( evm_services_methods ro_ctxt sequencer_config.time_between_blocks) -- GitLab From 8a629aed971d40c0b0e7fd5bce0938b90d86644e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Cauderlier?= Date: Mon, 19 May 2025 16:56:24 +0200 Subject: [PATCH 03/14] EVM node: get chain family before launching the tx container This will be needed to: - add the chain family as parameter of the Tx pool in the next commit, and - have Tezlink-compatible variants of the Tx containers in the future. --- etherlink/bin_node/lib_dev/observer.ml | 12 +++++------ etherlink/bin_node/lib_dev/proxy.ml | 28 ++++++++++++------------- etherlink/bin_node/lib_dev/rpc.ml | 12 +++++------ etherlink/bin_node/lib_dev/sequencer.ml | 10 ++++----- 4 files changed, 31 insertions(+), 31 deletions(-) diff --git a/etherlink/bin_node/lib_dev/observer.ml b/etherlink/bin_node/lib_dev/observer.ml index d030d874074d..8286909bf41c 100644 --- a/etherlink/bin_node/lib_dev/observer.ml +++ b/etherlink/bin_node/lib_dev/observer.ml @@ -220,6 +220,12 @@ let main ?network ?kernel_path ~data_dir ~(config : Configuration.t) ~no_sync Evm_ro_context.ro_backend ro_ctxt config ~evm_node_endpoint in + let* enable_multichain = Evm_ro_context.read_enable_multichain_flag ro_ctxt in + let* l2_chain_id, chain_family = + let (module Backend) = observer_backend in + Backend.single_chain_id_and_family ~config ~enable_multichain + in + let* () = match config.experimental_features.enable_tx_queue with | Some tx_queue_config -> @@ -246,12 +252,6 @@ let main ?network ?kernel_path ~data_dir ~(config : Configuration.t) ~no_sync ~tx_pool_size_info:Tx_pool.size_info ~smart_rollup_address ; - let* enable_multichain = Evm_ro_context.read_enable_multichain_flag ro_ctxt in - let* l2_chain_id, chain_family = - let (module Backend) = observer_backend in - Backend.single_chain_id_and_family ~config ~enable_multichain - in - let* finalizer_public_server = Rpc_server.start_public_server ~l2_chain_id diff --git a/etherlink/bin_node/lib_dev/proxy.ml b/etherlink/bin_node/lib_dev/proxy.ml index fbe600f49f4e..546f4f800da4 100644 --- a/etherlink/bin_node/lib_dev/proxy.ml +++ b/etherlink/bin_node/lib_dev/proxy.ml @@ -142,6 +142,20 @@ let main | Some _base -> Validate.Stateless | None -> Validate.Full in + let* l2_chain_id, chain_family = + if finalized_view then + if + (* When finalized_view is set, it's too early to request the + feature flag from the rollup node. *) + Option.is_some config.experimental_features.l2_chains + then + (* The finalized view of the proxy mode and the multichain feature are not compatible. *) + tzfail (Node_error.Proxy_finalize_with_multichain `Node) + else return (None, L2_types.EVM) + else + let* enable_multichain = Rollup_node_rpc.is_multichain_enabled () in + Rollup_node_rpc.single_chain_id_and_family ~config ~enable_multichain + in let* on_new_head, tx_container = match ( config.experimental_features.enable_send_raw_transaction, @@ -192,20 +206,6 @@ let main ~rollup_node_endpoint () in - let* l2_chain_id, chain_family = - if finalized_view then - if - (* When finalized_view is set, it's too early to request the - feature flag from the rollup node. *) - Option.is_some config.experimental_features.l2_chains - then - (* The finalized view of the proxy mode and the multichain feature are not compatible. *) - tzfail (Node_error.Proxy_finalize_with_multichain `Node) - else return (None, L2_types.EVM) - else - let* enable_multichain = Rollup_node_rpc.is_multichain_enabled () in - Rollup_node_rpc.single_chain_id_and_family ~config ~enable_multichain - in let* server_finalizer = Rpc_server.start_public_server diff --git a/etherlink/bin_node/lib_dev/rpc.ml b/etherlink/bin_node/lib_dev/rpc.ml index dd08d7fceeaa..587f09f1f9ea 100644 --- a/etherlink/bin_node/lib_dev/rpc.ml +++ b/etherlink/bin_node/lib_dev/rpc.ml @@ -168,6 +168,12 @@ let main ~data_dir ~evm_node_endpoint ?evm_node_private_endpoint let rpc_backend = Evm_ro_context.ro_backend ctxt config ~evm_node_endpoint in + let* enable_multichain = Evm_ro_context.read_enable_multichain_flag ctxt in + let* l2_chain_id, chain_family = + let (module Backend) = rpc_backend in + Backend.single_chain_id_and_family ~config ~enable_multichain + in + let* ping_tx_pool, tx_container = match (evm_node_private_endpoint, config.experimental_features.enable_tx_queue) @@ -229,12 +235,6 @@ let main ~data_dir ~evm_node_endpoint ?evm_node_private_endpoint } in - let* enable_multichain = Evm_ro_context.read_enable_multichain_flag ctxt in - let* l2_chain_id, chain_family = - let (module Backend) = rpc_backend in - Backend.single_chain_id_and_family ~config ~enable_multichain - in - let* server_public_finalizer = Rpc_server.start_public_server ~l2_chain_id diff --git a/etherlink/bin_node/lib_dev/sequencer.ml b/etherlink/bin_node/lib_dev/sequencer.ml index 123f31eeef2f..18379489c06d 100644 --- a/etherlink/bin_node/lib_dev/sequencer.ml +++ b/etherlink/bin_node/lib_dev/sequencer.ml @@ -286,6 +286,11 @@ let main ~data_dir ?(genesis_timestamp = Misc.now ()) ~cctxt in let backend = Evm_ro_context.ro_backend ro_ctxt configuration in + let* enable_multichain = Evm_ro_context.read_enable_multichain_flag ro_ctxt in + let* l2_chain_id, _chain_family = + let (module Backend) = backend in + Backend.single_chain_id_and_family ~config:configuration ~enable_multichain + in let* () = match configuration.experimental_features.enable_tx_queue with | Some tx_queue_config -> @@ -337,11 +342,6 @@ let main ~data_dir ?(genesis_timestamp = Misc.now ()) ~cctxt in return_unit in - let* enable_multichain = Evm_ro_context.read_enable_multichain_flag ro_ctxt in - let* l2_chain_id, _chain_family = - let (module Backend) = backend in - Backend.single_chain_id_and_family ~config:configuration ~enable_multichain - in let* finalizer_public_server = Rpc_server.start_public_server ~l2_chain_id -- GitLab From 531c66402f4e1a79b1fd182714df1c873afb0a94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Cauderlier?= Date: Mon, 19 May 2025 11:49:22 +0200 Subject: [PATCH 04/14] EVM node/block producer: pass chain family instead of l2_chains This will later let us disable validation in Tezlink --- etherlink/bin_node/lib_dev/block_producer.ml | 17 ++++++++--------- etherlink/bin_node/lib_dev/block_producer.mli | 2 +- etherlink/bin_node/lib_dev/sequencer.ml | 4 ++-- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/etherlink/bin_node/lib_dev/block_producer.ml b/etherlink/bin_node/lib_dev/block_producer.ml index 7b86cbc979ff..f433fae1d618 100644 --- a/etherlink/bin_node/lib_dev/block_producer.ml +++ b/etherlink/bin_node/lib_dev/block_producer.ml @@ -11,7 +11,7 @@ type parameters = { sequencer_key : Client_keys.sk_uri; maximum_number_of_chunks : int; uses_tx_queue : bool; - l2_chains : Configuration.l2_chain list option; + chain_family : L2_types.chain_family; } (* The size of a delayed transaction is overapproximated to the maximum size @@ -216,7 +216,7 @@ let validate_tx ~maximum_cumulative_size (current_size, validation_state) raw_tx in return `Drop -let tx_queue_pop_valid_tx (head_info : Evm_context.head) +let tx_queue_pop_valid_tx ~chain_family:_ (head_info : Evm_context.head) ~maximum_cumulative_size = let open Lwt_result_syntax in let read = Evm_state.read head_info.evm_state in @@ -245,7 +245,7 @@ let tx_queue_pop_valid_tx (head_info : Evm_context.head) (** Produces a block if we find at least one valid transaction in the transaction pool or if [force] is true. *) -let produce_block_if_needed ~cctxt ~l2_chains ~smart_rollup_address +let produce_block_if_needed ~cctxt ~chain_family ~smart_rollup_address ~sequencer_key ~force ~timestamp ~delayed_hashes ~remaining_cumulative_size ~uses_tx_queue head_info = let open Lwt_result_syntax in @@ -256,11 +256,10 @@ let produce_block_if_needed ~cctxt ~l2_chains ~smart_rollup_address return [] else if uses_tx_queue then tx_queue_pop_valid_tx + ~chain_family head_info ~maximum_cumulative_size:remaining_cumulative_size else - (* TODO: We should iterate when multichain https://gitlab.com/tezos/tezos/-/issues/7859 *) - let chain_family = Configuration.retrieve_chain_family ~l2_chains in Tx_pool.pop_transactions ~chain_family ~maximum_cumulative_size:remaining_cumulative_size @@ -305,7 +304,7 @@ let head_info_and_delayed_transactions ~with_delayed_transactions let*! head_info = Evm_context.head_info () in return (head_info, delayed_hashes, remaining_cumulative_size) -let produce_block ~l2_chains ~uses_tx_queue ~cctxt ~smart_rollup_address +let produce_block ~chain_family ~uses_tx_queue ~cctxt ~smart_rollup_address ~sequencer_key ~force ~timestamp ~maximum_number_of_chunks ~with_delayed_transactions = let open Lwt_result_syntax in @@ -343,7 +342,7 @@ let produce_block ~l2_chains ~uses_tx_queue ~cctxt ~smart_rollup_address else produce_block_if_needed ~cctxt - ~l2_chains + ~chain_family ~sequencer_key ~timestamp ~smart_rollup_address @@ -371,13 +370,13 @@ module Handlers = struct sequencer_key; maximum_number_of_chunks; uses_tx_queue; - l2_chains; + chain_family; } = state in produce_block - ~l2_chains ~uses_tx_queue + ~chain_family ~cctxt ~smart_rollup_address ~sequencer_key diff --git a/etherlink/bin_node/lib_dev/block_producer.mli b/etherlink/bin_node/lib_dev/block_producer.mli index 877f1b1857f2..4581efaf166e 100644 --- a/etherlink/bin_node/lib_dev/block_producer.mli +++ b/etherlink/bin_node/lib_dev/block_producer.mli @@ -11,7 +11,7 @@ type parameters = { sequencer_key : Client_keys.sk_uri; maximum_number_of_chunks : int; uses_tx_queue : bool; - l2_chains : Configuration.l2_chain list option; + chain_family : L2_types.chain_family; } (** [start parameters] starts the events follower. *) diff --git a/etherlink/bin_node/lib_dev/sequencer.ml b/etherlink/bin_node/lib_dev/sequencer.ml index 18379489c06d..04695e5ac2a1 100644 --- a/etherlink/bin_node/lib_dev/sequencer.ml +++ b/etherlink/bin_node/lib_dev/sequencer.ml @@ -287,7 +287,7 @@ let main ~data_dir ?(genesis_timestamp = Misc.now ()) ~cctxt let backend = Evm_ro_context.ro_backend ro_ctxt configuration in let* enable_multichain = Evm_ro_context.read_enable_multichain_flag ro_ctxt in - let* l2_chain_id, _chain_family = + let* l2_chain_id, chain_family = let (module Backend) = backend in Backend.single_chain_id_and_family ~config:configuration ~enable_multichain in @@ -322,7 +322,7 @@ let main ~data_dir ?(genesis_timestamp = Misc.now ()) ~cctxt sequencer_key = sequencer_config.sequencer; maximum_number_of_chunks = sequencer_config.max_number_of_chunks; uses_tx_queue = Configuration.is_tx_queue_enabled configuration; - l2_chains = configuration.experimental_features.l2_chains; + chain_family; } in let* () = -- GitLab From bfc43645d3fba45d4477d4fcabafecb644508547 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Cauderlier?= Date: Tue, 29 Apr 2025 23:00:46 +0200 Subject: [PATCH 05/14] EVM node/Block_producer: add tx_container parameter --- etherlink/bin_node/lib_dev/block_producer.ml | 7 ++++++- etherlink/bin_node/lib_dev/block_producer.mli | 1 + etherlink/bin_node/lib_dev/sequencer.ml | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/etherlink/bin_node/lib_dev/block_producer.ml b/etherlink/bin_node/lib_dev/block_producer.ml index f433fae1d618..62f33749d1e2 100644 --- a/etherlink/bin_node/lib_dev/block_producer.ml +++ b/etherlink/bin_node/lib_dev/block_producer.ml @@ -12,6 +12,7 @@ type parameters = { maximum_number_of_chunks : int; uses_tx_queue : bool; chain_family : L2_types.chain_family; + tx_container : (module Services_backend_sig.Tx_container); } (* The size of a delayed transaction is overapproximated to the maximum size @@ -306,8 +307,10 @@ let head_info_and_delayed_transactions ~with_delayed_transactions let produce_block ~chain_family ~uses_tx_queue ~cctxt ~smart_rollup_address ~sequencer_key ~force ~timestamp ~maximum_number_of_chunks - ~with_delayed_transactions = + ~with_delayed_transactions + ~(tx_container : (module Services_backend_sig.Tx_container)) = let open Lwt_result_syntax in + let (module Tx_container) = tx_container in let* is_locked = if uses_tx_queue then Tx_queue.is_locked () else Tx_pool.is_locked () in @@ -371,6 +374,7 @@ module Handlers = struct maximum_number_of_chunks; uses_tx_queue; chain_family; + tx_container; } = state in @@ -384,6 +388,7 @@ module Handlers = struct ~timestamp ~maximum_number_of_chunks ~with_delayed_transactions + ~tx_container type launch_error = error trace diff --git a/etherlink/bin_node/lib_dev/block_producer.mli b/etherlink/bin_node/lib_dev/block_producer.mli index 4581efaf166e..e7575f054348 100644 --- a/etherlink/bin_node/lib_dev/block_producer.mli +++ b/etherlink/bin_node/lib_dev/block_producer.mli @@ -12,6 +12,7 @@ type parameters = { maximum_number_of_chunks : int; uses_tx_queue : bool; chain_family : L2_types.chain_family; + tx_container : (module Services_backend_sig.Tx_container); } (** [start parameters] starts the events follower. *) diff --git a/etherlink/bin_node/lib_dev/sequencer.ml b/etherlink/bin_node/lib_dev/sequencer.ml index 04695e5ac2a1..c06e00444a4b 100644 --- a/etherlink/bin_node/lib_dev/sequencer.ml +++ b/etherlink/bin_node/lib_dev/sequencer.ml @@ -323,6 +323,7 @@ let main ~data_dir ?(genesis_timestamp = Misc.now ()) ~cctxt maximum_number_of_chunks = sequencer_config.max_number_of_chunks; uses_tx_queue = Configuration.is_tx_queue_enabled configuration; chain_family; + tx_container; } in let* () = -- GitLab From bad5cf524abbb4b480946ca299595d56f0eaedfb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Cauderlier?= Date: Tue, 29 Apr 2025 23:03:55 +0200 Subject: [PATCH 06/14] EVM node/Block_producer + Tx_queue + pool: move is_locked to Tx_container --- etherlink/bin_node/lib_dev/block_producer.ml | 4 +--- etherlink/bin_node/lib_dev/observer.ml | 2 ++ etherlink/bin_node/lib_dev/proxy.ml | 2 ++ etherlink/bin_node/lib_dev/rpc.ml | 2 ++ etherlink/bin_node/lib_dev/services_backend_sig.ml | 3 +++ etherlink/bin_node/lib_dev/tx_pool.ml | 12 ++++++------ etherlink/bin_node/lib_dev/tx_pool.mli | 3 --- etherlink/bin_node/lib_dev/tx_queue.ml | 10 +++++----- etherlink/bin_node/lib_dev/tx_queue.mli | 3 --- 9 files changed, 21 insertions(+), 20 deletions(-) diff --git a/etherlink/bin_node/lib_dev/block_producer.ml b/etherlink/bin_node/lib_dev/block_producer.ml index 62f33749d1e2..c550123e3e17 100644 --- a/etherlink/bin_node/lib_dev/block_producer.ml +++ b/etherlink/bin_node/lib_dev/block_producer.ml @@ -311,9 +311,7 @@ let produce_block ~chain_family ~uses_tx_queue ~cctxt ~smart_rollup_address ~(tx_container : (module Services_backend_sig.Tx_container)) = let open Lwt_result_syntax in let (module Tx_container) = tx_container in - let* is_locked = - if uses_tx_queue then Tx_queue.is_locked () else Tx_pool.is_locked () - in + let* is_locked = Tx_container.is_locked () in if is_locked then let*! () = Block_producer_events.production_locked () in return `No_block diff --git a/etherlink/bin_node/lib_dev/observer.ml b/etherlink/bin_node/lib_dev/observer.ml index 8286909bf41c..dafe9ed24775 100644 --- a/etherlink/bin_node/lib_dev/observer.ml +++ b/etherlink/bin_node/lib_dev/observer.ml @@ -140,6 +140,8 @@ let container_forward_tx ~keep_alive ~evm_node_endpoint : let lock_transactions () = Lwt_result_syntax.return_unit let unlock_transactions () = Lwt_result_syntax.return_unit + + let is_locked () = Lwt_result_syntax.return_false end) let main ?network ?kernel_path ~data_dir ~(config : Configuration.t) ~no_sync diff --git a/etherlink/bin_node/lib_dev/proxy.ml b/etherlink/bin_node/lib_dev/proxy.ml index 546f4f800da4..d5408830a7ba 100644 --- a/etherlink/bin_node/lib_dev/proxy.ml +++ b/etherlink/bin_node/lib_dev/proxy.ml @@ -53,6 +53,8 @@ let container_forward_tx ~evm_node_endpoint ~keep_alive : let lock_transactions () = Lwt_result_syntax.return_unit let unlock_transactions () = Lwt_result_syntax.return_unit + + let is_locked () = Lwt_result_syntax.return_false end) let tx_queue_pop_and_inject (module Rollup_node_rpc : Services_backend_sig.S) diff --git a/etherlink/bin_node/lib_dev/rpc.ml b/etherlink/bin_node/lib_dev/rpc.ml index 587f09f1f9ea..fb552024f497 100644 --- a/etherlink/bin_node/lib_dev/rpc.ml +++ b/etherlink/bin_node/lib_dev/rpc.ml @@ -146,6 +146,8 @@ let container_forward_request ~public_endpoint ~private_endpoint ~keep_alive : let lock_transactions () = Lwt_result_syntax.return_unit let unlock_transactions () = Lwt_result_syntax.return_unit + + let is_locked () = Lwt_result_syntax.return_false end) let main ~data_dir ~evm_node_endpoint ?evm_node_private_endpoint diff --git a/etherlink/bin_node/lib_dev/services_backend_sig.ml b/etherlink/bin_node/lib_dev/services_backend_sig.ml index eb9ece55145e..09a2f48e43fd 100644 --- a/etherlink/bin_node/lib_dev/services_backend_sig.ml +++ b/etherlink/bin_node/lib_dev/services_backend_sig.ml @@ -293,4 +293,7 @@ module type Tx_container = sig (** [unlock_transactions] unlocks the transactions if it was locked by {!lock_transactions}. *) val unlock_transactions : unit -> unit tzresult Lwt.t + + (** [is_locked] checks if the queue is locked. *) + val is_locked : unit -> bool tzresult Lwt.t end diff --git a/etherlink/bin_node/lib_dev/tx_pool.ml b/etherlink/bin_node/lib_dev/tx_pool.ml index 7fdf52b2b041..a74dd8dbce2b 100644 --- a/etherlink/bin_node/lib_dev/tx_pool.ml +++ b/etherlink/bin_node/lib_dev/tx_pool.ml @@ -868,12 +868,6 @@ let pop_and_inject_transactions_lazy () = in return_unit -let is_locked () = - let open Lwt_result_syntax in - let*? worker = Lazy.force worker in - Worker.Queue.push_request_and_wait worker Request.Is_locked - |> handle_request_error - let size_info () = let open Lwt_result_syntax in let*? worker = Lazy.force worker in @@ -977,4 +971,10 @@ module Tx_container = struct let*? worker = Lazy.force worker in Worker.Queue.push_request_and_wait worker Request.Unlock_transactions |> handle_request_error + + let is_locked () = + let open Lwt_result_syntax in + let*? worker = Lazy.force worker in + Worker.Queue.push_request_and_wait worker Request.Is_locked + |> handle_request_error end diff --git a/etherlink/bin_node/lib_dev/tx_pool.mli b/etherlink/bin_node/lib_dev/tx_pool.mli index 47fe10f33c4f..63dd7c5c146e 100644 --- a/etherlink/bin_node/lib_dev/tx_pool.mli +++ b/etherlink/bin_node/lib_dev/tx_pool.mli @@ -44,9 +44,6 @@ val pop_and_inject_transactions : unit -> unit tzresult Lwt.t complete *) val pop_and_inject_transactions_lazy : unit -> unit tzresult Lwt.t -(** [is_locked] checks if the pools is locked. *) -val is_locked : unit -> bool tzresult Lwt.t - val size_info : unit -> Metrics.Tx_pool.size_info tzresult Lwt.t val clear_popped_transactions : unit -> unit tzresult Lwt.t diff --git a/etherlink/bin_node/lib_dev/tx_queue.ml b/etherlink/bin_node/lib_dev/tx_queue.ml index 652151590600..383cedb45db1 100644 --- a/etherlink/bin_node/lib_dev/tx_queue.ml +++ b/etherlink/bin_node/lib_dev/tx_queue.ml @@ -1033,11 +1033,6 @@ let start ~config ~keep_alive () = let*! () = Tx_queue_events.is_ready () in return_unit -let is_locked () = - let open Lwt_result_syntax in - let*? worker = Lazy.force worker in - Worker.Queue.push_request_and_wait worker Is_locked |> handle_request_error - let pop_transactions ~validate_tx ~initial_validation_state = let open Lwt_result_syntax in let*? w = Lazy.force worker in @@ -1131,4 +1126,9 @@ module Tx_container = struct let unlock_transactions () = bind_worker @@ fun w -> push_request w Unlock_transactions + + let is_locked () = + let open Lwt_result_syntax in + let*? worker = Lazy.force worker in + Worker.Queue.push_request_and_wait worker Is_locked |> handle_request_error end diff --git a/etherlink/bin_node/lib_dev/tx_queue.mli b/etherlink/bin_node/lib_dev/tx_queue.mli index c3d38e360005..be6c8bf1b996 100644 --- a/etherlink/bin_node/lib_dev/tx_queue.mli +++ b/etherlink/bin_node/lib_dev/tx_queue.mli @@ -33,9 +33,6 @@ val start : unit -> unit tzresult Lwt.t -(** [is_locked] checks if the queue is locked. *) -val is_locked : unit -> bool tzresult Lwt.t - (** [pop_transactions ~validate_tx ~initial_validation_state] pops as many transactions as possible from the queue, validating them with [validate_tx]. If [validate_tx] returns [`Keep validation_state] -- GitLab From 67f381a4a8e8cbadf474ff85b35c4f3a67c70819 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Cauderlier?= Date: Wed, 30 Apr 2025 11:58:12 +0200 Subject: [PATCH 07/14] EVM node/Tx_pool: add chain_family parameter --- etherlink/bin_node/lib_dev/observer.ml | 1 + etherlink/bin_node/lib_dev/proxy.ml | 1 + etherlink/bin_node/lib_dev/rpc.ml | 1 + etherlink/bin_node/lib_dev/sequencer.ml | 1 + etherlink/bin_node/lib_dev/tx_pool.ml | 4 ++++ etherlink/bin_node/lib_dev/tx_pool.mli | 1 + 6 files changed, 9 insertions(+) diff --git a/etherlink/bin_node/lib_dev/observer.ml b/etherlink/bin_node/lib_dev/observer.ml index dafe9ed24775..cc9f10dcb342 100644 --- a/etherlink/bin_node/lib_dev/observer.ml +++ b/etherlink/bin_node/lib_dev/observer.ml @@ -246,6 +246,7 @@ let main ?network ?kernel_path ~data_dir ~(config : Configuration.t) ~no_sync 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; } in diff --git a/etherlink/bin_node/lib_dev/proxy.ml b/etherlink/bin_node/lib_dev/proxy.ml index d5408830a7ba..d20503e51586 100644 --- a/etherlink/bin_node/lib_dev/proxy.ml +++ b/etherlink/bin_node/lib_dev/proxy.ml @@ -190,6 +190,7 @@ let main 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; } in return diff --git a/etherlink/bin_node/lib_dev/rpc.ml b/etherlink/bin_node/lib_dev/rpc.ml index fb552024f497..5747194b4f9a 100644 --- a/etherlink/bin_node/lib_dev/rpc.ml +++ b/etherlink/bin_node/lib_dev/rpc.ml @@ -213,6 +213,7 @@ let main ~data_dir ~evm_node_endpoint ?evm_node_private_endpoint 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; } in return diff --git a/etherlink/bin_node/lib_dev/sequencer.ml b/etherlink/bin_node/lib_dev/sequencer.ml index c06e00444a4b..c2671dacb290 100644 --- a/etherlink/bin_node/lib_dev/sequencer.ml +++ b/etherlink/bin_node/lib_dev/sequencer.ml @@ -308,6 +308,7 @@ let main ~data_dir ?(genesis_timestamp = Misc.now ()) ~cctxt 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; } in Metrics.init diff --git a/etherlink/bin_node/lib_dev/tx_pool.ml b/etherlink/bin_node/lib_dev/tx_pool.ml index a74dd8dbce2b..c7c51e5cb744 100644 --- a/etherlink/bin_node/lib_dev/tx_pool.ml +++ b/etherlink/bin_node/lib_dev/tx_pool.ml @@ -231,6 +231,7 @@ type parameters = { tx_timeout_limit : int64; tx_pool_addr_limit : int; tx_pool_tx_per_addr_limit : int; + chain_family : L2_types.chain_family; } module Types = struct @@ -244,6 +245,7 @@ module Types = struct tx_pool_addr_limit : int; tx_pool_tx_per_addr_limit : int; mutable locked : bool; + chain_family : L2_types.chain_family; } type nonrec parameters = parameters @@ -741,6 +743,7 @@ module Handlers = struct tx_timeout_limit; tx_pool_addr_limit; tx_pool_tx_per_addr_limit; + chain_family; } : Types.parameters) = let state = @@ -755,6 +758,7 @@ module Handlers = struct tx_pool_addr_limit; tx_pool_tx_per_addr_limit; locked = false; + chain_family; } in Lwt_result_syntax.return state diff --git a/etherlink/bin_node/lib_dev/tx_pool.mli b/etherlink/bin_node/lib_dev/tx_pool.mli index 63dd7c5c146e..d1e0feb8c444 100644 --- a/etherlink/bin_node/lib_dev/tx_pool.mli +++ b/etherlink/bin_node/lib_dev/tx_pool.mli @@ -20,6 +20,7 @@ type parameters = { tx_pool_addr_limit : int; (** Maximum allowed addresses inside the pool. *) tx_pool_tx_per_addr_limit : int; (** Maximum allowed transactions per address inside the pool. *) + chain_family : L2_types.chain_family; } (** [start parameters] starts the tx-pool *) -- GitLab From fd11e0d302b900589e12f8d5ac78ed03c40aa341 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Cauderlier?= Date: Wed, 30 Apr 2025 12:00:24 +0200 Subject: [PATCH 08/14] EVM node/Tx_pool: pop_transactions does not take chain_family as argument Fixes #7889. --- etherlink/bin_node/lib_dev/block_producer.ml | 1 - etherlink/bin_node/lib_dev/tx_pool.ml | 39 ++++++++------------ etherlink/bin_node/lib_dev/tx_pool.mli | 1 - 3 files changed, 16 insertions(+), 25 deletions(-) diff --git a/etherlink/bin_node/lib_dev/block_producer.ml b/etherlink/bin_node/lib_dev/block_producer.ml index c550123e3e17..985b5da61a29 100644 --- a/etherlink/bin_node/lib_dev/block_producer.ml +++ b/etherlink/bin_node/lib_dev/block_producer.ml @@ -262,7 +262,6 @@ let produce_block_if_needed ~cctxt ~chain_family ~smart_rollup_address ~maximum_cumulative_size:remaining_cumulative_size else Tx_pool.pop_transactions - ~chain_family ~maximum_cumulative_size:remaining_cumulative_size in let n = List.length transactions_and_objects + List.length delayed_hashes in diff --git a/etherlink/bin_node/lib_dev/tx_pool.ml b/etherlink/bin_node/lib_dev/tx_pool.ml index c7c51e5cb744..d80039959c81 100644 --- a/etherlink/bin_node/lib_dev/tx_pool.ml +++ b/etherlink/bin_node/lib_dev/tx_pool.ml @@ -270,11 +270,7 @@ module Request = struct Ethereum_types.legacy_transaction_object * string -> ((Ethereum_types.hash, string) result, tztrace) t | Pop_transactions : - (* TODO: https://gitlab.com/tezos/tezos/-/issues/7889 *) - (* We need the chain_family to verify if we are in Tezlink mode *) - (* If so, deactivate the pop_transactions and returns an empty list *) - L2_types.chain_family - * int + int -> ((string * Ethereum_types.legacy_transaction_object) list, tztrace) t | Pop_and_inject_transactions : (unit, tztrace) t | Lock_transactions : (unit, tztrace) t @@ -312,16 +308,15 @@ module Request = struct case (Tag 1) ~title:"Pop_transactions" - (obj3 + (obj2 (req "request" (constant "pop_transactions")) - (req "chain_family" L2_types.Chain_family.encoding) (req "maximum_cumulatize_size" int31)) (function - | View (Pop_transactions (chain_family, maximum_cumulative_size)) -> - Some ((), chain_family, maximum_cumulative_size) + | View (Pop_transactions maximum_cumulative_size) -> + Some ((), maximum_cumulative_size) | _ -> None) - (fun ((), chain_family, maximum_cumulative_size) -> - View (Pop_transactions (chain_family, maximum_cumulative_size))); + (fun ((), maximum_cumulative_size) -> + View (Pop_transactions maximum_cumulative_size)); case (Tag 2) ~title:"Pop_and_inject_transactions" @@ -375,7 +370,7 @@ module Request = struct ppf "Add tx [%s] to tx-pool" (Hex.of_string tx_raw |> Hex.show) - | Pop_transactions (_chain_family, maximum_cumulative_size) -> + | Pop_transactions maximum_cumulative_size -> Format.fprintf ppf "Popping transactions of maximum cumulative size %d bytes" @@ -495,7 +490,7 @@ let transaction_timed_out ~tx_timeout_limit ~current_timestamp ~inclusion_timestamp = Time.Protocol.diff current_timestamp inclusion_timestamp >= tx_timeout_limit -let pop_transactions state ~chain_family ~maximum_cumulative_size = +let pop_transactions state ~maximum_cumulative_size = let open Lwt_result_syntax in let Types. { @@ -507,7 +502,7 @@ let pop_transactions state ~chain_family ~maximum_cumulative_size = } = state in - if locked || chain_family = L2_types.Michelson then return [] + if locked || state.chain_family = L2_types.Michelson then return [] else (* Get all the addresses in the tx-pool. *) let addresses = Pool.addresses pool in @@ -625,7 +620,7 @@ let clear_popped_transactions state = state.Types.popped_txs <- [] are forwarded to a rollup node, in observer mode to the next evm node. The sequencer is not supposed to use this function, using it would make transaction disappear from the tx pool. *) -let pop_and_inject_transactions ~chain_family state = +let pop_and_inject_transactions state = let open Lwt_result_syntax in let open Types in (* We over approximate the number of transactions to pop in proxy and @@ -636,7 +631,7 @@ let pop_and_inject_transactions ~chain_family state = Sequencer_blueprint.maximum_usable_space_in_blueprint Sequencer_blueprint.maximum_chunks_per_l1_level in - let* txs = pop_transactions state ~chain_family ~maximum_cumulative_size in + let* txs = pop_transactions state ~maximum_cumulative_size in if not (List.is_empty txs) then let (module Backend : Services_backend_sig.S) = state.backend in let*! hashes = @@ -717,12 +712,10 @@ module Handlers = struct let* res = insert_valid_transaction state txn transaction_object in let* () = relay_self_inject_request w in return res - | Request.Pop_transactions (chain_family, maximum_cumulative_size) -> - protect @@ fun () -> - pop_transactions state ~chain_family ~maximum_cumulative_size + | Request.Pop_transactions maximum_cumulative_size -> + protect @@ fun () -> pop_transactions state ~maximum_cumulative_size | Request.Pop_and_inject_transactions -> - protect @@ fun () -> - pop_and_inject_transactions ~chain_family:L2_types.EVM state + protect @@ fun () -> pop_and_inject_transactions state | Request.Lock_transactions -> protect @@ fun () -> return (lock_transactions state) | Request.Unlock_transactions -> return (unlock_transactions state) @@ -834,12 +827,12 @@ let nonce pkey = in Pool.next_nonce pkey current_nonce pool -let pop_transactions ~chain_family ~maximum_cumulative_size = +let pop_transactions ~maximum_cumulative_size = let open Lwt_result_syntax in let*? worker = Lazy.force worker in Worker.Queue.push_request_and_wait worker - (Request.Pop_transactions (chain_family, maximum_cumulative_size)) + (Request.Pop_transactions maximum_cumulative_size) |> handle_request_error let pop_and_inject_transactions () = diff --git a/etherlink/bin_node/lib_dev/tx_pool.mli b/etherlink/bin_node/lib_dev/tx_pool.mli index d1e0feb8c444..9f02a6c96f4e 100644 --- a/etherlink/bin_node/lib_dev/tx_pool.mli +++ b/etherlink/bin_node/lib_dev/tx_pool.mli @@ -31,7 +31,6 @@ val start : parameters -> unit tzresult Lwt.t size exceeds `maximum_cumulative_size`. If the pool is locked or node in tezlink mode, returns no transactions. *) val pop_transactions : - chain_family:L2_types.chain_family -> maximum_cumulative_size:int -> (string * Ethereum_types.legacy_transaction_object) list tzresult Lwt.t -- GitLab From 9954f21560d1ab635044d6dbbf8044d996e0f5b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Cauderlier?= Date: Fri, 2 May 2025 18:15:52 +0200 Subject: [PATCH 09/14] EVM node/Observer: inline confirm_txs --- etherlink/bin_node/lib_dev/observer.ml | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/etherlink/bin_node/lib_dev/observer.ml b/etherlink/bin_node/lib_dev/observer.ml index cc9f10dcb342..344fbc687ee4 100644 --- a/etherlink/bin_node/lib_dev/observer.ml +++ b/etherlink/bin_node/lib_dev/observer.ml @@ -8,14 +8,6 @@ open Ethereum_types -let confirm_txs config confirmed_txs = - let open Lwt_result_syntax in - if Configuration.is_tx_queue_enabled config then - Tx_queue.confirm_transactions - ~clear_pending_queue_after:false - ~confirmed_txs - else return_unit - (** [on_new_blueprint evm_node_endpoint next_blueprint_number blueprint] applies evm events found in the blueprint, then applies the blueprint itself. @@ -67,8 +59,14 @@ let on_new_blueprint config evm_node_endpoint next_blueprint_number failwith "Could not recover from failing to apply latest received \ blueprint.") - | Ok tx_hashes -> - let* () = confirm_txs config tx_hashes in + | Ok confirmed_txs -> + let* () = + if Configuration.is_tx_queue_enabled config then + Tx_queue.confirm_transactions + ~clear_pending_queue_after:false + ~confirmed_txs + else return_unit + in return `Continue | Error (Node_error.Diverged {must_exit = false; _} :: _) -> (* If we have diverged, but should keep the node alive. This happens -- GitLab From 1d3722327a0130f7858196d020e2baa0af8c7e81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Cauderlier?= Date: Fri, 2 May 2025 18:06:35 +0200 Subject: [PATCH 10/14] EVM node/Block_producer + Tx_queue + pool: move confirm_transactions to Tx_container --- etherlink/bin_node/lib_dev/block_producer.ml | 13 +++++++------ etherlink/bin_node/lib_dev/observer.ml | 17 ++++++++++------- etherlink/bin_node/lib_dev/proxy.ml | 13 ++++++++++--- etherlink/bin_node/lib_dev/rpc.ml | 3 +++ .../bin_node/lib_dev/services_backend_sig.ml | 9 +++++++++ etherlink/bin_node/lib_dev/tx_pool.ml | 3 +++ etherlink/bin_node/lib_dev/tx_queue.ml | 16 ++++++++-------- etherlink/bin_node/lib_dev/tx_queue.mli | 8 -------- .../fa-bridge-watchtower/etherlink_monitor.ml | 2 +- 9 files changed, 51 insertions(+), 33 deletions(-) diff --git a/etherlink/bin_node/lib_dev/block_producer.ml b/etherlink/bin_node/lib_dev/block_producer.ml index 985b5da61a29..fdb783a110f0 100644 --- a/etherlink/bin_node/lib_dev/block_producer.ml +++ b/etherlink/bin_node/lib_dev/block_producer.ml @@ -248,8 +248,10 @@ let tx_queue_pop_valid_tx ~chain_family:_ (head_info : Evm_context.head) pool or if [force] is true. *) let produce_block_if_needed ~cctxt ~chain_family ~smart_rollup_address ~sequencer_key ~force ~timestamp ~delayed_hashes ~remaining_cumulative_size - ~uses_tx_queue head_info = + ~uses_tx_queue ~(tx_container : (module Services_backend_sig.Tx_container)) + head_info = let open Lwt_result_syntax in + let (module Tx_container) = tx_container in let* transactions_and_objects = (* Low key optimization to avoid even checking the txpool if there is not enough space for the smallest transaction. *) @@ -277,11 +279,9 @@ let produce_block_if_needed ~cctxt ~chain_family ~smart_rollup_address head_info in let* () = - if uses_tx_queue then - Tx_queue.confirm_transactions - ~clear_pending_queue_after:true - ~confirmed_txs - else Tx_pool.clear_popped_transactions () + Tx_container.confirm_transactions + ~clear_pending_queue_after:true + ~confirmed_txs in return (`Block_produced n) else return `No_block @@ -350,6 +350,7 @@ let produce_block ~chain_family ~uses_tx_queue ~cctxt ~smart_rollup_address ~delayed_hashes ~remaining_cumulative_size ~uses_tx_queue + ~tx_container head_info module Handlers = struct diff --git a/etherlink/bin_node/lib_dev/observer.ml b/etherlink/bin_node/lib_dev/observer.ml index 344fbc687ee4..02a1b084b1a0 100644 --- a/etherlink/bin_node/lib_dev/observer.ml +++ b/etherlink/bin_node/lib_dev/observer.ml @@ -21,10 +21,12 @@ 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 config evm_node_endpoint next_blueprint_number +let on_new_blueprint (tx_container : (module 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 (module Tx_container) = tx_container in let (Qty level) = blueprint.number in let (Qty number) = next_blueprint_number in if Z.(equal level number) then @@ -61,11 +63,9 @@ let on_new_blueprint config evm_node_endpoint next_blueprint_number blueprint.") | Ok confirmed_txs -> let* () = - if Configuration.is_tx_queue_enabled config then - Tx_queue.confirm_transactions - ~clear_pending_queue_after:false - ~confirmed_txs - else return_unit + Tx_container.confirm_transactions + ~clear_pending_queue_after:false + ~confirmed_txs in return `Continue | Error (Node_error.Diverged {must_exit = false; _} :: _) -> @@ -140,6 +140,9 @@ let container_forward_tx ~keep_alive ~evm_node_endpoint : let unlock_transactions () = Lwt_result_syntax.return_unit let is_locked () = Lwt_result_syntax.return_false + + let confirm_transactions ~clear_pending_queue_after:_ ~confirmed_txs:_ = + Lwt_result_syntax.return_unit end) let main ?network ?kernel_path ~data_dir ~(config : Configuration.t) ~no_sync @@ -341,7 +344,7 @@ let main ?network ?kernel_path ~data_dir ~(config : Configuration.t) ~no_sync ~time_between_blocks ~evm_node_endpoint ~next_blueprint_number - (on_new_blueprint config evm_node_endpoint) + (on_new_blueprint tx_container evm_node_endpoint) and* () = Drift_monitor.run ~evm_node_endpoint Evm_context.next_blueprint_number and* () = diff --git a/etherlink/bin_node/lib_dev/proxy.ml b/etherlink/bin_node/lib_dev/proxy.ml index d20503e51586..463eaa65ab29 100644 --- a/etherlink/bin_node/lib_dev/proxy.ml +++ b/etherlink/bin_node/lib_dev/proxy.ml @@ -55,9 +55,13 @@ let container_forward_tx ~evm_node_endpoint ~keep_alive : let unlock_transactions () = Lwt_result_syntax.return_unit let is_locked () = Lwt_result_syntax.return_false + + let confirm_transactions ~clear_pending_queue_after:_ ~confirmed_txs:_ = + Lwt_result_syntax.return_unit end) let tx_queue_pop_and_inject (module Rollup_node_rpc : Services_backend_sig.S) + (module Tx_container : Services_backend_sig.Tx_container) ~smart_rollup_address = let open Lwt_result_syntax in let maximum_cumulative_size = @@ -87,7 +91,7 @@ let tx_queue_pop_and_inject (module Rollup_node_rpc : Services_backend_sig.S) return_unit | Ok hashes -> let* () = - Tx_queue.confirm_transactions + Tx_container.confirm_transactions ~clear_pending_queue_after:true ~confirmed_txs:(List.to_seq hashes) in @@ -171,14 +175,17 @@ let main ~keep_alive:config.keep_alive () in + let tx_container = + (module Tx_queue.Tx_container : Services_backend_sig.Tx_container) + in return @@ ( Some (fun () -> tx_queue_pop_and_inject (module Rollup_node_rpc) + tx_container ~smart_rollup_address), - (module Tx_queue.Tx_container : Services_backend_sig.Tx_container) - ) + tx_container ) | true, None, None -> let* () = Tx_pool.start diff --git a/etherlink/bin_node/lib_dev/rpc.ml b/etherlink/bin_node/lib_dev/rpc.ml index 5747194b4f9a..c18011ae99ac 100644 --- a/etherlink/bin_node/lib_dev/rpc.ml +++ b/etherlink/bin_node/lib_dev/rpc.ml @@ -148,6 +148,9 @@ let container_forward_request ~public_endpoint ~private_endpoint ~keep_alive : let unlock_transactions () = Lwt_result_syntax.return_unit let is_locked () = Lwt_result_syntax.return_false + + let confirm_transactions ~clear_pending_queue_after:_ ~confirmed_txs:_ = + Lwt_result_syntax.return_unit end) let main ~data_dir ~evm_node_endpoint ?evm_node_private_endpoint diff --git a/etherlink/bin_node/lib_dev/services_backend_sig.ml b/etherlink/bin_node/lib_dev/services_backend_sig.ml index 09a2f48e43fd..111dbfa804f4 100644 --- a/etherlink/bin_node/lib_dev/services_backend_sig.ml +++ b/etherlink/bin_node/lib_dev/services_backend_sig.ml @@ -296,4 +296,13 @@ module type Tx_container = sig (** [is_locked] checks if the queue is locked. *) val is_locked : unit -> bool tzresult Lwt.t + + (** [confirm_transactions ~clear_pending_queue_after ~confirmed_txs] + confirms [confirmed_txs] hash. If [clear_pending_queue_after] + then any other pending transactions in the tx_queue are + dropped. *) + val confirm_transactions : + clear_pending_queue_after:bool -> + confirmed_txs:Ethereum_types.hash Seq.t -> + unit tzresult Lwt.t end diff --git a/etherlink/bin_node/lib_dev/tx_pool.ml b/etherlink/bin_node/lib_dev/tx_pool.ml index d80039959c81..5701d13f10b3 100644 --- a/etherlink/bin_node/lib_dev/tx_pool.ml +++ b/etherlink/bin_node/lib_dev/tx_pool.ml @@ -974,4 +974,7 @@ module Tx_container = struct let*? worker = Lazy.force worker in Worker.Queue.push_request_and_wait worker Request.Is_locked |> handle_request_error + + let confirm_transactions ~clear_pending_queue_after:_ ~confirmed_txs:_ = + clear_popped_transactions () end diff --git a/etherlink/bin_node/lib_dev/tx_queue.ml b/etherlink/bin_node/lib_dev/tx_queue.ml index 383cedb45db1..833b13b7619e 100644 --- a/etherlink/bin_node/lib_dev/tx_queue.ml +++ b/etherlink/bin_node/lib_dev/tx_queue.ml @@ -1041,14 +1041,6 @@ let pop_transactions ~validate_tx ~initial_validation_state = (Pop_transactions {validate_tx; validation_state = initial_validation_state}) |> handle_request_error -let confirm_transactions ~clear_pending_queue_after ~confirmed_txs = - let open Lwt_result_syntax in - let*? w = Lazy.force worker in - Worker.Queue.push_request_and_wait - w - (Confirm_transactions {confirmed_txs; clear_pending_queue_after}) - |> handle_request_error - module Internal_for_tests = struct module Nonce_bitset = Nonce_bitset module Address_nonce = Address_nonce @@ -1121,6 +1113,14 @@ module Tx_container = struct in loop () + let confirm_transactions ~clear_pending_queue_after ~confirmed_txs = + let open Lwt_result_syntax in + let*? w = Lazy.force worker in + Worker.Queue.push_request_and_wait + w + (Confirm_transactions {confirmed_txs; clear_pending_queue_after}) + |> handle_request_error + let lock_transactions () = bind_worker @@ fun w -> push_request w Lock_transactions diff --git a/etherlink/bin_node/lib_dev/tx_queue.mli b/etherlink/bin_node/lib_dev/tx_queue.mli index be6c8bf1b996..96a95d4751c5 100644 --- a/etherlink/bin_node/lib_dev/tx_queue.mli +++ b/etherlink/bin_node/lib_dev/tx_queue.mli @@ -52,14 +52,6 @@ val pop_transactions : initial_validation_state:'a -> (string * Ethereum_types.legacy_transaction_object) list tzresult Lwt.t -(** [confirm_transactions ~clear_pending_queue_after ~confirmed_txs] - confirms [confirmed_txs] hash. If [drop_unconfirmed] then any - other pending transactions in the tx_queue are dropped. *) -val confirm_transactions : - clear_pending_queue_after:bool -> - confirmed_txs:Ethereum_types.hash Seq.t -> - unit tzresult Lwt.t - (** wrapper of the Tx_queue to be compatible with the Tx_container signature for the services. *) module Tx_container : Services_backend_sig.Tx_container diff --git a/etherlink/fa-bridge-watchtower/etherlink_monitor.ml b/etherlink/fa-bridge-watchtower/etherlink_monitor.ml index d9cca8fe8812..68d8a34cd053 100644 --- a/etherlink/fa-bridge-watchtower/etherlink_monitor.ml +++ b/etherlink/fa-bridge-watchtower/etherlink_monitor.ml @@ -724,7 +724,7 @@ let handle_confirmed_txs {db; ws_client; _} in let* () = Db.Deposits.set_claimed db nonce exec in let* () = - Tx_queue.confirm_transactions + Tx_queue.Tx_container.confirm_transactions ~clear_pending_queue_after:false ~confirmed_txs:(Seq.cons tx_hash Seq.empty) in -- GitLab From 229b17fbf3903cc43bdf2863e924aa52f007df9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Cauderlier?= Date: Mon, 19 May 2025 11:33:54 +0200 Subject: [PATCH 11/14] Tezlink/Node/Block producer: skip validation --- etherlink/bin_node/lib_dev/block_producer.ml | 61 ++++++++++++-------- 1 file changed, 37 insertions(+), 24 deletions(-) diff --git a/etherlink/bin_node/lib_dev/block_producer.ml b/etherlink/bin_node/lib_dev/block_producer.ml index fdb783a110f0..bc4cf8480262 100644 --- a/etherlink/bin_node/lib_dev/block_producer.ml +++ b/etherlink/bin_node/lib_dev/block_producer.ml @@ -217,32 +217,45 @@ let validate_tx ~maximum_cumulative_size (current_size, validation_state) raw_tx in return `Drop -let tx_queue_pop_valid_tx ~chain_family:_ (head_info : Evm_context.head) +let tx_queue_pop_valid_tx ~chain_family (head_info : Evm_context.head) ~maximum_cumulative_size = let open Lwt_result_syntax in - let read = Evm_state.read head_info.evm_state in - let* base_fee_per_gas = Durable_storage.base_fee_per_gas read in - let* maximum_gas_limit = Durable_storage.maximum_gas_per_transaction read in - let* da_fee_per_byte = Durable_storage.da_fee_per_byte read in - let config = - Validate. - { - base_fee_per_gas; - maximum_gas_limit; - da_fee_per_byte; - next_nonce = (fun addr -> Durable_storage.nonce read addr); - balance = (fun addr -> Durable_storage.balance read addr); - } - in - let initial_validation_state = - ( 0, - Validate. - {config; addr_balance = String.Map.empty; addr_nonce = String.Map.empty} - ) - in - Tx_queue.pop_transactions - ~validate_tx:(validate_tx ~maximum_cumulative_size) - ~initial_validation_state + (* Skip validation if chain_family is Michelson. *) + match chain_family with + | L2_types.Michelson -> + let initial_validation_state = () in + Tx_queue.pop_transactions + ~validate_tx:(fun () _ _ -> return (`Keep ())) + ~initial_validation_state + | EVM -> + let read = Evm_state.read head_info.evm_state in + let* base_fee_per_gas = Durable_storage.base_fee_per_gas read in + let* maximum_gas_limit = + Durable_storage.maximum_gas_per_transaction read + in + let* da_fee_per_byte = Durable_storage.da_fee_per_byte read in + let config = + Validate. + { + base_fee_per_gas; + maximum_gas_limit; + da_fee_per_byte; + next_nonce = (fun addr -> Durable_storage.nonce read addr); + balance = (fun addr -> Durable_storage.balance read addr); + } + in + let initial_validation_state = + ( 0, + Validate. + { + config; + addr_balance = String.Map.empty; + addr_nonce = String.Map.empty; + } ) + in + Tx_queue.pop_transactions + ~validate_tx:(validate_tx ~maximum_cumulative_size) + ~initial_validation_state (** Produces a block if we find at least one valid transaction in the transaction pool or if [force] is true. *) -- GitLab From 67f4b73a1c139f94aab2e25cdacd658fa3d4f9ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Cauderlier?= Date: Wed, 30 Apr 2025 11:29:25 +0200 Subject: [PATCH 12/14] EVM node/Block_producer + Tx_queue + pool: move pop_transactions to Tx_container --- etherlink/bin_node/lib_dev/block_producer.ml | 24 ++++++++++--------- etherlink/bin_node/lib_dev/observer.ml | 4 ++++ etherlink/bin_node/lib_dev/proxy.ml | 9 ++++++- etherlink/bin_node/lib_dev/rpc.ml | 4 ++++ .../bin_node/lib_dev/services_backend_sig.ml | 16 +++++++++++++ etherlink/bin_node/lib_dev/tx_pool.ml | 4 ++++ etherlink/bin_node/lib_dev/tx_queue.ml | 18 +++++++------- etherlink/bin_node/lib_dev/tx_queue.mli | 19 --------------- 8 files changed, 59 insertions(+), 39 deletions(-) diff --git a/etherlink/bin_node/lib_dev/block_producer.ml b/etherlink/bin_node/lib_dev/block_producer.ml index bc4cf8480262..09adaed0a47f 100644 --- a/etherlink/bin_node/lib_dev/block_producer.ml +++ b/etherlink/bin_node/lib_dev/block_producer.ml @@ -217,14 +217,17 @@ let validate_tx ~maximum_cumulative_size (current_size, validation_state) raw_tx in return `Drop -let tx_queue_pop_valid_tx ~chain_family (head_info : Evm_context.head) - ~maximum_cumulative_size = +let pop_valid_tx ~chain_family + ~(tx_container : (module Services_backend_sig.Tx_container)) + (head_info : Evm_context.head) ~maximum_cumulative_size = let open Lwt_result_syntax in + let (module Tx_container) = tx_container in (* Skip validation if chain_family is Michelson. *) match chain_family with | L2_types.Michelson -> let initial_validation_state = () in - Tx_queue.pop_transactions + Tx_container.pop_transactions + ~maximum_cumulative_size ~validate_tx:(fun () _ _ -> return (`Keep ())) ~initial_validation_state | EVM -> @@ -253,7 +256,8 @@ let tx_queue_pop_valid_tx ~chain_family (head_info : Evm_context.head) addr_nonce = String.Map.empty; } ) in - Tx_queue.pop_transactions + Tx_container.pop_transactions + ~maximum_cumulative_size ~validate_tx:(validate_tx ~maximum_cumulative_size) ~initial_validation_state @@ -261,8 +265,8 @@ let tx_queue_pop_valid_tx ~chain_family (head_info : Evm_context.head) pool or if [force] is true. *) let produce_block_if_needed ~cctxt ~chain_family ~smart_rollup_address ~sequencer_key ~force ~timestamp ~delayed_hashes ~remaining_cumulative_size - ~uses_tx_queue ~(tx_container : (module Services_backend_sig.Tx_container)) - head_info = + ~uses_tx_queue:_ + ~(tx_container : (module Services_backend_sig.Tx_container)) head_info = let open Lwt_result_syntax in let (module Tx_container) = tx_container in let* transactions_and_objects = @@ -270,14 +274,12 @@ let produce_block_if_needed ~cctxt ~chain_family ~smart_rollup_address enough space for the smallest transaction. *) if remaining_cumulative_size <= minimum_ethereum_transaction_size then return [] - else if uses_tx_queue then - tx_queue_pop_valid_tx + else + pop_valid_tx ~chain_family + ~tx_container head_info ~maximum_cumulative_size:remaining_cumulative_size - else - Tx_pool.pop_transactions - ~maximum_cumulative_size:remaining_cumulative_size in let n = List.length transactions_and_objects + List.length delayed_hashes in if force || n > 0 then diff --git a/etherlink/bin_node/lib_dev/observer.ml b/etherlink/bin_node/lib_dev/observer.ml index 02a1b084b1a0..a2ceba27a1b1 100644 --- a/etherlink/bin_node/lib_dev/observer.ml +++ b/etherlink/bin_node/lib_dev/observer.ml @@ -143,6 +143,10 @@ let container_forward_tx ~keep_alive ~evm_node_endpoint : let confirm_transactions ~clear_pending_queue_after:_ ~confirmed_txs:_ = Lwt_result_syntax.return_unit + + let pop_transactions ~maximum_cumulative_size:_ ~validate_tx:_ + ~initial_validation_state:_ = + Lwt_result_syntax.return_nil end) let main ?network ?kernel_path ~data_dir ~(config : Configuration.t) ~no_sync diff --git a/etherlink/bin_node/lib_dev/proxy.ml b/etherlink/bin_node/lib_dev/proxy.ml index 463eaa65ab29..63ac6020f543 100644 --- a/etherlink/bin_node/lib_dev/proxy.ml +++ b/etherlink/bin_node/lib_dev/proxy.ml @@ -56,6 +56,10 @@ let container_forward_tx ~evm_node_endpoint ~keep_alive : let is_locked () = Lwt_result_syntax.return_false + let pop_transactions ~maximum_cumulative_size:_ ~validate_tx:_ + ~initial_validation_state:_ = + Lwt_result_syntax.return_nil + let confirm_transactions ~clear_pending_queue_after:_ ~confirmed_txs:_ = Lwt_result_syntax.return_unit end) @@ -75,7 +79,10 @@ let tx_queue_pop_and_inject (module Rollup_node_rpc : Services_backend_sig.S) else return (`Keep new_size) in let* popped_txs = - Tx_queue.pop_transactions ~initial_validation_state ~validate_tx + Tx_container.pop_transactions + ~maximum_cumulative_size + ~initial_validation_state + ~validate_tx in let*! hashes = Rollup_node_rpc.inject_transactions diff --git a/etherlink/bin_node/lib_dev/rpc.ml b/etherlink/bin_node/lib_dev/rpc.ml index c18011ae99ac..fc3732870bba 100644 --- a/etherlink/bin_node/lib_dev/rpc.ml +++ b/etherlink/bin_node/lib_dev/rpc.ml @@ -151,6 +151,10 @@ let container_forward_request ~public_endpoint ~private_endpoint ~keep_alive : let confirm_transactions ~clear_pending_queue_after:_ ~confirmed_txs:_ = Lwt_result_syntax.return_unit + + let pop_transactions ~maximum_cumulative_size:_ ~validate_tx:_ + ~initial_validation_state:_ = + Lwt_result_syntax.return_nil end) let main ~data_dir ~evm_node_endpoint ?evm_node_private_endpoint diff --git a/etherlink/bin_node/lib_dev/services_backend_sig.ml b/etherlink/bin_node/lib_dev/services_backend_sig.ml index 111dbfa804f4..b220b735560c 100644 --- a/etherlink/bin_node/lib_dev/services_backend_sig.ml +++ b/etherlink/bin_node/lib_dev/services_backend_sig.ml @@ -305,4 +305,20 @@ module type Tx_container = sig clear_pending_queue_after:bool -> confirmed_txs:Ethereum_types.hash Seq.t -> unit tzresult Lwt.t + + (** The Tx_pool pops transactions until the sum of the sizes of the + popped transactions reaches maximum_cumulative_size; it ignores + the [validate_tx] and [initial_validation_state] arguments, The + Tx_queue however ignores [maximum_cumulative_size] and instead + uses [validate_tx] to pop valid transactions until either `Drop + or `Stop is returned. *) + val pop_transactions : + maximum_cumulative_size:int -> + validate_tx: + ('a -> + string -> + Ethereum_types.legacy_transaction_object -> + [`Keep of 'a | `Drop | `Stop] tzresult Lwt.t) -> + initial_validation_state:'a -> + (string * Ethereum_types.legacy_transaction_object) list tzresult Lwt.t end diff --git a/etherlink/bin_node/lib_dev/tx_pool.ml b/etherlink/bin_node/lib_dev/tx_pool.ml index 5701d13f10b3..3a226c4029c0 100644 --- a/etherlink/bin_node/lib_dev/tx_pool.ml +++ b/etherlink/bin_node/lib_dev/tx_pool.ml @@ -977,4 +977,8 @@ module Tx_container = struct let confirm_transactions ~clear_pending_queue_after:_ ~confirmed_txs:_ = clear_popped_transactions () + + let pop_transactions ~maximum_cumulative_size ~validate_tx:_ + ~initial_validation_state:_ = + pop_transactions ~maximum_cumulative_size end diff --git a/etherlink/bin_node/lib_dev/tx_queue.ml b/etherlink/bin_node/lib_dev/tx_queue.ml index 833b13b7619e..05c8d3643f8a 100644 --- a/etherlink/bin_node/lib_dev/tx_queue.ml +++ b/etherlink/bin_node/lib_dev/tx_queue.ml @@ -1033,14 +1033,6 @@ let start ~config ~keep_alive () = let*! () = Tx_queue_events.is_ready () in return_unit -let pop_transactions ~validate_tx ~initial_validation_state = - let open Lwt_result_syntax in - let*? w = Lazy.force worker in - Worker.Queue.push_request_and_wait - w - (Pop_transactions {validate_tx; validation_state = initial_validation_state}) - |> handle_request_error - module Internal_for_tests = struct module Nonce_bitset = Nonce_bitset module Address_nonce = Address_nonce @@ -1131,4 +1123,14 @@ module Tx_container = struct let open Lwt_result_syntax in let*? worker = Lazy.force worker in Worker.Queue.push_request_and_wait worker Is_locked |> handle_request_error + + let pop_transactions ~maximum_cumulative_size:_ ~validate_tx + ~initial_validation_state = + let open Lwt_result_syntax in + let*? w = Lazy.force worker in + Worker.Queue.push_request_and_wait + w + (Pop_transactions + {validate_tx; validation_state = initial_validation_state}) + |> handle_request_error end diff --git a/etherlink/bin_node/lib_dev/tx_queue.mli b/etherlink/bin_node/lib_dev/tx_queue.mli index 96a95d4751c5..2d419faf96f6 100644 --- a/etherlink/bin_node/lib_dev/tx_queue.mli +++ b/etherlink/bin_node/lib_dev/tx_queue.mli @@ -33,25 +33,6 @@ val start : unit -> unit tzresult Lwt.t -(** [pop_transactions ~validate_tx ~initial_validation_state] pops as - many transactions as possible from the queue, validating them with - [validate_tx]. If [validate_tx] returns [`Keep validation_state] - then the evaluated transaction is popped, else if it returns - [`Drop], it's considered invalid and it's callback is called with - [`Refused]. If [validate_tx] returns [`Stop] then the caller has - enough transactions. - - If the tx_queue is locked (c.f. {!lock_transactions} then returns - the empty list. *) -val pop_transactions : - validate_tx: - ('a -> - string -> - Ethereum_types.legacy_transaction_object -> - [`Keep of 'a | `Drop | `Stop] tzresult Lwt.t) -> - initial_validation_state:'a -> - (string * Ethereum_types.legacy_transaction_object) list tzresult Lwt.t - (** wrapper of the Tx_queue to be compatible with the Tx_container signature for the services. *) module Tx_container : Services_backend_sig.Tx_container -- GitLab From ac46e41696e9a1731aa9285471c905e6eee930ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Cauderlier?= Date: Fri, 2 May 2025 18:09:46 +0200 Subject: [PATCH 13/14] EVM node/Block_producer: remove uses_tx_queue parameter --- etherlink/bin_node/lib_dev/block_producer.ml | 10 ++-------- etherlink/bin_node/lib_dev/block_producer.mli | 1 - etherlink/bin_node/lib_dev/sequencer.ml | 1 - 3 files changed, 2 insertions(+), 10 deletions(-) diff --git a/etherlink/bin_node/lib_dev/block_producer.ml b/etherlink/bin_node/lib_dev/block_producer.ml index 09adaed0a47f..5643bfa0e2e2 100644 --- a/etherlink/bin_node/lib_dev/block_producer.ml +++ b/etherlink/bin_node/lib_dev/block_producer.ml @@ -10,7 +10,6 @@ type parameters = { smart_rollup_address : string; sequencer_key : Client_keys.sk_uri; maximum_number_of_chunks : int; - uses_tx_queue : bool; chain_family : L2_types.chain_family; tx_container : (module Services_backend_sig.Tx_container); } @@ -265,7 +264,6 @@ let pop_valid_tx ~chain_family pool or if [force] is true. *) let produce_block_if_needed ~cctxt ~chain_family ~smart_rollup_address ~sequencer_key ~force ~timestamp ~delayed_hashes ~remaining_cumulative_size - ~uses_tx_queue:_ ~(tx_container : (module Services_backend_sig.Tx_container)) head_info = let open Lwt_result_syntax in let (module Tx_container) = tx_container in @@ -319,9 +317,8 @@ let head_info_and_delayed_transactions ~with_delayed_transactions let*! head_info = Evm_context.head_info () in return (head_info, delayed_hashes, remaining_cumulative_size) -let produce_block ~chain_family ~uses_tx_queue ~cctxt ~smart_rollup_address - ~sequencer_key ~force ~timestamp ~maximum_number_of_chunks - ~with_delayed_transactions +let produce_block ~chain_family ~cctxt ~smart_rollup_address ~sequencer_key + ~force ~timestamp ~maximum_number_of_chunks ~with_delayed_transactions ~(tx_container : (module Services_backend_sig.Tx_container)) = let open Lwt_result_syntax in let (module Tx_container) = tx_container in @@ -364,7 +361,6 @@ let produce_block ~chain_family ~uses_tx_queue ~cctxt ~smart_rollup_address ~force ~delayed_hashes ~remaining_cumulative_size - ~uses_tx_queue ~tx_container head_info @@ -385,14 +381,12 @@ module Handlers = struct smart_rollup_address; sequencer_key; maximum_number_of_chunks; - uses_tx_queue; chain_family; tx_container; } = state in produce_block - ~uses_tx_queue ~chain_family ~cctxt ~smart_rollup_address diff --git a/etherlink/bin_node/lib_dev/block_producer.mli b/etherlink/bin_node/lib_dev/block_producer.mli index e7575f054348..cabbd676e14c 100644 --- a/etherlink/bin_node/lib_dev/block_producer.mli +++ b/etherlink/bin_node/lib_dev/block_producer.mli @@ -10,7 +10,6 @@ type parameters = { smart_rollup_address : string; sequencer_key : Client_keys.sk_uri; maximum_number_of_chunks : int; - uses_tx_queue : bool; chain_family : L2_types.chain_family; tx_container : (module Services_backend_sig.Tx_container); } diff --git a/etherlink/bin_node/lib_dev/sequencer.ml b/etherlink/bin_node/lib_dev/sequencer.ml index c2671dacb290..63882adc1417 100644 --- a/etherlink/bin_node/lib_dev/sequencer.ml +++ b/etherlink/bin_node/lib_dev/sequencer.ml @@ -322,7 +322,6 @@ let main ~data_dir ?(genesis_timestamp = Misc.now ()) ~cctxt smart_rollup_address = smart_rollup_address_b58; sequencer_key = sequencer_config.sequencer; maximum_number_of_chunks = sequencer_config.max_number_of_chunks; - uses_tx_queue = Configuration.is_tx_queue_enabled configuration; chain_family; tx_container; } -- GitLab From 741df78b87d9aed22e53065c8412fd87e70f4c08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Cauderlier?= Date: Mon, 19 May 2025 12:31:03 +0200 Subject: [PATCH 14/14] EVM node/Tx_container: improve docstring of confirm_transactions --- etherlink/bin_node/lib_dev/services_backend_sig.ml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/etherlink/bin_node/lib_dev/services_backend_sig.ml b/etherlink/bin_node/lib_dev/services_backend_sig.ml index b220b735560c..d6edcf72f031 100644 --- a/etherlink/bin_node/lib_dev/services_backend_sig.ml +++ b/etherlink/bin_node/lib_dev/services_backend_sig.ml @@ -297,7 +297,12 @@ module type Tx_container = sig (** [is_locked] checks if the queue is locked. *) val is_locked : unit -> bool tzresult Lwt.t - (** [confirm_transactions ~clear_pending_queue_after ~confirmed_txs] + (** The Tx_queue has a table of pending transactions. There are two + ways for transactions to be removed from this table; either they + are confirmed because they have been seen in a block or they are + dropped. + + [confirm_transactions ~clear_pending_queue_after ~confirmed_txs] confirms [confirmed_txs] hash. If [clear_pending_queue_after] then any other pending transactions in the tx_queue are dropped. *) -- GitLab