mirror of
https://github.com/sigp/lighthouse.git
synced 2026-06-18 22:49:34 +00:00
Reduce diff
This commit is contained in:
@@ -3122,6 +3122,15 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
||||
let mut blocks = filtered_chain_segment.split_off(last_index);
|
||||
std::mem::swap(&mut blocks, &mut filtered_chain_segment);
|
||||
|
||||
// Extract envelopes before passing blocks to signature verification.
|
||||
let envelopes: Vec<_> = blocks
|
||||
.iter()
|
||||
.map(|(_, block)| match block {
|
||||
RangeSyncBlock::Gloas { envelope, .. } => envelope.clone(),
|
||||
RangeSyncBlock::Base(_) => None,
|
||||
})
|
||||
.collect();
|
||||
|
||||
let chain = self.clone();
|
||||
let signature_verification_future = self.spawn_blocking_handle(
|
||||
move || signature_verify_chain_segment(blocks, &chain),
|
||||
@@ -3146,7 +3155,9 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
||||
};
|
||||
|
||||
// Import the blocks into the chain.
|
||||
for (signature_verified_block, maybe_envelope) in signature_verified_blocks {
|
||||
for (signature_verified_block, maybe_envelope) in
|
||||
signature_verified_blocks.into_iter().zip(envelopes)
|
||||
{
|
||||
let block_slot = signature_verified_block.slot();
|
||||
let block_root = signature_verified_block.block_root();
|
||||
let block = signature_verified_block.block_cloned();
|
||||
|
||||
@@ -60,7 +60,7 @@ use crate::execution_payload::{
|
||||
};
|
||||
use crate::kzg_utils::blobs_to_data_column_sidecars;
|
||||
use crate::observed_block_producers::SeenBlock;
|
||||
use crate::payload_envelope_verification::{AvailableEnvelope, EnvelopeError};
|
||||
use crate::payload_envelope_verification::EnvelopeError;
|
||||
use crate::validator_monitor::HISTORIC_EPOCHS as VALIDATOR_MONITOR_HISTORIC_EPOCHS;
|
||||
use crate::validator_pubkey_cache::ValidatorPubkeyCache;
|
||||
use crate::{
|
||||
@@ -594,17 +594,10 @@ pub(crate) fn process_block_slash_info<T: BeaconChainTypes, TErr: BlockBlobError
|
||||
/// The given `chain_segment` must contain only blocks from the same epoch, otherwise an error
|
||||
/// will be returned.
|
||||
#[instrument(skip_all)]
|
||||
#[allow(clippy::type_complexity)]
|
||||
pub fn signature_verify_chain_segment<T: BeaconChainTypes>(
|
||||
mut chain_segment: Vec<(Hash256, RangeSyncBlock<T::EthSpec>)>,
|
||||
chain: &BeaconChain<T>,
|
||||
) -> Result<
|
||||
Vec<(
|
||||
SignatureVerifiedBlock<T>,
|
||||
Option<Box<AvailableEnvelope<T::EthSpec>>>,
|
||||
)>,
|
||||
BlockError,
|
||||
> {
|
||||
) -> Result<Vec<SignatureVerifiedBlock<T>>, BlockError> {
|
||||
if chain_segment.is_empty() {
|
||||
return Ok(vec![]);
|
||||
}
|
||||
@@ -628,18 +621,11 @@ pub fn signature_verify_chain_segment<T: BeaconChainTypes>(
|
||||
|
||||
let mut available_blocks = Vec::with_capacity(chain_segment.len());
|
||||
let mut signature_verified_blocks = Vec::with_capacity(chain_segment.len());
|
||||
let mut envelopes: Vec<Option<Box<AvailableEnvelope<T::EthSpec>>>> =
|
||||
Vec::with_capacity(chain_segment.len());
|
||||
|
||||
for (block_root, block) in chain_segment {
|
||||
let consensus_context =
|
||||
ConsensusContext::new(block.slot()).set_current_block_root(block_root);
|
||||
|
||||
let envelope = match &block {
|
||||
RangeSyncBlock::Gloas { envelope, .. } => envelope.clone(),
|
||||
RangeSyncBlock::Base(_) => None,
|
||||
};
|
||||
|
||||
let available_block =
|
||||
block.into_available_block(&chain.data_availability_checker, chain.spec.clone())?;
|
||||
available_blocks.push(available_block.clone());
|
||||
@@ -649,7 +635,6 @@ pub fn signature_verify_chain_segment<T: BeaconChainTypes>(
|
||||
parent: None,
|
||||
consensus_context,
|
||||
});
|
||||
envelopes.push(envelope);
|
||||
}
|
||||
// TODO(gloas) When implementing range and backfill sync for gloas
|
||||
// we need a batch verify kzg function in the new da checker as well.
|
||||
@@ -675,10 +660,7 @@ pub fn signature_verify_chain_segment<T: BeaconChainTypes>(
|
||||
signature_verified_block.parent = Some(parent);
|
||||
}
|
||||
|
||||
Ok(signature_verified_blocks
|
||||
.into_iter()
|
||||
.zip(envelopes)
|
||||
.collect())
|
||||
Ok(signature_verified_blocks)
|
||||
}
|
||||
|
||||
/// A wrapper around a `SignedBeaconBlock` that indicates it has been approved for re-gossiping on
|
||||
|
||||
Reference in New Issue
Block a user