nimbus-eth2/ncli/ncli_transition.nim
Jacek Sieka 56ffb696be
reorder ssz (#1099)
* reorder ssz

* split into hash_trees and ssz_serialization, roughly, for hashing and
IO
* move bitseqs into ssz (from stew)
* clean up imports

* docs, imports
2020-06-03 15:52:02 +02:00

22 lines
665 B
Nim

import
confutils, chronicles,
../beacon_chain/spec/[crypto, datatypes],
../beacon_chain/[extras, state_transition],
../beacon_chain/ssz/[merkleization, ssz_serialization]
cli do(pre: string, blck: string, post: string, verifyStateRoot = false):
let
stateY = (ref HashedBeaconState)(
data: SSZ.loadFile(pre, BeaconState),
)
blckX = SSZ.loadFile(blck, SignedBeaconBlock)
flags = if verifyStateRoot: {skipStateRootValidation} else: {}
stateY.root = hash_tree_root(stateY.data)
if not state_transition(stateY[], blckX, flags, noRollback):
error "State transition failed"
quit 1
else:
SSZ.saveFile(post, stateY.data)