From 9cbd4d97d9e2bf791608e32a33d6ab286948cf7a Mon Sep 17 00:00:00 2001 From: Victor Allombert Date: Wed, 22 Nov 2023 15:54:43 +0100 Subject: [PATCH 1/2] RPCs/Shell: remove deprecated valid_blocks streamed RPC This is a breaking change, however, the ``applied_blocks`` RPC has the exact same behavior. --- src/lib_shell/monitor_directory.ml | 54 --------------------- src/lib_shell_services/monitor_services.ml | 29 ----------- src/lib_shell_services/monitor_services.mli | 31 ------------ 3 files changed, 114 deletions(-) diff --git a/src/lib_shell/monitor_directory.ml b/src/lib_shell/monitor_directory.ml index 1a3d10f9723b..48410e57c255 100644 --- a/src/lib_shell/monitor_directory.ml +++ b/src/lib_shell/monitor_directory.ml @@ -63,60 +63,6 @@ let build_rpc_directory ~(commit_info : Node_version.commit_info) validator in let shutdown () = Lwt_watcher.shutdown stopper in Tezos_rpc.Answer.return_stream {next; shutdown}) ; - gen_register0 Monitor_services.S.legacy_valid_blocks (fun q () -> - let block_stream, stopper = Store.global_block_watcher store in - let shutdown () = Lwt_watcher.shutdown stopper in - let in_chains (chain_store, _block) = - match q#chains with - | [] -> Lwt.return_true - | chains -> - let that_chain_id = Store.Chain.chain_id chain_store in - List.exists_p - (fun chain -> - let+ o = Chain_directory.get_chain_id_opt store chain in - match o with - | None -> false - | Some this_chain_id -> - Chain_id.equal this_chain_id that_chain_id) - chains - in - let in_protocols (chain_store, block) = - match q#protocols with - | [] -> Lwt.return_true - | protocols -> ( - let* o = Store.Block.read_predecessor_opt chain_store block in - match o with - | None -> Lwt.return_false (* won't happen *) - | Some pred -> - let* context = Store.Block.context_exn chain_store pred in - let* protocol = Context_ops.get_protocol context in - Lwt.return - (List.exists (Protocol_hash.equal protocol) protocols)) - in - let in_next_protocols (chain_store, block) = - match q#next_protocols with - | [] -> Lwt.return_true - | protocols -> - let* context = Store.Block.context_exn chain_store block in - let* next_protocol = Context_ops.get_protocol context in - Lwt.return - (List.exists (Protocol_hash.equal next_protocol) protocols) - in - let stream = - Lwt_stream.filter_map_s - (fun ((chain_store, block) as elt) -> - let* in_chains = in_chains elt in - let* in_next_protocols = in_next_protocols elt in - let* in_protocols = in_protocols elt in - if in_chains && in_protocols && in_next_protocols then - let chain_id = Store.Chain.chain_id chain_store in - Lwt.return_some - ((chain_id, Store.Block.hash block), Store.Block.header block) - else Lwt.return_none) - block_stream - in - let next () = Lwt_stream.get stream in - Tezos_rpc.Answer.return_stream {next; shutdown}) ; gen_register0 Monitor_services.S.applied_blocks (fun q () -> let block_stream, stopper = Store.global_block_watcher store in let shutdown () = Lwt_watcher.shutdown stopper in diff --git a/src/lib_shell_services/monitor_services.ml b/src/lib_shell_services/monitor_services.ml index 691f2b82a468..6dc026ddc521 100644 --- a/src/lib_shell_services/monitor_services.ml +++ b/src/lib_shell_services/monitor_services.ml @@ -100,20 +100,6 @@ module S = struct |+ multi_field "chain" Chain_services.chain_arg (fun t -> t#chains) |> seal - let legacy_valid_blocks = - Tezos_rpc.Service.get_service - ~description: - "(Deprecated) Monitor all blocks that are successfully applied by the \ - node, disregarding whether they were selected as the new head or not." - ~query:validated_or_apply_blocks_query - ~output: - (merge_objs - (obj2 - (req "chain_id" Chain_id.encoding) - (req "hash" Block_hash.encoding)) - Block_header.encoding) - Tezos_rpc.Path.(path / "valid_blocks") - let validated_blocks = Tezos_rpc.Service.get_service ~description: @@ -199,21 +185,6 @@ open Tezos_rpc.Context let bootstrapped ctxt = make_streamed_call S.bootstrapped ctxt () () () -let legacy_valid_blocks ctxt ?(chains = [`Main]) ?(protocols = []) - ?(next_protocols = []) () = - make_streamed_call - S.legacy_valid_blocks - ctxt - () - (object - method chains = chains - - method protocols = protocols - - method next_protocols = next_protocols - end) - () - let validated_blocks ctxt ?(chains = [`Main]) ?(protocols = []) ?(next_protocols = []) () = make_streamed_call diff --git a/src/lib_shell_services/monitor_services.mli b/src/lib_shell_services/monitor_services.mli index cf3ce8178a74..cfd6b7fbdc36 100644 --- a/src/lib_shell_services/monitor_services.mli +++ b/src/lib_shell_services/monitor_services.mli @@ -38,21 +38,6 @@ val bootstrapped : #streamed -> ((Block_hash.t * Time.Protocol.t) Lwt_stream.t * stopper) tzresult Lwt.t -(** Call RPC GET /monitor/valid_blocks (Deprecated) - - - Default [chains] is [Main]. - - Default [protocols] is [[]]. - - Default [next_protocols] is [[]]. *) -val legacy_valid_blocks : - #streamed -> - ?chains:Chain_services.chain list -> - ?protocols:Protocol_hash.t list -> - ?next_protocols:Protocol_hash.t list -> - unit -> - (((Chain_id.t * Block_hash.t) * Block_header.t) Lwt_stream.t * stopper) - tzresult - Lwt.t - (** Call RPC GET /monitor/validated_blocks - Default [chains] is [Main]. @@ -112,22 +97,6 @@ module S : sig Block_hash.t * Time.Protocol.t ) Tezos_rpc.Service.t - (** Define RPC GET /monitor/valid_blocks (Deprecated) - - - Default [chains] is [Main]. - - Default [protocols] is [[]]. - - Default [next_protocols] is [[]]. *) - val legacy_valid_blocks : - ( [`GET], - unit, - unit, - < chains : Chain_services.chain list - ; next_protocols : Protocol_hash.t list - ; protocols : Protocol_hash.t list >, - unit, - (Chain_id.t * Block_hash.t) * Block_header.t ) - Tezos_rpc.Service.t - (** Define RPC GET /monitor/validated_blocks - Default [chains] is [Main]. -- GitLab From b0d7748593b10e8f4bef080fa9202c8b21fb2626 Mon Sep 17 00:00:00 2001 From: Victor Allombert Date: Wed, 22 Nov 2023 16:06:22 +0100 Subject: [PATCH 2/2] Changelog: remove deprecated valid_blocks streamed RPC --- CHANGES.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGES.rst b/CHANGES.rst index 2c34c9aa455c..c530ba7556cb 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -57,6 +57,10 @@ Node was emitted every time a block was applied using an old protocol where its plugin was removed. +- **Breaking change** Removed the deprecated ``/monitor/valid_blocks`` + RPC. Instead, use the ``/monitor/applied_blocks`` RPC that has the + same behaviour. + Client ------ -- GitLab