Open dapplion opened 3 months ago
The example shown could use a superstruct mapping macro
pub fn attestations_len(self) -> usize {
map_beacon_block_body_ref!(&'a _, self, |inner, cons| {
let n = inner.attestations.len();
cons(inner);
n
})
}
Needs the cons(inner)
trick to do type hinting. That's an open issue: https://github.com/sigp/superstruct/issues/31
Description
Electra's new attestation type has introduced a match boilerplate.
https://github.com/sigp/lighthouse/blob/c4f2284dbe00ade38e93b1bac35c235386759cb9/consensus/types/src/beacon_block_body.rs#L236-L243
https://github.com/sigp/lighthouse/blob/9a01b6b363d1d54b15b3c37860b1c159eb7b8979/beacon_node/beacon_chain/tests/block_verification.rs#L727-L757
In previous issues, I stressed how we want fork addition to be as easy as possible to foster innovation. Having to add 1000 lines of mindless code just to develop a new feature is not optimal.
We can use some macro magic to prevent a new
ForkName::EIP9999
variant from having to modify all these statements.