libra_client 0.1.6 → 0.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -1
  3. data/Gemfile.lock +8 -6
  4. data/lib/libra/version.rb +1 -1
  5. data/libra_client.gemspec +1 -0
  6. data/proto-lib/admission_control_pb.rb +10 -7
  7. data/proto-lib/consensus_pb.rb +105 -0
  8. data/proto-lib/events_pb.rb +1 -1
  9. data/proto-lib/execution_pb.rb +51 -0
  10. data/proto-lib/execution_services_pb.rb +37 -0
  11. data/proto-lib/language_storage_pb.rb +17 -0
  12. data/proto-lib/mempool_pb.rb +18 -0
  13. data/proto-lib/mempool_status_pb.rb +7 -2
  14. data/proto-lib/network_pb.rb +59 -0
  15. data/proto-lib/node_debug_interface_pb.rb +39 -0
  16. data/proto-lib/node_debug_interface_services_pb.rb +32 -0
  17. data/proto-lib/proof_pb.rb +6 -0
  18. data/proto-lib/secret_service_pb.rb +54 -0
  19. data/proto-lib/secret_service_services_pb.rb +34 -0
  20. data/proto-lib/state_synchronizer_pb.rb +33 -0
  21. data/proto-lib/storage_pb.rb +61 -0
  22. data/proto-lib/storage_services_pb.rb +47 -0
  23. data/proto-lib/transaction_pb.rb +11 -0
  24. data/proto-lib/validator_public_keys_pb.rb +19 -0
  25. data/proto-lib/validator_set_pb.rb +17 -0
  26. data/proto-lib/vm_errors_pb.rb +84 -70
  27. data/protos/admission_control.proto +11 -4
  28. data/protos/consensus.proto +147 -0
  29. data/protos/events.proto +1 -1
  30. data/protos/execution.proto +92 -0
  31. data/protos/language_storage.proto +12 -0
  32. data/protos/mempool.proto +18 -0
  33. data/protos/mempool_status.proto +6 -1
  34. data/protos/network.proto +81 -0
  35. data/protos/node_debug_interface.proto +40 -0
  36. data/protos/proof.proto +15 -0
  37. data/protos/secret_service.proto +64 -0
  38. data/protos/state_synchronizer.proto +29 -0
  39. data/protos/storage.proto +115 -0
  40. data/protos/transaction.proto +16 -1
  41. data/protos/validator_public_keys.proto +18 -0
  42. data/protos/validator_set.proto +13 -0
  43. data/protos/vm_errors.proto +87 -71
  44. metadata +42 -2
@@ -51,6 +51,21 @@ message SparseMerkleProof {
51
51
  repeated bytes non_default_siblings = 3;
52
52
  }
53
53
 
54
+ message AccumulatorConsistencyProof {
55
+ // The root hashes of the frozen subtrees that form the small accumulator.
56
+ // Note that none of these hashes should be default hash.
57
+ repeated bytes frozen_subtree_roots = 1;
58
+
59
+ // The total number of siblings.
60
+ uint32 num_siblings = 2;
61
+
62
+ // The non-default siblings. Note that the entire list of siblings always
63
+ // start of zero or more non-default siblings, followed by zero of more
64
+ // default siblings. So given the total number of siblings and the non-default
65
+ // siblings we should be able to construct the entire sibling list.
66
+ repeated bytes non_default_siblings = 3;
67
+ }
68
+
54
69
  // The complete proof used to authenticate a signed transaction.
