diff --git a/src/bin_dal_node/RPC_server.ml b/src/bin_dal_node/RPC_server.ml index f494d41cb8fef7cf329f3fd659d784742131b55a..4180a77dc954a85136b2e7585c70cdd5fcd411d4 100644 --- a/src/bin_dal_node/RPC_server.ml +++ b/src/bin_dal_node/RPC_server.ml @@ -51,21 +51,23 @@ module Slots_handlers = struct match r with Ok () -> return_some () | Error `Not_found -> return_none) ctxt - let get_slot_content ctxt commitment () () = + let get_commitment_slot ctxt commitment () () = call_handler (fun store cryptobox -> let open Lwt_result_syntax in - let*! r = Slot_manager.find_slot store cryptobox commitment in + let*! r = Slot_manager.get_commitment_slot store cryptobox commitment in match r with Ok s -> return_some s | Error `Not_found -> return_none) ctxt - let get_slot_commitment_proof ctxt commitment () () = + let get_commitment_proof ctxt commitment () () = call_handler (fun store cryptobox -> let open Lwt_result_syntax in (* This handler may be costly: We need to recompute the polynomial and then compute the proof. *) - let*! slot = Slot_manager.find_slot store cryptobox commitment in + let*! slot = + Slot_manager.get_commitment_slot store cryptobox commitment + in match slot with | Error `Not_found -> return_none | Ok slot -> ( @@ -134,12 +136,12 @@ let register_new : (Slots_handlers.patch_commitment ctxt) |> add_service Tezos_rpc.Directory.opt_register1 - Services.get_slot - (Slots_handlers.get_slot_content ctxt) + Services.get_commitment_slot + (Slots_handlers.get_commitment_slot ctxt) |> add_service Tezos_rpc.Directory.opt_register1 - Services.get_slot_commitment_proof - (Slots_handlers.get_slot_commitment_proof ctxt) + Services.get_commitment_proof + (Slots_handlers.get_commitment_proof ctxt) |> add_service Tezos_rpc.Directory.opt_register2 Services.get_commitment_by_published_level_and_index diff --git a/src/bin_dal_node/slot_manager.ml b/src/bin_dal_node/slot_manager.ml index 95f557fe58cb3697d152121e5021ab5fb44758db..66f835991f2cd8a4101576d7913c2cf27d6857d4 100644 --- a/src/bin_dal_node/slot_manager.ml +++ b/src/bin_dal_node/slot_manager.ml @@ -88,7 +88,7 @@ let associate_slot_id_with_commitment node_store cryptobox commitment slot_id = in return_unit -let find_slot node_store cryptobox commitment = +let get_commitment_slot node_store cryptobox commitment = let open Lwt_result_syntax in let*! slot_opt = Store.Legacy.find_slot_by_commitment node_store cryptobox commitment diff --git a/src/bin_dal_node/slot_manager.mli b/src/bin_dal_node/slot_manager.mli index 3fb454f536c9e44c0f920fa1595a174b47d47984..1fdce207b41f92d610e1c05ffa38cd54f495fe72 100644 --- a/src/bin_dal_node/slot_manager.mli +++ b/src/bin_dal_node/slot_manager.mli @@ -57,11 +57,11 @@ val associate_slot_id_with_commitment : Services.Types.slot_id -> (unit, [> `Not_found]) result Lwt.t -(** [find_slot node_store cryptobox commitment] returns the slot +(** [get_commitment_slot node_store cryptobox commitment] returns the slot content associated with the given [commitment] in [node_store]. The function returns [Error `Not_found] if there is no slot content for [commitment] in [node_store]. *) -val find_slot : +val get_commitment_slot : Store.node_store -> Cryptobox.t -> Cryptobox.commitment -> diff --git a/src/lib_dal_node_services/services.ml b/src/lib_dal_node_services/services.ml index 17cbe1f2ae98081d25be639edc5ad1e2d07e9369..4def7b6ba451e3a4959bbf887035cb84e8fd4e1f 100644 --- a/src/lib_dal_node_services/services.ml +++ b/src/lib_dal_node_services/services.ml @@ -182,7 +182,7 @@ let patch_commitment : ~output:Data_encoding.unit Tezos_rpc.Path.(open_root / "commitments" /: Cryptobox.Commitment.rpc_arg) -let get_slot : +let get_commitment_slot : < meth : [`GET] ; input : unit ; output : Cryptobox.slot @@ -195,9 +195,10 @@ let get_slot : "Retrieve the content of the slot associated with the given commitment." ~query:Tezos_rpc.Query.empty ~output:Types.slot_encoding - Tezos_rpc.Path.(open_root / "slots" /: Cryptobox.Commitment.rpc_arg) + Tezos_rpc.Path.( + open_root / "commitments" /: Cryptobox.Commitment.rpc_arg / "slot") -let get_slot_commitment_proof : +let get_commitment_proof : < meth : [`GET] ; input : unit ; output : Cryptobox.commitment_proof @@ -210,7 +211,7 @@ let get_slot_commitment_proof : ~query:Tezos_rpc.Query.empty ~output:Cryptobox.Commitment_proof.encoding Tezos_rpc.Path.( - open_root / "slots" /: Cryptobox.Commitment.rpc_arg / "proof") + open_root / "commitments" /: Cryptobox.Commitment.rpc_arg / "proof") let get_commitment_by_published_level_and_index : < meth : [`GET] diff --git a/src/lib_dal_node_services/services.mli b/src/lib_dal_node_services/services.mli index 29ecbb0c2457206822efa55ba5011333121f7f3b..414109a2ee142c8eac8f943d82114f68f8dc2bf7 100644 --- a/src/lib_dal_node_services/services.mli +++ b/src/lib_dal_node_services/services.mli @@ -114,7 +114,7 @@ val patch_commitment : service (** Retrieve the content of the slot associated with the given commitment. *) -val get_slot : +val get_commitment_slot : < meth : [`GET] ; input : unit ; output : Cryptobox.slot @@ -124,7 +124,7 @@ val get_slot : service (** Compute the proof associated to a commitment. *) -val get_slot_commitment_proof : +val get_commitment_proof : < meth : [`GET] ; input : unit ; output : Cryptobox.commitment_proof diff --git a/tezt/lib_tezos/rollup.ml b/tezt/lib_tezos/rollup.ml index e3761ce83a5b9bd793f98d8a25e68ecd96fe3a88..908d8f1d6085b045828ead7e0e17f1eab7ba86fc 100644 --- a/tezt/lib_tezos/rollup.ml +++ b/tezt/lib_tezos/rollup.ml @@ -727,13 +727,16 @@ module Dal = struct in make ~data PATCH ["commitments"; commitment] as_empty_object_or_fail - let get_slot commitment = - make GET ["slots"; commitment] get_bytes_from_json_string_node + let get_commitment_slot commitment = + make + GET + ["commitments"; commitment; "slot"] + get_bytes_from_json_string_node type commitment_proof = string - let get_slot_proof commitment = - make GET ["slots"; commitment; "proof"] JSON.as_string + let get_commitment_proof commitment = + make GET ["commitments"; commitment; "proof"] JSON.as_string let get_level_index_commitment ~slot_level ~slot_index = make diff --git a/tezt/lib_tezos/rollup.mli b/tezt/lib_tezos/rollup.mli index b14b4d7ee4c271ac2fffc692d2dc4460f453100e..7aace78454675f5631ce137efe84d194876b1b26 100644 --- a/tezt/lib_tezos/rollup.mli +++ b/tezt/lib_tezos/rollup.mli @@ -325,15 +325,16 @@ module Dal : sig slot_index:int -> (Dal_node.t, unit) RPC_core.t - (** Call RPC "GET /slots/" to retrieve the slot content associated with the - given commitment. *) - val get_slot : commitment -> (Dal_node.t, slot) RPC_core.t + (** Call RPC "GET /commitments//slot" to retrieve the slot + content associated with the given commitment. *) + val get_commitment_slot : commitment -> (Dal_node.t, slot) RPC_core.t type commitment_proof = string - (** Call RPC "GET /slots//proof" to get the proof + (** Call RPC "GET /commitments//proof" to get the proof associated to a commitment. *) - val get_slot_proof : commitment -> (Dal_node.t, commitment_proof) RPC_core.t + val get_commitment_proof : + commitment -> (Dal_node.t, commitment_proof) RPC_core.t (** Call RPC "GET /levels//slot_indices//commitment" to get diff --git a/tezt/tests/dal.ml b/tezt/tests/dal.ml index 9a14d18be63a998e3f931f744da8e44d01543376..60ba46180bba6c63d50917d6ee215d7df6e60e1d 100644 --- a/tezt/tests/dal.ml +++ b/tezt/tests/dal.ml @@ -1228,20 +1228,24 @@ let test_dal_node_test_patch_commitments _protocol parameters cryptobox _node let* () = patch_slot_rpc ~slot_level:0 ~slot_index:1 in patch_slot_rpc ~slot_level:(-4) ~slot_index:3 -let test_dal_node_test_get_slots _protocol parameters cryptobox _node client - dal_node = +let test_dal_node_test_get_commitment_slot _protocol parameters cryptobox _node + client dal_node = let size = parameters.Rollup.Dal.Parameters.cryptobox.slot_size in let* slot = Rollup.Dal.make_slot (generate_dummy_slot size) client in let commit = Cryptobox.Commitment.to_b58check @@ commitment_of_slot cryptobox slot in let* () = - let* response = RPC.call_raw dal_node @@ Rollup.Dal.RPC.get_slot commit in + let* response = + RPC.call_raw dal_node @@ Rollup.Dal.RPC.get_commitment_slot commit + in return @@ RPC.check_string_response ~code:404 response in let* _commitment = RPC.call dal_node (Rollup.Dal.RPC.post_commitment slot) in - (* commit = _commitment already test in /POST test. *) - let* got_slot = RPC.call dal_node (Rollup.Dal.RPC.get_slot commit) in + (* commit = _commitment already tested in /POST test. *) + let* got_slot = + RPC.call dal_node (Rollup.Dal.RPC.get_commitment_slot commit) + in Check.(Rollup.Dal.content_of_slot slot = Rollup.Dal.content_of_slot got_slot) Check.string ~error_msg: @@ -1249,12 +1253,14 @@ let test_dal_node_test_get_slots _protocol parameters cryptobox _node client %L, got = %R)" ; unit -let test_dal_node_test_get_slot_proof _protocol parameters cryptobox _node +let test_dal_node_test_get_commitment_proof _protocol parameters cryptobox _node client dal_node = let size = parameters.Rollup.Dal.Parameters.cryptobox.slot_size in let* slot = Rollup.Dal.make_slot (generate_dummy_slot size) client in let* commitment = RPC.call dal_node (Rollup.Dal.RPC.post_commitment slot) in - let* proof = RPC.call dal_node (Rollup.Dal.RPC.get_slot_proof commitment) in + let* proof = + RPC.call dal_node (Rollup.Dal.RPC.get_commitment_proof commitment) + in let _, expected_proof = Rollup.Dal.Commitment.dummy_commitment cryptobox (generate_dummy_slot size) in @@ -1918,12 +1924,12 @@ let register ~protocols = test_dal_node_test_patch_commitments protocols ; scenario_with_layer1_and_dal_nodes - "dal node GET /slots" - test_dal_node_test_get_slots + "dal node GET /commitments//slot" + test_dal_node_test_get_commitment_slot protocols ; scenario_with_layer1_and_dal_nodes - "dal node GET /slot//proof" - test_dal_node_test_get_slot_proof + "dal node GET /commitments//proof" + test_dal_node_test_get_commitment_proof protocols ; scenario_with_layer1_and_dal_nodes "dal node PATCH+GET /profiles"