diff --git a/nimbus/vm_state.nim b/nimbus/vm_state.nim index 376873c92..7fed8e753 100644 --- a/nimbus/vm_state.nim +++ b/nimbus/vm_state.nim @@ -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) diff --git a/tests/test_blockchain_json.nim b/tests/test_blockchain_json.nim index 599cfa6b6..4c3ff6e43 100644 --- a/tests/test_blockchain_json.nim +++ b/tests/test_blockchain_json.nim @@ -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):