EIP-6475: Add SSZ `Optional[T]` type (and drop selector byte in `Union` `None` case)
Add specification for EIP-6475 support for SSZ. Remerkleable impl: https://eips.ethereum.org/assets/eip-6475/optional.py Tests: https://eips.ethereum.org/assets/eip-6475/tests.py
We could possibly change all planned usage of Union with Optional, and introduce the conceptually more complex Union once needed. Optional serialization can be more optimized than Union.
Discussion: https://ethereum-magicians.org/t/eip-6475-ssz-optional/12891
This PR builds on prior work from:
- @zah at https://github.com/ethereum/consensus-specs/issues/1916
I would like to update all Python Optional to PyOptional in this PR to avoid confusions.
@etan-status Thanks for adding remerkleable implmentation. Do you want to open a PR in remerkleable too?
Sure, I can open a PR against Remerkleable as well, once the specs are accepted.
With the Union also dropping the selector byte for the None case, it actually becomes a superset of Optional, so the implementation is a bit easier than in the EIP (which targets the current Remerkleable).
StableContainer (EIP-7495) supports Optional in an even more compact format, and is also forward-compatible; if containers are extended later, proofs for known fields can still be processed even if the verifier code is not updated to support later added fields.
#3789 supersedes this, but as long as Verkle still depends on this PR here will leave this open.
Superseded by EIP-7495