move buildWitness from test_blockchain_json to vm_state
This commit is contained in:
parent
eabacb0a33
commit
49460b6b1e
|
@ -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)
|
||||
|
|
|
@ -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):
|
||||
|
|
Loading…
Reference in New Issue