Skip to content

fix(ssz): Add validation checks for BitList and BitVector#10796

Open
kevaundray wants to merge 3 commits intoNethermindEth:masterfrom
kevaundray:kw/decode-bitlist-fix
Open

fix(ssz): Add validation checks for BitList and BitVector#10796
kevaundray wants to merge 3 commits intoNethermindEth:masterfrom
kevaundray:kw/decode-bitlist-fix

Conversation

@kevaundray
Copy link

@kevaundray kevaundray commented Mar 12, 2026

For my understanding:

BitVector

  • BitVector[N] is a fixed-length bit array that is serialized into ceil(N/8) bytes. Any bits above position N should be 0 since they are just padding. The old code seemed to just truncate and not check this.

  • There also were missing checks on the byte count. For example BitVector[5] needs 1 byte., however the code seemed to allow passing for example 2 bytes.

BitList

  • BitList[N] is variable length. We use a sentinel 1 bit after the data to encode the actual length. This means that the serialized form should always have at least one byte (for the sentinel bit) and moreover, the last byte should always be non-zero since it holds the sentinel.

Changes

  • This adds the necessary validation checks for bitlist and bitvector

Related to #10793

Types of changes

What types of changes does your code introduce?

  • Bugfix (a non-breaking change that fixes an issue)
  • New feature (a non-breaking change that adds functionality)
  • Breaking change (a change that causes existing functionality not to work as expected)
  • Optimization
  • Refactoring
  • Documentation update
  • Build-related changes
  • Other: Description

Testing

Requires testing

  • Yes
  • No

If yes, did you write tests?

  • Yes
  • No

Notes on testing

Optional. Remove if not applicable.

Documentation

Requires documentation update

  • Yes
  • No

If yes, link the PR to the docs update or the issue with the details labeled docs. Remove if not applicable.

Requires explanation in Release Notes

  • Yes
  • No

If yes, fill in the details here. Remove if not applicable.

Remarks

Optional. Remove if not applicable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants