Compare commits

...

6 Commits

Author SHA1 Message Date
andri lim 8249af6a01
Merge d9d01c9f28 into af34f90fe4 2024-06-16 09:17:36 +07:00
jangko d9d01c9f28
Add missing flip256 call 2024-06-16 08:42:24 +07:00
jangko d3f6ec2e6d
fix evmc imports 2024-06-16 00:09:02 +07:00
jangko 53ce79a9b1
Remove VMError 2024-06-15 23:19:27 +07:00
jangko 351be21c5b
Fix copyright year 2024-06-15 23:08:24 +07:00
jangko f693a55056
Remove EVM indirect imports and unused EVM errors
Those indirect imports are used when there was two EVMs.
2024-06-15 23:03:02 +07:00
66 changed files with 154 additions and 613 deletions

View File

@ -15,8 +15,8 @@ import
constants,
db/ledger,
transaction,
vm_state,
vm_types,
evm/state,
evm/types,
core/dao,
core/validate,
core/chain/chain_desc,

View File

@ -24,7 +24,7 @@ import
confutils/std/net
],
eth/[common, net/utils, net/nat, p2p/bootnodes, p2p/enode, p2p/discoveryv5/enr],
"."/[constants, vm_compile_info, version],
"."/[constants, compile_info, version],
common/chain_config,
db/opts

View File

@ -13,7 +13,7 @@
import
../../common/common,
../../utils/utils,
../../vm_types,
../../evm/types,
../pow
export

View File

@ -13,8 +13,8 @@
import
results,
../../db/ledger,
../../vm_state,
../../vm_types,
../../evm/state,
../../evm/types,
../executor,
../validate,
./chain_desc,

View File

@ -11,8 +11,8 @@
import
../../db/ledger,
../../common/common,
../../vm_state,
../../vm_types
../../evm/state,
../../evm/types
{.push raises: [].}

View File

@ -13,8 +13,8 @@
import
../../common/common,
../../db/ledger,
../../vm_state,
../../vm_types,
../../evm/state,
../../evm/types,
eth/[bloom]
type

View File

@ -14,8 +14,8 @@ import
../../constants,
../../db/ledger,
../../transaction,
../../vm_state,
../../vm_types,
../../evm/state,
../../evm/types,
../dao,
./calculate_reward,
./executor_helpers,

View File

@ -18,8 +18,8 @@ import
../../transaction/call_evm,
../../transaction/call_common,
../../transaction,
../../vm_state,
../../vm_types,
../../evm/state,
../../evm/types,
../../constants,
../validate

View File

@ -20,8 +20,8 @@ import
../../constants,
../../db/ledger,
../../utils/utils,
../../vm_state,
../../vm_types,
../../evm/state,
../../evm/types,
../eip4844,
../pow/difficulty,
../executor,

View File

@ -14,8 +14,8 @@
import
../../../common/common,
../../../vm_state,
../../../vm_types,
../../../evm/state,
../../../evm/types,
../../validate,
../../eip4844,
../tx_chain,

View File

@ -25,8 +25,8 @@ import
"../.."/[dao, executor, validate, eip4844, casper],
../../../transaction/call_evm,
../../../transaction,
../../../vm_state,
../../../vm_types,
../../../evm/state,
../../../evm/types,
".."/[tx_chain, tx_desc, tx_item, tx_tabs, tx_tabs/tx_status, tx_info],
"."/[tx_bucket, tx_classify]

View File

@ -1,5 +1,5 @@
# Nimbus
# Copyright (c) 2018 Status Research & Development GmbH
# Copyright (c) 2018-2024 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)
@ -12,65 +12,11 @@ type
BlockNotFound* = object of EVMError
## The block with the given number/hash does not exist.
ParentNotFound* = object of EVMError
## The parent of a given block does not exist.
CanonicalHeadNotFound* = object of EVMError
## The chain has no canonical head.
ValidationError* = object of EVMError
## Error to signal something does not pass a validation check.
VMError* = object of EVMError
## Class of errors which can be raised during VM execution.
OutOfGas* = object of VMError
## Error signaling that VM execution has run out of gas.
InsufficientStack* = object of VMError
## Error signaling that the stack is empty.
FullStack* = object of VMError
## Error signaling that the stack is full.
InvalidJumpDestination* = object of VMError
## Error signaling that the jump destination for a JUMPDEST operation is invalid.
InvalidInstruction* = object of VMError
## Error signaling that an opcode is invalid.
InsufficientFunds* = object of VMError
## Error signaling that an account has insufficient funds to transfer the
## requested value.
StackDepthError* = object of VMError
## Error signaling that the call stack has exceeded it's maximum allowed depth.
ContractCreationCollision* = object of VMError
## Error signaling that there was an address collision during contract creation.
WriteProtection* = object of VMError
## Error raised if an attempt to modify the state database is made while
## operating inside of a STATICCALL context.
OutOfBoundsRead* = object of VMError
## Error raised to indicate an attempt was made to read data beyond the
## boundaries of the buffer (such as with RETURNDATACOPY)
TypeError* = object of VMError
## Error when invalid values are found
NotImplementedError* = object of VMError
## Not implemented error
StaticContextError* = object of VMError
## State changes not allowed in static call context
VmStateError* = object of VMError
## VM state error relay
InitcodeError* = object of EVMError
## Error to signal inicode size > EIP3860_MAX_INITCODE_SIZE
CoreDbApiError* = object of CatchableError
## Errors related to `CoreDB` API

