From 7e7fa278136e0023ee135d4dbc02b601eb5dfe03 Mon Sep 17 00:00:00 2001 From: zhiqiangxu <652732310@qq.com> Date: Mon, 18 Mar 2024 18:08:16 +0800 Subject: [PATCH 1/2] reduce scope of commitment --- .../src/data_availability_checker/availability_view.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/beacon_node/beacon_chain/src/data_availability_checker/availability_view.rs b/beacon_node/beacon_chain/src/data_availability_checker/availability_view.rs index 65093db26bd..12d2304c424 100644 --- a/beacon_node/beacon_chain/src/data_availability_checker/availability_view.rs +++ b/beacon_node/beacon_chain/src/data_availability_checker/availability_view.rs @@ -108,11 +108,10 @@ pub trait AvailabilityView { /// 1. The blob entry at the index is empty and no block exists, or /// 2. The block exists and its commitment matches the blob's commitment. fn merge_single_blob(&mut self, index: usize, blob: Self::BlobType) { - let commitment = *blob.get_commitment(); if let Some(cached_block) = self.get_cached_block() { let block_commitment_opt = cached_block.get_commitments().get(index).copied(); if let Some(block_commitment) = block_commitment_opt { - if block_commitment == commitment { + if block_commitment == *blob.get_commitment() { self.insert_blob_at_index(index, blob) } } From 72a75fa412ef13304d68e9e549e8597504f357a6 Mon Sep 17 00:00:00 2001 From: zhiqiangxu <652732310@qq.com> Date: Wed, 20 Mar 2024 10:48:47 +0800 Subject: [PATCH 2/2] avoid clone for last reference --- beacon_node/http_api/src/publish_blocks.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/beacon_node/http_api/src/publish_blocks.rs b/beacon_node/http_api/src/publish_blocks.rs index 8b85c2ac951..e3d8cdb1814 100644 --- a/beacon_node/http_api/src/publish_blocks.rs +++ b/beacon_node/http_api/src/publish_blocks.rs @@ -82,11 +82,11 @@ pub async fn publish_block { - crate::publish_pubsub_message(&sender, PubsubMessage::BeaconBlock(block.clone())) + crate::publish_pubsub_message(&sender, PubsubMessage::BeaconBlock(block)) .map_err(|_| BlockError::BeaconChainError(BeaconChainError::UnableToPublish))?; } SignedBeaconBlock::Deneb(_) => { - let mut pubsub_messages = vec![PubsubMessage::BeaconBlock(block.clone())]; + let mut pubsub_messages = vec![PubsubMessage::BeaconBlock(block)]; if let Some(blob_sidecars) = blobs_opt { for (blob_index, blob) in blob_sidecars.into_iter().enumerate() { pubsub_messages.push(PubsubMessage::BlobSidecar(Box::new((