2020-06-12 16:43:20 +00:00
|
|
|
{.push raises: [Defect].}
|
|
|
|
|
2020-02-07 07:13:38 +00:00
|
|
|
import
|
2020-06-12 16:43:20 +00:00
|
|
|
os, strformat, chronicles,
|
2021-03-03 06:23:05 +00:00
|
|
|
./ssz_serialization,
|
|
|
|
../beacon_node_types,
|
|
|
|
../spec/[crypto, datatypes, digest]
|
2020-02-07 07:13:38 +00:00
|
|
|
|
2020-06-12 16:43:20 +00:00
|
|
|
# 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
|
|
|
|
|
2020-02-07 07:13:38 +00:00
|
|
|
proc dump*(dir: string, v: AttestationData, validator: ValidatorPubKey) =
|
2020-06-12 16:43:20 +00:00
|
|
|
logErrors:
|
|
|
|
SSZ.saveFile(dir / &"att-{v.slot}-{v.index}-{shortLog(validator)}.ssz", v)
|
2020-02-07 07:13:38 +00:00
|
|
|
|
2020-07-16 13:16:51 +00:00
|
|
|
proc dump*(dir: string, v: SignedBeaconBlock) =
|
2020-06-12 16:43:20 +00:00
|
|
|
logErrors:
|
2020-07-16 13:16:51 +00:00
|
|
|
SSZ.saveFile(dir / &"block-{v.message.slot}-{shortLog(v.root)}.ssz", v)
|
2020-05-11 18:08:52 +00:00
|
|
|
|
2020-07-16 13:16:51 +00:00
|
|
|
proc dump*(dir: string, v: TrustedSignedBeaconBlock) =
|
2020-06-25 10:23:10 +00:00
|
|
|
logErrors:
|
2020-07-16 13:16:51 +00:00
|
|
|
SSZ.saveFile(dir / &"block-{v.message.slot}-{shortLog(v.root)}.ssz", v)
|
2020-02-07 07:13:38 +00:00
|
|
|
|
|
|
|
proc dump*(dir: string, v: HashedBeaconState, blck: BlockRef) =
|
2020-06-12 16:43:20 +00:00
|
|
|
logErrors:
|
|
|
|
SSZ.saveFile(
|
|
|
|
dir / &"state-{v.data.slot}-{shortLog(blck.root)}-{shortLog(v.root)}.ssz",
|
|
|
|
v.data)
|
2020-05-11 18:08:52 +00:00
|
|
|
|
2020-06-06 11:26:19 +00:00
|
|
|
proc dump*(dir: string, v: HashedBeaconState) =
|
2020-06-12 16:43:20 +00:00
|
|
|
logErrors:
|
|
|
|
SSZ.saveFile(
|
|
|
|
dir / &"state-{v.data.slot}-{shortLog(v.root)}.ssz",
|
|
|
|
v.data)
|