mirror of
https://github.com/status-im/nimbus-eth1.git
synced 2025-01-13 13:55:45 +00:00
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],
|
vm/interpreter/[vm_forks, gas_costs],
|
||||||
./constants, ./db/[db_chain, accounts_cache],
|
./constants, ./db/[db_chain, accounts_cache],
|
||||||
./utils, json, vm_types, vm/transaction_tracer,
|
./utils, json, vm_types, vm/transaction_tracer,
|
||||||
./config
|
./config, ../stateless/[multi_keys, witness_from_tree, witness_types]
|
||||||
|
|
||||||
proc newAccessLogs*: AccessLogs =
|
proc newAccessLogs*: AccessLogs =
|
||||||
AccessLogs(reads: initTable[string, string](), writes: initTable[string, string]())
|
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) =
|
proc `generateWitness=`*(vmState: BaseVMState, status: bool) =
|
||||||
if status: vmState.flags.incl GenerateWitness
|
if status: vmState.flags.incl GenerateWitness
|
||||||
else: vmState.flags.excl 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/utils/header,
|
||||||
../nimbus/p2p/[executor, dao],
|
../nimbus/p2p/[executor, dao],
|
||||||
../nimbus/config,
|
../nimbus/config,
|
||||||
../stateless/[multi_keys, tree_from_witness, witness_from_tree, witness_types]
|
../stateless/[tree_from_witness, witness_types]
|
||||||
|
|
||||||
type
|
type
|
||||||
SealEngine = enum
|
SealEngine = enum
|
||||||
@ -283,13 +283,9 @@ proc parseTester(fixture: JsonNode, testStatusIMPL: var TestStatus): Tester =
|
|||||||
|
|
||||||
proc blockWitness(vmState: BaseVMState, fork: Fork, chainDB: BaseChainDB) =
|
proc blockWitness(vmState: BaseVMState, fork: Fork, chainDB: BaseChainDB) =
|
||||||
let rootHash = vmState.accountDb.rootHash
|
let rootHash = vmState.accountDb.rootHash
|
||||||
let mkeys = vmState.accountDb.makeMultiKeys()
|
let witness = vmState.buildWitness()
|
||||||
let flags = if fork >= FKSpurious: {wfEIP170} else: {}
|
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
|
# build tree from witness
|
||||||
var db = newMemoryDB()
|
var db = newMemoryDB()
|
||||||
when defined(useInputStream):
|
when defined(useInputStream):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user