From adbaaf584a5f3fad0dc8643ec3e29cfe60082408 Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Tue, 18 Jun 2024 09:52:01 +0100 Subject: [PATCH 1/2] chore: simplify method to generate a random blob --- consensus/types/src/blob_sidecar.rs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/consensus/types/src/blob_sidecar.rs b/consensus/types/src/blob_sidecar.rs index 50530543a56..e51ceb2f61d 100644 --- a/consensus/types/src/blob_sidecar.rs +++ b/consensus/types/src/blob_sidecar.rs @@ -221,13 +221,7 @@ impl BlobSidecar { rng.fill_bytes(&mut blob_bytes); // Ensure that the blob is canonical by ensuring that // each field element contained in the blob is < BLS_MODULUS - for i in 0..FIELD_ELEMENTS_PER_BLOB { - let Some(byte) = blob_bytes.get_mut( - i.checked_mul(BYTES_PER_FIELD_ELEMENT) - .ok_or("overflow".to_string())?, - ) else { - return Err(format!("blob byte index out of bounds: {:?}", i)); - }; + for byte in blob_bytes.iter_mut().step_by(BYTES_PER_FIELD_ELEMENT) { *byte = 0; } From 7a4d83fca2249b377625d7f0c0a9fdf98809da1a Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Tue, 18 Jun 2024 09:56:28 +0100 Subject: [PATCH 2/2] chore: remove now unused import --- consensus/types/src/blob_sidecar.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/consensus/types/src/blob_sidecar.rs b/consensus/types/src/blob_sidecar.rs index e51ceb2f61d..1f60f429db5 100644 --- a/consensus/types/src/blob_sidecar.rs +++ b/consensus/types/src/blob_sidecar.rs @@ -6,10 +6,7 @@ use crate::{ use crate::{KzgProofs, SignedBeaconBlock}; use bls::Signature; use derivative::Derivative; -use kzg::{ - Blob as KzgBlob, Kzg, KzgCommitment, KzgProof, BYTES_PER_BLOB, BYTES_PER_FIELD_ELEMENT, - FIELD_ELEMENTS_PER_BLOB, -}; +use kzg::{Blob as KzgBlob, Kzg, KzgCommitment, KzgProof, BYTES_PER_BLOB, BYTES_PER_FIELD_ELEMENT}; use merkle_proof::{merkle_root_from_branch, verify_merkle_proof, MerkleTreeError}; use rand::Rng; use safe_arith::ArithError;