Skip to content

Commit 7ce0210

Browse files
author
Matthieu Vachon
authored
Updated protobuf to latest version for NEAR (#2947)
* Updated protobuf to latest version for NEAR * Fixed tests with latest protobuf
1 parent 8cae63a commit 7ce0210

File tree

6 files changed

+408
-365
lines changed

6 files changed

+408
-365
lines changed

chain/near/proto/codec.proto

Lines changed: 109 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,21 @@ syntax = "proto3";
22

33
package sf.near.codec.v1;
44

5-
message BlockWrapper {
6-
Block block = 1;
7-
repeated IndexerShard shards = 2;
8-
repeated StateChangeWithCause state_changes = 3;
5+
option go_package = "github.com/streamingfast/sf-near/pb/sf/near/codec/v1;pbcodec";
6+
7+
message Block {
8+
string author = 1;
9+
BlockHeader header = 2;
10+
repeated ChunkHeader chunk_headers = 3;
11+
repeated IndexerShard shards = 4;
12+
repeated StateChangeWithCause state_changes = 5;
913
}
1014

1115
message StateChangeWithCause {
12-
StateChangeCause cause = 1;
13-
StateChangeValue value = 2;
16+
StateChangeValue value = 1;
17+
StateChangeCause cause = 2;
1418
}
1519

16-
1720
message StateChangeCause {
1821
oneof cause {
1922
NotWritableToDisk not_writable_to_disk = 1;
@@ -27,18 +30,18 @@ message StateChangeCause {
2730
ValidatorAccountsUpdate validator_accounts_update = 9;
2831
Migration migration = 10;
2932
}
30-
}
3133

32-
message NotWritableToDisk {}
33-
message InitialState {}
34-
message TransactionProcessing {CryptoHash tx_hash = 1;}
35-
message ActionReceiptProcessingStarted {CryptoHash receipt_hash = 1;}
36-
message ActionReceiptGasReward {CryptoHash tx_hash = 1;}
37-
message ReceiptProcessing {CryptoHash tx_hash = 1;}
38-
message PostponedReceipt {CryptoHash tx_hash = 1;}
39-
message UpdatedDelayedReceipts {}
40-
message ValidatorAccountsUpdate {}
41-
message Migration {}
34+
message NotWritableToDisk {}
35+
message InitialState {}
36+
message TransactionProcessing {CryptoHash tx_hash = 1;}
37+
message ActionReceiptProcessingStarted {CryptoHash receipt_hash = 1;}
38+
message ActionReceiptGasReward {CryptoHash tx_hash = 1;}
39+
message ReceiptProcessing {CryptoHash tx_hash = 1;}
40+
message PostponedReceipt {CryptoHash tx_hash = 1;}
41+
message UpdatedDelayedReceipts {}
42+
message ValidatorAccountsUpdate {}
43+
message Migration {}
44+
}
4245

4346
message StateChangeValue {
4447
oneof value {
@@ -51,51 +54,43 @@ message StateChangeValue {
5154
ContractCodeUpdate contract_code_update = 7;
5255
ContractCodeDeletion contract_deletion = 8;
5356
}
54-
}
5557

56-
message AccountUpdate {string account_id = 1; Account account = 2;}
57-
message AccountDeletion {string account_id = 1;}
58-
message AccessKeyUpdate {
59-
string account_id = 1;
60-
PublicKey public_key = 2;
61-
AccessKey access_key = 3;
62-
}
63-
message AccessKeyDeletion {
64-
string account_id = 1;
65-
PublicKey public_key = 2;
66-
}
67-
message DataUpdate {
68-
string account_id = 1;
69-
bytes key = 2;
70-
bytes value = 3;
71-
}
72-
message DataDeletion {
73-
string account_id = 1;
74-
bytes key = 2;
75-
}
76-
message ContractCodeUpdate {
77-
string account_id = 1;
78-
bytes code = 2;
79-
}
80-
message ContractCodeDeletion {
81-
string account_id = 1;
58+
message AccountUpdate {string account_id = 1; Account account = 2;}
59+
message AccountDeletion {string account_id = 1;}
60+
message AccessKeyUpdate {
61+
string account_id = 1;
62+
PublicKey public_key = 2;
63+
AccessKey access_key = 3;
64+
}
65+
message AccessKeyDeletion {
66+
string account_id = 1;
67+
PublicKey public_key = 2;
68+
}
69+
message DataUpdate {
70+
string account_id = 1;
71+
bytes key = 2;
72+
bytes value = 3;
73+
}
74+
message DataDeletion {
75+
string account_id = 1;
76+
bytes key = 2;
77+
}
78+
message ContractCodeUpdate {
79+
string account_id = 1;
80+
bytes code = 2;
81+
}
82+
message ContractCodeDeletion {
83+
string account_id = 1;
84+
}
8285
}
8386

84-
85-
8687
message Account {
8788
BigInt amount = 1;
8889
BigInt locked = 2;
8990
CryptoHash code_hash = 3;
9091
uint64 storage_usage = 4;
9192
}
9293

93-
message Block {
94-
string author = 1;
95-
BlockHeader header = 2;
96-
repeated ChunkHeader chunks = 3;
97-
}
98-
9994
message BlockHeader {
10095
uint64 height = 1;
10196
uint64 prev_height = 2;
@@ -117,17 +112,18 @@ message BlockHeader {
117112
repeated bool chunk_mask = 18;
118113
BigInt gas_price = 19;
119114
uint64 block_ordinal = 20;
120-
BigInt validator_reward = 21;
121-
BigInt total_supply = 22;
122-
repeated SlashedValidator challenges_result = 23;
115+
BigInt total_supply = 21;
116+
repeated SlashedValidator challenges_result = 22;
117+
uint64 last_final_block_height = 23;
123118
CryptoHash last_final_block = 24;
124-
CryptoHash last_ds_final_block = 25;
125-
CryptoHash next_bp_hash = 26;
126-
CryptoHash block_merkle_root = 27;
127-
bytes epoch_sync_data_hash = 28;
128-
repeated Signature approvals = 29;
129-
Signature signature = 30;
130-
uint32 latest_protocol_version = 31;
119+
uint64 last_ds_final_block_height = 25;
120+
CryptoHash last_ds_final_block = 26;
121+
CryptoHash next_bp_hash = 27;
122+
CryptoHash block_merkle_root = 28;
123+
bytes epoch_sync_data_hash = 29;
124+
repeated Signature approvals = 30;
125+
Signature signature = 31;
126+
uint32 latest_protocol_version = 32;
131127
}
132128

133129
message BigInt {
@@ -137,17 +133,19 @@ message CryptoHash {
137133
bytes bytes = 1;
138134
}
139135

140-
enum SignatureType {
136+
enum CurveKind {
141137
ED25519 = 0;
142138
SECP256K1 = 1;
143139
}
144140

145141
message Signature {
146-
SignatureType type = 1;
142+
CurveKind type = 1;
147143
bytes bytes = 2;
148144
}
145+
149146
message PublicKey {
150-
bytes bytes = 1;
147+
CurveKind type = 1;
148+
bytes bytes = 2;
151149
}
152150

153151
message ValidatorStake {
@@ -179,19 +177,16 @@ message ChunkHeader {
179177
bytes tx_root = 15;
180178
repeated ValidatorStake validator_proposals = 16;
181179
Signature signature = 17;
182-
183180
}
184181

185182
message IndexerShard {
186183
uint64 shard_id = 1;
187-
// Chunk is a real nullable field
188184
IndexerChunk chunk = 2;
189185
repeated IndexerExecutionOutcomeWithReceipt receipt_execution_outcomes = 3;
190-
191186
}
192187

193188
message IndexerExecutionOutcomeWithReceipt {
194-
ExecutionOutcomeWithIdView execution_outcome = 1;
189+
ExecutionOutcomeWithId execution_outcome = 1;
195190
Receipt receipt = 2;
196191
}
197192

@@ -200,7 +195,6 @@ message IndexerChunk {
200195
ChunkHeader header = 2;
201196
repeated IndexerTransactionWithOutcome transactions = 3;
202197
repeated Receipt receipts = 4;
203-
204198
}
205199

206200
message IndexerTransactionWithOutcome {
@@ -219,7 +213,7 @@ message SignedTransaction {
219213
}
220214

221215
message IndexerExecutionOutcomeWithOptionalReceipt {
222-
ExecutionOutcomeWithIdView execution_outcome = 1;
216+
ExecutionOutcomeWithId execution_outcome = 1;
223217
Receipt receipt = 2;
224218
}
225219

@@ -253,7 +247,7 @@ message DataReceiver {
253247
string receiver_id = 2;
254248
}
255249

256-
message ExecutionOutcomeWithIdView {
250+
message ExecutionOutcomeWithId {
257251
MerklePath proof = 1;
258252
CryptoHash block_hash = 2;
259253
CryptoHash id = 3;
@@ -272,10 +266,15 @@ message ExecutionOutcome {
272266
SuccessValueExecutionStatus success_value = 22;
273267
SuccessReceiptIdExecutionStatus success_receipt_id = 23;
274268
}
269+
ExecutionMetadata metadata = 6;
270+
}
271+
272+
enum ExecutionMetadata {
273+
ExecutionMetadataV1 = 0;
275274
}
276275

277276
message SuccessValueExecutionStatus {
278-
string value = 1;
277+
bytes value = 1;
279278
}
280279

281280
message SuccessReceiptIdExecutionStatus {
@@ -305,8 +304,8 @@ message ActionError {
305304
TriesToUnstakeErrorKind tries_to_unstake = 30;
306305
TriesToStakeErrorKind tries_to_stake = 31;
307306
InsufficientStakeErrorKind insufficient_stake = 32;
308-
FunctionCallErrorKind function_call = 33; //todo: uncompleted
309-
NewReceiptValidationErrorKind new_receipt_validation = 34; //todo: uncompleted
307+
FunctionCallErrorKind function_call = 33;
308+
NewReceiptValidationErrorKind new_receipt_validation = 34;
310309
OnlyImplicitAccountCreationAllowedErrorKind only_implicit_account_creation_allowed = 35;
311310
DeleteAccountWithLargeStateErrorKind delete_account_with_large_state = 36;
312311
}
@@ -372,18 +371,45 @@ message InsufficientStakeErrorKind{
372371
BigInt stake = 2;
373372
BigInt minimum_stake = 3;
374373
}
375-
message FunctionCallErrorKind{} //todo: incomplete
376-
message NewReceiptValidationErrorKind{} //todo: incomplete
374+
375+
message FunctionCallErrorKind {
376+
FunctionCallErrorSer error = 1;
377+
}
378+
379+
enum FunctionCallErrorSer { //todo: add more detail?
380+
CompilationError = 0;
381+
LinkError = 1;
382+
MethodResolveError = 2;
383+
WasmTrap = 3;
384+
WasmUnknownError = 4;
385+
HostError = 5;
386+
_EVMError = 6;
387+
ExecutionError = 7;
388+
}
389+
390+
message NewReceiptValidationErrorKind {
391+
ReceiptValidationError error = 1;
392+
}
393+
394+
enum ReceiptValidationError { //todo: add more detail?
395+
InvalidPredecessorId = 0;
396+
InvalidReceiverAccountId = 1;
397+
InvalidSignerAccountId = 2;
398+
InvalidDataReceiverId = 3;
399+
ReturnedValueLengthExceeded = 4;
400+
NumberInputDataDependenciesExceeded = 5;
401+
ActionsValidationError = 6;
402+
}
377403

378404
message OnlyImplicitAccountCreationAllowedErrorKind{
379405
string account_id = 1;
380406
}
407+
381408
message DeleteAccountWithLargeStateErrorKind{
382409
string account_id = 1;
383410
}
384411

385-
386-
enum InvalidTxError {//todo: half baked
412+
enum InvalidTxError { //todo: add more detail?
387413
InvalidAccessKeyError = 0;
388414
InvalidSignerId = 1;
389415
SignerDoesNotExist = 2;
@@ -400,10 +426,10 @@ enum InvalidTxError {//todo: half baked
400426
TransactionSizeExceeded = 13;
401427
}
402428

403-
404429
message MerklePath {
405430
repeated MerklePathItem path = 1;
406431
}
432+
407433
message MerklePathItem {
408434
CryptoHash hash = 1;
409435
Direction direction = 2;
@@ -414,7 +440,6 @@ enum Direction {
414440
right = 1;
415441
}
416442

417-
418443
message Action {
419444
oneof action {
420445
CreateAccountAction create_account = 1;
@@ -432,12 +457,12 @@ message CreateAccountAction {
432457
}
433458

434459
message DeployContractAction {
435-
string code = 1;
460+
bytes code = 1;
436461
}
437462

438463
message FunctionCallAction {
439464
string method_name = 1;
440-
string args = 2;
465+
bytes args = 2;
441466
uint64 gas = 3;
442467
BigInt deposit = 4;
443468
}
@@ -477,7 +502,6 @@ message AccessKeyPermission {
477502
}
478503

479504
message FunctionCallPermission {
480-
// Allowance is a real nullable field
481505
BigInt allowance = 1;
482506
string receiver_id = 2;
483507
repeated string method_names = 3;

0 commit comments

Comments
 (0)