View File

@ -87,7 +87,7 @@ template getBlockNumber*(c: Computation): UInt256 =
template getDifficulty*(c: Computation): DifficultyInt =
when evmc_enabled:
UInt256.fromEvmc c.host.getTxContext().block_prev_randao
fromEvmc c.host.getTxContext().block_prev_randao.flip256
else:
c.vmState.difficultyOrPrevRandao
@ -99,7 +99,7 @@ template getGasLimit*(c: Computation): GasInt =
template getBaseFee*(c: Computation): UInt256 =
when evmc_enabled:
UInt256.fromEvmc c.host.getTxContext().block_base_fee
fromEvmc c.host.getTxContext().block_base_fee.flip256
else:
c.vmState.blockCtx.baseFeePerGas.get(0.u256)
@ -117,7 +117,8 @@ template getOrigin*(c: Computation): EthAddress =
template getGasPrice*(c: Computation): GasInt =
when evmc_enabled:
UInt256.fromEvmc(c.host.getTxContext().tx_gas_price).truncate(GasInt)
fromEvmc(c.host.getTxContext().tx_gas_price.flip256).
truncate(GasInt)
else:
c.vmState.txCtx.gasPrice
@ -135,7 +136,7 @@ template getVersionedHashesLen*(c: Computation): int =
template getBlobBaseFee*(c: Computation): UInt256 =
when evmc_enabled:
UInt256.fromEvmc c.host.getTxContext().blob_base_fee
fromEvmc c.host.getTxContext().blob_base_fee.flip256
else:
c.vmState.txCtx.blobBaseFee

View File

