libra_client 0.1.3

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 (47) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +14 -0
  3. data/.travis.yml +7 -0
  4. data/CODE_OF_CONDUCT.md +74 -0
  5. data/Gemfile +4 -0
  6. data/Gemfile.lock +51 -0
  7. data/LICENSE.txt +21 -0
  8. data/README.md +57 -0
  9. data/Rakefile +10 -0
  10. data/bin/console +16 -0
  11. data/bin/setup +8 -0
  12. data/gen_proto.sh +2 -0
  13. data/lib/libra/access_path.rb +51 -0
  14. data/lib/libra/account_address.rb +29 -0
  15. data/lib/libra/account_config.rb +57 -0
  16. data/lib/libra/account_resource.rb +38 -0
  17. data/lib/libra/mnemonic.rb +147 -0
  18. data/lib/libra/version.rb +3 -0
  19. data/lib/libra_client.rb +173 -0
  20. data/libra_client.gemspec +49 -0
  21. data/libra_client.sublime-project +16 -0
  22. data/proto-lib/access_path_pb.rb +17 -0
  23. data/proto-lib/account_state_blob_pb.rb +23 -0
  24. data/proto-lib/admission_control_pb.rb +37 -0
  25. data/proto-lib/admission_control_services_pb.rb +37 -0
  26. data/proto-lib/events_pb.rb +35 -0
  27. data/proto-lib/get_with_proof_pb.rb +88 -0
  28. data/proto-lib/ledger_info_pb.rb +31 -0
  29. data/proto-lib/mempool_status_pb.rb +21 -0
  30. data/proto-lib/proof_pb.rb +41 -0
  31. data/proto-lib/transaction_info_pb.rb +19 -0
  32. data/proto-lib/transaction_pb.rb +102 -0
  33. data/proto-lib/validator_change_pb.rb +19 -0
  34. data/proto-lib/vm_errors_pb.rb +215 -0
  35. data/protos/access_path.proto +11 -0
  36. data/protos/account_state_blob.proto +16 -0
  37. data/protos/admission_control.proto +76 -0
  38. data/protos/events.proto +38 -0
  39. data/protos/get_with_proof.proto +310 -0
  40. data/protos/ledger_info.proto +82 -0
  41. data/protos/mempool_status.proto +21 -0
  42. data/protos/proof.proto +72 -0
  43. data/protos/transaction.proto +170 -0
  44. data/protos/transaction_info.proto +26 -0
  45. data/protos/validator_change.proto +27 -0
  46. data/protos/vm_errors.proto +276 -0
  47. metadata +191 -0
