move buildWitness from test_blockchain_json to vm_state

This commit is contained in:
jangko 2020-06-10 13:01:37 +07:00
parent eabacb0a33
commit 49460b6b1e
No known key found for this signature in database
GPG Key ID: 31702AE10541E6B9
2 changed files with 12 additions and 7 deletions

View File

@ -11,7 +11,7 @@ import
vm/interpreter/[vm_forks, gas_costs],
./constants, ./db/[db_chain, accounts_cache],
./utils, json, vm_types, vm/transaction_tracer,
./config
./config, ../stateless/[multi_keys, witness_from_tree, witness_types]
proc newAccessLogs*: AccessLogs =
AccessLogs(reads: initTable[string, string](), writes: initTable[string, string]())
@ -149,3 +149,12 @@ proc generateWitness*(vmState: BaseVMState): bool {.inline.} =
proc `generateWitness=`*(vmState: BaseVMState, status: bool) =
if status: vmState.flags.incl GenerateWitness
else: vmState.flags.excl GenerateWitness
proc buildWitness*(vmState: BaseVMState): seq[byte] =
let rootHash = vmState.accountDb.rootHash
let mkeys = vmState.accountDb.makeMultiKeys()
let flags = if vmState.fork >= FKSpurious: {wfEIP170} else: {}
# build witness from tree
var wb = initWitnessBuilder(vmState.chainDB.db, rootHash, flags)
result = wb.buildWitness(mkeys)

View File

@ -18,7 +18,7 @@ import
../nimbus/utils/header,
../nimbus/p2p/[executor, dao],
../nimbus/config,
../stateless/[multi_keys, tree_from_witness, witness_from_tree, witness_types]
../stateless/[tree_from_witness, witness_types]
type
SealEngine = enum
@ -283,13 +283,9 @@ proc parseTester(fixture: JsonNode, testStatusIMPL: var TestStatus): Tester =
proc blockWitness(vmState: BaseVMState, fork: Fork, chainDB: BaseChainDB) =
let rootHash = vmState.accountDb.rootHash
let mkeys = vmState.accountDb.makeMultiKeys()
let witness = vmState.buildWitness()
let flags = if fork >= FKSpurious: {wfEIP170} else: {}
# build witness from tree
var wb = initWitnessBuilder(chainDB.db, rootHash, flags)
let witness = wb.buildWitness(mkeys)
# build tree from witness
var db = newMemoryDB()
when defined(useInputStream):