@ -115,7 +115,7 @@ proc accountExists*(ctx: HostContext, address: EthAddress): bool =
proc getStorage*(ctx: HostContext, address: EthAddress, key: UInt256): UInt256 =
var key = toEvmc(key)
UInt256.fromEvmc ctx.host.get_storage(ctx.context, address, key.addr)
fromEvmc ctx.host.get_storage(ctx.context, address, key.addr).flip256
proc setStorage*(ctx: HostContext, address: EthAddress,
key, value: UInt256): evmc_storage_status =
@ -125,7 +125,7 @@ proc setStorage*(ctx: HostContext, address: EthAddress,
ctx.host.set_storage(ctx.context, address, key.addr, value.addr)
proc getBalance*(ctx: HostContext, address: EthAddress): UInt256 =
UInt256.fromEvmc ctx.host.get_balance(ctx.context, address)
fromEvmc ctx.host.get_balance(ctx.context, address).flip256
proc getCodeSize*(ctx: HostContext, address: EthAddress): uint =
ctx.host.get_code_size(ctx.context, address)
@ -159,11 +159,11 @@ proc accessAccount*(ctx: HostContext,
proc accessStorage*(ctx: HostContext, address: EthAddress,
key: UInt256): evmc_access_status =
var key = toEvmc(key)
ctx.host.access_storage(ctx.context, address, key)
ctx.host.access_storage(ctx.context, address, key.addr)
proc getTransientStorage*(ctx: HostContext, address: EthAddress, key: UInt256): UInt256 =
var key = toEvmc(key)
UInt256.fromEvmc ctx.host.get_transient_storage(ctx.context, address, key.addr)
fromEvmc ctx.host.get_transient_storage(ctx.context, address, key.addr).flip256
proc setTransientStorage*(ctx: HostContext, address: EthAddress,
key, value: UInt256) =
@ -179,4 +179,4 @@ template getBlockNumber*(ctx: HostContext): uint64 =
ctx.getTxContext().block_number.uint64
template getChainId*(ctx: HostContext): uint64 =
UInt256.fromEvmc(ctx.getTxContext().chain_id).truncate(uint64)
fromEvmc(ctx.getTxContext().chain_id.flip256).truncate(uint64)

View File

@ -1,5 +1,5 @@
# Nimbus
# Copyright (c) 2020-2023 Status Research & Development GmbH
# Copyright (c) 2020-2024 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)
@ -14,49 +14,26 @@ import
evmc/evmc,
../utils/utils
const
evmc_native* {.booldefine.} = false
template toEvmc*(n: UInt256): evmc_uint256be =
cast[evmc_uint256be](n)
func toEvmc*(a: EthAddress): evmc_address {.inline.} =
cast[evmc_address](a)
template toEvmc*(n: Hash256): evmc_bytes32 =
cast[evmc_bytes32](n)
func toEvmc*(h: Hash256 | ContractSalt): evmc_bytes32 {.inline.} =
doAssert sizeof(h) == sizeof(evmc_bytes32)
cast[evmc_bytes32](h)
template toEvmc*(address: EthAddress): evmc_address =
cast[evmc_address](address)
func toEvmc*(n: UInt256): evmc_uint256be {.inline.} =
when evmc_native:
cast[evmc_uint256be](n)
else:
cast[evmc_uint256be](n.toBytesBE)
template fromEvmc*(n: evmc_uint256be): UInt256 =
cast[UInt256](n)
func fromEvmc*(T: type, n: evmc_bytes32): T {.inline.} =
when T is Hash256 | ContractSalt:
doAssert sizeof(n) == sizeof(T)
cast[T](n)
elif T is UInt256:
when evmc_native:
cast[UInt256](n)
else:
UInt256.fromBytesBE(n.bytes)
else:
{.error: "cannot convert unsupported evmc type".}
template fromEvmc*(address: evmc_address): EthAddress =
cast[EthAddress](address)
func fromEvmc*(a: evmc_address): EthAddress {.inline.} =
cast[EthAddress](a)
template flip256*(word256: evmc_uint256be): evmc_uint256be =
cast[evmc_uint256be](UInt256.fromBytesBE(word256.bytes).toBytes(cpuEndian))
when isMainModule:
import ../constants
var a: evmc_address
a.bytes[19] = 3.byte
var na = fromEvmc(a)
assert(a == toEvmc(na))
var b = stuint(10, 256)
var eb = b.toEvmc
assert(b == fromEvmc(UInt256, eb))
var h = EMPTY_SHA3
var eh = toEvmc(h)
assert(h == fromEvmc(Hash256, eh))
var s = cast[ContractSalt](EMPTY_ROOT_HASH)
var es = toEvmc(s)
assert(s == fromEvmc(ContractSalt, es))
template isCreate*(kind: evmc_call_kind): bool =
kind in {EVMC_CREATE, EVMC_CREATE2}
template isZero*(n: evmc_bytes32): bool =
n == default(evmc_bytes32)

View File

@ -1,5 +1,5 @@
# Nimbus
# Copyright (c) 2021-2024 Status Research & Development GmbH
# Copyright (c) 2023-2024 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)
@ -9,10 +9,19 @@
# according to those terms.
import
evm/state_transactions as vmx
./interpreter/utils/utils_numeric,
./interpreter/gas_costs,
./interpreter/gas_meter,
./interpreter/op_codes,
./code_stream,
./stack,
./memory
export
vmx.execComputation,
vmx.execSysCall
# End
utils_numeric,
code_stream,
gas_costs,
gas_meter,
op_codes,
memory,
stack

View File

@ -145,7 +145,7 @@ const
input_data: cpt.memory.readPtr(memPos),
input_size: memLen.uint,
value: toEvmc(endowment),
create2_salt: toEvmc(ZERO_CONTRACTSALT),
create2_salt: ZERO_CONTRACTSALT,
)
c.execSubCreate(msg)
else:
@ -228,7 +228,7 @@ const
input_data: cpt.memory.readPtr(memPos),
input_size: memLen.uint,
value: toEvmc(endowment),
create2_salt: toEvmc(salt),
create2_salt: salt,
)
c.execSubCreate(msg)
else:

View File

@ -18,7 +18,7 @@ import
../db/[state_db],
../rpc/rpc_types,
../rpc/rpc_utils,
".."/[transaction, vm_state, config, constants],
".."/[transaction, evm/state, config, constants],
../common/common,
../transaction/call_evm,
../core/[tx_pool, tx_pool/tx_item],

View File

@ -8,7 +8,7 @@
# those terms.
import
../nimbus/vm_compile_info
../nimbus/compile_info
import
std/[os, strutils, net],

View File

@ -12,7 +12,7 @@ import
json_rpc/rpcserver,
./rpc_utils,
./rpc_types,
../tracer, ../vm_types,
../tracer, ../evm/types,
../common/common,
../beacon/web3_eth_conv,
../core/tx_pool,

View File

@ -11,18 +11,22 @@
import
std/[typetraits],
json_rpc/rpcserver, stint, web3/conversions,
json_rpc/rpcserver,
web3/conversions,
eth/p2p,
../[transaction, vm_state, constants, vm_types],
../db/state_db,
rpc_types, rpc_utils,
../common/common,
../utils/utils,
../beacon/web3_eth_conv,
./filters,
stint,
../core/executor/process_block,
../db/ledger,
../[transaction, constants],
../beacon/web3_eth_conv,
../stateless/multi_keys,
../evm/[state, types],
../common/common,
../db/state_db,
../utils/utils,
../db/ledger,
./rpc_types,
./rpc_utils,
./filters,
./p2p
type

