nimbus-eth1/nimbus/errors.nim

71 lines
2.5 KiB
Nim
Raw Normal View History

# Nimbus
# Copyright (c) 2018 Status Research & Development GmbH
# Licensed under either of
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
# * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
# at your option. This file may not be copied, modified, or distributed except according to those terms.
type
EVMError* = object of CatchableError
## Base error class for all evm errors.
BlockNotFound* = object of EVMError
## The block with the given number/hash does not exist.
ParentNotFound* = object of EVMError
## The parent of a given block does not exist.
CanonicalHeadNotFound* = object of EVMError
## The chain has no canonical head.
ValidationError* = object of EVMError
## Error to signal something does not pass a validation check.
VMError* = object of EVMError
## Class of errors which can be raised during VM execution.
OutOfGas* = object of VMError
## Error signaling that VM execution has run out of gas.
InsufficientStack* = object of VMError
## Error signaling that the stack is empty.
FullStack* = object of VMError
## Error signaling that the stack is full.
InvalidJumpDestination* = object of VMError
## Error signaling that the jump destination for a JUMPDEST operation is invalid.
InvalidInstruction* = object of VMError
## Error signaling that an opcode is invalid.
InsufficientFunds* = object of VMError
## Error signaling that an account has insufficient funds to transfer the
## requested value.
StackDepthError* = object of VMError
## Error signaling that the call stack has exceeded it's maximum allowed depth.
ContractCreationCollision* = object of VMError
## Error signaling that there was an address collision during contract creation.
WriteProtection* = object of VMError
## Error raised if an attempt to modify the state database is made while
## operating inside of a STATICCALL context.
OutOfBoundsRead* = object of VMError
## Error raised to indicate an attempt was made to read data beyond the
## boundaries of the buffer (such as with RETURNDATACOPY)
TypeError* = object of VMError
## Error when invalid values are found
NotImplementedError* = object of VMError
## Not implemented error
2019-04-23 13:52:53 +00:00
StaticContextError* = object of VMError
## State changes not allowed in static call context
Redesign of BaseVMState descriptor (#923) * Redesign of BaseVMState descriptor why: BaseVMState provides an environment for executing transactions. The current descriptor also provides data that cannot generally be known within the execution environment, e.g. the total gasUsed which is available not before after all transactions have finished. Also, the BaseVMState constructor has been replaced by a constructor that does not need pre-initialised input of the account database. also: Previous constructor and some fields are provided with a deprecated annotation (producing a lot of noise.) * Replace legacy directives in production sources * Replace legacy directives in unit test sources * fix CI (missing premix update) * Remove legacy directives * chase CI problem * rebased * Re-introduce 'AccountsCache' constructor optimisation for 'BaseVmState' re-initialisation why: Constructing a new 'AccountsCache' descriptor can be avoided sometimes when the current state root is properly positioned already. Such a feature existed already as the update function 'initStateDB()' for the 'BaseChanDB' where the accounts cache was linked into this desctiptor. The function 'initStateDB()' was removed and re-implemented into the 'BaseVmState' constructor without optimisation. The old version was of restricted use as a wrong accounts cache state would unconditionally throw an exception rather than conceptually ask for a remedy. The optimised 'BaseVmState' re-initialisation has been implemented for the 'persistBlocks()' function. also: moved some test helpers to 'test/replay' folder * Remove unused & undocumented fields from Chain descriptor why: Reduces attack surface in general & improves reading the code.
2022-01-18 16:19:32 +00:00
VmStateError* = object of VMError
## VM state error relay