From c4dcf5da306808a051b5af0c61ecacf8666a3441 Mon Sep 17 00:00:00 2001 From: andri lim Date: Wed, 13 Nov 2019 21:49:39 +0700 Subject: [PATCH] reduce compiler warnings --- nimbus/block_types.nim | 3 +-- nimbus/constants.nim | 2 +- nimbus/db/capturedb.nim | 1 - nimbus/db/db_chain.nim | 4 ++-- nimbus/db/state_db.nim | 5 ++--- nimbus/genesis.nim | 4 ++-- nimbus/p2p/chain.nim | 6 +++--- nimbus/rpc/hexstrings.nim | 4 ++-- nimbus/transaction.nim | 2 +- nimbus/utils/difficulty.nim | 7 ++++--- nimbus/utils/header.nim | 2 +- nimbus/validation.nim | 2 +- nimbus/vm/code_stream.nim | 4 ++-- nimbus/vm/computation.nim | 6 +++--- nimbus/vm/interpreter/gas_costs.nim | 15 ++++++++------- nimbus/vm/interpreter/opcodes_impl.nim | 6 +++--- .../vm/interpreter/utils/macros_procs_opcodes.nim | 4 ++-- nimbus/vm/interpreter/utils/utils_numeric.nim | 4 ++-- nimbus/vm/memory.nim | 4 +--- nimbus/vm/stack.nim | 2 +- nimbus/vm/transaction_tracer.nim | 8 ++++---- nimbus/vm_state.nim | 6 +++--- nimbus/vm_state_transactions.nim | 8 ++++---- nimbus/vm_types.nim | 4 ++-- tests/macro_assembler.nim | 5 +++-- tests/test_code_stream.nim | 2 +- tests/test_difficulty.nim | 2 +- tests/test_generalstate_json.nim | 9 ++++----- tests/test_helpers.nim | 6 +++--- tests/test_memory.nim | 2 +- tests/test_op_custom.nim | 5 ++--- tests/test_op_env.nim | 2 +- tests/test_op_misc.nim | 5 ++--- tests/test_persistblock_json.nim | 2 +- tests/test_precompiles.nim | 6 +++--- tests/test_stack.nim | 2 +- tests/test_state_db.nim | 2 +- tests/test_vm_json.nim | 4 ++-- 38 files changed, 81 insertions(+), 86 deletions(-) diff --git a/nimbus/block_types.nim b/nimbus/block_types.nim index aff748449..837ec4b5c 100644 --- a/nimbus/block_types.nim +++ b/nimbus/block_types.nim @@ -6,8 +6,7 @@ # at your option. This file may not be copied, modified, or distributed except according to those terms. import - eth/common, - ./constants + eth/common type Block* = ref object of RootObj diff --git a/nimbus/constants.nim b/nimbus/constants.nim index 6a254844e..b3395e0e6 100644 --- a/nimbus/constants.nim +++ b/nimbus/constants.nim @@ -1,5 +1,5 @@ import - math, strutils, eth/common, nimcrypto/hash + eth/common, nimcrypto/hash proc default(t: typedesc): t = discard diff --git a/nimbus/db/capturedb.nim b/nimbus/db/capturedb.nim index 40169968f..135a36cf3 100644 --- a/nimbus/db/capturedb.nim +++ b/nimbus/db/capturedb.nim @@ -6,7 +6,6 @@ type PersistDel DB = TrieDatabaseRef - BytesRange = Range[byte] CaptureDB* = ref object of RootObj srcDb: DB diff --git a/nimbus/db/db_chain.nim b/nimbus/db/db_chain.nim index fa98e7a64..9868e92ff 100644 --- a/nimbus/db/db_chain.nim +++ b/nimbus/db/db_chain.nim @@ -6,8 +6,8 @@ # at your option. This file may not be copied, modified, or distributed except according to those terms. import - tables, sequtils, algorithm, - stew/[byteutils, ranges], state_db, eth/trie/[hexary, db], + sequtils, algorithm, + stew/[byteutils, ranges], eth/trie/[hexary, db], eth/[common, rlp], chronicles, ../errors, ../constants, ./storage_types, ../utils, ../config diff --git a/nimbus/db/state_db.nim b/nimbus/db/state_db.nim index 146a86882..c8bd1ca94 100644 --- a/nimbus/db/state_db.nim +++ b/nimbus/db/state_db.nim @@ -6,10 +6,9 @@ # at your option. This file may not be copied, modified, or distributed except according to those terms. import - sequtils, strformat, tables, + strformat, chronicles, eth/[common, rlp], eth/trie/[hexary, db], - ../constants, ../errors, ../validation, ../utils, - storage_types + ../constants, ../utils, storage_types logScope: topics = "state_db" diff --git a/nimbus/genesis.nim b/nimbus/genesis.nim index db688c8d6..ec52fbcba 100644 --- a/nimbus/genesis.nim +++ b/nimbus/genesis.nim @@ -1,6 +1,6 @@ import - times, tables, - eth/[common, rlp, trie], stint, stew/[byteutils, ranges], block_types, nimcrypto, + tables, + eth/[common, rlp, trie], stint, stew/[byteutils, ranges], chronicles, eth/trie/db, db/[db_chain, state_db], genesis_alloc, config, constants diff --git a/nimbus/p2p/chain.nim b/nimbus/p2p/chain.nim index a8b989823..ab19e11d8 100644 --- a/nimbus/p2p/chain.nim +++ b/nimbus/p2p/chain.nim @@ -1,6 +1,6 @@ -import ../db/[db_chain, state_db], eth/common, chronicles, ../vm_state, ../vm_types, ../transaction, stew/ranges, - ../vm/[computation, message], ../constants, stint, nimcrypto, - ../vm_state_transactions, sugar, ../utils, eth/trie/db, ../tracer, ./executor +import ../db/db_chain, eth/common, chronicles, ../vm_state, ../vm_types, stew/ranges, + ../vm/[computation, message], stint, nimcrypto, + ../utils, eth/trie/db, ../tracer, ./executor type Chain* = ref object of AbstractChainDB diff --git a/nimbus/rpc/hexstrings.nim b/nimbus/rpc/hexstrings.nim index ca607ba02..e6d62fac3 100644 --- a/nimbus/rpc/hexstrings.nim +++ b/nimbus/rpc/hexstrings.nim @@ -304,11 +304,11 @@ proc fromJson*(n: JsonNode, argName: string, result: var Bytes) = let hexStr = n.getStr() if not hexStr.isValidHexData: raise newException(ValueError, invalidMsg(argName) & " as a hex data \"" & hexStr & "\"") - result = hexToSeqByte(hexStr.string) + result = hexToSeqByte(hexStr) proc fromJson*(n: JsonNode, argName: string, result: var Hash256) = n.kind.expect(JString, argName) let hexStr = n.getStr() if not hexStr.isValidHash256: raise newException(ValueError, invalidMsg(argName) & " as a Hash256 \"" & hexStr & "\"") - hexToByteArray(hexStr.string, result.data) + hexToByteArray(hexStr, result.data) diff --git a/nimbus/transaction.nim b/nimbus/transaction.nim index b8a9549ce..19baf5c7a 100644 --- a/nimbus/transaction.nim +++ b/nimbus/transaction.nim @@ -6,7 +6,7 @@ # at your option. This file may not be copied, modified, or distributed except according to those terms. import - constants, errors, eth/[common, rlp, keys], nimcrypto, utils, + constants, errors, eth/[common, rlp, keys], utils, ./vm/interpreter/[vm_forks, gas_costs], constants import eth/common/transaction as common_transaction diff --git a/nimbus/utils/difficulty.nim b/nimbus/utils/difficulty.nim index 78ec3ebb4..155ad5cad 100644 --- a/nimbus/utils/difficulty.nim +++ b/nimbus/utils/difficulty.nim @@ -1,6 +1,7 @@ -import times -import eth/common, stint -import ../constants, ../vm/interpreter/vm_forks +import + times, + eth/common, stint, + ../constants, ../vm/interpreter/vm_forks const ExpDiffPeriod = 100000.u256 diff --git a/nimbus/utils/header.nim b/nimbus/utils/header.nim index aa92c14b9..4d82ccd6d 100644 --- a/nimbus/utils/header.nim +++ b/nimbus/utils/header.nim @@ -9,7 +9,7 @@ import strformat, times, options, eth/[common, rlp], - ../validation, ./difficulty, ../vm/interpreter/vm_forks, ../constants + ./difficulty, ../vm/interpreter/vm_forks, ../constants export BlockHeader diff --git a/nimbus/validation.nim b/nimbus/validation.nim index 31585770e..b4ca48525 100644 --- a/nimbus/validation.nim +++ b/nimbus/validation.nim @@ -7,7 +7,7 @@ import strformat, - errors, constants, eth/common + errors, eth/common proc validateGte*(value: Int256 | int, minimum: int, title: string = "Value") = if value.i256 < minimum.i256: diff --git a/nimbus/vm/code_stream.nim b/nimbus/vm/code_stream.nim index 85c16445b..485eac76f 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, - ../constants, ./interpreter/opcode_values + ./interpreter/opcode_values logScope: topics = "vm code_stream" @@ -28,7 +28,7 @@ proc newCodeStream*(codeBytes: seq[byte]): CodeStream = new(result) result.bytes = codeBytes result.pc = 0 - result.invalidPositions = initSet[int]() + result.invalidPositions = initHashSet[int]() result.depthProcessed = 0 result.cached = @[] diff --git a/nimbus/vm/computation.nim b/nimbus/vm/computation.nim index 0b1a1dd5f..7b38523e8 100644 --- a/nimbus/vm/computation.nim +++ b/nimbus/vm/computation.nim @@ -6,9 +6,9 @@ # at your option. This file may not be copied, modified, or distributed except according to those terms. import - chronicles, strformat, strutils, sequtils, macros, terminal, math, tables, options, + chronicles, strformat, strutils, sequtils, macros, math, tables, options, sets, eth/[common, keys], eth/trie/db as triedb, - ../constants, ../errors, ../validation, ../vm_state, ../vm_types, + ../constants, ../errors, ../vm_state, ../vm_types, ./interpreter/[opcode_values, gas_meter, gas_costs, vm_forks], ./code_stream, ./memory, ./message, ./stack, ../db/[state_db, db_chain], ../utils/header, stew/[byteutils, ranges], precompiles, @@ -254,7 +254,7 @@ proc addLogEntry*(c: BaseComputation, log: Log) {.inline.} = # in order to test some existing code iterator accountsForDeletion*(c: BaseComputation): EthAddress = var stack = @[c] - var deletedAccounts = initSet[EthAddress]() + var deletedAccounts = initHashSet[EthAddress]() while stack.len > 0: let comp = stack.pop() if comp.isError: continue diff --git a/nimbus/vm/interpreter/gas_costs.nim b/nimbus/vm/interpreter/gas_costs.nim index 407c9cd73..912c7db66 100644 --- a/nimbus/vm/interpreter/gas_costs.nim +++ b/nimbus/vm/interpreter/gas_costs.nim @@ -158,15 +158,16 @@ template gasCosts(fork: Fork, prefix, ResultGasCostsName: untyped) = # TODO: add logging result = max(newCost - prevCost, 0) - func `prefix all_but_one_64th`(gas: GasInt): GasInt {.inline.} = - ## Computes all but 1/64th - ## L(n) ≡ n − ⌊n/64⌋ - (floored(n/64)) - # Introduced in EIP-150 - https://github.com/ethereum/EIPs/blob/master/EIPS/eip-150.md + when fork >= FkTangerine: + func `prefix all_but_one_64th`(gas: GasInt): GasInt {.inline.} = + ## Computes all but 1/64th + ## L(n) ≡ n − ⌊n/64⌋ - (floored(n/64)) + # Introduced in EIP-150 - https://github.com/ethereum/EIPs/blob/master/EIPS/eip-150.md - # Note: The all-but-one-64th calculation should occur after the memory expansion fee is taken - # https://github.com/ethereum/yellowpaper/pull/442 + # Note: The all-but-one-64th calculation should occur after the memory expansion fee is taken + # https://github.com/ethereum/yellowpaper/pull/442 - result = gas - (gas shr 6) + result = gas - (gas shr 6) # ############### Opcode gas functions ############################## diff --git a/nimbus/vm/interpreter/opcodes_impl.nim b/nimbus/vm/interpreter/opcodes_impl.nim index 21f592c38..9b135f5d8 100644 --- a/nimbus/vm/interpreter/opcodes_impl.nim +++ b/nimbus/vm/interpreter/opcodes_impl.nim @@ -118,7 +118,7 @@ op signExtend, inline = false, bits, value: if bits <= 31.u256: let one = 1.u256 - testBit = bits.toInt * 8 + 7 + testBit = bits.truncate(int) * 8 + 7 bitPos = one shl testBit mask = bitPos - one if not isZero(value and bitPos): @@ -176,7 +176,7 @@ op notOp, inline = true, value: op byteOp, inline = true, position, value: ## 0x20, Retrieve single byte from word. - let pos = position.toInt + let pos = position.truncate(int) push: if pos >= 32 or pos < 0: zero(Uint256) @@ -453,7 +453,7 @@ proc jumpImpl(computation: BaseComputation, jumpTarget: UInt256) = if jumpTarget >= computation.code.len.u256: raise newException(InvalidJumpDestination, "Invalid Jump Destination") - let jt = jumpTarget.toInt + let jt = jumpTarget.truncate(int) computation.code.pc = jt let nextOpcode = computation.code.peek diff --git a/nimbus/vm/interpreter/utils/macros_procs_opcodes.nim b/nimbus/vm/interpreter/utils/macros_procs_opcodes.nim index 7aa532bfb..c1692e7c1 100644 --- a/nimbus/vm/interpreter/utils/macros_procs_opcodes.nim +++ b/nimbus/vm/interpreter/utils/macros_procs_opcodes.nim @@ -11,7 +11,7 @@ import macros, strformat, stint, eth/common, ../../computation, ../../stack, ../../code_stream, - ../../../constants, ../../../vm_types, ../../memory, + ../../../vm_types, ../../memory, ../../../errors, ../../message, ../../interpreter/[gas_meter, opcode_values], ../../interpreter/utils/utils_numeric @@ -43,7 +43,7 @@ macro op*(procname: untyped, inline: static[bool], stackParams_body: varargs[unt if len != 0: for params in stackParams: - popStackStmt.add newIdentNode(params.ident) + popStackStmt.add newIdentNode(params.strVal) popStackStmt.add newEmptyNode() popStackStmt.add quote do: diff --git a/nimbus/vm/interpreter/utils/utils_numeric.nim b/nimbus/vm/interpreter/utils/utils_numeric.nim index f0c2b215f..184d6f7b3 100644 --- a/nimbus/vm/interpreter/utils/utils_numeric.nim +++ b/nimbus/vm/interpreter/utils/utils_numeric.nim @@ -6,7 +6,7 @@ # at your option. This file may not be copied, modified, or distributed except according to those terms. import - strformat, strutils, sequtils, endians, macros, + macros, eth/common/eth_types, eth/rlp, ../../../constants @@ -57,7 +57,7 @@ func cleanMemRef*(x: UInt256): int {.inline.} = const upperBound = (high(int32) shr 2).u256 if x > upperBound: return high(int32) shr 2 - return x.toInt + return x.truncate(int) proc rangeToPadded*[T: StUint](x: openarray[byte], first, last: int, toLen = 0): T = ## Convert take a slice of a sequence of bytes interpret it as the big endian diff --git a/nimbus/vm/memory.nim b/nimbus/vm/memory.nim index 5f1f9f6d8..861f963ca 100644 --- a/nimbus/vm/memory.nim +++ b/nimbus/vm/memory.nim @@ -8,7 +8,7 @@ import sequtils, chronicles, eth/common/eth_types, - ../constants, ../errors, ../validation, + ../errors, ../validation, ./interpreter/utils/utils_numeric logScope: @@ -25,7 +25,6 @@ proc newMemory*: Memory = proc len*(memory: Memory): int = result = memory.bytes.len - proc extend*(memory: var Memory; startPos: Natural; size: Natural) = if size == 0: return @@ -50,7 +49,6 @@ proc write*(memory: var Memory, startPos: Natural, value: openarray[byte]) = #echo size #echo startPos validateLte(startPos + size, memory.len) - let index = memory.len if memory.len < startPos + size: memory.bytes = memory.bytes.concat(repeat(0.byte, memory.len - (startPos + size))) # TODO: better logarithmic scaling? diff --git a/nimbus/vm/stack.nim b/nimbus/vm/stack.nim index cd99be543..5625bb122 100644 --- a/nimbus/vm/stack.nim +++ b/nimbus/vm/stack.nim @@ -7,7 +7,7 @@ import chronicles, strformat, strutils, sequtils, macros, eth/[rlp, common], nimcrypto, - ../errors, ../validation, ./interpreter/utils/utils_numeric, ../constants + ../errors, ../validation logScope: topics = "vm stack" diff --git a/nimbus/vm/transaction_tracer.nim b/nimbus/vm/transaction_tracer.nim index 1d53cb4a5..f1bcd0554 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_types, memory, stack, ../db/[db_chain, state_db], + ../vm_types, memory, stack, ../db/state_db, eth/trie/hexary, ./message, stew/ranges/typedranges, ./interpreter/opcode_values @@ -21,7 +21,7 @@ proc initTracer*(tracer: var TransactionTracer, flags: set[TracerFlags] = {}) = tracer.trace["structLogs"] = newJArray() tracer.flags = flags - tracer.accounts = initSet[EthAddress]() + tracer.accounts = initHashSet[EthAddress]() tracer.storageKeys = @[] proc prepare*(tracer: var TransactionTracer, compDepth: int) = @@ -32,9 +32,9 @@ proc prepare*(tracer: var TransactionTracer, compDepth: int) = let prevLen = tracer.storageKeys.len tracer.storageKeys.setLen(compDepth + 1) for i in prevLen ..< tracer.storageKeys.len - 1: - tracer.storageKeys[i] = initSet[Uint256]() + tracer.storageKeys[i] = initHashSet[Uint256]() - tracer.storageKeys[compDepth] = initSet[Uint256]() + tracer.storageKeys[compDepth] = initHashSet[Uint256]() proc rememberStorageKey(tracer: var TransactionTracer, compDepth: int, key: Uint256) = tracer.storageKeys[compDepth].incl key diff --git a/nimbus/vm_state.nim b/nimbus/vm_state.nim index 9ec4e1693..6f75fd3db 100644 --- a/nimbus/vm_state.nim +++ b/nimbus/vm_state.nim @@ -7,8 +7,8 @@ import macros, strformat, tables, sets, - eth/common, eth/trie/db, - ./constants, ./errors, ./transaction, ./db/[db_chain, state_db], + eth/common, + ./constants, ./db/[db_chain, state_db], ./utils, json, vm_types, vm/transaction_tracer proc newAccessLogs*: AccessLogs = @@ -36,7 +36,7 @@ proc init*(self: BaseVMState, prevStateRoot: Hash256, header: BlockHeader, self.logEntries = @[] self.blockHeader.stateRoot = prevStateRoot self.accountDb = newAccountStateDB(chainDB.db, prevStateRoot, chainDB.pruneTrie) - self.touchedAccounts = initSet[EthAddress]() + self.touchedAccounts = initHashSet[EthAddress]() proc newBaseVMState*(prevStateRoot: Hash256, header: BlockHeader, chainDB: BaseChainDB, tracerFlags: set[TracerFlags] = {}): BaseVMState = diff --git a/nimbus/vm_state_transactions.nim b/nimbus/vm_state_transactions.nim index f7c19e94f..ded4bf661 100644 --- a/nimbus/vm_state_transactions.nim +++ b/nimbus/vm_state_transactions.nim @@ -6,10 +6,10 @@ # at your option. This file may not be copied, modified, or distributed except according to those terms. import - stew/ranges/typedranges, sequtils, strformat, tables, options, sets, - eth/common, chronicles, ./db/[db_chain, state_db], - constants, errors, transaction, vm_types, vm_state, utils, - ./vm/[computation, interpreter], ./vm/interpreter/gas_costs + stew/ranges/typedranges, options, sets, + eth/common, chronicles, ./db/state_db, + transaction, vm_types, vm_state, + ./vm/[computation, interpreter] proc validateTransaction*(vmState: BaseVMState, tx: Transaction, sender: EthAddress, fork: Fork): bool = # XXX: https://github.com/status-im/nimbus/issues/35#issuecomment-391726518 diff --git a/nimbus/vm_types.nim b/nimbus/vm_types.nim index 45fdd05dc..4ac821130 100644 --- a/nimbus/vm_types.nim +++ b/nimbus/vm_types.nim @@ -7,7 +7,7 @@ import tables, eth/common, eth/trie/db, - options, ./constants, json, sets, + options, json, sets, ./vm/[memory, stack, code_stream], ./vm/interpreter/[gas_costs, opcode_values, vm_forks], # TODO - will be hidden at a lower layer ./db/[db_chain, state_db] @@ -73,7 +73,7 @@ type # continuation helpers nextProc*: proc() {.gcsafe.} memOutLen*: int - memOutPos*: int + memOutPos*: int Error* = ref object info*: string diff --git a/tests/macro_assembler.nim b/tests/macro_assembler.nim index 00707719a..515daa2b0 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, tracer, vm_types, transaction, utils], + ../nimbus/[vm_state, vm_types, transaction, utils], ../nimbus/db/[db_chain, state_db], ../nimbus/vm_state_transactions, - ../nimbus/vm/interpreter/[vm_forks, gas_costs], + ../nimbus/vm/interpreter/vm_forks, ../nimbus/vm/[message, computation, memory] export opcode_values, byteutils @@ -246,6 +246,7 @@ proc initComputation(blockNumber: Uint256, chainDB: BaseChainDB, payload, data: proc runVM*(blockNumber: Uint256, chainDB: BaseChainDB, boa: Assembler): bool = var computation = initComputation(blockNumber, chainDB, boa.code, boa.data, boa.fork) + # TODO: support gas comsumption validation let gas = computation.gasMeter.gasRemaining execComputation(computation) let gasUsed = gas - computation.gasMeter.gasRemaining diff --git a/tests/test_code_stream.nim b/tests/test_code_stream.nim index d9f8f78c0..f78327697 100644 --- a/tests/test_code_stream.nim +++ b/tests/test_code_stream.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 unittest2, strutils, sequtils, +import unittest2, sequtils, ../nimbus/vm/interpreter proc codeStreamMain*() = diff --git a/tests/test_difficulty.nim b/tests/test_difficulty.nim index 041fe8412..fcbff7a67 100644 --- a/tests/test_difficulty.nim +++ b/tests/test_difficulty.nim @@ -1,4 +1,4 @@ -import unittest2, strutils, tables, ospaths, json, +import unittest2, strutils, tables, os, json, ../nimbus/utils/difficulty, stint, times, eth/common, test_helpers, stew/byteutils diff --git a/tests/test_generalstate_json.nim b/tests/test_generalstate_json.nim index 5cd7bee79..aa001a924 100644 --- a/tests/test_generalstate_json.nim +++ b/tests/test_generalstate_json.nim @@ -6,11 +6,11 @@ # at your option. This file may not be copied, modified, or distributed except according to those terms. import - unittest2, strformat, strutils, tables, json, ospaths, times, os, - stew/byteutils, stew/ranges/typedranges, nimcrypto, options, + unittest2, strformat, strutils, tables, json, times, os, + stew/ranges/typedranges, nimcrypto, options, eth/[rlp, common], eth/trie/[db, trie_defs], chronicles, ./test_helpers, ../nimbus/p2p/executor, test_config, - ../nimbus/[constants, errors, transaction], + ../nimbus/transaction, ../nimbus/[vm_state, vm_types, vm_state_transactions, utils], ../nimbus/vm/interpreter, ../nimbus/db/[db_chain, state_db] @@ -114,9 +114,8 @@ proc testFixtureIndexes(tester: Tester, testStatusIMPL: var TestStatus) = # perhaps the entire validateTransaction block # should be moved into processTransaction if tester.fork >= FkSpurious: - let recipient = tester.tx.getRecipient() let miner = tester.header.coinbase - let touchedAccounts = [miner] # [sender, miner, recipient] + let touchedAccounts = [miner] for account in touchedAccounts: debug "state clearing", account if db.accountExists(account) and db.isEmptyAccount(account): diff --git a/tests/test_helpers.nim b/tests/test_helpers.nim index c372c13ea..a5eb09613 100644 --- a/tests/test_helpers.nim +++ b/tests/test_helpers.nim @@ -6,11 +6,11 @@ # at your option. This file may not be copied, modified, or distributed except according to those terms. import - os, macros, json, strformat, strutils, parseutils, ospaths, tables, + os, macros, json, strformat, strutils, parseutils, os, tables, stew/byteutils, stew/ranges/typedranges, net, eth/[common, keys, rlp, p2p], unittest2, - ../nimbus/[vm_state, constants, config, transaction, utils, errors], + ../nimbus/[vm_state, config, transaction, utils, errors], ../nimbus/db/[db_chain, state_db], - ../nimbus/vm/interpreter/[gas_costs, vm_forks], + ../nimbus/vm/interpreter/vm_forks, ../tests/test_generalstate_failing func revmap(x: Table[Fork, string]): Table[string, Fork] = diff --git a/tests/test_memory.nim b/tests/test_memory.nim index f7e02d9e7..8b5c51756 100644 --- a/tests/test_memory.nim +++ b/tests/test_memory.nim @@ -8,7 +8,7 @@ import unittest2, sequtils, eth/common/eth_types, - ../nimbus/[constants, errors, vm/memory] + ../nimbus/[errors, vm/memory] proc memory32: Memory = result = newMemory() diff --git a/tests/test_op_custom.nim b/tests/test_op_custom.nim index e30f5f458..0ddd11805 100644 --- a/tests/test_op_custom.nim +++ b/tests/test_op_custom.nim @@ -1,7 +1,6 @@ import - macro_assembler, unittest2, macros, strutils, - stew/byteutils, eth/common, ../nimbus/db/state_db, - ../nimbus/db/db_chain, stew/ranges + macro_assembler, unittest2, macros, + stew/byteutils, eth/common, stew/ranges proc opCustomMain*() = suite "Custom Opcodes Test": diff --git a/tests/test_op_env.nim b/tests/test_op_env.nim index 06a94017c..8a89d5c8f 100644 --- a/tests/test_op_env.nim +++ b/tests/test_op_env.nim @@ -1,5 +1,5 @@ import - macro_assembler, unittest2, macros, strutils, + macro_assembler, unittest2, macros, stew/byteutils, eth/common, ../nimbus/db/state_db, ../nimbus/db/db_chain, stew/ranges diff --git a/tests/test_op_misc.nim b/tests/test_op_misc.nim index d04aa85e4..40cff30b5 100644 --- a/tests/test_op_misc.nim +++ b/tests/test_op_misc.nim @@ -1,7 +1,6 @@ import - macro_assembler, unittest2, macros, strutils, - stew/byteutils, eth/common, ../nimbus/db/state_db, - ../nimbus/db/db_chain, stew/ranges + macro_assembler, unittest2, macros, + stew/byteutils, eth/common, stew/ranges proc opMiscMain*() = suite "Misc Opcodes": diff --git a/tests/test_persistblock_json.nim b/tests/test_persistblock_json.nim index 69be7493f..db0671648 100644 --- a/tests/test_persistblock_json.nim +++ b/tests/test_persistblock_json.nim @@ -8,7 +8,7 @@ import unittest2, json, os, tables, strformat, strutils, eth/[common, rlp], stew/byteutils, eth/trie/db, - ./test_helpers, ../nimbus/db/[db_chain, storage_types], ../nimbus/[tracer, vm_types], + ./test_helpers, ../nimbus/db/db_chain, ../nimbus/p2p/chain # use tracerTestGen.nim to generate additional test data diff --git a/tests/test_precompiles.nim b/tests/test_precompiles.nim index 330b788e1..5652c4764 100644 --- a/tests/test_precompiles.nim +++ b/tests/test_precompiles.nim @@ -6,9 +6,9 @@ # at your option. This file may not be copied, modified, or distributed except according to those terms. import - unittest2, ../nimbus/vm/precompiles, json, stew/byteutils, test_helpers, ospaths, tables, - strformat, strutils, eth/trie/db, eth/common, ../nimbus/db/[db_chain, state_db], - ../nimbus/[constants, vm_types, vm_state], ../nimbus/vm/[computation, message], macros, + 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, message], macros, ../nimbus/vm/blake2b_f proc initAddress(i: byte): EthAddress = result[19] = i diff --git a/tests/test_stack.nim b/tests/test_stack.nim index e9214a08e..53aa16fca 100644 --- a/tests/test_stack.nim +++ b/tests/test_stack.nim @@ -38,7 +38,7 @@ proc stackMain*() = test "push does not allow stack to exceed 1024": var stack = newStack() - for z in 0 .. < 1024: + for z in 0 ..< 1024: stack.push(z.uint) check(stack.len == 1024) expect(FullStack): diff --git a/tests/test_state_db.nim b/tests/test_state_db.nim index dd360e7a0..34066d7f9 100644 --- a/tests/test_state_db.nim +++ b/tests/test_state_db.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 unittest2, strutils, eth/trie/[hexary, db], +import unittest2, eth/trie/[hexary, db], ../nimbus/db/state_db, stew/byteutils, eth/common, stew/ranges diff --git a/tests/test_vm_json.nim b/tests/test_vm_json.nim index 55597f018..08f3316ec 100644 --- a/tests/test_vm_json.nim +++ b/tests/test_vm_json.nim @@ -6,10 +6,10 @@ # at your option. This file may not be copied, modified, or distributed except according to those terms. import - unittest2, strformat, strutils, sequtils, tables, json, ospaths, times, + unittest2, strformat, strutils, tables, json, os, times, stew/byteutils, stew/ranges/typedranges, eth/[rlp, common], eth/trie/db, ./test_helpers, ../nimbus/vm/interpreter, - ../nimbus/[constants, errors, vm_state, vm_types, utils], + ../nimbus/[constants, vm_state, vm_types, utils], ../nimbus/db/[db_chain, state_db] proc testFixture(fixtures: JsonNode, testStatusIMPL: var TestStatus)