View File

@ -15,7 +15,7 @@ import
json_serialization, web3/conversions, json_serialization/stew/results,
eth/common/eth_types_json_serialization,
eth/[keys, rlp, p2p],
".."/[transaction, vm_state, constants],
".."/[transaction, evm/state, constants],
../db/state_db,
./rpc_types, ./rpc_utils, ./oracle,
../transaction/call_evm,

View File

@ -13,7 +13,7 @@ import
chronicles,
../common/common,
../transaction/call_common,
../vm_types,
../evm/types,
../beacon/web3_eth_conv,
../evm/evm_errors,
./rpc_types

View File

@ -22,8 +22,8 @@ import
../transaction/call_evm,
../core/eip4844,
../beacon/web3_eth_conv,
../vm_types,
../vm_state,
../evm/types,
../evm/state,
../evm/precompiles,
../evm/tracer/access_list_tracer,
../evm/evm_errors

View File

@ -91,7 +91,7 @@ proc inPool(ctx: EthWireRef, txHash: Hash256): bool =
proc successorHeader(db: CoreDbRef,
h: BlockHeader,
output: var BlockHeader,
skip = 0'u): bool {.gcsafe, raises: [RlpError].} =
skip = 0'u): bool =
let offset = 1 + skip.BlockNumber
if h.number <= (not 0.BlockNumber) - offset:
result = db.getBlockHeader(h.number + offset, output)
@ -99,15 +99,14 @@ proc successorHeader(db: CoreDbRef,
proc ancestorHeader(db: CoreDbRef,
h: BlockHeader,
output: var BlockHeader,
skip = 0'u): bool {.gcsafe, raises: [RlpError].} =
skip = 0'u): bool =
let offset = 1 + skip.BlockNumber
if h.number >= offset:
result = db.getBlockHeader(h.number - offset, output)
proc blockHeader(db: CoreDbRef,
b: HashOrNum,
output: var BlockHeader): bool
{.gcsafe, raises: [RlpError].} =
output: var BlockHeader): bool =
if b.isHash:
db.getBlockHeader(b.hash, output)
else:

View File

@ -14,7 +14,10 @@ import
./db/[core_db, ledger],
./utils/utils,
./evm/tracer/legacy_tracer,
"."/[constants, vm_state, vm_types, transaction, core/executor],
./constants,
./transaction,
./core/executor,
./evm/[state, types],
nimcrypto/utils as ncrutils,
web3/conversions, ./launcher,
results,

View File

@ -7,7 +7,7 @@
import
./constants, ./errors, eth/[common, keys], ./utils/utils,
common/evmforks, ./vm_gas_costs
common/evmforks, ./evm/internals
import eth/common/transaction as common_transaction
export common_transaction, errors

View File

@ -12,9 +12,10 @@ import
eth/common/eth_types, stint, stew/ptrops,
chronos,
results,
".."/[vm_types, vm_state, vm_computation],
".."/[vm_internals, vm_precompiles, vm_gas_costs],
".."/[db/ledger],
../evm/[types, state, computation],
../evm/[precompiles, internals],
../evm/state_transactions,
../db/ledger,
../common/evmforks,
../core/eip4844,
./host_types
@ -22,8 +23,6 @@ import
when defined(evmc_enabled):
import ../utils/utils
import ./host_services
else:
import ../vm_state_transactions
type
# Standard call parameters.

View File

@ -12,7 +12,7 @@ import
chronicles,
chronos,
eth/common/eth_types_rlp,
".."/[vm_types, vm_state, vm_gas_costs],
../evm/[types, state, internals],
../db/ledger,
../common/common,
../evm/evm_errors,

View File

@ -10,7 +10,7 @@
import
./host_types, evmc/evmc,
".."/[vm_types, vm_computation, vm_state_transactions]
".."/[evm/types, evm/computation, evm/state_transactions]
proc evmcReleaseResult(result: var evmc_result) {.cdecl.} =
dealloc(result.output_data)

View File

@ -12,7 +12,9 @@ import
eth/common/eth_types,
stew/ptrops,
stint,
".."/[vm_types, vm_computation],
../evm/types,
../evm/computation,
../evm/interpreter_dispatch,
../utils/utils,
"."/[host_types, host_trace]

View File

@ -13,7 +13,7 @@ import
stint, chronicles,
eth/common/eth_types, ../db/ledger,
../common/[evmforks, common],
".."/[vm_state, vm_computation, vm_internals, vm_gas_costs],
../evm/[state, computation, internals],
./host_types, ./host_trace, ./host_call_nested,
stew/saturation_arith

View File

@ -1,13 +1,19 @@
# Nimbus - Types and helpers used at the boundary of transactions/RPC and EVMC/EVM
#
# Copyright (c) 2019-2021 Status Research & Development GmbH
# Copyright (c) 2019-2024 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
sets, stint, evmc/evmc, eth/common/eth_types, ../vm_types
stint, evmc/evmc,
eth/common/eth_types,
../evm/types,
../evm/evmc_helpers
export
evmc_helpers
# Object `TransactionHost` represents "EVMC host" to the EVM. "Host services"
# manage account state outside EVM such as balance transfers, storage, logs and
@ -63,34 +69,6 @@ type
saveComputation*: seq[Computation]
hostInterface*: ptr evmc_host_interface
# These versions of `toEvmc` and `fromEvmc` don't flip big/little-endian like
# the older functions in `evmc_helpers`. New code only flips with _explicit_
# calls to `flip256` where it is wanted.
template toEvmc*(n: UInt256): evmc_uint256be =
cast[evmc_uint256be](n)
template toEvmc*(n: Hash256): evmc_bytes32 =
cast[evmc_bytes32](n)
template toEvmc*(address: EthAddress): evmc_address =
cast[evmc_address](address)
template fromEvmc*(n: evmc_uint256be): UInt256 =
cast[UInt256](n)
template fromEvmc*(address: evmc_address): EthAddress =
cast[EthAddress](address)
template flip256*(word256: evmc_uint256be): evmc_uint256be =
cast[evmc_uint256be](UInt256.fromBytesBE(word256.bytes).toBytes(cpuEndian))
template isCreate*(kind: EvmcCallKind): bool =
kind in {EVMC_CREATE, EVMC_CREATE2}
template isZero*(n: evmc_bytes32): bool =
n == default(evmc_bytes32)
# Nim quirks: Exporting `evmc_status_code` (etc) are needed to access the enum
# values, even though alias `EnumStatusCode` is already exported. Exporting
# `evmc_flags` won't export the flags, `evmc_flag_bit_shifts` must be used.

View File

@ -12,8 +12,8 @@ import
std/[options, json],
../common/common,
stew/byteutils,
../vm_state,
../vm_types,
../evm/state,
../evm/types,
../db/ledger,
./utils,
./state_dump

View File

@ -66,8 +66,12 @@ func hasBody*(h: BlockHeader): bool =
func generateAddress*(address: EthAddress, nonce: AccountNonce): EthAddress =
result[0..19] = keccakHash(rlp.encodeList(address, nonce)).data.toOpenArray(12, 31)
type ContractSalt* = object
bytes*: array[32, byte]
when defined(evmc_enabled):
import evmc/evmc
type ContractSalt* = evmc_bytes32
else:
type ContractSalt* = object
bytes*: array[32, byte]
const ZERO_CONTRACTSALT* = default(ContractSalt)

View File

@ -1,60 +0,0 @@
# Nimbus
# Copyright (c) 2018-2024 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
./evm/computation as vmc,
./evm/interpreter_dispatch as vmi
export
vmi.execCallOrCreate,
vmi.executeOpcodes
export
vmc.accountExists,
vmc.addLogEntry,
vmc.chainTo,
vmc.commit,
vmc.dispose,
vmc.execSelfDestruct,
vmc.fork,
vmc.getBalance,
vmc.getBlockHash,
vmc.getBlockNumber,
vmc.getChainId,
vmc.getCode,
vmc.getCodeHash,
vmc.getCodeSize,
vmc.getCoinbase,
vmc.getDifficulty,
vmc.getGasLimit,
vmc.getGasPrice,
vmc.getGasRefund,
vmc.getOrigin,
vmc.getStorage,
vmc.getTimestamp,
vmc.isError,
vmc.isSuccess,
vmc.merge,
vmc.newComputation,
vmc.prepareTracer,
vmc.refundSelfDestruct,
vmc.rollback,
vmc.selfDestruct,
vmc.setError,
vmc.shouldBurnGas,
vmc.snapshot,
vmc.traceError,
vmc.traceOpCodeEnded,
vmc.traceOpCodeStarted,
vmc.tracingEnabled,
vmc.writeContract,
vmc.evmcStatus,
vmc.errorOpt
# End

View File

@ -1,55 +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.
import
./evm/interpreter/gas_costs as vmg
export
vmg.Bls12381G1AddGas,
vmg.Bls12381G1MulGas,
vmg.Bls12381G2AddGas,
vmg.Bls12381G2MulGas,
vmg.Bls12381MapG1Gas,
vmg.Bls12381MapG2Gas,
vmg.Bls12381PairingBaseGas,
vmg.Bls12381PairingPerPairGas,
vmg.ColdAccountAccessCost,
vmg.ColdSloadCost,
vmg.GasCostKind,
vmg.GasCosts,
vmg.GasECAdd,
vmg.GasECAddIstanbul,
vmg.GasECMul,
vmg.GasECMulIstanbul,
vmg.GasECPairingBase,
vmg.GasECPairingBaseIstanbul,
vmg.GasECPairingPerPoint,
vmg.GasECPairingPerPointIstanbul,
vmg.GasECRecover,
vmg.GasFeeKind,
vmg.GasIdentity,
vmg.GasIdentityWord,
vmg.GasParams,
vmg.GasQuadDivisorEIP2565,
vmg.GasRIPEMD160,
vmg.GasRIPEMD160Word,
vmg.GasSHA256,
vmg.GasSHA256Word,
vmg.WarmStorageReadCost,
vmg.forkToSchedule,
vmg.gasFees,
vmg.ACCESS_LIST_STORAGE_KEY_COST,
vmg.ACCESS_LIST_ADDRESS_COST
when defined(evmc_enabled):
export
vmg.SstoreCost
# End

View File

@ -1,141 +0,0 @@
# Nimbus
# Copyright (c) 2018-2024 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.
# At the moment, this header file interface is only used for testing.
import
./evm/memory as vmm
export
vmm.EvmMemoryRef,
vmm.extend,
vmm.len,
vmm.new,
vmm.read,
vmm.write
when defined(evmc_enabled):
export
vmm.readPtr
import
./evm/interpreter/utils/utils_numeric as vmn
export
vmn.GasNatural,
vmn.calcMemSize,
vmn.ceil32,
vmn.cleanMemRef,
vmn.log2,
vmn.log256,
vmn.rangeToPadded,
vmn.safeInt,
vmn.setSign,
vmn.toInt,
vmn.wordCount
# Wrapping the wrapper -- lol
import
./evm/code_stream as aCst,
./evm/computation as bChp,
./evm/interpreter_dispatch as cVmc,
./evm/interpreter/gas_meter as eGmt,
./evm/interpreter/op_codes as fVmo,
./evm/message as gVmg,
./evm/stack as hStk
export
aCst.CodeStream,
aCst.`$`,
aCst.`[]`,
aCst.atEnd,
aCst.decompile,
aCst.displayDecompiled,
aCst.hasSStore,
aCst.isValidOpcode,
aCst.items,
aCst.len,
aCst.newCodeStream,
aCst.newCodeStreamFromUnescaped,
aCst.next,
aCst.peek,
aCst.read,
aCst.readVmWord,
aCst.updatePc,
bChp.accountExists,
bChp.addLogEntry,
bChp.chainTo,
bChp.commit,
bChp.dispose,
bChp.fork,
bChp.getBalance,
bChp.getBlockHash,
bChp.getBlockNumber,
bChp.getChainId,
bChp.getCode,
bChp.getCodeHash,
bChp.getCodeSize,
bChp.getCoinbase,
bChp.getDifficulty,
bChp.getGasLimit,
bChp.getGasPrice,
bChp.getGasRefund,
bChp.getOrigin,
bChp.getStorage,
bChp.getTimestamp,
bChp.isError,
bChp.isSuccess,
bChp.merge,
bChp.newComputation,
bChp.prepareTracer,
bChp.refundSelfDestruct,
bChp.rollback,
bChp.selfDestruct,
bChp.setError,
bChp.shouldBurnGas,
bChp.snapshot,
bChp.traceError,
bChp.traceOpCodeEnded,
bChp.traceOpCodeStarted,
bChp.tracingEnabled,
bChp.writeContract,
cVmc.execCallOrCreate,
cVmc.executeOpcodes,
eGmt.consumeGas,
eGmt.init,
eGmt.refundGas,
eGmt.returnGas,
fVmo.Op,
fVmo.PrevRandao,
gVmg.isCreate,
hStk.EvmStackRef,
hStk.`[]`,
hStk.dup,
hStk.len,
hStk.new,
hStk.peek,
hStk.peekInt,
hStk.popAddress,
hStk.popInt,
hStk.popTopic,
hStk.push,
hStk.swap,
hStk.top,
hStk.items,
hStk.pairs
import
./evm/evm_errors
export
evm_errors
# End

View File

@ -1,19 +0,0 @@
# Nimbus
# Copyright (c) 2018-2024 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
./evm/precompiles as vmp
export
vmp.PrecompileAddresses,
vmp.activePrecompiles,
vmp.execPrecompiles
# End

View File

@ -1,49 +0,0 @@
# Nimbus
# Copyright (c) 2021-2024 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
./evm/state_transactions as vmx,
./evm/state as vms
export
vmx.setupTxContext
export
vms.`$`,
vms.blockNumber,
vms.coinbase,
vms.determineFork,
vms.difficultyOrPrevRandao,
vms.baseFeePerGas,
vms.forkDeterminationInfoForVMState,
vms.collectWitnessData,
vms.`collectWitnessData=`,
vms.getAncestorHash,
vms.getAndClearLogEntries,
vms.init,
vms.mutateStateDB,
vms.new,
vms.reinit,
vms.readOnlyStateDB,
vms.status,
vms.`status=`,
vms.tracingEnabled,
vms.captureTxStart,
vms.captureTxEnd,
vms.captureStart,
vms.captureEnd,
vms.captureEnter,
vms.captureExit,
vms.captureOpStart,
vms.captureGasCost,
vms.captureOpEnd,
vms.captureFault,
vms.capturePrepare
# End

View File

@ -1,57 +0,0 @@
# Nimbus
# Copyright (c) 2018-2024 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.
{.used.}
import
./evm/types as vmt
export
vmt.BaseVMState,
vmt.CallKind,
vmt.Computation,
vmt.Error,
vmt.GasMeter,
vmt.Message,
vmt.MsgFlags,
vmt.TracerFlags,
vmt.TracerRef,
vmt.VMFlag,
vmt.BlockContext,
vmt.TxContext
when defined(evmc_enabled):
import
./evm/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
# End

View File

@ -13,7 +13,7 @@ import
stew/byteutils,
chronicles,
results,
../nimbus/[vm_state, vm_types],
../nimbus/[evm/state, evm/types],
../nimbus/core/executor,
./premixcore, ./prestate,
../nimbus/tracer,

View File

@ -19,7 +19,7 @@ import
../nimbus/db/opts,
../nimbus/db/core_db/persistent,
../nimbus/core/executor,
../nimbus/[vm_state, vm_types],
../nimbus/[evm/state, evm/types],
../nimbus/tracer,
./configuration # must be late (compilation annoyance)

View File

@ -12,7 +12,7 @@ import
std/[json, tables, hashes],
eth/trie/trie_defs,
stint, stew/byteutils, chronicles,
../nimbus/[vm_state, vm_types],
../nimbus/[evm/state, evm/types],
../nimbus/utils/utils,
../nimbus/tracer,
../nimbus/db/[core_db, state_db/read_write],

View File

@ -10,7 +10,7 @@
import
chronicles,
../nimbus/[vm_state, vm_types],
../nimbus/[evm/state, evm/types],
../nimbus/core/executor,
../nimbus/common/common,
../nimbus/db/opts,

View File

@ -1,5 +1,5 @@
# Nimbus
# Copyright (c) 2018-2023 Status Research & Development GmbH
# Copyright (c) 2018-2024 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)
@ -8,7 +8,7 @@
import
std/[times, macros, strutils, os, osproc, threadpool],
unittest2,
../nimbus/vm_compile_info,
../nimbus/compile_info,
../nimbus/utils/utils
export strutils, os, unittest2, osproc, threadpool

View File

@ -19,9 +19,9 @@ import
import
../nimbus/db/ledger,
../nimbus/evm/types,
../nimbus/vm_internals,
../nimbus/evm/internals,
../nimbus/transaction/[call_common, call_evm],
../nimbus/[vm_types, vm_state],
../nimbus/evm/state,
../nimbus/core/pow/difficulty
from ../nimbus/db/aristo

View File

@ -17,8 +17,8 @@ import
../nimbus/core/chain,
../nimbus/transaction,
../nimbus/constants,
../nimbus/vm_state,
../nimbus/vm_types,
../nimbus/evm/state,
../nimbus/evm/types,
./replay/undump_blocks,
unittest2

View File

@ -15,7 +15,7 @@ import
stew/byteutils,
./test_helpers, ./test_allowed_to_fail,
../premix/parser, test_config,
../nimbus/[vm_state, vm_types, errors, constants],
../nimbus/[evm/state, evm/types, errors, constants],
../nimbus/db/[ledger, state_db],
../nimbus/utils/[utils, debug],
../nimbus/evm/tracer/legacy_tracer,

View File

@ -1,12 +1,12 @@
# Nimbus
# Copyright (c) 2018-2023 Status Research & Development GmbH
# Copyright (c) 2018-2024 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 unittest2, sequtils,
../nimbus/vm_internals
../nimbus/evm/internals
proc codeStreamMain*() =
suite "parse bytecode":

View File

@ -8,7 +8,7 @@
import
unittest2, macros, strformat,
eth/common/eth_types,
../nimbus/[vm_types, vm_internals]
../nimbus/[evm/types, evm/internals, evm/evm_errors]
# TODO: quicktest
# PS: parametrize can be easily immitated, but still quicktests would be even more useful

View File

@ -10,7 +10,7 @@ import
./test_helpers, ./test_allowed_to_fail,
../nimbus/core/executor, test_config,
../nimbus/transaction,
../nimbus/[vm_state, vm_types],
../nimbus/[evm/state, evm/types],
../nimbus/db/ledger,
../nimbus/common/common,
../nimbus/utils/[utils, debug],

View File

@ -1,5 +1,5 @@
# Nimbus
# Copyright (c) 2019-2023 Status Research & Development GmbH
# Copyright (c) 2019-2024 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)
@ -11,7 +11,7 @@
import
unittest2,
eth/common/eth_types,
../nimbus/vm_internals,
../nimbus/evm/internals,
../nimbus/core/pow/header
func toAddress(n: int): EthAddress =

View File

@ -11,7 +11,7 @@
import
macro_assembler, unittest2,
stew/byteutils, ../nimbus/common/common,
../nimbus/[vm_state, constants],
../nimbus/[evm/state, constants],
../nimbus/db/ledger
proc opEnvMain*() =

View File

@ -12,8 +12,8 @@ import eth/[keys, trie]
import stew/byteutils
import unittest2
import ../nimbus/common
import ../nimbus/vm_state
import ../nimbus/vm_types
import ../nimbus/evm/state
import ../nimbus/evm/types
import ../nimbus/transaction
import ../nimbus/transaction/call_evm
import ../nimbus/db/core_db

View File

@ -10,11 +10,11 @@ import
unittest2, stew/byteutils,
eth/[keys, trie],
../nimbus/common/common,
../nimbus/[vm_computation,
vm_state,
vm_types,
../nimbus/[evm/computation,
evm/state,
evm/types,
constants,
vm_precompiles {.all.},
evm/precompiles {.all.},
transaction,
transaction/call_evm
],

View File

@ -12,7 +12,7 @@ import
json_rpc/[rpcserver, rpcclient],
nimcrypto/[keccak, hash],
eth/[rlp, keys, trie/hexary_proof_verification],
../nimbus/[constants, transaction, config, vm_state, vm_types, version],
../nimbus/[constants, transaction, config, evm/state, evm/types, version],
../nimbus/db/[ledger, storage_types],
../nimbus/sync/protocol,
../nimbus/core/[tx_pool, chain, executor, executor/executor_helpers, pow/difficulty],

View File

@ -19,7 +19,7 @@ import
../nimbus/db/aristo/aristo_merge,
../nimbus/db/kvt/kvt_utils,
../nimbus/db/aristo,
../nimbus/[tracer, vm_types],
../nimbus/[tracer, evm/types],
../nimbus/common/common
proc setErrorLevel {.used.} =

View File

@ -1,5 +1,5 @@
# Nimbus
# Copyright (c) 2019-2023 Status Research & Development GmbH
# Copyright (c) 2019-2024 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)
@ -13,7 +13,7 @@ import
unittest2,
eth/rlp,
./test_helpers,
../nimbus/[errors, transaction, vm_types],
../nimbus/[errors, transaction, evm/types],
../nimbus/utils/utils
const

View File

@ -13,7 +13,7 @@ import
../nimbus/core/chain, # must be early (compilation annoyance)
../nimbus/common/common,
../nimbus/core/[executor, casper, tx_pool, tx_pool/tx_item],
../nimbus/[config, vm_state, vm_types],
../nimbus/[config, evm/state, evm/types],
./test_txpool/[helpers, setup, sign_helper],
chronos,
eth/[keys, p2p],

View File

@ -19,7 +19,7 @@ import
../nimbus/core/casper,
../nimbus/common/common,
../nimbus/utils/utils,
../nimbus/vm_types,
../nimbus/evm/types,
./test_txpool/helpers,
./macro_assembler

View File

@ -14,7 +14,7 @@ import
../nimbus/common/common, # must be early (compilation annoyance)
../nimbus/db/opts,
../nimbus/db/core_db/persistent,
../nimbus/[config, tracer, vm_types]
../nimbus/[config, tracer, evm/types]
proc dumpTest(com: CommonRef, blockNumber: BlockNumber) =
var

View File

@ -10,7 +10,7 @@
import
../../nimbus/common/common,
../../nimbus/[vm_state, vm_types],
../../nimbus/[evm/state, evm/types],
../../nimbus/db/ledger
proc coinbaseStateClearing*(vmState: BaseVMState,

View File

@ -16,7 +16,7 @@ import
results,
stint,
eth/trie/[trie_defs],
../../nimbus/[vm_types, vm_state],
../../nimbus/[evm/types, evm/state],
../../nimbus/db/ledger,
../../nimbus/transaction,
../../nimbus/core/executor,

View File

@ -14,7 +14,7 @@ import
stint, results,
"."/[config, types, helpers],
../common/state_clearing,
../../nimbus/[vm_types, vm_state, transaction],
../../nimbus/[evm/types, evm/state, transaction],
../../nimbus/common/common,
../../nimbus/db/ledger,
../../nimbus/utils/utils,