Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,10 @@ vergen-git2 = { version = "9", features = ["rustc"] }
git2 = { version = "0.20", default-features = false }

rayon = "1.11"
# BLS12-381 decoding and pairings plus PeerDAS cell checks and extension, on
# AVX-512 IFMA where the CPU has it (runtime detection, no build flags). Used by
# `ethlambda-crypto`'s `bls` and `ethlambda-state-transition`'s `beacon::kzg`.
silver_crypto_simd = "0.1.0"
rand = "0.10"
lru = "0.16"
rocksdb = "0.24"
Expand Down
4 changes: 4 additions & 0 deletions crates/blockchain/state_transition/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ rayon.workspace = true
# version and feature set ethrex uses, plus the embedded mainnet trusted setup.
c-kzg = { version = "2.1.8", features = ["ethereum_kzg_settings"] }

# `beacon::kzg`'s cell extension and cell-proof batch check, on AVX-512 IFMA
# where the CPU has it; everything else there stays on c-kzg.
silver_crypto_simd.workspace = true

# Reduction modulo the BLS field order, for the two Fiat-Shamir challenge
# functions that c-kzg does not export.
num-bigint = "0.4.6"
Expand Down
4 changes: 2 additions & 2 deletions crates/blockchain/state_transition/src/beacon/data_columns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,8 @@ pub fn get_data_column_sidecars(
let column: Vec<fulu::Cell> = cells_and_proofs
.iter()
.map(|(cells, _)| {
SszVector::try_from(cells[column_index].to_bytes().to_vec())
.expect("a c-kzg cell is BYTES_PER_CELL bytes")
SszVector::try_from(cells[column_index].to_vec())
.expect("a cell is BYTES_PER_CELL bytes")
})
.collect();
let kzg_proofs: Vec<KzgProof> = cells_and_proofs
Expand Down
17 changes: 9 additions & 8 deletions crates/blockchain/state_transition/src/beacon/fork_choice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4174,14 +4174,18 @@ fn verify_column_cells(
let cell_indices = vec![index; column.len()];
let mut cells = Vec::with_capacity(column.len());
for cell in column {
cells.push(
c_kzg::Cell::from_bytes(&cell[..])
.map_err(|_| Error::SpecAssert("len(cell) == BYTES_PER_CELL"))?,
);
cells.push(kzg_cell(cell)?);
}
kzg::verify_cell_kzg_proof_batch(commitments, &cell_indices, &cells, proofs)
}

/// A column's cell as the KZG module's [`kzg::Cell`].
fn kzg_cell(cell: &fulu::Cell) -> Result<kzg::Cell> {
cell[..]
.try_into()
.map_err(|_| Error::SpecAssert("len(cell) == BYTES_PER_CELL"))
}

/// One column's worth of input to [`verify_column_cells_batch`]: the cell
/// position every cell of the column sits at, the cells, and the commitments
/// and proofs they are checked against.
Expand Down Expand Up @@ -4210,10 +4214,7 @@ pub fn verify_column_cells_batch(columns: &[ColumnCells<'_>]) -> Result<bool> {
for column in columns {
cell_indices.extend(std::iter::repeat_n(column.index, column.column.len()));
for cell in column.column {
cells.push(
c_kzg::Cell::from_bytes(&cell[..])
.map_err(|_| Error::SpecAssert("len(cell) == BYTES_PER_CELL"))?,
);
cells.push(kzg_cell(cell)?);
}
commitments.extend_from_slice(column.commitments);
proofs.extend_from_slice(column.proofs);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ pub fn gloas_data_column_sidecars(
let mut kzg_proofs = Vec::with_capacity(blobs.len());
for (blob, cells) in per_blob_cells.iter().enumerate() {
let cell = ethlambda_types::beacon::containers::fulu::Cell::try_from(
cells[column_index].to_bytes().to_vec(),
cells[column_index].to_vec(),
)
.map_err(|_| Error::SpecAssert("len(cell) == BYTES_PER_CELL"))?;
column.push(cell);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1766,10 +1766,8 @@ mod tests {
let column: Vec<fulu::Cell> = cells
.iter()
.map(|blob_cells| {
libssz_types::SszVector::try_from(
blob_cells[index as usize].to_bytes().to_vec(),
)
.expect("exact cell size")
libssz_types::SszVector::try_from(blob_cells[index as usize].to_vec())
.expect("exact cell size")
})
.collect();
let column_proofs: Vec<KzgProof> = proofs
Expand Down
Loading
Loading