Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No error raised when a (non-zero) vector field is assigned with an empty list #5

Open
ericsson49 opened this issue Jun 19, 2020 · 0 comments

Comments

@ericsson49
Copy link

When one assigns an empty list to a non zero vector (or initialized it with an empty list), the outcome of operation is ambiguous.
@protolambda has clarified that an error should be raised.
Currently, remerkleable.Vector doesn't raise an error.

Two code snippets illustrating that

>>> from eth2spec.phase1 import spec
>>> spec.Vector[spec.Bytes32,10]([])
Vector[SpecialByteVectorView, 10]<<len=10>>(
  0x0000000000000000000000000000000000000000000000000000000000000000,
  0x0000000000000000000000000000000000000000000000000000000000000000,
  0x0000000000000000000000000000000000000000000000000000000000000000,
  ... 4 omitted ...,
  0x0000000000000000000000000000000000000000000000000000000000000000,
  0x0000000000000000000000000000000000000000000000000000000000000000,
  0x0000000000000000000000000000000000000000000000000000000000000000
)
>>> from eth2spec.phase1 import spec
>>> spec.BeaconState().exposed_derived_secrets
Vector[List[ValidatorIndex, 32], 32768]<<len=32768>>(
  List[ValidatorIndex, 32]<<len=0>>(),
  List[ValidatorIndex, 32]<<len=0>>(),
  List[ValidatorIndex, 32]<<len=0>>(),
  ... 32762 omitted ...,
  List[ValidatorIndex, 32]<<len=0>>(),
  List[ValidatorIndex, 32]<<len=0>>(),
  List[ValidatorIndex, 32]<<len=0>>()
)
>>> spec.BeaconState().exposed_derived_secrets = []
>>>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant