You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The SSZ spec states that lists and vectors should not have 0 capacity. The ssz_generic test suite from the EF tests checks this.
One way to enforce a non-zero capacity is at runtime, although this is a bit annoying in that it makes some previously infallible functions like List::empty() return a Result. This makes traits like Default impossible to implement without unwrap. I've got a WIP version of this change here: 6bcb9ba
Alternatively, we could use typenum's NonZero trait to enforce non-zero lengths at compile-time (dependent types!). This has the advantage of not adding any new Result types, but is a bit more complicated from an interface PoV. I've got a WIP version of this change here: d1eed1a. Integrating it into lighthouse would be a little more involved, we'd need to update EthSpec to add NonZero bounds to all typenum lengths. We could possibly use a new trait defined in milhouse to minimise the churn (e.g. use milhouse::Unsigned rather than use typenume::{Unsigned, NonZero}).
The text was updated successfully, but these errors were encountered:
The SSZ spec states that lists and vectors should not have 0 capacity. The
ssz_generic
test suite from the EF tests checks this.One way to enforce a non-zero capacity is at runtime, although this is a bit annoying in that it makes some previously infallible functions like
List::empty()
return aResult
. This makes traits likeDefault
impossible to implement withoutunwrap
. I've got a WIP version of this change here: 6bcb9baAlternatively, we could use
typenum
'sNonZero
trait to enforce non-zero lengths at compile-time (dependent types!). This has the advantage of not adding any newResult
types, but is a bit more complicated from an interface PoV. I've got a WIP version of this change here: d1eed1a. Integrating it intolighthouse
would be a little more involved, we'd need to updateEthSpec
to addNonZero
bounds to alltypenum
lengths. We could possibly use a new trait defined inmilhouse
to minimise the churn (e.g.use milhouse::Unsigned
rather thanuse typenume::{Unsigned, NonZero}
).The text was updated successfully, but these errors were encountered: