// Copyright (c) The Libra Core Contributors // SPDX-License-Identifier: Apache-2.0 syntax = "proto3"; package types; // 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; } StatusKind status_kind = 1; // For StatusKind::SCRIPT this is ignored. uint32 module_idx = 2; VMVerificationErrorKind error_kind = 3; string message = 4; } // 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; RangeOutOfBounds = 2; InvalidSignatureToken = 3; InvalidFieldDefReference = 4; RecursiveStructDefinition = 5; InvalidResourceField = 6; InvalidFallThrough = 7; JoinFailure = 8; NegativeStackSizeWithinBlock = 9; UnbalancedStack = 10; InvalidMainFunctionSignature = 11; DuplicateElement = 12; InvalidModuleHandle = 13; UnimplementedHandle = 14; InconsistentFields = 15; UnusedFields = 16; LookupFailed = 17; VisibilityMismatch = 18; TypeResolutionFailure = 19; TypeMismatch = 20; MissingDependency = 21; PopReferenceError = 22; PopResourceError = 23; ReleaseRefTypeMismatchError = 24; BrTypeMismatchError = 25; AssertTypeMismatchError = 26; StLocTypeMismatchError = 27; StLocUnsafeToDestroyError = 28; RetUnsafeToDestroyError = 29; RetTypeMismatchError = 30; FreezeRefTypeMismatchError = 31; FreezeRefExistsMutableBorrowError = 32; BorrowFieldTypeMismatchError = 33; BorrowFieldBadFieldError = 34; BorrowFieldExistsMutableBorrowError = 35; CopyLocUnavailableError = 36; CopyLocResourceError = 37; CopyLocExistsBorrowError = 38; MoveLocUnavailableError = 39; MoveLocExistsBorrowError = 40; BorrowLocReferenceError = 41; BorrowLocUnavailableError = 42; BorrowLocExistsBorrowError = 43; CallTypeMismatchError = 44; CallBorrowedMutableReferenceError = 45; PackTypeMismatchError = 46; UnpackTypeMismatchError = 47; ReadRefTypeMismatchError = 48; ReadRefResourceError = 49; ReadRefExistsMutableBorrowError = 50; WriteRefTypeMismatchError = 51; WriteRefResourceError = 52; WriteRefExistsBorrowError = 53; WriteRefNoMutableReferenceError = 54; IntegerOpTypeMismatchError = 55; BooleanOpTypeMismatchError = 56; EqualityOpTypeMismatchError = 57; ExistsResourceTypeMismatchError = 58; BorrowGlobalTypeMismatchError = 59; BorrowGlobalNoResourceError = 60; MoveFromTypeMismatchError = 61; MoveFromNoResourceError = 62; MoveToSenderTypeMismatchError = 63; MoveToSenderNoResourceError = 64; CreateAccountTypeMismatchError = 65; // The self address of a module the transaction is publishing is not the sender address ModuleAddressDoesNotMatchSender = 66; // The module does not have any module handles. Each module or script must have at least one module handle. NoModuleHandles = 67; } // 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; } // 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; } // user-defined assertion error code number message AssertionFailure { uint64 assertion_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; AssertionFailure assertion_failure = 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; } }