-
Notifications
You must be signed in to change notification settings - Fork 57
/
Copy pathwitnet.proto
456 lines (394 loc) · 10.9 KB
/
witnet.proto
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
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
syntax = "proto3";
package witnet;
message LegacyMessage {
message LegacyCommand {
oneof kind {
Version Version = 1;
Verack Verack = 2;
GetPeers GetPeers = 3;
Peers Peers = 4;
LegacyBlock Block = 5;
InventoryAnnouncement InventoryAnnouncement = 6;
InventoryRequest InventoryRequest = 7;
LastBeacon LastBeacon = 8;
Transaction Transaction = 9;
SuperBlockVote SuperBlockVote = 10;
SuperBlock SuperBlock = 11;
}
}
// uint32 is not a fixed-size 32 bit integer: it uses variable length encoding
uint32 magic = 1;
LegacyCommand kind = 2;
}
message Message {
message Command {
oneof kind {
Version Version = 1;
Verack Verack = 2;
GetPeers GetPeers = 3;
Peers Peers = 4;
Block Block = 5;
InventoryAnnouncement InventoryAnnouncement = 6;
InventoryRequest InventoryRequest = 7;
LastBeacon LastBeacon = 8;
Transaction Transaction = 9;
SuperBlockVote SuperBlockVote = 10;
SuperBlock SuperBlock = 11;
}
}
// uint32 is not a fixed-size 32 bit integer: it uses variable length encoding
uint32 magic = 1;
Command kind = 2;
}
message Version {
uint32 version = 1;
int64 timestamp = 2;
fixed64 capabilities = 3;
Address sender_address = 4;
Address receiver_address = 5;
string user_agent = 6;
fixed64 nonce = 7;
LastBeacon beacon = 8;
}
message Verack {
// Intentionally empty
}
message GetPeers {
// Intentionally empty
}
message Peers {
repeated Address peers = 1;
}
message BlockEligibilityClaim {
VrfProof proof = 1;
}
message LegacyBlock {
message LegacyBlockHeader {
message LegacyBlockMerkleRoots {
Hash mint_hash = 1;
Hash vt_hash_merkle_root = 2;
Hash dr_hash_merkle_root = 3;
Hash commit_hash_merkle_root = 4;
Hash reveal_hash_merkle_root = 5;
Hash tally_hash_merkle_root = 6;
}
uint32 signals = 1;
CheckpointBeacon beacon = 2;
LegacyBlockMerkleRoots merkle_roots = 3;
BlockEligibilityClaim proof = 4;
Bn256PublicKey bn256_public_key = 5;
}
message LegacyBlockTransactions {
MintTransaction mint = 1;
repeated VTTransaction value_transfer_txns = 2;
repeated DRTransaction data_request_txns = 3;
repeated CommitTransaction commit_txns = 4;
repeated RevealTransaction reveal_txns = 5;
repeated TallyTransaction tally_txns = 6;
}
LegacyBlockHeader block_header = 1;
KeyedSignature block_sig = 2;
LegacyBlockTransactions txns = 3;
}
message Block {
message BlockHeader {
message BlockMerkleRoots {
Hash mint_hash = 1;
Hash vt_hash_merkle_root = 2;
Hash dr_hash_merkle_root = 3;
Hash commit_hash_merkle_root = 4;
Hash reveal_hash_merkle_root = 5;
Hash tally_hash_merkle_root = 6;
Hash stake_hash_merkle_root = 7;
Hash unstake_hash_merkle_root = 8;
}
uint32 signals = 1;
CheckpointBeacon beacon = 2;
BlockMerkleRoots merkle_roots = 3;
BlockEligibilityClaim proof = 4;
Bn256PublicKey bn256_public_key = 5;
}
message BlockTransactions {
MintTransaction mint = 1;
repeated VTTransaction value_transfer_txns = 2;
repeated DRTransaction data_request_txns = 3;
repeated CommitTransaction commit_txns = 4;
repeated RevealTransaction reveal_txns = 5;
repeated TallyTransaction tally_txns = 6;
repeated StakeTransaction stake_txns = 7;
repeated UnstakeTransaction unstake_txns = 8;
}
BlockHeader block_header = 1;
KeyedSignature block_sig = 2;
BlockTransactions txns = 3;
}
message SuperBlock {
uint32 signing_committee_length = 1;
Hash ars_root = 2;
Hash data_request_root = 3;
uint32 index = 4;
Hash last_block = 5;
Hash last_block_in_previous_superblock = 6;
Hash tally_root = 7;
}
message InventoryAnnouncement {
repeated InventoryEntry inventory = 1;
}
message InventoryRequest {
repeated InventoryEntry inventory = 1;
}
message LastBeacon {
CheckpointBeacon highest_block_checkpoint = 1;
CheckpointBeacon highest_superblock_checkpoint = 2;
}
message OutputPointer {
Hash transaction_id = 1;
uint32 output_index = 2;
}
message ValueTransferOutput {
PublicKeyHash pkh = 1;
uint64 value = 2;
uint64 time_lock = 3;
}
message DataRequestOutput {
message RADRequest {
enum RADType {
Unknown = 0;
HttpGet = 1;
Rng = 2;
HttpPost = 3;
HttpHead = 4;
}
message RADFilter {
uint32 op = 1;
bytes args = 2;
}
message RADRetrieve {
RADType kind = 1;
string url = 2;
// TODO: RADScript should maybe be a type?
bytes script = 3;
// Body of HTTP-POST request
bytes body = 4;
// Extra headers for HTTP-GET, HTTP-HEAD and HTTP-POST requests
repeated StringPair headers = 5;
}
message RADAggregate {
repeated RADFilter filters = 1;
uint32 reducer = 2;
}
message RADTally {
repeated RADFilter filters = 1;
uint32 reducer = 2;
}
uint64 time_lock = 1;
repeated RADRetrieve retrieve = 2;
RADAggregate aggregate = 3;
RADTally tally = 4;
}
RADRequest data_request = 1;
uint64 witness_reward = 2;
uint32 witnesses = 3;
uint64 commit_and_reveal_fee = 4;
uint32 min_consensus_percentage = 5;
uint64 collateral = 6;
}
message StringPair {
string left = 1;
string right = 2;
}
message Input {
OutputPointer output_pointer = 1;
}
// Transaction types
message VTTransactionBody {
repeated Input inputs = 1;
repeated ValueTransferOutput outputs = 2;
}
message VTTransaction {
VTTransactionBody body = 1;
repeated KeyedSignature signatures = 2;
}
message DRTransactionBody {
repeated Input inputs = 1;
repeated ValueTransferOutput outputs = 2;
DataRequestOutput dr_output = 3;
}
message DRTransaction {
DRTransactionBody body = 1;
repeated KeyedSignature signatures = 2;
}
message CommitTransactionBody {
Hash dr_pointer = 1;
Hash commitment = 2;
DataRequestEligibilityClaim proof = 3;
repeated Input collateral = 4;
repeated ValueTransferOutput outputs = 5;
Bn256PublicKey bn256_public_key = 6;
}
message CommitTransaction {
CommitTransactionBody body = 1;
repeated KeyedSignature signatures = 2;
}
message RevealTransactionBody {
Hash dr_pointer = 1;
bytes reveal = 2;
PublicKeyHash pkh = 3;
}
message RevealTransaction {
RevealTransactionBody body = 1;
repeated KeyedSignature signatures = 2;
}
message TallyTransaction {
Hash dr_pointer = 1;
bytes tally = 2;
repeated ValueTransferOutput outputs = 3;
repeated PublicKeyHash out_of_consensus = 4;
repeated PublicKeyHash error_committers = 5;
}
message MintTransaction {
// The epoch field is used to ensure that each MintTransaction has a unique hash
fixed32 epoch = 1;
repeated ValueTransferOutput outputs = 2;
}
message StakeKey {
PublicKeyHash validator = 1;
PublicKeyHash withdrawer = 2;
}
message StakeOutput {
uint64 value = 1;
StakeKey key = 2;
KeyedSignature authorization = 3;
}
message StakeTransactionBody {
repeated Input inputs = 1;
StakeOutput output = 2;
ValueTransferOutput change = 3;
}
message StakeTransaction {
StakeTransactionBody body = 1 ;
repeated KeyedSignature signatures = 2;
}
message UnstakeTransactionBody {
PublicKeyHash operator = 1;
ValueTransferOutput withdrawal = 2;
uint64 fee = 3;
uint64 nonce = 4;
}
message UnstakeTransaction {
UnstakeTransactionBody body = 1 ;
KeyedSignature signature = 2;
}
message Transaction {
oneof kind {
VTTransaction ValueTransfer = 1;
DRTransaction DataRequest = 2;
CommitTransaction Commit = 3;
RevealTransaction Reveal = 4;
TallyTransaction Tally = 5;
MintTransaction Mint = 6;
StakeTransaction Stake = 7;
UnstakeTransaction Unstake = 8;
}
}
// Helper structures (not meant to be sent directly as messages)
message Hash {
oneof kind {
bytes SHA256 = 1;
}
}
message Secp256k1Signature {
bytes der = 1;
}
message Signature {
oneof kind {
Secp256k1Signature Secp256k1 = 1;
}
}
message Bn256Signature {
bytes signature = 1;
}
message PublicKey {
bytes public_key = 1;
}
message Bn256PublicKey {
bytes public_key = 1;
}
message PublicKeyHash {
bytes hash = 1;
}
message KeyedSignature {
Signature signature = 1;
PublicKey public_key = 2;
}
message Bn256KeyedSignature {
Bn256Signature signature = 1;
Bn256PublicKey public_key = 2;
}
message Address {
bytes address = 1;
}
message CheckpointBeacon {
fixed32 checkpoint = 1;
Hash hash_prev_block = 2;
}
message CheckpointVRF {
fixed32 checkpoint = 1;
Hash hash_prev_vrf = 2;
}
message InventoryEntry {
oneof kind {
Hash Block = 1;
Hash Tx = 2;
uint32 SuperBlock = 3;
}
}
message ConsensusConstants {
int64 checkpoint_zero_timestamp = 1;
uint32 checkpoints_period = 2;
Hash bootstrap_hash = 3;
Hash genesis_hash = 4;
uint32 max_vt_weight = 5;
uint32 max_dr_weight = 6;
uint32 activity_period = 7;
uint32 reputation_expire_alpha_diff = 8;
uint32 reputation_issuance = 9;
uint32 reputation_issuance_stop = 10;
double reputation_penalization_factor = 11;
uint32 mining_backup_factor = 12;
uint32 mining_replication_factor = 13;
uint64 collateral_minimum = 14;
uint32 collateral_age = 15;
uint32 superblock_period = 16;
uint32 extra_rounds = 17;
uint32 minimum_difficulty = 18;
uint32 epochs_with_minimum_difficulty = 19;
repeated string bootstrapping_committee = 20;
uint32 superblock_signing_committee_size = 21;
uint32 superblock_committee_decreasing_period = 22;
uint32 superblock_committee_decreasing_step = 23;
uint64 initial_block_reward = 24;
uint32 halving_period = 25;
}
message ConsensusConstantsWit2 {
int64 checkpoint_zero_timestamp = 1;
uint32 checkpoints_period = 2;
}
message VrfProof {
bytes proof = 1;
PublicKey public_key = 2;
}
message DataRequestVrfMessage {
CheckpointVRF vrf_input = 1;
Hash dr_hash = 2;
PublicKeyHash withdrawer = 3;
}
message DataRequestEligibilityClaim {
VrfProof proof = 1;
}
message SuperBlockVote {
Bn256Signature bn256_signature = 1;
KeyedSignature secp256k1_signature = 2;
Hash superblock_hash = 3;
fixed32 superblock_index = 4;
}