nimbus-eth2/research/serialized_sizes.nim
Jacek Sieka 9a3db7a81f
[WIP] Fake bls at runtime (#735)
* Initial implementation of runtime bls skipping.

Add libnfuzz skipBLSValidation handling, check that it propagates.

* Rename skipBLSValidation -> skipBlsValidation, start skipStateRootValidation
* Replace skipValidation flags with more granular flags.

Also added skipBlockParentRootValidation flag
Mainly replaced with skipBlsValidation but also StateRoot or
BlockParentRootValidation flags where appropriate.

* Adjust interop test to pass when skipping merkle validation.
* Stop skipping validation for mainchain_monitor.
* Remove comment.
* Also skipMerkleValidation for test_beacon_chain_db.
2020-03-05 13:52:10 +01:00

30 lines
1.2 KiB
Nim

import
confutils,
../beacon_chain/[extras, ssz],
../beacon_chain/spec/[beaconstate, datatypes, digest],
../tests/testblockutil
proc stateSize(deposits: int, maxContent = false) =
var state = initialize_beacon_state_from_eth1(
Eth2Digest(), 0,
makeInitialDeposits(deposits, {skipBLSValidation}), {skipBLSValidation})
if maxContent:
# TODO: state.latest_attestations was removed
# in https://github.com/status-im/nim-beacon-chain/pull/195
raise newException(ValueError, "Not supported at the moment")
# # TODO verify this is correct, but generally we collect up to two epochs
# # of attestations, and each block has a cap on the number of
# # attestations it may hold, so we'll just add so many of them
# state.latest_attestations.setLen(MAX_ATTESTATIONS * SLOTS_PER_EPOCH * 2)
# let
# crosslink_committees = get_crosslink_committees_at_slot(state, 0.Slot)
# validatorsPerCommittee =
# len(crosslink_committees[0].committee) # close enough..
# for a in state.latest_attestations.mitems():
# a.aggregation_bits = BitSeq.init(validatorsPerCommittee)
echo "Validators: ", deposits, ", total: ", SSZ.encode(state).len
dispatch(stateSize)