nimbus-eth2/research/serialized_sizes.nim
Dustin Brody 2d52d5cbfe convert some asserts to doAsserts to keep them in release mode builds; rename get_initial_beacon_state to get_genesis_beacon_state to track spec; switch target spec version to 0.3.0; switch references to penalize_validator to slash_validator/slashValidator to track spec; make some function returns safer by omitting 'return' (#132)
* convert some asserts to doAsserts to keep them in release mode builds; rename get_initial_beacon_state to get_genesis_beacon_state to track spec; switch target spec version to 0.3.0; switch references to penalize_validator to slash_validator/slashValidator to track spec; make some function returns safer by omitting 'return'

* 2x shuffling speedup by hoisting pivot calculations per https://github.com/protolambda/eth2-shuffle
2019-02-22 10:56:45 +01:00

25 lines
988 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), 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)