nimbus-eth2/research/serialized_sizes.nim
Jacek Sieka 125231d321
add initial block pool (#139)
* implement in-memory block graph
* store tail block in database
* resolve unknown parents by syncing them from peers
* introduce concept of resolved blocks and attestations - those that
follow minimal protocol rules
* update state head lazily
* log more stuff
* shortHash -> shortLog
* start 9/10 beacon nodes by default, last can be started manually
* see also #134
* fix start.sh epoch length
2019-02-28 15:21:29 -06:00

26 lines
1013 B
Nim

import
confutils,
../beacon_chain/[extras, ssz],
../beacon_chain/spec/[beaconstate, 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 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)
validatorsPerCommittee =
len(crosslink_committees[0].committee) # close enough..
for a in state.latest_attestations.mitems():
a.aggregation_bitfield.setLen(validatorsPerCommittee)
echo "Validators: ", deposits, ", total: ", state.serialize().len
dispatch(stateSize)