From a087d655429b3c2db903e44cd514fac13a0dd636 Mon Sep 17 00:00:00 2001 From: jangko Date: Fri, 29 Jul 2022 02:34:38 +0700 Subject: [PATCH] reduce test suite time consumption --- nimbus/chain_config.nim | 20 ++++++++++++++++++-- nimbus/p2p/clique/snapshot/snapshot_desc.nim | 2 ++ nimbus/vm/interpreter_dispatch.nim | 3 ++- test_macro.nim | 12 ++++++++++++ tests/test_blockchain_json.nim | 6 +++++- tests/test_configuration.nim | 3 ++- tests/test_generalstate_json.nim | 8 ++++++-- 7 files changed, 47 insertions(+), 7 deletions(-) diff --git a/nimbus/chain_config.nim b/nimbus/chain_config.nim index 8c13c1259..26fa3cc32 100644 --- a/nimbus/chain_config.nim +++ b/nimbus/chain_config.nim @@ -50,7 +50,7 @@ type clique : CliqueOptions terminalTotalDifficulty*: Option[UInt256] - ChainConfig* = object + ChainConfig* = ref object chainId* : ChainId homesteadBlock* : BlockNumber daoForkBlock* : BlockNumber @@ -79,7 +79,7 @@ type terminalTotalDifficulty*: Option[UInt256] - Genesis* = object + Genesis* = ref object nonce* : BlockNonce timestamp* : EthTime extraData* : seq[byte] @@ -246,6 +246,7 @@ template to(a: string, b: type UInt256): UInt256 = proc loadNetworkParams*(cc: CustomChain, cg: var NetworkParams): bool = cg.genesis = cc.genesis + cg.config = ChainConfig() cg.config.chainId = cc.config.chainId cg.config.daoForkSupport = cc.config.daoForkSupport cg.config.eip150Hash = cc.config.eip150Hash @@ -517,3 +518,18 @@ proc networkParams*(id: NetworkId): NetworkParams {.gcsafe, raises: [Defect, ValueError, RlpError].} = result.genesis = genesisBlockForNetwork(id) result.config = chainConfigForNetwork(id) + +proc `==`*(a, b: ChainId): bool = + a.uint64 == b.uint64 + +proc `==`*(a, b: Genesis): bool = + if a.isNil and b.isNil: return true + if a.isNil and not b.isNil: return false + if not a.isNil and b.isNil: return false + a[] == b[] + +proc `==`*(a, b: ChainConfig): bool = + if a.isNil and b.isNil: return true + if a.isNil and not b.isNil: return false + if not a.isNil and b.isNil: return false + a[] == b[] diff --git a/nimbus/p2p/clique/snapshot/snapshot_desc.nim b/nimbus/p2p/clique/snapshot/snapshot_desc.nim index ef13657b2..1295f41ba 100644 --- a/nimbus/p2p/clique/snapshot/snapshot_desc.nim +++ b/nimbus/p2p/clique/snapshot/snapshot_desc.nim @@ -29,6 +29,8 @@ import eth/[common, rlp, trie/db], stew/results +export tables + type SnapshotResult* = ##\ ## Snapshot/error result type diff --git a/nimbus/vm/interpreter_dispatch.nim b/nimbus/vm/interpreter_dispatch.nim index df9234eec..afc9138e0 100644 --- a/nimbus/vm/interpreter_dispatch.nim +++ b/nimbus/vm/interpreter_dispatch.nim @@ -308,7 +308,7 @@ proc opTableToCaseStmt(opTable: array[Op, NimNode], c: NimNode): NimNode = `c`.prepareTracer() while true: `instr` = `c`.code.next() - #{.computedGoto.} + {.computedGoto.} # computed goto causing stack overflow, it consumes a lot of space # we could use manual jump table instead # TODO lots of macro magic here to unravel, with chronicles... @@ -377,6 +377,7 @@ proc londonVM(c: Computation) {.gcsafe.} = proc selectVM(c: Computation, fork: Fork) {.gcsafe.} = # TODO: Optimise getting fork and updating opCodeExec only when necessary + {.computedGoto.} case fork of FkFrontier: c.frontierVM() diff --git a/test_macro.nim b/test_macro.nim index 73940bb0a..ba757a3b0 100644 --- a/test_macro.nim +++ b/test_macro.nim @@ -5,6 +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 std/times import ./nimbus/vm_compile_info import macros, strutils, os, unittest2, osproc import threadpool @@ -16,12 +17,23 @@ setMinPoolSize(2) proc executeMyself(numModules: int, names: openArray[string]): int = let appName = getAppFilename() + var elpdList = newSeq[Duration](numModules) for i in 0..