Last active
April 6, 2024 19:39
-
-
Save protolambda/db75c7faa1e94f2464787a480e5d613e to your computer and use it in GitHub Desktop.
Eth2 type bounds v0.12
This file contains 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
{ | |
"AggregateAndProof": { | |
"min_size": 337, | |
"max_size": 593 | |
}, | |
"Attestation": { | |
"min_size": 229, | |
"max_size": 485 | |
}, | |
"AttestationData": { | |
"size": 128 | |
}, | |
"AttesterSlashing": { | |
"min_size": 464, | |
"max_size": 33232 | |
}, | |
"BeaconBlock": { | |
"min_size": 304, | |
"max_size": 157656 | |
}, | |
"BeaconBlockBody": { | |
"min_size": 220, | |
"max_size": 157572 | |
}, | |
"BeaconBlockHeader": { | |
"size": 112 | |
}, | |
"BeaconState": { | |
"min_size": 2687377, | |
"max_size": 141837542965649 | |
}, | |
"Checkpoint": { | |
"size": 40 | |
}, | |
"Deposit": { | |
"size": 1240 | |
}, | |
"DepositData": { | |
"size": 184 | |
}, | |
"DepositMessage": { | |
"size": 88 | |
}, | |
"Eth1Block": { | |
"size": 48 | |
}, | |
"Eth1Data": { | |
"size": 72 | |
}, | |
"Fork": { | |
"size": 16 | |
}, | |
"ForkData": { | |
"size": 36 | |
}, | |
"HistoricalBatch": { | |
"size": 524288 | |
}, | |
"IndexedAttestation": { | |
"min_size": 228, | |
"max_size": 16612 | |
}, | |
"PendingAttestation": { | |
"min_size": 149, | |
"max_size": 405 | |
}, | |
"ProposerSlashing": { | |
"size": 416 | |
}, | |
"SignedAggregateAndProof": { | |
"min_size": 437, | |
"max_size": 693 | |
}, | |
"SignedBeaconBlock": { | |
"min_size": 404, | |
"max_size": 157756 | |
}, | |
"SignedBeaconBlockHeader": { | |
"size": 208 | |
}, | |
"SignedVoluntaryExit": { | |
"size": 112 | |
}, | |
"SigningData": { | |
"size": 64 | |
}, | |
"Validator": { | |
"size": 121 | |
}, | |
"VoluntaryExit": { | |
"size": 16 | |
}, | |
"MetaData": { | |
"size": 16 | |
}, | |
"Status": { | |
"size": 84 | |
}, | |
"Goodbye": { | |
"size": 8 | |
}, | |
"BeaconBlocksByRange": { | |
"size": 24 | |
} | |
} |
This file contains 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
from inspect import getmembers, isclass | |
from eth2spec.utils.ssz.ssz_typing import Container, uint64, Bitvector | |
from eth2spec.phase0 import spec | |
from eth2spec.phase0.spec import ForkDigest, Root, Slot, Epoch | |
ATTESTATION_SUBNET_COUNT = 64 | |
class MetaData(Container): | |
seq_number: uint64 | |
attnets: Bitvector[ATTESTATION_SUBNET_COUNT] | |
class Status(Container): | |
fork_digest: ForkDigest | |
finalized_root: Root | |
finalized_epoch: Epoch | |
head_root: Root | |
head_slot: Slot | |
class Goodbye(uint64): | |
pass | |
class BeaconBlocksByRange(Container): | |
start_slot: Slot | |
count: uint64 | |
step: uint64 | |
def get_spec_ssz_types(): | |
return [ | |
value for (_, value) in getmembers(spec, isclass) | |
if issubclass(value, Container) and value != Container # only the subclasses, not the imported base class | |
] + [MetaData, Status, Goodbye, BeaconBlocksByRange] | |
type_bounds = { | |
value.__name__: ({ | |
'size': value.type_byte_length() | |
} if value.is_fixed_byte_length() else { | |
'min_size': value.min_byte_length(), | |
'max_size': value.max_byte_length(), | |
}) for value in get_spec_ssz_types() | |
} | |
import json | |
print(json.dumps(type_bounds)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment