zebrad 7.2.0

The Zcash Foundation's independent, consensus-compatible implementation of a Zcash node
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
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
//! Descriptions of the metrics `zebrad` itself records.
//!
//! The library crates describe their own metrics in their `metrics` modules, and
//! [`describe_all`](super::describe_all) describes every one of them once a recorder is installed.

use metrics::{describe_counter, describe_gauge, describe_histogram, Unit};

/// The label keys of each labelled metric `zebrad` records.
///
/// - `zebrad.build.info`:
///   - `version`: the `zebrad` version.
///   - `commit`: the git commit `zebrad` was built from, or `unknown`.
/// - `sync.restart.count`:
///   - `reason`: `exhausted_tips`, `obtain_tips_timeout`, `obtain_tips_error`,
///     `extend_tips_error`, `sync_step_timeout`, or `block_error`.
///   - `made_progress`: `true` or `false`.
/// - `sync.block.error.count`: `kind`, a block download or verify error kind such as
///   `not_found`, `download_timed_out`, `invalid`, `verify_timeout`, or `already_verified`.
/// - `sync.block.download.duration_seconds`: `result`, `success` or `cancelled`.
/// - `sync.block.verify.duration_seconds`: `result`, `success`, `failure`, or `cancelled`.
/// - `sync.stage.duration_seconds`: `stage`, `obtain_tips` or `extend_tips`.
/// - `mempool.failed.verify.tasks.total`: `reason`, one of `in_state`, `state_error`,
///   `download_failed`, `cancelled`, `invalid`, or `timeout`.
/// - `mempool.*.transactions.total`: `version`, the transaction version number, such as `4` or
///   `5`.
/// - `zcash.mempool.actions.unpaid`: `bk`, a fee weight ratio bucket: `< 0.2`, `< 0.4`, `< 0.6`,
///   `< 0.8`, or `< 1`.
/// - `zcash.mempool.size.weighted`: `bk`, a fee weight ratio bucket: `< 1`, `1`, `> 1`, `> 2`, or
///   `> 3`.
/// - `zcash.chain.tip.block_delay_seconds`: `chain.network_upgrade`, the network upgrade at the
///   block's height, such as `Nu6`.
/// - `zebrad.sentry.metrics.dropped.total`: `reason`, `flush_budget`, `transport_backlog`, or
///   `label_set_cap`.
/// - `sync.mined.block.announcement.outcomes.total`: `outcome`, `completed` or `failed`.
pub const LABELS: &[(&str, &[&str])] = &[
    ("zebrad.build.info", &["version", "commit"]),
    ("sync.restart.count", &["reason", "made_progress"]),
    ("sync.block.error.count", &["kind"]),
    ("sync.block.download.duration_seconds", &["result"]),
    ("sync.block.verify.duration_seconds", &["result"]),
    ("sync.stage.duration_seconds", &["stage"]),
    ("mempool.failed.verify.tasks.total", &["reason"]),
    ("mempool.downloaded.transactions.total", &["version"]),
    ("mempool.pushed.transactions.total", &["version"]),
    ("mempool.verified.transactions.total", &["version"]),
    ("zcash.mempool.actions.unpaid", &["bk"]),
    ("zcash.mempool.size.weighted", &["bk"]),
    (
        "zcash.chain.tip.block_delay_seconds",
        &["chain.network_upgrade"],
    ),
    ("zebrad.sentry.metrics.dropped.total", &["reason"]),
    ("sync.mined.block.announcement.outcomes.total", &["outcome"]),
];

/// Describes every metric `zebrad` itself records to the installed [`metrics`] recorder.
pub fn describe() {
    describe_counter!(
        concat!(env!("CARGO_PKG_NAME"), ".build.info"),
        Unit::Count,
        "Always 1, with the running zebrad version and git commit as labels."
    );
    describe_counter!(
        "zebrad.sentry.metrics.dropped.total",
        Unit::Count,
        "Metric values that weren't sent to Sentry when due, because a flush was full, the Sentry \
         transport was still sending earlier data, or the metric had too many label sets."
    );

    describe_gauge!(
        "process.memory.rss_bytes",
        Unit::Bytes,
        "Memory zebrad is using, its resident set size. Only recorded on Linux."
    );
    describe_gauge!(
        "process.memory.rss_fraction",
        Unit::Count,
        "process.memory.rss_bytes as a fraction of the memory zebrad can use: the tightest \
         cgroup memory limit, or the machine's memory if that is smaller."
    );

    describe_sync();
    describe_gossip();
    describe_mempool();

    // zcashd compatibility mode
    describe_gauge!(
        "zcashd.compat.supervisor.active",
        Unit::Count,
        "1 while zebrad is supervising a zcashd child process, otherwise 0."
    );
    describe_gauge!(
        "zcashd.compat.supervisor.disabled",
        Unit::Count,
        "1 when zcashd supervision is turned off or has stopped, otherwise 0."
    );
    describe_gauge!(
        "zcashd.compat.supervisor.exhausted",
        Unit::Count,
        "1 when zcashd supervision stopped after too many restarts, otherwise 0."
    );
}

/// Describes the syncer's metrics.
fn describe_sync() {
    describe_histogram!(
        "sync.mined.block.announcement.duration_seconds",
        Unit::Seconds,
        "Time from a mined block's acceptance until its announcement to peers finished."
    );
    describe_counter!(
        "sync.mined.block.announcement.outcomes.total",
        Unit::Count,
        "Announcements of mined blocks to peers, by whether they finished or failed."
    );
    describe_counter!(
        "sync.restart.count",
        Unit::Count,
        "Sync rounds that ended, by why they ended and whether the state tip advanced."
    );
    describe_counter!(
        "sync.block.error.count",
        Unit::Count,
        "Block download and verify errors, by kind."
    );
    describe_histogram!(
        "sync.stage.duration_seconds",
        Unit::Seconds,
        "Time taken by each stage of a sync round."
    );
    describe_histogram!(
        "sync.obtain.response.hash.count",
        Unit::Count,
        "Block hashes in each peer response while obtaining tips."
    );
    describe_gauge!(
        "sync.obtain.queued.hash.count",
        Unit::Count,
        "Block hashes queued for download after obtaining tips."
    );
    describe_histogram!(
        "sync.extend.response.hash.count",
        Unit::Count,
        "Block hashes in each peer response while extending tips."
    );
    describe_gauge!(
        "sync.extend.queued.hash.count",
        Unit::Count,
        "Block hashes queued for download after extending tips."
    );
    describe_gauge!(
        "sync.prospective_tips.len",
        Unit::Count,
        "Chain tips the syncer is following."
    );
    describe_gauge!(
        "sync.downloads.in_flight",
        Unit::Count,
        "Blocks the syncer is downloading or verifying."
    );
    describe_gauge!(
        "sync.downloads.oldest_age_seconds",
        Unit::Seconds,
        "How long the oldest block still being downloaded or verified has waited, or 0 when none are."
    );
    describe_gauge!(
        "sync.estimated_network_tip_height",
        Unit::Count,
        "Estimated height of the network's chain tip."
    );
    describe_gauge!(
        "sync.estimated_distance_to_tip",
        Unit::Count,
        "Estimated number of blocks between the state tip and the network's chain tip."
    );
    describe_histogram!(
        "zcash.chain.tip.block_delay_seconds",
        Unit::Seconds,
        "Time from a block's header time until it became this node's best chain tip."
    );

    // Block downloads
    describe_histogram!(
        "sync.block.download.duration_seconds",
        Unit::Seconds,
        "Time taken to download a block during sync."
    );
    describe_histogram!(
        "sync.block.verify.duration_seconds",
        Unit::Seconds,
        "Time taken to verify a downloaded block during sync."
    );
    describe_counter!(
        "sync.downloaded.block.count",
        Unit::Count,
        "Blocks downloaded by the syncer."
    );
    describe_counter!(
        "sync.verified.block.count",
        Unit::Count,
        "Blocks verified after the syncer downloaded them."
    );
    describe_counter!(
        "sync.already.queued.dropped.block.hash.count",
        Unit::Count,
        "Block hashes the syncer ignored because they were already queued for download."
    );
    describe_counter!(
        "sync.already.rejected.dropped.block.hash.count",
        Unit::Count,
        "Block hashes the syncer ignored because a compact relay peer already sent that block, \
         and it failed validation after its early relay checks."
    );
    describe_counter!(
        "sync.no.height.dropped.block.count",
        Unit::Count,
        "Downloaded blocks dropped because they have no coinbase height."
    );
    describe_counter!(
        "sync.cancelled.download.count",
        Unit::Count,
        "Block downloads cancelled by a sync restart."
    );
    describe_counter!(
        "sync.cancelled.verify.ready.count",
        Unit::Count,
        "Block verifications cancelled while waiting for the verifier to be ready."
    );
    describe_counter!(
        "sync.cancelled.verify.count",
        Unit::Count,
        "Block verifications cancelled by a sync restart."
    );
    describe_counter!(
        "sync.max.height.limit.paused.count",
        Unit::Count,
        "Times downloads paused because the syncer got too far ahead of the state tip."
    );
    describe_counter!(
        "sync.max.height.limit.reset.count",
        Unit::Count,
        "Times downloads resumed after the state tip caught up with the syncer."
    );
    describe_counter!(
        "sync.max.height.limit.reset.attempt.count",
        Unit::Count,
        "Attempts to resume downloads after the state tip caught up with the syncer."
    );
}

