mirror of
https://github.com/status-im/nimbus-eth1.git
synced 2025-01-12 21:34:33 +00:00
prepared v2state_transaction.nim so it can be compiled locally
details: use the -d:kludge:1 flag for syntax check
This commit is contained in:
parent
ff6921eb1a
commit
e6eee3f3a6
@ -19,7 +19,8 @@ import
|
|||||||
../op_codes,
|
../op_codes,
|
||||||
../../memory,
|
../../memory,
|
||||||
../../stack_defs,
|
../../stack_defs,
|
||||||
eth/common/eth_types
|
eth/common/eth_types,
|
||||||
|
sets
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# Kludge BEGIN
|
# Kludge BEGIN
|
||||||
@ -48,8 +49,37 @@ type
|
|||||||
bytes*: seq[byte]
|
bytes*: seq[byte]
|
||||||
pc*: int
|
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
|
BaseVMState* = ref object of RootObj
|
||||||
accountDb*: ReadOnlyStateDB
|
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
|
Message* = ref object
|
||||||
kind*: CallKind
|
kind*: CallKind
|
||||||
@ -75,6 +105,9 @@ type
|
|||||||
fork*: Fork
|
fork*: Fork
|
||||||
parent*, child*: Computation
|
parent*, child*: Computation
|
||||||
continuation*: proc() {.gcsafe.}
|
continuation*: proc() {.gcsafe.}
|
||||||
|
touchedAccounts*: HashSet[EthAddress]
|
||||||
|
suicides*: HashSet[EthAddress]
|
||||||
|
logEntries*: seq[Log]
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# Kludge END
|
# Kludge END
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
import
|
import
|
||||||
../../../errors,
|
../../../errors,
|
||||||
|
../forks_list,
|
||||||
../op_codes,
|
../op_codes,
|
||||||
./oph_defs_kludge,
|
./oph_defs_kludge,
|
||||||
eth/common/eth_types,
|
eth/common/eth_types,
|
||||||
@ -31,6 +32,7 @@ const
|
|||||||
MaxCallDepth* = 42
|
MaxCallDepth* = 42
|
||||||
|
|
||||||
# function stubs from state.nim
|
# function stubs from state.nim
|
||||||
|
proc `status=`*(v: BaseVMState; status: bool) = discard
|
||||||
template mutateStateDB*(vmState: BaseVMState, body: untyped) =
|
template mutateStateDB*(vmState: BaseVMState, body: untyped) =
|
||||||
block:
|
block:
|
||||||
var db {.inject.} = vmState.accountDb
|
var db {.inject.} = vmState.accountDb
|
||||||
@ -42,22 +44,28 @@ proc getBalance*[T](c: Computation, address: T): Uint256 = result
|
|||||||
proc accountExists*(c: Computation, address: EthAddress): bool = result
|
proc accountExists*(c: Computation, address: EthAddress): bool = result
|
||||||
|
|
||||||
# function stubs from computation.nim (to satisfy compiler logic)
|
# function stubs from computation.nim (to satisfy compiler logic)
|
||||||
|
proc execCallOrCreate*(cParam: Computation) = discard
|
||||||
|
proc refundSelfDestruct*(c: Computation) = discard
|
||||||
func shouldBurnGas*(c: Computation): bool = result
|
func shouldBurnGas*(c: Computation): bool = result
|
||||||
|
proc getGasRefund*(c: Computation): GasInt = result
|
||||||
proc newComputation*[A,B](v:A, m:B, salt = 0.u256): Computation = new result
|
proc newComputation*[A,B](v:A, m:B, salt = 0.u256): Computation = new result
|
||||||
proc isSuccess*(c: Computation): bool = result
|
proc isSuccess*(c: Computation): bool = result
|
||||||
|
proc isOriginComputation*(c: Computation): bool = result
|
||||||
proc merge*(c, child: Computation) = discard
|
proc merge*(c, child: Computation) = discard
|
||||||
template chainTo*(c, d: Computation, e: untyped) =
|
template chainTo*(c, d: Computation, e: untyped) =
|
||||||
c.child = d; c.continuation = proc() = e
|
c.child = d; c.continuation = proc() = e
|
||||||
|
|
||||||
# function stubs from accounts_cache.nim:
|
# function stubs from accounts_cache.nim (some also match state_db.nim):
|
||||||
func inAccessList*[A,B](ac: A; address: B): bool = false
|
func inAccessList*[A,B](ac: A; address: B): bool = false
|
||||||
proc accessList*[A,B](ac: var A, address: B) = discard
|
proc accessList*[A,B](ac: var A, address: B) = discard
|
||||||
|
proc incNonce*[A,B](ac: var A, address: B) = discard
|
||||||
|
proc addBalance*[A,B](ac: var A, address: B, delta: UInt256) = discard
|
||||||
|
|
||||||
# function stubs from gas_meter.nim
|
# function stubs from gas_meter.nim
|
||||||
proc consumeGas*(gasMeter: var GasMeter;amount: GasInt;reason: string) = discard
|
proc consumeGas*(gasMeter: var GasMeter;amount: GasInt;reason: string) = discard
|
||||||
proc returnGas*(gasMeter: var GasMeter; amount: GasInt) = discard
|
proc returnGas*(gasMeter: var GasMeter; amount: GasInt) = discard
|
||||||
|
|
||||||
# stubs from gas_costs.nim
|
# function stubs from gas_costs.nim
|
||||||
type
|
type
|
||||||
GasResult* =
|
GasResult* =
|
||||||
tuple[gasCost, gasRefund: GasInt]
|
tuple[gasCost, gasRefund: GasInt]
|
||||||
@ -72,8 +80,19 @@ type
|
|||||||
c_gasBalance*, c_currentMemSize*, c_memOffset*, c_memLength*: int64
|
c_gasBalance*, c_currentMemSize*, c_memOffset*, c_memLength*: int64
|
||||||
else:
|
else:
|
||||||
discard
|
discard
|
||||||
|
|
||||||
proc c_handler*(x: int; y: Uint256, z: GasParams): GasResult = result
|
proc c_handler*(x: int; y: Uint256, z: GasParams): GasResult = result
|
||||||
proc m_handler*(x: int; curMemSize, memOffset, memLen: int64): int = result
|
proc m_handler*(x: int; curMemSize, memOffset, memLen: int64): int = result
|
||||||
|
proc forkToSchedule*(fork: Fork): GasCosts = result
|
||||||
|
|
||||||
|
# function stubs from config.nim
|
||||||
|
proc toFork*[T](c: T; number: BlockNumber): Fork = result
|
||||||
|
|
||||||
|
# function stubs from transaction.nim
|
||||||
|
proc intrinsicGas*(tx: Transaction, fork: Fork): GasInt = result
|
||||||
|
|
||||||
|
# function stubs from message.nim
|
||||||
|
proc isCreate*(message: Message): bool = result
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# Kludge END
|
# Kludge END
|
||||||
|
@ -1,19 +1,48 @@
|
|||||||
# Nimbus
|
# Nimbus
|
||||||
# Copyright (c) 2018 Status Research & Development GmbH
|
# Copyright (c) 2018 Status Research & Development GmbH
|
||||||
# Licensed under either of
|
# Licensed under either of
|
||||||
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
|
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
|
||||||
# * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
|
# http://www.apache.org/licenses/LICENSE-2.0)
|
||||||
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
# * 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.
|
||||||
|
|
||||||
when defined(evmc_enabled):
|
const
|
||||||
{.fatal: "Flags \"evmc_enabled\" and \"vm2_enabled\" are mutually exclusive"}
|
# needed for compiling locally
|
||||||
|
kludge {.intdefine.}: int = 0
|
||||||
|
breakCircularDependency {.used.} = kludge > 0
|
||||||
|
|
||||||
import
|
import
|
||||||
options, sets,
|
|
||||||
eth/common, chronicles, ../db/accounts_cache,
|
|
||||||
../config, ./interpreter/gas_costs,
|
|
||||||
../transaction,
|
../transaction,
|
||||||
./computation, ./interpreter, ./state, ./types
|
./interpreter,
|
||||||
|
chronicles,
|
||||||
|
eth/common/eth_types,
|
||||||
|
options,
|
||||||
|
sets
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# Kludge BEGIN
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
when not breakCircularDependency:
|
||||||
|
import
|
||||||
|
../config,
|
||||||
|
../constants,
|
||||||
|
../db/accounts_cache,
|
||||||
|
./computation,
|
||||||
|
./state,
|
||||||
|
./types,
|
||||||
|
./interpreter/gas_costs,
|
||||||
|
eth/common
|
||||||
|
|
||||||
|
else:
|
||||||
|
import
|
||||||
|
./interpreter/op_handlers/[oph_defs_kludge, oph_helpers_kludge]
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# Kludge END
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
|
||||||
proc setupTxContext*(vmState: BaseVMState, origin: EthAddress, gasPrice: GasInt, forkOverride=none(Fork)) =
|
proc setupTxContext*(vmState: BaseVMState, origin: EthAddress, gasPrice: GasInt, forkOverride=none(Fork)) =
|
||||||
## this proc will be called each time a new transaction
|
## this proc will be called each time a new transaction
|
||||||
|
Loading…
x
Reference in New Issue
Block a user