2022-11-25 05:26:29 +00:00
|
|
|
# Nimbus
|
|
|
|
# Copyright (c) 2022 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.
|
|
|
|
|
2022-10-15 15:58:23 +00:00
|
|
|
import
|
2022-12-08 05:17:14 +00:00
|
|
|
std/[tables, json],
|
2022-10-15 15:58:23 +00:00
|
|
|
eth/common,
|
2022-12-02 04:39:12 +00:00
|
|
|
../../nimbus/common/chain_config,
|
2022-11-25 05:26:29 +00:00
|
|
|
../common/types
|
2022-10-15 15:58:23 +00:00
|
|
|
|
2022-11-25 05:26:29 +00:00
|
|
|
export
|
|
|
|
types
|
2022-10-15 15:58:23 +00:00
|
|
|
|
2022-11-25 05:26:29 +00:00
|
|
|
type
|
2022-10-15 15:58:23 +00:00
|
|
|
T8NExitCode* = distinct int
|
|
|
|
|
|
|
|
T8NError* = object of CatchableError
|
|
|
|
exitCode*: T8NExitCode
|
|
|
|
|
|
|
|
Ommer* = object
|
|
|
|
delta*: uint64
|
|
|
|
address*: EthAddress
|
|
|
|
|
|
|
|
EnvStruct* = object
|
|
|
|
currentCoinbase*: EthAddress
|
|
|
|
currentDifficulty*: Option[DifficultyInt]
|
|
|
|
currentRandom*: Option[Hash256]
|
|
|
|
parentDifficulty*: Option[DifficultyInt]
|
|
|
|
currentGasLimit*: GasInt
|
|
|
|
currentNumber*: BlockNumber
|
|
|
|
currentTimestamp*: EthTime
|
|
|
|
parentTimestamp*: EthTime
|
|
|
|
blockHashes*: Table[uint64, Hash256]
|
|
|
|
ommers*: seq[Ommer]
|
|
|
|
currentBaseFee*: Option[UInt256]
|
|
|
|
parentUncleHash*: Hash256
|
2022-12-08 05:17:14 +00:00
|
|
|
parentBaseFee*: Option[UInt256]
|
|
|
|
parentGasUsed*: Option[GasInt]
|
|
|
|
parentGasLimit*: Option[GasInt]
|
|
|
|
|
|
|
|
TxsType* = enum
|
|
|
|
TxsNone
|
|
|
|
TxsRlp
|
|
|
|
TxsJson
|
|
|
|
|
|
|
|
TxsList* = object
|
|
|
|
case txsType*: TxsType
|
|
|
|
of TxsRlp: r*: Rlp
|
|
|
|
of TxsJson: n*: JsonNode
|
|
|
|
else: discard
|
2022-10-15 15:58:23 +00:00
|
|
|
|
|
|
|
TransContext* = object
|
|
|
|
alloc*: GenesisAlloc
|
2022-12-08 05:17:14 +00:00
|
|
|
txs*: TxsList
|
2022-10-15 15:58:23 +00:00
|
|
|
env*: EnvStruct
|
|
|
|
|
|
|
|
RejectedTx* = object
|
|
|
|
index*: int
|
|
|
|
error*: string
|
|
|
|
|
|
|
|
TxReceipt* = object
|
|
|
|
txType*: TxType
|
|
|
|
root*: Hash256
|
|
|
|
status*: bool
|
|
|
|
cumulativeGasUsed*: GasInt
|
|
|
|
logsBloom*: BloomFilter
|
|
|
|
logs*: seq[Log]
|
|
|
|
transactionHash*: Hash256
|
|
|
|
contractAddress*: EthAddress
|
|
|
|
gasUsed*: GasInt
|
|
|
|
blockHash*: Hash256
|
|
|
|
transactionIndex*: int
|
|
|
|
|
|
|
|
# ExecutionResult contains the execution status after running a state test, any
|
|
|
|
# error that might have occurred and a dump of the final state if requested.
|
|
|
|
ExecutionResult* = object
|
|
|
|
stateRoot*: Hash256
|
|
|
|
txRoot*: Hash256
|
|
|
|
receiptsRoot*: Hash256
|
|
|
|
logsHash*: Hash256
|
|
|
|
bloom*: BloomFilter
|
|
|
|
receipts*: seq[TxReceipt]
|
|
|
|
rejected*: seq[RejectedTx]
|
|
|
|
currentDifficulty*: Option[DifficultyInt]
|
|
|
|
gasUsed*: GasInt
|
2022-12-08 05:17:14 +00:00
|
|
|
currentBaseFee*: Option[UInt256]
|
2022-10-15 15:58:23 +00:00
|
|
|
|
|
|
|
const
|
|
|
|
ErrorEVM* = 2.T8NExitCode
|
|
|
|
ErrorConfig* = 3.T8NExitCode
|
|
|
|
ErrorMissingBlockhash* = 4.T8NExitCode
|
|
|
|
|
|
|
|
ErrorJson* = 10.T8NExitCode
|
|
|
|
ErrorIO* = 11.T8NExitCode
|
|
|
|
ErrorRlp* = 12.T8NExitCode
|
|
|
|
|
|
|
|
proc newError*(code: T8NExitCode, msg: string): ref T8NError =
|
|
|
|
(ref T8NError)(exitCode: code, msg: msg)
|