-
Notifications
You must be signed in to change notification settings - Fork 5
/
blockchain.proto
473 lines (394 loc) · 8.43 KB
/
blockchain.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
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
syntax = "proto3";
//package types;
//option go_package = "github.com/aergoio/aergo/types";
message Block {
bytes hash = 1;
BlockHeader header = 2;
BlockBody body = 3;
}
message BlockHeader {
bytes chainID = 1; // chain identifier
bytes prevBlockHash = 2; // hash of previous block
uint64 blockNo = 3; // block number
int64 timestamp = 4; // block creation time stamp
bytes blocksRootHash = 5; // hash of root of block merkle tree
bytes txsRootHash = 6; // hash of root of transaction merkle tree
bytes receiptsRootHash = 7; // hash of root of receipt merkle tree
uint64 confirms = 8; // number of blocks this block is able to confirm
bytes pubKey = 9; // block producer's public key
bytes coinbaseAccount = 10; // address of account to receive fees
bytes sign = 11; // block producer's signature of BlockHeader
bytes consensus = 12; // consensus meta
// CAUTION: WHENEVER A NEW FIELD ADDED HERE, types.lastFieldOfBH MUST BE
// REPLACE BY IT.
}
message BlockBody {
repeated Tx txs = 1;
}
message TxList {
repeated Tx txs = 1;
}
enum TxType {
NORMAL = 0;
GOVERNANCE = 1;
REDEPLOY = 2;
FEEDELEGATION = 3;
TRANSFER = 4;
CALL = 5;
DEPLOY = 6;
}
message Tx {
bytes hash = 1;
bytes body = 2; // TxBody
}
message TxBody {
uint64 nonce = 1; // increasing number used only once per sender account
bytes account = 2; // decoded account address
bytes recipient = 3; // decoded account address
bytes amount = 4; // variable-length big integer
bytes payload = 5;
uint64 gasLimit = 6; // maximum gas used for this transaction. 0 = no limit
bytes gasPrice = 7; // variable-length big integer. currently not used
TxType type = 8;
bytes chainIdHash = 9; // hash value of chain identifier in the block
bytes sign = 10; // sender's signature for this TxBody
}
// TxIdx specifies a transaction's block hash and index within the block body
message TxIdx {
bytes blockHash = 1;
int32 idx = 2;
}
message TxInBlock {
TxIdx txIdx = 1;
Tx tx = 2;
}
message State {
uint64 nonce = 1;
bytes balance = 2;
bytes codeHash = 3;
bytes storageRoot = 4;
uint64 sqlRecoveryPoint = 5;
}
message AccountProof {
State state = 1;
bool inclusion = 2;
bytes key = 3;
bytes proofKey = 4;
bytes proofVal = 5;
bytes bitmap = 6;
uint32 height = 7;
repeated bytes auditPath = 8;
}
message ContractVarProof{
bytes value = 1;
bool inclusion = 2;
reserved 3;
bytes proofKey = 4;
bytes proofVal = 5;
bytes bitmap = 6;
uint32 height = 7;
repeated bytes auditPath = 8;
bytes key = 9;
}
message StateQueryProof {
AccountProof contractProof = 1;
repeated ContractVarProof varProofs = 2;
}
message Receipt {
bytes contractAddress = 1;
string status = 2;
string ret = 3;
bytes txHash = 4;
bytes feeUsed = 5;
bytes cumulativeFeeUsed = 6;
bytes bloom = 7;
repeated Event events = 8;
uint64 blockNo = 9;
bytes blockHash = 10;
int32 txIndex = 11;
bytes from = 12;
bytes to = 13;
bool feeDelegation = 14;
uint64 gasUsed = 15;
}
message Event {
bytes contractAddress = 1;
string eventName = 2;
string jsonArgs = 3;
int32 eventIdx = 4;
bytes txHash = 5;
bytes blockHash = 6;
uint64 blockNo = 7;
int32 txIndex = 8;
}
message FnArgument {
string name = 1;
}
message Function {
string name = 1;
repeated FnArgument arguments = 2;
bool payable = 3;
bool view = 4;
bool fee_delegation = 5;
}
message StateVar {
string name = 1;
string type = 2;
int32 len = 3;
}
message ABI {
string version = 1;
string language = 2;
repeated Function functions = 3;
repeated StateVar state_variables = 4;
}
message Query {
bytes contractAddress = 1;
bytes queryinfo= 2;
}
message StateQuery {
bytes contractAddress = 1;
reserved 2;
bytes root = 3;
bool compressed = 4;
repeated bytes storageKeys = 5;
}
message FilterInfo {
bytes contractAddress = 1;
string eventName = 2;
uint64 blockfrom = 3;
uint64 blockto = 4;
bool desc = 5;
bytes argFilter = 6;
int32 recentBlockCnt = 7;
}
message Proposal {
string id = 1;
string description = 3;
uint32 multipleChoice = 6;
}
//// from account.proto: ///////////////////////////////////////////////////////
message Account {
bytes address = 1;
}
message AccountList {
repeated Account accounts = 1;
}
//// from rpc.proto: ///////////////////////////////////////////////////////
// BlockchainStatus is current status of blockchain
message BlockchainStatus {
bytes best_block_hash = 1;
uint64 best_height = 2;
string consensus_info = 3;
bytes best_chain_id_hash = 4;
ChainInfo chain_info = 5;
}
message ChainId {
string magic = 1;
bool is_public = 2;
bool mainnet = 3;
string consensus = 4;
int32 version = 5;
}
// ChainInfo returns chain configuration
message ChainInfo {
ChainId id = 1;
uint32 bpNumber = 2;
uint64 maxblocksize = 3;
bytes maxtokens = 4;
bytes stakingminimum = 5;
bytes totalstaking = 6;
bytes gasprice = 7;
bytes nameprice = 8;
bytes totalvotingpower = 9;
bytes votingreward= 10;
}
// ChainStats corresponds to a chain statistics report.
message ChainStats {
string report = 1;
}
message Input {
bytes hash = 1;
repeated bytes address = 2;
bytes value = 3;
bytes script = 4;
}
message Output {
uint32 index = 1;
bytes address = 2;
bytes value = 3;
bytes script = 4;
}
message Empty {
}
message SingleBytes {
bytes value = 1;
}
message SingleString {
string value = 1;
}
message AccountAddress {
bytes value = 1;
}
message AccountAndRoot {
bytes Account = 1;
bytes Root = 2;
bool Compressed = 3;
}
/*
message Peer {
PeerAddress address = 1;
NewBlockNotice bestblock = 2;
int32 state = 3;
bool hidden = 4;
int64 lashCheck = 5;
bool selfpeer = 6;
string version = 7;
repeated AgentCertificate certificates = 8;
PeerRole acceptedRole = 9;
}
message PeerList {
repeated Peer peers=1;
}
*/
message ListParams {
bytes hash = 1;
uint64 height = 2;
uint32 size = 3;
uint32 offset = 4;
bool asc = 5;
}
message PageParams {
uint32 offset = 1;
uint32 size = 2;
}
message BlockBodyPaged {
uint32 total = 1;
uint32 offset = 2;
uint32 size = 3;
BlockBody body = 4;
}
message BlockBodyParams {
bytes hashornumber = 1;
PageParams paging = 2;
}
message BlockHeaderList {
repeated Block blocks = 1;
}
message BlockMetadata {
bytes hash = 1;
BlockHeader header = 2;
int32 txcount = 3;
int64 size = 4; // blocksize in bytes
}
message BlockMetadataList {
repeated BlockMetadata blocks = 1;
}
enum CommitStatus {
TX_OK = 0;
TX_NONCE_TOO_LOW = 1;
TX_ALREADY_EXISTS = 2;
TX_INVALID_HASH = 3;
TX_INVALID_SIGN = 4;
TX_INVALID_FORMAT = 5;
TX_INSUFFICIENT_BALANCE = 6;
TX_HAS_SAME_NONCE= 7;
TX_INTERNAL_ERROR = 9;
}
message CommitResult {
bytes hash = 1;
CommitStatus error = 2;
string detail = 3;
}
// ATTENTION: the 'repeated' keyword was removed here, just for C
message CommitResultList {
CommitResult results = 1;
}
enum VerifyStatus {
VERIFY_STATUS_OK = 0;
VERIFY_STATUS_SIGN_NOT_MATCH = 1;
VERIFY_STATUS_INVALID_HASH = 2; //TODO: not yet impl
}
message VerifyResult {
Tx tx = 1;
VerifyStatus error = 2;
}
message Personal {
string passphrase = 1;
Account account = 2;
}
message ImportFormat{
SingleBytes wif = 1;
string oldpass = 2;
string newpass = 3;
SingleBytes keystore = 4;
}
message Staking {
bytes amount = 1;
uint64 when = 2;
}
message Vote {
bytes candidate = 1;
bytes amount = 2;
}
message VoteParams {
string id = 1;
uint32 count = 2;
}
message AccountVoteInfo {
Staking staking = 1;
repeated VoteInfo voting = 2;
}
message VoteInfo {
string id = 1;
repeated string candidates = 2;
string amount = 3;
}
message VoteList {
repeated Vote votes = 1;
string id = 2;
}
message NodeReq {
bytes timeout = 1;
bytes component = 2;
}
message Name {
string name = 1;
uint64 blockNo = 2;
}
message NameInfo {
Name name = 1;
bytes owner = 2;
bytes destination = 3;
}
message PeersParams {
bool noHidden = 1;
bool showSelf = 2;
}
message KeyParams {
repeated string key = 1;
}
message ServerInfo {
map<string,string> status = 1;
map<string,ConfigItem> config = 2;
}
message ConfigItem {
map<string,string> props = 2;
}
message EventList {
repeated Event events = 1;
}
// info and bps is json string
message ConsensusInfo {
string type = 1;
string info = 2;
repeated string bps = 3;
}
message EnterpriseConfigKey {
string key = 1;
}
message EnterpriseConfig {
string key = 1;
bool on = 2;
repeated string values = 3;
}