-
Notifications
You must be signed in to change notification settings - Fork 108
feat(l1,l2): support fusaka blobs cell_proofs #4814
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
base: main
Are you sure you want to change the base?
Changes from all commits
7375575
34713c8
5918d8f
4a86ee2
934e407
9775650
44ceffa
c46220a
9c5d320
d4b2b11
c82d7c8
2d05121
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
use std::ops::AddAssign; | ||
|
||
use crate::serde_utils; | ||
#[cfg(feature = "c-kzg")] | ||
use crate::types::Fork; | ||
use crate::types::constants::VERSIONED_HASH_VERSION_KZG; | ||
use crate::{Bytes, H256}; | ||
|
||
|
@@ -80,23 +82,34 @@ impl BlobsBundle { | |
|
||
// In the future we might want to provide a new method that calculates the commitments and proofs using the following. | ||
#[cfg(feature = "c-kzg")] | ||
pub fn create_from_blobs(blobs: &Vec<Blob>) -> Result<Self, BlobsBundleError> { | ||
pub fn create_from_blobs(blobs: &Vec<Blob>, fork: Fork) -> Result<Self, BlobsBundleError> { | ||
use ethrex_crypto::kzg::blob_to_kzg_commitment_and_proof; | ||
let mut commitments = Vec::new(); | ||
let mut proofs = Vec::new(); | ||
let c_kzg_settings = c_kzg::ethereum_kzg_settings(8); | ||
|
||
// Populate the commitments and proofs | ||
for blob in blobs { | ||
let (commitment, proof) = blob_to_kzg_commitment_and_proof(blob)?; | ||
commitments.push(commitment); | ||
proofs.push(proof); | ||
|
||
if fork <= Fork::Prague { | ||
proofs.push(proof); | ||
} else { | ||
let blob: c_kzg::Blob = (*blob).into(); | ||
let (_cells, cell_proofs) = c_kzg_settings | ||
.compute_cells_and_kzg_proofs(&blob) | ||
.map_err(|e| BlobsBundleError::Kzg(ethrex_crypto::kzg::KzgError::CKzg(e)))?; | ||
let cell_proofs = cell_proofs.map(|p| p.to_bytes().into_inner()); | ||
proofs.extend(cell_proofs); | ||
Comment on lines
+100
to
+104
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The variable '_cells' is ignored but the function computes both cells and proofs. If cells are not needed, consider using a more specific function that only computes proofs to avoid unnecessary computation. If cells might be needed in the future, add a comment explaining why they're currently ignored. Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||
} | ||
} | ||
|
||
Ok(Self { | ||
blobs: blobs.clone(), | ||
commitments, | ||
proofs, | ||
version: 0, | ||
version: if fork <= Fork::Prague { 0 } else { 1 }, | ||
}) | ||
} | ||
|
||
|
@@ -266,8 +279,9 @@ mod tests { | |
}) | ||
.collect(); | ||
|
||
let blobs_bundle = crate::types::BlobsBundle::create_from_blobs(&blobs) | ||
.expect("Failed to create blobs bundle"); | ||
let blobs_bundle = | ||
crate::types::BlobsBundle::create_from_blobs(&blobs, crate::types::Fork::Prague) | ||
.expect("Failed to create blobs bundle"); | ||
|
||
let blob_versioned_hashes = blobs_bundle.generate_versioned_hashes(); | ||
|
||
|
@@ -403,8 +417,9 @@ mod tests { | |
let blobs = | ||
std::iter::repeat_n(blob, super::MAX_BLOB_COUNT_ELECTRA + 1).collect::<Vec<_>>(); | ||
|
||
let blobs_bundle = crate::types::BlobsBundle::create_from_blobs(&blobs) | ||
.expect("Failed to create blobs bundle"); | ||
let blobs_bundle = | ||
crate::types::BlobsBundle::create_from_blobs(&blobs, crate::types::Fork::Prague) | ||
.expect("Failed to create blobs bundle"); | ||
|
||
let blob_versioned_hashes = blobs_bundle.generate_versioned_hashes(); | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.