From 5300919cf39e27fd6ae8f626f6123d97ca31fa01 Mon Sep 17 00:00:00 2001 From: Albin Coquereau Date: Wed, 5 Jul 2023 10:21:59 +0200 Subject: [PATCH 01/19] lib_shell: remove support of version 0 for pending_operations --- src/lib_shell_services/block_services.ml | 110 ++-------------------- src/lib_shell_services/block_services.mli | 2 - 2 files changed, 8 insertions(+), 104 deletions(-) diff --git a/src/lib_shell_services/block_services.ml b/src/lib_shell_services/block_services.ml index dd591042fc34..98289580eb79 100644 --- a/src/lib_shell_services/block_services.ml +++ b/src/lib_shell_services/block_services.ml @@ -1212,87 +1212,7 @@ module Make (Proto : PROTO) (Next_proto : PROTO) = struct unprocessed : Next_proto.operation Operation_hash.Map.t; } - let version_0_encoding = - conv - (fun { - validated; - refused; - outdated; - branch_refused; - branch_delayed; - unprocessed; - } -> - ( validated, - refused, - outdated, - branch_refused, - branch_delayed, - unprocessed )) - (fun ( validated, - refused, - outdated, - branch_refused, - branch_delayed, - unprocessed ) -> - { - validated; - refused; - outdated; - branch_refused; - branch_delayed; - unprocessed; - }) - (obj6 - (req - "applied" - (list - (conv - (fun (hash, (op : Next_proto.operation)) -> - ((hash, op.shell), op.protocol_data)) - (fun ((hash, shell), protocol_data) -> - (hash, {shell; protocol_data})) - (merge_objs - (merge_objs - (obj1 (req "hash" Operation_hash.encoding)) - (dynamic_size Operation.shell_header_encoding)) - (dynamic_size - Next_proto - .operation_data_encoding_with_legacy_attestation_name))))) - (req - "refused" - (Operation_hash.Map.encoding - (merge_objs - (dynamic_size - next_operation_encoding_with_legacy_attestation_name) - (obj1 (req "error" Tezos_rpc.Error.encoding))))) - (req - "outdated" - (Operation_hash.Map.encoding - (merge_objs - (dynamic_size - next_operation_encoding_with_legacy_attestation_name) - (obj1 (req "error" Tezos_rpc.Error.encoding))))) - (req - "branch_refused" - (Operation_hash.Map.encoding - (merge_objs - (dynamic_size - next_operation_encoding_with_legacy_attestation_name) - (obj1 (req "error" Tezos_rpc.Error.encoding))))) - (req - "branch_delayed" - (Operation_hash.Map.encoding - (merge_objs - (dynamic_size - next_operation_encoding_with_legacy_attestation_name) - (obj1 (req "error" Tezos_rpc.Error.encoding))))) - (req - "unprocessed" - (Operation_hash.Map.encoding - (dynamic_size - next_operation_encoding_with_legacy_attestation_name)))) - - let version_1_encoding ~use_legacy_name ~use_validated = + let pending_operations_encoding ~use_legacy_name ~use_validated = let next_operation_encoding = if use_legacy_name then next_operation_encoding_with_legacy_attestation_name @@ -1373,19 +1293,9 @@ module Make (Proto : PROTO) (Next_proto : PROTO) = struct (obj1 (req "hash" Operation_hash.encoding)) next_operation_encoding))))) - let version_2_encoding = - version_1_encoding ~use_legacy_name:false ~use_validated:true - - let version_1_encoding = - version_1_encoding ~use_legacy_name:true ~use_validated:false - - (* This encoding should be always the one by default. *) - let encoding = version_1_encoding - let default_pending_operations_version = Version_1 - let pending_operations_supported_versions = - [Version_0; Version_1; Version_2] + let pending_operations_supported_versions = [Version_1; Version_2] let pending_query = let open Tezos_rpc.Query in @@ -1475,7 +1385,9 @@ module Make (Proto : PROTO) (Next_proto : PROTO) = struct case ~title:"pending_operations_encoding" (Tag 2) - version_2_encoding + (pending_operations_encoding + ~use_legacy_name:false + ~use_validated:true) (function | Version_2, pending_operations -> Some pending_operations | (Version_0 | Version_1), _ -> None) @@ -1483,19 +1395,13 @@ module Make (Proto : PROTO) (Next_proto : PROTO) = struct case ~title:"pending_operations_encoding_with_legacy_attestation_name" (Tag 1) - version_1_encoding + (pending_operations_encoding + ~use_legacy_name:true + ~use_validated:false) (function | Version_1, pending_operations -> Some pending_operations | (Version_0 | Version_2), _ -> None) (fun pending_operations -> (Version_1, pending_operations)); - case - ~title:"old_encoding_pending_operations" - Json_only - version_0_encoding - (function - | Version_0, pending_operations -> Some pending_operations - | (Version_1 | Version_2), _ -> None) - (fun pending_operations -> (Version_0, pending_operations)); ] let pending_operations path = diff --git a/src/lib_shell_services/block_services.mli b/src/lib_shell_services/block_services.mli index f79febd8139b..de27e51248fd 100644 --- a/src/lib_shell_services/block_services.mli +++ b/src/lib_shell_services/block_services.mli @@ -733,8 +733,6 @@ module Make (Proto : PROTO) (Next_proto : PROTO) : sig end module Mempool : sig - val encoding : Mempool.t Data_encoding.t - (** Define RPC GET /chains/[chain]/mempool/pending_operations *) val pending_operations : ('a, 'b) Tezos_rpc.Path.t -> -- GitLab From 58d97a01967e2c6198b8fe5071b3cf978936d3a2 Mon Sep 17 00:00:00 2001 From: Albin Coquereau Date: Wed, 5 Jul 2023 10:41:32 +0200 Subject: [PATCH 02/19] lib_shell: introduce `pending_operation/v1` --- src/lib_mockup/local_services.ml | 5 +- src/lib_shell/prevalidator.ml | 4 +- src/lib_shell/prevalidator_internal.ml | 153 +++++++++--------- src/lib_shell_services/block_services.ml | 98 +++++------ src/lib_shell_services/block_services.mli | 22 ++- .../test/mockup_simulator/faked_services.ml | 4 +- .../test/mockup_simulator/faked_services.ml | 4 +- .../test/mockup_simulator/faked_services.ml | 4 +- .../test/mockup_simulator/faked_services.ml | 4 +- 9 files changed, 153 insertions(+), 145 deletions(-) diff --git a/src/lib_mockup/local_services.ml b/src/lib_mockup/local_services.ml index 10cbfc2c0e26..3d38467ba1c9 100644 --- a/src/lib_mockup/local_services.ml +++ b/src/lib_mockup/local_services.ml @@ -363,7 +363,7 @@ module Make (E : MENV) = struct (* /chains//mempool/pending_operations *) (E.Block_services.S.Mempool.pending_operations @@ Block_services.mempool_path Block_services.chain_path) - (fun ((), chain) params () -> + (fun ((), chain) _params () -> let*! pending_operations = let* () = check_chain chain in let* pooled_operations = Mempool.read () in @@ -382,8 +382,7 @@ module Make (E : MENV) = struct in match pending_operations with | Error errs -> Tezos_rpc.Answer.fail errs - | Ok pending_operations -> - Tezos_rpc.Answer.return (params#version, pending_operations)) + | Ok pending_operations -> Tezos_rpc.Answer.return pending_operations) let shell_header () = Directory.prefix diff --git a/src/lib_shell/prevalidator.ml b/src/lib_shell/prevalidator.ml index ca61b87c9b8a..88be1bbadeca 100644 --- a/src/lib_shell/prevalidator.ml +++ b/src/lib_shell/prevalidator.ml @@ -139,7 +139,7 @@ let empty_rpc_directory : unit Tezos_rpc.Directory.t = Tezos_rpc.Directory.gen_register Tezos_rpc.Directory.empty (Block_services.Empty.S.Mempool.pending_operations Tezos_rpc.Path.open_root) - (fun _pv params () -> + (fun _pv _params () -> let pending_operations = { Block_services.Empty.Mempool.validated = []; @@ -150,7 +150,7 @@ let empty_rpc_directory : unit Tezos_rpc.Directory.t = unprocessed = Operation_hash.Map.empty; } in - Tezos_rpc.Answer.return (params#version, pending_operations)) + Tezos_rpc.Answer.return pending_operations) let rpc_directory : t option Tezos_rpc.Directory.t = Tezos_rpc.Directory.register_dynamic_directory diff --git a/src/lib_shell/prevalidator_internal.ml b/src/lib_shell/prevalidator_internal.ml index 086084812042..69fe33334fe6 100644 --- a/src/lib_shell/prevalidator_internal.ml +++ b/src/lib_shell/prevalidator_internal.ml @@ -970,85 +970,88 @@ module Make (fun pv () () -> pv.shell.banned_operations <- Operation_hash.Set.empty ; return_unit) ; + let pending_operations pv params () = + let validated = + if + params#validated && Option.value ~default:true params#applied + (* https://gitlab.com/tezos/tezos/-/issues/5891 + applied is deprecated and should be removed in a future + version of Octez *) + then + Classification.Sized_map.to_map pv.shell.classification.validated + |> Operation_hash.Map.to_seq + |> Seq.filter_map (fun (oph, op) -> + if + filter_validation_passes + params#validation_passes + op.protocol + then Some (oph, op.protocol) + else None) + |> List.of_seq + else [] + in + let process_map map = + let open Operation_hash in + Map.filter_map + (fun _oph (op, error) -> + if filter_validation_passes params#validation_passes op.protocol + then Some (op.protocol, error) + else None) + map + in + let refused = + if params#refused then + process_map (Classification.map pv.shell.classification.refused) + else Operation_hash.Map.empty + in + let outdated = + if params#outdated then + process_map (Classification.map pv.shell.classification.outdated) + else Operation_hash.Map.empty + in + let branch_refused = + if params#branch_refused then + process_map + (Classification.map pv.shell.classification.branch_refused) + else Operation_hash.Map.empty + in + let branch_delayed = + if params#branch_delayed then + process_map + (Classification.map pv.shell.classification.branch_delayed) + else Operation_hash.Map.empty + in + let unprocessed = + Operation_hash.Map.filter_map + (fun _ {protocol; _} -> + if filter_validation_passes params#validation_passes protocol then + Some protocol + else None) + (Pending_ops.operations pv.shell.pending) + in + let pending_operations = + { + Proto_services.Mempool.validated; + refused; + outdated; + branch_refused; + branch_delayed; + unprocessed; + } + in + Tezos_rpc.Answer.return pending_operations + in dir := Tezos_rpc.Directory.gen_register !dir (Proto_services.S.Mempool.pending_operations Tezos_rpc.Path.open_root) - (fun pv params () -> - let validated = - if - params#validated && Option.value ~default:true params#applied - (* https://gitlab.com/tezos/tezos/-/issues/5891 - applied is deprecated and should be removed in a future - version of Octez *) - then - Classification.Sized_map.to_map - pv.shell.classification.validated - |> Operation_hash.Map.to_seq - |> Seq.filter_map (fun (oph, op) -> - if - filter_validation_passes - params#validation_passes - op.protocol - then Some (oph, op.protocol) - else None) - |> List.of_seq - else [] - in - let process_map map = - let open Operation_hash in - Map.filter_map - (fun _oph (op, error) -> - if - filter_validation_passes - params#validation_passes - op.protocol - then Some (op.protocol, error) - else None) - map - in - let refused = - if params#refused then - process_map (Classification.map pv.shell.classification.refused) - else Operation_hash.Map.empty - in - let outdated = - if params#outdated then - process_map - (Classification.map pv.shell.classification.outdated) - else Operation_hash.Map.empty - in - let branch_refused = - if params#branch_refused then - process_map - (Classification.map pv.shell.classification.branch_refused) - else Operation_hash.Map.empty - in - let branch_delayed = - if params#branch_delayed then - process_map - (Classification.map pv.shell.classification.branch_delayed) - else Operation_hash.Map.empty - in - let unprocessed = - Operation_hash.Map.filter_map - (fun _ {protocol; _} -> - if filter_validation_passes params#validation_passes protocol - then Some protocol - else None) - (Pending_ops.operations pv.shell.pending) - in - let pending_operations = - { - Proto_services.Mempool.validated; - refused; - outdated; - branch_refused; - branch_delayed; - unprocessed; - } - in - Tezos_rpc.Answer.return (params#version, pending_operations)) ; + pending_operations ; + dir := + Tezos_rpc.Directory.gen_register + !dir + (Proto_services.S.Mempool.pending_operations_v1 + Tezos_rpc.Path.open_root) + pending_operations ; dir := Tezos_rpc.Directory.register !dir diff --git a/src/lib_shell_services/block_services.ml b/src/lib_shell_services/block_services.ml index 98289580eb79..d7635291b78e 100644 --- a/src/lib_shell_services/block_services.ml +++ b/src/lib_shell_services/block_services.ml @@ -1301,7 +1301,6 @@ module Make (Proto : PROTO) (Next_proto : PROTO) = struct let open Tezos_rpc.Query in query (fun - version applied validated refused @@ -1311,8 +1310,6 @@ module Make (Proto : PROTO) (Next_proto : PROTO) = struct validation_passes -> object - method version = version - method applied = applied method validated = validated @@ -1327,11 +1324,6 @@ module Make (Proto : PROTO) (Next_proto : PROTO) = struct method validation_passes = validation_passes end) - |+ field - "version" - (version_arg pending_operations_supported_versions) - default_pending_operations_version - (fun t -> t#version) |+ opt_field ~descr: "(DEPRECATED use validated instead) Include validated operations" @@ -1379,38 +1371,28 @@ module Make (Proto : PROTO) (Next_proto : PROTO) = struct (fun t -> t#validation_passes) |> seal - let pending_operations_encoding = - union - [ - case - ~title:"pending_operations_encoding" - (Tag 2) - (pending_operations_encoding - ~use_legacy_name:false - ~use_validated:true) - (function - | Version_2, pending_operations -> Some pending_operations - | (Version_0 | Version_1), _ -> None) - (fun pending_operations -> (Version_2, pending_operations)); - case - ~title:"pending_operations_encoding_with_legacy_attestation_name" - (Tag 1) - (pending_operations_encoding - ~use_legacy_name:true - ~use_validated:false) - (function - | Version_1, pending_operations -> Some pending_operations - | (Version_0 | Version_2), _ -> None) - (fun pending_operations -> (Version_1, pending_operations)); - ] - let pending_operations path = Tezos_rpc.Service.get_service - ~description:"List the prevalidated operations." + ~description: + "(Deprecated, used `/pending_operations/v1` instead) List the \ + prevalidated operations." ~query:pending_query - ~output:pending_operations_encoding + ~output: + (pending_operations_encoding + ~use_legacy_name:true + ~use_validated:false) Tezos_rpc.Path.(path / "pending_operations") + let pending_operations_v1 path = + Tezos_rpc.Service.get_service + ~description:"List the prevalidated operations." + ~query:pending_query + ~output: + (pending_operations_encoding + ~use_legacy_name:false + ~use_validated:true) + Tezos_rpc.Path.(path / "pending_operations" / "v1") + let ban_operation path = Tezos_rpc.Service.post_service ~description: @@ -1917,31 +1899,39 @@ module Make (Proto : PROTO) (Next_proto : PROTO) = struct ?(validated = true) ?(branch_delayed = true) ?(branch_refused = true) ?(refused = true) ?(outdated = true) ?(validation_passes = []) () = let open Lwt_result_syntax in - let* _version, pending_operations = - Tezos_rpc.Context.make_call1 - (S.Mempool.pending_operations (mempool_path chain_path)) - ctxt - chain - (object - method version = version + let* s = + match version with + | Version_0 -> + return (S.Mempool.pending_operations (mempool_path chain_path)) + | Version_1 -> + return (S.Mempool.pending_operations_v1 (mempool_path chain_path)) + | Version_2 -> + failwith + "%s" + (unsupported_version + version + S.Mempool.pending_operations_supported_versions) + in + Tezos_rpc.Context.make_call1 + s + ctxt + chain + (object + method applied = None - method applied = None + method validated = validated - method validated = validated + method refused = refused - method refused = refused - - method outdated = outdated + method outdated = outdated - method branch_refused = branch_refused + method branch_refused = branch_refused - method branch_delayed = branch_delayed + method branch_delayed = branch_delayed - method validation_passes = validation_passes - end) - () - in - return pending_operations + method validation_passes = validation_passes + end) + () let ban_operation ctxt ?(chain = `Main) op_hash = let s = S.Mempool.ban_operation (mempool_path chain_path) in diff --git a/src/lib_shell_services/block_services.mli b/src/lib_shell_services/block_services.mli index de27e51248fd..c5c13abf6ed7 100644 --- a/src/lib_shell_services/block_services.mli +++ b/src/lib_shell_services/block_services.mli @@ -739,8 +739,24 @@ module Make (Proto : PROTO) (Next_proto : PROTO) : sig ( [`GET], 'a, 'b, - < version : version - ; applied : bool option + < applied : bool option + ; validated : bool + ; branch_delayed : bool + ; branch_refused : bool + ; refused : bool + ; outdated : bool + ; validation_passes : int list >, + unit, + Mempool.t ) + Tezos_rpc.Service.t + + (** Define RPC GET /chains/[chain]/mempool/pending_operations/v1 *) + val pending_operations_v1 : + ('a, 'b) Tezos_rpc.Path.t -> + ( [`GET], + 'a, + 'b, + < applied : bool option ; validated : bool ; branch_delayed : bool ; branch_refused : bool @@ -748,7 +764,7 @@ module Make (Proto : PROTO) (Next_proto : PROTO) : sig ; outdated : bool ; validation_passes : int list >, unit, - version * Mempool.t ) + Mempool.t ) Tezos_rpc.Service.t (** Define RPC POST /chains/[chain]/mempool/ban_operation *) diff --git a/src/proto_016_PtMumbai/lib_delegate/test/mockup_simulator/faked_services.ml b/src/proto_016_PtMumbai/lib_delegate/test/mockup_simulator/faked_services.ml index cab89d4c8c06..5ec773845f1b 100644 --- a/src/proto_016_PtMumbai/lib_delegate/test/mockup_simulator/faked_services.ml +++ b/src/proto_016_PtMumbai/lib_delegate/test/mockup_simulator/faked_services.ml @@ -274,9 +274,9 @@ module Make (Hooks : Mocked_services_hooks) = struct Directory.empty (Mockup.M.Block_services.S.Mempool.pending_operations @@ Block_services.mempool_path Block_services.chain_path) - (fun ((), _chain) params () -> + (fun ((), _chain) _params () -> Hooks.pending_operations () >>= fun mempool -> - Tezos_rpc.Answer.return (params#version, mempool)) + Tezos_rpc.Answer.return mempool) let monitor_operations = Directory.gen_register diff --git a/src/proto_017_PtNairob/lib_delegate/test/mockup_simulator/faked_services.ml b/src/proto_017_PtNairob/lib_delegate/test/mockup_simulator/faked_services.ml index 533c0d99036e..95ccc458f26f 100644 --- a/src/proto_017_PtNairob/lib_delegate/test/mockup_simulator/faked_services.ml +++ b/src/proto_017_PtNairob/lib_delegate/test/mockup_simulator/faked_services.ml @@ -263,9 +263,9 @@ module Make (Hooks : Mocked_services_hooks) = struct Directory.empty (Mockup.M.Block_services.S.Mempool.pending_operations @@ Block_services.mempool_path Block_services.chain_path) - (fun ((), _chain) params () -> + (fun ((), _chain) _params () -> Hooks.pending_operations () >>= fun mempool -> - Tezos_rpc.Answer.return (params#version, mempool)) + Tezos_rpc.Answer.return mempool) let monitor_operations = Directory.gen_register diff --git a/src/proto_018_Proxford/lib_delegate/test/mockup_simulator/faked_services.ml b/src/proto_018_Proxford/lib_delegate/test/mockup_simulator/faked_services.ml index 533c0d99036e..95ccc458f26f 100644 --- a/src/proto_018_Proxford/lib_delegate/test/mockup_simulator/faked_services.ml +++ b/src/proto_018_Proxford/lib_delegate/test/mockup_simulator/faked_services.ml @@ -263,9 +263,9 @@ module Make (Hooks : Mocked_services_hooks) = struct Directory.empty (Mockup.M.Block_services.S.Mempool.pending_operations @@ Block_services.mempool_path Block_services.chain_path) - (fun ((), _chain) params () -> + (fun ((), _chain) _params () -> Hooks.pending_operations () >>= fun mempool -> - Tezos_rpc.Answer.return (params#version, mempool)) + Tezos_rpc.Answer.return mempool) let monitor_operations = Directory.gen_register diff --git a/src/proto_alpha/lib_delegate/test/mockup_simulator/faked_services.ml b/src/proto_alpha/lib_delegate/test/mockup_simulator/faked_services.ml index 533c0d99036e..95ccc458f26f 100644 --- a/src/proto_alpha/lib_delegate/test/mockup_simulator/faked_services.ml +++ b/src/proto_alpha/lib_delegate/test/mockup_simulator/faked_services.ml @@ -263,9 +263,9 @@ module Make (Hooks : Mocked_services_hooks) = struct Directory.empty (Mockup.M.Block_services.S.Mempool.pending_operations @@ Block_services.mempool_path Block_services.chain_path) - (fun ((), _chain) params () -> + (fun ((), _chain) _params () -> Hooks.pending_operations () >>= fun mempool -> - Tezos_rpc.Answer.return (params#version, mempool)) + Tezos_rpc.Answer.return mempool) let monitor_operations = Directory.gen_register -- GitLab From e3bcda369f5c343e389ce4c06b9e9b77989aba19 Mon Sep 17 00:00:00 2001 From: Albin Coquereau Date: Wed, 5 Jul 2023 11:10:24 +0200 Subject: [PATCH 03/19] lib_shell: remove version_2 in block services --- src/lib_shell_services/block_services.ml | 71 +++++------------------ src/lib_shell_services/block_services.mli | 2 +- 2 files changed, 16 insertions(+), 57 deletions(-) diff --git a/src/lib_shell_services/block_services.ml b/src/lib_shell_services/block_services.ml index d7635291b78e..0b347f311232 100644 --- a/src/lib_shell_services/block_services.ml +++ b/src/lib_shell_services/block_services.ml @@ -27,12 +27,9 @@ open Data_encoding module Proof = Tezos_context_sigs.Context.Proof_types -type version = Version_0 | Version_1 | Version_2 +type version = Version_0 | Version_1 -let string_of_version = function - | Version_0 -> "0" - | Version_1 -> "1" - | Version_2 -> "2" +let string_of_version = function Version_0 -> "0" | Version_1 -> "1" let unsupported_version_msg version supported = Format.asprintf @@ -53,7 +50,6 @@ let version_of_string supported version = match version with | "0" -> Ok Version_0 | "1" -> Ok Version_1 - | "2" -> Ok Version_2 | _ -> Error (unsupported_version_msg version supported) in if is_supported_version version_t supported then Ok version_t @@ -645,15 +641,7 @@ module Make (Proto : PROTO) (Next_proto : PROTO) = struct (Tag 1) new_encoding (function - | Version_1, operations -> Some operations - | ( ( Version_0 - | Version_2 - (* The same [version] type is used for versioning all the - RPC. Even though this version is not supported for this - RPC we need to handle it. We rely on the supported - version list to fail at parsing for this version *) ), - _ ) -> - None) + | Version_1, operations -> Some operations | Version_0, _ -> None) (fun operations -> (Version_1, operations)); case ~title: @@ -663,15 +651,7 @@ module Make (Proto : PROTO) (Next_proto : PROTO) = struct (Tag 0) old_encoding (function - | Version_0, operations -> Some operations - | ( ( Version_1 - | Version_2 - (* The same [version] type is used for versioning all the - RPC. Even though this version is not supported for this - RPC we need to handle it. We rely on the supported - version list to fail at parsing for this version *) ), - _ ) -> - None) + | Version_0, operations -> Some operations | Version_1, _ -> None) (fun operations -> (Version_0, operations)); ] @@ -1076,7 +1056,7 @@ module Make (Proto : PROTO) (Next_proto : PROTO) = struct (dynamic_size Next_proto.operation_data_and_receipt_encoding)) (function | Version_1, preapply_operations -> Some preapply_operations - | (Version_0 | Version_2), _ -> None) + | Version_0, _ -> None) (fun preapply_operations -> (Version_1, preapply_operations)); case ~title: @@ -1088,7 +1068,7 @@ module Make (Proto : PROTO) (Next_proto : PROTO) = struct .operation_data_and_receipt_encoding_with_legacy_attestation_name)) (function | Version_0, preapply_operations -> Some preapply_operations - | (Version_1 | Version_2), _ -> None) + | Version_1, _ -> None) (fun preapply_operations -> (Version_0, preapply_operations)); ] @@ -1293,9 +1273,7 @@ module Make (Proto : PROTO) (Next_proto : PROTO) = struct (obj1 (req "hash" Operation_hash.encoding)) next_operation_encoding))))) - let default_pending_operations_version = Version_1 - - let pending_operations_supported_versions = [Version_1; Version_2] + let default_pending_operations_version = Version_0 let pending_query = let open Tezos_rpc.Query in @@ -1531,14 +1509,7 @@ module Make (Proto : PROTO) (Next_proto : PROTO) = struct (list (monitor_operations_encoding ~use_legacy_name:false)) (function | Version_1, monitor_operations -> Some monitor_operations - | ( ( Version_0 - | Version_2 - (* The same [version] type is used for versioning all the - RPC. Even though this version is not supported for this - RPC we need to handle it. We rely on the supported - version list to fail at parsing for this version *) ), - _ ) -> - None) + | Version_0, _ -> None) (fun monitor_operations -> (Version_1, monitor_operations)); case ~title:"monitor_operations_encoding_with_legacy_attestation_name" @@ -1546,7 +1517,7 @@ module Make (Proto : PROTO) (Next_proto : PROTO) = struct (list (monitor_operations_encoding ~use_legacy_name:true)) (function | Version_0, monitor_operations -> Some monitor_operations - | (Version_1 | Version_2), _ -> None) + | Version_1, _ -> None) (fun monitor_operations -> (Version_0, monitor_operations)); ] @@ -1686,7 +1657,7 @@ module Make (Proto : PROTO) (Next_proto : PROTO) = struct let open Lwt_result_syntax in let f = make_call0 S.Operations.operations ctxt in fun ?(chain = `Main) ?(block = `Head 0) () -> - let* (Version_0 | Version_1 | Version_2), operations = + let* (Version_0 | Version_1), operations = f chain block @@ -1706,7 +1677,7 @@ module Make (Proto : PROTO) (Next_proto : PROTO) = struct let open Lwt_result_syntax in let f = make_call1 S.Operations.operations_in_pass ctxt in fun ?(chain = `Main) ?(block = `Head 0) n -> - let* (Version_0 | Version_1 | Version_2), operations = + let* (Version_0 | Version_1), operations = f chain block @@ -1727,7 +1698,7 @@ module Make (Proto : PROTO) (Next_proto : PROTO) = struct let open Lwt_result_syntax in let f = make_call2 S.Operations.operation ctxt in fun ?(chain = `Main) ?(block = `Head 0) n m -> - let* (Version_0 | Version_1 | Version_2), operation = + let* (Version_0 | Version_1), operation = f chain block @@ -1845,7 +1816,7 @@ module Make (Proto : PROTO) (Next_proto : PROTO) = struct let operations ctxt ?(chain = `Main) ?(block = `Head 0) ?(version = S.default_preapply_operations_version) operations = let open Lwt_result_syntax in - let* (Version_0 | Version_1 | Version_2), preapply_operations = + let* (Version_0 | Version_1), preapply_operations = make_call0 S.operations ctxt @@ -1869,7 +1840,7 @@ module Make (Proto : PROTO) (Next_proto : PROTO) = struct let open Lwt_result_syntax in let f = make_call0 S.info ctxt in fun ?(chain = `Main) ?(block = `Head 0) () -> - let* (Version_0 | Version_1 | Version_2), infos = + let* (Version_0 | Version_1), infos = f chain block @@ -1905,12 +1876,6 @@ module Make (Proto : PROTO) (Next_proto : PROTO) = struct return (S.Mempool.pending_operations (mempool_path chain_path)) | Version_1 -> return (S.Mempool.pending_operations_v1 (mempool_path chain_path)) - | Version_2 -> - failwith - "%s" - (unsupported_version - version - S.Mempool.pending_operations_supported_versions) in Tezos_rpc.Context.make_call1 s @@ -1977,13 +1942,7 @@ module Make (Proto : PROTO) (Next_proto : PROTO) = struct in return ( Lwt_stream.map - (fun ( ( Version_0 | Version_1 - | Version_2 - (* The same [version] type is used for versioning all the - RPC. Even though this version is not supported for this - RPC we need to handle it. We rely on the supported - version list to fail at parsing for this version *) ), - operations ) -> operations) + (fun ((Version_0 | Version_1), operations) -> operations) stream, stopper ) diff --git a/src/lib_shell_services/block_services.mli b/src/lib_shell_services/block_services.mli index c5c13abf6ed7..027067931384 100644 --- a/src/lib_shell_services/block_services.mli +++ b/src/lib_shell_services/block_services.mli @@ -26,7 +26,7 @@ module Proof = Tezos_context_sigs.Context.Proof_types -type version = Version_0 | Version_1 | Version_2 +type version = Version_0 | Version_1 type chain = [`Main | `Test | `Hash of Chain_id.t] -- GitLab From ee6b4e70c9735aea4fd48ca3125952644ec7d74c Mon Sep 17 00:00:00 2001 From: Albin Coquereau Date: Wed, 5 Jul 2023 11:21:18 +0200 Subject: [PATCH 04/19] tezt/lib_tezos: adapt pending_operations path according to version --- tezt/lib_tezos/RPC.ml | 17 ++++++++++------- tezt/lib_tezos/mempool.ml | 2 +- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/tezt/lib_tezos/RPC.ml b/tezt/lib_tezos/RPC.ml index d1594a3b5147..639565b1cc95 100644 --- a/tezt/lib_tezos/RPC.ml +++ b/tezt/lib_tezos/RPC.ml @@ -46,6 +46,13 @@ let make ?data ?query_string = ~get_port:Node.rpc_port ~get_scheme:Node.rpc_scheme +(* Add `/v` at the end of the rpc path if the given version is not the + default one *) +let rpc_version ~default ~path = function + | None -> path + | Some n when String.equal n default -> path + | Some n -> path @ [sf "v%s" n] + module Decode = struct let mutez json = json |> JSON.as_int |> Tez.of_mutez_int end @@ -450,8 +457,7 @@ let get_chain_block_operations_validation_pass ?(chain = "main") let get_chain_mempool_pending_operations ?(chain = "main") ?version ?validated ?branch_delayed ?branch_refused ?refused ?outdated ?validation_passes () = let query_string = - Query_arg.opt "version" Fun.id version - @ Query_arg.opt_bool "validated" validated + Query_arg.opt_bool "validated" validated @ Query_arg.opt_bool "refused" refused @ Query_arg.opt_bool "outdated" outdated @ Query_arg.opt_bool "branch_delayed" branch_delayed @@ -461,11 +467,8 @@ let get_chain_mempool_pending_operations ?(chain = "main") ?version ?validated (fun name vp -> (name, string_of_int vp)) validation_passes in - make - ~query_string - GET - ["chains"; chain; "mempool"; "pending_operations"] - Fun.id + let path = ["chains"; chain; "mempool"; "pending_operations"] in + make ~query_string GET (rpc_version ~default:"0" ~path version) Fun.id let get_chain_mempool_monitor_operations ?(chain = "main") ?version ?validated ?branch_delayed ?branch_refused ?refused ?outdated ?validation_passes () = diff --git a/tezt/lib_tezos/mempool.ml b/tezt/lib_tezos/mempool.ml index db1fa6bde2ff..6a07a9724c6f 100644 --- a/tezt/lib_tezos/mempool.ml +++ b/tezt/lib_tezos/mempool.ml @@ -108,7 +108,7 @@ let get_mempool ?endpoint ?hooks ?chain ?(validated = true) RPC.Client.call client ?hooks ?endpoint @@ RPC.get_chain_mempool_pending_operations ?chain - ~version:"2" + ~version:"1" ~validated ~branch_delayed ~branch_refused -- GitLab From 6bcd882e89da6ef15b4dd7f8b81c895ebc74e968 Mon Sep 17 00:00:00 2001 From: Albin Coquereau Date: Wed, 5 Jul 2023 12:28:30 +0200 Subject: [PATCH 05/19] tezt/tests: adapt pending_operations rpc tests --- tezt/tests/baker_operations_cli_options.ml | 2 +- tezt/tests/double_consensus.ml | 8 ++++---- ... client) RPC regression tests- mempool.out | 20 +++++++++---------- ...e proxy) RPC regression tests- mempool.out | 20 +++++++++---------- ... client) RPC regression tests- mempool.out | 20 +++++++++---------- ...e proxy) RPC regression tests- mempool.out | 20 +++++++++---------- ... client) RPC regression tests- mempool.out | 20 +++++++++---------- ...e proxy) RPC regression tests- mempool.out | 20 +++++++++---------- ... client) RPC regression tests- mempool.out | 20 +++++++++---------- ...e proxy) RPC regression tests- mempool.out | 20 +++++++++---------- tezt/tests/prevalidator.ml | 13 ++++++++---- tezt/tests/rpc_versioning_attestation.ml | 20 ++++++++++--------- 12 files changed, 105 insertions(+), 98 deletions(-) diff --git a/tezt/tests/baker_operations_cli_options.ml b/tezt/tests/baker_operations_cli_options.ml index 653e9347ec44..d74ba4e3efc2 100644 --- a/tezt/tests/baker_operations_cli_options.ml +++ b/tezt/tests/baker_operations_cli_options.ml @@ -262,7 +262,7 @@ let get_operations client = in let* mempool = RPC.Client.call client - @@ RPC.get_chain_mempool_pending_operations ~version:"2" () + @@ RPC.get_chain_mempool_pending_operations ~version:"1" () in return JSON.(mempool |-> "validated" |> as_list |> List.map to_op) diff --git a/tezt/tests/double_consensus.ml b/tezt/tests/double_consensus.ml index ac833ddf77cf..62e0db4638ec 100644 --- a/tezt/tests/double_consensus.ml +++ b/tezt/tests/double_consensus.ml @@ -54,7 +54,7 @@ let double_consensus_already_denounced_waiter accuser oph = let get_double_consensus_denounciation_hash consensus_name client = let* mempool = RPC.Client.call client - @@ RPC.get_chain_mempool_pending_operations ~version:"2" () + @@ RPC.get_chain_mempool_pending_operations ~version:"1" () in let ops = JSON.(mempool |-> "validated" |> as_list) in let op = @@ -104,7 +104,7 @@ let double_attestation_init Log.info "Get mempool and recover consensus information." ; let* mempool = RPC.Client.call client - @@ RPC.get_chain_mempool_pending_operations ~version:"2" () + @@ RPC.get_chain_mempool_pending_operations ~version:"1" () in let op = List.hd JSON.(mempool |-> "validated" |> as_list) in let branch = JSON.(op |-> "branch" |> as_string) in @@ -332,7 +332,7 @@ let operation_too_old = Log.info "Get mempool and recover consensus information." ; let* mempool = RPC.Client.call client - @@ RPC.get_chain_mempool_pending_operations ~version:"2" () + @@ RPC.get_chain_mempool_pending_operations ~version:"1" () in let op = List.hd JSON.(mempool |-> "validated" |> as_list) in let branch = JSON.(op |-> "branch" |> as_string) in @@ -396,7 +396,7 @@ let operation_too_far_in_future = Log.info "Get mempool and recover consensus information." ; let* mempool = RPC.Client.call client - @@ RPC.get_chain_mempool_pending_operations ~version:"2" () + @@ RPC.get_chain_mempool_pending_operations ~version:"1" () in let op = List.hd JSON.(mempool |-> "validated" |> as_list) in let branch = JSON.(op |-> "branch" |> as_string) in diff --git a/tezt/tests/expected/RPC_test.ml/Alpha- (mode client) RPC regression tests- mempool.out b/tezt/tests/expected/RPC_test.ml/Alpha- (mode client) RPC regression tests- mempool.out index f609eac4c969..4b56e81f2fb4 100644 --- a/tezt/tests/expected/RPC_test.ml/Alpha- (mode client) RPC regression tests- mempool.out +++ b/tezt/tests/expected/RPC_test.ml/Alpha- (mode client) RPC regression tests- mempool.out @@ -6,7 +6,7 @@ curl -s 'http://localhost:[PORT]/chains/main/mempool/monitor_operations?applied= [{"hash":"[OPERATION_HASH]","protocol":"ProtoALphaALphaALphaALphaALphaALphaALphaALphaDdp3zK","branch":"[BRANCH_HASH]","contents":[{"kind":"transaction","source":"[PUBLIC_KEY_HASH]","fee":"0","counter":"1","gas_limit":"1040","storage_limit":"257","amount":"1000000","destination":"[PUBLIC_KEY_HASH]"}],"signature":"[SIGNATURE]"}] [{"hash":"[OPERATION_HASH]","protocol":"ProtoALphaALphaALphaALphaALphaALphaALphaALphaDdp3zK","branch":"[BRANCH_HASH]","contents":[{"kind":"transaction","source":"[PUBLIC_KEY_HASH]","fee":"1000","counter":"1","gas_limit":"1040","storage_limit":"257","amount":"1000000","destination":"[PUBLIC_KEY_HASH]"}],"signature":"[SIGNATURE]"}] -./octez-client rpc get '/chains/main/mempool/pending_operations?version=2&validated=true&refused=true&outdated=true&branch_delayed=true&branch_refused=true' +./octez-client rpc get '/chains/main/mempool/pending_operations/v1?validated=true&refused=true&outdated=true&branch_delayed=true&branch_refused=true' { "validated": [ { "hash": "[OPERATION_HASH]", "branch": "[BRANCH_HASH]", @@ -69,11 +69,11 @@ curl -s 'http://localhost:[PORT]/chains/main/mempool/monitor_operations?applied= "contract": "[PUBLIC_KEY_HASH]", "expected": "1", "found": "5" } ] } ], "unprocessed": [] } -./octez-client rpc get '/chains/main/mempool/pending_operations?version=2&validated=true&refused=true&outdated=true&branch_delayed=true&branch_refused=true&validation_pass=0' +./octez-client rpc get '/chains/main/mempool/pending_operations/v1?validated=true&refused=true&outdated=true&branch_delayed=true&branch_refused=true&validation_pass=0' { "validated": [], "refused": [], "outdated": [], "branch_refused": [], "branch_delayed": [], "unprocessed": [] } -./octez-client rpc get '/chains/main/mempool/pending_operations?version=2&validated=true&refused=true&outdated=true&branch_delayed=true&branch_refused=true&validation_pass=3' +./octez-client rpc get '/chains/main/mempool/pending_operations/v1?validated=true&refused=true&outdated=true&branch_delayed=true&branch_refused=true&validation_pass=3' { "validated": [ { "hash": "[OPERATION_HASH]", "branch": "[BRANCH_HASH]", @@ -136,7 +136,7 @@ curl -s 'http://localhost:[PORT]/chains/main/mempool/monitor_operations?applied= "contract": "[PUBLIC_KEY_HASH]", "expected": "1", "found": "5" } ] } ], "unprocessed": [] } -./octez-client rpc get '/chains/main/mempool/pending_operations?version=2&validated=true&refused=true&outdated=true&branch_delayed=true&branch_refused=true&validation_pass=0&validation_pass=3' +./octez-client rpc get '/chains/main/mempool/pending_operations/v1?validated=true&refused=true&outdated=true&branch_delayed=true&branch_refused=true&validation_pass=0&validation_pass=3' { "validated": [ { "hash": "[OPERATION_HASH]", "branch": "[BRANCH_HASH]", @@ -199,11 +199,11 @@ curl -s 'http://localhost:[PORT]/chains/main/mempool/monitor_operations?applied= "contract": "[PUBLIC_KEY_HASH]", "expected": "1", "found": "5" } ] } ], "unprocessed": [] } -./octez-client rpc get '/chains/main/mempool/pending_operations?version=2&validated=true&refused=true&outdated=true&branch_delayed=true&branch_refused=true&validation_pass=1&validation_pass=2' +./octez-client rpc get '/chains/main/mempool/pending_operations/v1?validated=true&refused=true&outdated=true&branch_delayed=true&branch_refused=true&validation_pass=1&validation_pass=2' { "validated": [], "refused": [], "outdated": [], "branch_refused": [], "branch_delayed": [], "unprocessed": [] } -./octez-client rpc get '/chains/main/mempool/pending_operations?version=2&validated=true&refused=false&outdated=false&branch_delayed=false&branch_refused=false' +./octez-client rpc get '/chains/main/mempool/pending_operations/v1?validated=true&refused=false&outdated=false&branch_delayed=false&branch_refused=false' { "validated": [ { "hash": "[OPERATION_HASH]", "branch": "[BRANCH_HASH]", @@ -218,7 +218,7 @@ curl -s 'http://localhost:[PORT]/chains/main/mempool/monitor_operations?applied= "refused": [], "outdated": [], "branch_refused": [], "branch_delayed": [], "unprocessed": [] } -./octez-client rpc get '/chains/main/mempool/pending_operations?version=2&validated=false&refused=true&outdated=false&branch_delayed=false&branch_refused=false' +./octez-client rpc get '/chains/main/mempool/pending_operations/v1?validated=false&refused=true&outdated=false&branch_delayed=false&branch_refused=false' { "validated": [], "refused": [ { "hash": "[OPERATION_HASH]", @@ -238,7 +238,7 @@ curl -s 'http://localhost:[PORT]/chains/main/mempool/monitor_operations?applied= "outdated": [], "branch_refused": [], "branch_delayed": [], "unprocessed": [] } -./octez-client rpc get '/chains/main/mempool/pending_operations?version=2&validated=false&refused=false&outdated=false&branch_delayed=true&branch_refused=false' +./octez-client rpc get '/chains/main/mempool/pending_operations/v1?validated=false&refused=false&outdated=false&branch_delayed=true&branch_refused=false' { "validated": [], "refused": [], "outdated": [], "branch_refused": [], "branch_delayed": [ { "hash": "[OPERATION_HASH]", @@ -258,7 +258,7 @@ curl -s 'http://localhost:[PORT]/chains/main/mempool/monitor_operations?applied= "contract": "[PUBLIC_KEY_HASH]", "expected": "1", "found": "5" } ] } ], "unprocessed": [] } -./octez-client rpc get '/chains/main/mempool/pending_operations?version=2&validated=false&refused=false&outdated=false&branch_delayed=false&branch_refused=true' +./octez-client rpc get '/chains/main/mempool/pending_operations/v1?validated=false&refused=false&outdated=false&branch_delayed=false&branch_refused=true' { "validated": [], "refused": [], "outdated": [], "branch_refused": [ { "hash": "[OPERATION_HASH]", @@ -279,7 +279,7 @@ curl -s 'http://localhost:[PORT]/chains/main/mempool/monitor_operations?applied= "expected": "2", "found": "1" } ] } ], "branch_delayed": [], "unprocessed": [] } -./octez-client rpc get '/chains/main/mempool/pending_operations?version=2&validated=false&refused=false&outdated=true&branch_delayed=false&branch_refused=false' +./octez-client rpc get '/chains/main/mempool/pending_operations/v1?validated=false&refused=false&outdated=true&branch_delayed=false&branch_refused=false' { "validated": [], "refused": [], "outdated": [], "branch_refused": [], "branch_delayed": [], "unprocessed": [] } diff --git a/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy) RPC regression tests- mempool.out b/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy) RPC regression tests- mempool.out index 2bd48bda697d..5ac508248bdf 100644 --- a/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy) RPC regression tests- mempool.out +++ b/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy) RPC regression tests- mempool.out @@ -6,7 +6,7 @@ curl -s 'http://localhost:[PORT]/chains/main/mempool/monitor_operations?applied= [{"hash":"[OPERATION_HASH]","protocol":"ProtoALphaALphaALphaALphaALphaALphaALphaALphaDdp3zK","branch":"[BRANCH_HASH]","contents":[{"kind":"transaction","source":"[PUBLIC_KEY_HASH]","fee":"0","counter":"1","gas_limit":"1040","storage_limit":"257","amount":"1000000","destination":"[PUBLIC_KEY_HASH]"}],"signature":"[SIGNATURE]"}] [{"hash":"[OPERATION_HASH]","protocol":"ProtoALphaALphaALphaALphaALphaALphaALphaALphaDdp3zK","branch":"[BRANCH_HASH]","contents":[{"kind":"transaction","source":"[PUBLIC_KEY_HASH]","fee":"1000","counter":"1","gas_limit":"1040","storage_limit":"257","amount":"1000000","destination":"[PUBLIC_KEY_HASH]"}],"signature":"[SIGNATURE]"}] -./octez-client --mode proxy rpc get '/chains/main/mempool/pending_operations?version=2&validated=true&refused=true&outdated=true&branch_delayed=true&branch_refused=true' +./octez-client --mode proxy rpc get '/chains/main/mempool/pending_operations/v1?validated=true&refused=true&outdated=true&branch_delayed=true&branch_refused=true' { "validated": [ { "hash": "[OPERATION_HASH]", "branch": "[BRANCH_HASH]", @@ -69,11 +69,11 @@ curl -s 'http://localhost:[PORT]/chains/main/mempool/monitor_operations?applied= "contract": "[PUBLIC_KEY_HASH]", "expected": "1", "found": "5" } ] } ], "unprocessed": [] } -./octez-client --mode proxy rpc get '/chains/main/mempool/pending_operations?version=2&validated=true&refused=true&outdated=true&branch_delayed=true&branch_refused=true&validation_pass=0' +./octez-client --mode proxy rpc get '/chains/main/mempool/pending_operations/v1?validated=true&refused=true&outdated=true&branch_delayed=true&branch_refused=true&validation_pass=0' { "validated": [], "refused": [], "outdated": [], "branch_refused": [], "branch_delayed": [], "unprocessed": [] } -./octez-client --mode proxy rpc get '/chains/main/mempool/pending_operations?version=2&validated=true&refused=true&outdated=true&branch_delayed=true&branch_refused=true&validation_pass=3' +./octez-client --mode proxy rpc get '/chains/main/mempool/pending_operations/v1?validated=true&refused=true&outdated=true&branch_delayed=true&branch_refused=true&validation_pass=3' { "validated": [ { "hash": "[OPERATION_HASH]", "branch": "[BRANCH_HASH]", @@ -136,7 +136,7 @@ curl -s 'http://localhost:[PORT]/chains/main/mempool/monitor_operations?applied= "contract": "[PUBLIC_KEY_HASH]", "expected": "1", "found": "5" } ] } ], "unprocessed": [] } -./octez-client --mode proxy rpc get '/chains/main/mempool/pending_operations?version=2&validated=true&refused=true&outdated=true&branch_delayed=true&branch_refused=true&validation_pass=0&validation_pass=3' +./octez-client --mode proxy rpc get '/chains/main/mempool/pending_operations/v1?validated=true&refused=true&outdated=true&branch_delayed=true&branch_refused=true&validation_pass=0&validation_pass=3' { "validated": [ { "hash": "[OPERATION_HASH]", "branch": "[BRANCH_HASH]", @@ -199,11 +199,11 @@ curl -s 'http://localhost:[PORT]/chains/main/mempool/monitor_operations?applied= "contract": "[PUBLIC_KEY_HASH]", "expected": "1", "found": "5" } ] } ], "unprocessed": [] } -./octez-client --mode proxy rpc get '/chains/main/mempool/pending_operations?version=2&validated=true&refused=true&outdated=true&branch_delayed=true&branch_refused=true&validation_pass=1&validation_pass=2' +./octez-client --mode proxy rpc get '/chains/main/mempool/pending_operations/v1?validated=true&refused=true&outdated=true&branch_delayed=true&branch_refused=true&validation_pass=1&validation_pass=2' { "validated": [], "refused": [], "outdated": [], "branch_refused": [], "branch_delayed": [], "unprocessed": [] } -./octez-client --mode proxy rpc get '/chains/main/mempool/pending_operations?version=2&validated=true&refused=false&outdated=false&branch_delayed=false&branch_refused=false' +./octez-client --mode proxy rpc get '/chains/main/mempool/pending_operations/v1?validated=true&refused=false&outdated=false&branch_delayed=false&branch_refused=false' { "validated": [ { "hash": "[OPERATION_HASH]", "branch": "[BRANCH_HASH]", @@ -218,7 +218,7 @@ curl -s 'http://localhost:[PORT]/chains/main/mempool/monitor_operations?applied= "refused": [], "outdated": [], "branch_refused": [], "branch_delayed": [], "unprocessed": [] } -./octez-client --mode proxy rpc get '/chains/main/mempool/pending_operations?version=2&validated=false&refused=true&outdated=false&branch_delayed=false&branch_refused=false' +./octez-client --mode proxy rpc get '/chains/main/mempool/pending_operations/v1?validated=false&refused=true&outdated=false&branch_delayed=false&branch_refused=false' { "validated": [], "refused": [ { "hash": "[OPERATION_HASH]", @@ -238,7 +238,7 @@ curl -s 'http://localhost:[PORT]/chains/main/mempool/monitor_operations?applied= "outdated": [], "branch_refused": [], "branch_delayed": [], "unprocessed": [] } -./octez-client --mode proxy rpc get '/chains/main/mempool/pending_operations?version=2&validated=false&refused=false&outdated=false&branch_delayed=true&branch_refused=false' +./octez-client --mode proxy rpc get '/chains/main/mempool/pending_operations/v1?validated=false&refused=false&outdated=false&branch_delayed=true&branch_refused=false' { "validated": [], "refused": [], "outdated": [], "branch_refused": [], "branch_delayed": [ { "hash": "[OPERATION_HASH]", @@ -258,7 +258,7 @@ curl -s 'http://localhost:[PORT]/chains/main/mempool/monitor_operations?applied= "contract": "[PUBLIC_KEY_HASH]", "expected": "1", "found": "5" } ] } ], "unprocessed": [] } -./octez-client --mode proxy rpc get '/chains/main/mempool/pending_operations?version=2&validated=false&refused=false&outdated=false&branch_delayed=false&branch_refused=true' +./octez-client --mode proxy rpc get '/chains/main/mempool/pending_operations/v1?validated=false&refused=false&outdated=false&branch_delayed=false&branch_refused=true' { "validated": [], "refused": [], "outdated": [], "branch_refused": [ { "hash": "[OPERATION_HASH]", @@ -279,7 +279,7 @@ curl -s 'http://localhost:[PORT]/chains/main/mempool/monitor_operations?applied= "expected": "2", "found": "1" } ] } ], "branch_delayed": [], "unprocessed": [] } -./octez-client --mode proxy rpc get '/chains/main/mempool/pending_operations?version=2&validated=false&refused=false&outdated=true&branch_delayed=false&branch_refused=false' +./octez-client --mode proxy rpc get '/chains/main/mempool/pending_operations/v1?validated=false&refused=false&outdated=true&branch_delayed=false&branch_refused=false' { "validated": [], "refused": [], "outdated": [], "branch_refused": [], "branch_delayed": [], "unprocessed": [] } diff --git a/tezt/tests/expected/RPC_test.ml/Mumbai- (mode client) RPC regression tests- mempool.out b/tezt/tests/expected/RPC_test.ml/Mumbai- (mode client) RPC regression tests- mempool.out index abc42ee104f0..b1c1c8dbfd8b 100644 --- a/tezt/tests/expected/RPC_test.ml/Mumbai- (mode client) RPC regression tests- mempool.out +++ b/tezt/tests/expected/RPC_test.ml/Mumbai- (mode client) RPC regression tests- mempool.out @@ -6,7 +6,7 @@ curl -s 'http://localhost:[PORT]/chains/main/mempool/monitor_operations?applied= [{"hash":"[OPERATION_HASH]","protocol":"PtMumbai2TmsJHNGRkD8v8YDbtao7BLUC3wjASn1inAKLFCjaH1","branch":"[BRANCH_HASH]","contents":[{"kind":"transaction","source":"[PUBLIC_KEY_HASH]","fee":"0","counter":"1","gas_limit":"1040","storage_limit":"257","amount":"1000000","destination":"[PUBLIC_KEY_HASH]"}],"signature":"[SIGNATURE]"}] [{"hash":"[OPERATION_HASH]","protocol":"PtMumbai2TmsJHNGRkD8v8YDbtao7BLUC3wjASn1inAKLFCjaH1","branch":"[BRANCH_HASH]","contents":[{"kind":"transaction","source":"[PUBLIC_KEY_HASH]","fee":"1000","counter":"1","gas_limit":"1040","storage_limit":"257","amount":"1000000","destination":"[PUBLIC_KEY_HASH]"}],"signature":"[SIGNATURE]"}] -./octez-client rpc get '/chains/main/mempool/pending_operations?version=2&validated=true&refused=true&outdated=true&branch_delayed=true&branch_refused=true' +./octez-client rpc get '/chains/main/mempool/pending_operations/v1?validated=true&refused=true&outdated=true&branch_delayed=true&branch_refused=true' { "validated": [ { "hash": "[OPERATION_HASH]", "branch": "[BRANCH_HASH]", @@ -69,11 +69,11 @@ curl -s 'http://localhost:[PORT]/chains/main/mempool/monitor_operations?applied= "contract": "[PUBLIC_KEY_HASH]", "expected": "1", "found": "5" } ] } ], "unprocessed": [] } -./octez-client rpc get '/chains/main/mempool/pending_operations?version=2&validated=true&refused=true&outdated=true&branch_delayed=true&branch_refused=true&validation_pass=0' +./octez-client rpc get '/chains/main/mempool/pending_operations/v1?validated=true&refused=true&outdated=true&branch_delayed=true&branch_refused=true&validation_pass=0' { "validated": [], "refused": [], "outdated": [], "branch_refused": [], "branch_delayed": [], "unprocessed": [] } -./octez-client rpc get '/chains/main/mempool/pending_operations?version=2&validated=true&refused=true&outdated=true&branch_delayed=true&branch_refused=true&validation_pass=3' +./octez-client rpc get '/chains/main/mempool/pending_operations/v1?validated=true&refused=true&outdated=true&branch_delayed=true&branch_refused=true&validation_pass=3' { "validated": [ { "hash": "[OPERATION_HASH]", "branch": "[BRANCH_HASH]", @@ -136,7 +136,7 @@ curl -s 'http://localhost:[PORT]/chains/main/mempool/monitor_operations?applied= "contract": "[PUBLIC_KEY_HASH]", "expected": "1", "found": "5" } ] } ], "unprocessed": [] } -./octez-client rpc get '/chains/main/mempool/pending_operations?version=2&validated=true&refused=true&outdated=true&branch_delayed=true&branch_refused=true&validation_pass=0&validation_pass=3' +./octez-client rpc get '/chains/main/mempool/pending_operations/v1?validated=true&refused=true&outdated=true&branch_delayed=true&branch_refused=true&validation_pass=0&validation_pass=3' { "validated": [ { "hash": "[OPERATION_HASH]", "branch": "[BRANCH_HASH]", @@ -199,11 +199,11 @@ curl -s 'http://localhost:[PORT]/chains/main/mempool/monitor_operations?applied= "contract": "[PUBLIC_KEY_HASH]", "expected": "1", "found": "5" } ] } ], "unprocessed": [] } -./octez-client rpc get '/chains/main/mempool/pending_operations?version=2&validated=true&refused=true&outdated=true&branch_delayed=true&branch_refused=true&validation_pass=1&validation_pass=2' +./octez-client rpc get '/chains/main/mempool/pending_operations/v1?validated=true&refused=true&outdated=true&branch_delayed=true&branch_refused=true&validation_pass=1&validation_pass=2' { "validated": [], "refused": [], "outdated": [], "branch_refused": [], "branch_delayed": [], "unprocessed": [] } -./octez-client rpc get '/chains/main/mempool/pending_operations?version=2&validated=true&refused=false&outdated=false&branch_delayed=false&branch_refused=false' +./octez-client rpc get '/chains/main/mempool/pending_operations/v1?validated=true&refused=false&outdated=false&branch_delayed=false&branch_refused=false' { "validated": [ { "hash": "[OPERATION_HASH]", "branch": "[BRANCH_HASH]", @@ -218,7 +218,7 @@ curl -s 'http://localhost:[PORT]/chains/main/mempool/monitor_operations?applied= "refused": [], "outdated": [], "branch_refused": [], "branch_delayed": [], "unprocessed": [] } -./octez-client rpc get '/chains/main/mempool/pending_operations?version=2&validated=false&refused=true&outdated=false&branch_delayed=false&branch_refused=false' +./octez-client rpc get '/chains/main/mempool/pending_operations/v1?validated=false&refused=true&outdated=false&branch_delayed=false&branch_refused=false' { "validated": [], "refused": [ { "hash": "[OPERATION_HASH]", @@ -238,7 +238,7 @@ curl -s 'http://localhost:[PORT]/chains/main/mempool/monitor_operations?applied= "outdated": [], "branch_refused": [], "branch_delayed": [], "unprocessed": [] } -./octez-client rpc get '/chains/main/mempool/pending_operations?version=2&validated=false&refused=false&outdated=false&branch_delayed=true&branch_refused=false' +./octez-client rpc get '/chains/main/mempool/pending_operations/v1?validated=false&refused=false&outdated=false&branch_delayed=true&branch_refused=false' { "validated": [], "refused": [], "outdated": [], "branch_refused": [], "branch_delayed": [ { "hash": "[OPERATION_HASH]", @@ -258,7 +258,7 @@ curl -s 'http://localhost:[PORT]/chains/main/mempool/monitor_operations?applied= "contract": "[PUBLIC_KEY_HASH]", "expected": "1", "found": "5" } ] } ], "unprocessed": [] } -./octez-client rpc get '/chains/main/mempool/pending_operations?version=2&validated=false&refused=false&outdated=false&branch_delayed=false&branch_refused=true' +./octez-client rpc get '/chains/main/mempool/pending_operations/v1?validated=false&refused=false&outdated=false&branch_delayed=false&branch_refused=true' { "validated": [], "refused": [], "outdated": [], "branch_refused": [ { "hash": "[OPERATION_HASH]", @@ -279,7 +279,7 @@ curl -s 'http://localhost:[PORT]/chains/main/mempool/monitor_operations?applied= "expected": "2", "found": "1" } ] } ], "branch_delayed": [], "unprocessed": [] } -./octez-client rpc get '/chains/main/mempool/pending_operations?version=2&validated=false&refused=false&outdated=true&branch_delayed=false&branch_refused=false' +./octez-client rpc get '/chains/main/mempool/pending_operations/v1?validated=false&refused=false&outdated=true&branch_delayed=false&branch_refused=false' { "validated": [], "refused": [], "outdated": [], "branch_refused": [], "branch_delayed": [], "unprocessed": [] } diff --git a/tezt/tests/expected/RPC_test.ml/Mumbai- (mode proxy) RPC regression tests- mempool.out b/tezt/tests/expected/RPC_test.ml/Mumbai- (mode proxy) RPC regression tests- mempool.out index b5a3e64970ed..cd910b83e762 100644 --- a/tezt/tests/expected/RPC_test.ml/Mumbai- (mode proxy) RPC regression tests- mempool.out +++ b/tezt/tests/expected/RPC_test.ml/Mumbai- (mode proxy) RPC regression tests- mempool.out @@ -6,7 +6,7 @@ curl -s 'http://localhost:[PORT]/chains/main/mempool/monitor_operations?applied= [{"hash":"[OPERATION_HASH]","protocol":"PtMumbai2TmsJHNGRkD8v8YDbtao7BLUC3wjASn1inAKLFCjaH1","branch":"[BRANCH_HASH]","contents":[{"kind":"transaction","source":"[PUBLIC_KEY_HASH]","fee":"0","counter":"1","gas_limit":"1040","storage_limit":"257","amount":"1000000","destination":"[PUBLIC_KEY_HASH]"}],"signature":"[SIGNATURE]"}] [{"hash":"[OPERATION_HASH]","protocol":"PtMumbai2TmsJHNGRkD8v8YDbtao7BLUC3wjASn1inAKLFCjaH1","branch":"[BRANCH_HASH]","contents":[{"kind":"transaction","source":"[PUBLIC_KEY_HASH]","fee":"1000","counter":"1","gas_limit":"1040","storage_limit":"257","amount":"1000000","destination":"[PUBLIC_KEY_HASH]"}],"signature":"[SIGNATURE]"}] -./octez-client --mode proxy rpc get '/chains/main/mempool/pending_operations?version=2&validated=true&refused=true&outdated=true&branch_delayed=true&branch_refused=true' +./octez-client --mode proxy rpc get '/chains/main/mempool/pending_operations/v1?validated=true&refused=true&outdated=true&branch_delayed=true&branch_refused=true' { "validated": [ { "hash": "[OPERATION_HASH]", "branch": "[BRANCH_HASH]", @@ -69,11 +69,11 @@ curl -s 'http://localhost:[PORT]/chains/main/mempool/monitor_operations?applied= "contract": "[PUBLIC_KEY_HASH]", "expected": "1", "found": "5" } ] } ], "unprocessed": [] } -./octez-client --mode proxy rpc get '/chains/main/mempool/pending_operations?version=2&validated=true&refused=true&outdated=true&branch_delayed=true&branch_refused=true&validation_pass=0' +./octez-client --mode proxy rpc get '/chains/main/mempool/pending_operations/v1?validated=true&refused=true&outdated=true&branch_delayed=true&branch_refused=true&validation_pass=0' { "validated": [], "refused": [], "outdated": [], "branch_refused": [], "branch_delayed": [], "unprocessed": [] } -./octez-client --mode proxy rpc get '/chains/main/mempool/pending_operations?version=2&validated=true&refused=true&outdated=true&branch_delayed=true&branch_refused=true&validation_pass=3' +./octez-client --mode proxy rpc get '/chains/main/mempool/pending_operations/v1?validated=true&refused=true&outdated=true&branch_delayed=true&branch_refused=true&validation_pass=3' { "validated": [ { "hash": "[OPERATION_HASH]", "branch": "[BRANCH_HASH]", @@ -136,7 +136,7 @@ curl -s 'http://localhost:[PORT]/chains/main/mempool/monitor_operations?applied= "contract": "[PUBLIC_KEY_HASH]", "expected": "1", "found": "5" } ] } ], "unprocessed": [] } -./octez-client --mode proxy rpc get '/chains/main/mempool/pending_operations?version=2&validated=true&refused=true&outdated=true&branch_delayed=true&branch_refused=true&validation_pass=0&validation_pass=3' +./octez-client --mode proxy rpc get '/chains/main/mempool/pending_operations/v1?validated=true&refused=true&outdated=true&branch_delayed=true&branch_refused=true&validation_pass=0&validation_pass=3' { "validated": [ { "hash": "[OPERATION_HASH]", "branch": "[BRANCH_HASH]", @@ -199,11 +199,11 @@ curl -s 'http://localhost:[PORT]/chains/main/mempool/monitor_operations?applied= "contract": "[PUBLIC_KEY_HASH]", "expected": "1", "found": "5" } ] } ], "unprocessed": [] } -./octez-client --mode proxy rpc get '/chains/main/mempool/pending_operations?version=2&validated=true&refused=true&outdated=true&branch_delayed=true&branch_refused=true&validation_pass=1&validation_pass=2' +./octez-client --mode proxy rpc get '/chains/main/mempool/pending_operations/v1?validated=true&refused=true&outdated=true&branch_delayed=true&branch_refused=true&validation_pass=1&validation_pass=2' { "validated": [], "refused": [], "outdated": [], "branch_refused": [], "branch_delayed": [], "unprocessed": [] } -./octez-client --mode proxy rpc get '/chains/main/mempool/pending_operations?version=2&validated=true&refused=false&outdated=false&branch_delayed=false&branch_refused=false' +./octez-client --mode proxy rpc get '/chains/main/mempool/pending_operations/v1?validated=true&refused=false&outdated=false&branch_delayed=false&branch_refused=false' { "validated": [ { "hash": "[OPERATION_HASH]", "branch": "[BRANCH_HASH]", @@ -218,7 +218,7 @@ curl -s 'http://localhost:[PORT]/chains/main/mempool/monitor_operations?applied= "refused": [], "outdated": [], "branch_refused": [], "branch_delayed": [], "unprocessed": [] } -./octez-client --mode proxy rpc get '/chains/main/mempool/pending_operations?version=2&validated=false&refused=true&outdated=false&branch_delayed=false&branch_refused=false' +./octez-client --mode proxy rpc get '/chains/main/mempool/pending_operations/v1?validated=false&refused=true&outdated=false&branch_delayed=false&branch_refused=false' { "validated": [], "refused": [ { "hash": "[OPERATION_HASH]", @@ -238,7 +238,7 @@ curl -s 'http://localhost:[PORT]/chains/main/mempool/monitor_operations?applied= "outdated": [], "branch_refused": [], "branch_delayed": [], "unprocessed": [] } -./octez-client --mode proxy rpc get '/chains/main/mempool/pending_operations?version=2&validated=false&refused=false&outdated=false&branch_delayed=true&branch_refused=false' +./octez-client --mode proxy rpc get '/chains/main/mempool/pending_operations/v1?validated=false&refused=false&outdated=false&branch_delayed=true&branch_refused=false' { "validated": [], "refused": [], "outdated": [], "branch_refused": [], "branch_delayed": [ { "hash": "[OPERATION_HASH]", @@ -258,7 +258,7 @@ curl -s 'http://localhost:[PORT]/chains/main/mempool/monitor_operations?applied= "contract": "[PUBLIC_KEY_HASH]", "expected": "1", "found": "5" } ] } ], "unprocessed": [] } -./octez-client --mode proxy rpc get '/chains/main/mempool/pending_operations?version=2&validated=false&refused=false&outdated=false&branch_delayed=false&branch_refused=true' +./octez-client --mode proxy rpc get '/chains/main/mempool/pending_operations/v1?validated=false&refused=false&outdated=false&branch_delayed=false&branch_refused=true' { "validated": [], "refused": [], "outdated": [], "branch_refused": [ { "hash": "[OPERATION_HASH]", @@ -279,7 +279,7 @@ curl -s 'http://localhost:[PORT]/chains/main/mempool/monitor_operations?applied= "expected": "2", "found": "1" } ] } ], "branch_delayed": [], "unprocessed": [] } -./octez-client --mode proxy rpc get '/chains/main/mempool/pending_operations?version=2&validated=false&refused=false&outdated=true&branch_delayed=false&branch_refused=false' +./octez-client --mode proxy rpc get '/chains/main/mempool/pending_operations/v1?validated=false&refused=false&outdated=true&branch_delayed=false&branch_refused=false' { "validated": [], "refused": [], "outdated": [], "branch_refused": [], "branch_delayed": [], "unprocessed": [] } diff --git a/tezt/tests/expected/RPC_test.ml/Nairobi- (mode client) RPC regression tests- mempool.out b/tezt/tests/expected/RPC_test.ml/Nairobi- (mode client) RPC regression tests- mempool.out index d2848fbef44f..8e004fdf93f2 100644 --- a/tezt/tests/expected/RPC_test.ml/Nairobi- (mode client) RPC regression tests- mempool.out +++ b/tezt/tests/expected/RPC_test.ml/Nairobi- (mode client) RPC regression tests- mempool.out @@ -6,7 +6,7 @@ curl -s 'http://localhost:[PORT]/chains/main/mempool/monitor_operations?applied= [{"hash":"[OPERATION_HASH]","protocol":"PtNairobiyssHuh87hEhfVBGCVrK3WnS8Z2FT4ymB5tAa4r1nQf","branch":"[BRANCH_HASH]","contents":[{"kind":"transaction","source":"[PUBLIC_KEY_HASH]","fee":"0","counter":"1","gas_limit":"1040","storage_limit":"257","amount":"1000000","destination":"[PUBLIC_KEY_HASH]"}],"signature":"[SIGNATURE]"}] [{"hash":"[OPERATION_HASH]","protocol":"PtNairobiyssHuh87hEhfVBGCVrK3WnS8Z2FT4ymB5tAa4r1nQf","branch":"[BRANCH_HASH]","contents":[{"kind":"transaction","source":"[PUBLIC_KEY_HASH]","fee":"1000","counter":"1","gas_limit":"1040","storage_limit":"257","amount":"1000000","destination":"[PUBLIC_KEY_HASH]"}],"signature":"[SIGNATURE]"}] -./octez-client rpc get '/chains/main/mempool/pending_operations?version=2&validated=true&refused=true&outdated=true&branch_delayed=true&branch_refused=true' +./octez-client rpc get '/chains/main/mempool/pending_operations/v1?validated=true&refused=true&outdated=true&branch_delayed=true&branch_refused=true' { "validated": [ { "hash": "[OPERATION_HASH]", "branch": "[BRANCH_HASH]", @@ -69,11 +69,11 @@ curl -s 'http://localhost:[PORT]/chains/main/mempool/monitor_operations?applied= "contract": "[PUBLIC_KEY_HASH]", "expected": "1", "found": "5" } ] } ], "unprocessed": [] } -./octez-client rpc get '/chains/main/mempool/pending_operations?version=2&validated=true&refused=true&outdated=true&branch_delayed=true&branch_refused=true&validation_pass=0' +./octez-client rpc get '/chains/main/mempool/pending_operations/v1?validated=true&refused=true&outdated=true&branch_delayed=true&branch_refused=true&validation_pass=0' { "validated": [], "refused": [], "outdated": [], "branch_refused": [], "branch_delayed": [], "unprocessed": [] } -./octez-client rpc get '/chains/main/mempool/pending_operations?version=2&validated=true&refused=true&outdated=true&branch_delayed=true&branch_refused=true&validation_pass=3' +./octez-client rpc get '/chains/main/mempool/pending_operations/v1?validated=true&refused=true&outdated=true&branch_delayed=true&branch_refused=true&validation_pass=3' { "validated": [ { "hash": "[OPERATION_HASH]", "branch": "[BRANCH_HASH]", @@ -136,7 +136,7 @@ curl -s 'http://localhost:[PORT]/chains/main/mempool/monitor_operations?applied= "contract": "[PUBLIC_KEY_HASH]", "expected": "1", "found": "5" } ] } ], "unprocessed": [] } -./octez-client rpc get '/chains/main/mempool/pending_operations?version=2&validated=true&refused=true&outdated=true&branch_delayed=true&branch_refused=true&validation_pass=0&validation_pass=3' +./octez-client rpc get '/chains/main/mempool/pending_operations/v1?validated=true&refused=true&outdated=true&branch_delayed=true&branch_refused=true&validation_pass=0&validation_pass=3' { "validated": [ { "hash": "[OPERATION_HASH]", "branch": "[BRANCH_HASH]", @@ -199,11 +199,11 @@ curl -s 'http://localhost:[PORT]/chains/main/mempool/monitor_operations?applied= "contract": "[PUBLIC_KEY_HASH]", "expected": "1", "found": "5" } ] } ], "unprocessed": [] } -./octez-client rpc get '/chains/main/mempool/pending_operations?version=2&validated=true&refused=true&outdated=true&branch_delayed=true&branch_refused=true&validation_pass=1&validation_pass=2' +./octez-client rpc get '/chains/main/mempool/pending_operations/v1?validated=true&refused=true&outdated=true&branch_delayed=true&branch_refused=true&validation_pass=1&validation_pass=2' { "validated": [], "refused": [], "outdated": [], "branch_refused": [], "branch_delayed": [], "unprocessed": [] } -./octez-client rpc get '/chains/main/mempool/pending_operations?version=2&validated=true&refused=false&outdated=false&branch_delayed=false&branch_refused=false' +./octez-client rpc get '/chains/main/mempool/pending_operations/v1?validated=true&refused=false&outdated=false&branch_delayed=false&branch_refused=false' { "validated": [ { "hash": "[OPERATION_HASH]", "branch": "[BRANCH_HASH]", @@ -218,7 +218,7 @@ curl -s 'http://localhost:[PORT]/chains/main/mempool/monitor_operations?applied= "refused": [], "outdated": [], "branch_refused": [], "branch_delayed": [], "unprocessed": [] } -./octez-client rpc get '/chains/main/mempool/pending_operations?version=2&validated=false&refused=true&outdated=false&branch_delayed=false&branch_refused=false' +./octez-client rpc get '/chains/main/mempool/pending_operations/v1?validated=false&refused=true&outdated=false&branch_delayed=false&branch_refused=false' { "validated": [], "refused": [ { "hash": "[OPERATION_HASH]", @@ -238,7 +238,7 @@ curl -s 'http://localhost:[PORT]/chains/main/mempool/monitor_operations?applied= "outdated": [], "branch_refused": [], "branch_delayed": [], "unprocessed": [] } -./octez-client rpc get '/chains/main/mempool/pending_operations?version=2&validated=false&refused=false&outdated=false&branch_delayed=true&branch_refused=false' +./octez-client rpc get '/chains/main/mempool/pending_operations/v1?validated=false&refused=false&outdated=false&branch_delayed=true&branch_refused=false' { "validated": [], "refused": [], "outdated": [], "branch_refused": [], "branch_delayed": [ { "hash": "[OPERATION_HASH]", @@ -258,7 +258,7 @@ curl -s 'http://localhost:[PORT]/chains/main/mempool/monitor_operations?applied= "contract": "[PUBLIC_KEY_HASH]", "expected": "1", "found": "5" } ] } ], "unprocessed": [] } -./octez-client rpc get '/chains/main/mempool/pending_operations?version=2&validated=false&refused=false&outdated=false&branch_delayed=false&branch_refused=true' +./octez-client rpc get '/chains/main/mempool/pending_operations/v1?validated=false&refused=false&outdated=false&branch_delayed=false&branch_refused=true' { "validated": [], "refused": [], "outdated": [], "branch_refused": [ { "hash": "[OPERATION_HASH]", @@ -279,7 +279,7 @@ curl -s 'http://localhost:[PORT]/chains/main/mempool/monitor_operations?applied= "expected": "2", "found": "1" } ] } ], "branch_delayed": [], "unprocessed": [] } -./octez-client rpc get '/chains/main/mempool/pending_operations?version=2&validated=false&refused=false&outdated=true&branch_delayed=false&branch_refused=false' +./octez-client rpc get '/chains/main/mempool/pending_operations/v1?validated=false&refused=false&outdated=true&branch_delayed=false&branch_refused=false' { "validated": [], "refused": [], "outdated": [], "branch_refused": [], "branch_delayed": [], "unprocessed": [] } diff --git a/tezt/tests/expected/RPC_test.ml/Nairobi- (mode proxy) RPC regression tests- mempool.out b/tezt/tests/expected/RPC_test.ml/Nairobi- (mode proxy) RPC regression tests- mempool.out index b0a189ceaaa6..086d5eb8e394 100644 --- a/tezt/tests/expected/RPC_test.ml/Nairobi- (mode proxy) RPC regression tests- mempool.out +++ b/tezt/tests/expected/RPC_test.ml/Nairobi- (mode proxy) RPC regression tests- mempool.out @@ -6,7 +6,7 @@ curl -s 'http://localhost:[PORT]/chains/main/mempool/monitor_operations?applied= [{"hash":"[OPERATION_HASH]","protocol":"PtNairobiyssHuh87hEhfVBGCVrK3WnS8Z2FT4ymB5tAa4r1nQf","branch":"[BRANCH_HASH]","contents":[{"kind":"transaction","source":"[PUBLIC_KEY_HASH]","fee":"0","counter":"1","gas_limit":"1040","storage_limit":"257","amount":"1000000","destination":"[PUBLIC_KEY_HASH]"}],"signature":"[SIGNATURE]"}] [{"hash":"[OPERATION_HASH]","protocol":"PtNairobiyssHuh87hEhfVBGCVrK3WnS8Z2FT4ymB5tAa4r1nQf","branch":"[BRANCH_HASH]","contents":[{"kind":"transaction","source":"[PUBLIC_KEY_HASH]","fee":"1000","counter":"1","gas_limit":"1040","storage_limit":"257","amount":"1000000","destination":"[PUBLIC_KEY_HASH]"}],"signature":"[SIGNATURE]"}] -./octez-client --mode proxy rpc get '/chains/main/mempool/pending_operations?version=2&validated=true&refused=true&outdated=true&branch_delayed=true&branch_refused=true' +./octez-client --mode proxy rpc get '/chains/main/mempool/pending_operations/v1?validated=true&refused=true&outdated=true&branch_delayed=true&branch_refused=true' { "validated": [ { "hash": "[OPERATION_HASH]", "branch": "[BRANCH_HASH]", @@ -69,11 +69,11 @@ curl -s 'http://localhost:[PORT]/chains/main/mempool/monitor_operations?applied= "contract": "[PUBLIC_KEY_HASH]", "expected": "1", "found": "5" } ] } ], "unprocessed": [] } -./octez-client --mode proxy rpc get '/chains/main/mempool/pending_operations?version=2&validated=true&refused=true&outdated=true&branch_delayed=true&branch_refused=true&validation_pass=0' +./octez-client --mode proxy rpc get '/chains/main/mempool/pending_operations/v1?validated=true&refused=true&outdated=true&branch_delayed=true&branch_refused=true&validation_pass=0' { "validated": [], "refused": [], "outdated": [], "branch_refused": [], "branch_delayed": [], "unprocessed": [] } -./octez-client --mode proxy rpc get '/chains/main/mempool/pending_operations?version=2&validated=true&refused=true&outdated=true&branch_delayed=true&branch_refused=true&validation_pass=3' +./octez-client --mode proxy rpc get '/chains/main/mempool/pending_operations/v1?validated=true&refused=true&outdated=true&branch_delayed=true&branch_refused=true&validation_pass=3' { "validated": [ { "hash": "[OPERATION_HASH]", "branch": "[BRANCH_HASH]", @@ -136,7 +136,7 @@ curl -s 'http://localhost:[PORT]/chains/main/mempool/monitor_operations?applied= "contract": "[PUBLIC_KEY_HASH]", "expected": "1", "found": "5" } ] } ], "unprocessed": [] } -./octez-client --mode proxy rpc get '/chains/main/mempool/pending_operations?version=2&validated=true&refused=true&outdated=true&branch_delayed=true&branch_refused=true&validation_pass=0&validation_pass=3' +./octez-client --mode proxy rpc get '/chains/main/mempool/pending_operations/v1?validated=true&refused=true&outdated=true&branch_delayed=true&branch_refused=true&validation_pass=0&validation_pass=3' { "validated": [ { "hash": "[OPERATION_HASH]", "branch": "[BRANCH_HASH]", @@ -199,11 +199,11 @@ curl -s 'http://localhost:[PORT]/chains/main/mempool/monitor_operations?applied= "contract": "[PUBLIC_KEY_HASH]", "expected": "1", "found": "5" } ] } ], "unprocessed": [] } -./octez-client --mode proxy rpc get '/chains/main/mempool/pending_operations?version=2&validated=true&refused=true&outdated=true&branch_delayed=true&branch_refused=true&validation_pass=1&validation_pass=2' +./octez-client --mode proxy rpc get '/chains/main/mempool/pending_operations/v1?validated=true&refused=true&outdated=true&branch_delayed=true&branch_refused=true&validation_pass=1&validation_pass=2' { "validated": [], "refused": [], "outdated": [], "branch_refused": [], "branch_delayed": [], "unprocessed": [] } -./octez-client --mode proxy rpc get '/chains/main/mempool/pending_operations?version=2&validated=true&refused=false&outdated=false&branch_delayed=false&branch_refused=false' +./octez-client --mode proxy rpc get '/chains/main/mempool/pending_operations/v1?validated=true&refused=false&outdated=false&branch_delayed=false&branch_refused=false' { "validated": [ { "hash": "[OPERATION_HASH]", "branch": "[BRANCH_HASH]", @@ -218,7 +218,7 @@ curl -s 'http://localhost:[PORT]/chains/main/mempool/monitor_operations?applied= "refused": [], "outdated": [], "branch_refused": [], "branch_delayed": [], "unprocessed": [] } -./octez-client --mode proxy rpc get '/chains/main/mempool/pending_operations?version=2&validated=false&refused=true&outdated=false&branch_delayed=false&branch_refused=false' +./octez-client --mode proxy rpc get '/chains/main/mempool/pending_operations/v1?validated=false&refused=true&outdated=false&branch_delayed=false&branch_refused=false' { "validated": [], "refused": [ { "hash": "[OPERATION_HASH]", @@ -238,7 +238,7 @@ curl -s 'http://localhost:[PORT]/chains/main/mempool/monitor_operations?applied= "outdated": [], "branch_refused": [], "branch_delayed": [], "unprocessed": [] } -./octez-client --mode proxy rpc get '/chains/main/mempool/pending_operations?version=2&validated=false&refused=false&outdated=false&branch_delayed=true&branch_refused=false' +./octez-client --mode proxy rpc get '/chains/main/mempool/pending_operations/v1?validated=false&refused=false&outdated=false&branch_delayed=true&branch_refused=false' { "validated": [], "refused": [], "outdated": [], "branch_refused": [], "branch_delayed": [ { "hash": "[OPERATION_HASH]", @@ -258,7 +258,7 @@ curl -s 'http://localhost:[PORT]/chains/main/mempool/monitor_operations?applied= "contract": "[PUBLIC_KEY_HASH]", "expected": "1", "found": "5" } ] } ], "unprocessed": [] } -./octez-client --mode proxy rpc get '/chains/main/mempool/pending_operations?version=2&validated=false&refused=false&outdated=false&branch_delayed=false&branch_refused=true' +./octez-client --mode proxy rpc get '/chains/main/mempool/pending_operations/v1?validated=false&refused=false&outdated=false&branch_delayed=false&branch_refused=true' { "validated": [], "refused": [], "outdated": [], "branch_refused": [ { "hash": "[OPERATION_HASH]", @@ -279,7 +279,7 @@ curl -s 'http://localhost:[PORT]/chains/main/mempool/monitor_operations?applied= "expected": "2", "found": "1" } ] } ], "branch_delayed": [], "unprocessed": [] } -./octez-client --mode proxy rpc get '/chains/main/mempool/pending_operations?version=2&validated=false&refused=false&outdated=true&branch_delayed=false&branch_refused=false' +./octez-client --mode proxy rpc get '/chains/main/mempool/pending_operations/v1?validated=false&refused=false&outdated=true&branch_delayed=false&branch_refused=false' { "validated": [], "refused": [], "outdated": [], "branch_refused": [], "branch_delayed": [], "unprocessed": [] } diff --git a/tezt/tests/expected/RPC_test.ml/Oxford- (mode client) RPC regression tests- mempool.out b/tezt/tests/expected/RPC_test.ml/Oxford- (mode client) RPC regression tests- mempool.out index b09dc68849e4..650710037629 100644 --- a/tezt/tests/expected/RPC_test.ml/Oxford- (mode client) RPC regression tests- mempool.out +++ b/tezt/tests/expected/RPC_test.ml/Oxford- (mode client) RPC regression tests- mempool.out @@ -6,7 +6,7 @@ curl -s 'http://localhost:[PORT]/chains/main/mempool/monitor_operations?applied= [{"hash":"[OPERATION_HASH]","protocol":"ProxfordLcjScHFgpTURyTjcKR88D5juu1jGgT18pPUoGTVgxiA","branch":"[BRANCH_HASH]","contents":[{"kind":"transaction","source":"[PUBLIC_KEY_HASH]","fee":"0","counter":"1","gas_limit":"1040","storage_limit":"257","amount":"1000000","destination":"[PUBLIC_KEY_HASH]"}],"signature":"[SIGNATURE]"}] [{"hash":"[OPERATION_HASH]","protocol":"ProxfordLcjScHFgpTURyTjcKR88D5juu1jGgT18pPUoGTVgxiA","branch":"[BRANCH_HASH]","contents":[{"kind":"transaction","source":"[PUBLIC_KEY_HASH]","fee":"1000","counter":"1","gas_limit":"1040","storage_limit":"257","amount":"1000000","destination":"[PUBLIC_KEY_HASH]"}],"signature":"[SIGNATURE]"}] -./octez-client rpc get '/chains/main/mempool/pending_operations?version=2&validated=true&refused=true&outdated=true&branch_delayed=true&branch_refused=true' +./octez-client rpc get '/chains/main/mempool/pending_operations/v1?validated=true&refused=true&outdated=true&branch_delayed=true&branch_refused=true' { "validated": [ { "hash": "[OPERATION_HASH]", "branch": "[BRANCH_HASH]", @@ -69,11 +69,11 @@ curl -s 'http://localhost:[PORT]/chains/main/mempool/monitor_operations?applied= "contract": "[PUBLIC_KEY_HASH]", "expected": "1", "found": "5" } ] } ], "unprocessed": [] } -./octez-client rpc get '/chains/main/mempool/pending_operations?version=2&validated=true&refused=true&outdated=true&branch_delayed=true&branch_refused=true&validation_pass=0' +./octez-client rpc get '/chains/main/mempool/pending_operations/v1?validated=true&refused=true&outdated=true&branch_delayed=true&branch_refused=true&validation_pass=0' { "validated": [], "refused": [], "outdated": [], "branch_refused": [], "branch_delayed": [], "unprocessed": [] } -./octez-client rpc get '/chains/main/mempool/pending_operations?version=2&validated=true&refused=true&outdated=true&branch_delayed=true&branch_refused=true&validation_pass=3' +./octez-client rpc get '/chains/main/mempool/pending_operations/v1?validated=true&refused=true&outdated=true&branch_delayed=true&branch_refused=true&validation_pass=3' { "validated": [ { "hash": "[OPERATION_HASH]", "branch": "[BRANCH_HASH]", @@ -136,7 +136,7 @@ curl -s 'http://localhost:[PORT]/chains/main/mempool/monitor_operations?applied= "contract": "[PUBLIC_KEY_HASH]", "expected": "1", "found": "5" } ] } ], "unprocessed": [] } -./octez-client rpc get '/chains/main/mempool/pending_operations?version=2&validated=true&refused=true&outdated=true&branch_delayed=true&branch_refused=true&validation_pass=0&validation_pass=3' +./octez-client rpc get '/chains/main/mempool/pending_operations/v1?validated=true&refused=true&outdated=true&branch_delayed=true&branch_refused=true&validation_pass=0&validation_pass=3' { "validated": [ { "hash": "[OPERATION_HASH]", "branch": "[BRANCH_HASH]", @@ -199,11 +199,11 @@ curl -s 'http://localhost:[PORT]/chains/main/mempool/monitor_operations?applied= "contract": "[PUBLIC_KEY_HASH]", "expected": "1", "found": "5" } ] } ], "unprocessed": [] } -./octez-client rpc get '/chains/main/mempool/pending_operations?version=2&validated=true&refused=true&outdated=true&branch_delayed=true&branch_refused=true&validation_pass=1&validation_pass=2' +./octez-client rpc get '/chains/main/mempool/pending_operations/v1?validated=true&refused=true&outdated=true&branch_delayed=true&branch_refused=true&validation_pass=1&validation_pass=2' { "validated": [], "refused": [], "outdated": [], "branch_refused": [], "branch_delayed": [], "unprocessed": [] } -./octez-client rpc get '/chains/main/mempool/pending_operations?version=2&validated=true&refused=false&outdated=false&branch_delayed=false&branch_refused=false' +./octez-client rpc get '/chains/main/mempool/pending_operations/v1?validated=true&refused=false&outdated=false&branch_delayed=false&branch_refused=false' { "validated": [ { "hash": "[OPERATION_HASH]", "branch": "[BRANCH_HASH]", @@ -218,7 +218,7 @@ curl -s 'http://localhost:[PORT]/chains/main/mempool/monitor_operations?applied= "refused": [], "outdated": [], "branch_refused": [], "branch_delayed": [], "unprocessed": [] } -./octez-client rpc get '/chains/main/mempool/pending_operations?version=2&validated=false&refused=true&outdated=false&branch_delayed=false&branch_refused=false' +./octez-client rpc get '/chains/main/mempool/pending_operations/v1?validated=false&refused=true&outdated=false&branch_delayed=false&branch_refused=false' { "validated": [], "refused": [ { "hash": "[OPERATION_HASH]", @@ -238,7 +238,7 @@ curl -s 'http://localhost:[PORT]/chains/main/mempool/monitor_operations?applied= "outdated": [], "branch_refused": [], "branch_delayed": [], "unprocessed": [] } -./octez-client rpc get '/chains/main/mempool/pending_operations?version=2&validated=false&refused=false&outdated=false&branch_delayed=true&branch_refused=false' +./octez-client rpc get '/chains/main/mempool/pending_operations/v1?validated=false&refused=false&outdated=false&branch_delayed=true&branch_refused=false' { "validated": [], "refused": [], "outdated": [], "branch_refused": [], "branch_delayed": [ { "hash": "[OPERATION_HASH]", @@ -258,7 +258,7 @@ curl -s 'http://localhost:[PORT]/chains/main/mempool/monitor_operations?applied= "contract": "[PUBLIC_KEY_HASH]", "expected": "1", "found": "5" } ] } ], "unprocessed": [] } -./octez-client rpc get '/chains/main/mempool/pending_operations?version=2&validated=false&refused=false&outdated=false&branch_delayed=false&branch_refused=true' +./octez-client rpc get '/chains/main/mempool/pending_operations/v1?validated=false&refused=false&outdated=false&branch_delayed=false&branch_refused=true' { "validated": [], "refused": [], "outdated": [], "branch_refused": [ { "hash": "[OPERATION_HASH]", @@ -279,7 +279,7 @@ curl -s 'http://localhost:[PORT]/chains/main/mempool/monitor_operations?applied= "expected": "2", "found": "1" } ] } ], "branch_delayed": [], "unprocessed": [] } -./octez-client rpc get '/chains/main/mempool/pending_operations?version=2&validated=false&refused=false&outdated=true&branch_delayed=false&branch_refused=false' +./octez-client rpc get '/chains/main/mempool/pending_operations/v1?validated=false&refused=false&outdated=true&branch_delayed=false&branch_refused=false' { "validated": [], "refused": [], "outdated": [], "branch_refused": [], "branch_delayed": [], "unprocessed": [] } diff --git a/tezt/tests/expected/RPC_test.ml/Oxford- (mode proxy) RPC regression tests- mempool.out b/tezt/tests/expected/RPC_test.ml/Oxford- (mode proxy) RPC regression tests- mempool.out index c550eaa41b0c..b81846eb1665 100644 --- a/tezt/tests/expected/RPC_test.ml/Oxford- (mode proxy) RPC regression tests- mempool.out +++ b/tezt/tests/expected/RPC_test.ml/Oxford- (mode proxy) RPC regression tests- mempool.out @@ -6,7 +6,7 @@ curl -s 'http://localhost:[PORT]/chains/main/mempool/monitor_operations?applied= [{"hash":"[OPERATION_HASH]","protocol":"ProxfordLcjScHFgpTURyTjcKR88D5juu1jGgT18pPUoGTVgxiA","branch":"[BRANCH_HASH]","contents":[{"kind":"transaction","source":"[PUBLIC_KEY_HASH]","fee":"0","counter":"1","gas_limit":"1040","storage_limit":"257","amount":"1000000","destination":"[PUBLIC_KEY_HASH]"}],"signature":"[SIGNATURE]"}] [{"hash":"[OPERATION_HASH]","protocol":"ProxfordLcjScHFgpTURyTjcKR88D5juu1jGgT18pPUoGTVgxiA","branch":"[BRANCH_HASH]","contents":[{"kind":"transaction","source":"[PUBLIC_KEY_HASH]","fee":"1000","counter":"1","gas_limit":"1040","storage_limit":"257","amount":"1000000","destination":"[PUBLIC_KEY_HASH]"}],"signature":"[SIGNATURE]"}] -./octez-client --mode proxy rpc get '/chains/main/mempool/pending_operations?version=2&validated=true&refused=true&outdated=true&branch_delayed=true&branch_refused=true' +./octez-client --mode proxy rpc get '/chains/main/mempool/pending_operations/v1?validated=true&refused=true&outdated=true&branch_delayed=true&branch_refused=true' { "validated": [ { "hash": "[OPERATION_HASH]", "branch": "[BRANCH_HASH]", @@ -69,11 +69,11 @@ curl -s 'http://localhost:[PORT]/chains/main/mempool/monitor_operations?applied= "contract": "[PUBLIC_KEY_HASH]", "expected": "1", "found": "5" } ] } ], "unprocessed": [] } -./octez-client --mode proxy rpc get '/chains/main/mempool/pending_operations?version=2&validated=true&refused=true&outdated=true&branch_delayed=true&branch_refused=true&validation_pass=0' +./octez-client --mode proxy rpc get '/chains/main/mempool/pending_operations/v1?validated=true&refused=true&outdated=true&branch_delayed=true&branch_refused=true&validation_pass=0' { "validated": [], "refused": [], "outdated": [], "branch_refused": [], "branch_delayed": [], "unprocessed": [] } -./octez-client --mode proxy rpc get '/chains/main/mempool/pending_operations?version=2&validated=true&refused=true&outdated=true&branch_delayed=true&branch_refused=true&validation_pass=3' +./octez-client --mode proxy rpc get '/chains/main/mempool/pending_operations/v1?validated=true&refused=true&outdated=true&branch_delayed=true&branch_refused=true&validation_pass=3' { "validated": [ { "hash": "[OPERATION_HASH]", "branch": "[BRANCH_HASH]", @@ -136,7 +136,7 @@ curl -s 'http://localhost:[PORT]/chains/main/mempool/monitor_operations?applied= "contract": "[PUBLIC_KEY_HASH]", "expected": "1", "found": "5" } ] } ], "unprocessed": [] } -./octez-client --mode proxy rpc get '/chains/main/mempool/pending_operations?version=2&validated=true&refused=true&outdated=true&branch_delayed=true&branch_refused=true&validation_pass=0&validation_pass=3' +./octez-client --mode proxy rpc get '/chains/main/mempool/pending_operations/v1?validated=true&refused=true&outdated=true&branch_delayed=true&branch_refused=true&validation_pass=0&validation_pass=3' { "validated": [ { "hash": "[OPERATION_HASH]", "branch": "[BRANCH_HASH]", @@ -199,11 +199,11 @@ curl -s 'http://localhost:[PORT]/chains/main/mempool/monitor_operations?applied= "contract": "[PUBLIC_KEY_HASH]", "expected": "1", "found": "5" } ] } ], "unprocessed": [] } -./octez-client --mode proxy rpc get '/chains/main/mempool/pending_operations?version=2&validated=true&refused=true&outdated=true&branch_delayed=true&branch_refused=true&validation_pass=1&validation_pass=2' +./octez-client --mode proxy rpc get '/chains/main/mempool/pending_operations/v1?validated=true&refused=true&outdated=true&branch_delayed=true&branch_refused=true&validation_pass=1&validation_pass=2' { "validated": [], "refused": [], "outdated": [], "branch_refused": [], "branch_delayed": [], "unprocessed": [] } -./octez-client --mode proxy rpc get '/chains/main/mempool/pending_operations?version=2&validated=true&refused=false&outdated=false&branch_delayed=false&branch_refused=false' +./octez-client --mode proxy rpc get '/chains/main/mempool/pending_operations/v1?validated=true&refused=false&outdated=false&branch_delayed=false&branch_refused=false' { "validated": [ { "hash": "[OPERATION_HASH]", "branch": "[BRANCH_HASH]", @@ -218,7 +218,7 @@ curl -s 'http://localhost:[PORT]/chains/main/mempool/monitor_operations?applied= "refused": [], "outdated": [], "branch_refused": [], "branch_delayed": [], "unprocessed": [] } -./octez-client --mode proxy rpc get '/chains/main/mempool/pending_operations?version=2&validated=false&refused=true&outdated=false&branch_delayed=false&branch_refused=false' +./octez-client --mode proxy rpc get '/chains/main/mempool/pending_operations/v1?validated=false&refused=true&outdated=false&branch_delayed=false&branch_refused=false' { "validated": [], "refused": [ { "hash": "[OPERATION_HASH]", @@ -238,7 +238,7 @@ curl -s 'http://localhost:[PORT]/chains/main/mempool/monitor_operations?applied= "outdated": [], "branch_refused": [], "branch_delayed": [], "unprocessed": [] } -./octez-client --mode proxy rpc get '/chains/main/mempool/pending_operations?version=2&validated=false&refused=false&outdated=false&branch_delayed=true&branch_refused=false' +./octez-client --mode proxy rpc get '/chains/main/mempool/pending_operations/v1?validated=false&refused=false&outdated=false&branch_delayed=true&branch_refused=false' { "validated": [], "refused": [], "outdated": [], "branch_refused": [], "branch_delayed": [ { "hash": "[OPERATION_HASH]", @@ -258,7 +258,7 @@ curl -s 'http://localhost:[PORT]/chains/main/mempool/monitor_operations?applied= "contract": "[PUBLIC_KEY_HASH]", "expected": "1", "found": "5" } ] } ], "unprocessed": [] } -./octez-client --mode proxy rpc get '/chains/main/mempool/pending_operations?version=2&validated=false&refused=false&outdated=false&branch_delayed=false&branch_refused=true' +./octez-client --mode proxy rpc get '/chains/main/mempool/pending_operations/v1?validated=false&refused=false&outdated=false&branch_delayed=false&branch_refused=true' { "validated": [], "refused": [], "outdated": [], "branch_refused": [ { "hash": "[OPERATION_HASH]", @@ -279,7 +279,7 @@ curl -s 'http://localhost:[PORT]/chains/main/mempool/monitor_operations?applied= "expected": "2", "found": "1" } ] } ], "branch_delayed": [], "unprocessed": [] } -./octez-client --mode proxy rpc get '/chains/main/mempool/pending_operations?version=2&validated=false&refused=false&outdated=true&branch_delayed=false&branch_refused=false' +./octez-client --mode proxy rpc get '/chains/main/mempool/pending_operations/v1?validated=false&refused=false&outdated=true&branch_delayed=false&branch_refused=false' { "validated": [], "refused": [], "outdated": [], "branch_refused": [], "branch_delayed": [], "unprocessed": [] } diff --git a/tezt/tests/prevalidator.ml b/tezt/tests/prevalidator.ml index 25cf0c092dfc..488dbcfe209c 100644 --- a/tezt/tests/prevalidator.ml +++ b/tezt/tests/prevalidator.ml @@ -1958,7 +1958,7 @@ module Revamped = struct log_step 3 "Check that the batch is correctly [validated] in the mempool." ; let* mempool_json = RPC.Client.call client - @@ RPC.get_chain_mempool_pending_operations ~version:"2" () + @@ RPC.get_chain_mempool_pending_operations ~version:"1" () in let mempool = Mempool.of_json mempool_json in Mempool.check_mempool ~validated:[oph] mempool ; @@ -2050,7 +2050,12 @@ module Revamped = struct the third." ; let* () = check_mempool ~validated:[oph1] client1 in let* () = check_mempool ~validated:[oph1] client2 in - let* () = check_mempool ~validated:[] client3 in + let*? p = + RPC.Client.spawn client3 + @@ RPC.get_chain_mempool_pending_operations ~version:"1" () + in + let msg = rex "Fatal error:\n No service found at this URL" in + let* () = Process.check_error ~msg p in log_step 5 "Check that injecting an operation into the node with disabled mempool \ @@ -2222,7 +2227,7 @@ let forge_and_inject_operation ~branch ~fee ~gas_limit ~source ~destination let check_if_op_is_in_mempool client ~classification oph = let* ops = RPC.Client.call client - @@ RPC.get_chain_mempool_pending_operations ~version:"1" () + @@ RPC.get_chain_mempool_pending_operations ~version:"0" () in let open JSON in let search_in ops c = @@ -3632,7 +3637,7 @@ let check_mempool_ops_fees ~(applied : int list) ~(refused : int list) client = let client_name = Client.name client in let* ops = RPC.Client.call client - @@ RPC.get_chain_mempool_pending_operations ~version:"1" () + @@ RPC.get_chain_mempool_pending_operations ~version:"0" () in let check_fees classification expected = let classification_ops = JSON.(ops |-> classification |> as_list) in diff --git a/tezt/tests/rpc_versioning_attestation.ml b/tezt/tests/rpc_versioning_attestation.ml index 0a44befa11dd..14ff04489b17 100644 --- a/tezt/tests/rpc_versioning_attestation.ml +++ b/tezt/tests/rpc_versioning_attestation.ml @@ -79,13 +79,19 @@ let check_version ~version ~use_legacy_name ~check ~rpc ~get_name ~data client = let* t = RPC.Client.call client @@ rpc ~version data in return (check ~use_legacy_name t (get_name use_legacy_name)) -let check_unknown_version ~version ~rpc ~data client = +let check_unknown_version_parse ~version ~rpc ~data client = let*? p = RPC.Client.spawn client @@ rpc ~version data in let msg = rex "Failed to parse argument 'version'" in Process.check_error ~msg p -let check_rpc_versions ?(old = "0") ?(new_ = "1") ?(unknown = "2") ~check ~rpc - ~get_name ~data client = +let check_unknown_version ~version ~rpc ~data client = + let*? p = RPC.Client.spawn client @@ rpc ~version data in + let msg = rex "Fatal error:\n No service found at this URL" in + Process.check_error ~msg p + +let check_rpc_versions ?(old = "0") ?(new_ = "1") ?(unknown = "2") ~check + ?(check_unknown_version = check_unknown_version_parse) ~rpc ~get_name ~data + client = Log.info "Call the rpc with the old version and check that the operations returned \ contain endorsement kinds" ; @@ -489,10 +495,8 @@ module Mempool = struct in let get_name = Operation.Consensus.kind_to_string kind in check_rpc_versions - ~old:"1" - ~new_:"2" - ~unknown:"3" ~check + ~check_unknown_version ~rpc ~get_name ~data:() @@ -536,10 +540,8 @@ module Mempool = struct in let get_name = Operation.Anonymous.kind_to_string double_evidence_kind in check_rpc_versions - ~old:"1" - ~new_:"2" - ~unknown:"3" ~check + ~check_unknown_version ~rpc ~get_name ~data:() -- GitLab From 9950f8a7e74ac09c2f63c8b0fc178db7bf29faf5 Mon Sep 17 00:00:00 2001 From: Albin Coquereau Date: Wed, 5 Jul 2023 12:29:04 +0200 Subject: [PATCH 06/19] tezt/tests: remove old prevalidator test This test checked that the old version of pending_operations did not have the same format as the recent one. Since the old version of pending_operation as been removed this test can be removed. --- tezt/tests/prevalidator.ml | 80 -------------------------------------- 1 file changed, 80 deletions(-) diff --git a/tezt/tests/prevalidator.ml b/tezt/tests/prevalidator.ml index 488dbcfe209c..9b2ba4236f62 100644 --- a/tezt/tests/prevalidator.ml +++ b/tezt/tests/prevalidator.ml @@ -3164,85 +3164,6 @@ let get_refused_operation_hash_list_v0 mempool = let get_refused_operation_hash_list_v1 mempool = List.map get_hash JSON.(mempool |-> "refused" |> as_list) -(** This test tries to check the format of different versions of - pending_operations RPC. - - Scenario: - - + Node 1 activates a protocol - - + Inject operation on node_1 with low fees - - + Bake empty block to classify operation as refused - - + Get the hash of the operation using different versions of pending_operation RPC - and check that they are the same *) -let test_pending_operation_version = - Protocol.register_test - ~__FILE__ - ~title:"pending operation version" - ~tags:["mempool"; "pending_operations"; "version"] - @@ fun protocol -> - (* Step 1 *) - (* Initialise one node *) - let* node_1 = - Node.init - ~event_sections_levels:[("prevalidator", `Debug)] - [Synchronisation_threshold 0; Private_mode] - in - let* client_1 = Client.init ~endpoint:(Node node_1) () in - let* () = Client.activate_protocol_and_wait ~protocol client_1 in - Log.info "Activated protocol." ; - (* Step 2 *) - (* Inject refused operation *) - let* branch = Operation.Manager.get_branch client_1 in - - let* _ = - forge_and_inject_operation - ~branch - ~fee:10 - ~gas_limit:1040 - ~source:Constant.bootstrap1.public_key_hash - ~destination:Constant.bootstrap2.public_key_hash - ~counter:1 - ~signer:Constant.bootstrap1 - ~client:client_1 - in - (* Step 3 *) - (* Bake empty block to force operation to be classify as refused *) - let dummy_baking = wait_for_flush node_1 in - let* () = bake_empty_block ~protocol client_1 in - let* () = dummy_baking in - (* Step 4 *) - (* Get pending operations using different version of the RPC and check *) - let* mempool_v0 = - RPC.Client.call client_1 - @@ RPC.get_chain_mempool_pending_operations ~version:"0" () - in - let* mempool_v1 = - RPC.Client.call client_1 @@ RPC.get_chain_mempool_pending_operations () - in - let ophs_refused_v0 = get_refused_operation_hash_list_v0 mempool_v0 in - let ophs_refused_v1 = get_refused_operation_hash_list_v1 mempool_v1 in - try - if not (List.for_all2 String.equal ophs_refused_v0 ophs_refused_v1) then - Format.kasprintf - (Test.fail "%s") - "Refused operation hash list should have the same elements. Got : %a \ - (version 1) and %a (version 2)" - (Format.pp_print_list (fun ppf oph -> Format.fprintf ppf "%s" oph)) - ophs_refused_v0 - (Format.pp_print_list (fun ppf oph -> Format.fprintf ppf "%s" oph)) - ophs_refused_v1 ; - unit - with Invalid_argument _ -> - Format.kasprintf - (Test.fail "%s") - "Refused operation hash list should have the same number of elements. \ - Got : %d (version 1) and %d (version 2)" - (List.length ophs_refused_v0) - (List.length ophs_refused_v1) - (** This test tries to check that invalid operation can be injected on a local node with private/injection/operation RPC *) let force_operation_injection = @@ -3923,7 +3844,6 @@ let register ~protocols = refetch_failed_operation protocols ; ban_operation_and_check_applied protocols ; test_do_not_reclassify protocols ; - test_pending_operation_version protocols ; force_operation_injection protocols ; injecting_old_operation_fails protocols ; test_get_post_mempool_filter protocols ; -- GitLab From 69fb8faddc2c6822dedd71d54a287d38cf1b81e3 Mon Sep 17 00:00:00 2001 From: Albin Coquereau Date: Wed, 5 Jul 2023 21:32:53 +0200 Subject: [PATCH 07/19] changes: update pending_operations RPC entry --- CHANGES.rst | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 25ea3f8dab1c..5dae4bb4f6f4 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -92,13 +92,15 @@ Node ``preattestation``, ``double_attestation_evidence`` and ``double_preattestation_evidence`` kinds in the JSON result. (MR :gl:`!8840`) -- Added version ``2`` to RPC ``GET ../mempool/pending_operations``. It can be - used by calling the RPC with the parameter ``?version=2`` (default version is - still ``1``). Version ``2`` allows the RPC to output ``attestation``, - ``preattestation``, ``double_attestation_evidence`` and - ``double_preattestation_evidence`` kinds in the JSON result. This version - also renames the ``applied`` field of the result to ``validated`` - (MRs :gl:`!8960`, :gl:`!9143`) +- Removed the version ``0`` of RPC ``GET ../mempool/pending_operations``. (MR + :gl:`!9410`) + +- Introduced a version ``v1`` to RPC ``GET ../mempool/pending_operations``. It + can be used by calling ``GET ../mempool/pending_operations/v1``. This version + allows the RPC to output ``attestation``, ``preattestation``, + ``double_attestation_evidence`` and ``double_preattestation_evidence`` kinds + in the JSON result. This version also renames the ``applied`` field of the + result to ``validated`` (MRs :gl:`!8960`, :gl:`!9143`, :gl:`!9410`) - RPCs ``/helpers/scripts/run_operation`` and ``/helpers/scripts/simulate_operation`` can now take JSON formatted operations -- GitLab From 6788029c97793445ad658138e8caaea1336ac232 Mon Sep 17 00:00:00 2001 From: Albin Coquereau Date: Wed, 5 Jul 2023 09:38:01 +0200 Subject: [PATCH 08/19] lib_shell: introduce `monitor_operation/v1` This rpc output `attestation` instead of `endorsement` for consensus operation kind in JSON --- src/lib_shell/prevalidator_internal.ml | 201 +++++++++--------- src/lib_shell_services/block_services.ml | 89 +++----- src/lib_shell_services/block_services.mli | 26 ++- .../test/mockup_simulator/faked_services.ml | 6 +- .../test/mockup_simulator/mockup_simulator.ml | 7 +- .../test/mockup_simulator/faked_services.ml | 6 +- .../test/mockup_simulator/mockup_simulator.ml | 7 +- .../test/mockup_simulator/faked_services.ml | 6 +- .../test/mockup_simulator/mockup_simulator.ml | 7 +- .../test/mockup_simulator/faked_services.ml | 6 +- .../test/mockup_simulator/mockup_simulator.ml | 7 +- 11 files changed, 172 insertions(+), 196 deletions(-) diff --git a/src/lib_shell/prevalidator_internal.ml b/src/lib_shell/prevalidator_internal.ml index 69fe33334fe6..11c2c6200211 100644 --- a/src/lib_shell/prevalidator_internal.ml +++ b/src/lib_shell/prevalidator_internal.ml @@ -1059,108 +1059,113 @@ module Make (fun pv t () -> pv.shell.parameters.tools.send_get_current_head ?peer:t#peer_id () ; return_unit) ; + let monitor_operations pv params () = + Lwt_mutex.with_lock pv.lock @@ fun () -> + let op_stream, stopper = + Lwt_watcher.create_stream pv.operation_stream + in + (* First call : retrieve the current set of op from the mempool *) + let validated_seq = + if + params#validated && Option.value ~default:true params#applied + (* https://gitlab.com/tezos/tezos/-/issues/5891 + applied is deprecated and should be removed in a future + version of Octez *) + then + Classification.Sized_map.to_map pv.shell.classification.validated + |> Operation_hash.Map.to_seq + |> Seq.map (fun (hash, {protocol; _}) -> ((hash, protocol), None)) + else Seq.empty + in + let process_error_map map = + let open Operation_hash in + map |> Map.to_seq + |> Seq.map (fun (hash, (op, error)) -> + ((hash, op.protocol), Some error)) + in + let refused_seq = + if params#refused then + process_error_map + (Classification.map pv.shell.classification.refused) + else Seq.empty + in + let branch_refused_seq = + if params#branch_refused then + process_error_map + (Classification.map pv.shell.classification.branch_refused) + else Seq.empty + in + let branch_delayed_seq = + if params#branch_delayed then + process_error_map + (Classification.map pv.shell.classification.branch_delayed) + else Seq.empty + in + let outdated_seq = + if params#outdated then + process_error_map + (Classification.map pv.shell.classification.outdated) + else Seq.empty + in + let filter ((_, op), _) = + filter_validation_passes params#validation_passes op + in + let current_mempool = + Seq.append outdated_seq branch_delayed_seq + |> Seq.append branch_refused_seq + |> Seq.append refused_seq |> Seq.append validated_seq + |> Seq.filter filter |> List.of_seq + in + let current_mempool = ref (Some current_mempool) in + let filter_result = function + | `Validated -> + params#validated && Option.value ~default:true params#applied + | `Refused _ -> params#refused + | `Outdated _ -> params#outdated + | `Branch_refused _ -> params#branch_refused + | `Branch_delayed _ -> params#branch_delayed + in + let rec next () = + let open Lwt_syntax in + match !current_mempool with + | Some mempool -> + current_mempool := None ; + Lwt.return_some mempool + | None -> ( + let* o = Lwt_stream.get op_stream in + match o with + | Some (kind, op) + when filter_result kind + && filter_validation_passes + params#validation_passes + op.protocol -> + let errors = + match kind with + | `Validated -> None + | `Branch_delayed errors + | `Branch_refused errors + | `Refused errors + | `Outdated errors -> + Some errors + in + Lwt.return_some [((op.hash, op.protocol), errors)] + | Some _ -> next () + | None -> Lwt.return_none) + in + let shutdown () = Lwt_watcher.shutdown stopper in + Tezos_rpc.Answer.return_stream {next; shutdown} + in dir := Tezos_rpc.Directory.gen_register !dir (Proto_services.S.Mempool.monitor_operations Tezos_rpc.Path.open_root) - (fun pv params () -> - Lwt_mutex.with_lock pv.lock @@ fun () -> - let op_stream, stopper = - Lwt_watcher.create_stream pv.operation_stream - in - (* First call : retrieve the current set of op from the mempool *) - let validated_seq = - if - params#validated && Option.value ~default:true params#applied - (* https://gitlab.com/tezos/tezos/-/issues/5891 - applied is deprecated and should be removed in a future - version of Octez *) - then - Classification.Sized_map.to_map - pv.shell.classification.validated - |> Operation_hash.Map.to_seq - |> Seq.map (fun (hash, {protocol; _}) -> - ((hash, protocol), None)) - else Seq.empty - in - let process_error_map map = - let open Operation_hash in - map |> Map.to_seq - |> Seq.map (fun (hash, (op, error)) -> - ((hash, op.protocol), Some error)) - in - let refused_seq = - if params#refused then - process_error_map - (Classification.map pv.shell.classification.refused) - else Seq.empty - in - let branch_refused_seq = - if params#branch_refused then - process_error_map - (Classification.map pv.shell.classification.branch_refused) - else Seq.empty - in - let branch_delayed_seq = - if params#branch_delayed then - process_error_map - (Classification.map pv.shell.classification.branch_delayed) - else Seq.empty - in - let outdated_seq = - if params#outdated then - process_error_map - (Classification.map pv.shell.classification.outdated) - else Seq.empty - in - let filter ((_, op), _) = - filter_validation_passes params#validation_passes op - in - let current_mempool = - Seq.append outdated_seq branch_delayed_seq - |> Seq.append branch_refused_seq - |> Seq.append refused_seq |> Seq.append validated_seq - |> Seq.filter filter |> List.of_seq - in - let current_mempool = ref (Some current_mempool) in - let filter_result = function - | `Validated -> - params#validated && Option.value ~default:true params#applied - | `Refused _ -> params#refused - | `Outdated _ -> params#outdated - | `Branch_refused _ -> params#branch_refused - | `Branch_delayed _ -> params#branch_delayed - in - let rec next () = - let open Lwt_syntax in - match !current_mempool with - | Some mempool -> - current_mempool := None ; - Lwt.return_some (params#version, mempool) - | None -> ( - let* o = Lwt_stream.get op_stream in - match o with - | Some (kind, op) - when filter_result kind - && filter_validation_passes - params#validation_passes - op.protocol -> - let errors = - match kind with - | `Validated -> None - | `Branch_delayed errors - | `Branch_refused errors - | `Refused errors - | `Outdated errors -> - Some errors - in - Lwt.return_some - (params#version, [((op.hash, op.protocol), errors)]) - | Some _ -> next () - | None -> Lwt.return_none) - in - let shutdown () = Lwt_watcher.shutdown stopper in - Tezos_rpc.Answer.return_stream {next; shutdown}) ; + monitor_operations ; + dir := + Tezos_rpc.Directory.gen_register + !dir + (Proto_services.S.Mempool.monitor_operations_v1 + Tezos_rpc.Path.open_root) + monitor_operations ; !dir) (** Module implementing the events at the {!Worker} level. Contrary diff --git a/src/lib_shell_services/block_services.ml b/src/lib_shell_services/block_services.ml index 0b347f311232..ea76257bb209 100644 --- a/src/lib_shell_services/block_services.ml +++ b/src/lib_shell_services/block_services.ml @@ -1404,13 +1404,10 @@ module Make (Proto : PROTO) (Next_proto : PROTO) = struct let default_monitoring_operations_version = Version_0 - let monitoring_operations_supported_versions = [Version_0; Version_1] - let mempool_query = let open Tezos_rpc.Query in query (fun - version applied validated refused @@ -1420,8 +1417,6 @@ module Make (Proto : PROTO) (Next_proto : PROTO) = struct validation_passes -> object - method version = version - method applied = applied method validated = validated @@ -1436,11 +1431,6 @@ module Make (Proto : PROTO) (Next_proto : PROTO) = struct method validation_passes = validation_passes end) - |+ field - "version" - (version_arg monitoring_operations_supported_versions) - default_monitoring_operations_version - (fun t -> t#version) |+ opt_field ~descr: "(DEPRECATED use validated instead) Include validated operations" @@ -1500,34 +1490,22 @@ module Make (Proto : PROTO) (Next_proto : PROTO) = struct else next_operation_encoding)) (obj1 (dft "error" Tezos_rpc.Error.opt_encoding None)) - let processed_operation_encoding = - union - [ - case - ~title:"monitor_operations_encoding" - (Tag 1) - (list (monitor_operations_encoding ~use_legacy_name:false)) - (function - | Version_1, monitor_operations -> Some monitor_operations - | Version_0, _ -> None) - (fun monitor_operations -> (Version_1, monitor_operations)); - case - ~title:"monitor_operations_encoding_with_legacy_attestation_name" - (Tag 0) - (list (monitor_operations_encoding ~use_legacy_name:true)) - (function - | Version_0, monitor_operations -> Some monitor_operations - | Version_1, _ -> None) - (fun monitor_operations -> (Version_0, monitor_operations)); - ] - let monitor_operations path = Tezos_rpc.Service.get_service - ~description:"Monitor the mempool operations." + ~description: + "(Deprecated, used `/monitor_operations/v1` instead) Monitor the \ + mempool operations." ~query:mempool_query - ~output:processed_operation_encoding + ~output:(list (monitor_operations_encoding ~use_legacy_name:true)) Tezos_rpc.Path.(path / "monitor_operations") + let monitor_operations_v1 path = + Tezos_rpc.Service.get_service + ~description:"Monitor the mempool operations." + ~query:mempool_query + ~output:(list (monitor_operations_encoding ~use_legacy_name:false)) + Tezos_rpc.Path.(path / "monitor_operations" / "v1") + let get_filter_query = let open Tezos_rpc.Query in query (fun include_default -> @@ -1915,36 +1893,33 @@ module Make (Proto : PROTO) (Next_proto : PROTO) = struct ?(validated = true) ?(branch_delayed = true) ?(branch_refused = false) ?(refused = false) ?(outdated = false) ?(validation_passes = []) () = let open Lwt_result_syntax in - let s = S.Mempool.monitor_operations (mempool_path chain_path) in - let* stream, stopper = - Tezos_rpc.Context.make_streamed_call - s - ctxt - ((), chain) - (object - method version = version - - method applied = None + let* s = + match version with + | Version_0 -> + return (S.Mempool.monitor_operations (mempool_path chain_path)) + | Version_1 -> + return (S.Mempool.monitor_operations_v1 (mempool_path chain_path)) + in + Tezos_rpc.Context.make_streamed_call + s + ctxt + ((), chain) + (object + method applied = None - method validated = validated + method validated = validated - method refused = refused + method refused = refused - method outdated = outdated + method outdated = outdated - method branch_refused = branch_refused + method branch_refused = branch_refused - method branch_delayed = branch_delayed + method branch_delayed = branch_delayed - method validation_passes = validation_passes - end) - () - in - return - ( Lwt_stream.map - (fun ((Version_0 | Version_1), operations) -> operations) - stream, - stopper ) + method validation_passes = validation_passes + end) + () let request_operations ctxt ?(chain = `Main) ?peer_id () = let s = S.Mempool.request_operations (mempool_path chain_path) in diff --git a/src/lib_shell_services/block_services.mli b/src/lib_shell_services/block_services.mli index 027067931384..265635fb1808 100644 --- a/src/lib_shell_services/block_services.mli +++ b/src/lib_shell_services/block_services.mli @@ -788,8 +788,25 @@ module Make (Proto : PROTO) (Next_proto : PROTO) : sig ( [`GET], 'a, 'b, - < version : version - ; applied : bool option + < applied : bool option + ; validated : bool + ; branch_delayed : bool + ; branch_refused : bool + ; refused : bool + ; outdated : bool + ; validation_passes : int list >, + unit, + ((Operation_hash.t * Next_proto.operation) * error trace option) list + ) + Tezos_rpc.Service.t + + (** Define RPC GET /chains/[chain]/mempool/monitor_operations/v1 *) + val monitor_operations_v1 : + ('a, 'b) Tezos_rpc.Path.t -> + ( [`GET], + 'a, + 'b, + < applied : bool option ; validated : bool ; branch_delayed : bool ; branch_refused : bool @@ -797,9 +814,8 @@ module Make (Proto : PROTO) (Next_proto : PROTO) : sig ; outdated : bool ; validation_passes : int list >, unit, - version - * ((Operation_hash.t * Next_proto.operation) * error trace option) - list ) + ((Operation_hash.t * Next_proto.operation) * error trace option) list + ) Tezos_rpc.Service.t (** Define RPC GET /chains/[chain]/mempool/filter *) diff --git a/src/proto_016_PtMumbai/lib_delegate/test/mockup_simulator/faked_services.ml b/src/proto_016_PtMumbai/lib_delegate/test/mockup_simulator/faked_services.ml index 5ec773845f1b..276562f75601 100644 --- a/src/proto_016_PtMumbai/lib_delegate/test/mockup_simulator/faked_services.ml +++ b/src/proto_016_PtMumbai/lib_delegate/test/mockup_simulator/faked_services.ml @@ -65,14 +65,11 @@ module type Mocked_services_hooks = sig endorsements. Invariant: the stream becomes empty when the node changes head. *) val monitor_operations : - version:Block_services.version -> validated:bool -> branch_delayed:bool -> branch_refused:bool -> refused:bool -> - (Block_services.version - * ((Operation_hash.t * Mockup.M.Protocol.operation) * error trace option) - list) + ((Operation_hash.t * Mockup.M.Protocol.operation) * error trace option) list Tezos_rpc.Answer.stream (** Lists block hashes from the chain, up to the last checkpoint, sorted @@ -286,7 +283,6 @@ module Make (Hooks : Mocked_services_hooks) = struct (fun ((), _chain) flags () -> let stream = Hooks.monitor_operations - ~version:flags#version ~validated:flags#validated ~branch_delayed:flags#branch_delayed ~branch_refused:flags#branch_refused diff --git a/src/proto_016_PtMumbai/lib_delegate/test/mockup_simulator/mockup_simulator.ml b/src/proto_016_PtMumbai/lib_delegate/test/mockup_simulator/mockup_simulator.ml index 3c023176b106..36c96b3b1c8e 100644 --- a/src/proto_016_PtMumbai/lib_delegate/test/mockup_simulator/mockup_simulator.ml +++ b/src/proto_016_PtMumbai/lib_delegate/test/mockup_simulator/mockup_simulator.ml @@ -475,8 +475,7 @@ let make_mocked_services_hooks (state : state) (user_hooks : (module Hooks)) : unprocessed = Operation_hash.Map.empty; } - let monitor_operations ~version ~validated ~branch_delayed ~branch_refused - ~refused = + let monitor_operations ~validated ~branch_delayed ~branch_refused ~refused = ignore validated ; ignore branch_delayed ; ignore branch_refused ; @@ -489,11 +488,11 @@ let make_mocked_services_hooks (state : state) (user_hooks : (module Hooks)) : | None when !streamed -> Lwt.return None | None -> streamed := true ; - Lwt.return_some (version, []) + Lwt.return_some [] | Some ops -> ( List.filter_map_s User_hooks.on_new_operation ops >>= function | [] -> loop () - | l -> Lwt.return_some (version, List.map (fun x -> (x, None)) l)) + | l -> Lwt.return_some (List.map (fun x -> (x, None)) l)) in loop () in diff --git a/src/proto_017_PtNairob/lib_delegate/test/mockup_simulator/faked_services.ml b/src/proto_017_PtNairob/lib_delegate/test/mockup_simulator/faked_services.ml index 95ccc458f26f..e878aaa41b4d 100644 --- a/src/proto_017_PtNairob/lib_delegate/test/mockup_simulator/faked_services.ml +++ b/src/proto_017_PtNairob/lib_delegate/test/mockup_simulator/faked_services.ml @@ -65,14 +65,11 @@ module type Mocked_services_hooks = sig endorsements. Invariant: the stream becomes empty when the node changes head. *) val monitor_operations : - version:Block_services.version -> validated:bool -> branch_delayed:bool -> branch_refused:bool -> refused:bool -> - (Block_services.version - * ((Operation_hash.t * Mockup.M.Protocol.operation) * error trace option) - list) + ((Operation_hash.t * Mockup.M.Protocol.operation) * error trace option) list Tezos_rpc.Answer.stream (** Lists block hashes from the chain, up to the last checkpoint, sorted @@ -275,7 +272,6 @@ module Make (Hooks : Mocked_services_hooks) = struct (fun ((), _chain) flags () -> let stream = Hooks.monitor_operations - ~version:flags#version ~validated:flags#validated ~branch_delayed:flags#branch_delayed ~branch_refused:flags#branch_refused diff --git a/src/proto_017_PtNairob/lib_delegate/test/mockup_simulator/mockup_simulator.ml b/src/proto_017_PtNairob/lib_delegate/test/mockup_simulator/mockup_simulator.ml index 5fb836f50f34..1805b57eead7 100644 --- a/src/proto_017_PtNairob/lib_delegate/test/mockup_simulator/mockup_simulator.ml +++ b/src/proto_017_PtNairob/lib_delegate/test/mockup_simulator/mockup_simulator.ml @@ -476,8 +476,7 @@ let make_mocked_services_hooks (state : state) (user_hooks : (module Hooks)) : unprocessed = Operation_hash.Map.empty; } - let monitor_operations ~version ~validated ~branch_delayed ~branch_refused - ~refused = + let monitor_operations ~validated ~branch_delayed ~branch_refused ~refused = ignore validated ; ignore branch_delayed ; ignore branch_refused ; @@ -490,11 +489,11 @@ let make_mocked_services_hooks (state : state) (user_hooks : (module Hooks)) : | None when !streamed -> Lwt.return None | None -> streamed := true ; - Lwt.return_some (version, []) + Lwt.return_some [] | Some ops -> ( List.filter_map_s User_hooks.on_new_operation ops >>= function | [] -> loop () - | l -> Lwt.return_some (version, List.map (fun x -> (x, None)) l)) + | l -> Lwt.return_some (List.map (fun x -> (x, None)) l)) in loop () in diff --git a/src/proto_018_Proxford/lib_delegate/test/mockup_simulator/faked_services.ml b/src/proto_018_Proxford/lib_delegate/test/mockup_simulator/faked_services.ml index 95ccc458f26f..e878aaa41b4d 100644 --- a/src/proto_018_Proxford/lib_delegate/test/mockup_simulator/faked_services.ml +++ b/src/proto_018_Proxford/lib_delegate/test/mockup_simulator/faked_services.ml @@ -65,14 +65,11 @@ module type Mocked_services_hooks = sig endorsements. Invariant: the stream becomes empty when the node changes head. *) val monitor_operations : - version:Block_services.version -> validated:bool -> branch_delayed:bool -> branch_refused:bool -> refused:bool -> - (Block_services.version - * ((Operation_hash.t * Mockup.M.Protocol.operation) * error trace option) - list) + ((Operation_hash.t * Mockup.M.Protocol.operation) * error trace option) list Tezos_rpc.Answer.stream (** Lists block hashes from the chain, up to the last checkpoint, sorted @@ -275,7 +272,6 @@ module Make (Hooks : Mocked_services_hooks) = struct (fun ((), _chain) flags () -> let stream = Hooks.monitor_operations - ~version:flags#version ~validated:flags#validated ~branch_delayed:flags#branch_delayed ~branch_refused:flags#branch_refused diff --git a/src/proto_018_Proxford/lib_delegate/test/mockup_simulator/mockup_simulator.ml b/src/proto_018_Proxford/lib_delegate/test/mockup_simulator/mockup_simulator.ml index 0fe62d4c5fef..af9bef7736f7 100644 --- a/src/proto_018_Proxford/lib_delegate/test/mockup_simulator/mockup_simulator.ml +++ b/src/proto_018_Proxford/lib_delegate/test/mockup_simulator/mockup_simulator.ml @@ -476,8 +476,7 @@ let make_mocked_services_hooks (state : state) (user_hooks : (module Hooks)) : unprocessed = Operation_hash.Map.empty; } - let monitor_operations ~version ~validated ~branch_delayed ~branch_refused - ~refused = + let monitor_operations ~validated ~branch_delayed ~branch_refused ~refused = ignore validated ; ignore branch_delayed ; ignore branch_refused ; @@ -490,11 +489,11 @@ let make_mocked_services_hooks (state : state) (user_hooks : (module Hooks)) : | None when !streamed -> Lwt.return None | None -> streamed := true ; - Lwt.return_some (version, []) + Lwt.return_some [] | Some ops -> ( List.filter_map_s User_hooks.on_new_operation ops >>= function | [] -> loop () - | l -> Lwt.return_some (version, List.map (fun x -> (x, None)) l)) + | l -> Lwt.return_some (List.map (fun x -> (x, None)) l)) in loop () in diff --git a/src/proto_alpha/lib_delegate/test/mockup_simulator/faked_services.ml b/src/proto_alpha/lib_delegate/test/mockup_simulator/faked_services.ml index 95ccc458f26f..e878aaa41b4d 100644 --- a/src/proto_alpha/lib_delegate/test/mockup_simulator/faked_services.ml +++ b/src/proto_alpha/lib_delegate/test/mockup_simulator/faked_services.ml @@ -65,14 +65,11 @@ module type Mocked_services_hooks = sig endorsements. Invariant: the stream becomes empty when the node changes head. *) val monitor_operations : - version:Block_services.version -> validated:bool -> branch_delayed:bool -> branch_refused:bool -> refused:bool -> - (Block_services.version - * ((Operation_hash.t * Mockup.M.Protocol.operation) * error trace option) - list) + ((Operation_hash.t * Mockup.M.Protocol.operation) * error trace option) list Tezos_rpc.Answer.stream (** Lists block hashes from the chain, up to the last checkpoint, sorted @@ -275,7 +272,6 @@ module Make (Hooks : Mocked_services_hooks) = struct (fun ((), _chain) flags () -> let stream = Hooks.monitor_operations - ~version:flags#version ~validated:flags#validated ~branch_delayed:flags#branch_delayed ~branch_refused:flags#branch_refused diff --git a/src/proto_alpha/lib_delegate/test/mockup_simulator/mockup_simulator.ml b/src/proto_alpha/lib_delegate/test/mockup_simulator/mockup_simulator.ml index 3b4acac0c286..1e5819a97d12 100644 --- a/src/proto_alpha/lib_delegate/test/mockup_simulator/mockup_simulator.ml +++ b/src/proto_alpha/lib_delegate/test/mockup_simulator/mockup_simulator.ml @@ -476,8 +476,7 @@ let make_mocked_services_hooks (state : state) (user_hooks : (module Hooks)) : unprocessed = Operation_hash.Map.empty; } - let monitor_operations ~version ~validated ~branch_delayed ~branch_refused - ~refused = + let monitor_operations ~validated ~branch_delayed ~branch_refused ~refused = ignore validated ; ignore branch_delayed ; ignore branch_refused ; @@ -490,11 +489,11 @@ let make_mocked_services_hooks (state : state) (user_hooks : (module Hooks)) : | None when !streamed -> Lwt.return None | None -> streamed := true ; - Lwt.return_some (version, []) + Lwt.return_some [] | Some ops -> ( List.filter_map_s User_hooks.on_new_operation ops >>= function | [] -> loop () - | l -> Lwt.return_some (version, List.map (fun x -> (x, None)) l)) + | l -> Lwt.return_some (List.map (fun x -> (x, None)) l)) in loop () in -- GitLab From 252852c56ccc390fbdb353cfb15a0b20709211ca Mon Sep 17 00:00:00 2001 From: Albin Coquereau Date: Wed, 5 Jul 2023 09:52:51 +0200 Subject: [PATCH 09/19] tezt/lib_tezos: adapt monitor_operations path according to version --- tezt/lib_tezos/RPC.ml | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/tezt/lib_tezos/RPC.ml b/tezt/lib_tezos/RPC.ml index 639565b1cc95..5b6a82208621 100644 --- a/tezt/lib_tezos/RPC.ml +++ b/tezt/lib_tezos/RPC.ml @@ -473,8 +473,7 @@ let get_chain_mempool_pending_operations ?(chain = "main") ?version ?validated let get_chain_mempool_monitor_operations ?(chain = "main") ?version ?validated ?branch_delayed ?branch_refused ?refused ?outdated ?validation_passes () = let query_string = - Query_arg.opt "version" Fun.id version - @ Query_arg.opt_bool "validated" validated + Query_arg.opt_bool "validated" validated @ Query_arg.opt_bool "refused" refused @ Query_arg.opt_bool "outdated" outdated @ Query_arg.opt_bool "branch_delayed" branch_delayed @@ -484,11 +483,10 @@ let get_chain_mempool_monitor_operations ?(chain = "main") ?version ?validated (fun name vp -> (name, string_of_int vp)) validation_passes in - make - ~query_string - GET - ["chains"; chain; "mempool"; "monitor_operations"] - Fun.id + let path = ["chains"; chain; "mempool"; "monitor_operations"] in + let default = "0" in + let path = rpc_version ~default ~path version in + make ~query_string GET path Fun.id let post_chain_mempool_request_operations ?(chain = "main") ?peer () = make -- GitLab From 214e628599ba9d39371e0913f4b6ec067849e1af Mon Sep 17 00:00:00 2001 From: Albin Coquereau Date: Wed, 5 Jul 2023 10:06:33 +0200 Subject: [PATCH 10/19] tezt/tests: adapt monitor_operation rpc tests --- tezt/tests/rpc_versioning_attestation.ml | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/tezt/tests/rpc_versioning_attestation.ml b/tezt/tests/rpc_versioning_attestation.ml index 14ff04489b17..87458757e89b 100644 --- a/tezt/tests/rpc_versioning_attestation.ml +++ b/tezt/tests/rpc_versioning_attestation.ml @@ -604,22 +604,13 @@ module Mempool = struct |> Uri.to_string) in let*? p = RPC.Curl.get monitor_operations_url in - let* s = Process.check_and_read_stdout p in - try - let _ = - Str.( - search_forward - (regexp - "Failed to parse the query string: Failed to parse argument \ - \'version\'")) - s - 0 - in - unit - with Not_found -> + let* out, err = Process.check_and_read_both p in + if (not String.(equal empty out)) || not String.(equal empty err) then Test.fail ~__LOC__ - {|RPC call should have return: Failed to parse the query string: Failed to parse argument \'version\' ..|} + "The call of monitor_operations with an invalid version should have \ + succeed without returning anything on both output" + else unit let test_monitor_operations_consensus kind protocol = let* node, client = Client.init_with_protocol ~protocol `Client () in -- GitLab From 0a106fe1e5f6d2fd0c259cdc56371696349f3ae5 Mon Sep 17 00:00:00 2001 From: Albin Coquereau Date: Wed, 5 Jul 2023 21:34:19 +0200 Subject: [PATCH 11/19] changes: update monitor_operations RPC entry --- CHANGES.rst | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 5dae4bb4f6f4..5acaeab4fef6 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -144,11 +144,11 @@ Node the "reverting its effect if it was applied" part since operations are never applied.) (MR :gl:`!8857`) -- Added version ``1`` to RPC ``GET ../mempool/monitor_operations``. It can be - used by calling the RPC with the parameter ``?version=1`` (default version is - still ``0``). Version ``1`` allows the RPC to output ``attestation``, - ``preattestation``, ``double_attestation_evidence`` and - ``double_preattestation_evidence`` kinds in the JSON result. (MR :gl:`!8980`) +- Introduced a version ``v1`` to RPC ``GET ../mempool/monitor_operations``. It + can be used by calling ``GET ../mempool/monitor_operations/v1``. This version + allows the RPC to output ``attestation``, ``preattestation``, + ``double_attestation_evidence`` and ``double_preattestation_evidence`` kinds + in the JSON result. (MR :gl:`!8980`, :gl:`!9410`) - Improved the performances of JSON RPC calls by optimizing the serialization to JSON. (MR :gl:`!9072`) -- GitLab From 82e01ee1ad9017e8d46cfb9eb01a91e4679cd923 Mon Sep 17 00:00:00 2001 From: Albin Coquereau Date: Wed, 5 Jul 2023 14:52:05 +0200 Subject: [PATCH 12/19] lib_shell: introduce `//v1`and `//v1/operations/` RPCs --- src/lib_mockup/local_services.ml | 4 +- src/lib_shell/block_directory.ml | 425 +++++++++--------- src/lib_shell_services/block_services.ml | 236 +++++----- src/lib_shell_services/block_services.mli | 63 ++- .../test/mockup_simulator/faked_services.ml | 5 +- .../test/mockup_simulator/faked_services.ml | 5 +- .../test/mockup_simulator/faked_services.ml | 5 +- .../test/mockup_simulator/faked_services.ml | 5 +- 8 files changed, 364 insertions(+), 384 deletions(-) diff --git a/src/lib_mockup/local_services.ml b/src/lib_mockup/local_services.ml index 3d38467ba1c9..7f66009d0497 100644 --- a/src/lib_mockup/local_services.ml +++ b/src/lib_mockup/local_services.ml @@ -951,10 +951,10 @@ module Make (E : MENV) = struct @@ Directory.register Directory.empty E.Block_services.S.Operations.operations - (fun (((), chain), _block) query () -> + (fun (((), chain), _block) _query () -> with_chain ~caller_name:"operations" chain (fun () -> (* FIXME: Better answer here *) - Tezos_rpc.Answer.return (query#version, [[]; []; []; []]))) + Tezos_rpc.Answer.return [[]; []; []; []])) let monitor_operations () = let open Lwt_syntax in diff --git a/src/lib_shell/block_directory.ml b/src/lib_shell/block_directory.ml index 47be17da83ce..3d35d55922b0 100644 --- a/src/lib_shell/block_directory.ml +++ b/src/lib_shell/block_directory.ml @@ -339,182 +339,167 @@ let build_raw_rpc_directory (module Proto : Block_services.PROTO) return ops_metadata in (*****************************************************************) - register0 S.Operations.operations (fun (chain_store, block) q () -> - let with_metadata = - with_metadata ~force_metadata:q#force_metadata ~metadata:q#metadata - in - let* operations = + let register_operations (chain_store, block) q () = + let with_metadata = + with_metadata ~force_metadata:q#force_metadata ~metadata:q#metadata + in + match with_metadata with + | Some `Always -> ( + let chain_id = Store.Chain.chain_id chain_store in + let ops = Store.Block.operations block in + let* metadata = Store.Block.get_block_metadata chain_store block in + let ops_metadata = metadata.operations_metadata in + let* ops_metadata = + (* Iter through the operations metadata to check if some are + considered as too large. *) + if + List.exists + (fun v -> + List.exists (fun v -> v = Block_validation.Too_large_metadata) v) + ops_metadata + then + (* The metadatas are stored but contains some too large + metadata, we need te recompute them *) + force_operation_metadata chain_id chain_store block + else return ops_metadata + in + List.map2_e + ~when_different_lengths:() + (List.map2 + ~when_different_lengths:() + (convert_with_metadata chain_id)) + ops + ops_metadata + |> function + | Ok v -> return v + | Error () -> fail_with_exn Not_found) + | Some `Never -> operations_without_metadata chain_store block + | None -> operations chain_store block + in + register0 S.Operations.operations register_operations ; + register0 S.Operations.operations_v1 register_operations ; + let register_operations_in_pass (chain_store, block) i q () = + let chain_id = Store.Chain.chain_id chain_store in + Lwt.catch + (fun () -> + let with_metadata = + with_metadata ~force_metadata:q#force_metadata ~metadata:q#metadata + in match with_metadata with | Some `Always -> ( - let chain_id = Store.Chain.chain_id chain_store in - let ops = Store.Block.operations block in - let* metadata = Store.Block.get_block_metadata chain_store block in - let ops_metadata = metadata.operations_metadata in - let* ops_metadata = - (* Iter through the operations metadata to check if some are - considered as too large. *) - if - List.exists - (fun v -> + let*! o = Store.Block.get_block_metadata_opt chain_store block in + let ops = fst @@ Store.Block.operations_path block i in + match o with + | None -> return (List.map (convert_without_metadata chain_id) ops) + | Some metadata -> ( + let opss_metadata = Store.Block.operations_metadata metadata in + let ops_metadata = + List.nth opss_metadata i + |> WithExceptions.Option.to_exn ~none:Not_found + in + let* ops_metadata = + (* Iter through the operations metadata of the + requested pass to check if some are considered as + too large. *) + if List.exists (fun v -> v = Block_validation.Too_large_metadata) - v) - ops_metadata - then - (* The metadatas are stored but contains some too large - metadata, we need te recompute them *) - force_operation_metadata chain_id chain_store block - else return ops_metadata - in - List.map2_e - ~when_different_lengths:() - (List.map2 - ~when_different_lengths:() - (convert_with_metadata chain_id)) - ops - ops_metadata - |> function - | Ok v -> return v - | Error () -> fail_with_exn Not_found) - | Some `Never -> operations_without_metadata chain_store block - | None -> operations chain_store block - in - return (q#version, operations)) ; - register1 S.Operations.operations_in_pass (fun (chain_store, block) i q () -> - let chain_id = Store.Chain.chain_id chain_store in - Lwt.catch - (fun () -> - let with_metadata = - with_metadata ~force_metadata:q#force_metadata ~metadata:q#metadata - in - let* operations = - match with_metadata with - | Some `Always -> ( - let*! o = - Store.Block.get_block_metadata_opt chain_store block - in - let ops = fst @@ Store.Block.operations_path block i in - match o with - | None -> - return (List.map (convert_without_metadata chain_id) ops) - | Some metadata -> ( - let opss_metadata = - Store.Block.operations_metadata metadata + ops_metadata + then + let* opss_metadata = + force_operation_metadata chain_id chain_store block in let ops_metadata = - List.nth opss_metadata i + List.nth_opt opss_metadata i |> WithExceptions.Option.to_exn ~none:Not_found in - let* ops_metadata = - (* Iter through the operations metadata of the - requested pass to check if some are considered as - too large. *) - if - List.exists - (fun v -> v = Block_validation.Too_large_metadata) - ops_metadata - then - let* opss_metadata = - force_operation_metadata chain_id chain_store block - in - let ops_metadata = - List.nth_opt opss_metadata i - |> WithExceptions.Option.to_exn ~none:Not_found - in - return ops_metadata - else return ops_metadata - in - List.map2 - ~when_different_lengths:() - (convert_with_metadata chain_id) - ops - ops_metadata - |> function - | Ok x -> return x - | _ -> fail_with_exn Not_found)) - | Some `Never -> - let* ops = operations_without_metadata chain_store block in - return - (List.nth ops i - |> WithExceptions.Option.to_exn ~none:Not_found) - | None -> - let* ops = operations chain_store block in - return - (List.nth ops i - |> WithExceptions.Option.to_exn ~none:Not_found) - in - return (q#version, operations)) - (fun _ -> fail_with_exn Not_found)) ; - register2 S.Operations.operation (fun (chain_store, block) i j q () -> - let chain_id = Store.Chain.chain_id chain_store in - Lwt.catch - (fun () -> - let ops = fst @@ Store.Block.operations_path block i in - let op = - List.nth ops j |> WithExceptions.Option.to_exn ~none:Not_found - in - let with_metadata = - with_metadata ~force_metadata:q#force_metadata ~metadata:q#metadata - in - let* operation = - match with_metadata with - | Some `Always -> ( - let*! o = - Store.Block.get_block_metadata_opt chain_store block + return ops_metadata + else return ops_metadata in - match o with - | None -> return (convert_without_metadata chain_id op) - | Some metadata -> ( - let opss_metadata = - Store.Block.operations_metadata metadata + List.map2 + ~when_different_lengths:() + (convert_with_metadata chain_id) + ops + ops_metadata + |> function + | Ok x -> return x + | _ -> fail_with_exn Not_found)) + | Some `Never -> + let* ops = operations_without_metadata chain_store block in + return + (List.nth ops i |> WithExceptions.Option.to_exn ~none:Not_found) + | None -> + let* ops = operations chain_store block in + return + (List.nth ops i |> WithExceptions.Option.to_exn ~none:Not_found)) + (fun _ -> fail_with_exn Not_found) + in + register1 S.Operations.operations_in_pass register_operations_in_pass ; + register1 S.Operations.operations_in_pass_v1 register_operations_in_pass ; + let register_operation (chain_store, block) i j q () = + let chain_id = Store.Chain.chain_id chain_store in + Lwt.catch + (fun () -> + let ops = fst @@ Store.Block.operations_path block i in + let op = + List.nth ops j |> WithExceptions.Option.to_exn ~none:Not_found + in + let with_metadata = + with_metadata ~force_metadata:q#force_metadata ~metadata:q#metadata + in + match with_metadata with + | Some `Always -> ( + let*! o = Store.Block.get_block_metadata_opt chain_store block in + match o with + | None -> return (convert_without_metadata chain_id op) + | Some metadata -> ( + let opss_metadata = Store.Block.operations_metadata metadata in + let ops_metadata = + List.nth opss_metadata i + |> WithExceptions.Option.to_exn ~none:Not_found + in + let op_metadata = + List.nth ops_metadata j + |> WithExceptions.Option.to_exn ~none:Not_found + in + match op_metadata with + | Block_validation.Too_large_metadata -> + let* opss_metadata = + force_operation_metadata chain_id chain_store block in let ops_metadata = - List.nth opss_metadata i + List.nth_opt opss_metadata i |> WithExceptions.Option.to_exn ~none:Not_found in let op_metadata = List.nth ops_metadata j |> WithExceptions.Option.to_exn ~none:Not_found in - match op_metadata with - | Block_validation.Too_large_metadata -> - let* opss_metadata = - force_operation_metadata chain_id chain_store block - in - let ops_metadata = - List.nth_opt opss_metadata i - |> WithExceptions.Option.to_exn ~none:Not_found - in - let op_metadata = - List.nth ops_metadata j - |> WithExceptions.Option.to_exn ~none:Not_found - in - return ((convert_with_metadata chain_id) op op_metadata) - | Metadata _ -> - return (convert_with_metadata chain_id op op_metadata))) - | Some `Never -> - let* opss = operations_without_metadata chain_store block in - let ops = - List.nth opss i - |> WithExceptions.Option.to_exn ~none:Not_found - in - let op = - List.nth ops j |> WithExceptions.Option.to_exn ~none:Not_found - in - return op - | None -> - let* opss = operations chain_store block in - let ops = - List.nth opss i - |> WithExceptions.Option.to_exn ~none:Not_found - in - let op = - List.nth ops j |> WithExceptions.Option.to_exn ~none:Not_found - in - return op - in - return (q#version, operation)) - (fun _ -> fail_with_exn Not_found)) ; + return ((convert_with_metadata chain_id) op op_metadata) + | Metadata _ -> + return (convert_with_metadata chain_id op op_metadata))) + | Some `Never -> + let* opss = operations_without_metadata chain_store block in + let ops = + List.nth opss i |> WithExceptions.Option.to_exn ~none:Not_found + in + let op = + List.nth ops j |> WithExceptions.Option.to_exn ~none:Not_found + in + return op + | None -> + let* opss = operations chain_store block in + let ops = + List.nth opss i |> WithExceptions.Option.to_exn ~none:Not_found + in + let op = + List.nth ops j |> WithExceptions.Option.to_exn ~none:Not_found + in + return op) + (fun _ -> fail_with_exn Not_found) + in + register2 S.Operations.operation register_operation ; + register2 S.Operations.operation_v1 register_operation ; (* operation_hashes *) register0 S.Operation_hashes.operation_hashes (fun (_, block) () () -> return (Store.Block.all_operation_hashes block)) ; @@ -596,67 +581,69 @@ let build_raw_rpc_directory (module Proto : Block_services.PROTO) let*! v = Context_ops.merkle_tree_v2 context leaf_kind path in return_some v) ; (* info *) - register0 S.info (fun (chain_store, block) q () -> - let chain_id = Store.Chain.chain_id chain_store in - let hash = Store.Block.hash block in - let header = Store.Block.header block in - let shell = header.shell in - let protocol_data = - Data_encoding.Binary.of_bytes_exn - Proto.block_header_data_encoding - header.protocol_data - in - let* metadata = - let*! metadata = block_metadata chain_store block in - return (Option.of_result metadata) - in - let* operations = - let with_metadata = - with_metadata ~force_metadata:q#force_metadata ~metadata:q#metadata - in - match with_metadata with - | Some `Always -> ( - let ops = Store.Block.operations block in - let* metadata = Store.Block.get_block_metadata chain_store block in - let ops_metadata = metadata.operations_metadata in - let* ops_metadata = - (* Iter through the operations metadata to check if some are - considered as too large. *) - if - List.exists - (fun v -> - List.exists - (fun v -> v = Block_validation.Too_large_metadata) - v) - ops_metadata - then - (* The metadatas are stored but contains some too large - metadata, we need te recompute them *) - force_operation_metadata chain_id chain_store block - else return ops_metadata - in - List.map2_e - ~when_different_lengths:() - (List.map2 - ~when_different_lengths:() - (convert_with_metadata chain_id)) - ops - ops_metadata - |> function - | Ok v -> return v - | Error () -> fail_with_exn Not_found) - | Some `Never -> operations_without_metadata chain_store block - | None -> operations chain_store block + let info (chain_store, block) q () = + let chain_id = Store.Chain.chain_id chain_store in + let hash = Store.Block.hash block in + let header = Store.Block.header block in + let shell = header.shell in + let protocol_data = + Data_encoding.Binary.of_bytes_exn + Proto.block_header_data_encoding + header.protocol_data + in + let* metadata = + let*! metadata = block_metadata chain_store block in + return (Option.of_result metadata) + in + let* operations = + let with_metadata = + with_metadata ~force_metadata:q#force_metadata ~metadata:q#metadata in - return - ( q#version, - { - Block_services.hash; - chain_id; - header = {shell; protocol_data}; - metadata; - operations; - } )) ; + match with_metadata with + | Some `Always -> ( + let ops = Store.Block.operations block in + let* metadata = Store.Block.get_block_metadata chain_store block in + let ops_metadata = metadata.operations_metadata in + let* ops_metadata = + (* Iter through the operations metadata to check if some are + considered as too large. *) + if + List.exists + (fun v -> + List.exists + (fun v -> v = Block_validation.Too_large_metadata) + v) + ops_metadata + then + (* The metadatas are stored but contains some too large + metadata, we need te recompute them *) + force_operation_metadata chain_id chain_store block + else return ops_metadata + in + List.map2_e + ~when_different_lengths:() + (List.map2 + ~when_different_lengths:() + (convert_with_metadata chain_id)) + ops + ops_metadata + |> function + | Ok v -> return v + | Error () -> fail_with_exn Not_found) + | Some `Never -> operations_without_metadata chain_store block + | None -> operations chain_store block + in + return + { + Block_services.hash; + chain_id; + header = {shell; protocol_data}; + metadata; + operations; + } + in + register0 S.info info ; + register0 S.info_v1 info ; (* helpers *) register0 S.Helpers.Preapply.block (fun (chain_store, block) q p -> let timestamp = diff --git a/src/lib_shell_services/block_services.ml b/src/lib_shell_services/block_services.ml index ea76257bb209..59de076d9679 100644 --- a/src/lib_shell_services/block_services.ml +++ b/src/lib_shell_services/block_services.ml @@ -633,28 +633,6 @@ module Make (Proto : PROTO) (Next_proto : PROTO) = struct operations : operation list list; } - let encoding_versioning ~encoding_name ~old_encoding ~new_encoding = - union - [ - case - ~title:(Format.sprintf "%s_encoding" encoding_name) - (Tag 1) - new_encoding - (function - | Version_1, operations -> Some operations | Version_0, _ -> None) - (fun operations -> (Version_1, operations)); - case - ~title: - (Format.sprintf - "%s_encoding_with_legacy_attestation_name" - encoding_name) - (Tag 0) - old_encoding - (function - | Version_0, operations -> Some operations | Version_1, _ -> None) - (fun operations -> (Version_0, operations)); - ] - let block_info_encoding ~use_legacy_attestation_name = let operation_encoding = if use_legacy_attestation_name then @@ -674,12 +652,6 @@ module Make (Proto : PROTO) (Next_proto : PROTO) = struct (opt "metadata" (dynamic_size block_metadata_encoding)) (req "operations" (list (dynamic_size (list operation_encoding))))) - let block_info_encoding = - encoding_versioning - ~encoding_name:"block_info" - ~old_encoding:(block_info_encoding ~use_legacy_attestation_name:true) - ~new_encoding:(block_info_encoding ~use_legacy_attestation_name:false) - module S = struct let path : prefix Tezos_rpc.Path.context = Tezos_rpc.Path.open_root @@ -768,23 +740,14 @@ module Make (Proto : PROTO) (Next_proto : PROTO) = struct let default_operation_version = Version_0 - let operations_supported_versions = [Version_0; Version_1] - let force_operation_metadata_query = let open Tezos_rpc.Query in - query (fun version force_metadata metadata -> + query (fun force_metadata metadata -> object - method version = version - method force_metadata = force_metadata method metadata = metadata end) - |+ field - "version" - (version_arg operations_supported_versions) - default_operation_version - (fun t -> t#version) |+ flag "force_metadata" ~descr: @@ -804,24 +767,29 @@ module Make (Proto : PROTO) (Next_proto : PROTO) = struct |> seal module Operations = struct + let path_v1 = Tezos_rpc.Path.(path / "v1" / "operations") + let path = Tezos_rpc.Path.(path / "operations") let operations = - let output = - encoding_versioning - ~encoding_name:"operations" - ~old_encoding: - (list - (dynamic_size - (list operation_encoding_with_legacy_attestation_name))) - ~new_encoding:(list (dynamic_size (list operation_encoding))) - in Tezos_rpc.Service.get_service - ~description:"All the operations included in the block." + ~description: + "(Deprecated, used `/operations/v1` instead) All the operations \ + included in the block." ~query:force_operation_metadata_query - ~output + ~output: + (list + (dynamic_size + (list operation_encoding_with_legacy_attestation_name))) path + let operations_v1 = + Tezos_rpc.Service.get_service + ~description:"All the operations included in the block." + ~query:force_operation_metadata_query + ~output:(list (dynamic_size (list operation_encoding))) + path_v1 + let list_arg = let name = "list_offset" in let descr = "Index `n` of the requested validation pass." in @@ -845,33 +813,39 @@ module Make (Proto : PROTO) (Next_proto : PROTO) = struct Tezos_rpc.Arg.make ~name ~descr ~construct ~destruct () let operations_in_pass = - let output = - encoding_versioning - ~encoding_name:"operations_in_pass" - ~old_encoding:(list operation_encoding_with_legacy_attestation_name) - ~new_encoding:(list operation_encoding) - in + Tezos_rpc.Service.get_service + ~description: + "(Deprecated, used `/operations/v1` instead) All the operations \ + included in `n-th` validation pass of the block." + ~query:force_operation_metadata_query + ~output:(list operation_encoding_with_legacy_attestation_name) + Tezos_rpc.Path.(path /: list_arg) + + let operations_in_pass_v1 = Tezos_rpc.Service.get_service ~description: "All the operations included in `n-th` validation pass of the \ block." ~query:force_operation_metadata_query - ~output - Tezos_rpc.Path.(path /: list_arg) + ~output:(list operation_encoding) + Tezos_rpc.Path.(path_v1 /: list_arg) let operation = - let output = - encoding_versioning - ~encoding_name:"operation" - ~old_encoding:operation_encoding_with_legacy_attestation_name - ~new_encoding:operation_encoding - in Tezos_rpc.Service.get_service ~description: - "The `m-th` operation in the `n-th` validation pass of the block." + "(Deprecated, used `/operations/v1` instead) The `m-th` operation \ + in the `n-th` validation pass of the block." ~query:force_operation_metadata_query - ~output + ~output:operation_encoding_with_legacy_attestation_name Tezos_rpc.Path.(path /: list_arg /: offset_arg) + + let operation_v1 = + Tezos_rpc.Service.get_service + ~description: + "The `m-th` operation in the `n-th` validation pass of the block." + ~query:force_operation_metadata_query + ~output:operation_encoding + Tezos_rpc.Path.(path_v1 /: list_arg /: offset_arg) end module Operation_hashes = struct @@ -1171,14 +1145,24 @@ module Make (Proto : PROTO) (Next_proto : PROTO) = struct end let info = + Tezos_rpc.Service.get_service + ~description: + "(Deprecated, used `/blocks//v1` instead) All the information \ + about a block. The associated metadata may not be present depending \ + on the history mode and block's distance from the head." + ~query:force_operation_metadata_query + ~output:(block_info_encoding ~use_legacy_attestation_name:true) + path + + let info_v1 = Tezos_rpc.Service.get_service ~description: "All the information about a block. The associated metadata may not \ be present depending on the history mode and block's distance from \ the head." ~query:force_operation_metadata_query - ~output:block_info_encoding - path + ~output:(block_info_encoding ~use_legacy_attestation_name:false) + Tezos_rpc.Path.(path / "v1") module Mempool = struct type t = { @@ -1632,66 +1616,60 @@ module Make (Proto : PROTO) (Next_proto : PROTO) = struct module Operations = struct let operations ctxt ?(version = S.default_operation_version) ?(force_metadata = false) ?metadata = - let open Lwt_result_syntax in - let f = make_call0 S.Operations.operations ctxt in + let f = + match version with + | Version_0 -> make_call0 S.Operations.operations ctxt + | Version_1 -> make_call0 S.Operations.operations_v1 ctxt + in fun ?(chain = `Main) ?(block = `Head 0) () -> - let* (Version_0 | Version_1), operations = - f - chain - block - (object - method version = version - - method force_metadata = force_metadata + f + chain + block + (object + method force_metadata = force_metadata - method metadata = metadata - end) - () - in - return operations + method metadata = metadata + end) + () let operations_in_pass ctxt ?(version = S.default_operation_version) ?(force_metadata = false) ?metadata = - let open Lwt_result_syntax in - let f = make_call1 S.Operations.operations_in_pass ctxt in + let f = + match version with + | Version_0 -> make_call1 S.Operations.operations_in_pass ctxt + | Version_1 -> make_call1 S.Operations.operations_in_pass_v1 ctxt + in fun ?(chain = `Main) ?(block = `Head 0) n -> - let* (Version_0 | Version_1), operations = - f - chain - block - n - (object - method version = version - - method force_metadata = force_metadata + f + chain + block + n + (object + method force_metadata = force_metadata - method metadata = metadata - end) - () - in - return operations + method metadata = metadata + end) + () let operation ctxt ?(version = S.default_operation_version) ?(force_metadata = false) ?metadata = - let open Lwt_result_syntax in - let f = make_call2 S.Operations.operation ctxt in + let f = + match version with + | Version_0 -> make_call2 S.Operations.operation ctxt + | Version_1 -> make_call2 S.Operations.operation_v1 ctxt + in fun ?(chain = `Main) ?(block = `Head 0) n m -> - let* (Version_0 | Version_1), operation = - f - chain - block - n - m - (object - method version = version - - method force_metadata = force_metadata + f + chain + block + n + m + (object + method force_metadata = force_metadata - method metadata = metadata - end) - () - in - return operation + method metadata = metadata + end) + () end module Operation_hashes = struct @@ -1815,23 +1793,21 @@ module Make (Proto : PROTO) (Next_proto : PROTO) = struct let info ctxt ?(version = S.default_operation_version) ?(force_metadata = false) ?metadata = - let open Lwt_result_syntax in - let f = make_call0 S.info ctxt in + let f = + match version with + | Version_0 -> make_call0 S.info ctxt + | Version_1 -> make_call0 S.info_v1 ctxt + in fun ?(chain = `Main) ?(block = `Head 0) () -> - let* (Version_0 | Version_1), infos = - f - chain - block - (object - method version = version - - method force_metadata = force_metadata + f + chain + block + (object + method force_metadata = force_metadata - method metadata = metadata - end) - () - in - return infos + method metadata = metadata + end) + () module Mempool = struct type t = S.Mempool.t = { diff --git a/src/lib_shell_services/block_services.mli b/src/lib_shell_services/block_services.mli index 265635fb1808..142fb4ff353a 100644 --- a/src/lib_shell_services/block_services.mli +++ b/src/lib_shell_services/block_services.mli @@ -186,7 +186,8 @@ module Make (Proto : PROTO) (Next_proto : PROTO) : sig operations : operation list list; } - val block_info_encoding : (version * block_info) Data_encoding.t + val block_info_encoding : + use_legacy_attestation_name:bool -> block_info Data_encoding.t open Tezos_rpc.Context @@ -498,11 +499,18 @@ module Make (Proto : PROTO) (Next_proto : PROTO) : sig ( [`GET], prefix, prefix, - < version : version - ; force_metadata : bool - ; metadata : [`Always | `Never] option >, + < force_metadata : bool ; metadata : [`Always | `Never] option >, unit, - version * block_info ) + block_info ) + Tezos_rpc.Service.t + + val info_v1 : + ( [`GET], + prefix, + prefix, + < force_metadata : bool ; metadata : [`Always | `Never] option >, + unit, + block_info ) Tezos_rpc.Service.t val header : @@ -557,33 +565,54 @@ module Make (Proto : PROTO) (Next_proto : PROTO) : sig ( [`GET], prefix, prefix, - < version : version - ; force_metadata : bool - ; metadata : [`Always | `Never] option >, + < force_metadata : bool ; metadata : [`Always | `Never] option >, + unit, + operation list list ) + Tezos_rpc.Service.t + + val operations_v1 : + ( [`GET], + prefix, + prefix, + < force_metadata : bool ; metadata : [`Always | `Never] option >, unit, - version * operation list list ) + operation list list ) Tezos_rpc.Service.t val operations_in_pass : ( [`GET], prefix, prefix * int, - < version : version - ; force_metadata : bool - ; metadata : [`Always | `Never] option >, + < force_metadata : bool ; metadata : [`Always | `Never] option >, unit, - version * operation list ) + operation list ) + Tezos_rpc.Service.t + + val operations_in_pass_v1 : + ( [`GET], + prefix, + prefix * int, + < force_metadata : bool ; metadata : [`Always | `Never] option >, + unit, + operation list ) Tezos_rpc.Service.t val operation : ( [`GET], prefix, (prefix * int) * int, - < version : version - ; force_metadata : bool - ; metadata : [`Always | `Never] option >, + < force_metadata : bool ; metadata : [`Always | `Never] option >, + unit, + operation ) + Tezos_rpc.Service.t + + val operation_v1 : + ( [`GET], + prefix, + (prefix * int) * int, + < force_metadata : bool ; metadata : [`Always | `Never] option >, unit, - version * operation ) + operation ) Tezos_rpc.Service.t end diff --git a/src/proto_016_PtMumbai/lib_delegate/test/mockup_simulator/faked_services.ml b/src/proto_016_PtMumbai/lib_delegate/test/mockup_simulator/faked_services.ml index 276562f75601..48aa08f6a6bc 100644 --- a/src/proto_016_PtMumbai/lib_delegate/test/mockup_simulator/faked_services.ml +++ b/src/proto_016_PtMumbai/lib_delegate/test/mockup_simulator/faked_services.ml @@ -185,10 +185,7 @@ module Make (Hooks : Mocked_services_hooks) = struct @@ Directory.register Directory.empty Mockup.M.Block_services.S.Operations.operations - (fun (((), _chain), block) q () -> - let open Lwt_result_syntax in - let* ops = Hooks.operations block in - return (q#version, ops)) + (fun (((), _chain), block) _q () -> Hooks.operations block) let hash = Directory.prefix diff --git a/src/proto_017_PtNairob/lib_delegate/test/mockup_simulator/faked_services.ml b/src/proto_017_PtNairob/lib_delegate/test/mockup_simulator/faked_services.ml index e878aaa41b4d..1808b71eb7d6 100644 --- a/src/proto_017_PtNairob/lib_delegate/test/mockup_simulator/faked_services.ml +++ b/src/proto_017_PtNairob/lib_delegate/test/mockup_simulator/faked_services.ml @@ -185,10 +185,7 @@ module Make (Hooks : Mocked_services_hooks) = struct @@ Directory.register Directory.empty Mockup.M.Block_services.S.Operations.operations - (fun (((), _chain), block) q () -> - let open Lwt_result_syntax in - let* ops = Hooks.operations block in - return (q#version, ops)) + (fun (((), _chain), block) _q () -> Hooks.operations block) let hash = Directory.prefix diff --git a/src/proto_018_Proxford/lib_delegate/test/mockup_simulator/faked_services.ml b/src/proto_018_Proxford/lib_delegate/test/mockup_simulator/faked_services.ml index e878aaa41b4d..1808b71eb7d6 100644 --- a/src/proto_018_Proxford/lib_delegate/test/mockup_simulator/faked_services.ml +++ b/src/proto_018_Proxford/lib_delegate/test/mockup_simulator/faked_services.ml @@ -185,10 +185,7 @@ module Make (Hooks : Mocked_services_hooks) = struct @@ Directory.register Directory.empty Mockup.M.Block_services.S.Operations.operations - (fun (((), _chain), block) q () -> - let open Lwt_result_syntax in - let* ops = Hooks.operations block in - return (q#version, ops)) + (fun (((), _chain), block) _q () -> Hooks.operations block) let hash = Directory.prefix diff --git a/src/proto_alpha/lib_delegate/test/mockup_simulator/faked_services.ml b/src/proto_alpha/lib_delegate/test/mockup_simulator/faked_services.ml index e878aaa41b4d..1808b71eb7d6 100644 --- a/src/proto_alpha/lib_delegate/test/mockup_simulator/faked_services.ml +++ b/src/proto_alpha/lib_delegate/test/mockup_simulator/faked_services.ml @@ -185,10 +185,7 @@ module Make (Hooks : Mocked_services_hooks) = struct @@ Directory.register Directory.empty Mockup.M.Block_services.S.Operations.operations - (fun (((), _chain), block) q () -> - let open Lwt_result_syntax in - let* ops = Hooks.operations block in - return (q#version, ops)) + (fun (((), _chain), block) _q () -> Hooks.operations block) let hash = Directory.prefix -- GitLab From aabb59977f2f134c29912b23408cc399a59f8e80 Mon Sep 17 00:00:00 2001 From: Albin Coquereau Date: Wed, 5 Jul 2023 15:01:50 +0200 Subject: [PATCH 13/19] tezt/lib_tezos: adapt block and operations path according to version --- tezt/lib_tezos/RPC.ml | 31 ++++++++++++------------------- 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/tezt/lib_tezos/RPC.ml b/tezt/lib_tezos/RPC.ml index 5b6a82208621..00688458e708 100644 --- a/tezt/lib_tezos/RPC.ml +++ b/tezt/lib_tezos/RPC.ml @@ -285,8 +285,8 @@ let get_chain_chain_id ?(chain = "main") () = make GET ["chains"; chain; "chain_id"] JSON.as_string let get_chain_block ?(chain = "main") ?(block = "head") ?version () = - let query_string = Query_arg.opt "version" Fun.id version in - make ~query_string GET ["chains"; chain; "blocks"; block] Fun.id + let path = ["chains"; chain; "blocks"; block] in + make GET (rpc_version ~default:"0" ~path version) Fun.id type block_metadata = { protocol : string; @@ -426,32 +426,25 @@ let get_chain_block_header_protocol_data ?(chain = "main") ?(block = "head") ["chains"; chain; "blocks"; block; "header"; "protocol_data"] Fun.id +let block_operations_path ~chain ~block version = + rpc_version ~default:"0" ~path:["chains"; chain; "blocks"; block] version + @ ["operations"] + let get_chain_block_operations ?(chain = "main") ?(block = "head") ?version ?(force_metadata = false) () = - let query_string = - Query_arg.opt "version" Fun.id version - @ if force_metadata then [("force_metadata", "")] else [] - in - make ~query_string GET ["chains"; chain; "blocks"; block; "operations"] Fun.id + let query_string = if force_metadata then [("force_metadata", "")] else [] in + let path = block_operations_path ~chain ~block version in + make ~query_string GET path Fun.id let get_chain_block_operations_validation_pass ?(chain = "main") ?(block = "head") ?version ?(force_metadata = false) ?operation_offset ~validation_pass () = let path = - [ - "chains"; - chain; - "blocks"; - block; - "operations"; - string_of_int validation_pass; - ] + block_operations_path ~chain ~block version + @ [string_of_int validation_pass] @ match operation_offset with None -> [] | Some m -> [string_of_int m] in - let query_string = - Query_arg.opt "version" Fun.id version - @ if force_metadata then [("force_metadata", "")] else [] - in + let query_string = if force_metadata then [("force_metadata", "")] else [] in make ~query_string GET path Fun.id let get_chain_mempool_pending_operations ?(chain = "main") ?version ?validated -- GitLab From c4faf7868104ef701815d952e3baf3d4e90c1761 Mon Sep 17 00:00:00 2001 From: Albin Coquereau Date: Wed, 5 Jul 2023 19:06:33 +0200 Subject: [PATCH 14/19] tezt/tests: adapt block and block/operations rpc tests --- tezt/tests/rpc_versioning_attestation.ml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tezt/tests/rpc_versioning_attestation.ml b/tezt/tests/rpc_versioning_attestation.ml index 87458757e89b..f1dc1fb5327e 100644 --- a/tezt/tests/rpc_versioning_attestation.ml +++ b/tezt/tests/rpc_versioning_attestation.ml @@ -986,6 +986,7 @@ module Block = struct Log.info "Check kind for operation rpc" ; check_rpc_versions ~check:(fun ~use_legacy_name:_ -> check_kind) + ~check_unknown_version ~get_name ~rpc:(fun ~version () -> RPC.get_chain_block_operations_validation_pass @@ -1002,6 +1003,7 @@ module Block = struct let check ~use_legacy_name:_ json = check_kind JSON.(json |=> 0) in check_rpc_versions ~check + ~check_unknown_version ~get_name ~rpc:(fun ~version () -> RPC.get_chain_block_operations_validation_pass @@ -1018,6 +1020,7 @@ module Block = struct in check_rpc_versions ~check + ~check_unknown_version ~get_name ~rpc:(fun ~version () -> RPC.get_chain_block_operations ~version ()) ~data:() @@ -1030,6 +1033,7 @@ module Block = struct in check_rpc_versions ~check + ~check_unknown_version ~get_name ~rpc:(fun ~version () -> RPC.get_chain_block ~version ()) ~data:() -- GitLab From 741983a672a4095e1d499f0f1867058e658daa14 Mon Sep 17 00:00:00 2001 From: Albin Coquereau Date: Wed, 5 Jul 2023 21:39:32 +0200 Subject: [PATCH 15/19] changes: update block and block/operations RPC entry --- CHANGES.rst | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 5acaeab4fef6..daa8033397b1 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -188,12 +188,13 @@ Node no prevalidator filter is found later on for a different protocol. (MR :gl:`!9261`) -- Added version ``1`` to RPCs ``GET ../blocks/``, and ``GET - ../blocks//operations``. It can be used by calling the RPC with the - parameter ``?version=1`` (default version is still ``0``). Version ``1`` - allows the RPC to output ``attestation``, ``preattestation``, - ``double_attestation_evidence`` and ``double_preattestation_evidence`` kinds - in the JSON result. (MR :gl:`!9008`) +- Introduced a version ``v1`` to RPC ``GET ../blocks/`` and ``GET + ../blocks//operations``. It can be used by calling ``GET + ../blocks//v1`` and ``GET ../blocks//v1/operations``. This + version allows the RPC to allow in both input and output ``attestation``, + ``preattestation``, ``double_attestation_evidence`` and + ``double_preattestation_evidence`` kinds in the JSON result. (MRs :gl:`!9008`, + :gl:`!9410`) Client ------ -- GitLab From f42a519d47526f2942004fdf347ac395f2831a1a Mon Sep 17 00:00:00 2001 From: Albin Coquereau Date: Wed, 5 Jul 2023 19:34:59 +0200 Subject: [PATCH 16/19] lib_shell: introduce `preapply/block/v1`and `preapply/operations/v1` RPCs --- src/lib_mockup/local_services.ml | 4 +- src/lib_shell/block_directory.ml | 204 +++++++++++----------- src/lib_shell_services/block_services.ml | 175 ++++++------------- src/lib_shell_services/block_services.mli | 25 ++- 4 files changed, 180 insertions(+), 228 deletions(-) diff --git a/src/lib_mockup/local_services.ml b/src/lib_mockup/local_services.ml index 7f66009d0497..c1ac02db957a 100644 --- a/src/lib_mockup/local_services.ml +++ b/src/lib_mockup/local_services.ml @@ -561,7 +561,7 @@ module Make (E : MENV) = struct Directory.empty (* /chains//blocks//helpers/preapply/operations *) E.Block_services.S.Helpers.Preapply.operations - (fun ((_, chain), _block) params op_list -> + (fun ((_, chain), _block) _params op_list -> with_chain ~caller_name:"preapply operations" chain (fun () -> let*! outcome = let* proto_state = partial_construction ~cache:`Lazy () in @@ -585,7 +585,7 @@ module Make (E : MENV) = struct return (List.rev acc) in match outcome with - | Ok result -> Tezos_rpc.Answer.return (params#version, result) + | Ok result -> Tezos_rpc.Answer.return result | Error errs -> Tezos_rpc.Answer.fail errs))) let hash_op (shell, proto) = diff --git a/src/lib_shell/block_directory.ml b/src/lib_shell/block_directory.ml index 3d35d55922b0..c42fda02cdfe 100644 --- a/src/lib_shell/block_directory.ml +++ b/src/lib_shell/block_directory.ml @@ -645,109 +645,109 @@ let build_raw_rpc_directory (module Proto : Block_services.PROTO) register0 S.info info ; register0 S.info_v1 info ; (* helpers *) - register0 S.Helpers.Preapply.block (fun (chain_store, block) q p -> - let timestamp = - match q#timestamp with - | None -> Time.System.to_protocol (Time.System.now ()) - | Some time -> time - in - let protocol_data = - Data_encoding.Binary.to_bytes_exn - Next_proto.block_header_data_encoding - p.protocol_data - in - let operations = - List.map - (fun operations -> - let operations = - List.map - (fun op -> - let proto = - Data_encoding.Binary.to_bytes_exn - Next_proto - .operation_data_encoding_with_legacy_attestation_name - op.Next_proto.protocol_data - in - (op, {Operation.shell = op.shell; proto})) + let register_preapply_block (chain_store, block) q + (p : S.Helpers.Preapply.block_param) = + let timestamp = + match q#timestamp with + | None -> Time.System.to_protocol (Time.System.now ()) + | Some time -> time + in + let protocol_data = + Data_encoding.Binary.to_bytes_exn + Next_proto.block_header_data_encoding + p.protocol_data + in + let operations = + List.map + (fun operations -> + let operations = + List.map + (fun op -> + let proto = + Data_encoding.Binary.to_bytes_exn + Next_proto + .operation_data_encoding_with_legacy_attestation_name + op.Next_proto.protocol_data + in + (op, {Operation.shell = op.shell; proto})) + operations + in + let operations = + if q#sort_operations then + List.sort + (fun (op, ops) (op', ops') -> + let oph, oph' = (Operation.hash ops, Operation.hash ops') in + Next_proto.compare_operations (oph, op) (oph', op')) operations - in - let operations = - if q#sort_operations then - List.sort - (fun (op, ops) (op', ops') -> - let oph, oph' = (Operation.hash ops, Operation.hash ops') in - Next_proto.compare_operations (oph, op) (oph', op')) - operations - else operations - in - List.map snd operations) - p.operations - in - let* bv = - try return (Block_validator.running_worker ()) - with _ -> failwith "Block validator is not running" - in - Block_validator.preapply - bv - chain_store - ~predecessor:block - ~timestamp - ~protocol_data - operations) ; - register0 - S.Helpers.Preapply.operations - (fun (chain_store, block) params ops -> - let* ctxt = Store.Block.context chain_store block in - let chain_id = Store.Chain.chain_id chain_store in - let mode = - let predecessor_hash = Store.Block.hash block in - let timestamp = Time.System.to_protocol (Time.System.now ()) in - Next_proto.Partial_construction {predecessor_hash; timestamp} - in - let predecessor = Store.Block.shell_header block in - let* validation_state = - Next_proto.begin_validation ctxt chain_id mode ~predecessor ~cache:`Lazy - in - let* application_state = - Next_proto.begin_application - ctxt - chain_id - mode - ~predecessor - ~cache:`Lazy - in - let* hashed_ops = - List.map_es - (fun op -> - match - Data_encoding.Binary.to_bytes - Next_proto.operation_data_encoding_with_legacy_attestation_name - op.Next_proto.protocol_data - with - | Error _ -> - failwith "preapply_operations: cannot deserialize operation" - | Ok proto -> - let op_t = {Operation.shell = op.shell; proto} in - Lwt_result.return (Operation.hash op_t, op)) - ops - in - let* _validation_state, _application_state, acc = - List.fold_left_es - (fun (validation_state, application_state, acc) (oph, op) -> - let* validation_state = - Next_proto.validate_operation validation_state oph op - in - let* application_state, result = - Next_proto.apply_operation application_state oph op - in - return - ( validation_state, - application_state, - (op.protocol_data, result) :: acc )) - (validation_state, application_state, []) - hashed_ops - in - return (params#version, List.rev acc)) ; + else operations + in + List.map snd operations) + p.operations + in + let* bv = + try return (Block_validator.running_worker ()) + with _ -> failwith "Block validator is not running" + in + Block_validator.preapply + bv + chain_store + ~predecessor:block + ~timestamp + ~protocol_data + operations + in + register0 S.Helpers.Preapply.block register_preapply_block ; + register0 S.Helpers.Preapply.block_v1 register_preapply_block ; + let register_preapply_operations (chain_store, block) _params ops = + let* ctxt = Store.Block.context chain_store block in + let chain_id = Store.Chain.chain_id chain_store in + let mode = + let predecessor_hash = Store.Block.hash block in + let timestamp = Time.System.to_protocol (Time.System.now ()) in + Next_proto.Partial_construction {predecessor_hash; timestamp} + in + let predecessor = Store.Block.shell_header block in + let* validation_state = + Next_proto.begin_validation ctxt chain_id mode ~predecessor ~cache:`Lazy + in + let* application_state = + Next_proto.begin_application ctxt chain_id mode ~predecessor ~cache:`Lazy + in + let* hashed_ops = + List.map_es + (fun op -> + match + Data_encoding.Binary.to_bytes + Next_proto.operation_data_encoding_with_legacy_attestation_name + op.Next_proto.protocol_data + with + | Error _ -> + failwith "preapply_operations: cannot deserialize operation" + | Ok proto -> + let op_t = {Operation.shell = op.shell; proto} in + Lwt_result.return (Operation.hash op_t, op)) + ops + in + let* _validation_state, _application_state, acc = + List.fold_left_es + (fun (validation_state, application_state, acc) (oph, op) -> + let* validation_state = + Next_proto.validate_operation validation_state oph op + in + let* application_state, result = + Next_proto.apply_operation application_state oph op + in + return + ( validation_state, + application_state, + (op.protocol_data, result) :: acc )) + (validation_state, application_state, []) + hashed_ops + in + return (List.rev acc) + in + register0 S.Helpers.Preapply.operations register_preapply_operations ; + register0 S.Helpers.Preapply.operations_v1 register_preapply_operations ; register1 S.Helpers.complete (fun (chain_store, block) prefix () () -> let* ctxt = Store.Block.context chain_store block in let*! l1 = Tezos_crypto.Base58.complete prefix in diff --git a/src/lib_shell_services/block_services.ml b/src/lib_shell_services/block_services.ml index 59de076d9679..c7d094b5e41d 100644 --- a/src/lib_shell_services/block_services.ml +++ b/src/lib_shell_services/block_services.ml @@ -29,40 +29,6 @@ module Proof = Tezos_context_sigs.Context.Proof_types type version = Version_0 | Version_1 -let string_of_version = function Version_0 -> "0" | Version_1 -> "1" - -let unsupported_version_msg version supported = - Format.asprintf - "Unsupported version %s (supported versions %a)" - version - (Format.pp_print_list - ~pp_sep:(fun fmt () -> Format.fprintf fmt ",") - (fun fmt version -> - Format.fprintf fmt "\"%s\"" (string_of_version version))) - supported - -let is_supported_version version supported = - List.mem ~equal:( == ) version supported - -let version_of_string supported version = - let open Result_syntax in - let* version_t = - match version with - | "0" -> Ok Version_0 - | "1" -> Ok Version_1 - | _ -> Error (unsupported_version_msg version supported) - in - if is_supported_version version_t supported then Ok version_t - else Error (unsupported_version_msg version supported) - -let version_arg supported = - let open Tezos_rpc.Arg in - make - ~name:"version" - ~destruct:(version_of_string supported) - ~construct:string_of_version - () - (* TODO: V2.Tree32 has been chosen arbitrarily ; maybe it's not the best option *) module Merkle_proof_encoding = Tezos_context_merkle_proof_encoding.Merkle_proof_encoding.V2.Tree32 @@ -935,23 +901,6 @@ module Make (Proto : PROTO) (Next_proto : PROTO) = struct module Preapply = struct let path = Tezos_rpc.Path.(path / "preapply") - let preapply_operation_encoding = - union - [ - case - ~title:"operation_data_encoding" - (Tag 0) - next_operation_encoding - Option.some - Fun.id; - case - ~title:"operation_data_encoding_with_legacy_attestation_name" - Json_only - next_operation_encoding_with_legacy_attestation_name - Option.some - Fun.id; - ] - let block_result_encoding = obj2 (req "shell_header" Block_header.shell_header_encoding) @@ -964,7 +913,7 @@ module Make (Proto : PROTO) (Next_proto : PROTO) = struct operations : Next_proto.operation list list; } - let block_param_encoding = + let block_param_encoding ~use_legacy_encoding_name = conv (fun {protocol_data; operations} -> (protocol_data, operations)) (fun (protocol_data, operations) -> {protocol_data; operations}) @@ -979,7 +928,12 @@ module Make (Proto : PROTO) (Next_proto : PROTO) = struct (dynamic_size Next_proto.block_header_data_encoding)))) (req "operations" - (list (dynamic_size (list preapply_operation_encoding))))) + (list + (dynamic_size + (list + (if use_legacy_encoding_name then + next_operation_encoding_with_legacy_attestation_name + else next_operation_encoding)))))) let block_query = let open Tezos_rpc.Query in @@ -993,69 +947,58 @@ module Make (Proto : PROTO) (Next_proto : PROTO) = struct |+ opt_field "timestamp" Time.Protocol.rpc_arg (fun t -> t#timestamp) |> seal + let default_preapply_block_version = Version_0 + let block = + Tezos_rpc.Service.post_service + ~description: + "(Deprecated, used `/preapply/block/v1` instead) Simulate the \ + validation of a block that would contain the given operations \ + and return the resulting fitness and context hash." + ~query:block_query + ~input:(block_param_encoding ~use_legacy_encoding_name:true) + ~output:block_result_encoding + Tezos_rpc.Path.(path / "block") + + let block_v1 = Tezos_rpc.Service.post_service ~description: "Simulate the validation of a block that would contain the given \ operations and return the resulting fitness and context hash." ~query:block_query - ~input:block_param_encoding + ~input:(block_param_encoding ~use_legacy_encoding_name:false) ~output:block_result_encoding - Tezos_rpc.Path.(path / "block") + Tezos_rpc.Path.(path / "block" / "v1") let default_preapply_operations_version = Version_0 - let preapply_supported_versions = [Version_0; Version_1] - - let operations_query = - let open Tezos_rpc.Query in - query (fun version -> - object - method version = version - end) - |+ field - "version" - (version_arg preapply_supported_versions) - default_preapply_operations_version - (fun t -> t#version) - |> seal - - let preapplied_operations_encoding = - union - [ - case - ~title:"preapplied_operations_encoding" - (Tag 1) - (list - (dynamic_size Next_proto.operation_data_and_receipt_encoding)) - (function - | Version_1, preapply_operations -> Some preapply_operations - | Version_0, _ -> None) - (fun preapply_operations -> (Version_1, preapply_operations)); - case - ~title: - "preapplied_operations_encoding_with_legacy_attestation_name" - (Tag 0) - (list - (dynamic_size - Next_proto - .operation_data_and_receipt_encoding_with_legacy_attestation_name)) - (function - | Version_0, preapply_operations -> Some preapply_operations - | Version_1, _ -> None) - (fun preapply_operations -> (Version_0, preapply_operations)); - ] - let operations = + Tezos_rpc.Service.post_service + ~description: + "(Deprecated, used `/preapply/operations/v1` instead) Simulate \ + the application of the operations with the context of the given \ + block and return the result of each operation application." + ~query:Tezos_rpc.Query.empty + ~input:(list next_operation_encoding_with_legacy_attestation_name) + ~output: + (list + (dynamic_size + Next_proto + .operation_data_and_receipt_encoding_with_legacy_attestation_name)) + Tezos_rpc.Path.(path / "operations") + + let operations_v1 = Tezos_rpc.Service.post_service ~description: "Simulate the application of the operations with the context of \ the given block and return the result of each operation \ application." - ~query:operations_query - ~input:(list preapply_operation_encoding) - ~output:preapplied_operations_encoding - Tezos_rpc.Path.(path / "operations") + ~query:Tezos_rpc.Query.empty + ~input:(list next_operation_encoding) + ~output: + (list + (dynamic_size Next_proto.operation_data_and_receipt_encoding)) + Tezos_rpc.Path.(path / "operations" / "v1") end let complete = @@ -1751,14 +1694,13 @@ module Make (Proto : PROTO) (Next_proto : PROTO) = struct module Preapply = struct module S = S.Preapply - let block ctxt = - let f = make_call0 S.block ctxt in - fun ?(chain = `Main) - ?(block = `Head 0) - ?(sort = false) - ?timestamp - ~protocol_data - operations -> + let block ctxt ?(chain = `Main) ?(block = `Head 0) + ?(version = S.default_preapply_block_version) = + let s = + match version with Version_0 -> S.block | Version_1 -> S.block_v1 + in + let f = make_call0 s ctxt in + fun ?(sort = false) ?timestamp ~protocol_data operations -> f chain block @@ -1771,19 +1713,12 @@ module Make (Proto : PROTO) (Next_proto : PROTO) = struct let operations ctxt ?(chain = `Main) ?(block = `Head 0) ?(version = S.default_preapply_operations_version) operations = - let open Lwt_result_syntax in - let* (Version_0 | Version_1), preapply_operations = - make_call0 - S.operations - ctxt - chain - block - (object - method version = version - end) - operations + let s = + match version with + | Version_0 -> S.operations + | Version_1 -> S.operations_v1 in - return preapply_operations + make_call0 s ctxt chain block () operations end let complete ctxt = diff --git a/src/lib_shell_services/block_services.mli b/src/lib_shell_services/block_services.mli index 142fb4ff353a..f83a0a625e14 100644 --- a/src/lib_shell_services/block_services.mli +++ b/src/lib_shell_services/block_services.mli @@ -379,6 +379,7 @@ module Make (Proto : PROTO) (Next_proto : PROTO) : sig #simple -> ?chain:chain -> ?block:block -> + ?version:version -> ?sort:bool -> ?timestamp:Time.Protocol.t -> protocol_data:Next_proto.block_header_data -> @@ -739,15 +740,31 @@ module Make (Proto : PROTO) (Next_proto : PROTO) : sig Block_header.shell_header * error Preapply_result.t list ) Tezos_rpc.Service.t + val block_v1 : + ( [`POST], + prefix, + prefix, + < sort_operations : bool ; timestamp : Time.Protocol.t option >, + block_param, + Block_header.shell_header * error Preapply_result.t list ) + Tezos_rpc.Service.t + val operations : ( [`POST], prefix, prefix, - < version : version >, + unit, + Next_proto.operation list, + (Next_proto.operation_data * Next_proto.operation_receipt) list ) + Tezos_rpc.Service.t + + val operations_v1 : + ( [`POST], + prefix, + prefix, + unit, Next_proto.operation list, - version - * (Next_proto.operation_data * Next_proto.operation_receipt) list - ) + (Next_proto.operation_data * Next_proto.operation_receipt) list ) Tezos_rpc.Service.t end -- GitLab From 004f3785e3694b400e725026972953fd764f8f9b Mon Sep 17 00:00:00 2001 From: Albin Coquereau Date: Wed, 5 Jul 2023 21:12:31 +0200 Subject: [PATCH 17/19] tezt/lib_tezos: adapt preapply rpc path according to version --- tezt/lib_tezos/RPC.ml | 29 ++++++++++++++++------------- tezt/lib_tezos/RPC.mli | 7 ++++++- 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/tezt/lib_tezos/RPC.ml b/tezt/lib_tezos/RPC.ml index 00688458e708..bee5f914de52 100644 --- a/tezt/lib_tezos/RPC.ml +++ b/tezt/lib_tezos/RPC.ml @@ -509,22 +509,25 @@ let post_chain_mempool_filter ?(chain = "main") ~data () = make ~data POST ["chains"; chain; "mempool"; "filter"] Fun.id let post_chain_block_helpers_preapply_block ?(chain = "main") ?(block = "head") - ~data () = - make - ~data - POST - ["chains"; chain; "blocks"; block; "helpers"; "preapply"; "block"] - Fun.id + ?version ~data () = + let path = + rpc_version + ~default:"0" + ~path:["chains"; chain; "blocks"; block; "helpers"; "preapply"; "block"] + version + in + make ~data POST path Fun.id let post_chain_block_helpers_preapply_operations ?(chain = "main") ?(block = "head") ?version ~data () = - let query_string = Query_arg.opt "version" Fun.id version in - make - ~query_string - ~data - POST - ["chains"; chain; "blocks"; block; "helpers"; "preapply"; "operations"] - Fun.id + let path = + rpc_version + ~default:"0" + ~path: + ["chains"; chain; "blocks"; block; "helpers"; "preapply"; "operations"] + version + in + make ~data POST path Fun.id let post_chain_block_helpers_forge_operations ?(chain = "main") ?(block = "head") ~data () = diff --git a/tezt/lib_tezos/RPC.mli b/tezt/lib_tezos/RPC.mli index 23bf1204a3fe..83563f65248d 100644 --- a/tezt/lib_tezos/RPC.mli +++ b/tezt/lib_tezos/RPC.mli @@ -529,7 +529,12 @@ val post_chain_mempool_filter : ?chain:string -> data:data -> unit -> JSON.t t [block] defaults to ["head"]. *) val post_chain_block_helpers_preapply_block : - ?chain:string -> ?block:string -> data:data -> unit -> JSON.t t + ?chain:string -> + ?block:string -> + ?version:string -> + data:data -> + unit -> + JSON.t t (** RPC: [POST /chains//blocks//helpers/preapply/operations] -- GitLab From 4fbda411abc214894795ebe041422dddfc444ee1 Mon Sep 17 00:00:00 2001 From: Albin Coquereau Date: Wed, 5 Jul 2023 21:26:42 +0200 Subject: [PATCH 18/19] tezt/tests: adapt preapply/operations rpc tests --- tezt/tests/rpc_versioning_attestation.ml | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/tezt/tests/rpc_versioning_attestation.ml b/tezt/tests/rpc_versioning_attestation.ml index f1dc1fb5327e..0c0dd76d12a6 100644 --- a/tezt/tests/rpc_versioning_attestation.ml +++ b/tezt/tests/rpc_versioning_attestation.ml @@ -912,7 +912,17 @@ module Preapply = struct let check ~use_legacy_name:_ json = check_kind JSON.(json |> as_list |> List.hd) in - check_rpc_versions ~check ~rpc ~get_name ~data:consensus_json client + let* () = + check_version + ~version:(if use_legacy_name then "0" else "1") + ~use_legacy_name + ~check + ~rpc + ~get_name + ~data:consensus_json + client + in + check_unknown_version ~version:"2" ~rpc ~data:consensus_json client in let* () = preapply_op ~use_legacy_name:true in preapply_op ~use_legacy_name:false @@ -951,7 +961,17 @@ module Preapply = struct let check ~use_legacy_name:_ json = check_kind JSON.(json |> as_list |> List.hd) in - check_rpc_versions ~check ~rpc ~get_name ~data:consensus_json client + let* () = + check_version + ~version:(if use_legacy_name then "0" else "1") + ~use_legacy_name + ~check + ~rpc + ~get_name + ~data:consensus_json + client + in + check_unknown_version ~version:"2" ~rpc ~data:consensus_json client in let* () = preapply_op ~use_legacy_name:true in preapply_op ~use_legacy_name:false -- GitLab From 20ada74c82a4fc03de6d28c3b80f0d2314617231 Mon Sep 17 00:00:00 2001 From: Albin Coquereau Date: Wed, 5 Jul 2023 21:36:32 +0200 Subject: [PATCH 19/19] changes: update preapply RPC entry --- CHANGES.rst | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index daa8033397b1..abd3275509cc 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -161,11 +161,13 @@ Node metric, and renamed the ``octez_mempool_pending_prechecked`` one to ``octez_mempool_pending_validated``. (MR :gl:`!9137`) -- Added version ``1`` to RPC ``POST ../helpers/preapply/operations``. It can be - used by calling the RPC with the parameter ``?version=1`` (default version is - still ``0``). Version ``1`` allows the RPC to output ``attestation``, +- Introduced a version ``v1`` to RPC ``POST ../helpers/preapply/operations`` and + ``POST ../helpers/preapply/block``. It can be used by calling ``POST + ../helpers/preapply/operations/v1`` and ``POST ../helpers/preapply/block/v1``. + This version allows the RPC to allow in both input and output ``attestation``, ``preattestation``, ``double_attestation_evidence`` and - ``double_preattestation_evidence`` kinds in the JSON result. (MR :gl:`!8891`) + ``double_preattestation_evidence`` kinds in the JSON result. (MRs :gl:`!8891`, + :gl:`!9410`) - Changed default stdout logs by adding simple coloration. The log header header is now bold and warning and errors are highlighted. The -- GitLab