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

provide ssz bitvector OR function #8302

Merged
merged 4 commits into from
May 8, 2024
Merged

Conversation

tbenr
Copy link
Contributor

@tbenr tbenr commented May 8, 2024

provides bitvecor OR, useful for 7549

Related to #7965

Documentation

  • I thought about documentation and added the doc-change-required label to this PR if updates are required.

Changelog

  • I thought about adding a changelog entry, and added one if I deemed necessary.

Co-authored-by: mehdi-aouadi <mehdi.aouadi@consensys.net>
@tbenr tbenr changed the title provide bitvector OR function provide ssz bitvector OR function May 8, 2024
Copy link
Contributor

@zilm13 zilm13 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM just nit finals

@@ -76,6 +76,16 @@ public List<Integer> getSetBitIndices() {
return data.stream().boxed().toList();
}

public BitvectorImpl or(final BitvectorImpl other) {
if (other.getSize() > getSize()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'd think we want to make sure the sizes match exactly if we're doing a bitwise or, otherwise we'll be needing to decide if the stragglers are left or right etc... other.size() != getSize

Copy link
Contributor Author

@tbenr tbenr May 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mm yes but this mimics the BitlistImpl or which does the same. We may say that this is a vector so it could be more strict but I'm more on the side to have a similar behavior.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

its probably bad behaviour to mimic... you can mis-match and do bitwise or partially.... future @tbenr problem to find i guess...

Copy link
Contributor

@zilm13 zilm13 May 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this feature really used somewhere? (I mean or with smaller list/vector)
If yes we could split it to several safer steps, but it could affect performance

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

k lets be more stringent and maybe open in the future.
@zilm13 we won't (at least for 7549)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i really do think we're better off making this one right rather than copying a bad idea - especially on a bitwise or... at least then we know why its a greater than if it causes a break...

Copy link
Contributor

@rolfyone rolfyone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

other than the discussion about sizings, looks good. won't block it but i do feel like we should check it fully on a bitwise op.

@tbenr tbenr enabled auto-merge (squash) May 8, 2024 21:23
@tbenr tbenr merged commit c55f69e into Consensys:master May 8, 2024
14 of 16 checks passed
@tbenr tbenr deleted the Bitvector-OR branch May 8, 2024 21:44
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

Successfully merging this pull request may close these issues.

3 participants