mirror of
https://github.com/status-im/nimbus-eth2.git
synced 2025-01-09 22:06:21 +00:00
1301600341
* cleanups * fix ncli state root check flag * add block dump to ncli_db * limit ncli_db benchmark length * tone down finalization logs * introduce trusted blocks We only store blocks whose signature we've verified in the database - as such, there's no need to check it again, and most importantly, no need to deserialize the signature when loading from database. 50x startup time improvement, 200x block load time improvement. * fix rewinding when deposits have invalid signature * speed up ancestor iteration by avoiding copy * avoid deserializing signatures for trusted data * load blocks lazily when rewinding (less memory used) * chronicles workarounds * document trustedbeaconblock
43 lines
1.3 KiB
Nim
43 lines
1.3 KiB
Nim
{.push raises: [Defect].}
|
|
|
|
import
|
|
os, strformat, chronicles,
|
|
ssz/ssz_serialization,
|
|
beacon_node_types,
|
|
./spec/[crypto, datatypes, digest]
|
|
|
|
# Dump errors are generally not fatal where used currently - the code calling
|
|
# these functions, like most code, is not exception safe
|
|
template logErrors(body: untyped) =
|
|
try:
|
|
body
|
|
except CatchableError as err:
|
|
notice "Failed to write SSZ", dir, msg = err.msg
|
|
|
|
proc dump*(dir: string, v: AttestationData, validator: ValidatorPubKey) =
|
|
logErrors:
|
|
SSZ.saveFile(dir / &"att-{v.slot}-{v.index}-{shortLog(validator)}.ssz", v)
|
|
|
|
proc dump*(dir: string, v: SignedBeaconBlock, root: Eth2Digest) =
|
|
logErrors:
|
|
SSZ.saveFile(dir / &"block-{v.message.slot}-{shortLog(root)}.ssz", v)
|
|
|
|
proc dump*(dir: string, v: TrustedSignedBeaconBlock, root: Eth2Digest) =
|
|
logErrors:
|
|
SSZ.saveFile(dir / &"block-{v.message.slot}-{shortLog(root)}.ssz", v)
|
|
|
|
proc dump*(dir: string, v: SomeSignedBeaconBlock, blck: BlockRef) =
|
|
dump(dir, v, blck.root)
|
|
|
|
proc dump*(dir: string, v: HashedBeaconState, blck: BlockRef) =
|
|
logErrors:
|
|
SSZ.saveFile(
|
|
dir / &"state-{v.data.slot}-{shortLog(blck.root)}-{shortLog(v.root)}.ssz",
|
|
v.data)
|
|
|
|
proc dump*(dir: string, v: HashedBeaconState) =
|
|
logErrors:
|
|
SSZ.saveFile(
|
|
dir / &"state-{v.data.slot}-{shortLog(v.root)}.ssz",
|
|
v.data)
|