merged oph_*_kludge.nim sources => single oph_kludge.nim

This commit is contained in:
Jordan Hrycaj 2021-04-23 11:15:38 +01:00 committed by zah
parent 69a1ee5fc8
commit 45558282f7
7 changed files with 98 additions and 134 deletions

View File

@ -46,8 +46,7 @@ when not breakCircularDependency:
else: else:
import import
./oph_defs_kludge, ./oph_kludge
./oph_helpers_kludge
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Kludge END # Kludge END

View File

@ -47,8 +47,7 @@ when not breakCircularDependency:
else: else:
import import
./oph_defs_kludge, ./oph_kludge
./oph_helpers_kludge
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Kludge END # Kludge END

View File

@ -13,10 +13,10 @@
## ##
# Including types.nim needed unless included (not imported) into # Including types.nim needed unless included (not imported) into
# oph_defs_kludge.nim # oph_kludge.nim
# #
# Note that the nim compiler will distinguish <Vm2Ctx> tuples defined # Note that the nim compiler will distinguish <Vm2Ctx> tuples defined
# here when imported and from oph_defs_kludge.nim. This is so due to the # here when imported and from oph_kludge.nim. This is so due to the
# duplicate/different Computation definitions. # duplicate/different Computation definitions.
# #
when not declared(Computation): when not declared(Computation):

View File

@ -1,121 +0,0 @@
# 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.
## EVM Opcodes, Definitions -- Kludge Version
## ==========================================
##
{.warning: "Circular dependency breaker kludge -- no production code".}
import
../forks_list,
../op_codes,
../../memory,
../../stack,
eth/common/eth_types,
sets
# ------------------------------------------------------------------------------
# Kludge BEGIN
# ------------------------------------------------------------------------------
type
MsgFlags* = enum
emvcNoFlags = 0
emvcStatic = 1
CallKind* = enum
evmcCall = 0 # CALL
evmcDelegateCall = 1 # DELEGATECALL
evmcCallCode = 2 # CALLCODE
evmcCreate = 3 # CREATE
evmcCreate2 = 4 # CREATE2
ReadOnlyStateDB* =
seq[byte]
GasMeter* = object
gasRefunded*: GasInt
gasRemaining*: GasInt
CodeStream* = ref object
bytes*: seq[byte]
pc*: int
ChainId* = uint # distinct uint
ChainConfig* = object
chainId*: ChainId
homesteadBlock*: BlockNumber
daoForkBlock*: BlockNumber
daoForkSupport*: bool
AccountsCache* = ref object
isDirty: bool
BaseChainDB* = ref object
pruneTrie*: bool
config*: ChainConfig
GasCost* = object
opaq: int
GasCosts* = array[Op, GasCost]
BaseVMState* = ref object of RootObj
chaindb* : BaseChainDB
blockHeader* : BlockHeader
logEntries* : seq[Log]
accountDb* : AccountsCache
touchedAccounts*: HashSet[EthAddress]
suicides* : HashSet[EthAddress]
txOrigin* : EthAddress
txGasPrice* : GasInt
gasCosts* : GasCosts
fork* : Fork
Message* = ref object
kind*: CallKind
depth*: int
gas*: GasInt
contractAddress*: EthAddress
codeAddress*: EthAddress
sender*: EthAddress
value*: UInt256
data*: seq[byte]
flags*: MsgFlags
Computation* = ref object
returnStack*: seq[int]
output*: seq[byte]
vmState*: BaseVMState
gasMeter*: GasMeter
stack*: Stack
memory*: Memory
msg*: Message
code*: CodeStream
returnData*: seq[byte]
fork*: Fork
parent*, child*: Computation
continuation*: proc() {.gcsafe.}
touchedAccounts*: HashSet[EthAddress]
suicides*: HashSet[EthAddress]
logEntries*: seq[Log]
# ------------------------------------------------------------------------------
# Kludge END
# ------------------------------------------------------------------------------
include
./oph_defs
# ------------------------------------------------------------------------------
# End
# ------------------------------------------------------------------------------

