fixes nimbus evm tracer, add missing networkParams when constructing chainDB

This commit is contained in:
jangko 2021-09-26 10:45:52 +07:00
parent 8552dda7bb
commit 44394d9ffd
No known key found for this signature in database
GPG Key ID: 31702AE10541E6B9
2 changed files with 11 additions and 4 deletions

View File

@ -46,6 +46,9 @@ proc newBaseChainDB*(
proc `$`*(db: BaseChainDB): string =
result = "BaseChainDB"
proc networkParams*(db: BaseChainDB): NetworkParams =
NetworkParams(config: db.config, genesis: db.genesis)
proc exists*(self: BaseChainDB, hash: Hash256): bool =
self.db.contains(hash.data)

View File

@ -86,7 +86,8 @@ proc traceTransaction*(chainDB: BaseChainDB, header: BlockHeader,
memoryDB = newMemoryDB()
captureDB = newCaptureDB(chainDB.db, memoryDB)
captureTrieDB = trieDB captureDB
captureChainDB = newBaseChainDB(captureTrieDB, false, chainDB.networkId) # prune or not prune?
networkParams = chainDB.networkParams
captureChainDB = newBaseChainDB(captureTrieDB, false, chainDB.networkId, networkParams) # prune or not prune?
vmState = newBaseVMState(parent.stateRoot, header, captureChainDB, tracerFlags + {EnableAccount})
var stateDb = vmState.accountDb
@ -153,7 +154,8 @@ proc dumpBlockState*(db: BaseChainDB, header: BlockHeader, body: BlockBody, dump
memoryDB = newMemoryDB()
captureDB = newCaptureDB(db.db, memoryDB)
captureTrieDB = trieDB captureDB
captureChainDB = newBaseChainDB(captureTrieDB, false, db.networkId)
networkParams = db.networkParams
captureChainDB = newBaseChainDB(captureTrieDB, false, db.networkId, networkParams)
# we only need stack dump if we want to scan for internal transaction address
vmState = newBaseVMState(parent.stateRoot, header, captureChainDB, {EnableTracing, DisableMemory, DisableStorage, EnableAccount})
miner = vmState.coinbase()
@ -210,7 +212,8 @@ proc traceBlock*(chainDB: BaseChainDB, header: BlockHeader, body: BlockBody, tra
memoryDB = newMemoryDB()
captureDB = newCaptureDB(chainDB.db, memoryDB)
captureTrieDB = trieDB captureDB
captureChainDB = newBaseChainDB(captureTrieDB, false, chainDB.networkId)
networkParams = chainDB.networkParams
captureChainDB = newBaseChainDB(captureTrieDB, false, chainDB.networkId, networkParams)
vmState = newBaseVMState(parent.stateRoot, header, captureChainDB, tracerFlags + {EnableTracing})
if header.txRoot == BLANK_ROOT_HASH: return newJNull()
@ -243,7 +246,8 @@ proc dumpDebuggingMetaData*(chainDB: BaseChainDB, header: BlockHeader,
memoryDB = newMemoryDB()
captureDB = newCaptureDB(chainDB.db, memoryDB)
captureTrieDB = trieDB captureDB
captureChainDB = newBaseChainDB(captureTrieDB, false, chainDB.networkId)
networkParams = chainDB.networkParams
captureChainDB = newBaseChainDB(captureTrieDB, false, chainDB.networkId, networkParams)
bloom = createBloom(vmState.receipts)
let blockSummary = %{