sigp / lighthouse

Ethereum consensus client in Rust
https://lighthouse.sigmaprime.io/
Apache License 2.0
2.81k stars 696 forks source link

Superstruct `PartialBeaconBlock`? #5981

Open realbigsean opened 1 week ago

realbigsean commented 1 week ago

Description

Not sure how much of a pain this would be but it might clean up the block production code a bit.

PartialBeaconBlock is essentially a state and the info/operations required to propose a block. As we've added block fields across forks we've added optional fields PartialBeaconBlock rather than superstruct-ing it. This has worked pretty well, but we do end up having to handle Options where fields should really be required. In Electra, we've also got to handle fork-specific variants of operations too. So we're introducing more paths we have to handle that should never happen. superstruct-ing PartialBeaconBlock should let us grab all operations we need based on the state's fork and constructing a PartialBeaconBlock with all the required fields at once.