Last active
December 13, 2024 13:20
-
-
Save arnetheduck/34b3cc5ada5180d581bc08a866a5e8af to your computer and use it in GitHub Desktop.
Block sizes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SignedBeaconBlock: 1125899911395480 | |
message: 1125899911395380 | |
slot: 8 | |
proposer_index: 8 | |
parent_root: 32 | |
state_root: 32 | |
body: 1125899911395296 | |
randao_reveal: 96 | |
eth1_data: 72 | |
graffiti: 32 | |
proposer_slashings: 6656 | |
attester_slashings: 66472 | |
attestations: 62592 | |
deposits: 19840 | |
voluntary_exits: 1792 | |
sync_aggregate: 160 | |
execution_payload: 1125899911038192 | |
parent_hash: 32 | |
fee_recipient: 20 | |
state_root: 32 | |
receipts_root: 32 | |
logs_bloom: 256 | |
prev_randao: 32 | |
block_number: 8 | |
gas_limit: 8 | |
gas_used: 8 | |
timestamp: 8 | |
extra_data: 32 | |
base_fee_per_gas: 32 | |
block_hash: 32 | |
transactions: 1125899911036928 | |
withdrawals: 704 | |
blob_gas_used: 8 | |
excess_blob_gas: 8 | |
bls_to_execution_changes: 2752 | |
blob_kzg_commitments: 196608 | |
signature: 96 | |
root: 32 | |
Attestation: 485 | |
aggregation_bits: 257 | |
data: 128 | |
signature: 96 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import | |
std/typetraits, | |
../beacon_chain/spec/eth2_ssz_serialization, | |
../beacon_chain/spec/datatypes/[deneb] | |
proc maxSize(T: type): int = | |
when isFixedSize(T): | |
fixedPortionSize(T) | |
elif T is HashList: | |
maxSize(T.T) | |
elif T is BitList: | |
(T.maxLen div 8) + 1 | |
elif T is BitArray: | |
(T.maxLen + 7) div 8 | |
elif T is List: | |
type E = T.T | |
when isFixedSize(E): | |
T.maxLen * maxSize(E) | |
else: | |
T.maxLen * (maxSize(E) + 4) | |
elif T is object|tuple: | |
var size = fixedPortionSize(T) | |
for field in fields(default(T)): | |
when not isFixedSize(typeof(field)): | |
size += maxSize(typeof(field)) | |
size | |
else: | |
0 | |
proc printSizes(T: type, indent: string) = | |
when T is object: | |
for name, field in fieldPairs(default(T)): | |
type F = typeof(field) | |
echo indent, name, ": ", maxSize(F) | |
when not isFixedSize(F): | |
printSizes(F, indent & " ") | |
proc printSizes(T: type) = | |
echo T.name, ": ", maxSize(T) | |
printSizes(T, " ") | |
printSizes(deneb.SignedBeaconBlock) | |
printSizes(Attestation) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment