mirror of
https://github.com/status-im/nimbus-eth1.git
synced 2025-01-13 13:55:45 +00:00
221e6c9e2f
* Nimbus folder environment update details: * Integrated `CoreDbRef` for the sources in the `nimbus` sub-folder. * The `nimbus` program does not compile yet as it needs the updates in the parallel `stateless` sub-folder. * Stateless environment update details: * Integrated `CoreDbRef` for the sources in the `stateless` sub-folder. * The `nimbus` program compiles now. * Premix environment update details: * Integrated `CoreDbRef` for the sources in the `premix` sub-folder. * Fluffy environment update details: * Integrated `CoreDbRef` for the sources in the `fluffy` sub-folder. * Tools environment update details: * Integrated `CoreDbRef` for the sources in the `tools` sub-folder. * Nodocker environment update details: * Integrated `CoreDbRef` for the sources in the `hive_integration/nodocker` sub-folder. * Tests environment update details: * Integrated `CoreDbRef` for the sources in the `tests` sub-folder. * The unit tests compile and run cleanly now. * Generalise `CoreDbRef` to any `select_backend` supported database why: Generalisation was just missed due to overcoming some compiler oddity which was tied to rocksdb for testing. * Suppress compiler warning for `newChainDB()` why: Warning was added to this function which must be wrapped so that any `CatchableError` is re-raised as `Defect`. * Split off persistent `CoreDbRef` constructor into separate file why: This allows to compile a memory only database version without linking the backend library. * Use memory `CoreDbRef` database by default detail: Persistent DB constructor needs to import `db/core_db/persistent why: Most tests use memory DB anyway. This avoids linking `-lrocksdb` or any other backend by default. * fix `toLegacyBackend()` availability check why: got garbled after memory/persistent split. * Clarify raw access to MPT for snap sync handler why: Logically, `kvt` is not the raw access for the hexary trie (although this holds for the legacy database)
78 lines
1.9 KiB
Nim
78 lines
1.9 KiB
Nim
import
|
|
chronicles,
|
|
../nimbus/[vm_state, vm_types],
|
|
../nimbus/core/executor,
|
|
../nimbus/common/common,
|
|
../nimbus/db/core_db/persistent,
|
|
configuration # must be late (compilation annoyance)
|
|
|
|
const
|
|
numBlocks = 256
|
|
|
|
proc validateBlock(com: CommonRef, blockNumber: BlockNumber): BlockNumber =
|
|
var
|
|
parentNumber = blockNumber - 1
|
|
parent = com.db.getBlockHeader(parentNumber)
|
|
headers = newSeq[BlockHeader](numBlocks)
|
|
bodies = newSeq[BlockBody](numBlocks)
|
|
lastBlockHash: Hash256
|
|
|
|
for i in 0 ..< numBlocks:
|
|
headers[i] = com.db.getBlockHeader(blockNumber + i.u256)
|
|
bodies[i] = com.db.getBlockBody(headers[i].blockHash)
|
|
|
|
let transaction = com.db.beginTransaction()
|
|
defer: transaction.dispose()
|
|
|
|
for i in 0 ..< numBlocks:
|
|
stdout.write blockNumber + i.u256
|
|
stdout.write "\r"
|
|
|
|
let
|
|
vmState = BaseVMState.new(parent, headers[i], com)
|
|
validationResult = vmState.processBlockNotPoA(headers[i], bodies[i])
|
|
|
|
if validationResult != ValidationResult.OK:
|
|
error "block validation error", validationResult, blockNumber = blockNumber + i.u256
|
|
|
|
parent = headers[i]
|
|
|
|
transaction.rollback()
|
|
result = blockNumber + numBlocks.u256
|
|
|
|
proc main() {.used.} =
|
|
let
|
|
conf = getConfiguration()
|
|
com = CommonRef.new(newCoreDbRef(LegacyDbPersistent, conf.dataDir), false)
|
|
|
|
# move head to block number ...
|
|
if conf.head == 0.u256:
|
|
raise newException(ValueError, "please set block number with --head: blockNumber")
|
|
|
|
var counter = 0
|
|
var blockNumber = conf.head
|
|
|
|
while true:
|
|
blockNumber = com.validateBlock(blockNumber)
|
|
|
|
inc counter
|
|
if conf.maxBlocks != 0 and counter >= conf.maxBlocks:
|
|
break
|
|
|
|
when isMainModule:
|
|
var message: string
|
|
|
|
## Processing command line arguments
|
|
if processArguments(message) != Success:
|
|
echo message
|
|
quit(QuitFailure)
|
|
else:
|
|
if len(message) > 0:
|
|
echo message
|
|
quit(QuitSuccess)
|
|
|
|
try:
|
|
main()
|
|
except:
|
|
echo getCurrentExceptionMsg()
|