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

ADD: nullity bitmap and hashes in storage #63

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

thomas-quadratic
Copy link
Contributor

PR description

  • Adding children's nullity bitmap to StoredNodes in order to avoid reading/seeking non-existent keys from database.
  • Adding children's hashes/values to storage to batch reads.

Not included but possible next steps:

  • avoid storing null commitments/hashes.
  • explore whether storing hashes and/or uncompressed commitments versus only compressed commitments is a good trade-off between storage and compute.

Copy link

  • I thought about the changelog.

int indicator = (int) encodedValues.get(0);
Bytes values = encodedValues.slice(1);
return switch (indicator) {
case 0 -> Optional.of(createRootNode(values));
Copy link
Contributor

Choose a reason for hiding this comment

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

why not using an enum for that ?

enum NodeType {
  ROOT(0),
  INTERNAL(1),
  STEM(2),
  LEAF(3);
  
  int type;

  NodeType(final int type) {
    this.type = type;
  }

  public int getType() {
    return type;
  }
}

throw new RuntimeException("cannot persist dirty node");
}
nodeUpdater.store(location, null, leafNode.getEncodedValue());
// if (leafNode.isPersisted()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

do we need this ?

List<Bytes> values = new ArrayList<>(nChild);
for (int i = 0; i < nChild; i++) {
if (!isNull.get(i)) {
Bytes value = encoded.slice(0, 32);
Copy link
Contributor

Choose a reason for hiding this comment

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

It is possible that a value is not 32 bytes. it is therefore possible to represent it with less byte and save space

example : UInt256.valueOf(1)
0x0000000000000000000000000000000000000000000000000000000000000001

@matkt
Copy link
Contributor

matkt commented Oct 31, 2024

@thomas-quadratic can we close this one ?

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.

2 participants