package tezos-dac-lib

  1. Overview
  2. Docs

Source file RPC_services.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
(*****************************************************************************)
(*                                                                           *)
(* Open Source License                                                       *)
(* Copyright (c) 2023 Trili Tech, <contact@trili.tech>                       *)
(* Copyright (c) 2023 Marigold  <contact@tmarigold.dev>                      *)
(*                                                                           *)
(* Permission is hereby granted, free of charge, to any person obtaining a   *)
(* copy of this software and associated documentation files (the "Software"),*)
(* to deal in the Software without restriction, including without limitation *)
(* the rights to use, copy, modify, merge, publish, distribute, sublicense,  *)
(* and/or sell copies of the Software, and to permit persons to whom the     *)
(* Software is furnished to do so, subject to the following conditions:      *)
(*                                                                           *)
(* The above copyright notice and this permission notice shall be included   *)
(* in all copies or substantial portions of the Software.                    *)
(*                                                                           *)
(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)
(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,  *)
(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL   *)
(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)
(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING   *)
(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER       *)
(* DEALINGS IN THE SOFTWARE.                                                 *)
(*                                                                           *)
(*****************************************************************************)

module V0 = struct
  let v0_prefix = Api_version.v0_prefix

  let get_preimage =
    Tezos_rpc.Service.get_service
      ~description:"Retrieves a page by its page hash and returns its contents"
      ~query:Tezos_rpc.Query.empty
      ~output:Data_encoding.bytes
      Tezos_rpc.Path.(v0_prefix / "preimage" /: Dac_plugin.raw_hash_rpc_arg)

  let put_dac_member_signature =
    Tezos_rpc.Service.put_service
      ~description:
        "Verifies and stores the Dac member signature of a root page hash"
      ~query:Tezos_rpc.Query.empty
      ~input:Signature_repr.encoding
      ~output:Data_encoding.empty
      Tezos_rpc.Path.(v0_prefix / "dac_member_signature")

  let get_certificate =
    Tezos_rpc.Service.get_service
      ~description:
        "Retrieve the Dac certificate associated with the given root page hash"
      ~query:Tezos_rpc.Query.empty
      ~output:Certificate_repr.encoding
      Tezos_rpc.Path.(v0_prefix / "certificates" /: Dac_plugin.raw_hash_rpc_arg)

  let get_serialized_certificate =
    Tezos_rpc.Service.get_service
      ~description:
        "Retrieve the Dac certificate encoded in binary associated with the \
         given root page hash. The contained [root_hash] is compatible with \
         Kernel SDK."
      ~query:Tezos_rpc.Query.empty
      ~output:Data_encoding.(option (string' Hex))
      Tezos_rpc.Path.(
        v0_prefix / "serialized_certificates" /: Dac_plugin.raw_hash_rpc_arg)

  let get_missing_page =
    Tezos_rpc.Service.get_service
      ~description:
        "Fetch a given page by forwarding the request to a Coordinator's GET \
         /preimage. The page is then saved to the node's page store before \
         being returned in the response. The endpoint should only be exposed \
         in Observer mode."
      ~query:Tezos_rpc.Query.empty
      ~output:Data_encoding.bytes
      Tezos_rpc.Path.(v0_prefix / "missing_page" /: Dac_plugin.raw_hash_rpc_arg)

  (* TODO: https://gitlab.com/tezos/tezos/-/issues/4935
     Coordinator's "POST /preimage" endpoint should in addition to root page hash
     also return expiration level. Additionally, when it pushes a new root hash to
     all attached subscribers, it should push it together with expiration level. *)

  module Coordinator = struct
    (** [Coordinator]'s endpoint for serializing dac payload. In addition to
    returning a root page hash, it also pushes it to the subscribed [Observer]s
    and [Dac_member]s. *)
    let post_preimage =
      Tezos_rpc.Service.post_service
        ~description:
          "Stores the preimage in a sequence of pages. Returns a root page \
           hash representing the stored preimage. Additionally, it triggers \
           streaming of root page hash to subscribed committee members and \
           observers. "
        ~query:Tezos_rpc.Query.empty
        ~input:Data_encoding.bytes
        ~output:Dac_plugin.raw_hash_encoding
        Tezos_rpc.Path.(v0_prefix / "preimage")
  end
end

let get_health_live =
  Tezos_rpc.Service.get_service
    ~description:"Check that DAC node is alive"
    ~query:Tezos_rpc.Query.empty
    ~output:Data_encoding.bool
    Tezos_rpc.Path.(open_root / "health" / "live")

let get_health_ready =
  Tezos_rpc.Service.get_service
    ~description:"Check that DAC node is ready"
    ~query:Tezos_rpc.Query.empty
    ~output:Data_encoding.bool
    Tezos_rpc.Path.(open_root / "health" / "ready")

module V1 = struct
  let v1_prefix = Api_version.v1_prefix

  let get_pages =
    Tezos_rpc.Service.get_service
      ~description:"Retrieves a page by its page hash and returns its contents"
      ~query:Tezos_rpc.Query.empty
      ~output:Data_encoding.bytes
      Tezos_rpc.Path.(v1_prefix / "pages" /: Dac_plugin.raw_hash_rpc_arg)
end
OCaml

Innovation. Community. Security.