package octez-smart-rollup-node-lib

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Source file event.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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
(*****************************************************************************)
(*                                                                           *)
(* Open Source License                                                       *)
(* Copyright (c) 2023 Nomadic Labs, <contact@nomadic-labs.com>               *)
(* Copyright (c) 2023 Functori, <contact@functori.com>                       *)
(*                                                                           *)
(* 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 Simple = struct
  include Internal_event.Simple

  let section = ["smart_rollup_node"]

  let starting_node =
    declare_0
      ~section
      ~name:"starting_smart_rollup_node"
      ~msg:"Starting the smart rollup node"
      ~level:Notice
      ()

  let shutdown_node =
    declare_1
      ~section
      ~name:"stopping_smart_rollup_node"
      ~msg:"Stopping the smart rollup node"
      ~level:Notice
      ("exit_status", Data_encoding.int8)

  let node_is_ready =
    declare_2
      ~section
      ~name:"smart_rollup_node_is_ready"
      ~msg:"The smart rollup node is listening to {addr}:{port}"
      ~level:Notice
      ("addr", Data_encoding.string)
      ("port", Data_encoding.uint16)

  let rollup_exists =
    declare_2
      ~section
      ~name:"smart_rollup_node_knows_its_rollup"
      ~msg:
        "The smart rollup node is interacting with rollup {addr} of kind {kind}"
      ~level:Notice
      ("addr", Octez_smart_rollup.Address.encoding)
      ("kind", Data_encoding.string)

  let connection_lost =
    declare_0
      ~section
      ~name:"smart_rollup_daemon_connection_lost"
      ~msg:"connection to the node has been lost"
      ~level:Warning
      ()

  let cannot_connect =
    declare_2
      ~section
      ~name:"smart_rollup_daemon_cannot_connect"
      ~msg:"cannot connect to Tezos node ({count}) {error}"
      ~level:Warning
      ("count", Data_encoding.int31)
      ("error", trace_encoding)
      ~pp2:pp_print_trace

  let wait_reconnect =
    declare_1
      ~section
      ~name:"smart_rollup_daemon_wait_reconnect"
      ~msg:"Retrying to connect in {delay}s"
      ~level:Warning
      ("delay", Data_encoding.float)

  let starting_metrics_server =
    declare_2
      ~section
      ~name:"starting_metrics_server"
      ~msg:"starting metrics server on {host}:{port}"
      ~level:Notice
      ("host", Data_encoding.string)
      ("port", Data_encoding.uint16)

  let metrics_ended =
    declare_1
      ~section
      ~name:"metrics_ended"
      ~level:Error
      ~msg:"metrics server ended with error {stacktrace}"
      ("stacktrace", Data_encoding.string)

  let kernel_debug =
    declare_1
      ~section
      ~name:"kernel_debug"
      ~level:Info
      ~msg:"{log}"
      ("log", Data_encoding.string)
      ~pp1:Format.pp_print_string

  let simulation_kernel_debug =
    declare_1
      ~section
      ~name:"simulation_kernel_debug"
      ~level:Info
      ~msg:"[simulation] {log}"
      ("log", Data_encoding.string)
      ~pp1:Format.pp_print_string

  let warn_dal_enabled_no_node =
    declare_0
      ~section
      ~name:"dal_enabled_no_node"
      ~level:Warning
      ~msg:
        "Warning: DAL is enabled in the protocol but no DAL node was provided \
         for the rollup node."
      ()

  let waiting_first_block =
    declare_1
      ~section
      ~name:"waiting_first_block"
      ~level:Notice
      ~msg:"Waiting for first block of protocol {protocol} to appear."
      ("protocol", Protocol_hash.encoding)

  let received_first_block =
    declare_2
      ~section
      ~name:"received_first_block"
      ~level:Notice
      ~msg:"First block of protocol {protocol} received: {block}."
      ("block", Block_hash.encoding)
      ("protocol", Protocol_hash.encoding)

  let detected_protocol_migration =
    declare_0
      ~section
      ~name:"detected_protocol_migration"
      ~level:Notice
      ~msg:"Detected protocol migration, the rollup node will now stop."
      ()

  let acquiring_lock =
    declare_0
      ~section
      ~name:"acquiring_lock"
      ~level:Notice
      ~msg:"Acquiring lock on data directory."
      ()
end

let starting_node = Simple.(emit starting_node)

let shutdown_node exit_status = Simple.(emit shutdown_node exit_status)

let node_is_ready ~rpc_addr ~rpc_port =
  Simple.(emit node_is_ready (rpc_addr, rpc_port))

let rollup_exists ~addr ~kind =
  let kind = Octez_smart_rollup.Kind.to_string kind in
  Simple.(emit rollup_exists (addr, kind))

let connection_lost () = Simple.(emit connection_lost) ()

let cannot_connect ~count error = Simple.(emit cannot_connect) (count, error)

let wait_reconnect delay = Simple.(emit wait_reconnect) delay

let starting_metrics_server ~host ~port =
  Simple.(emit starting_metrics_server) (host, port)

let metrics_ended error = Simple.(emit metrics_ended) error

let metrics_ended_dont_wait error =
  Simple.(emit__dont_wait__use_with_care metrics_ended) error

let kernel_debug msg = Simple.(emit kernel_debug) msg

let simulation_kernel_debug msg = Simple.(emit simulation_kernel_debug) msg

let kernel_debug_dont_wait msg =
  Simple.(emit__dont_wait__use_with_care kernel_debug) msg

let warn_dal_enabled_no_node () = Simple.(emit warn_dal_enabled_no_node) ()

let waiting_first_block p = Simple.(emit waiting_first_block) p

let received_first_block b p = Simple.(emit received_first_block) (b, p)

let detected_protocol_migration () =
  Simple.(emit detected_protocol_migration) ()

let acquiring_lock () = Simple.(emit acquiring_lock) ()
OCaml

Innovation. Community. Security.