From 08056762c6e576e75638416adaf271fa9f187cd7 Mon Sep 17 00:00:00 2001 From: Thomas Letan Date: Fri, 30 Aug 2024 20:08:32 +0200 Subject: [PATCH] EVM Node: Make the TE sequencer mode use the read-only context for RPCs --- .../lib_dev/threshold_encryption_sequencer.ml | 67 +++++-------------- 1 file changed, 16 insertions(+), 51 deletions(-) diff --git a/etherlink/bin_node/lib_dev/threshold_encryption_sequencer.ml b/etherlink/bin_node/lib_dev/threshold_encryption_sequencer.ml index cc3dee7a51ea..c61a32cc965f 100644 --- a/etherlink/bin_node/lib_dev/threshold_encryption_sequencer.ml +++ b/etherlink/bin_node/lib_dev/threshold_encryption_sequencer.ml @@ -6,41 +6,6 @@ (* *) (*****************************************************************************) -module MakeBackend (Ctxt : sig - val smart_rollup_address : Tezos_crypto.Hashed.Smart_rollup_address.t -end) : Services_backend_sig.Backend = struct - module Reader = Evm_context_based_reader - module SimulatorBackend = Evm_context_based_reader - - module TxEncoder = struct - type transactions = (string * Ethereum_types.transaction_object) list - - type messages = transactions - - let encode_transactions ~smart_rollup_address:_ ~transactions:_ = - assert false - end - - module Publisher = struct - type messages = TxEncoder.messages - - let publish_messages ~timestamp:_ ~smart_rollup_address:_ ~messages:_ = - assert false - end - - let block_param_to_block_number = Evm_context.block_param_to_block_number - - module Tracer = Tracer - - let smart_rollup_address = - Tezos_crypto.Hashed.Smart_rollup_address.to_string Ctxt.smart_rollup_address -end - -module Make (Ctxt : sig - val smart_rollup_address : Tezos_crypto.Hashed.Smart_rollup_address.t -end) = - Services_backend_sig.Make (MakeBackend (Ctxt)) - let install_finalizer_seq server_public_finalizer server_private_finalizer = let open Lwt_syntax in Lwt_exit.register_clean_up_callback ~loc:__LOC__ @@ fun exit_status -> @@ -126,17 +91,20 @@ let main ~data_dir ?(genesis_timestamp = Misc.now ()) ~cctxt Tezos_crypto.Hashed.Smart_rollup_address.of_string_exn smart_rollup_address in - let module Rollup_rpc = - Make - (struct - let smart_rollup_address = smart_rollup_address_typed - end) - (Evm_context) + let* ro_ctxt = + Evm_ro_context.load + ~smart_rollup_address:smart_rollup_address_typed + ~data_dir + ~preimages:configuration.kernel_execution.preimages + ?preimages_endpoint:configuration.kernel_execution.preimages_endpoint + () in + let ro_backend = Evm_ro_context.ro_backend ro_ctxt configuration in + let* () = Tx_pool.start { - rollup_node = (module Rollup_rpc); + rollup_node = ro_backend; smart_rollup_address; mode = Sequencer; tx_timeout_limit = configuration.tx_pool_timeout_limit; @@ -176,21 +144,18 @@ let main ~data_dir ?(genesis_timestamp = Misc.now ()) ~cctxt let* finalizer_public_server = Rpc_server.start_public_server ~evm_services: - { - next_blueprint_number = Evm_context.next_blueprint_number; - find_blueprint = Evm_context.blueprint; - smart_rollup_address = smart_rollup_address_typed; - time_between_blocks = - threshold_encryption_sequencer_config.time_between_blocks; - } + Evm_ro_context.( + evm_services_methods + ro_ctxt + threshold_encryption_sequencer_config.time_between_blocks) configuration - ((module Rollup_rpc), smart_rollup_address_typed) + (ro_backend, smart_rollup_address_typed) in let* finalizer_private_server = Rpc_server.start_private_server ~block_production:`Threshold_encryption configuration - ((module Rollup_rpc), smart_rollup_address_typed) + (ro_backend, smart_rollup_address_typed) in let (_ : Lwt_exit.clean_up_callback_id) = install_finalizer_seq finalizer_public_server finalizer_private_server -- GitLab