diff --git a/hive_integration/nodocker/engine/node.nim b/hive_integration/nodocker/engine/node.nim index 90e68fdfc..30b22b29d 100644 --- a/hive_integration/nodocker/engine/node.nim +++ b/hive_integration/nodocker/engine/node.nim @@ -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, diff --git a/nimbus/vm_compile_info.nim b/nimbus/compile_info.nim similarity index 100% rename from nimbus/vm_compile_info.nim rename to nimbus/compile_info.nim diff --git a/nimbus/config.nim b/nimbus/config.nim index a5487f4a1..e878c8992 100644 --- a/nimbus/config.nim +++ b/nimbus/config.nim @@ -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 diff --git a/nimbus/core/chain/chain_desc.nim b/nimbus/core/chain/chain_desc.nim index 9cab1adfa..6f2d3b35b 100644 --- a/nimbus/core/chain/chain_desc.nim +++ b/nimbus/core/chain/chain_desc.nim @@ -13,7 +13,7 @@ import ../../common/common, ../../utils/utils, - ../../vm_types + ../../evm/types export common diff --git a/nimbus/core/chain/persist_blocks.nim b/nimbus/core/chain/persist_blocks.nim index 791b3bef4..a2dba0e37 100644 --- a/nimbus/core/chain/persist_blocks.nim +++ b/nimbus/core/chain/persist_blocks.nim @@ -13,8 +13,8 @@ import results, ../../db/ledger, - ../../vm_state, - ../../vm_types, + ../../evm/state, + ../../evm/types, ../executor, ../validate, ./chain_desc, diff --git a/nimbus/core/executor/calculate_reward.nim b/nimbus/core/executor/calculate_reward.nim index d666d99c5..f70d9a2bf 100644 --- a/nimbus/core/executor/calculate_reward.nim +++ b/nimbus/core/executor/calculate_reward.nim @@ -11,8 +11,8 @@ import ../../db/ledger, ../../common/common, - ../../vm_state, - ../../vm_types + ../../evm/state, + ../../evm/types {.push raises: [].} diff --git a/nimbus/core/executor/executor_helpers.nim b/nimbus/core/executor/executor_helpers.nim index b4f8ae188..fadf8af74 100644 --- a/nimbus/core/executor/executor_helpers.nim +++ b/nimbus/core/executor/executor_helpers.nim @@ -13,8 +13,8 @@ import ../../common/common, ../../db/ledger, - ../../vm_state, - ../../vm_types, + ../../evm/state, + ../../evm/types, eth/[bloom] type diff --git a/nimbus/core/executor/process_block.nim b/nimbus/core/executor/process_block.nim index 14cd25b1b..739adc7bc 100644 --- a/nimbus/core/executor/process_block.nim +++ b/nimbus/core/executor/process_block.nim @@ -14,8 +14,8 @@ import ../../constants, ../../db/ledger, ../../transaction, - ../../vm_state, - ../../vm_types, + ../../evm/state, + ../../evm/types, ../dao, ./calculate_reward, ./executor_helpers, diff --git a/nimbus/core/executor/process_transaction.nim b/nimbus/core/executor/process_transaction.nim index e80a742e0..142decaa3 100644 --- a/nimbus/core/executor/process_transaction.nim +++ b/nimbus/core/executor/process_transaction.nim @@ -18,8 +18,8 @@ import ../../transaction/call_evm, ../../transaction/call_common, ../../transaction, - ../../vm_state, - ../../vm_types, + ../../evm/state, + ../../evm/types, ../../constants, ../validate diff --git a/nimbus/core/tx_pool/tx_chain.nim b/nimbus/core/tx_pool/tx_chain.nim index 490bac56d..de92cd10e 100644 --- a/nimbus/core/tx_pool/tx_chain.nim +++ b/nimbus/core/tx_pool/tx_chain.nim @@ -20,8 +20,8 @@ import ../../constants, ../../db/ledger, ../../utils/utils, - ../../vm_state, - ../../vm_types, + ../../evm/state, + ../../evm/types, ../eip4844, ../pow/difficulty, ../executor, diff --git a/nimbus/core/tx_pool/tx_tasks/tx_classify.nim b/nimbus/core/tx_pool/tx_tasks/tx_classify.nim index 42199cec1..5628075dc 100644 --- a/nimbus/core/tx_pool/tx_tasks/tx_classify.nim +++ b/nimbus/core/tx_pool/tx_tasks/tx_classify.nim @@ -14,8 +14,8 @@ import ../../../common/common, - ../../../vm_state, - ../../../vm_types, + ../../../evm/state, + ../../../evm/types, ../../validate, ../../eip4844, ../tx_chain, diff --git a/nimbus/core/tx_pool/tx_tasks/tx_packer.nim b/nimbus/core/tx_pool/tx_tasks/tx_packer.nim index 615836c55..fb5eec77b 100644 --- a/nimbus/core/tx_pool/tx_tasks/tx_packer.nim +++ b/nimbus/core/tx_pool/tx_tasks/tx_packer.nim @@ -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] diff --git a/nimbus/errors.nim b/nimbus/errors.nim index f712db393..f701af955 100644 --- a/nimbus/errors.nim +++ b/nimbus/errors.nim @@ -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 diff --git a/nimbus/vm_state_transactions.nim b/nimbus/evm/internals.nim similarity index 54% rename from nimbus/vm_state_transactions.nim rename to nimbus/evm/internals.nim index 485c0a4fe..f1bd1614f 100644 --- a/nimbus/vm_state_transactions.nim +++ b/nimbus/evm/internals.nim @@ -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 diff --git a/nimbus/graphql/ethapi.nim b/nimbus/graphql/ethapi.nim index aa1315843..1035219b3 100644 --- a/nimbus/graphql/ethapi.nim +++ b/nimbus/graphql/ethapi.nim @@ -18,7 +18,7 @@ import ../db/[ledger], ../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], diff --git a/nimbus/nimbus.nim b/nimbus/nimbus.nim index f2992e846..50e5df85b 100644 --- a/nimbus/nimbus.nim +++ b/nimbus/nimbus.nim @@ -8,7 +8,7 @@ # those terms. import - ../nimbus/vm_compile_info + ../nimbus/compile_info import std/[os, strutils, net], diff --git a/nimbus/rpc/debug.nim b/nimbus/rpc/debug.nim index ccd9814c9..c7f0d2c76 100644 --- a/nimbus/rpc/debug.nim +++ b/nimbus/rpc/debug.nim @@ -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, diff --git a/nimbus/rpc/experimental.nim b/nimbus/rpc/experimental.nim index cda5e2d56..19e8b2bf6 100644 --- a/nimbus/rpc/experimental.nim +++ b/nimbus/rpc/experimental.nim @@ -11,17 +11,21 @@ import std/[typetraits], - json_rpc/rpcserver, stint, web3/conversions, + json_rpc/rpcserver, + web3/conversions, eth/p2p, - ../[transaction, vm_state, constants, vm_types], - rpc_types, rpc_utils, + stint, + ../core/executor/process_block, + ../[transaction, constants], + ../beacon/web3_eth_conv, + ../stateless/multi_keys, + ../evm/[state, types], ../common/common, ../utils/utils, - ../beacon/web3_eth_conv, - ./filters, - ../core/executor/process_block, ../db/ledger, - ../stateless/multi_keys, + ./rpc_types, + ./rpc_utils, + ./filters, ./p2p type diff --git a/nimbus/rpc/p2p.nim b/nimbus/rpc/p2p.nim index a235022ed..e697203b0 100644 --- a/nimbus/rpc/p2p.nim +++ b/nimbus/rpc/p2p.nim @@ -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/ledger, ./rpc_types, ./rpc_utils, ./oracle, ../transaction/call_evm, diff --git a/nimbus/rpc/params.nim b/nimbus/rpc/params.nim index e4d503c39..f58e3c7d4 100644 --- a/nimbus/rpc/params.nim +++ b/nimbus/rpc/params.nim @@ -13,7 +13,7 @@ import chronicles, ../common/common, ../transaction/call_common, - ../vm_types, + ../evm/types, ../beacon/web3_eth_conv, ../evm/evm_errors, ./rpc_types diff --git a/nimbus/rpc/rpc_utils.nim b/nimbus/rpc/rpc_utils.nim index 672550923..aa50f89a0 100644 --- a/nimbus/rpc/rpc_utils.nim +++ b/nimbus/rpc/rpc_utils.nim @@ -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 diff --git a/nimbus/sync/handlers/eth.nim b/nimbus/sync/handlers/eth.nim index b7f283211..6e3f29c86 100644 --- a/nimbus/sync/handlers/eth.nim +++ b/nimbus/sync/handlers/eth.nim @@ -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: diff --git a/nimbus/tracer.nim b/nimbus/tracer.nim index 2b83019b6..89f31dca3 100644 --- a/nimbus/tracer.nim +++ b/nimbus/tracer.nim @@ -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, diff --git a/nimbus/transaction.nim b/nimbus/transaction.nim index 44b85d12b..7008646eb 100644 --- a/nimbus/transaction.nim +++ b/nimbus/transaction.nim @@ -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 diff --git a/nimbus/transaction/call_common.nim b/nimbus/transaction/call_common.nim index 81ffd76ec..550852836 100644 --- a/nimbus/transaction/call_common.nim +++ b/nimbus/transaction/call_common.nim @@ -12,18 +12,20 @@ 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, state_transactions], + ../evm/[precompiles, internals], + ../db/ledger, ../common/evmforks, ../core/eip4844, ./host_types +import ../evm/computation except fromEvmc, toEvmc + when defined(evmc_enabled): import ../utils/utils import ./host_services -else: - import ../vm_state_transactions +#else: + #import ../evm/state_transactions type # Standard call parameters. diff --git a/nimbus/transaction/call_evm.nim b/nimbus/transaction/call_evm.nim index 56dc3a58c..fbe686778 100644 --- a/nimbus/transaction/call_evm.nim +++ b/nimbus/transaction/call_evm.nim @@ -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, diff --git a/nimbus/transaction/evmc_vm_glue.nim b/nimbus/transaction/evmc_vm_glue.nim index 5cd443285..640ed8a1c 100644 --- a/nimbus/transaction/evmc_vm_glue.nim +++ b/nimbus/transaction/evmc_vm_glue.nim @@ -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) diff --git a/nimbus/transaction/host_call_nested.nim b/nimbus/transaction/host_call_nested.nim index ad3a61df3..084360a1b 100644 --- a/nimbus/transaction/host_call_nested.nim +++ b/nimbus/transaction/host_call_nested.nim @@ -12,10 +12,13 @@ import eth/common/eth_types, stew/ptrops, stint, - ".."/[vm_types, vm_computation], + ../evm/types, + ../evm/interpreter_dispatch, ../utils/utils, "."/[host_types, host_trace] +import ../evm/computation except fromEvmc, toEvmc + proc evmcResultRelease(res: var EvmcResult) {.cdecl, gcsafe.} = dealloc(res.output_data) diff --git a/nimbus/transaction/host_services.nim b/nimbus/transaction/host_services.nim index 8af70d954..494440f5b 100644 --- a/nimbus/transaction/host_services.nim +++ b/nimbus/transaction/host_services.nim @@ -13,10 +13,12 @@ import stint, chronicles, eth/common/eth_types, ../db/ledger, ../common/[evmforks, common], - ".."/[vm_state, vm_computation, vm_internals, vm_gas_costs], + ../evm/[state, internals], ./host_types, ./host_trace, ./host_call_nested, stew/saturation_arith +import ../evm/computation except fromEvmc, toEvmc + proc setupTxContext(host: TransactionHost) = # Conversion issues: # diff --git a/nimbus/transaction/host_types.nim b/nimbus/transaction/host_types.nim index da9bd9493..fcade656b 100644 --- a/nimbus/transaction/host_types.nim +++ b/nimbus/transaction/host_types.nim @@ -1,13 +1,16 @@ # 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 + std/sets, + stint, evmc/evmc, + eth/common/eth_types, + ../evm/types # Object `TransactionHost` represents "EVMC host" to the EVM. "Host services" # manage account state outside EVM such as balance transfers, storage, logs and diff --git a/nimbus/utils/debug.nim b/nimbus/utils/debug.nim index 7c5b6ac10..252ea3514 100644 --- a/nimbus/utils/debug.nim +++ b/nimbus/utils/debug.nim @@ -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 diff --git a/nimbus/vm_computation.nim b/nimbus/vm_computation.nim deleted file mode 100644 index 71d3d65be..000000000 --- a/nimbus/vm_computation.nim +++ /dev/null @@ -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 diff --git a/nimbus/vm_gas_costs.nim b/nimbus/vm_gas_costs.nim deleted file mode 100644 index 67a556f21..000000000 --- a/nimbus/vm_gas_costs.nim +++ /dev/null @@ -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 diff --git a/nimbus/vm_internals.nim b/nimbus/vm_internals.nim deleted file mode 100644 index cf4b54ba2..000000000 --- a/nimbus/vm_internals.nim +++ /dev/null @@ -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 diff --git a/nimbus/vm_precompiles.nim b/nimbus/vm_precompiles.nim deleted file mode 100644 index cc3b7ec92..000000000 --- a/nimbus/vm_precompiles.nim +++ /dev/null @@ -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 diff --git a/nimbus/vm_state.nim b/nimbus/vm_state.nim deleted file mode 100644 index ff51d3c0e..000000000 --- a/nimbus/vm_state.nim +++ /dev/null @@ -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 diff --git a/nimbus/vm_types.nim b/nimbus/vm_types.nim deleted file mode 100644 index 48551ef10..000000000 --- a/nimbus/vm_types.nim +++ /dev/null @@ -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 diff --git a/premix/debug.nim b/premix/debug.nim index 847015481..3aed14b41 100644 --- a/premix/debug.nim +++ b/premix/debug.nim @@ -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, diff --git a/premix/dumper.nim b/premix/dumper.nim index b46c6333d..8c21bf7f6 100644 --- a/premix/dumper.nim +++ b/premix/dumper.nim @@ -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) diff --git a/premix/no-hunter.nim b/premix/no-hunter.nim index 67373fb41..bc3477768 100644 --- a/premix/no-hunter.nim +++ b/premix/no-hunter.nim @@ -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], diff --git a/premix/regress.nim b/premix/regress.nim index 471c893f2..b36908a60 100644 --- a/premix/regress.nim +++ b/premix/regress.nim @@ -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, diff --git a/tests/all_tests_macro.nim b/tests/all_tests_macro.nim index 1b657a05b..f0346eb28 100644 --- a/tests/all_tests_macro.nim +++ b/tests/all_tests_macro.nim @@ -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 diff --git a/tests/macro_assembler.nim b/tests/macro_assembler.nim index 62b9fed6d..cb90cdad4 100644 --- a/tests/macro_assembler.nim +++ b/tests/macro_assembler.nim @@ -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 diff --git a/tests/test_accounts_cache.nim b/tests/test_accounts_cache.nim index 92154c4ad..d484021af 100644 --- a/tests/test_accounts_cache.nim +++ b/tests/test_accounts_cache.nim @@ -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 diff --git a/tests/test_blockchain_json.nim b/tests/test_blockchain_json.nim index 343f71809..aa5b3aa78 100644 --- a/tests/test_blockchain_json.nim +++ b/tests/test_blockchain_json.nim @@ -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, ../nimbus/utils/[utils, debug], ../nimbus/evm/tracer/legacy_tracer, diff --git a/tests/test_code_stream.nim b/tests/test_code_stream.nim index e14d7f43d..4fafeac20 100644 --- a/tests/test_code_stream.nim +++ b/tests/test_code_stream.nim @@ -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": diff --git a/tests/test_gas_meter.nim b/tests/test_gas_meter.nim index 52e85ebb0..3be283ce4 100644 --- a/tests/test_gas_meter.nim +++ b/tests/test_gas_meter.nim @@ -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 diff --git a/tests/test_generalstate_json.nim b/tests/test_generalstate_json.nim index b98d7670e..9ba23f82b 100644 --- a/tests/test_generalstate_json.nim +++ b/tests/test_generalstate_json.nim @@ -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], diff --git a/tests/test_misc.nim b/tests/test_misc.nim index 942f9c901..93931c09a 100644 --- a/tests/test_misc.nim +++ b/tests/test_misc.nim @@ -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 = diff --git a/tests/test_op_env.nim b/tests/test_op_env.nim index 8f33736e4..8bea4f30b 100644 --- a/tests/test_op_env.nim +++ b/tests/test_op_env.nim @@ -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*() = diff --git a/tests/test_overflow.nim b/tests/test_overflow.nim index 1709a8737..f25838226 100644 --- a/tests/test_overflow.nim +++ b/tests/test_overflow.nim @@ -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 diff --git a/tests/test_precompiles.nim b/tests/test_precompiles.nim index 882916dc5..fdce2fbe6 100644 --- a/tests/test_precompiles.nim +++ b/tests/test_precompiles.nim @@ -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 ], diff --git a/tests/test_rpc.nim b/tests/test_rpc.nim index 37c28e033..162847e45 100644 --- a/tests/test_rpc.nim +++ b/tests/test_rpc.nim @@ -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], diff --git a/tests/test_tracer_json.nim b/tests/test_tracer_json.nim index 22a2a75ac..2246f0920 100644 --- a/tests/test_tracer_json.nim +++ b/tests/test_tracer_json.nim @@ -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.} = diff --git a/tests/test_transaction_json.nim b/tests/test_transaction_json.nim index 99fa93a26..a68dc203b 100644 --- a/tests/test_transaction_json.nim +++ b/tests/test_transaction_json.nim @@ -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 diff --git a/tests/test_txpool.nim b/tests/test_txpool.nim index f06a3975f..4cf0c1d54 100644 --- a/tests/test_txpool.nim +++ b/tests/test_txpool.nim @@ -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], diff --git a/tests/test_txpool2.nim b/tests/test_txpool2.nim index a3c88a7ce..a225753a9 100644 --- a/tests/test_txpool2.nim +++ b/tests/test_txpool2.nim @@ -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 diff --git a/tests/tracerTestGen.nim b/tests/tracerTestGen.nim index 799ef6eb2..e75ff62d7 100644 --- a/tests/tracerTestGen.nim +++ b/tests/tracerTestGen.nim @@ -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 diff --git a/tools/common/state_clearing.nim b/tools/common/state_clearing.nim index 3e7bc58c1..d7ec1f811 100644 --- a/tools/common/state_clearing.nim +++ b/tools/common/state_clearing.nim @@ -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, diff --git a/tools/evmstate/evmstate.nim b/tools/evmstate/evmstate.nim index 56eb4a24d..60b4c41dc 100644 --- a/tools/evmstate/evmstate.nim +++ b/tools/evmstate/evmstate.nim @@ -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, diff --git a/tools/t8n/transition.nim b/tools/t8n/transition.nim index 52ff96e1e..239727675 100644 --- a/tools/t8n/transition.nim +++ b/tools/t8n/transition.nim @@ -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,