// Copyright (c) The Libra Core Contributors // SPDX-License-Identifier: Apache-2.0 syntax = "proto3"; package types; import "language_storage.proto"; // The statuses and errors produced by the VM can be categorized into a // couple different types: // 1. Validation Statuses: all the errors that can (/should) be // the result of executing the prologue -- these are primarily used by // the vm validator and AC. // 2. Verification Errors: errors that are the result of performing // bytecode verification (happens at the time of publishing). // 3. VM Invariant Errors: errors that arise from an internal invariant of // the VM being violated. These signify a problem with either the VM or // bytecode verifier. // 4. Binary Errors: errors that can occur during the process of // deserialization of a transaction. // 5. Runtime Statuses: errors that can arise from the execution of a // transaction (assuming the prologue executes without error). These are // errors that can occur during execution due to things such as division // by zero, running out of gas, etc. These do not signify an issue with // the VM. // NB: we make a distinction between a status and an error here: A // status contains errors, along with possible affirmation of a successful // execution or valid prologue. // The status of a transaction as determined by the prologue. enum VMValidationStatusCode { // We don't want the default value to be valid UnknownValidationStatus = 0; // The transaction has a bad signature InvalidSignature = 1; // Bad account authentication key InvalidAuthKey = 2; // Sequence number is too old SequenceNumberTooOld = 3; // Sequence number is too new SequenceNumberTooNew = 4; // Insufficient balance to pay minimum transaction fee InsufficientBalanceForTransactionFee = 5; // The transaction has expired TransactionExpired = 6; // The sending account does not exist SendingAccountDoesNotExist = 7; // This write set transaction was rejected because it did not meet the // requirements for one. RejectedWriteSet = 8; // This write set transaction cannot be applied to the current state. InvalidWriteSet = 9; // Length of program field in raw transaction exceeded max length ExceededMaxTransactionSize = 10; // This script is not on our whitelist of script. UnknownScript = 11; // Transaction is trying to publish a new module. UnknownModule = 12; // Max gas units submitted with transaction exceeds max gas units bound // in VM MaxGasUnitsExceedsMaxGasUnitsBound = 13; // Max gas units submitted with transaction not enough to cover the // intrinsic cost of the transaction. MaxGasUnitsBelowMinTransactionGasUnits = 14; // Gas unit price submitted with transaction is below minimum gas price // set in the VM. GasUnitPriceBelowMinBound = 15; // Gas unit price submitted with the transaction is above the maximum // gas price set in the VM. GasUnitPriceAboveMaxBound = 16; } message VMValidationStatus { VMValidationStatusCode code = 1; string message = 2; } message VMVerificationStatusList { repeated VMVerificationStatus status_list = 1; } message VMVerificationStatus { enum StatusKind { SCRIPT = 0; MODULE = 1; DEPENDENCY = 2; } StatusKind status_kind = 1; // For StatusKind::SCRIPT and DEPENDENCY this is ignored. uint32 module_idx = 2; VMVerificationErrorKind error_kind = 3; string message = 4; // For StatusKind::SCRIPT and MODULE this is ignored. ModuleId dependency_id = 5; } // When a code module/script is published it is verified. These are the // possible errors that can arise from the verification process. enum VMVerificationErrorKind { // Likewise default to a unknown verification error UnknownVerificationError = 0; IndexOutOfBounds = 1; CodeUnitIndexOutOfBounds = 2; RangeOutOfBounds = 3; InvalidSignatureToken = 4; InvalidFieldDefReference = 5; RecursiveStructDefinition = 6; InvalidResourceField = 7; InvalidFallThrough = 8; JoinFailure = 9; NegativeStackSizeWithinBlock = 10; UnbalancedStack = 11; InvalidMainFunctionSignature = 12; DuplicateElement = 13; InvalidModuleHandle = 14; UnimplementedHandle = 15; InconsistentFields = 16; UnusedFields = 17; LookupFailed = 18; VisibilityMismatch = 19; TypeResolutionFailure = 20; TypeMismatch = 21; MissingDependency = 22; PopReferenceError = 23; PopResourceError = 24; ReleaseRefTypeMismatchError = 25; BrTypeMismatchError = 26; AbortTypeMismatchError = 27; StLocTypeMismatchError = 28; StLocUnsafeToDestroyError = 29; RetUnsafeToDestroyError = 30; RetTypeMismatchError = 31; FreezeRefTypeMismatchError = 32; FreezeRefExistsMutableBorrowError = 33; BorrowFieldTypeMismatchError = 34; BorrowFieldBadFieldError = 35; BorrowFieldExistsMutableBorrowError = 36; CopyLocUnavailableError = 37; CopyLocResourceError = 38; CopyLocExistsBorrowError = 39; MoveLocUnavailableError = 40; MoveLocExistsBorrowError = 41; BorrowLocReferenceError = 42; BorrowLocUnavailableError = 43; BorrowLocExistsBorrowError = 44; CallTypeMismatchError = 45; CallBorrowedMutableReferenceError = 46; PackTypeMismatchError = 47; UnpackTypeMismatchError = 48; ReadRefTypeMismatchError = 49; ReadRefResourceError = 50; ReadRefExistsMutableBorrowError = 51; WriteRefTypeMismatchError = 52; WriteRefResourceError = 53; WriteRefExistsBorrowError = 54; WriteRefNoMutableReferenceError = 55; IntegerOpTypeMismatchError = 56; BooleanOpTypeMismatchError = 57; EqualityOpTypeMismatchError = 58; ExistsResourceTypeMismatchError = 59; ExistsNoResourceError = 60; BorrowGlobalTypeMismatchError = 61; BorrowGlobalNoResourceError = 62; MoveFromTypeMismatchError = 63; MoveFromNoResourceError = 64; MoveToSenderTypeMismatchError = 65; MoveToSenderNoResourceError = 66; CreateAccountTypeMismatchError = 67; GlobalReferenceError = 68; // The self address of a module the transaction is publishing is not the sender address ModuleAddressDoesNotMatchSender = 69; // The module does not have any module handles. Each module or script must have at least one module handle. NoModuleHandles = 70; MissingAcquiresResourceAnnotationError = 71; ExtraneousAcquiresResourceAnnotationError = 72; DuplicateAcquiresResourceAnnotationError = 73; InvalidAcquiresResourceAnnotationError = 74; } // These are errors that the VM might raise if a violation of internal // invariants takes place. enum VMInvariantViolationError { UnknownInvariantViolationError = 0; OutOfBoundsIndex = 1; OutOfBoundsRange = 2; EmptyValueStack = 3; EmptyCallStack = 4; PCOverflow = 5; LinkerError = 6; LocalReferenceError = 7; StorageError = 8; InternalTypeError = 9; EventKeyMismatch = 10; } // Errors that can arise from binary decoding (deserialization) enum BinaryError { UnknownBinaryError = 0; Malformed = 1; BadMagic = 2; UnknownVersion = 3; UnknownTableType = 4; UnknownSignatureType = 5; UnknownSerializedType = 6; UnknownOpcode = 7; BadHeaderTable = 8; UnexpectedSignatureType = 9; DuplicateTable = 10; } //************************* // Runtime errors/status //************************* enum RuntimeStatus { UnknownRuntimeStatus = 0; Executed = 1; OutOfGas = 2; // We tried to access a resource that does not exist under the account. ResourceDoesNotExist = 3; // We tried to create a resource under an account where that resource // already exists. ResourceAlreadyExists = 4; // We accessed an account that is evicted. EvictedAccountAccess = 5; // We tried to create an account at an address where an account already // exists. AccountAddressAlreadyExists = 6; TypeError = 7; MissingData = 8; DataFormatError = 9; InvalidData = 10; RemoteDataError = 11; CannotWriteExistingResource = 12; ValueSerializationError = 13; ValueDeserializationError = 14; // The sender is trying to publish a module named `M`, but the sender's account already contains // a module with this name. DuplicateModuleName = 15; ExecutionStackOverflow = 16; CallStackOverflow = 17; } // user-defined abort error code number message Aborted { uint64 aborted_error_code = 1; } message ArithmeticError { enum ArithmeticErrorType { UnknownArithmeticError = 0; Underflow = 1; Overflow = 2; DivisionByZero = 3; // Fill with more later } ArithmeticErrorType error_code = 1; } message DynamicReferenceError { enum DynamicReferenceErrorType { UnknownDynamicReferenceError = 0; MoveOfBorrowedResource = 1; GlobalRefAlreadyReleased = 2; MissingReleaseRef = 3; GlobalAlreadyBorrowed = 4; // Fill with with more later } DynamicReferenceErrorType error_code = 1; } message ExecutionStatus { oneof execution_status { RuntimeStatus runtime_status = 1; Aborted aborted = 2; ArithmeticError arithmetic_error = 3; DynamicReferenceError reference_error = 4; } } // The status of the VM message VMStatus { oneof error_type { VMValidationStatus validation = 1; VMVerificationStatusList verification = 2; VMInvariantViolationError invariant_violation = 3; BinaryError deserialization = 4; ExecutionStatus execution = 5; } }