View File

@ -13,9 +13,9 @@
## ##
# Including types.nim and others unless included (not imported) into # Including types.nim and others unless included (not imported) into
# oph_helpes_kludge.nim # oph_kludge.nim
# #
when not declared(consumeGas): when not declared(Computation):
import import
../../../db/accounts_cache, ../../../db/accounts_cache,
../../state, ../../state,

View File

@ -8,17 +8,21 @@
# at your option. This file may not be copied, modified, or distributed except # at your option. This file may not be copied, modified, or distributed except
# according to those terms. # according to those terms.
## EVM Opcode Handlers: Helper Functions -- Kludge Version ## EVM Opcodes, Definitions -- Kludge Version
## ======================================================= ## ==========================================
## ##
{.warning: "Circular dependency breaker kludge -- no production code".}
import import
../../../errors, ../../../errors,
../../memory,
../../stack,
../forks_list, ../forks_list,
../op_codes, ../op_codes,
./oph_defs_kludge,
eth/common/eth_types, eth/common/eth_types,
macros, macros,
sets,
stint, stint,
strutils strutils
@ -26,6 +30,89 @@ import
# Kludge BEGIN # Kludge BEGIN
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
type
MsgFlags* = enum
emvcNoFlags = 0
emvcStatic = 1
CallKind* = enum
evmcCall = 0 # CALL
evmcDelegateCall = 1 # DELEGATECALL
evmcCallCode = 2 # CALLCODE
evmcCreate = 3 # CREATE
evmcCreate2 = 4 # CREATE2
ReadOnlyStateDB* =
seq[byte]
GasMeter* = object
gasRefunded*: GasInt
gasRemaining*: GasInt
CodeStream* = ref object
bytes*: seq[byte]
pc*: int
ChainId* = uint # distinct uint
ChainConfig* = object
chainId*: ChainId
homesteadBlock*: BlockNumber
daoForkBlock*: BlockNumber
daoForkSupport*: bool
AccountsCache* = ref object
isDirty: bool
BaseChainDB* = ref object
pruneTrie*: bool
config*: ChainConfig
GasCost* = object
opaq: int
GasCosts* = array[Op, GasCost]
BaseVMState* = ref object of RootObj
chaindb* : BaseChainDB
blockHeader* : BlockHeader
logEntries* : seq[Log]
accountDb* : AccountsCache
touchedAccounts*: HashSet[EthAddress]
suicides* : HashSet[EthAddress]
txOrigin* : EthAddress
txGasPrice* : GasInt
gasCosts* : GasCosts
fork* : Fork
Message* = ref object
kind*: CallKind
depth*: int
gas*: GasInt
contractAddress*: EthAddress
codeAddress*: EthAddress
sender*: EthAddress
value*: UInt256
data*: seq[byte]
flags*: MsgFlags
Computation* = ref object
returnStack*: seq[int]
output*: seq[byte]
vmState*: BaseVMState
gasMeter*: GasMeter
stack*: Stack
memory*: Memory
msg*: Message
code*: CodeStream
returnData*: seq[byte]
fork*: Fork
parent*, child*: Computation
continuation*: proc() {.gcsafe.}
touchedAccounts*: HashSet[EthAddress]
suicides*: HashSet[EthAddress]
logEntries*: seq[Log]
const const
ColdAccountAccessCost* = 2 ColdAccountAccessCost* = 2
WarmStorageReadCost* = 3 WarmStorageReadCost* = 3
@ -99,9 +186,9 @@ proc isCreate*(message: Message): bool = result
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
include include
./oph_defs,
./oph_helpers ./oph_helpers
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# End # End
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------

View File

@ -38,7 +38,7 @@ when not breakCircularDependency:
else: else:
import import
./interpreter/op_handlers/[oph_defs_kludge, oph_helpers_kludge] ./interpreter/op_handlers/oph_kludge
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Kludge END # Kludge END