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

Pack more bits into blobs #2101

Merged
merged 1 commit into from
Jan 25, 2024
Merged

Pack more bits into blobs #2101

merged 1 commit into from
Jan 25, 2024

Conversation

PlasmaPower
Copy link
Collaborator

Points into #2095

In addition to utilizing all whole bytes of each blob field element, this PR also utilizes all whole bits of each field element, increasing encoding efficiency by roughly 2.5%.

This PR also includes a test of blob encoding and decoding.

@cla-bot cla-bot bot added the s Automatically added by the CLA bot if the creator of a PR is registered as having signed the CLA. label Jan 24, 2024
Base automatically changed from 4844-batch-posting to 4844-inbox-reader January 24, 2024 22:56
Copy link
Member

@Tristan-Wilson Tristan-Wilson left a comment

Choose a reason for hiding this comment

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

LGTM

accBits -= 8
}
}
if accBits != 0 {
Copy link
Member

Choose a reason for hiding this comment

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

nice, this should never happen because 4096 is divisible by 4 and the pattern for accBits is 2, 4, 6, 0, repeat on encoding and 6, 4, 2, 0, repeat on decoding.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Exactly, though this condition (well the one on encoding) helped track down a bug before where I exited the loop early and left some bits in the accumulator

}
if accBits != 0 {
return nil, fmt.Errorf("somehow ended up with %v spare accBits", accBits)
}
}
var outputData []byte
err := rlp.Decode(bytes.NewReader(rlpData), &outputData)
Copy link
Member

Choose a reason for hiding this comment

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

we already have the 1000 byte buffer so I think it's fine, but do we need to take into account the RLP length prefix of the data in the max bytes encoded per blob?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah that's a good point, though I think we'll just fit in the 1000

@PlasmaPower PlasmaPower merged commit a931a61 into 4844-inbox-reader Jan 25, 2024
6 checks passed
@PlasmaPower PlasmaPower deleted the 4844-bit-packing branch January 25, 2024 03:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
s Automatically added by the CLA bot if the creator of a PR is registered as having signed the CLA.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants