From c8582583ef74243973599539e0cbe8e29e3f9b1f Mon Sep 17 00:00:00 2001 From: Jordan Hrycaj Date: Wed, 31 Mar 2021 18:08:31 +0100 Subject: [PATCH] merge vm_memory, vm_interpreter, and vm_utils_numeric => vm_internals why: currently used for tests only --- ...{vm_utils_numeric.nim => vm_internals.nim} | 29 +++++++++++++++--- nimbus/vm_interpreter.nim | 21 ------------- nimbus/vm_memory.nim | 30 ------------------- tests/macro_assembler.nim | 4 +-- tests/test_code_stream.nim | 2 +- tests/test_gas_meter.nim | 2 +- tests/test_generalstate_json.nim | 2 +- tests/test_memory.nim | 2 +- tests/test_misc.nim | 2 +- tests/test_stack.nim | 2 +- tests/test_vm_json.nim | 2 +- 11 files changed, 34 insertions(+), 64 deletions(-) rename nimbus/{vm_utils_numeric.nim => vm_internals.nim} (74%) delete mode 100644 nimbus/vm_interpreter.nim delete mode 100644 nimbus/vm_memory.nim diff --git a/nimbus/vm_utils_numeric.nim b/nimbus/vm_internals.nim similarity index 74% rename from nimbus/vm_utils_numeric.nim rename to nimbus/vm_internals.nim index 62577ee12..41648caf0 100644 --- a/nimbus/vm_utils_numeric.nim +++ b/nimbus/vm_internals.nim @@ -8,11 +8,25 @@ # 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, so it -# might be worth merging it into a vm_internals.nim (or so) header file. +# At the moment, this header file interface is only used for testing. + +import + ./vm/memory as vmm +export + vmm.Memory, + vmm.extend, + vmm.len, + vmm.newMemory, + vmm.read, + vmm.write + +when defined(evmc_enabled): + export + vmm.readPtr + + import ./vm/interpreter/utils/utils_numeric as vmn - export vmn.GasNatural, vmn.calcMemSize, @@ -26,5 +40,12 @@ export vmn.setSign, vmn.toInt, vmn.wordCount - + + +# Wrapping the wrapper -- lol +import + ./vm/interpreter as vmi +export + vmi + # End diff --git a/nimbus/vm_interpreter.nim b/nimbus/vm_interpreter.nim deleted file mode 100644 index 2b77986cd..000000000 --- a/nimbus/vm_interpreter.nim +++ /dev/null @@ -1,21 +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. - -# Wrapper for a wrapper -- lol - -# At the moment, this header file interface is only used for testing, so it -# might be worth merging it into a vm_internals.nim (or so) header file. -import - ./vm/interpreter as vmi - -export - vmi - -# End diff --git a/nimbus/vm_memory.nim b/nimbus/vm_memory.nim deleted file mode 100644 index 61b83fa5e..000000000 --- a/nimbus/vm_memory.nim +++ /dev/null @@ -1,30 +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. - -# Wrapper for a wrapper -- lol - -# At the moment, this header file interface is only used for testing, so it -# might be worth merging it into a vm_internals.nim (or so) header file. -import - ./vm/memory as vmm - -export - vmm.Memory, - vmm.extend, - vmm.len, - vmm.newMemory, - vmm.read, - vmm.write - -when defined(evmc_enabled): - export - vmm.readPtr - -# End diff --git a/tests/macro_assembler.nim b/tests/macro_assembler.nim index e89e8b6f7..5243c0a52 100644 --- a/tests/macro_assembler.nim +++ b/tests/macro_assembler.nim @@ -7,8 +7,8 @@ import options, json, os, eth/trie/[db, hexary], ../nimbus/[transaction, utils], ../nimbus/db/[db_chain, accounts_cache], - ../nimbus/[vm_computation, vm_state_transactions, vm_types2, - vm_message, vm_memory, vm_state, vm_types] + ../nimbus/[vm_state_transactions, vm_types2, + vm_message, vm_internals, vm_state, vm_types] export vm_types2, byteutils {.experimental: "dynamicBindSym".} diff --git a/tests/test_code_stream.nim b/tests/test_code_stream.nim index aeb1e572a..ddbce4772 100644 --- a/tests/test_code_stream.nim +++ b/tests/test_code_stream.nim @@ -6,7 +6,7 @@ # at your option. This file may not be copied, modified, or distributed except according to those terms. import unittest2, sequtils, - ../nimbus/vm_interpreter + ../nimbus/vm_internals proc codeStreamMain*() = suite "parse bytecode": diff --git a/tests/test_gas_meter.nim b/tests/test_gas_meter.nim index 4a176bc11..5bc1951cd 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, errors, vm_interpreter] + ../nimbus/[vm_types, errors, vm_internals] # 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 ca7b7f8f8..f8ad06c9f 100644 --- a/tests/test_generalstate_json.nim +++ b/tests/test_generalstate_json.nim @@ -13,7 +13,7 @@ import ../nimbus/p2p/executor, test_config, ../nimbus/transaction, ../nimbus/[vm_state, vm_types, utils], - ../nimbus/vm_interpreter, + ../nimbus/vm_internals, ../nimbus/db/[db_chain, accounts_cache] type diff --git a/tests/test_memory.nim b/tests/test_memory.nim index 0db72c96e..944285284 100644 --- a/tests/test_memory.nim +++ b/tests/test_memory.nim @@ -8,7 +8,7 @@ import unittest2, sequtils, eth/common/eth_types, - ../nimbus/[errors, vm_memory] + ../nimbus/[errors, vm_internals] proc memory32: Memory = result = newMemory() diff --git a/tests/test_misc.nim b/tests/test_misc.nim index 92d35f270..afa2ca183 100644 --- a/tests/test_misc.nim +++ b/tests/test_misc.nim @@ -1,7 +1,7 @@ import unittest2, stew/byteutils, eth/common/eth_types, - ../nimbus/vm_utils_numeric + ../nimbus/vm_internals func toAddress(n: int): EthAddress = result[19] = n.byte diff --git a/tests/test_stack.nim b/tests/test_stack.nim index 014ecf434..79360a805 100644 --- a/tests/test_stack.nim +++ b/tests/test_stack.nim @@ -8,7 +8,7 @@ import unittest2, eth/common/eth_types, - ../nimbus/[constants, errors, vm_interpreter] + ../nimbus/[constants, errors, vm_internals] template testPush(value: untyped, expected: untyped): untyped = diff --git a/tests/test_vm_json.nim b/tests/test_vm_json.nim index 0925748a2..c60bcc6b8 100644 --- a/tests/test_vm_json.nim +++ b/tests/test_vm_json.nim @@ -8,7 +8,7 @@ import unittest2, strformat, strutils, tables, json, os, times, sequtils, stew/byteutils, eth/[rlp, common], eth/trie/db, - ./test_helpers, ./test_allowed_to_fail, ../nimbus/vm_interpreter, + ./test_helpers, ./test_allowed_to_fail, ../nimbus/vm_internals, ../nimbus/[constants, vm_state, vm_types, utils], ../nimbus/db/[db_chain]