mirror of
https://github.com/status-im/nimbus-eth1.git
synced 2025-01-12 13:24:21 +00:00
isolate vm_types as import/export wrapper
details: moved original vm_types.nim => vm/nvm_types.nim
This commit is contained in:
parent
a3db0f41d8
commit
ed59f602d5
@ -8,7 +8,7 @@
|
|||||||
import
|
import
|
||||||
chronicles, strformat, macros, options, times,
|
chronicles, strformat, macros, options, times,
|
||||||
sets, eth/[common, keys],
|
sets, eth/[common, keys],
|
||||||
constants, errors, vm_state, vm_types,
|
constants, errors, vm_state, vm/nvm_types,
|
||||||
vm/interpreter/[opcode_values, gas_meter, gas_costs, vm_forks],
|
vm/interpreter/[opcode_values, gas_meter, gas_costs, vm_forks],
|
||||||
vm/code_stream, vm/memory, vm/message, vm/stack, db/[accounts_cache, db_chain],
|
vm/code_stream, vm/memory, vm/message, vm/stack, db/[accounts_cache, db_chain],
|
||||||
utils/header, precompiles,
|
utils/header, precompiles,
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
import
|
import
|
||||||
chronicles, strformat, eth/common, # GasInt
|
chronicles, strformat, eth/common, # GasInt
|
||||||
errors, vm_types
|
errors, vm/nvm_types
|
||||||
|
|
||||||
logScope:
|
logScope:
|
||||||
topics = "vm gas"
|
topics = "vm gas"
|
||||||
|
@ -11,7 +11,7 @@ import
|
|||||||
vm/interpreter/utils/[macros_procs_opcodes, utils_numeric],
|
vm/interpreter/utils/[macros_procs_opcodes, utils_numeric],
|
||||||
vm/interpreter/[gas_meter, gas_costs, opcode_values, vm_forks],
|
vm/interpreter/[gas_meter, gas_costs, opcode_values, vm_forks],
|
||||||
vm/[memory, stack, code_stream, computation],
|
vm/[memory, stack, code_stream, computation],
|
||||||
vm_state, errors, constants, vm_types,
|
vm_state, errors, constants, vm/nvm_types,
|
||||||
db/[db_chain, accounts_cache]
|
db/[db_chain, accounts_cache]
|
||||||
|
|
||||||
when defined(evmc_enabled):
|
when defined(evmc_enabled):
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
import
|
import
|
||||||
macros, strformat, stint, eth/common,
|
macros, strformat, stint, eth/common,
|
||||||
vm/[computation, stack, code_stream, memory],
|
vm/[computation, stack, code_stream, memory],
|
||||||
vm_types, errors, vm/interpreter/[gas_meter, opcode_values],
|
vm/nvm_types, errors, vm/interpreter/[gas_meter, opcode_values],
|
||||||
vm/interpreter/utils/utils_numeric
|
vm/interpreter/utils/utils_numeric
|
||||||
|
|
||||||
when defined(evmc_enabled):
|
when defined(evmc_enabled):
|
||||||
|
@ -9,7 +9,7 @@ import
|
|||||||
tables, macros,
|
tables, macros,
|
||||||
chronicles,
|
chronicles,
|
||||||
vm/interpreter/[opcode_values, opcodes_impl, vm_forks, gas_costs, gas_meter, utils/macros_gen_opcodes],
|
vm/interpreter/[opcode_values, opcodes_impl, vm_forks, gas_costs, gas_meter, utils/macros_gen_opcodes],
|
||||||
vm/code_stream, vm_types, errors, precompiles, vm/stack,
|
vm/code_stream, vm/nvm_types, errors, precompiles, vm/stack,
|
||||||
terminal # Those are only needed for logging
|
terminal # Those are only needed for logging
|
||||||
|
|
||||||
logScope:
|
logScope:
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
# * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
|
# * 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.
|
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
||||||
|
|
||||||
import vm_types
|
import vm/nvm_types
|
||||||
|
|
||||||
proc isCreate*(message: Message): bool =
|
proc isCreate*(message: Message): bool =
|
||||||
message.kind in {evmcCreate, evmcCreate2}
|
message.kind in {evmcCreate, evmcCreate2}
|
||||||
|
117
nimbus/vm/nvm_types.nim
Normal file
117
nimbus/vm/nvm_types.nim
Normal file
@ -0,0 +1,117 @@
|
|||||||
|
# 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.
|
||||||
|
|
||||||
|
import
|
||||||
|
tables, eth/common,
|
||||||
|
options, json, sets,
|
||||||
|
vm/[memory, stack, code_stream],
|
||||||
|
vm/interpreter/[gas_costs, opcode_values, vm_forks],
|
||||||
|
# TODO - will be hidden at a lower layer
|
||||||
|
db/[db_chain, accounts_cache]
|
||||||
|
|
||||||
|
when defined(evmc_enabled):
|
||||||
|
import
|
||||||
|
./vm/evmc_api
|
||||||
|
|
||||||
|
type
|
||||||
|
VMFlag* = enum
|
||||||
|
ExecutionOK
|
||||||
|
GenerateWitness
|
||||||
|
ClearCache
|
||||||
|
|
||||||
|
BaseVMState* = ref object of RootObj
|
||||||
|
prevHeaders* : seq[BlockHeader]
|
||||||
|
chaindb* : BaseChainDB
|
||||||
|
accessLogs* : AccessLogs
|
||||||
|
blockHeader* : BlockHeader
|
||||||
|
name* : string
|
||||||
|
flags* : set[VMFlag]
|
||||||
|
tracer* : TransactionTracer
|
||||||
|
logEntries* : seq[Log]
|
||||||
|
receipts* : seq[Receipt]
|
||||||
|
accountDb* : AccountsCache
|
||||||
|
cumulativeGasUsed*: GasInt
|
||||||
|
touchedAccounts*: HashSet[EthAddress]
|
||||||
|
suicides* : HashSet[EthAddress]
|
||||||
|
txOrigin* : EthAddress
|
||||||
|
txGasPrice* : GasInt
|
||||||
|
gasCosts* : GasCosts
|
||||||
|
fork* : Fork
|
||||||
|
minerAddress* : EthAddress
|
||||||
|
|
||||||
|
AccessLogs* = ref object
|
||||||
|
reads*: Table[string, string]
|
||||||
|
writes*: Table[string, string]
|
||||||
|
|
||||||
|
TracerFlags* {.pure.} = enum
|
||||||
|
EnableTracing
|
||||||
|
DisableStorage
|
||||||
|
DisableMemory
|
||||||
|
DisableStack
|
||||||
|
DisableState
|
||||||
|
DisableStateDiff
|
||||||
|
EnableAccount
|
||||||
|
|
||||||
|
TransactionTracer* = object
|
||||||
|
trace*: JsonNode
|
||||||
|
flags*: set[TracerFlags]
|
||||||
|
accounts*: HashSet[EthAddress]
|
||||||
|
storageKeys*: seq[HashSet[Uint256]]
|
||||||
|
|
||||||
|
Computation* = ref object
|
||||||
|
# The execution computation
|
||||||
|
vmState*: BaseVMState
|
||||||
|
when defined(evmc_enabled):
|
||||||
|
host*: HostContext
|
||||||
|
msg*: Message
|
||||||
|
memory*: Memory
|
||||||
|
stack*: Stack
|
||||||
|
returnStack*: seq[int]
|
||||||
|
gasMeter*: GasMeter
|
||||||
|
code*: CodeStream
|
||||||
|
output*: seq[byte]
|
||||||
|
returnData*: seq[byte]
|
||||||
|
error*: Error
|
||||||
|
touchedAccounts*: HashSet[EthAddress]
|
||||||
|
suicides*: HashSet[EthAddress]
|
||||||
|
logEntries*: seq[Log]
|
||||||
|
savePoint*: SavePoint
|
||||||
|
instr*: Op
|
||||||
|
opIndex*: int
|
||||||
|
|
||||||
|
Error* = ref object
|
||||||
|
info*: string
|
||||||
|
burnsGas*: bool
|
||||||
|
|
||||||
|
GasMeter* = object
|
||||||
|
gasRefunded*: GasInt
|
||||||
|
gasRemaining*: GasInt
|
||||||
|
|
||||||
|
CallKind* = enum
|
||||||
|
evmcCall = 0, # CALL
|
||||||
|
evmcDelegateCall = 1, # DELEGATECALL
|
||||||
|
evmcCallCode = 2, # CALLCODE
|
||||||
|
evmcCreate = 3, # CREATE
|
||||||
|
evmcCreate2 = 4 # CREATE2
|
||||||
|
|
||||||
|
MsgFlags* = enum
|
||||||
|
emvcNoFlags = 0
|
||||||
|
emvcStatic = 1
|
||||||
|
|
||||||
|
Message* = ref object
|
||||||
|
kind*: CallKind
|
||||||
|
depth*: int
|
||||||
|
gas*: GasInt
|
||||||
|
sender*: EthAddress
|
||||||
|
contractAddress*: EthAddress
|
||||||
|
codeAddress*: EthAddress
|
||||||
|
value*: UInt256
|
||||||
|
data*: seq[byte]
|
||||||
|
flags*: MsgFlags
|
@ -1,5 +1,5 @@
|
|||||||
import
|
import
|
||||||
vm_types,
|
vm/nvm_types,
|
||||||
vm/interpreter/[gas_meter, gas_costs, utils/utils_numeric, vm_forks],
|
vm/interpreter/[gas_meter, gas_costs, utils/utils_numeric, vm_forks],
|
||||||
errors, stint, eth/[keys, common], chronicles, tables, macros,
|
errors, stint, eth/[keys, common], chronicles, tables, macros,
|
||||||
math, nimcrypto, bncurve/[fields, groups], vm/blake2b_f, vm/blscurve
|
math, nimcrypto, bncurve/[fields, groups], vm/blake2b_f, vm/blscurve
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import
|
import
|
||||||
json, strutils, sets, hashes,
|
json, strutils, sets, hashes,
|
||||||
chronicles, nimcrypto, eth/common, stint,
|
chronicles, nimcrypto, eth/common, stint,
|
||||||
vm_types, memory, vm/stack, db/accounts_cache,
|
vm/nvm_types, memory, vm/stack, db/accounts_cache,
|
||||||
eth/trie/hexary,
|
eth/trie/hexary,
|
||||||
vm/interpreter/opcode_values
|
vm/interpreter/opcode_values
|
||||||
|
|
||||||
|
@ -1,112 +1,54 @@
|
|||||||
# 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.
|
||||||
|
|
||||||
import
|
import
|
||||||
tables, eth/common,
|
./vm/nvm_types as vmt
|
||||||
options, json, sets,
|
|
||||||
vm/[memory, stack, code_stream],
|
export
|
||||||
vm/interpreter/[gas_costs, opcode_values, vm_forks], # TODO - will be hidden at a lower layer
|
vmt.AccessLogs,
|
||||||
db/[db_chain, accounts_cache]
|
vmt.BaseVMState,
|
||||||
|
vmt.CallKind,
|
||||||
|
vmt.Computation,
|
||||||
|
vmt.Error,
|
||||||
|
vmt.GasMeter,
|
||||||
|
vmt.Message,
|
||||||
|
vmt.MsgFlags,
|
||||||
|
vmt.TracerFlags,
|
||||||
|
vmt.TransactionTracer,
|
||||||
|
vmt.VMFlag
|
||||||
|
|
||||||
when defined(evmc_enabled):
|
when defined(evmc_enabled):
|
||||||
import ./vm/evmc_api
|
import
|
||||||
|
./vm/evmc_api as evmc
|
||||||
|
export
|
||||||
|
evmc.HostContext,
|
||||||
|
evmc.accountExists,
|
||||||
|
evmc.call,
|
||||||
|
evmc.copyCode,
|
||||||
|
evmc.emitLog,
|
||||||
|
evmc.getBalance,
|
||||||
|
evmc.getBlockHash,
|
||||||
|
evmc.getCodeHash,
|
||||||
|
evmc.getCodeSize,
|
||||||
|
evmc.getStorage,
|
||||||
|
evmc.getTxContext,
|
||||||
|
evmc.init,
|
||||||
|
evmc.nim_create_nimbus_vm,
|
||||||
|
evmc.nim_host_create_context,
|
||||||
|
evmc.nim_host_destroy_context,
|
||||||
|
evmc.nim_host_get_interface,
|
||||||
|
evmc.nimbus_host_interface,
|
||||||
|
evmc.nimbus_message,
|
||||||
|
evmc.nimbus_result,
|
||||||
|
evmc.nimbus_tx_context,
|
||||||
|
evmc.selfDestruct,
|
||||||
|
evmc.setStorage
|
||||||
|
|
||||||
type
|
# End
|
||||||
VMFlag* = enum
|
|
||||||
ExecutionOK
|
|
||||||
GenerateWitness
|
|
||||||
ClearCache
|
|
||||||
|
|
||||||
BaseVMState* = ref object of RootObj
|
|
||||||
prevHeaders* : seq[BlockHeader]
|
|
||||||
chaindb* : BaseChainDB
|
|
||||||
accessLogs* : AccessLogs
|
|
||||||
blockHeader* : BlockHeader
|
|
||||||
name* : string
|
|
||||||
flags* : set[VMFlag]
|
|
||||||
tracer* : TransactionTracer
|
|
||||||
logEntries* : seq[Log]
|
|
||||||
receipts* : seq[Receipt]
|
|
||||||
accountDb* : AccountsCache
|
|
||||||
cumulativeGasUsed*: GasInt
|
|
||||||
touchedAccounts*: HashSet[EthAddress]
|
|
||||||
suicides* : HashSet[EthAddress]
|
|
||||||
txOrigin* : EthAddress
|
|
||||||
txGasPrice* : GasInt
|
|
||||||
gasCosts* : GasCosts
|
|
||||||
fork* : Fork
|
|
||||||
minerAddress* : EthAddress
|
|
||||||
|
|
||||||
AccessLogs* = ref object
|
|
||||||
reads*: Table[string, string]
|
|
||||||
writes*: Table[string, string]
|
|
||||||
|
|
||||||
TracerFlags* {.pure.} = enum
|
|
||||||
EnableTracing
|
|
||||||
DisableStorage
|
|
||||||
DisableMemory
|
|
||||||
DisableStack
|
|
||||||
DisableState
|
|
||||||
DisableStateDiff
|
|
||||||
EnableAccount
|
|
||||||
|
|
||||||
TransactionTracer* = object
|
|
||||||
trace*: JsonNode
|
|
||||||
flags*: set[TracerFlags]
|
|
||||||
accounts*: HashSet[EthAddress]
|
|
||||||
storageKeys*: seq[HashSet[Uint256]]
|
|
||||||
|
|
||||||
Computation* = ref object
|
|
||||||
# The execution computation
|
|
||||||
vmState*: BaseVMState
|
|
||||||
when defined(evmc_enabled):
|
|
||||||
host*: HostContext
|
|
||||||
msg*: Message
|
|
||||||
memory*: Memory
|
|
||||||
stack*: Stack
|
|
||||||
returnStack*: seq[int]
|
|
||||||
gasMeter*: GasMeter
|
|
||||||
code*: CodeStream
|
|
||||||
output*: seq[byte]
|
|
||||||
returnData*: seq[byte]
|
|
||||||
error*: Error
|
|
||||||
touchedAccounts*: HashSet[EthAddress]
|
|
||||||
suicides*: HashSet[EthAddress]
|
|
||||||
logEntries*: seq[Log]
|
|
||||||
savePoint*: SavePoint
|
|
||||||
instr*: Op
|
|
||||||
opIndex*: int
|
|
||||||
|
|
||||||
Error* = ref object
|
|
||||||
info*: string
|
|
||||||
burnsGas*: bool
|
|
||||||
|
|
||||||
GasMeter* = object
|
|
||||||
gasRefunded*: GasInt
|
|
||||||
gasRemaining*: GasInt
|
|
||||||
|
|
||||||
CallKind* = enum
|
|
||||||
evmcCall = 0, # CALL
|
|
||||||
evmcDelegateCall = 1, # DELEGATECALL
|
|
||||||
evmcCallCode = 2, # CALLCODE
|
|
||||||
evmcCreate = 3, # CREATE
|
|
||||||
evmcCreate2 = 4 # CREATE2
|
|
||||||
|
|
||||||
MsgFlags* = enum
|
|
||||||
emvcNoFlags = 0
|
|
||||||
emvcStatic = 1
|
|
||||||
|
|
||||||
Message* = ref object
|
|
||||||
kind*: CallKind
|
|
||||||
depth*: int
|
|
||||||
gas*: GasInt
|
|
||||||
sender*: EthAddress
|
|
||||||
contractAddress*: EthAddress
|
|
||||||
codeAddress*: EthAddress
|
|
||||||
value*: UInt256
|
|
||||||
data*: seq[byte]
|
|
||||||
flags*: MsgFlags
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user