No tests for SSZ union type
Ligthouse's SSZ impl was recently found to have a bug in its decoding of invalid Union types:
- https://github.com/sigp/ethereum_ssz/issues/64
TL;DR we would decode 0x00......: Union[T...] as None, ignoring any trailing bytes after the 0x00 selector.
Fortunately this does not cause a consensus failure as Union is currently unused in Ethereum consensus.
However, I still think it would be prudent for the spec to add some tests exercising the Union code paths. Writing new tests in ssz_generic might be the simplest.
The same issue was reported by the same bug-hunter against remerkleable:
- https://github.com/protolambda/remerkleable/issues/28
(I have not validated this bug however)
Hey @michaelsproul. Great findings from UCSB! Yes, we should definitely add tests for this.
I threw copilot at it and it seemed to do OK:
- https://github.com/michaelsproul/consensus-specs/pull/1
But I am not well-versed in the test generators, so will leave it up to you. Obvs feel free to take anything/nothing from that PR.
I threw copilot at it and it seemed to do OK:
Oh cool. This does look pretty good. I'll leave it up to @leolara but yes, we might steal some of this 😄
an alternative would be to remove Union entirely 🙈
an alternative would be to remove
Unionentirely 🙈
well
- https://github.com/ethereum/consensus-specs/pull/3906
RIP, Lighthouse uses them internally in our database types 💀