forked from gobitfly/eth2-beaconchain-explorer
-
Notifications
You must be signed in to change notification settings - Fork 2
/
tables.sql
232 lines (216 loc) · 7.23 KB
/
tables.sql
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
/*
Lookup table to store the index - pubkey association
In order to save db space we only use the unique validator index in all other tables
In the future it is better to replace this table with an in memory cache (redis)
*/
drop table if exists validators;
create table validators (
validatorindex int not null,
pubkey bytea not null,
primary key (validatorindex)
);
create index idx_validators_pubkey on validators (pubkey);
drop table if exists validator_set;
create table validator_set (
epoch int not null,
validatorindex int not null,
withdrawableepoch bigint not null,
withdrawalcredentials bytea not null,
effectivebalance bigint not null,
slashed bool not null,
activationeligibilityepoch bigint not null,
activationepoch bigint not null,
exitepoch bigint not null,
primary key (validatorindex, epoch)
);
-- drop table if exists validator_assignments;
-- create table validator_assignments (
-- epoch int not null,
-- validatorindex int not null,
-- beaconcommittees int[] not null,
-- committeeindex int not null,
-- attesterslot int not null,
-- proposerslot int not null,
-- primary key (epoch, validatorindex)
-- );
drop table if exists proposal_assignments;
create table proposal_assignments (
epoch int not null,
validatorindex int not null,
proposerslot int not null,
status int not null, /* Can be 0 = scheduled, 1 executed, 2 missed */
primary key (epoch, validatorindex, proposerslot)
);
drop table if exists attestation_assignments;
create table attestation_assignments (
epoch int not null,
validatorindex int not null,
attesterslot int not null,
committeeindex int not null,
status int not null, /* Can be 0 = scheduled, 1 executed, 2 missed */
primary key (epoch, validatorindex, attesterslot, committeeindex)
);
drop table if exists beacon_committees;
create table beacon_committees (
epoch int not null,
slot int not null,
slotindex int not null,
indices int[] not null,
primary key (epoch, slot, slotindex)
);
drop table if exists validator_balances;
create table validator_balances (
epoch int not null,
validatorindex int not null,
balance bigint not null,
primary key (validatorindex, epoch)
);
drop table if exists attestationpool;
create table attestationpool (
aggregationbits bytea not null,
custodybits bytea not null,
signature bytea not null,
slot int not null,
index int not null,
beaconblockroot bytea not null,
source_epoch int not null,
source_root bytea not null,
target_epoch int not null,
target_root bytea not null,
primary key (slot, index)
);
drop table if exists validatorqueue_activation;
create table validatorqueue_activation (
index int not null,
publickey bytea not null,
primary key (index, publickey)
);
drop table if exists validatorqueue_exit;
create table validatorqueue_exit (
index int not null,
publickey bytea not null,
primary key (index, publickey)
);
drop table if exists epochs;
create table epochs (
epoch int not null,
blockscount int not null default 0,
proposerslashingscount int not null,
attesterslashingscount int not null,
attestationscount int not null,
depositscount int not null,
voluntaryexitscount int not null,
validatorscount int not null,
averagevalidatorbalance bigint not null,
finalized bool,
eligibleether bigint,
globalparticipationrate float,
votedether bigint,
primary key (epoch)
);
drop table if exists blocks;
create table blocks (
epoch int not null,
slot int not null,
blockroot bytea not null,
parentroot bytea not null,
stateroot bytea not null,
signature bytea not null,
randaoreveal bytea not null,
graffiti bytea not null,
eth1data_depositroot bytea not null,
eth1data_depositcount int not null,
eth1data_blockhash bytea not null,
proposerslashingscount int not null,
attesterslashingscount int not null,
attestationscount int not null,
depositscount int not null,
voluntaryexitscount int not null,
proposer int not null,
status text not null,
primary key (slot, blockroot)
);
create index idx_blocks_proposer on blocks (proposer);
drop table if exists blocks_proposerslashings;
create table blocks_proposerslashings (
block_slot int not null,
block_index int not null,
proposerindex int not null,
header1_slot int not null,
header1_parentroot bytea not null,
header1_stateroot bytea not null,
header1_bodyroot bytea not null,
header1_signature bytea not null,
header2_slot int not null,
header2_parentroot bytea not null,
header2_stateroot bytea not null,
header2_bodyroot bytea not null,
header2_signature bytea not null,
primary key (block_slot, block_index)
);
drop table if exists blocks_attesterslashings;
create table blocks_attesterslashings (
block_slot int not null,
block_index int not null,
attestation1_custodybit_0indices int[] not null,
attestation1_custodybit_1indices int[] not null,
attestation1_signature bytea not null,
attestation1_slot int not null,
attestation1_index int not null,
attestation1_beaconblockroot bytea not null,
attestation1_source_epoch int not null,
attestation1_source_root bytea not null,
attestation1_target_epoch int not null,
attestation1_target_root bytea not null,
attestation2_custodybit_0indices int[] not null,
attestation2_custodybit_1indices int[] not null,
attestation2_signature bytea not null,
attestation2_slot int not null,
attestation2_index int not null,
attestation2_beaconblockroot bytea not null,
attestation2_source_epoch int not null,
attestation2_source_root bytea not null,
attestation2_target_epoch int not null,
attestation2_target_root bytea not null,
primary key (block_slot, block_index)
);
drop table if exists blocks_attestations;
create table blocks_attestations (
block_slot int not null,
block_index int not null,
aggregationbits bytea not null,
validators int[] not null,
custodybits bytea not null,
signature bytea not null,
slot int not null,
committeeindex int not null,
beaconblockroot bytea not null,
source_epoch int not null,
source_root bytea not null,
target_epoch int not null,
target_root bytea not null,
primary key (block_slot, block_index)
);
create index idx_blocks_attestations_beaconblockroot on blocks_attestations (beaconblockroot);
create index idx_blocks_attestations_source_root on blocks_attestations (source_root);
create index idx_blocks_attestations_target_root on blocks_attestations (target_root);
drop table if exists blocks_deposits;
create table blocks_deposits (
block_slot int not null,
block_index int not null,
proof bytea[],
publickey bytea not null,
withdrawalcredentials bytea not null,
amount bigint not null,
signature bytea not null,
primary key (block_slot, block_index)
);
drop table if exists blocks_voluntaryexits;
create table blocks_voluntaryexits (
block_slot int not null,
block_index int not null,
epoch int not null,
validatorindex int not null,
signature bytea not null,
primary key (block_slot, block_index)
);