Skip to content
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

merge queue: embarking unstable (c457a25) and #5913 together #6067

Closed
wants to merge 3 commits into from
Closed
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Simplify kzg_commitments_merkle_proof
  • Loading branch information
dapplion committed Jul 5, 2024
commit 2c6dface2200cf0c6a760556a349f4b8cdc7024a
56 changes: 7 additions & 49 deletions consensus/types/src/beacon_block_body.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,55 +230,13 @@ impl<'a, E: EthSpec, Payload: AbstractExecPayload<E>> BeaconBlockBodyRef<'a, E,
pub fn kzg_commitments_merkle_proof(
&self,
) -> Result<FixedVector<Hash256, E::KzgCommitmentsInclusionProofDepth>, Error> {
match self {
Self::Base(_) | Self::Altair(_) | Self::Bellatrix(_) | Self::Capella(_) => {
Err(Error::IncorrectStateVariant)
}
Self::Deneb(body) => {
let leaves = [
body.randao_reveal.tree_hash_root(),
body.eth1_data.tree_hash_root(),
body.graffiti.tree_hash_root(),
body.proposer_slashings.tree_hash_root(),
body.attester_slashings.tree_hash_root(),
body.attestations.tree_hash_root(),
body.deposits.tree_hash_root(),
body.voluntary_exits.tree_hash_root(),
body.sync_aggregate.tree_hash_root(),
body.execution_payload.tree_hash_root(),
body.bls_to_execution_changes.tree_hash_root(),
body.blob_kzg_commitments.tree_hash_root(),
];
let beacon_block_body_depth = leaves.len().next_power_of_two().ilog2() as usize;
let tree = MerkleTree::create(&leaves, beacon_block_body_depth);
let (_, proof) = tree
.generate_proof(BLOB_KZG_COMMITMENTS_INDEX, beacon_block_body_depth)
.map_err(Error::MerkleTreeError)?;
Ok(proof.into())
}
Self::Electra(body) => {
let leaves = [
body.randao_reveal.tree_hash_root(),
body.eth1_data.tree_hash_root(),
body.graffiti.tree_hash_root(),
body.proposer_slashings.tree_hash_root(),
body.attester_slashings.tree_hash_root(),
body.attestations.tree_hash_root(),
body.deposits.tree_hash_root(),
body.voluntary_exits.tree_hash_root(),
body.sync_aggregate.tree_hash_root(),
body.execution_payload.tree_hash_root(),
body.bls_to_execution_changes.tree_hash_root(),
body.blob_kzg_commitments.tree_hash_root(),
];
let beacon_block_body_depth = leaves.len().next_power_of_two().ilog2() as usize;
let tree = MerkleTree::create(&leaves, beacon_block_body_depth);
let (_, proof) = tree
.generate_proof(BLOB_KZG_COMMITMENTS_INDEX, beacon_block_body_depth)
.map_err(Error::MerkleTreeError)?;
Ok(proof.into())
}
}
let body_leaves = self.body_merkle_leaves();
let beacon_block_body_depth = body_leaves.len().next_power_of_two().ilog2() as usize;
let tree = MerkleTree::create(&body_leaves, beacon_block_body_depth);
let (_, proof) = tree
.generate_proof(BLOB_KZG_COMMITMENTS_INDEX, beacon_block_body_depth)
.map_err(Error::MerkleTreeError)?;
Ok(proof.into())
}

/// Return `true` if this block body has a non-zero number of blobs.
Expand Down
Loading