/// Describes the metrics of blocks gossiped by peers.
fn describe_gossip() {
    describe_histogram!(
        "gossip.block.download.duration_seconds",
        Unit::Seconds,
        "Time taken to download a gossiped block, from the request to a successful response."
    );
    describe_histogram!(
        "gossip.block.verify_commit.duration_seconds",
        Unit::Seconds,
        "Time from sending a downloaded gossiped block to the block verifier until it was \
         committed."
    );
    describe_gauge!(
        "gossip.queued.block.count",
        Unit::Count,
        "Gossiped blocks queued for download and verification."
    );
    describe_counter!(
        "gossip.already.queued.dropped.block.hash.count",
        Unit::Count,
        "Gossiped block hashes ignored because they were already queued."
    );
    describe_counter!(
        "gossip.already.rejected.dropped.block.hash.count",
        Unit::Count,
        "Gossiped block hashes ignored because a compact relay peer already sent that block, \
         and it failed validation after its early relay checks."
    );
    describe_counter!(
        "gossip.full.queue.dropped.block.hash.count",
        Unit::Count,
        "Gossiped block hashes ignored because the download queue was full."
    );
    describe_counter!(
        "gossip.peer.limit.dropped.block.hash.count",
        Unit::Count,
        "Gossiped block hashes ignored because the peer already had a download in progress."
    );
    describe_counter!(
        "gossip.downloaded.block.count",
        Unit::Count,
        "Gossiped blocks downloaded."
    );
    describe_counter!(
        "gossip.verified.block.count",
        Unit::Count,
        "Gossiped blocks verified."
    );
    describe_counter!(
        "gossip.cancelled.count",
        Unit::Count,
        "Gossiped block downloads or verifications cancelled."
    );
    describe_counter!(
        "gossip.no.height.dropped.block.count",
        Unit::Count,
        "Gossiped blocks dropped because they have no coinbase height."
    );
    describe_counter!(
        "gossip.max.height.limit.dropped.block.count",
        Unit::Count,
        "Gossiped blocks dropped because they are too far above the state tip."
    );
    describe_counter!(
        "gossip.min.height.limit.dropped.block.count",
        Unit::Count,
        "Downloaded blocks dropped because they are behind the finalized tip."
    );
}

/// Describes the mempool's metrics.
fn describe_mempool() {
    describe_histogram!(
        "mempool.tip_cleanup.duration_seconds",
        Unit::Seconds,
        "Time taken to remove a new tip block's transactions and their conflicts from the mempool."
    );
    describe_histogram!(
        "mempool.expiry.duration_seconds",
        Unit::Seconds,
        "Time taken by each check of the mempool for expired transactions."
    );
    describe_gauge!(
        "mempool.currently.queued.transactions",
        Unit::Count,
        "Transactions queued for mempool download and verification."
    );
    describe_counter!(
        "mempool.queued.transactions.total",
        Unit::Count,
        "Transactions queued for mempool download and verification."
    );
    describe_counter!(
        "mempool.full_queue.per_peer.total",
        Unit::Count,
        "Transactions ignored because their peer already had too many queued."
    );
    describe_counter!(
        "mempool.downloaded.transactions.total",
        Unit::Count,
        "Transactions downloaded for the mempool, by transaction version."
    );
    describe_counter!(
        "mempool.pushed.transactions.total",
        Unit::Count,
        "Transactions submitted to the mempool directly, such as by RPC, by transaction version."
    );
    describe_counter!(
        "mempool.verified.transactions.total",
        Unit::Count,
        "Transactions verified for the mempool, by transaction version."
    );
    describe_counter!(
        "mempool.failed.verify.tasks.total",
        Unit::Count,
        "Mempool download and verify tasks that failed, by reason."
    );
    describe_counter!(
        "mempool.cancelled.verify.tasks.total",
        Unit::Count,
        "Mempool download and verify tasks cancelled."
    );
    describe_counter!(
        "mempool.gossiped.transactions.total",
        Unit::Count,
        "Mempool transaction IDs gossiped to peers."
    );
    describe_gauge!(
        "mempool.rejected.transaction.ids",
        Unit::Count,
        "Transaction IDs in the mempool's rejected lists."
    );
    describe_gauge!(
        "mempool.rejected.transaction.ids.bytes",
        Unit::Bytes,
        "Approximate memory used by the mempool's rejected lists."
    );
    describe_gauge!(
        "zcash.mempool.size.transactions",
        Unit::Count,
        "Transactions in the mempool."
    );
    describe_gauge!(
        "zcash.mempool.size.bytes",
        Unit::Bytes,
        "Serialized size of the transactions in the mempool."
    );
    describe_gauge!(
        "zcash.mempool.cost.bytes",
        Unit::Bytes,
        "Total ZIP-401 eviction cost of the transactions in the mempool."
    );
    describe_gauge!(
        "zcash.mempool.size.weighted",
        Unit::Bytes,
        "Serialized size of the mempool transactions in each fee weight ratio bucket."
    );
    describe_gauge!(
        "zcash.mempool.actions.unpaid",
        Unit::Count,
        "Unpaid actions in the mempool in each fee weight ratio bucket."
    );
    describe_gauge!(
        "zcash.mempool.actions.paid",
        Unit::Count,
        "Paid actions in the mempool."
    );
}