nimbus-eth1/nimbus/errors.nim

77 lines
2.6 KiB
Nim
Raw Permalink 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
2023-01-10 04:25:23 +00:00
InitcodeError* = object of EVMError
## Error to signal inicode size > EIP3860_MAX_INITCODE_SIZE
Core db update providing additional results code interface (#1776) * Split `core_db/base.nim` into several sources * Rename `core_db/legacy.nim` => `core_db/legacy_db.nim` * Update `CoreDb` API, dual methods returning `Result[]` or plain value detail: Plain value methods implemet the legacy API, they defect on error results * Redesign `CoreDB` direct backend access why: Made the `backend` directive integral part of the API * Discontinue providing unused or otherwise available functions details: + setTransactionID() removed, not used and not easily replicable in Aristo + maybeGet() removed, available via direct backend access + newPhk() removed, never used & was experimental anyway * Update/reorg backend API why: + Added error print function `$$()` + General descriptor completion (and optional validation) via `bless()` * Update `Aristo`/`Kvt` exception handling why: Avoid `CatchableError` exceptions, rather pass them as error code where appropriate. * More `CoreDB` compliant `Aristo` and `Kvt` methods details: + Providing functions like `contains()`, `getVtxRc()` (returns `Result[]`). + Additional error code: `NotImplemented` * Rewrite/reorg of Aristo DB constructor why: Previously used global object `DefaultQidLayoutRef` as default initialiser. This object was created at compile time which lead to non-gc safe functions. * Update nimbus/db/core_db/legacy_db.nim Co-authored-by: Kim De Mey <kim.demey@gmail.com> * Update nimbus/db/aristo/aristo_transcode.nim Co-authored-by: Kim De Mey <kim.demey@gmail.com> * Update nimbus/db/core_db/legacy_db.nim Co-authored-by: Kim De Mey <kim.demey@gmail.com> --------- Co-authored-by: Kim De Mey <kim.demey@gmail.com>
2023-09-26 09:21:13 +00:00
CoreDbApiError* = object of CatchableError
## Errors related to `CoreDB` API