55
70
  message SignedTransactionProof {
56
71
  AccumulatorProof ledger_info_to_transaction_info_proof = 1;
@@ -0,0 +1,64 @@
1
+ // Copyright (c) The Libra Core Contributors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ syntax = "proto3";
5
+
6
+ package secret_service;
7
+
8
+ // -----------------------------------------------------------------------------
9
+ // ---------------- Service definition
10
+ // -----------------------------------------------------------------------------
11
+ service SecretService {
12
+ // API to request key generation
13
+ rpc GenerateKey (GenerateKeyRequest) returns (GenerateKeyResponse) {}
14
+ // API to request a public key
15
+ rpc GetPublicKey (PublicKeyRequest) returns (PublicKeyResponse) {}
16
+ // API to request a signature
17
+ rpc Sign (SignRequest) returns (SignResponse) {}
18
+ }
19
+
20
+ message GenerateKeyRequest {
21
+ // Spec gives a way to generate the key (potentially BIP32 private derivation path here)
22
+ KeyType spec = 1;
23
+ }
24
+
25
+ message GenerateKeyResponse {
26
+ bytes key_id = 1;
27
+ ErrorCode code = 2;
28
+ }
29
+
30
+ message PublicKeyRequest {
31
+ bytes key_id = 1;
32
+ }
33
+
34
+ message PublicKeyResponse {
35
+ bytes public_key = 1;
36
+ ErrorCode code = 2;
37
+ }
38
+
39
+ message SignRequest {
40
+ bytes key_id = 1;
41
+ // message_hash should be a prehashed message of length crypto::HashValue::LENGTH = 32 bytes
42
+ bytes message_hash = 2;
43
+ }
44
+
45
+ message SignResponse {
46
+ bytes signature = 1;
47
+ ErrorCode code = 2;
48
+ }
49
+
50
+ enum ErrorCode {
51
+ Success = 0;
52
+ KeyIdNotFound = 1;
53
+ WrongLength = 2;
54
+ InvalidParameters = 3;
55
+ AuthenticationFailed = 4;
56
+ Unspecified = 5;
57
+
58
+ // Good examples of more error codes: https://developers.yubico.com/YubiHSM2/Component_Reference/KSP/Status_codes.html
59
+ }
60
+
61
+ enum KeyType {
62
+ Ed25519 = 0;
63
+ BLS12381 = 1;
64
+ }
@@ -0,0 +1,29 @@
1
+ // Copyright (c) The Libra Core Contributors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ syntax = "proto3";
5
+
6
+ package network;
7
+
8
+ import "ledger_info.proto";
9
+ import "transaction.proto";
10
+
11
+ message GetChunkRequest {
12
+ uint64 known_version = 1;
13
+ uint64 limit = 2;
14
+ uint64 timeout = 3;
15
+ types.LedgerInfoWithSignatures ledger_info_with_sigs = 4;
16
+ }
17
+
18
+ message GetChunkResponse {
19
+ types.LedgerInfoWithSignatures ledger_info_with_sigs = 1;
20
+ // chunk of transactions with proof corresponding to version in `ledger_info_with_sigs`
21
+ types.TransactionListWithProof txn_list_with_proof = 2;
22
+ }
23
+
24
+ message StateSynchronizerMsg {
25
+ oneof message {
26
+ GetChunkRequest chunk_request = 1;
27
+ GetChunkResponse chunk_response = 2;
28
+ }
29
+ }
@@ -0,0 +1,115 @@
1
+ // Copyright (c) The Libra Core Contributors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ syntax = "proto3";
5
+
6
+ package storage;
7
+
8
+ import "get_with_proof.proto";
9
+ import "ledger_info.proto";
10
+ import "transaction.proto";
11
+ import "account_state_blob.proto";
12
+ import "proof.proto";
13
+
14
+ // -----------------------------------------------------------------------------
15
+ // ---------------- Service definition for storage
16
+ // -----------------------------------------------------------------------------
17
+ service Storage {
18
+ // Write APIs.
19
+
20
+ // Persist transactions. Called by Execution when either syncing nodes or
21
+ // committing blocks during normal operation.
22
+ rpc SaveTransactions(SaveTransactionsRequest)
23
+ returns (SaveTransactionsResponse);
24
+
25
+ // Read APIs.
26
+
27
+ // Used to get a piece of data and return the proof of it. If the client
28
+ // knows and trusts a ledger info at version v, it should pass v in as the
29
+ // client_known_version and we will return the latest ledger info together
30
+ // with the proof that it derives from v.
31
+ rpc UpdateToLatestLedger(
32
+ types.UpdateToLatestLedgerRequest)
33
+ returns (types.UpdateToLatestLedgerResponse);
34
+
35
+ // When we receive a request from a peer validator asking a list of
36
+ // transactions for state synchronization, this API can be used to serve the
37
+ // request. Note that the peer should specify a ledger version and all proofs
38
+ // in the response will be relative to this given ledger version.
39
+ rpc GetTransactions(GetTransactionsRequest) returns (GetTransactionsResponse);
40
+
41
+ rpc GetAccountStateWithProofByVersion(
42
+ GetAccountStateWithProofByVersionRequest)
43
+ returns (GetAccountStateWithProofByVersionResponse);
44
+
45
+ // Returns information needed for libra core to start up.
46
+ rpc GetStartupInfo(GetStartupInfoRequest)
47
+ returns (GetStartupInfoResponse);
48
+ }
49
+
50
+ message SaveTransactionsRequest {
51
+ // Transactions to persist.
52
+ repeated types.TransactionToCommit txns_to_commit = 1;
53
+
54
+ // The version of the first transaction in `txns_to_commit`.
55
+ uint64 first_version = 2;
56
+
57
+ // If this is set, Storage will check its state after applying the above
58
+ // transactions matches info in this LedgerInfo before committing otherwise
59
+ // it denies the request.
60
+ types.LedgerInfoWithSignatures ledger_info_with_signatures = 3;
61
+ }
62
+
63
+ message SaveTransactionsResponse {}
64
+
65
+ message GetTransactionsRequest {
66
+ // The version to start with.
67
+ uint64 start_version = 1;
68
+ // The size of the transaction batch.
69
+ uint64 batch_size = 2;
70
+ // All the proofs returned in the response should be relative to this
71
+ // given version.
72
+ uint64 ledger_version = 3;
73
+ // Used to return the events associated with each transaction
74
+ bool fetch_events = 4;
75
+ }
76
+
77
+ message GetTransactionsResponse {
78
+ types.TransactionListWithProof txn_list_with_proof = 1;
79
+ }
80
+
81
+ message GetAccountStateWithProofByVersionRequest {
82
+ /// The account address to query with.
83
+ bytes address = 1;
84
+
85
+ /// The version the query is based on.
86
+ uint64 version = 2;
87
+ }
88
+
89
+ message GetAccountStateWithProofByVersionResponse {
90
+ /// The optional blob of account state blob.
91
+ types.AccountStateBlob account_state_blob = 1;
92
+
93
+ /// The state root hash the query is based on.
94
+ types.SparseMerkleProof sparse_merkle_proof = 2;
95
+ }
96
+
97
+ message GetStartupInfoRequest {}
98
+
99
+ message GetStartupInfoResponse {
100
+ // When this is empty, Storage needs to be bootstrapped via the bootstrap API
101
+ StartupInfo info = 1;
102
+ }
103
+
104
+ message StartupInfo {
105
+ // The latest LedgerInfo. Note that at start up storage can have more
106
+ // transactions than the latest LedgerInfo indicates due to an incomplete
107
+ // start up sync.
108
+ types.LedgerInfo ledger_info = 1;
109
+ // The latest version. All fields below are based on this version.
110
+ uint64 latest_version = 2;
111
+ // The latest account state root hash.
112
+ bytes account_state_root_hash = 3;
113
+ // From left to right, root hashes of all frozen subtrees.
114
+ repeated bytes ledger_frozen_subtree_hashes = 4;
115
+ }
@@ -24,11 +24,15 @@ message RawTransaction {
24
24
  // This bypasses the rules for regular transactions so will typically be
25
25
  // rejected. Only under special circumstances will it be accepted.
26
26
  WriteSet write_set = 4;
27
+ // The transaction script to execute.
28
+ Script script = 8;
29
+ // The MOVE Module to publish.
30
+ Module module = 9;
27
31
  }
28
32
  // Maximal total gas specified by wallet to spend for this transaction.
29
33
  uint64 max_gas_amount = 5;
30
34
  // The price to be paid for each unit of gas.
31
- uint64 gas_unit_price = 6;
35
+ uint64 gas_unit_price = 6;
32
36
  // Expiration time for this transaction. If storage is queried and
33
37
  // the time returned is greater than or equal to this time and this
34
38
  // transaction has not been included, you can be certain that it will
@@ -44,6 +48,12 @@ message Program {
44
48
  repeated bytes modules = 3;
45
49
  }
46
50
 
51
+ // The code for the transaction to execute
52
+ message Script {
53
+ bytes code = 1;
54
+ repeated TransactionArgument arguments = 2;
55
+ }
56
+
47
57
  // An argument to the transaction if the transaction takes arguments
48
58
  message TransactionArgument {
49
59
  enum ArgType {
@@ -56,6 +66,11 @@ message TransactionArgument {
56
66
  bytes data = 2;
57
67
  }
58
68
 
69
+ // A Move Module to publish
70
+ message Module {
71
+ bytes code = 1;
72
+ }
73
+
59
74
  // A generic structure that represents signed RawTransaction
60
75
  message SignedTransaction {
61
76
  // The serialized Protobuf bytes for RawTransaction, for which the signature
@@ -0,0 +1,18 @@
1
+ // Copyright (c) The Libra Core Contributors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ syntax = "proto3";
5
+
6
+ package types;
7
+
8
+ // Protobuf definition for the Rust struct ValidatorPublicKeys
9
+ message ValidatorPublicKeys {
10
+ // Validator account address
11
+ bytes account_address = 1;
12
+ // Consensus public key
13
+ bytes consensus_public_key = 2;
14
+ // Network signing publick key
15
+ bytes network_signing_public_key = 3;
16
+ /// Network identity publick key
17
+ bytes network_identity_public_key = 4;
18
+ }
@@ -0,0 +1,13 @@
1
+ // Copyright (c) The Libra Core Contributors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ syntax = "proto3";
5
+
6
+ package types;
7
+
8
+ import "validator_public_keys.proto";
9
+
10
+ // Protobuf definition for the Rust struct ValidatorSet.
11
+ message ValidatorSet {
12
+ repeated ValidatorPublicKeys validator_public_keys = 1;
13
+ }
@@ -5,6 +5,8 @@ syntax = "proto3";
5
5
 
6
6
  package types;
7
7
 
8
+ import "language_storage.proto";
9
+
8
10
  // The statuses and errors produced by the VM can be categorized into a
9
11
  // couple different types:
10
12
  // 1. Validation Statuses: all the errors that can (/should) be
@@ -83,12 +85,15 @@ message VMVerificationStatus {
83
85
  enum StatusKind {
84
86
  SCRIPT = 0;
85
87
  MODULE = 1;
88
+ DEPENDENCY = 2;
86
89
  }
87
90
  StatusKind status_kind = 1;
88
- // For StatusKind::SCRIPT this is ignored.
91
+ // For StatusKind::SCRIPT and DEPENDENCY this is ignored.
89
92
  uint32 module_idx = 2;
90
93
  VMVerificationErrorKind error_kind = 3;
91
94
  string message = 4;
95
+ // For StatusKind::SCRIPT and MODULE this is ignored.
96
+ ModuleId dependency_id = 5;
92
97
  }
93
98
 
94
99
  // When a code module/script is published it is verified. These are the
@@ -97,74 +102,81 @@ enum VMVerificationErrorKind {
97
102
  // Likewise default to a unknown verification error
98
103
  UnknownVerificationError = 0;
99
104
  IndexOutOfBounds = 1;
100
- RangeOutOfBounds = 2;
101
- InvalidSignatureToken = 3;
102
- InvalidFieldDefReference = 4;
103
- RecursiveStructDefinition = 5;
104
- InvalidResourceField = 6;
105
- InvalidFallThrough = 7;
106
- JoinFailure = 8;
107
- NegativeStackSizeWithinBlock = 9;
108
- UnbalancedStack = 10;
109
- InvalidMainFunctionSignature = 11;
110
- DuplicateElement = 12;
111
- InvalidModuleHandle = 13;
112
- UnimplementedHandle = 14;
113
- InconsistentFields = 15;
114
- UnusedFields = 16;
115
- LookupFailed = 17;
116
- VisibilityMismatch = 18;
117
- TypeResolutionFailure = 19;
118
- TypeMismatch = 20;
119
- MissingDependency = 21;
120
- PopReferenceError = 22;
121
- PopResourceError = 23;
122
- ReleaseRefTypeMismatchError = 24;
123
- BrTypeMismatchError = 25;
124
- AssertTypeMismatchError = 26;
125
- StLocTypeMismatchError = 27;
126
- StLocUnsafeToDestroyError = 28;
127
- RetUnsafeToDestroyError = 29;
128
- RetTypeMismatchError = 30;
129
- FreezeRefTypeMismatchError = 31;
130
- FreezeRefExistsMutableBorrowError = 32;
131
- BorrowFieldTypeMismatchError = 33;
132
- BorrowFieldBadFieldError = 34;
133
- BorrowFieldExistsMutableBorrowError = 35;
134
- CopyLocUnavailableError = 36;
135
- CopyLocResourceError = 37;
136
- CopyLocExistsBorrowError = 38;
137
- MoveLocUnavailableError = 39;
138
- MoveLocExistsBorrowError = 40;
139
- BorrowLocReferenceError = 41;
140
- BorrowLocUnavailableError = 42;
141
- BorrowLocExistsBorrowError = 43;
142
- CallTypeMismatchError = 44;
143
- CallBorrowedMutableReferenceError = 45;
144
- PackTypeMismatchError = 46;
145
- UnpackTypeMismatchError = 47;
146
- ReadRefTypeMismatchError = 48;
147
- ReadRefResourceError = 49;
148
- ReadRefExistsMutableBorrowError = 50;
149
- WriteRefTypeMismatchError = 51;
150
- WriteRefResourceError = 52;
151
- WriteRefExistsBorrowError = 53;
152
- WriteRefNoMutableReferenceError = 54;
153
- IntegerOpTypeMismatchError = 55;
154
- BooleanOpTypeMismatchError = 56;
155
- EqualityOpTypeMismatchError = 57;
156
- ExistsResourceTypeMismatchError = 58;
157
- BorrowGlobalTypeMismatchError = 59;
158
- BorrowGlobalNoResourceError = 60;
159
- MoveFromTypeMismatchError = 61;
160
- MoveFromNoResourceError = 62;
161
- MoveToSenderTypeMismatchError = 63;
162
- MoveToSenderNoResourceError = 64;
163
- CreateAccountTypeMismatchError = 65;
105
+ CodeUnitIndexOutOfBounds = 2;
106
+ RangeOutOfBounds = 3;
107
+ InvalidSignatureToken = 4;
108
+ InvalidFieldDefReference = 5;
109
+ RecursiveStructDefinition = 6;
110
+ InvalidResourceField = 7;
111
+ InvalidFallThrough = 8;
112
+ JoinFailure = 9;
113
+ NegativeStackSizeWithinBlock = 10;
114
+ UnbalancedStack = 11;
115
+ InvalidMainFunctionSignature = 12;
116
+ DuplicateElement = 13;
117
+ InvalidModuleHandle = 14;
118
+ UnimplementedHandle = 15;
119
+ InconsistentFields = 16;
120
+ UnusedFields = 17;
121
+ LookupFailed = 18;
122
+ VisibilityMismatch = 19;
123
+ TypeResolutionFailure = 20;
124
+ TypeMismatch = 21;
125
+ MissingDependency = 22;
126
+ PopReferenceError = 23;
127
+ PopResourceError = 24;
128
+ ReleaseRefTypeMismatchError = 25;
129
+ BrTypeMismatchError = 26;
130
+ AbortTypeMismatchError = 27;
131
+ StLocTypeMismatchError = 28;
132
+ StLocUnsafeToDestroyError = 29;
133
+ RetUnsafeToDestroyError = 30;
134
+ RetTypeMismatchError = 31;
135
+ FreezeRefTypeMismatchError = 32;
136
+ FreezeRefExistsMutableBorrowError = 33;
137
+ BorrowFieldTypeMismatchError = 34;
138
+ BorrowFieldBadFieldError = 35;
139
+ BorrowFieldExistsMutableBorrowError = 36;
140
+ CopyLocUnavailableError = 37;
141
+ CopyLocResourceError = 38;
142
+ CopyLocExistsBorrowError = 39;
143
+ MoveLocUnavailableError = 40;
144
+ MoveLocExistsBorrowError = 41;
145
+ BorrowLocReferenceError = 42;
146
+ BorrowLocUnavailableError = 43;
147
+ BorrowLocExistsBorrowError = 44;
148
+ CallTypeMismatchError = 45;
149
+ CallBorrowedMutableReferenceError = 46;
150
+ PackTypeMismatchError = 47;
151
+ UnpackTypeMismatchError = 48;
152
+ ReadRefTypeMismatchError = 49;
153
+ ReadRefResourceError = 50;
154
+ ReadRefExistsMutableBorrowError = 51;
155
+ WriteRefTypeMismatchError = 52;
156
+ WriteRefResourceError = 53;
157
+ WriteRefExistsBorrowError = 54;
158
+ WriteRefNoMutableReferenceError = 55;
159
+ IntegerOpTypeMismatchError = 56;
160
+ BooleanOpTypeMismatchError = 57;
161
+ EqualityOpTypeMismatchError = 58;
162
+ ExistsResourceTypeMismatchError = 59;
163
+ ExistsNoResourceError = 60;
164
+ BorrowGlobalTypeMismatchError = 61;
165
+ BorrowGlobalNoResourceError = 62;
166
+ MoveFromTypeMismatchError = 63;
167
+ MoveFromNoResourceError = 64;
168
+ MoveToSenderTypeMismatchError = 65;
169
+ MoveToSenderNoResourceError = 66;
170
+ CreateAccountTypeMismatchError = 67;
171
+ GlobalReferenceError = 68;
164
172
  // The self address of a module the transaction is publishing is not the sender address
165
- ModuleAddressDoesNotMatchSender = 66;
173
+ ModuleAddressDoesNotMatchSender = 69;
166
174
  // The module does not have any module handles. Each module or script must have at least one module handle.
167
- NoModuleHandles = 67;
175
+ NoModuleHandles = 70;
176
+ MissingAcquiresResourceAnnotationError = 71;
177
+ ExtraneousAcquiresResourceAnnotationError = 72;
178
+ DuplicateAcquiresResourceAnnotationError = 73;
179
+ InvalidAcquiresResourceAnnotationError = 74;
168
180
  }
169
181
 
170
182
  // These are errors that the VM might raise if a violation of internal
@@ -179,6 +191,8 @@ enum VMInvariantViolationError {
179
191
  LinkerError = 6;
180
192
  LocalReferenceError = 7;
181
193
  StorageError = 8;
194
+ InternalTypeError = 9;
195
+ EventKeyMismatch = 10;
182
196
  }
183
197
 
184
198
  // Errors that can arise from binary decoding (deserialization)
@@ -225,11 +239,13 @@ enum RuntimeStatus {
225
239
  // The sender is trying to publish a module named `M`, but the sender's account already contains
226
240
  // a module with this name.
227
241
  DuplicateModuleName = 15;
242
+ ExecutionStackOverflow = 16;
243
+ CallStackOverflow = 17;
228
244
  }
229
245
 
230
- // user-defined assertion error code number
231
- message AssertionFailure {
232
- uint64 assertion_error_code = 1;
246
+ // user-defined abort error code number
247
+ message Aborted {
248
+ uint64 aborted_error_code = 1;
233
249
  }
234
250
 
235
251
  message ArithmeticError {
@@ -258,7 +274,7 @@ message DynamicReferenceError {
258
274
  message ExecutionStatus {
259
275
  oneof execution_status {
260
276
  RuntimeStatus runtime_status = 1;
261
- AssertionFailure assertion_failure = 2;
277
+ Aborted aborted = 2;
262
278
  ArithmeticError arithmetic_error = 3;
263
279
  DynamicReferenceError reference_error = 4;
264
280
  }