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
use crate::counters::CRITICAL_ERRORS;
use diem_crypto::HashValue;
use diem_logger::Schema;
use diem_state_view::StateViewId;
use diem_types::transaction::Version;
use serde::Serialize;
#[derive(Schema, Clone)]
pub struct AdapterLogSchema {
name: LogEntry,
block_id: Option<HashValue>,
first_version: Option<Version>,
base_version: Option<Version>,
txn_id: usize,
}
impl AdapterLogSchema {
pub fn new(view_id: StateViewId, txn_id: usize) -> Self {
match view_id {
StateViewId::BlockExecution { block_id } => Self {
name: LogEntry::Execution,
block_id: Some(block_id),
first_version: None,
base_version: None,
txn_id,
},
StateViewId::ChunkExecution { first_version } => Self {
name: LogEntry::Execution,
block_id: None,
first_version: Some(first_version),
base_version: None,
txn_id,
},
StateViewId::TransactionValidation { base_version } => Self {
name: LogEntry::Validation,
block_id: None,
first_version: None,
base_version: Some(base_version),
txn_id,
},
StateViewId::Miscellaneous => Self {
name: LogEntry::Miscellaneous,
block_id: None,
first_version: None,
base_version: None,
txn_id,
},
}
}
pub fn alert(&self) {
CRITICAL_ERRORS.inc();
}
}
#[derive(Clone, Copy, Serialize)]
#[serde(rename_all = "snake_case")]
pub enum LogEntry {
Execution,
Validation,
Miscellaneous, }