reduce test suite time consumption
This commit is contained in:
parent
2c0a8fa26d
commit
a087d65542
|
@ -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[]
|
||||
|
|
|
@ -29,6 +29,8 @@ import
|
|||
eth/[common, rlp, trie/db],
|
||||
stew/results
|
||||
|
||||
export tables
|
||||
|
||||
type
|
||||
SnapshotResult* = ##\
|
||||
## Snapshot/error result type
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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..<numModules:
|
||||
let start = getTime()
|
||||
let execResult = execCmd(appName & " " & $i)
|
||||
let elpd = getTime() - start
|
||||
elpdList[i] = elpd
|
||||
if execResult != 0:
|
||||
stderr.writeLine("subtest no: " & $i & " failed: " & names[i])
|
||||
result = result or execResult
|
||||
|
||||
var f = open("all_test.md", fmWrite)
|
||||
for i in 0..<numModules:
|
||||
f.write("* " & names[i])
|
||||
f.write(" - " & $elpdList[i])
|
||||
f.write("\n")
|
||||
f.close()
|
||||
|
||||
proc getImportStmt(stmtList: NimNode): NimNode =
|
||||
result = stmtList[0]
|
||||
result.expectKind nnkImportStmt
|
||||
|
|
|
@ -371,6 +371,10 @@ proc dumpDebugData(tester: Tester, fixture: JsonNode, fixtureName: string, fixtu
|
|||
let status = if success: "_success" else: "_failed"
|
||||
writeFile("debug_" & fixtureName & "_" & $fixtureIndex & status & ".json", debugData.pretty())
|
||||
|
||||
# using only one networkParams will reduce execution
|
||||
# time ~87.5% instead of create it for every test
|
||||
let chainParams = networkParams(MainNet)
|
||||
|
||||
proc testFixture(node: JsonNode, testStatusIMPL: var TestStatus, debugMode = false, trace = false) =
|
||||
# 1 - mine the genesis block
|
||||
# 2 - loop over blocks:
|
||||
|
@ -391,7 +395,7 @@ proc testFixture(node: JsonNode, testStatusIMPL: var TestStatus, debugMode = fal
|
|||
|
||||
let
|
||||
pruneTrie = test_config.getConfiguration().pruning
|
||||
chainDB = newBaseChainDB(newMemoryDb(), pruneTrie)
|
||||
chainDB = newBaseChainDB(newMemoryDb(), pruneTrie, params = chainParams)
|
||||
stateDB = AccountsCache.init(chainDB.db, emptyRlpHash, chainDB.pruneTrie)
|
||||
|
||||
setupStateDB(fixture["pre"], stateDB)
|
||||
|
|
|
@ -63,7 +63,8 @@ proc configurationMain*() =
|
|||
test "network-id set, no custom-network":
|
||||
let conf = makeConfig(@["--network:678"])
|
||||
check conf.networkId == 678.NetworkId
|
||||
check conf.networkParams == NetworkParams()
|
||||
check conf.networkParams.genesis == Genesis()
|
||||
check conf.networkParams.config == ChainConfig()
|
||||
|
||||
test "network-id not set, copy from chainId of custom network":
|
||||
let conf = makeConfig(@["--custom-network:" & genesisFile])
|
||||
|
|
|
@ -10,7 +10,7 @@ import
|
|||
./test_helpers, ./test_allowed_to_fail,
|
||||
../nimbus/p2p/executor, test_config,
|
||||
../nimbus/transaction,
|
||||
../nimbus/[vm_state, vm_types, utils],
|
||||
../nimbus/[vm_state, vm_types, utils, chain_config],
|
||||
../nimbus/db/[db_chain, accounts_cache],
|
||||
../nimbus/forks,
|
||||
chronicles,
|
||||
|
@ -83,9 +83,13 @@ proc dumpDebugData(tester: Tester, vmState: BaseVMState, sender: EthAddress, gas
|
|||
let status = if success: "_success" else: "_failed"
|
||||
writeFile("debug_" & tester.name & "_" & $tester.index & status & ".json", debugData.pretty())
|
||||
|
||||
# using only one networkParams will reduce execution
|
||||
# time ~90% instead of create it for every test
|
||||
let chainParams = networkParams(MainNet)
|
||||
|
||||
proc testFixtureIndexes(tester: Tester, testStatusIMPL: var TestStatus) =
|
||||
let
|
||||
chainDB = newBaseChainDB(newMemoryDB(), getConfiguration().pruning)
|
||||
chainDB = newBaseChainDB(newMemoryDB(), getConfiguration().pruning, params = chainParams)
|
||||
vmState = BaseVMState.new(
|
||||
parent = BlockHeader(stateRoot: emptyRlpHash),
|
||||
header = tester.header,
|
||||
|
|
Loading…
Reference in New Issue