From 3a3e4d57075d88199146d338854aa98760a86ee5 Mon Sep 17 00:00:00 2001 From: Jordan Hrycaj Date: Wed, 31 Mar 2021 10:46:50 +0100 Subject: [PATCH] provide vm_forks as import/export wrapper details: moved original vm/interpreter/vm_forks.nim => vm/interpreter/nvm_forks.nim --- nimbus/config.nim | 2 +- nimbus/p2p/chain.nim | 2 +- nimbus/p2p/executor.nim | 2 +- nimbus/rpc/p2p.nim | 2 +- nimbus/rpc/rpc_utils.nim | 2 +- nimbus/tracer.nim | 2 +- nimbus/transaction.nim | 2 +- nimbus/vm/computation.nim | 2 +- nimbus/vm/interpreter.nim | 4 ++-- nimbus/vm/interpreter/gas_costs.nim | 2 +- .../{vm_forks.nim => nvm_forks.nim} | 0 nimbus/vm/interpreter/opcodes_impl.nim | 2 +- nimbus/vm/interpreter_dispatch.nim | 2 +- nimbus/vm/nvm_state.nim | 2 +- nimbus/vm/nvm_types.nim | 2 +- nimbus/vm/precompiles.nim | 2 +- nimbus/vm_forks.nim | 19 +++++++++++++++++++ tests/macro_assembler.nim | 3 +-- tests/test_blockchain_json.nim | 3 +-- tests/test_config.nim | 2 +- tests/test_difficulty.nim | 2 +- tests/test_helpers.nim | 2 +- tests/test_precompiles.nim | 4 ++-- 23 files changed, 42 insertions(+), 25 deletions(-) rename nimbus/vm/interpreter/{vm_forks.nim => nvm_forks.nim} (100%) create mode 100644 nimbus/vm_forks.nim diff --git a/nimbus/config.nim b/nimbus/config.nim index 052d313bf..c993461ab 100644 --- a/nimbus/config.nim +++ b/nimbus/config.nim @@ -12,7 +12,7 @@ import chronos, eth/[keys, common, p2p, net/nat], chronicles, nimcrypto/hash, eth/p2p/bootnodes, eth/p2p/rlpx_protocols/whisper_protocol, ./db/select_backend, eth/keys, - ./vm/interpreter/vm_forks + ./vm_forks const NimbusName* = "Nimbus" diff --git a/nimbus/p2p/chain.nim b/nimbus/p2p/chain.nim index 4bf9f36ba..aa892e4f8 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, message], ../vm/interpreter/vm_forks, stint, nimcrypto, + ../vm/[computation, message], ./vm_forks, 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 d34cfc55f..c0a39aa0b 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, message, precompiles], - ../vm/interpreter/vm_forks, + ./vm_forks, ./dao, ../config proc processTransaction*(tx: Transaction, sender: EthAddress, vmState: BaseVMState, fork: Fork): GasInt = diff --git a/nimbus/rpc/p2p.nim b/nimbus/rpc/p2p.nim index 27118014a..934398d94 100644 --- a/nimbus/rpc/p2p.nim +++ b/nimbus/rpc/p2p.nim @@ -15,7 +15,7 @@ import ../transaction, ../config, ../vm_state, ../constants, ../vm_types, ../utils, ../db/[db_chain, state_db], rpc_types, rpc_utils, ../vm/[message, computation], - ../vm/interpreter/vm_forks + ../vm_forks #[ Note: diff --git a/nimbus/rpc/rpc_utils.nim b/nimbus/rpc/rpc_utils.nim index 2ea6cd26d..6134c60f8 100644 --- a/nimbus/rpc/rpc_utils.nim +++ b/nimbus/rpc/rpc_utils.nim @@ -10,7 +10,7 @@ import hexstrings, eth/[common, rlp, keys, trie/db], stew/byteutils, nimcrypto, ../db/[db_chain, accounts_cache], strutils, algorithm, options, times, json, ../constants, stint, hexstrings, rpc_types, ../config, - ../vm_state_transactions, ../vm_state, ../vm_types, ../vm/interpreter/vm_forks, + ../vm_state_transactions, ../vm_state, ../vm_types, ../vm_forks, ../vm/computation, ../p2p/executor, ../utils, ../transaction type diff --git a/nimbus/tracer.nim b/nimbus/tracer.nim index bdcedd6e9..bf6096699 100644 --- a/nimbus/tracer.nim +++ b/nimbus/tracer.nim @@ -3,7 +3,7 @@ import constants, vm_state, vm_types, transaction, p2p/executor, eth/trie/db, nimcrypto, strutils, chronicles, rpc/hexstrings, launcher, - vm/interpreter/vm_forks, ./config + ./vm_forks, ./config when defined(geth): import db/geth_db diff --git a/nimbus/transaction.nim b/nimbus/transaction.nim index e6e417ba4..bde410024 100644 --- a/nimbus/transaction.nim +++ b/nimbus/transaction.nim @@ -7,7 +7,7 @@ import constants, errors, eth/[common, keys], utils, - ./vm/interpreter/[vm_forks, gas_costs], constants + ./vm_forks, ./vm/interpreter/gas_costs, constants import eth/common/transaction as common_transaction export common_transaction diff --git a/nimbus/vm/computation.nim b/nimbus/vm/computation.nim index 2f91b10da..301ba7a37 100644 --- a/nimbus/vm/computation.nim +++ b/nimbus/vm/computation.nim @@ -9,7 +9,7 @@ import chronicles, strformat, macros, options, times, sets, eth/[common, keys], constants, errors, - vm/interpreter/[opcode_values, gas_meter, gas_costs, vm_forks], + vm/interpreter/[opcode_values, gas_meter, gas_costs, nvm_forks], vm/[code_stream, memory, message, stack, nvm_types, nvm_state], db/[accounts_cache, db_chain], utils/header, precompiles, diff --git a/nimbus/vm/interpreter.nim b/nimbus/vm/interpreter.nim index 6461449f9..cbc4af9a8 100644 --- a/nimbus/vm/interpreter.nim +++ b/nimbus/vm/interpreter.nim @@ -6,14 +6,14 @@ # at your option. This file may not be copied, modified, or distributed except according to those terms. import - vm/interpreter/[opcode_values, gas_meter, vm_forks] + vm/interpreter/[opcode_values, gas_meter, nvm_forks] import # Used in vm_types. Beware of recursive dependencies vm/[code_stream, computation, stack, message] export opcode_values, gas_meter, - vm_forks + nvm_forks export code_stream, computation, stack, message diff --git a/nimbus/vm/interpreter/gas_costs.nim b/nimbus/vm/interpreter/gas_costs.nim index f3ef8941d..d8a5a4381 100644 --- a/nimbus/vm/interpreter/gas_costs.nim +++ b/nimbus/vm/interpreter/gas_costs.nim @@ -8,7 +8,7 @@ import math, eth/common/eth_types, vm/interpreter/utils/[macros_gen_opcodes, utils_numeric], - vm/interpreter/[opcode_values, vm_forks], errors + vm/interpreter/[opcode_values, nvm_forks], errors when defined(evmc_enabled): import evmc/evmc diff --git a/nimbus/vm/interpreter/vm_forks.nim b/nimbus/vm/interpreter/nvm_forks.nim similarity index 100% rename from nimbus/vm/interpreter/vm_forks.nim rename to nimbus/vm/interpreter/nvm_forks.nim diff --git a/nimbus/vm/interpreter/opcodes_impl.nim b/nimbus/vm/interpreter/opcodes_impl.nim index 456fe47af..fc16aa23a 100644 --- a/nimbus/vm/interpreter/opcodes_impl.nim +++ b/nimbus/vm/interpreter/opcodes_impl.nim @@ -9,7 +9,7 @@ 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/interpreter/[gas_meter, gas_costs, opcode_values, nvm_forks], vm/[memory, stack, code_stream, computation, nvm_state, nvm_types], errors, constants, db/[db_chain, accounts_cache] diff --git a/nimbus/vm/interpreter_dispatch.nim b/nimbus/vm/interpreter_dispatch.nim index d0aa687ad..758501ad0 100644 --- a/nimbus/vm/interpreter_dispatch.nim +++ b/nimbus/vm/interpreter_dispatch.nim @@ -8,7 +8,7 @@ import tables, macros, chronicles, - vm/interpreter/[opcode_values, opcodes_impl, vm_forks, gas_costs, gas_meter, utils/macros_gen_opcodes], + vm/interpreter/[opcode_values, opcodes_impl, nvm_forks, gas_costs, gas_meter, utils/macros_gen_opcodes], vm/code_stream, vm/nvm_types, errors, precompiles, vm/stack, terminal # Those are only needed for logging diff --git a/nimbus/vm/nvm_state.nim b/nimbus/vm/nvm_state.nim index 3fdcf9808..963792ff3 100644 --- a/nimbus/vm/nvm_state.nim +++ b/nimbus/vm/nvm_state.nim @@ -11,7 +11,7 @@ import macros, strformat, tables, sets, options, eth/[common, keys, rlp], nimcrypto/keccak, - vm/interpreter/[vm_forks, gas_costs], errors, + vm/interpreter/[nvm_forks, gas_costs], errors, constants, db/[db_chain, accounts_cache], utils, json, vm/[transaction_tracer, nvm_types], config, ../stateless/[witness_from_tree, witness_types] diff --git a/nimbus/vm/nvm_types.nim b/nimbus/vm/nvm_types.nim index 4c4610a3a..f000fde8b 100644 --- a/nimbus/vm/nvm_types.nim +++ b/nimbus/vm/nvm_types.nim @@ -12,7 +12,7 @@ import tables, eth/common, options, json, sets, vm/[memory, stack, code_stream], - vm/interpreter/[gas_costs, opcode_values, vm_forks], + vm/interpreter/[gas_costs, opcode_values, nvm_forks], # TODO - will be hidden at a lower layer db/[db_chain, accounts_cache] diff --git a/nimbus/vm/precompiles.nim b/nimbus/vm/precompiles.nim index 1911823d9..168e0a501 100644 --- a/nimbus/vm/precompiles.nim +++ b/nimbus/vm/precompiles.nim @@ -1,6 +1,6 @@ import vm/nvm_types, - vm/interpreter/[gas_meter, gas_costs, utils/utils_numeric, vm_forks], + vm/interpreter/[gas_meter, gas_costs, utils/utils_numeric, nvm_forks], errors, stint, eth/[keys, common], chronicles, tables, macros, math, nimcrypto, bncurve/[fields, groups], vm/blake2b_f, vm/blscurve diff --git a/nimbus/vm_forks.nim b/nimbus/vm_forks.nim new file mode 100644 index 000000000..e4dec851b --- /dev/null +++ b/nimbus/vm_forks.nim @@ -0,0 +1,19 @@ +# 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. + +# This should really go into vm_types once the circular computation.nim +# include/import dependency is solved +import + ./vm/interpreter/nvm_forks as vmf + +export + vmf.Fork + +# End diff --git a/tests/macro_assembler.nim b/tests/macro_assembler.nim index 38dc0fe3d..854118c87 100644 --- a/tests/macro_assembler.nim +++ b/tests/macro_assembler.nim @@ -8,8 +8,7 @@ import options, json, os, eth/trie/[db, hexary], ../nimbus/[vm_state, vm_types, transaction, utils], ../nimbus/db/[db_chain, accounts_cache], - ../nimbus/vm_state_transactions, - ../nimbus/vm/interpreter/vm_forks, + ../nimbus/[vm_state_transactions, vm_forks], ../nimbus/vm/[message, computation, memory] export opcode_values, byteutils diff --git a/tests/test_blockchain_json.nim b/tests/test_blockchain_json.nim index 7558bfb74..120d372b8 100644 --- a/tests/test_blockchain_json.nim +++ b/tests/test_blockchain_json.nim @@ -12,8 +12,7 @@ import ethash, stew/endians2, nimcrypto, ./test_helpers, ./test_allowed_to_fail, ../premix/parser, test_config, - ../nimbus/vm/interpreter/vm_forks, - ../nimbus/[vm_state, utils, vm_types, errors, transaction, constants], + ../nimbus/[vm_state, utils, vm_types, errors, transaction, constants, vm_forks], ../nimbus/db/[db_chain, accounts_cache], ../nimbus/utils/header, ../nimbus/p2p/[executor, dao], diff --git a/tests/test_config.nim b/tests/test_config.nim index 310ad97dc..da9ac3ff3 100644 --- a/tests/test_config.nim +++ b/tests/test_config.nim @@ -1,6 +1,6 @@ import parseopt, strutils, - ../nimbus/vm/interpreter/vm_forks + ../nimbus/vm_forks type ConfigStatus* = enum diff --git a/tests/test_difficulty.nim b/tests/test_difficulty.nim index d7b53c6e9..089d03a4c 100644 --- a/tests/test_difficulty.nim +++ b/tests/test_difficulty.nim @@ -1,7 +1,7 @@ import unittest2, strutils, tables, os, json, ../nimbus/utils/difficulty, stint, times, eth/common, test_helpers, stew/byteutils, - ../nimbus/constants, ../nimbus/vm/interpreter/vm_forks, + ../nimbus/constants, ../nimbus/vm_forks, ../nimbus/config type diff --git a/tests/test_helpers.nim b/tests/test_helpers.nim index 5b2e04684..cca6905c6 100644 --- a/tests/test_helpers.nim +++ b/tests/test_helpers.nim @@ -10,7 +10,7 @@ import stew/byteutils, net, eth/[common, keys, rlp, p2p], unittest2, testutils/markdown_reports, ../nimbus/[config, transaction, utils, errors], - ../nimbus/vm/interpreter/vm_forks, + ../nimbus/vm_forks, ../nimbus/db/accounts_cache, ../nimbus/random_keys diff --git a/tests/test_precompiles.nim b/tests/test_precompiles.nim index e1f7a155c..b023e928a 100644 --- a/tests/test_precompiles.nim +++ b/tests/test_precompiles.nim @@ -8,8 +8,8 @@ import unittest2, ../nimbus/vm/precompiles, json, stew/byteutils, test_helpers, os, tables, strformat, strutils, eth/trie/db, eth/common, ../nimbus/db/db_chain, - ../nimbus/[vm_types, vm_state], ../nimbus/vm/computation, macros, - ../nimbus/vm/interpreter/vm_forks, test_allowed_to_fail + ../nimbus/[vm_types, vm_state, vm_forks], ../nimbus/vm/computation, macros, + test_allowed_to_fail proc initAddress(i: byte): EthAddress = result[19] = i