@@ -0,0 +1,82 @@
1
+ // Copyright (c) The Libra Core Contributors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ syntax = "proto3";
5
+
6
+ package types;
7
+
8
+ /// Even though we don't always need all hashes, we pass them in and return them
9
+ /// always so that we keep them in sync on the client and don't make the client
10
+ /// worry about which one(s) to pass in which cases
11
+ ///
12
+ /// This structure serves a dual purpose.
13
+ ///
14
+ /// First, if this structure is signed by 2f+1 validators it signifies the state
15
+ /// of the ledger at version `version` -- it contains the transaction
16
+ /// accumulator at that version which commits to all historical transactions.
17
+ /// This structure may be expanded to include other information that is derived
18
+ /// from that accumulator (e.g. the current time according to the time contract)
19
+ /// to reduce the number of proofs a client must get.
20
+ ///
21
+ /// Second, the structure contains a `consensus_data_hash` value. This is the
22
+ /// hash of an internal data structure that represents a block that is voted on
23
+ /// by consensus.
24
+ ///
25
+ /// Combining these two concepts when the consensus algorithm votes on a block B
26
+ /// it votes for a LedgerInfo with the `version` being the latest version that
27
+ /// will be committed if B gets 2f+1 votes. It sets `consensus_data_hash` to
28
+ /// represent B so that if those 2f+1 votes are gathered, the block is valid to
29
+ /// commit
30
+ message LedgerInfo {
31
+ // Current latest version of the system
32
+ uint64 version = 1;
33
+
34
+ // Root hash of transaction accumulator at this version
35
+ bytes transaction_accumulator_hash = 2;
36
+
37
+ // Hash of consensus-specific data that is opaque to all parts of the system
38
+ // other than consensus. This is needed to verify signatures because
39
+ // consensus signing includes this hash
40
+ bytes consensus_data_hash = 3;
41
+
42
+ // The block id of the last committed block corresponding to this ledger info.
43
+ // This field is not particularly interesting to the clients, but can be used
44
+ // by the validators for synchronization.
45
+ bytes consensus_block_id = 4;
46
+
47
+ // Epoch number corresponds to the set of validators that are active for this
48
+ // ledger info. The main motivation for keeping the epoch number in the
49
+ // LedgerInfo is to ensure that the client has enough information to verify
50
+ // that the signatures for this info are coming from the validators that
51
+ // indeed form a quorum. Without epoch number a potential attack could reuse
52
+ // the signatures from the validators in one epoch in order to sign the wrong
53
+ // info belonging to another epoch, in which these validators do not form a
54
+ // quorum. The very first epoch number is 0.
55
+ uint64 epoch_num = 5;
56
+
57
+ // Timestamp that represents the microseconds since the epoch (unix time) that is
58
+ // generated by the proposer of the block. This is strictly increasing with every block.
59
+ // If a client reads a timestamp > the one they specified for transaction expiration time,
60
+ // they can be certain that their transaction will never be included in a block in the future
61
+ // (assuming that their transaction has not yet been included)
62
+ uint64 timestamp_usecs = 6;
63
+ }
64
+
65
+ /// The validator node returns this structure which includes signatures
66
+ /// from each validator to confirm the state. The client needs to only pass
67
+ /// back the LedgerInfo element since the validator node doesn't need to know
68
+ /// the signatures again when the client performs a query, those are only there
69
+ /// for the client to be able to verify the state
70
+ message LedgerInfoWithSignatures {
71
+ // Signatures of the root node from each validator
72
+ repeated ValidatorSignature signatures = 1;
73
+
74
+ LedgerInfo ledger_info = 2;
75
+ }
76
+
77
+ message ValidatorSignature {
78
+ // The account address of the validator, which can be used for retrieving its
79
+ // public key during the given epoch.
80
+ bytes validator_id = 1;
81
+ bytes signature = 2;
82
+ }
@@ -0,0 +1,21 @@
1
+ // Copyright (c) The Libra Core Contributors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ syntax = "proto3";
5
+
6
+ package mempool;
7
+
8
+ enum MempoolAddTransactionStatus {
9
+ // Transaction was sent to Mempool
10
+ Valid = 0;
11
+ // The sender does not have enough balance for the transaction.
12
+ InsufficientBalance = 1;
13
+ // Sequence number is old, etc.
14
+ InvalidSeqNumber = 2;
15
+ // Mempool is full (reached max global capacity)
16
+ MempoolIsFull = 3;
17
+ // Account reached max capacity per account
18
+ TooManyTransactions = 4;
19
+ // Invalid update. Only gas price increase is allowed
20
+ InvalidUpdate = 5;
21
+ }
@@ -0,0 +1,72 @@
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 "transaction_info.proto";
9
+
10
+ message AccumulatorProof {
11
+ // The bitmap indicating which siblings are default. 1 means non-default and
12
+ // 0 means default. The LSB corresponds to the sibling at the bottom of the
13
+ // accumulator. The leftmost 1-bit corresponds to the sibling at the level
14
+ // just below root level in the accumulator, since this one is always
15
+ // non-default.
16
+ uint64 bitmap = 1;
17
+
18
+ // The non-default siblings. The ones near the root are at the beginning of
19
+ // the list.
20
+ repeated bytes non_default_siblings = 2;
21
+ }
22
+
23
+ message SparseMerkleProof {
24
+ // This proof can be used to authenticate whether a given leaf exists in the
25
+ // tree or not. In Rust:
26
+ // - If this is `Some(HashValue, HashValue)`
27
+ // - If the first `HashValue` equals requested key, this is an inclusion
28
+ // proof and the second `HashValue` equals the hash of the
29
+ // corresponding account blob.
30
+ // - Otherwise this is a non-inclusion proof. The first `HashValue` is
31
+ // the only key that exists in the subtree and the second `HashValue`
32
+ // equals the hash of the corresponding account blob.
33
+ // - If this is `None`, this is also a non-inclusion proof which indicates
34
+ // the subtree is empty.
35
+ //
36
+ // In protobuf, this leaf field should either be
37
+ // - empty, which corresponds to None in the Rust structure.
38
+ // - exactly 64 bytes, which corresponds to Some<(HashValue, HashValue)>
39
+ // in the Rust structure.
40
+ bytes leaf = 1;
41
+
42
+ // The bitmap indicating which siblings are default. 1 means non-default and
43
+ // 0 means default. The MSB of the first byte corresponds to the sibling at
44
+ // the top of the Sparse Merkle Tree. The rightmost 1-bit of the last byte
45
+ // corresponds to the sibling at the bottom, since this one is always
46
+ // non-default.
47
+ bytes bitmap = 2;
48
+
49
+ // The non-default siblings. The ones near the root are at the beginning of
50
+ // the list.
51
+ repeated bytes non_default_siblings = 3;
52
+ }
53
+
54
+ // The complete proof used to authenticate a signed transaction.
55
+ message SignedTransactionProof {
56
+ AccumulatorProof ledger_info_to_transaction_info_proof = 1;
57
+ TransactionInfo transaction_info = 2;
58
+ }
59
+
60
+ // The complete proof used to authenticate an account state.
61
+ message AccountStateProof {
62
+ AccumulatorProof ledger_info_to_transaction_info_proof = 1;
63
+ TransactionInfo transaction_info = 2;
64
+ SparseMerkleProof transaction_info_to_account_proof = 3;
65
+ }
66
+
67
+ // The complete proof used to authenticate an event.
68
+ message EventProof {
69
+ AccumulatorProof ledger_info_to_transaction_info_proof = 1;
70
+ TransactionInfo transaction_info = 2;
71
+ AccumulatorProof transaction_info_to_event_proof = 3;
72
+ }
@@ -0,0 +1,170 @@
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 "access_path.proto";
9
+ import "events.proto";
10
+ import "proof.proto";
11
+ import "transaction_info.proto";
12
+ import "google/protobuf/wrappers.proto";
13
+
14
+ // A generic structure that describes a transaction that a client submits
15
+ message RawTransaction {
16
+ // Sender's account address
17
+ bytes sender_account = 1;
18
+ // Sequence number of this transaction corresponding to sender's account.
19
+ uint64 sequence_number = 2;
20
+ oneof payload {
21
+ // The transaction script to execute.
22
+ Program program = 3;
23
+ // A write set, used for genesis blocks and other magic transactions.
24
+ // This bypasses the rules for regular transactions so will typically be
25
+ // rejected. Only under special circumstances will it be accepted.
26
+ WriteSet write_set = 4;
27
+ }
28
+ // Maximal total gas specified by wallet to spend for this transaction.
29
+ uint64 max_gas_amount = 5;
30
+ // The price to be paid for each unit of gas.
31
+ uint64 gas_unit_price = 6;
32
+ // Expiration time for this transaction. If storage is queried and
33
+ // the time returned is greater than or equal to this time and this
34
+ // transaction has not been included, you can be certain that it will
35
+ // never be included.
36
+ // If set to 0, there will be no expiration time
37
+ uint64 expiration_time = 7;
38
+ }
39
+
40
+ // The code for the transaction to execute
41
+ message Program {
42
+ bytes code = 1;
43
+ repeated TransactionArgument arguments = 2;
44
+ repeated bytes modules = 3;
45
+ }
46
+
47
+ // An argument to the transaction if the transaction takes arguments
48
+ message TransactionArgument {
49
+ enum ArgType {
50
+ U64 = 0;
51
+ ADDRESS = 1;
52
+ STRING = 2;
53
+ BYTEARRAY = 3;
54
+ }
55
+ ArgType type = 1;
56
+ bytes data = 2;
57
+ }
58
+
59
+ // A generic structure that represents signed RawTransaction
60
+ message SignedTransaction {
61
+ // The serialized Protobuf bytes for RawTransaction, for which the signature
62
+ // was signed. Protobuf doesn't guarantee the serialized bytes is canonical
63
+ // across different language implementations, but for our use cases for
64
+ // transaction it is not necessary because the client is the only one to
65
+ // produce this bytes, which is then persisted in storage.
66
+ bytes raw_txn_bytes = 1;
67
+ // public key that corresponds to RawTransaction::sender_account
68
+ bytes sender_public_key = 2;
69
+ // signature for the hash
70
+ bytes sender_signature = 3;
71
+ }
72
+
73
+ message SignedTransactionWithProof {
74
+ // The version of the returned signed transaction.
75
+ uint64 version = 1;
76
+
77
+ // The transaction itself.
78
+ SignedTransaction signed_transaction = 2;
79
+
80
+ // The proof authenticating the signed transaction.
81
+ SignedTransactionProof proof = 3;
82
+
83
+ // The events yielded by executing the transaction, if requested.
84
+ EventsList events = 4;
85
+ }
86
+
87
+ // A generic structure that represents a block of transactions originated from a
88
+ // particular validator instance.
89
+ message SignedTransactionsBlock {
90
+ // Set of Signed Transactions
91
+ repeated SignedTransaction transactions = 1;
92
+ // Public key of the validator that created this block
93
+ bytes validator_public_key = 2;
94
+ // Signature of the validator that created this block
95
+ bytes validator_signature = 3;
96
+ }
97
+
98
+ // Set of WriteOps to save to storage.
99
+ message WriteSet {
100
+ // Set of WriteOp for storage update.
101
+ repeated WriteOp write_set = 1;
102
+ }
103
+
104
+ // Write Operation on underlying storage.
105
+ message WriteOp {
106
+ // AccessPath of the write set.
107
+ AccessPath access_path = 1;
108
+ // The value of the write op. Empty if `type` is Delete.
109
+ bytes value = 2;
110
+ // WriteOp type.
111
+ WriteOpType type = 3;
112
+ }
113
+
114
+ // Type of write operation
115
+ enum WriteOpType {
116
+ // The WriteOp is to create/update the field from storage.
117
+ Write = 0;
118
+ // The WriteOp is to delete the field from storage.
119
+ Delete = 1;
120
+ }
121
+
122
+ // Account state as a whole.
123
+ // After execution, updates to accounts are passed in this form to storage for
124
+ // persistence.
125
+ message AccountState {
126
+ // Account address
127
+ bytes address = 1;
128
+ // Account state blob
129
+ bytes blob = 2;
130
+ }
131
+
132
+ // Transaction struct to commit to storage
133
+ message TransactionToCommit {
134
+ // The signed transaction which was executed
135
+ SignedTransaction signed_txn = 1;
136
+ // State db updates
137
+ repeated AccountState account_states = 2;
138
+ // Events yielded by the transaction.
139
+ repeated Event events = 3;
140
+ // The amount of gas used.
141
+ uint64 gas_used = 4;
142
+ }
143
+
144
+ // A list of consecutive transactions with proof. This is mainly used for state
145
+ // synchronization when a validator would request a list of transactions from a
146
+ // peer, verify the proof, execute the transactions and persist them. Note that
147
+ // the transactions are supposed to belong to the same epoch E, otherwise
148
+ // verification will fail.
149
+ message TransactionListWithProof {
150
+ // The list of transactions.
151
+ repeated SignedTransaction transactions = 1;
152
+
153
+ // The list of corresponding TransactionInfo objects.
154
+ repeated TransactionInfo infos = 2;
155
+
156
+ // The list of corresponding Event objects (only present if fetch_events was set to true in req)
157
+ EventsForVersions events_for_versions = 3;
158
+
159
+ // If the list is not empty, the version of the first transaction.
160
+ google.protobuf.UInt64Value first_transaction_version = 4;
161
+
162
+ // The proofs of the first and last transaction in this chunk. When this is
163
+ // used for state synchronization, the validator who requests the transactions
164
+ // will provide a version in the request and the proofs will be relative to
165
+ // the given version. When this is returned in GetTransactionsResponse, the
166
+ // proofs will be relative to the ledger info returned in
167
+ // UpdateToLatestLedgerResponse.
168
+ AccumulatorProof proof_of_first_transaction = 5;
169
+ AccumulatorProof proof_of_last_transaction = 6;
170
+ }
@@ -0,0 +1,26 @@
1
+ // Copyright (c) The Libra Core Contributors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ syntax = "proto3";
5
+
6
+ package types;
7
+
8
+ // `TransactionInfo` is the object we store in the transaction accumulator. It
9
+ // consists of the transaction as well as the execution result of this
10
+ // transaction. This are later returned to the client so that a client can
11
+ // validate the tree
12
+ message TransactionInfo {
13
+ // Hash of the signed transaction that is stored
14
+ bytes signed_transaction_hash = 1;
15
+
16
+ // The root hash of Sparse Merkle Tree describing the world state at the end
17
+ // of this transaction
18
+ bytes state_root_hash = 2;
19
+
20
+ // The root hash of Merkle Accumulator storing all events emitted during this
21
+ // transaction.
22
+ bytes event_root_hash = 3;
23
+
24
+ // The amount of gas used by this transaction.
25
+ uint64 gas_used = 4;
26
+ }
@@ -0,0 +1,27 @@
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 "events.proto";
9
+ import "ledger_info.proto";
10
+
11
+ // This is used to prove validator changes. When a validator is changing, it
12
+ // triggers an event on /validator_change_account/events/sent. To tell the
13
+ // client about validator changes, we query
14
+ // /validator_change_account/events/sent to get all versions that contain
15
+ // validator changes after the version that we are trying to update from. For
16
+ // each of these versions, the old validator set would have signed the ledger
17
+ // info at that version. The client needs this as well as the event results +
18
+ // proof. The client can then verify that these events were under the current
19
+ // tree and that the changes were signed by the old validators (and that the
20
+ // events correctly show which validators are the new validators).
21
+ //
22
+ // This message represents a single validator change event and the proof that
23
+ // corresponds to it
24
+ message ValidatorChangeEventWithProof {
25
+ LedgerInfoWithSignatures ledger_info_with_sigs = 1;
26
+ EventWithProof event_with_proof = 2;
27
+ }
@@ -0,0 +1,276 @@
1
+ // Copyright (c) The Libra Core Contributors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ syntax = "proto3";
5
+
6
+ package types;
7
+
8
+ // The statuses and errors produced by the VM can be categorized into a
9
+ // couple different types:
10
+ // 1. Validation Statuses: all the errors that can (/should) be
11
+ // the result of executing the prologue -- these are primarily used by
12
+ // the vm validator and AC.
13
+ // 2. Verification Errors: errors that are the result of performing
14
+ // bytecode verification (happens at the time of publishing).
15
+ // 3. VM Invariant Errors: errors that arise from an internal invariant of
16
+ // the VM being violated. These signify a problem with either the VM or
17
+ // bytecode verifier.
18
+ // 4. Binary Errors: errors that can occur during the process of
19
+ // deserialization of a transaction.
20
+ // 5. Runtime Statuses: errors that can arise from the execution of a
21
+ // transaction (assuming the prologue executes without error). These are
22
+ // errors that can occur during execution due to things such as division
23
+ // by zero, running out of gas, etc. These do not signify an issue with
24
+ // the VM.
25
+
26
+ // NB: we make a distinction between a status and an error here: A
27
+ // status contains errors, along with possible affirmation of a successful
28
+ // execution or valid prologue.
29
+
30
+ // The status of a transaction as determined by the prologue.
31
+ enum VMValidationStatusCode {
32
+ // We don't want the default value to be valid
33
+ UnknownValidationStatus = 0;
34
+ // The transaction has a bad signature
35
+ InvalidSignature = 1;
36
+ // Bad account authentication key
37
+ InvalidAuthKey = 2;
38
+ // Sequence number is too old
39
+ SequenceNumberTooOld = 3;
40
+ // Sequence number is too new
41
+ SequenceNumberTooNew = 4;
42
+ // Insufficient balance to pay minimum transaction fee
43
+ InsufficientBalanceForTransactionFee = 5;
44
+ // The transaction has expired
45
+ TransactionExpired = 6;
46
+ // The sending account does not exist
47
+ SendingAccountDoesNotExist = 7;
48
+ // This write set transaction was rejected because it did not meet the
49
+ // requirements for one.
50
+ RejectedWriteSet = 8;
51
+ // This write set transaction cannot be applied to the current state.
52
+ InvalidWriteSet = 9;
53
+ // Length of program field in raw transaction exceeded max length
54
+ ExceededMaxTransactionSize = 10;
55
+ // This script is not on our whitelist of script.
56
+ UnknownScript = 11;
57
+ // Transaction is trying to publish a new module.
58
+ UnknownModule = 12;
59
+ // Max gas units submitted with transaction exceeds max gas units bound
60
+ // in VM
61
+ MaxGasUnitsExceedsMaxGasUnitsBound = 13;
62
+ // Max gas units submitted with transaction not enough to cover the
63
+ // intrinsic cost of the transaction.
64
+ MaxGasUnitsBelowMinTransactionGasUnits = 14;
65
+ // Gas unit price submitted with transaction is below minimum gas price
66
+ // set in the VM.
67
+ GasUnitPriceBelowMinBound = 15;
68
+ // Gas unit price submitted with the transaction is above the maximum
69
+ // gas price set in the VM.
70
+ GasUnitPriceAboveMaxBound = 16;
71
+ }
72
+
73
+ message VMValidationStatus {
74
+ VMValidationStatusCode code = 1;
75
+ string message = 2;
76
+ }
77
+
78
+ message VMVerificationStatusList {
79
+ repeated VMVerificationStatus status_list = 1;
80
+ }
81
+
82
+ message VMVerificationStatus {
83
+ enum StatusKind {
84
+ SCRIPT = 0;
85
+ MODULE = 1;
86
+ }
87
+ StatusKind status_kind = 1;
88
+ // For StatusKind::SCRIPT this is ignored.
89
+ uint32 module_idx = 2;
90
+ VMVerificationErrorKind error_kind = 3;
91
+ string message = 4;
92
+ }
93
+
94
+ // When a code module/script is published it is verified. These are the
95
+ // possible errors that can arise from the verification process.
96
+ enum VMVerificationErrorKind {
97
+ // Likewise default to a unknown verification error
98
+ UnknownVerificationError = 0;
99
+ 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;
164
+ // The self address of a module the transaction is publishing is not the sender address
165
+ ModuleAddressDoesNotMatchSender = 66;
166
+ // The module does not have any module handles. Each module or script must have at least one module handle.
167
+ NoModuleHandles = 67;
168
+ }
169
+
170
+ // These are errors that the VM might raise if a violation of internal
171
+ // invariants takes place.
172
+ enum VMInvariantViolationError {
173
+ UnknownInvariantViolationError = 0;
174
+ OutOfBoundsIndex = 1;
175
+ OutOfBoundsRange = 2;
176
+ EmptyValueStack = 3;
177
+ EmptyCallStack = 4;
178
+ PCOverflow = 5;
179
+ LinkerError = 6;
180
+ LocalReferenceError = 7;
181
+ StorageError = 8;
182
+ }
183
+
184
+ // Errors that can arise from binary decoding (deserialization)
185
+ enum BinaryError {
186
+ UnknownBinaryError = 0;
187
+ Malformed = 1;
188
+ BadMagic = 2;
189
+ UnknownVersion = 3;
190
+ UnknownTableType = 4;
191
+ UnknownSignatureType = 5;
192
+ UnknownSerializedType = 6;
193
+ UnknownOpcode = 7;
194
+ BadHeaderTable = 8;
195
+ UnexpectedSignatureType = 9;
196
+ DuplicateTable = 10;
197
+ }
198
+
199
+ //*************************
200
+ // Runtime errors/status
201
+ //*************************
202
+
203
+ enum RuntimeStatus {
204
+ UnknownRuntimeStatus = 0;
205
+ Executed = 1;
206
+ OutOfGas = 2;
207
+ // We tried to access a resource that does not exist under the account.
208
+ ResourceDoesNotExist = 3;
209
+ // We tried to create a resource under an account where that resource
210
+ // already exists.
211
+ ResourceAlreadyExists = 4;
212
+ // We accessed an account that is evicted.
213
+ EvictedAccountAccess = 5;
214
+ // We tried to create an account at an address where an account already
215
+ // exists.
216
+ AccountAddressAlreadyExists = 6;
217
+ TypeError = 7;
218
+ MissingData = 8;
219
+ DataFormatError = 9;
220
+ InvalidData = 10;
221
+ RemoteDataError = 11;
222
+ CannotWriteExistingResource = 12;
223
+ ValueSerializationError = 13;
224
+ ValueDeserializationError = 14;
225
+ // The sender is trying to publish a module named `M`, but the sender's account already contains
226
+ // a module with this name.
227
+ DuplicateModuleName = 15;
228
+ }
229
+
230
+ // user-defined assertion error code number
231
+ message AssertionFailure {
232
+ uint64 assertion_error_code = 1;
233
+ }
234
+
235
+ message ArithmeticError {
236
+ enum ArithmeticErrorType {
237
+ UnknownArithmeticError = 0;
238
+ Underflow = 1;
239
+ Overflow = 2;
240
+ DivisionByZero = 3;
241
+ // Fill with more later
242
+ }
243
+ ArithmeticErrorType error_code = 1;
244
+ }
245
+
246
+ message DynamicReferenceError {
247
+ enum DynamicReferenceErrorType {
248
+ UnknownDynamicReferenceError = 0;
249
+ MoveOfBorrowedResource = 1;
250
+ GlobalRefAlreadyReleased = 2;
251
+ MissingReleaseRef = 3;
252
+ GlobalAlreadyBorrowed = 4;
253
+ // Fill with with more later
254
+ }
255
+ DynamicReferenceErrorType error_code = 1;
256
+ }
257
+
258
+ message ExecutionStatus {
259
+ oneof execution_status {
260
+ RuntimeStatus runtime_status = 1;
261
+ AssertionFailure assertion_failure = 2;
262
+ ArithmeticError arithmetic_error = 3;
263
+ DynamicReferenceError reference_error = 4;
264
+ }
265
+ }
266
+
267
+ // The status of the VM
268
+ message VMStatus {
269
+ oneof error_type {
270
+ VMValidationStatus validation = 1;
271
+ VMVerificationStatusList verification = 2;
272
+ VMInvariantViolationError invariant_violation = 3;
273
+ BinaryError deserialization = 4;
274
+ ExecutionStatus execution = 5;
275
+ }
276
+ }