-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathtrace.rust.d.ts
113 lines (99 loc) · 2.63 KB
/
trace.rust.d.ts
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
/** Rust simulation trace format */
// Base types
interface RustBaseEvent {
time_s: number;
message: {
type: string;
[key: string]: any;
};
}
interface RustTaskInfo {
node: string;
index: number;
}
// CPU Events
type BlockOrTaskType =
| "RBBlock"
| "EBBlock"
| "VTBundle"
| "IBBlock"
| "Transaction";
type Action = "Validated" | "Generated";
type RustCpuTaskType = `${BlockOrTaskType}${Action}`;
type CpuTaskPrefix = "CpuTask" | "CpuSubtask";
type CpuTaskAction = "Scheduled" | "Started" | "Finished";
type RustCpuMessageType = `${CpuTaskPrefix}${CpuTaskAction}`;
interface RustCpuEvent extends Omit<RustBaseEvent, "message"> {
message: {
type: RustCpuMessageType;
task: RustTaskInfo;
task_type?: RustCpuTaskType;
subtasks?: number;
subtask_id?: number;
duration_s?: number;
cpu_time_s?: number;
extra?: string;
};
}
// Block Events
interface RustBaseBlockEvent {
id?: string;
slot: number;
producer: string;
sender?: string;
recipient?: string;
}
type BlockType = "IB" | "EB" | "RB";
type BlockAction = "Sent" | "Received" | "LotteryWon" | "Generated";
type RustBlockMessageType = `${BlockType}${BlockAction}`;
interface RustBlockEvent extends Omit<RustBaseEvent, "message"> {
message: RustBaseBlockEvent & {
type: RustBlockMessageType;
index?: number;
header_bytes?: number;
transactions?: string[];
vrf?: number;
endorsement?: any;
};
}
// Transaction Events
type TransactionAction = "Sent" | "Received" | "Generated";
type RustTransactionMessageType = `Transaction${TransactionAction}`;
interface RustTransactionEvent extends Omit<RustBaseEvent, "message"> {
message: {
type: RustTransactionMessageType;
id: string;
sender?: string;
recipient?: string;
publisher?: string;
bytes?: number;
};
}
// Vote Events
type VoteAction = "Received" | "Sent" | "Generated" | "LotteryWon";
type RustVoteMessageType = `Votes${VoteAction}`;
interface RustVoteEvent extends Omit<RustBaseEvent, "message"> {
message: {
type: RustVoteMessageType;
id: string;
slot: number;
producer: string;
sender?: string;
recipient?: string;
votes?: Record<string, number>;
};
}
// Slot Event
interface RustSlotEvent extends Omit<RustBaseEvent, "message"> {
message: {
type: "Slot";
number: number;
};
}
// Combined type
export type RustTraceEvent =
| RustCpuEvent
| RustBlockEvent
| RustTransactionEvent
| RustVoteEvent
| RustSlotEvent;