Skip to content

Commit

Permalink
chore: remove generate sidecar fn (paradigmxyz#12167)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattsse authored Oct 29, 2024
1 parent e92ecfb commit 58f24e0
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 37 deletions.
2 changes: 0 additions & 2 deletions crates/primitives/src/transaction/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ pub use error::{
};
pub use meta::TransactionMeta;
pub use pooled::{PooledTransactionsElement, PooledTransactionsElementEcRecovered};
#[cfg(all(feature = "c-kzg", any(test, feature = "arbitrary")))]
pub use sidecar::generate_blob_sidecar;
#[cfg(feature = "c-kzg")]
pub use sidecar::BlobTransactionValidationError;
pub use sidecar::{BlobTransaction, BlobTransactionSidecar};
Expand Down
37 changes: 4 additions & 33 deletions crates/primitives/src/transaction/sidecar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,35 +191,6 @@ impl BlobTransaction {
}
}

/// Generates a [`BlobTransactionSidecar`] structure containing blobs, commitments, and proofs.
#[cfg(all(feature = "c-kzg", any(test, feature = "arbitrary")))]
pub fn generate_blob_sidecar(blobs: Vec<c_kzg::Blob>) -> BlobTransactionSidecar {
use alloc::vec::Vec;
use alloy_eips::eip4844::env_settings::EnvKzgSettings;
use c_kzg::{KzgCommitment, KzgProof};

let kzg_settings = EnvKzgSettings::Default;

let commitments: Vec<c_kzg::Bytes48> = blobs
.iter()
.map(|blob| {
KzgCommitment::blob_to_kzg_commitment(&blob.clone(), kzg_settings.get()).unwrap()
})
.map(|commitment| commitment.to_bytes())
.collect();

let proofs: Vec<c_kzg::Bytes48> = blobs
.iter()
.zip(commitments.iter())
.map(|(blob, commitment)| {
KzgProof::compute_blob_kzg_proof(blob, commitment, kzg_settings.get()).unwrap()
})
.map(|proof| proof.to_bytes())
.collect();

BlobTransactionSidecar::from_kzg(blobs, commitments, proofs)
}

#[cfg(all(test, feature = "c-kzg"))]
mod tests {
use super::*;
Expand Down Expand Up @@ -251,7 +222,7 @@ mod tests {
.unwrap()];

// Generate a BlobTransactionSidecar from the blobs
let sidecar = generate_blob_sidecar(blobs);
let sidecar = BlobTransactionSidecar::try_from_blobs(blobs).unwrap();

// Assert commitment equality
assert_eq!(
Expand Down Expand Up @@ -300,7 +271,7 @@ mod tests {
}

// Generate a BlobTransactionSidecar from the blobs
let sidecar = generate_blob_sidecar(blobs.clone());
let sidecar = BlobTransactionSidecar::try_from_blobs(blobs).unwrap();

// Assert sidecar size
assert_eq!(sidecar.size(), 524672);
Expand All @@ -325,7 +296,7 @@ mod tests {
.unwrap()];

// Generate a BlobTransactionSidecar from the blobs
let sidecar = generate_blob_sidecar(blobs);
let sidecar = BlobTransactionSidecar::try_from_blobs(blobs).unwrap();

// Create a vector to store the encoded RLP
let mut encoded_rlp = Vec::new();
Expand Down Expand Up @@ -356,7 +327,7 @@ mod tests {
.unwrap()];

// Generate a BlobTransactionSidecar from the blobs
let sidecar = generate_blob_sidecar(blobs);
let sidecar = BlobTransactionSidecar::try_from_blobs(blobs).unwrap();

// Create a vector to store the encoded RLP
let mut encoded_rlp = Vec::new();
Expand Down
5 changes: 3 additions & 2 deletions crates/transaction-pool/src/pool/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1236,7 +1236,8 @@ mod tests {
validate::ValidTransaction,
BlockInfo, PoolConfig, SubPoolLimit, TransactionOrigin, TransactionValidationOutcome, U256,
};
use reth_primitives::{kzg::Blob, transaction::generate_blob_sidecar};
use alloy_eips::eip4844::BlobTransactionSidecar;
use reth_primitives::kzg::Blob;
use std::{fs, path::PathBuf};

#[test]
Expand Down Expand Up @@ -1271,7 +1272,7 @@ mod tests {
.unwrap()];

// Generate a BlobTransactionSidecar from the blobs.
let sidecar = generate_blob_sidecar(blobs);
let sidecar = BlobTransactionSidecar::try_from_blobs(blobs).unwrap();

// Create an in-memory blob store.
let blob_store = InMemoryBlobStore::default();
Expand Down

0 comments on commit 58f24e0

Please sign in to comment.