nimbus-eth1/nimbus/vm_types.nim

92 lines
2.9 KiB
Nim
Raw 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.
2018-03-13 14:30:38 +00:00
import
tables,
constants, vm_state,
2018-05-30 16:11:15 +00:00
opcode_values, stint, eth_common,
vm / [code_stream, memory, stack, forks/gas_costs],
./logging
2018-03-13 14:30:38 +00:00
export GasInt, gas_costs
2018-05-30 16:11:15 +00:00
2018-03-13 14:30:38 +00:00
type
BaseComputation* = ref object of RootObj
# The execution computation
vmState*: BaseVMState
msg*: Message
memory*: Memory
stack*: Stack
gasMeter*: GasMeter
code*: CodeStream
children*: seq[BaseComputation]
rawOutput*: string
returnData*: string
error*: Error
2018-05-30 16:11:15 +00:00
logEntries*: seq[(EthAddress, seq[UInt256], string)]
2018-03-13 14:30:38 +00:00
shouldEraseReturnData*: bool
2018-05-30 16:11:15 +00:00
accountsToDelete*: Table[EthAddress, EthAddress]
opcodes*: Table[Op, proc(computation: var BaseComputation){.nimcall.}]
2018-03-13 14:30:38 +00:00
precompiles*: Table[string, Opcode]
gasCosts*: GasCosts # TODO - avoid allocating memory for this const
2018-03-13 14:30:38 +00:00
Error* = ref object
info*: string
burnsGas*: bool
erasesReturnData*: bool
Opcode* = ref object of RootObj
# TODO can't use a stack-allocated object because
# "BaseComputation is not a concrete type"
# TODO: We can probably remove this.
2018-03-13 14:30:38 +00:00
kind*: Op
runLogic*: proc(computation: var BaseComputation)
GasMeter* = ref object
logger*: Logger
gasRefunded*: GasInt
startGas*: GasInt
gasRemaining*: GasInt
Message* = ref object
# A message for VM computation
# depth = None
# code = None
# codeAddress = None
# createAddress = None
# shouldTransferValue = None
# isStatic = None
# logger = logging.getLogger("evm.vm.message.Message")
gas*: GasInt
gasPrice*: GasInt
2018-05-30 16:11:15 +00:00
to*: EthAddress
sender*: EthAddress
value*: UInt256
data*: seq[byte]
code*: string
2018-05-30 16:11:15 +00:00
internalOrigin*: EthAddress
internalCodeAddress*: EthAddress
depth*: int
2018-05-30 16:11:15 +00:00
internalStorageAddress*: EthAddress
shouldTransferValue*: bool
isStatic*: bool
isCreate*: bool
MessageOptions* = ref object
2018-05-30 16:11:15 +00:00
origin*: EthAddress
depth*: int
2018-05-30 16:11:15 +00:00
createAddress*: EthAddress
codeAddress*: EthAddress
shouldTransferValue*: bool
isStatic*: bool