From cf63b9b03f4bc78eab0c05383233bef861f45408 Mon Sep 17 00:00:00 2001 From: Jordan Hrycaj Date: Wed, 31 Mar 2021 15:03:25 +0100 Subject: [PATCH] provide vm_memory as import/export wrapper details: moved original vm/memory.nim => vm/nvm_memory.nim --- nimbus/vm/interpreter/opcodes_impl.nim | 2 +- .../utils/macros_procs_opcodes.nim | 2 +- nimbus/vm/nvm_computation.nim | 2 +- nimbus/vm/{memory.nim => nvm_memory.nim} | 0 nimbus/vm/nvm_types.nim | 2 +- nimbus/vm/transaction_tracer.nim | 2 +- nimbus/vm_memory.nim | 30 +++++++++++++++++++ tests/macro_assembler.nim | 6 ++-- tests/test_memory.nim | 2 +- 9 files changed, 39 insertions(+), 9 deletions(-) rename nimbus/vm/{memory.nim => nvm_memory.nim} (100%) create mode 100644 nimbus/vm_memory.nim diff --git a/nimbus/vm/interpreter/opcodes_impl.nim b/nimbus/vm/interpreter/opcodes_impl.nim index 0964a694c..d4b795585 100644 --- a/nimbus/vm/interpreter/opcodes_impl.nim +++ b/nimbus/vm/interpreter/opcodes_impl.nim @@ -10,7 +10,7 @@ import chronicles, stint, nimcrypto, stew/ranges/ptr_arith, eth/common, vm/interpreter/utils/[macros_procs_opcodes, utils_numeric], vm/interpreter/[gas_meter, nvm_gas_costs, opcode_values, nvm_forks], - vm/[memory, stack, code_stream, nvm_computation, nvm_state, nvm_types], + vm/[nvm_memory, stack, code_stream, nvm_computation, nvm_state, nvm_types], errors, constants, db/[db_chain, accounts_cache] diff --git a/nimbus/vm/interpreter/utils/macros_procs_opcodes.nim b/nimbus/vm/interpreter/utils/macros_procs_opcodes.nim index fe7e1b1ed..13177867b 100644 --- a/nimbus/vm/interpreter/utils/macros_procs_opcodes.nim +++ b/nimbus/vm/interpreter/utils/macros_procs_opcodes.nim @@ -10,7 +10,7 @@ import macros, strformat, stint, eth/common, - vm/[nvm_computation, stack, code_stream, memory], + vm/[nvm_computation, stack, code_stream, nvm_memory], vm/nvm_types, errors, vm/interpreter/[gas_meter, opcode_values], vm/interpreter/utils/utils_numeric diff --git a/nimbus/vm/nvm_computation.nim b/nimbus/vm/nvm_computation.nim index 65ae67a1b..0a56dea11 100644 --- a/nimbus/vm/nvm_computation.nim +++ b/nimbus/vm/nvm_computation.nim @@ -10,7 +10,7 @@ import sets, eth/[common, keys], constants, errors, vm/interpreter/[opcode_values, gas_meter, nvm_gas_costs, nvm_forks], - vm/[code_stream, memory, nvm_message, stack, nvm_types, nvm_state], + vm/[code_stream, nvm_memory, nvm_message, stack, nvm_types, nvm_state], db/[accounts_cache, db_chain], utils/header, nvm_precompiles, transaction_tracer, utils diff --git a/nimbus/vm/memory.nim b/nimbus/vm/nvm_memory.nim similarity index 100% rename from nimbus/vm/memory.nim rename to nimbus/vm/nvm_memory.nim diff --git a/nimbus/vm/nvm_types.nim b/nimbus/vm/nvm_types.nim index b5a85fad9..8ac3cc83d 100644 --- a/nimbus/vm/nvm_types.nim +++ b/nimbus/vm/nvm_types.nim @@ -11,7 +11,7 @@ import tables, eth/common, options, json, sets, - vm/[memory, stack, code_stream], + vm/[nvm_memory, stack, code_stream], vm/interpreter/[nvm_gas_costs, opcode_values, nvm_forks], # TODO - will be hidden at a lower layer db/[db_chain, accounts_cache] diff --git a/nimbus/vm/transaction_tracer.nim b/nimbus/vm/transaction_tracer.nim index fe3d64088..7be9074bd 100644 --- a/nimbus/vm/transaction_tracer.nim +++ b/nimbus/vm/transaction_tracer.nim @@ -1,7 +1,7 @@ import json, strutils, sets, hashes, chronicles, nimcrypto, eth/common, stint, - vm/nvm_types, memory, vm/stack, db/accounts_cache, + vm/[nvm_types, nvm_memory, stack], db/accounts_cache, eth/trie/hexary, vm/interpreter/opcode_values diff --git a/nimbus/vm_memory.nim b/nimbus/vm_memory.nim new file mode 100644 index 000000000..573160e4a --- /dev/null +++ b/nimbus/vm_memory.nim @@ -0,0 +1,30 @@ +# 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/nvm_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 24e81863d..44eb6f2eb 100644 --- a/tests/macro_assembler.nim +++ b/tests/macro_assembler.nim @@ -6,10 +6,10 @@ import import options, json, os, eth/trie/[db, hexary], - ../nimbus/[vm_state, vm_types, transaction, utils], + ../nimbus/[transaction, utils], ../nimbus/db/[db_chain, accounts_cache], - ../nimbus/[vm_computation, vm_state_transactions, vm_forks, vm_message], - ../nimbus/vm/memory + ../nimbus/[vm_computation, vm_state_transactions, vm_forks, + vm_message, vm_memory, vm_state, vm_types] export opcode_values, byteutils {.experimental: "dynamicBindSym".} diff --git a/tests/test_memory.nim b/tests/test_memory.nim index b9be8497e..0db72c96e 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_memory] proc memory32: Memory = result = newMemory()