nimbus-eth2/research/serialized_sizes.nim
Dustin Brody 9f55b4646c
More 0.5.1 spec updates (#195)
* rm gone-in-0.5.0 Proposal, verifyBlockSignature, and slot check which moved to spec function processBlockHeader

* mark get_attestation_participants and get_epoch_committee_count as 0.5.1; finish updating processAttestations to 0.5.1; add kludgy workaround for bug relating to get_winning_roots_etc using crosslink_data_root as index when we have that as ZERO_HASH for all leading to it confusing attesters on different shards; rm BeaconState.latest_attestations, which splits into previous_epoch_attestations and current_epoch_attestations

* Fix CI due to removed latest_attestations field
2019-03-22 18:33:12 +00:00

30 lines
1.2 KiB
Nim

import
confutils,
../beacon_chain/[extras, ssz],
../beacon_chain/spec/[beaconstate, bitfield, datatypes, digest, validator],
../tests/testutil
proc stateSize(deposits: int, maxContent = false) =
var state = get_genesis_beacon_state(
makeInitialDeposits(
deposits, {skipValidation}), 0, Eth1Data(), {skipValidation})
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_bitfield = BitField.init(validatorsPerCommittee)
echo "Validators: ", deposits, ", total: ", SSZ.encode(state).len
dispatch(stateSize)