mirror of
https://github.com/status-im/nimbus-eth2.git
synced 2025-02-13 06:57:10 +00:00
* ssz: move ref support outside Instead of allocating ref's inside SSZ, move it to separate helper: * makes `ref` allocations explicit * less magic inside SSZ * `ref` in nim generally means reference whereas SSZ was loading as value - if a type indeed used references it would get copies instead of references to a single value on roundtrip which is unexpected TODO: EF tests would benefit from some refactoring since they all do the same thing practically.. Co-authored-by: Zahary Karadjov <zahary@gmail.com>
20 lines
601 B
Nim
20 lines
601 B
Nim
import
|
|
confutils, chronicles,
|
|
../beacon_chain/spec/[crypto, datatypes],
|
|
../beacon_chain/[extras, state_transition, ssz]
|
|
|
|
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"
|
|
else:
|
|
SSZ.saveFile(post, stateY.data)
|