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

feat: add logsBloom class #2684

Closed
wants to merge 2 commits into from
Closed

feat: add logsBloom class #2684

wants to merge 2 commits into from

Conversation

georgi-l95
Copy link
Collaborator

Description:
This PR adds logsBloom object, which can take care of all bloom calculations, needed when there is missing logsBloom. Example are synthetic transactions, where we don't have logsBloom from the mirror node response. This PR only adds the class for this, calculations will be done in another to keep them tight and focused.

Related issue(s):

Fixes #2683

Notes for reviewer:

Checklist

  • Documented (Code comments, README, etc.)
  • Tested (unit, integration, etc.)

Signed-off-by: georgi-l95 <glazarov95@gmail.com>
@georgi-l95 georgi-l95 added this to the 0.52.0 milestone Jul 8, 2024
@georgi-l95 georgi-l95 self-assigned this Jul 8, 2024
@georgi-l95 georgi-l95 linked an issue Jul 8, 2024 that may be closed by this pull request
Signed-off-by: georgi-l95 <glazarov95@gmail.com>
Copy link

sonarcloud bot commented Jul 8, 2024

@georgi-l95 georgi-l95 added the enhancement New feature or request label Jul 8, 2024
Copy link

github-actions bot commented Jul 8, 2024

Acceptance Tests

  17 files  220 suites   28m 33s ⏱️
604 tests 599 ✔️ 4 💤 1
667 runs  662 ✔️ 4 💤 1

Results for commit 20c5ed3.

♻️ This comment has been updated with latest results.

Copy link

github-actions bot commented Jul 8, 2024

Tests

    2 files  159 suites   14s ⏱️
864 tests 863 ✔️ 1 💤 0
876 runs  875 ✔️ 1 💤 0

Results for commit 20c5ed3.

Copy link
Member

@quiet-node quiet-node left a comment

Choose a reason for hiding this comment

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

Great work just some Qs around


import { keccak256 } from 'ethereum-cryptography/keccak.js';

const BYTE_SIZE = 256;
Copy link
Member

Choose a reason for hiding this comment

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

We might want to put this constant into a shared common place. I forgot what it is but there's a file we store constants, right?

if (!bitvector) {
this.bitvector = new Uint8Array(BYTE_SIZE);
} else {
if (bitvector.length !== BYTE_SIZE) throw new Error('bitvectors must be 2048 bits long');
Copy link
Member

Choose a reason for hiding this comment

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

Would be nice to have a refference link states why logsBloom must be 2048 bits (256 bytes).

const mask = 2047; // binary 11111111111

for (let i = 0; i < 3; i++) {
const first2bytes = new DataView(e.buffer).getUint16(i * 2);
Copy link
Member

Choose a reason for hiding this comment

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

Would be nice to explain along the steps through code comments

e = keccak256(e);
const mask = 2047; // binary 11111111111

for (let i = 0; i < 3; i++) {
Copy link
Member

Choose a reason for hiding this comment

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

Why 3?

Copy link
Member

Choose a reason for hiding this comment

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

Would be nice to explain along the steps through code comments

const mask = 2047; // binary 11111111111
let match = true;

for (let i = 0; i < 3 && match; i++) {
Copy link
Member

Choose a reason for hiding this comment

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

Would be nice to explain along the steps through code comments

Copy link
Collaborator

@Nana-EC Nana-EC left a comment

Choose a reason for hiding this comment

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

Nice work unblocking this.
I think @quiet-node had some good requests in here.
This is one of those classes that is likely rarely going to be updated but his deep crypto logic that is good to make sure if well commented and referenced so that the 1 time we do have to update it we understand what's going on

@georgi-l95 georgi-l95 modified the milestones: 0.52.0, 0.53.0 Jul 15, 2024
@georgi-l95
Copy link
Collaborator Author

Superseded by #2785

@georgi-l95 georgi-l95 closed this Aug 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add logsBloom class
3 participants