mirror of
https://github.com/status-im/nimbus-eth2.git
synced 2025-01-12 07:14:20 +00:00
42832cefa8
* random fixes * create dump dir on startup * don't crash on failure to write dump * fix a few `uint64` instances being used when indexing arrays - this should be a compile error but isn't due to compiler bugs * fix standalone test_block_pool compilation * add signed block processing in ncli * reuse cache entry instead of allocating a new one * allow for small clock disparities when validating blocks
40 lines
1.2 KiB
Nim
40 lines
1.2 KiB
Nim
import
|
|
confutils, os, strutils, json_serialization,
|
|
stew/byteutils,
|
|
../beacon_chain/spec/[crypto, datatypes, digest],
|
|
../beacon_chain/ssz/[merkleization, ssz_serialization]
|
|
|
|
# TODO turn into arguments
|
|
cli do(kind: string, file: string):
|
|
|
|
template printit(t: untyped) {.dirty.} =
|
|
let v = newClone(
|
|
if cmpIgnoreCase(ext, ".ssz") == 0:
|
|
SSZ.loadFile(file, t)
|
|
elif cmpIgnoreCase(ext, ".json") == 0:
|
|
JSON.loadFile(file, t)
|
|
else:
|
|
echo "Unknown file type: ", ext
|
|
quit 1
|
|
)
|
|
when t is SignedBeaconBlock:
|
|
echo hash_tree_root(v.message).data.toHex()
|
|
else:
|
|
echo hash_tree_root(v[]).data.toHex()
|
|
|
|
let ext = splitFile(file).ext
|
|
|
|
case kind
|
|
of "attester_slashing": printit(AttesterSlashing)
|
|
of "attestation": printit(Attestation)
|
|
of "signed_block": printit(SignedBeaconBlock)
|
|
of "block": printit(BeaconBlock)
|
|
of "block_body": printit(BeaconBlockBody)
|
|
of "block_header": printit(BeaconBlockHeader)
|
|
of "deposit": printit(Deposit)
|
|
of "deposit_data": printit(DepositData)
|
|
of "eth1_data": printit(Eth1Data)
|
|
of "state": printit(BeaconState)
|
|
of "proposer_slashing": printit(ProposerSlashing)
|
|
of "voluntary_exit": printit(VoluntaryExit)
|