From 827b8c9c815d3366a102315cdee6d9a269e6d727 Mon Sep 17 00:00:00 2001 From: Jordan Hrycaj Date: Thu, 1 Apr 2021 12:53:22 +0100 Subject: [PATCH] reset explicit import paths for local modules why: it was convenient to have relocatable source modules when writing the vm interface wrappers. this patch moves it back to the standard. also: there are no deep links into the vm folder anymore which leaves some room for manoeuvring inside --- nim.cfg | 1 - nimbus/p2p/chain.nim | 2 +- nimbus/p2p/executor.nim | 2 +- nimbus/vm/code_stream.nim | 2 +- nimbus/vm/computation.nim | 12 ++++++------ nimbus/vm/evmc_api.nim | 2 +- nimbus/vm/interpreter.nim | 14 +++++++------- nimbus/vm/interpreter/gas_costs.nim | 4 ++-- nimbus/vm/interpreter/gas_meter.nim | 2 +- nimbus/vm/interpreter/opcode_values.nim | 2 +- nimbus/vm/interpreter/opcodes_impl.nim | 12 ++++++------ .../vm/interpreter/utils/macros_procs_opcodes.nim | 8 ++++---- nimbus/vm/interpreter/utils/utils_numeric.nim | 2 +- nimbus/vm/interpreter_dispatch.nim | 4 ++-- nimbus/vm/memory.nim | 4 ++-- nimbus/vm/message.nim | 2 +- nimbus/vm/precompiles.nim | 8 ++++---- nimbus/vm/stack.nim | 2 +- nimbus/vm/state.nim | 8 ++++---- nimbus/vm/state_transactions.nim | 6 +++--- nimbus/vm/transaction_tracer.nim | 4 ++-- nimbus/vm/types.nim | 8 ++++---- 22 files changed, 55 insertions(+), 56 deletions(-) delete mode 100644 nim.cfg diff --git a/nim.cfg b/nim.cfg deleted file mode 100644 index f96c5702c..000000000 --- a/nim.cfg +++ /dev/null @@ -1 +0,0 @@ -path = nimbus diff --git a/nimbus/p2p/chain.nim b/nimbus/p2p/chain.nim index 0591b5c10..d48c15671 100644 --- a/nimbus/p2p/chain.nim +++ b/nimbus/p2p/chain.nim @@ -1,5 +1,5 @@ import ../db/db_chain, eth/common, chronicles, ../vm_state, ../vm_types, - ../vm_computation, ../vm_message, ./vm_types2, stint, nimcrypto, + ../vm_computation, ../vm_message, ../vm_types2, stint, nimcrypto, ../utils, eth/trie/db, ./executor, ../config, ../genesis, ../utils, stew/endians2 diff --git a/nimbus/p2p/executor.nim b/nimbus/p2p/executor.nim index dee6e1762..bbab4a0fc 100644 --- a/nimbus/p2p/executor.nim +++ b/nimbus/p2p/executor.nim @@ -4,7 +4,7 @@ import options, sets, ../utils, ../constants, ../transaction, ../vm_state, ../vm_types, ../vm_state_transactions, ../vm_computation, ../vm_message, ../vm_precompiles, - ./vm_types2, + ../vm_types2, ./dao, ../config proc processTransaction*(tx: Transaction, sender: EthAddress, vmState: BaseVMState, fork: Fork): GasInt = diff --git a/nimbus/vm/code_stream.nim b/nimbus/vm/code_stream.nim index f63d09e17..9f2ce84e6 100644 --- a/nimbus/vm/code_stream.nim +++ b/nimbus/vm/code_stream.nim @@ -8,7 +8,7 @@ import chronicles, strformat, strutils, sequtils, parseutils, sets, macros, eth/common, - vm/interpreter/opcode_values + ./interpreter/opcode_values logScope: topics = "vm code_stream" diff --git a/nimbus/vm/computation.nim b/nimbus/vm/computation.nim index e5ba8fb52..44de3d4c2 100644 --- a/nimbus/vm/computation.nim +++ b/nimbus/vm/computation.nim @@ -8,12 +8,12 @@ import chronicles, strformat, macros, options, times, sets, eth/[common, keys], - constants, errors, - vm/interpreter/[opcode_values, gas_meter, gas_costs, vm_forks], - vm/[code_stream, memory, message, stack, types, state], - db/[accounts_cache, db_chain], - utils/header, precompiles, - transaction_tracer, utils + ../constants, ../errors, + ./interpreter/[opcode_values, gas_meter, gas_costs, vm_forks], + ./code_stream, ./memory, ./message, ./stack, ./types, ./state, + ../db/[accounts_cache, db_chain], + ../utils/header, ./precompiles, + ./transaction_tracer, ../utils when defined(chronicles_log_level): import stew/byteutils diff --git a/nimbus/vm/evmc_api.nim b/nimbus/vm/evmc_api.nim index 1383f6234..61e2ab687 100644 --- a/nimbus/vm/evmc_api.nim +++ b/nimbus/vm/evmc_api.nim @@ -5,7 +5,7 @@ # * 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 evmc/evmc, vm/evmc_helpers, eth/common, constants +import evmc/evmc, ./evmc_helpers, eth/common, ../constants type # we are not using EVMC original signature here diff --git a/nimbus/vm/interpreter.nim b/nimbus/vm/interpreter.nim index 3d85fe597..f12dfb1d7 100644 --- a/nimbus/vm/interpreter.nim +++ b/nimbus/vm/interpreter.nim @@ -10,21 +10,21 @@ # see vm_opcode_value import - ./vm/interpreter/opcode_values as vmo + ./interpreter/opcode_values as vmo export vmo.Op # see vm_forks import - vm/interpreter/vm_forks as vmf + ./interpreter/vm_forks as vmf export vmf.Fork # see vm_message import - ./vm/message as vmm + ./message as vmm export vmm.isCreate @@ -32,7 +32,7 @@ export # see vm_computation import - ./vm/computation as vmc + ./computation as vmc export vmc.accountExists, vmc.addLogEntry, @@ -79,7 +79,7 @@ export import - vm/interpreter/gas_meter as gmt + ./interpreter/gas_meter as gmt export gmt.consumeGas, gmt.init, @@ -88,7 +88,7 @@ export import - vm/code_stream as cst + ./code_stream as cst export cst.CodeStream, cst.`$`, @@ -110,7 +110,7 @@ export import - vm/stack as stk + ./stack as stk export stk.Stack, stk.`$`, diff --git a/nimbus/vm/interpreter/gas_costs.nim b/nimbus/vm/interpreter/gas_costs.nim index f3ef8941d..1d37ee466 100644 --- a/nimbus/vm/interpreter/gas_costs.nim +++ b/nimbus/vm/interpreter/gas_costs.nim @@ -7,8 +7,8 @@ import math, eth/common/eth_types, - vm/interpreter/utils/[macros_gen_opcodes, utils_numeric], - vm/interpreter/[opcode_values, vm_forks], errors + ./utils/[macros_gen_opcodes, utils_numeric], + ./opcode_values, ./vm_forks, ../../errors when defined(evmc_enabled): import evmc/evmc diff --git a/nimbus/vm/interpreter/gas_meter.nim b/nimbus/vm/interpreter/gas_meter.nim index 8c57ff7f2..9a0fb4077 100644 --- a/nimbus/vm/interpreter/gas_meter.nim +++ b/nimbus/vm/interpreter/gas_meter.nim @@ -7,7 +7,7 @@ import chronicles, strformat, eth/common, # GasInt - errors, vm/types + ../../errors, ../types logScope: topics = "vm gas" diff --git a/nimbus/vm/interpreter/opcode_values.nim b/nimbus/vm/interpreter/opcode_values.nim index 8b771d3c2..5b6aa0e22 100644 --- a/nimbus/vm/interpreter/opcode_values.nim +++ b/nimbus/vm/interpreter/opcode_values.nim @@ -5,7 +5,7 @@ # * 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 vm/interpreter/utils/macros_gen_opcodes +import ./utils/macros_gen_opcodes fill_enum_holes: type diff --git a/nimbus/vm/interpreter/opcodes_impl.nim b/nimbus/vm/interpreter/opcodes_impl.nim index d3db2d69e..5efe0e246 100644 --- a/nimbus/vm/interpreter/opcodes_impl.nim +++ b/nimbus/vm/interpreter/opcodes_impl.nim @@ -8,14 +8,14 @@ import strformat, times, sets, sequtils, options, chronicles, stint, nimcrypto, stew/ranges/ptr_arith, eth/common, - vm/interpreter/utils/[macros_procs_opcodes, utils_numeric], - vm/interpreter/[gas_meter, gas_costs, opcode_values, vm_forks], - vm/[memory, stack, code_stream, computation, state, types], - errors, constants, - db/[db_chain, accounts_cache] + ./utils/[macros_procs_opcodes, utils_numeric], + ./gas_meter, ./gas_costs, ./opcode_values, ./vm_forks, + ../memory, ../stack, ../code_stream, ../computation, ../state, ../types, + ../../errors, ../../constants, + ../../db/[db_chain, accounts_cache] when defined(evmc_enabled): - import vm/evmc_api, vm/evmc_helpers, evmc/evmc + import ../evmc_api, ../evmc_helpers, evmc/evmc logScope: topics = "opcode impl" diff --git a/nimbus/vm/interpreter/utils/macros_procs_opcodes.nim b/nimbus/vm/interpreter/utils/macros_procs_opcodes.nim index f23cccd83..f18a7b851 100644 --- a/nimbus/vm/interpreter/utils/macros_procs_opcodes.nim +++ b/nimbus/vm/interpreter/utils/macros_procs_opcodes.nim @@ -10,12 +10,12 @@ import macros, strformat, stint, eth/common, - vm/[computation, stack, code_stream, memory], - vm/types, errors, vm/interpreter/[gas_meter, opcode_values], - vm/interpreter/utils/utils_numeric + ../../computation, ../../stack, ../../code_stream, ../../memory, + ../../types, ../../../errors, ../gas_meter, ../opcode_values, + ./utils_numeric when defined(evmc_enabled): - import vm/evmc_api, evmc/evmc + import ../../evmc_api, evmc/evmc proc pop(tree: var NimNode): NimNode = ## Returns the last value of a NimNode and remove it diff --git a/nimbus/vm/interpreter/utils/utils_numeric.nim b/nimbus/vm/interpreter/utils/utils_numeric.nim index 1da53d68d..eb074ab18 100644 --- a/nimbus/vm/interpreter/utils/utils_numeric.nim +++ b/nimbus/vm/interpreter/utils/utils_numeric.nim @@ -9,7 +9,7 @@ import macros, stew/endians2, stew/ranges/ptr_arith, eth/common/eth_types, - constants + ../../../constants type # cannot use range for unknown reason diff --git a/nimbus/vm/interpreter_dispatch.nim b/nimbus/vm/interpreter_dispatch.nim index cad86df65..af7e3f59b 100644 --- a/nimbus/vm/interpreter_dispatch.nim +++ b/nimbus/vm/interpreter_dispatch.nim @@ -8,8 +8,8 @@ import tables, macros, chronicles, - 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, + ./interpreter/[opcode_values, opcodes_impl, vm_forks, gas_costs, gas_meter, utils/macros_gen_opcodes], + ./code_stream, ./types, ../errors, ./precompiles, ./stack, terminal # Those are only needed for logging logScope: diff --git a/nimbus/vm/memory.nim b/nimbus/vm/memory.nim index 1d1e55a93..fab766fbe 100644 --- a/nimbus/vm/memory.nim +++ b/nimbus/vm/memory.nim @@ -8,8 +8,8 @@ import sequtils, chronicles, eth/common/eth_types, - errors, validation, - vm/interpreter/utils/utils_numeric + ../errors, ../validation, + ./interpreter/utils/utils_numeric logScope: topics = "vm memory" diff --git a/nimbus/vm/message.nim b/nimbus/vm/message.nim index b2611914a..3720715a3 100644 --- a/nimbus/vm/message.nim +++ b/nimbus/vm/message.nim @@ -5,7 +5,7 @@ # * 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 vm/types +import ./types proc isCreate*(message: Message): bool = message.kind in {evmcCreate, evmcCreate2} diff --git a/nimbus/vm/precompiles.nim b/nimbus/vm/precompiles.nim index 5ca1a0046..9887bef8d 100644 --- a/nimbus/vm/precompiles.nim +++ b/nimbus/vm/precompiles.nim @@ -1,8 +1,8 @@ import - vm/types, - vm/interpreter/[gas_meter, gas_costs, utils/utils_numeric, vm_forks], - errors, stint, eth/[keys, common], chronicles, tables, macros, - math, nimcrypto, bncurve/[fields, groups], vm/blake2b_f, vm/blscurve + ./types, + ./interpreter/[gas_meter, gas_costs, utils/utils_numeric, vm_forks], + ../errors, stint, eth/[keys, common], chronicles, tables, macros, + math, nimcrypto, bncurve/[fields, groups], ./blake2b_f, ./blscurve type PrecompileAddresses* = enum diff --git a/nimbus/vm/stack.nim b/nimbus/vm/stack.nim index 7ae85b65f..5026f01cc 100644 --- a/nimbus/vm/stack.nim +++ b/nimbus/vm/stack.nim @@ -7,7 +7,7 @@ import chronicles, strformat, strutils, sequtils, macros, eth/common, nimcrypto, - errors, validation + ../errors, ../validation logScope: topics = "vm stack" diff --git a/nimbus/vm/state.nim b/nimbus/vm/state.nim index bdcf04eec..4520cb889 100644 --- a/nimbus/vm/state.nim +++ b/nimbus/vm/state.nim @@ -11,10 +11,10 @@ import macros, strformat, tables, sets, options, eth/[common, keys, rlp], nimcrypto/keccak, - vm/interpreter/[vm_forks, gas_costs], errors, - constants, db/[db_chain, accounts_cache], - utils, json, vm/[transaction_tracer, types], - config, ../stateless/[witness_from_tree, witness_types] + ./interpreter/[vm_forks, gas_costs], ../errors, + ../constants, ../db/[db_chain, accounts_cache], + ../utils, json, ./transaction_tracer, ./types, + ../config, ../../stateless/[witness_from_tree, witness_types] proc newAccessLogs*: AccessLogs = AccessLogs(reads: initTable[string, string](), writes: initTable[string, string]()) diff --git a/nimbus/vm/state_transactions.nim b/nimbus/vm/state_transactions.nim index 8627e3120..238cd3993 100644 --- a/nimbus/vm/state_transactions.nim +++ b/nimbus/vm/state_transactions.nim @@ -7,9 +7,9 @@ import options, sets, - eth/common, chronicles, db/accounts_cache, - transaction, - vm/[computation, interpreter, state, types] + eth/common, chronicles, ../db/accounts_cache, + ../transaction, + ./computation, ./interpreter, ./state, ./types proc validateTransaction*(vmState: BaseVMState, tx: Transaction, sender: EthAddress, fork: Fork): bool = let balance = vmState.readOnlyStateDB.getBalance(sender) diff --git a/nimbus/vm/transaction_tracer.nim b/nimbus/vm/transaction_tracer.nim index 6b1ad2b9d..57826f0c9 100644 --- a/nimbus/vm/transaction_tracer.nim +++ b/nimbus/vm/transaction_tracer.nim @@ -1,9 +1,9 @@ import json, strutils, sets, hashes, chronicles, nimcrypto, eth/common, stint, - vm/[types, memory, stack], db/accounts_cache, + ./types, ./memory, ./stack, ../db/accounts_cache, eth/trie/hexary, - vm/interpreter/opcode_values + ./interpreter/opcode_values logScope: topics = "vm opcode" diff --git a/nimbus/vm/types.nim b/nimbus/vm/types.nim index 4c4610a3a..e5776c812 100644 --- a/nimbus/vm/types.nim +++ b/nimbus/vm/types.nim @@ -11,14 +11,14 @@ import tables, eth/common, options, json, sets, - vm/[memory, stack, code_stream], - vm/interpreter/[gas_costs, opcode_values, vm_forks], + ./memory, ./stack, ./code_stream, + ./interpreter/[gas_costs, opcode_values, vm_forks], # TODO - will be hidden at a lower layer - db/[db_chain, accounts_cache] + ../db/[db_chain, accounts_cache] when defined(evmc_enabled): import - ./vm/evmc_api + ./evmc_api type VMFlag* = enum