diff --git a/.gitlab/ci/jobs/test/tezt.yml b/.gitlab/ci/jobs/test/tezt.yml index 9d53e3ae58b8d41cd344ea0e2bf0f84424cf4751..95ba8c88df6e6b4b361f9cfb59ab674e5bbc54a6 100644 --- a/.gitlab/ci/jobs/test/tezt.yml +++ b/.gitlab/ci/jobs/test/tezt.yml @@ -71,6 +71,7 @@ include: .gitlab/ci/jobs/test/common.yml - .image_template__runtime_e2etest_dependencies - .template__coverage_files - .tezt_template + - .tags_template__no_gcp variables: # Certain tests can be blacklisted by modifying the TESTS variable. # Do not tests with the tag 'ci_disabled' and 'flaky'. @@ -89,8 +90,6 @@ include: .gitlab/ci/jobs/test/common.yml # WARNING: if you increase the number of parallel jobs, you need to # update test_coverage.yml with the new list of jobs. parallel: 60 - tags: - - gcp_tezt tezt: extends: @@ -112,7 +111,9 @@ tezt-greedy-4k: parallel: 4 tezt-greedy-3k: - extends: [.tezt_tests] + extends: + - .tezt_tests + - .tags_template__no_gcp variables: TESTS: "memory_3k" TEZT_PARALLEL: 1 @@ -126,6 +127,7 @@ tezt:static-binaries: - .default_settings_template - .image_template__runtime_e2etest_dependencies - .tezt_template + - .tags_template__no_gcp dependencies: # Fetch src/proto_*/parameters/*.json and tezt/tests/main.exe from # build_x86_64-exp-dev-extra diff --git a/CHANGES.rst b/CHANGES.rst index daf7fcd84dbb332b233a60a4ca762d56f9023129..f134fe7f88016762375ec9a8d8dd8c3d3ca38ca7 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -44,13 +44,6 @@ Node nodes. Also, improved the consistency of ``snapshot`` import errors messages (MR :gl:`!10138`) -- Introduced a new process, forked by the node, that is responsible of - managing the RPC server: the RPC-process. It is used by default by - the node. - -- Introduced a new ``--local-rpc-addr`` that starts the RPC server - locally, not using the dedicated RPC-process. - - Add logs at ``Info`` level about the disconnection reasons in the p2p section. - Removed a spurious "missing validation plugin" warning message that diff --git a/docs/developer/rpc.rst b/docs/developer/rpc.rst index ffa212cc5565b639655886c8c5981e3fdfdd511a..ac79e0e8a888fc6372c7a83a94ffe9cd29af9665 100644 --- a/docs/developer/rpc.rst +++ b/docs/developer/rpc.rst @@ -1,20 +1,11 @@ JSON/RPC interface ================== -The Octez node provides a JSON/RPC interface. Note that it is an RPC -interface, and it is JSON based, but it does not follow the “JSON-RPC” -protocol. It is not active by default and it must be explicitly -activated with the ``--rpc-addr`` option. In that case, an RPC server -is started in a separate process, alongside the node, that is -responsible of dealing with the RPCs. Starting the RPC server as an -independent process avoids slowing down the node when an intensive RPC -usage is being done. It is also possible to run an RPC server locally -to the node thanks to the ``--local-rpc-addr`` command. Use -``--local-rpc-addr`` to use an in-node process RPC server only if you -understand the associated performance issues. - -As an example, if you are not trying to run a public RPC node, but you -just want to explore the RPC interface on your own, you would run: +The Octez node provides a JSON/RPC interface. Note that it is an RPC, +and it is JSON based, but it does not follow the “JSON-RPC” protocol. It +is not active by default and it must be explicitly activated with the +``--rpc-addr`` option. Typically, if you are not trying to run a local +network and just want to explore the RPC, you would run: :: diff --git a/src/bin_node/node_run_command.ml b/src/bin_node/node_run_command.ml index 24b75745275a7776db9c8cf762a2da70ccb8d395..69814fae9cca378173aa701a1c2fd0ec13621d1e 100644 --- a/src/bin_node/node_run_command.ml +++ b/src/bin_node/node_run_command.ml @@ -107,20 +107,12 @@ module Event = struct declare_3 ~section ~name:"starting_local_rpc_server" - ~msg:"starting local RPC server on {host}:{port} (acl = {acl_policy})" + ~msg:"starting RPC server on {host}:{port} (acl = {acl_policy})" ~level:Notice ("host", Data_encoding.string) ("port", Data_encoding.uint16) ("acl_policy", Data_encoding.string) - let starting_internal_rpc_server = - declare_0 - ~section - ~name:"starting_internal_rpc_server" - ~msg:"starting internal RPC server" - ~level:Info - () - let starting_metrics_server = declare_2 ~section @@ -370,15 +362,9 @@ module Metrics_server = Prometheus_app.Cohttp (Cohttp_lwt_unix.Server) type port = int -type socket_file = string +type single_server_kind = Local of Conduit_lwt_unix.server * port -type single_server_kind = - | Process of socket_file - | Local of Conduit_lwt_unix.server * port - -let extract_mode = function - | Process socket_file -> `Unix_domain_socket (`File socket_file) - | Local (mode, _) -> mode +let extract_mode = function Local (mode, _) -> mode (* Add default accepted CORS headers *) let sanitize_cors_headers ~default headers = @@ -396,9 +382,6 @@ let launch_rpc_server (config : Config_file.t) dir rpc_server_kind addr = let* acl = (* Also emits events depending on server kind *) match rpc_server_kind with - | Process _ -> - let*! () = Event.(emit starting_internal_rpc_server) () in - return_none | Local (mode, port) -> let*! acl_policy = RPC_server.Acl.resolve_domain_names rpc_config.acl in let acl = @@ -454,22 +437,16 @@ let launch_rpc_server (config : Config_file.t) dir rpc_server_kind addr = (* FIXME: https://gitlab.com/tezos/tezos/-/issues/1312 This exception seems to be unreachable. *) - | Unix.Unix_error (Unix.EADDRINUSE, "bind", "") as exn -> ( + | Unix.Unix_error (Unix.EADDRINUSE, "bind", "") -> ( match rpc_server_kind with - | Process _ -> fail_with_exn exn | Local (_, port) -> tzfail (RPC_Port_already_in_use [(addr, port)])) | exn -> fail_with_exn exn) (* Describes the kind of servers that can be handled by the node. - Local_rpc_server: RPC server is run by the node itself (this may block the node in case of heavy RPC load), - - External_rpc_server: RPC server is spawned as an external - process, - No_server: the node is not responding to any RPC. *) -type rpc_server_kind = - | Local_rpc_server of RPC_server.server list - | External_rpc_server of (RPC_server.server * Rpc_process_worker.t) list - | No_server +type rpc_server_kind = Local_rpc_server of RPC_server.server list | No_server (* Initializes an RPC server handled by the node main process. *) let init_local_rpc_server (config : Config_file.t) dir = @@ -495,83 +472,9 @@ let init_local_rpc_server (config : Config_file.t) dir = in launch_rpc_server config dir (Local (mode, port)) addr) addrs) - config.rpc.local_listen_addrs - in - return (Local_rpc_server servers) - -let rpc_socket_path ~socket_dir ~id ~pid = - let filename = Format.sprintf "octez-external-rpc-socket-%d-%d" pid id in - Filename.concat socket_dir filename - -(* Initializes an RPC server handled by the node process. It will be - used by an external RPC process, identified by [id], to forward - RPCs to the node through a Unix socket. *) -let init_local_rpc_server_for_external_process id (config : Config_file.t) dir - addr = - let open Lwt_result_syntax in - let socket_dir = Tezos_base_unix.Socket.get_temporary_socket_dir () in - let pid = Unix.getpid () in - let comm_socket_path = rpc_socket_path ~id ~socket_dir ~pid in - (* Register a clean up callback to clean the comm_socket_path when - shutting down. Indeed, the socket file is created by the - Conduit-lwt-unix.Conduit_lwt_server.listen function, but the - resource is not cleaned. *) - let _ = - Lwt_exit.register_clean_up_callback ~loc:__LOC__ (fun _ -> - Lwt_unix.unlink comm_socket_path) - in - let* rpc_server = - launch_rpc_server config dir (Process comm_socket_path) addr - in - return (rpc_server, comm_socket_path) - -let init_external_rpc_server config node_version dir internal_events = - let open Lwt_result_syntax in - (* Start one rpc_process for each rpc endpoint. *) - let id = ref 0 in - let* rpc_servers = - List.concat_map_ep - (fun addr -> - let* addrs = Config_file.resolve_rpc_listening_addrs addr in - match addrs with - | [] -> failwith "Cannot resolve listening address: %S" addr - | addrs -> - List.map_ep - (fun (p2p_point : P2p_point.Id.t) -> - let id = - let curid = !id in - incr id ; - curid - in - let* local_rpc_server, comm_socket_path = - init_local_rpc_server_for_external_process - id - config - dir - (fst p2p_point) - in - let addr = P2p_point.Id.to_string p2p_point in - (* Update the config sent to the rpc_process to - start so that it contains a single listen - address. *) - let config = - {config with rpc = {config.rpc with listen_addrs = [addr]}} - in - let rpc_process = - Octez_rpc_process.Rpc_process_worker.create - ~comm_socket_path - config - node_version - internal_events - in - let* () = - Octez_rpc_process.Rpc_process_worker.start rpc_process - in - return (local_rpc_server, rpc_process)) - addrs) config.rpc.listen_addrs in - return (External_rpc_server rpc_servers) + return (Local_rpc_server servers) let metrics_serve metrics_addrs = let open Lwt_result_syntax in @@ -610,7 +513,7 @@ let init_zcash () = "Failed to initialize Zcash parameters: %s" (Printexc.to_string exn)) -let init_rpc (config : Config_file.t) (node : Node.t) internal_events = +let init_rpc (config : Config_file.t) (node : Node.t) _internal_events = let open Lwt_result_syntax in (* Start local RPC server (handled by the node main process) only when at least one local listen addr is given. *) @@ -631,20 +534,12 @@ let init_rpc (config : Config_file.t) (node : Node.t) internal_events = Tezos_rpc.Service.description_service in - let* local_rpc_server = - if config.rpc.local_listen_addrs = [] then return No_server - else init_local_rpc_server config dir - in (* Start RPC process only when at least one listen addr is given. *) let* rpc_server = if config.rpc.listen_addrs = [] then return No_server - else - (* Starts the node's local RPC server that aims to handle the - RPCs forwarded by the rpc_process, if they cannot be - processed by the rpc_process itself. *) - init_external_rpc_server config node_version dir internal_events + else init_local_rpc_server config dir in - return (local_rpc_server :: [rpc_server]) + return [rpc_server] let run ?verbosity ?sandbox ?target ?(cli_warnings = []) ?ignore_testchain_warning ~singleprocess ~force_history_mode_switch @@ -724,18 +619,6 @@ let run ?verbosity ?sandbox ?target ?(cli_warnings = []) List.iter_s (function | No_server -> Lwt.return_unit - | External_rpc_server rpc_servers -> - List.iter_p - (fun (local_server, rpc_process) -> - (* Stop the RPC_process first to avoid requests to - be forwarded to the note with a RPC_server that - is down. *) - let*! () = - Octez_rpc_process.Rpc_process_worker.stop rpc_process - in - let*! () = RPC_server.shutdown local_server in - Lwt.return_unit) - rpc_servers | Local_rpc_server rpc_server -> List.iter_p RPC_server.shutdown rpc_server) rpc_servers) diff --git a/src/lib_node_config/config_file.ml b/src/lib_node_config/config_file.ml index 711cbe39282cc5315a627d042778d53d9485d625..0498b888fef7774ec5cb6c6f6f9a9235227530c6 100644 --- a/src/lib_node_config/config_file.ml +++ b/src/lib_node_config/config_file.ml @@ -355,7 +355,6 @@ and p2p = { and rpc = { listen_addrs : string list; - local_listen_addrs : string list; cors_origins : string list; cors_headers : string list; tls : tls option; @@ -383,7 +382,6 @@ let default_p2p = let default_rpc = { listen_addrs = []; - local_listen_addrs = []; cors_origins = []; cors_headers = []; tls = None; @@ -551,22 +549,13 @@ let p2p = let rpc : rpc Data_encoding.t = let open Data_encoding in conv - (fun { - cors_origins; - cors_headers; - listen_addrs; - local_listen_addrs; - tls; - acl; - media_type; - } -> + (fun {cors_origins; cors_headers; listen_addrs; tls; acl; media_type} -> let cert, key = match tls with | None -> (None, None) | Some {cert; key} -> (Some cert, Some key) in ( Some listen_addrs, - Some local_listen_addrs, None, cors_origins, cors_headers, @@ -575,7 +564,6 @@ let rpc : rpc Data_encoding.t = acl, media_type )) (fun ( listen_addrs, - local_listen_addrs, legacy_listen_addr, cors_origins, cors_headers, @@ -598,31 +586,14 @@ let rpc : rpc Data_encoding.t = "Config file: Use only \"listen-addrs\" and not (legacy) \ \"listen-addr\"." in - let local_listen_addrs = - Option.value local_listen_addrs ~default:default_rpc.local_listen_addrs - in - { - listen_addrs; - local_listen_addrs; - cors_origins; - cors_headers; - tls; - acl; - media_type; - }) - (obj9 + {listen_addrs; cors_origins; cors_headers; tls; acl; media_type}) + (obj8 (opt "listen-addrs" ~description: "Hosts to listen to. If the port is not specified, the default \ port 8732 will be assumed." (list string)) - (opt - "local-listen-addrs" - ~description: - "Hosts to listen to. If the port is not specified, the default \ - port 8732 will be assumed." - (list string)) (opt "listen-addr" ~description:"Legacy value: Host to listen to" string) (dft "cors-origin" @@ -839,9 +810,9 @@ let update ?(disable_config_validation = false) ?data_dir ?min_connections ?expected_connections ?max_connections ?max_download_speed ?max_upload_speed ?binary_chunks_size ?peer_table_size ?expected_pow ?bootstrap_peers ?listen_addr ?advertised_net_port ?discovery_addr ?(rpc_listen_addrs = []) - ?(local_rpc_listen_addrs = []) ?(allow_all_rpc = []) - ?(media_type = Media_type.Command_line.Any) ?(metrics_addr = []) - ?operation_metadata_size_limit ?(private_mode = default_p2p.private_mode) + ?(allow_all_rpc = []) ?(media_type = Media_type.Command_line.Any) + ?(metrics_addr = []) ?operation_metadata_size_limit + ?(private_mode = default_p2p.private_mode) ?(disable_p2p_maintenance = Option.is_none default_p2p.limits.maintenance_idle_time) ?(disable_p2p_swap = Option.is_none default_p2p.limits.swap_linger) @@ -921,8 +892,6 @@ let update ?(disable_config_validation = false) ?data_dir ?min_connections and rpc : rpc = { listen_addrs = unopt_list ~default:cfg.rpc.listen_addrs rpc_listen_addrs; - local_listen_addrs = - unopt_list ~default:cfg.rpc.local_listen_addrs local_rpc_listen_addrs; cors_origins = unopt_list ~default:cfg.rpc.cors_origins cors_origins; cors_headers = unopt_list ~default:cfg.rpc.cors_headers cors_headers; tls = Option.either rpc_tls cfg.rpc.tls; diff --git a/src/lib_node_config/config_file.mli b/src/lib_node_config/config_file.mli index 9a63c29b3456eb52622270155fd3b32a1286af31..6100bb26263cf4d0555b7d1764ba560c693edbf5 100644 --- a/src/lib_node_config/config_file.mli +++ b/src/lib_node_config/config_file.mli @@ -75,7 +75,6 @@ and p2p = { and rpc = { listen_addrs : string list; - local_listen_addrs : string list; cors_origins : string list; cors_headers : string list; tls : tls option; @@ -117,7 +116,6 @@ val update : ?advertised_net_port:int -> ?discovery_addr:string -> ?rpc_listen_addrs:string list -> - ?local_rpc_listen_addrs:string list -> ?allow_all_rpc:P2p_point.Id.addr_port_id list -> ?media_type:Media_type.Command_line.t -> ?metrics_addr:string list -> diff --git a/src/lib_node_config/shared_arg.ml b/src/lib_node_config/shared_arg.ml index 8a095fa82f72d24ac01ebcc68828eb96fdb7769b..30234945e6160384066ecd26a32beb1ec183442f 100644 --- a/src/lib_node_config/shared_arg.ml +++ b/src/lib_node_config/shared_arg.ml @@ -49,7 +49,6 @@ type t = { advertised_net_port : int option; discovery_addr : string option; rpc_listen_addrs : string list; - local_rpc_listen_addrs : string list; private_mode : bool; disable_p2p_maintenance : bool; disable_p2p_swap : bool; @@ -185,11 +184,10 @@ let wrap data_dir config_file network connections max_download_speed max_upload_speed binary_chunks_size peer_table_size listen_addr advertised_net_port discovery_addr peers no_bootstrap_peers bootstrap_threshold private_mode disable_p2p_maintenance disable_p2p_swap - disable_mempool enable_testchain expected_pow rpc_listen_addrs - local_rpc_listen_addrs rpc_tls cors_origins cors_headers log_output - log_coloring history_mode synchronisation_threshold latency - disable_config_validation allow_all_rpc media_type metrics_addr - operation_metadata_size_limit = + disable_mempool enable_testchain expected_pow rpc_listen_addrs rpc_tls + cors_origins cors_headers log_output log_coloring history_mode + synchronisation_threshold latency disable_config_validation allow_all_rpc + media_type metrics_addr operation_metadata_size_limit = let actual_data_dir = Option.value ~default:Config_file.default_data_dir data_dir in @@ -217,7 +215,6 @@ let wrap data_dir config_file network connections max_download_speed advertised_net_port; discovery_addr; rpc_listen_addrs; - local_rpc_listen_addrs; private_mode; disable_p2p_maintenance; disable_p2p_swap; @@ -658,16 +655,6 @@ module Term = struct Arg.( value & opt_all string [] & info ~docs ~doc ~docv:"ADDR:PORT" ["rpc-addr"]) - let local_rpc_listen_addrs = - let doc = - "The TCP socket address at which this local RPC server instance can be \ - reached. As a local RPC server is handled by the node itself, calling \ - computational intensive RPCs can affect the performances of the node." - in - Arg.( - value & opt_all string [] - & info ~docs ~doc ~docv:"ADDR:PORT" ["local-rpc-addr"]) - let rpc_tls = let doc = "Enable TLS for this RPC server with the provided certificate and key." @@ -731,11 +718,10 @@ module Term = struct $ peer_table_size $ listen_addr $ advertised_net_port $ discovery_addr $ peers $ no_bootstrap_peers $ bootstrap_threshold $ private_mode $ disable_p2p_maintenance $ disable_p2p_swap $ disable_mempool - $ enable_testchain $ expected_pow $ rpc_listen_addrs - $ local_rpc_listen_addrs $ rpc_tls $ cors_origins $ cors_headers - $ log_output $ log_coloring $ history_mode $ synchronisation_threshold - $ latency $ disable_config_validation $ allow_all_rpc $ media_type - $ metrics_addr $ operation_metadata_size_limit + $ enable_testchain $ expected_pow $ rpc_listen_addrs $ rpc_tls + $ cors_origins $ cors_headers $ log_output $ log_coloring $ history_mode + $ synchronisation_threshold $ latency $ disable_config_validation + $ allow_all_rpc $ media_type $ metrics_addr $ operation_metadata_size_limit end let read_config_file args = @@ -866,7 +852,6 @@ let patch_config ?(may_override_network = false) ?(emit = Event.emit) disable_mempool; enable_testchain; rpc_listen_addrs; - local_rpc_listen_addrs; rpc_tls; cors_origins; cors_headers; @@ -1020,7 +1005,6 @@ let patch_config ?(may_override_network = false) ?(emit = Event.emit) ?advertised_net_port ?discovery_addr ~rpc_listen_addrs - ~local_rpc_listen_addrs ~allow_all_rpc ~media_type ~metrics_addr diff --git a/src/lib_node_config/shared_arg.mli b/src/lib_node_config/shared_arg.mli index 3328959a4b2dc99758b033e53fce5be1b58cef23..5d574693159b335316055180c8b8702db53ee36e 100644 --- a/src/lib_node_config/shared_arg.mli +++ b/src/lib_node_config/shared_arg.mli @@ -53,8 +53,6 @@ type t = { discovery_addr : string option; rpc_listen_addrs : string list; (** a list of addresses to listen to RPC requests on *) - local_rpc_listen_addrs : string list; - (** a list of addresses to listen to RPC requests on *) private_mode : bool; (** enables the private mode, see https://tezos.gitlab.io/user/node-configuration.html#private-node *) diff --git a/tezt/tests/main.ml b/tezt/tests/main.ml index 2da7b89e2c9a944bb40f9123d08e7c0d40687aaa..393383631a1f372e478bb7d6decd3174e5cd95cf 100644 --- a/tezt/tests/main.ml +++ b/tezt/tests/main.ml @@ -175,7 +175,6 @@ let register_protocol_tests_that_use_supports_correctly () = Protocol_limits.register ~protocols ; Proxy.register ~protocols ; Proxy_server_test.register ~protocols ; - Rpc_process.register ~protocols ; RPC_test.register protocols ; Rpc_versioning_attestation.register ~protocols ; Reject_malformed_micheline.register ~protocols ; diff --git a/tezt/tests/p2p.ml b/tezt/tests/p2p.ml index dae902b5b59a7cb2d905bc2635981cfdab8a3a5e..e9623ce368a89667b2030504673b42b4c8342387 100644 --- a/tezt/tests/p2p.ml +++ b/tezt/tests/p2p.ml @@ -345,21 +345,11 @@ module Maintenance = struct max_target max_threshold max_connections ; - (* TODO: https://gitlab.com/tezos/tezos/-/issues/6442 - This test launches 10 nodes and consumes a large amount of memory. - To reduce memory consumption each node launches its RPC server locally. - A better way to reduce memory consumption would be to use nodes that - only have the p2p layer. *) - let* target_node = - Node.init ~rpc_local:true [Connections expected_connections] - in + let* target_node = Node.init [Connections expected_connections] in let* target_client = Client.init ~endpoint:(Node target_node) () in Log.info "Target created." ; let nodes = - Cluster.create - max_connections - ~rpc_local:true - [Connections (max_connections - 1)] + Cluster.create max_connections [Connections (max_connections - 1)] in Cluster.clique nodes ; let* () = Cluster.start ~public:true nodes in diff --git a/tezt/tests/rpc_process.ml b/tezt/tests/rpc_process.ml deleted file mode 100644 index 8a6841bd3da067b5a9aec0ebe97e0c792ae9c610..0000000000000000000000000000000000000000 --- a/tezt/tests/rpc_process.ml +++ /dev/null @@ -1,353 +0,0 @@ -(*****************************************************************************) -(* *) -(* Open Source License *) -(* Copyright (c) 2023 Nomadic Labs *) -(* *) -(* Permission is hereby granted, free of charge, to any person obtaining a *) -(* copy of this software and associated documentation files (the "Software"),*) -(* to deal in the Software without restriction, including without limitation *) -(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *) -(* and/or sell copies of the Software, and to permit persons to whom the *) -(* Software is furnished to do so, subject to the following conditions: *) -(* *) -(* The above copyright notice and this permission notice shall be included *) -(* in all copies or substantial portions of the Software. *) -(* *) -(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*) -(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *) -(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *) -(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*) -(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *) -(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *) -(* DEALINGS IN THE SOFTWARE. *) -(* *) -(*****************************************************************************) - -(* Testing - ------- - Component: Node's RPC_process - Invocation: dune exec tezt/tests/main.exe -- --file rpc_process.ml - Subject: Tests the resilience of the RPC process -*) - -let wait_for_RPC_process_pid node = - let filter json = JSON.(json |> as_int_opt) in - Node.wait_for node "rpc_process_started.v0" filter - -type signal = SIGABRT | SIGINT | SIGKILL | SIGQUIT | SIGTERM - -let signal_to_int = function - | SIGABRT -> Sys.sigabrt - | SIGINT -> Sys.sigint - | SIGKILL -> Sys.sigkill - | SIGQUIT -> Sys.sigquit - | SIGTERM -> Sys.sigterm - -let pp_signal ppf signal = - let str = - match signal with - | SIGABRT -> "sigabrt" - | SIGINT -> "sigint" - | SIGKILL -> "sigkill" - | SIGQUIT -> "sigquit" - | SIGTERM -> "sigterm" - in - Format.fprintf ppf "%s" str - -let kill_process ~pid ~signal = - Log.info "Kill the rpc process (pid %d) with signal %a" pid pp_signal signal ; - Unix.kill pid (signal_to_int signal) - -let head_can_be_requested ~expected_level client = - let* json = Client.RPC.call client @@ RPC.get_chain_block_header () in - let v = JSON.(json |-> "level" |> as_int) in - return (v = expected_level) - -let test_kill = - Protocol.register_test - ~__FILE__ - ~title:"RPC process kill" - ~tags:["rpc"; "process"; "kill"] - @@ fun protocol -> - let node = Node.create [] in - let wait_RPC_process_pid = wait_for_RPC_process_pid node in - let* () = Node.run node [] in - let* () = Node.wait_for_ready node in - let* client = Client.init ~endpoint:(Node node) () in - let* rpc_process_pid = wait_RPC_process_pid in - Log.info "RPC process is now runnig on pid %d" rpc_process_pid ; - let* () = Client.activate_protocol_and_wait ~protocol client in - Log.info "Wait for level 1" ; - let* (_ : int) = Node.wait_for_level node 1 in - Log.info "Head can be requested" ; - let* (_ : bool) = head_can_be_requested ~expected_level:1 client in - let wait_new_rpc_process_pid = wait_for_RPC_process_pid node in - let () = kill_process ~pid:rpc_process_pid ~signal:SIGKILL in - let* new_rpc_process_pid = wait_new_rpc_process_pid in - Log.info "The new RPC process is now runnig on pid %d" new_rpc_process_pid ; - Log.info "Head can still be requested" ; - let* (_ : bool) = head_can_be_requested ~expected_level:1 client in - unit - -type expected_behavior = Forward | Handle - -let test_forward = - Protocol.register_test - ~__FILE__ - ~title:"RPC process forward" - ~tags:["rpc"; "process"; "forward"] - @@ fun protocol -> - Log.info - "Test whether some specific RPCs are handled directly by the RPC process \ - or forwarded to the node." ; - let* node, client = - Client.init_with_protocol - ~event_sections_levels:[("rpc-process", `Debug)] - ~protocol - `Client - () - in - let wait_for expected_behavior ~rpc_prefix = - let filter json = - if String.starts_with ~prefix:rpc_prefix (JSON.as_string json) then - Some () - else None - in - let where = sf "rpc_prefix = %s" rpc_prefix in - let event_name = - match expected_behavior with - | Forward -> "forwarding_rpc.v0" - | Handle -> "locally_handled_rpc.v0" - in - Node.wait_for ~where node event_name filter - in - let test_rpc expected_behavior ?error ~rpc_prefix rpc = - Log.info "Test %s" rpc_prefix ; - let waiter = wait_for expected_behavior ~rpc_prefix in - let* () = - match error with - | None -> - let* _ = Node.RPC.call node rpc in - unit - | Some msg -> - let*? process = Client.RPC.spawn client rpc in - Process.check_error ~msg:(rex msg) process - in - waiter - in - let* () = test_rpc Handle RPC.get_version ~rpc_prefix:"/version" in - let* () = test_rpc Handle RPC.get_config ~rpc_prefix:"/config" in - let* () = - test_rpc - Forward - (RPC.get_chain_chain_id ()) - ~rpc_prefix:"/chains/main/chain_id" - in - let* () = - test_rpc - Forward - (RPC.get_chain_chain_id ~chain:"test" ()) - ~rpc_prefix:"/chains/test/chain_id" - ~error:"No service found at this URL" - in - let* () = - test_rpc - Forward - (RPC.get_chain_chain_id ~chain:"nonexistent" ()) - ~rpc_prefix:"/chains/nonexistent/chain_id" - ~error:"Cannot parse chain identifier" - in - let* () = - test_rpc - Forward - (RPC.post_chain_mempool_filter ~data:(Data (Ezjsonm.from_string "{}")) ()) - ~rpc_prefix:"/chains/main/mempool/filter" - in - let* () = - test_rpc - Forward - RPC.nonexistent_path - ~rpc_prefix:"/nonexistent/path" - ~error:"No service found at this URL" - in - let test_streaming_rpc ~rpc_prefix rpc = - Log.info "Test streaming RPC: %s" rpc_prefix ; - let waiter = wait_for Forward ~rpc_prefix in - let url = - RPC_core.make_uri (Node.as_rpc_endpoint node) rpc |> Uri.to_string - in - let*? _process = Curl.get url in - waiter - in - let* () = - test_streaming_rpc - (RPC.get_chain_mempool_monitor_operations ()) - ~rpc_prefix:"/chains/main/mempool/monitor_operations" - in - let* () = - test_streaming_rpc - (RPC.get_monitor_heads_chain ()) - ~rpc_prefix:"/monitor/heads/main" - in - let* () = - test_streaming_rpc - (RPC.get_monitor_heads_chain ~chain:"test" ()) - ~rpc_prefix:"/monitor/heads/test" - in - let* () = - test_streaming_rpc - RPC.get_monitor_validated_blocks - ~rpc_prefix:"/monitor/validated_blocks" - in - test_streaming_rpc - RPC.get_monitor_applied_blocks - ~rpc_prefix:"/monitor/applied_blocks" - -let point_of_port port = "127.0.0.1:" ^ Int.to_string port - -let wait_for_starting_rpc_server_event ~local ?fail node port = - let filter = - match fail with - | None -> - fun json -> - let event_port = JSON.(json |-> "port" |> as_int) in - if port = event_port then Some () else None - | Some fail_msg -> fun _ -> Test.fail fail_msg - in - Node.wait_for - node - (if local then "starting_local_rpc_server.v0" else "starting_rpc_server.v0") - filter - -let make_endpoint port = - Client.Foreign_endpoint Endpoint.{host = "127.0.0.1"; scheme = "http"; port} - -let test_local_rpc_server = - Test.register - ~__FILE__ - ~title:"RPC local server" - ~tags:["rpc"; "process"; "local_server"] - @@ fun () -> - let node = Node.create ~rpc_local:true [] in - (* Register event watchers for local RPC server before the node is running to - ensure they will not be missed. *) - let local_event_promise = - wait_for_starting_rpc_server_event ~local:true node (Node.rpc_port node) - in - (* Register event watchers for process RPC server that will make the test - fails if detected. *) - let _ = - wait_for_starting_rpc_server_event - ~local:false - ~fail:"Process RPC server detected" - node - (Node.rpc_port node) - in - (* Run the node *) - let* () = Node.run node [] in - let* () = Node.wait_for_ready node in - Log.info "Node ready." ; - let* client = Client.init () in - Log.info "Checking if host is available." ; - let* _ = - Client.RPC.call ~endpoint:(make_endpoint (Node.rpc_port node)) client - @@ RPC.get_version - in - Log.info "Checking if local RPC server has been well started" ; - local_event_promise - -let test_process_rpc_server = - Test.register - ~__FILE__ - ~title:"RPC process server" - ~tags:["rpc"; "process"; "local_server"] - @@ fun () -> - (* By default Node module start a process RPC server. *) - let node = Node.create [] in - (* Register event watchers for process RPC server before the node is running - to ensure they will not be missed. *) - let process_event_promise = - wait_for_starting_rpc_server_event ~local:false node (Node.rpc_port node) - in - (* Register event watchers for local RPC server that will make the test fails - if detected. *) - let _ = - wait_for_starting_rpc_server_event - ~local:true - ~fail:"Local RPC server detected" - node - (Node.rpc_port node) - in - (* Run the node *) - let* () = Node.run node [] in - let* () = Node.wait_for_ready node in - Log.info "Node ready." ; - let* client = Client.init () in - Log.info "Checking if host is available." ; - let* _ = - Client.RPC.call ~endpoint:(make_endpoint (Node.rpc_port node)) client - @@ RPC.get_version - in - Log.info "Checking if process RPC server has been well started" ; - process_event_promise - -let test_local_and_process_rpc_servers = - Test.register - ~__FILE__ - ~title:"RPC local servers and process servers" - ~tags:["rpc"; "process"; "local_server"] - @@ fun () -> - (* Generate some ports for additional process RPC servers *) - let process_rpc_ports = List.init 2 (fun _ -> Port.fresh ()) in - (* Generate some ports for additional local RPC servers *) - let local_rpc_ports = List.init 2 (fun _ -> Port.fresh ()) in - let node = - Node.create - (List.map - (fun port -> Node.RPC_additional_addr (point_of_port port)) - process_rpc_ports - @ List.map - (fun port -> Node.RPC_additional_addr_local (point_of_port port)) - local_rpc_ports) - in - (* Add the RPC server created by default in Node module. *) - let process_rpc_ports = Node.rpc_port node :: process_rpc_ports in - (* Register event watchers for both process and local RPC servers before the - node is running to ensure they will not be missed. *) - let process_event_promises = - List.map - (wait_for_starting_rpc_server_event ~local:false node) - process_rpc_ports - in - let local_event_promises = - List.map - (wait_for_starting_rpc_server_event ~local:true node) - local_rpc_ports - in - (* Run the node *) - let* () = Node.run node [] in - let* () = Node.wait_for_ready node in - Log.info "Node ready." ; - let* client = Client.init () in - Log.info "Checking if process hosts are available." ; - let* _ = - Lwt_list.map_p - (fun port -> - Client.RPC.call ~endpoint:(make_endpoint port) client @@ RPC.get_version) - process_rpc_ports - in - Log.info "Checking if local hosts are available." ; - let* _ = - Lwt_list.map_p - (fun port -> - Client.RPC.call ~endpoint:(make_endpoint port) client @@ RPC.get_version) - local_rpc_ports - in - Log.info "Checking if process RPC servers have been well started" ; - let* () = Lwt_list.iter_p (fun p -> p) process_event_promises in - Log.info "Checking if local RPC servers have been well started" ; - Lwt_list.iter_p (fun p -> p) local_event_promises - -let register ~protocols = - test_kill protocols ; - test_forward protocols diff --git a/tezt/tests/sc_rollup.ml b/tezt/tests/sc_rollup.ml index 2b1d22836410077853c5e1639a5063c197e76101..a354cf5084284ea9ab677266117d33fefad29661 100644 --- a/tezt/tests/sc_rollup.ml +++ b/tezt/tests/sc_rollup.ml @@ -5199,15 +5199,7 @@ let custom_mode_empty_operation_kinds ~kind = block. *) let test_multiple_batcher_key ~kind = test_l1_scenario - (* TODO: https://gitlab.com/tezos/tezos/-/issues/6650 - - also might be related to https://gitlab.com/tezos/tezos/-/issues/3014 - - Test is flaky without rpc_local:true and it seems to be related to this issue. When - investigating it seems that the sink used by the octez node has a - race condition between process, it seems it due to the rpc server - being run in a separate process. *) - ~rpc_local:true + ~rpc_local:false ~kind { variant = None; @@ -5336,10 +5328,7 @@ let test_injector_uses_available_keys ~kind = let operators_pkh = List.map snd operators in let nb_operators = List.length operators in test_full_scenario - (* TODO: https://gitlab.com/tezos/tezos/-/issues/6650 - - cf multiple_batcher_test comment. *) - ~rpc_local:true + ~rpc_local:false ~kind ~operators ~mode:Batcher