Skip to content

Commit

Permalink
WIP - Iteration over Alex's feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
EchoAlice committed Oct 10, 2023
1 parent 91b5672 commit 351bcb6
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 16 deletions.
1 change: 1 addition & 0 deletions ethereum-consensus/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ ec = [
"bip39",
"rand_core",
"rayon",
"ruint",
"hkdf",
"uuid",
"scrypt",
Expand Down
10 changes: 5 additions & 5 deletions ethereum-consensus/src/deneb/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,12 @@ pub fn get_attestation_participation_flag_indices<
source_checkpoint: data.source.clone(),
current: get_current_epoch(state, context),
},
)));
)))
}
let is_matching_target = is_matching_source
&& (data.target.root == *get_block_root(state, data.target.epoch, context)?);
let is_matching_head = is_matching_target
&& (data.beacon_block_root == *get_block_root_at_slot(state, data.slot)?);
let is_matching_target = is_matching_source &&
(data.target.root == *get_block_root(state, data.target.epoch, context)?);
let is_matching_head = is_matching_target &&
(data.beacon_block_root == *get_block_root_at_slot(state, data.slot)?);

let mut participation_flag_indices = Vec::new();
if is_matching_source && inclusion_delay <= context.slots_per_epoch.integer_sqrt() {
Expand Down
10 changes: 3 additions & 7 deletions ethereum-consensus/src/deneb/polynomial_commitments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@ use crate::{deneb::blob_sidecar::Blob, primitives::Bytes32, ssz::prelude::*};
use c_kzg::Error;
pub use c_kzg::KzgSettings;

use super::mainnet::FIELD_ELEMENTS_PER_BLOB;

pub const BYTES_PER_FIELD_ELEMENT: usize = 32;
pub const BYTES_PER_BLOB: usize = BYTES_PER_FIELD_ELEMENT * FIELD_ELEMENTS_PER_BLOB;
pub const BYTES_PER_COMMITMENT: usize = 48;
pub const BYTES_PER_PROOF: usize = 48;

Expand Down Expand Up @@ -53,8 +50,8 @@ pub fn compute_blob_kzg_proof<const BYTES_PER_BLOB: usize>(
commitment: &KzgCommitment,
kzg_settings: &KzgSettings,
) -> Result<KzgProof, Error> {
let blob = c_kzg::Blob::from_bytes(blob.as_ref()).unwrap();
let commitment = c_kzg::Bytes48::from_bytes(commitment.as_ref()).unwrap();
let blob = c_kzg::Blob::from_bytes(blob.as_ref())?;
let commitment = c_kzg::Bytes48::from_bytes(commitment.as_ref()).unwrap(); // Can leave as unwrap()

let ckzg_proof = c_kzg::KzgProof::compute_blob_kzg_proof(&blob, &commitment, kzg_settings)?;

Expand Down Expand Up @@ -84,6 +81,7 @@ pub fn verify_kzg_proof(
)
.map_err(Into::into);

// Question mark should go where we're defining res
if res? == true {
Ok(())
} else {
Expand Down Expand Up @@ -121,8 +119,6 @@ pub fn verify_blob_kzg_proof_batch<const BYTES_PER_BLOB: usize>(
let mut c_kzg_commitments = Vec::with_capacity(commitments.len());
let mut c_kzg_proofs = Vec::with_capacity(proofs.len());

// TODO: Can we assume there are *always* the same number of
// blobs, commitments and proofs? We could then use one for loop.
for blob in blobs {
let blob = c_kzg::Blob::from_bytes(blob.as_ref())?;
c_kzg_blobs.push(blob);
Expand Down
Empty file.
3 changes: 1 addition & 2 deletions ethereum-consensus/src/types/beacon_block_body.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ use crate::{
altair::{beacon_block as altair, SyncAggregate},
bellatrix::beacon_block as bellatrix,
capella::{beacon_block as capella, SignedBlsToExecutionChange},
deneb::beacon_block as deneb,
deneb::polynomial_commitments::KzgCommitment,
deneb::{beacon_block as deneb, polynomial_commitments::KzgCommitment},
phase0::{
beacon_block as phase0, Attestation, AttesterSlashing, Deposit, Eth1Data, ProposerSlashing,
SignedVoluntaryExit,
Expand Down
3 changes: 1 addition & 2 deletions ethereum-consensus/src/types/blinded_beacon_block_body.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ use crate::{
altair::SyncAggregate,
bellatrix::blinded_beacon_block as bellatrix,
capella::{blinded_beacon_block as capella, SignedBlsToExecutionChange},
deneb::blinded_beacon_block as deneb,
deneb::polynomial_commitments::KzgCommitment,
deneb::{blinded_beacon_block as deneb, polynomial_commitments::KzgCommitment},
phase0::{
Attestation, AttesterSlashing, Deposit, Eth1Data, ProposerSlashing, SignedVoluntaryExit,
},
Expand Down

0 comments on commit 351bcb6

Please sign in to comment.