mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-31 05:07:12 +00:00
update
This commit is contained in:
@@ -3779,7 +3779,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
||||
///
|
||||
/// An error is returned if the block was unable to be imported. It may be partially imported
|
||||
/// (i.e., this function is not atomic).
|
||||
pub(crate) async fn process_availability(
|
||||
async fn process_availability(
|
||||
self: &Arc<Self>,
|
||||
slot: Slot,
|
||||
availability: AvailabilityOutcome<T::EthSpec>,
|
||||
@@ -3798,19 +3798,8 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
||||
),
|
||||
}
|
||||
}
|
||||
AvailabilityOutcome::Payload(availability) => match availability {
|
||||
PayloadAvailability::Available(available_envelope) => {
|
||||
// TODO(gloas) execution publish_fn
|
||||
publish_fn()?;
|
||||
|
||||
// Payload envelope is fully available
|
||||
self.import_available_execution_payload_envelope(available_envelope)
|
||||
.await
|
||||
.map_err(BlockError::from)
|
||||
}
|
||||
PayloadAvailability::MissingComponents(block_root) => Ok(
|
||||
AvailabilityProcessingStatus::MissingComponents(slot, block_root),
|
||||
),
|
||||
AvailabilityOutcome::Payload(_) => {
|
||||
return Err(BlockError::InternalError("Received a payload envelope availability outcome variant when a block variant was expected".to_string()))
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -322,12 +322,6 @@ pub enum BlockError {
|
||||
bid_parent_root: Hash256,
|
||||
block_parent_root: Hash256,
|
||||
},
|
||||
/// An error occurred while processing a payload envelope.
|
||||
///
|
||||
/// ## Peer scoring
|
||||
///
|
||||
/// Peer scoring depends on the inner `EnvelopeError`.
|
||||
EnvelopeError(EnvelopeError),
|
||||
}
|
||||
|
||||
/// Which specific signature(s) are invalid in a SignedBeaconBlock
|
||||
@@ -347,12 +341,6 @@ impl From<AvailabilityCheckError> for BlockError {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<EnvelopeError> for BlockError {
|
||||
fn from(e: EnvelopeError) -> Self {
|
||||
Self::EnvelopeError(e)
|
||||
}
|
||||
}
|
||||
|
||||
/// Returned when block validation failed due to some issue verifying
|
||||
/// the execution payload.
|
||||
#[derive(Debug)]
|
||||
|
||||
@@ -20,7 +20,6 @@ use types::{
|
||||
Hash256, SignedExecutionPayloadBid, SignedExecutionPayloadEnvelope, Slot,
|
||||
};
|
||||
|
||||
mod payload_envelope_cache;
|
||||
mod pending_components_cache;
|
||||
|
||||
use crate::data_column_verification::{
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
|
||||
@@ -81,7 +81,7 @@ impl<E: EthSpec> PendingComponents<E> {
|
||||
self.bid = Some(bid);
|
||||
}
|
||||
|
||||
pub fn insert_executed_paylaod_envelope(
|
||||
pub fn insert_executed_payload_envelope(
|
||||
&mut self,
|
||||
envelope: AvailabilityPendingExecutedEnvelope<E>,
|
||||
) {
|
||||
@@ -96,14 +96,6 @@ impl<E: EthSpec> PendingComponents<E> {
|
||||
self.envelope = Some(CachedPayloadEnvelope::PreExecution(envelope, import_source))
|
||||
}
|
||||
|
||||
/// Inserts an executed payload envelope into the cache.
|
||||
pub fn insert_executed_payload_envelope(
|
||||
&mut self,
|
||||
envelope: AvailabilityPendingExecutedEnvelope<E>,
|
||||
) {
|
||||
self.envelope = Some(CachedPayloadEnvelope::Executed(Box::new(envelope)))
|
||||
}
|
||||
|
||||
/// Returns the number of blobs expected by reading the bid's kzg commitments.
|
||||
/// Returns an error if the bid is not cached. This function should only be called
|
||||
/// after ensuring that the bid has been cached.
|
||||
|
||||
@@ -1,16 +1,11 @@
|
||||
use std::sync::Arc;
|
||||
use std::time::Duration;
|
||||
|
||||
use fork_choice::PayloadVerificationStatus;
|
||||
use slot_clock::SlotClock;
|
||||
use store::StoreOp;
|
||||
use tracing::{debug, error, info, info_span, instrument, warn};
|
||||
use types::{BeaconState, BlockImportSource, Hash256, Slot};
|
||||
|
||||
use super::{
|
||||
AvailableEnvelope, AvailableExecutedEnvelope, EnvelopeError, EnvelopeImportData,
|
||||
ExecutedEnvelope, gossip_verified_envelope::GossipVerifiedEnvelope,
|
||||
};
|
||||
use crate::data_availability_checker_v2::Availability as PayloadAvailability;
|
||||
use crate::{
|
||||
AvailabilityProcessingStatus, BeaconChain, BeaconChainError, BeaconChainTypes,
|
||||
NotifyExecutionLayer,
|
||||
@@ -22,6 +17,11 @@ use crate::{
|
||||
},
|
||||
validator_monitor::get_slot_delay_ms,
|
||||
};
|
||||
use fork_choice::PayloadVerificationStatus;
|
||||
use slot_clock::SlotClock;
|
||||
use store::StoreOp;
|
||||
use tracing::{debug, error, info, info_span, instrument, warn};
|
||||
use types::{BeaconState, BlockImportSource, Hash256, Slot};
|
||||
|
||||
const ENVELOPE_METRICS_CACHE_SLOT_LIMIT: u32 = 64;
|
||||
|
||||
@@ -161,6 +161,35 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
||||
}
|
||||
}
|
||||
|
||||
/// Imports a fully available payload envelope. Otherwise, returns `AvailabilityProcessingStatus::MissingComponents`
|
||||
///
|
||||
/// An error is returned if the enveope was unable to be imported. It may be partially imported
|
||||
/// (i.e., this function is not atomic).
|
||||
async fn process_payload_envelope_availability(
|
||||
self: &Arc<Self>,
|
||||
slot: Slot,
|
||||
availability: AvailabilityOutcome<T::EthSpec>,
|
||||
publish_fn: impl FnOnce() -> Result<(), EnvelopeError>,
|
||||
) -> Result<AvailabilityProcessingStatus, EnvelopeError> {
|
||||
match availability {
|
||||
AvailabilityOutcome::Block(_) => {
|
||||
return Err(EnvelopeError::InternalError("Received a block availability outcome variant when a payload envelope variant was expected".to_string()))
|
||||
}
|
||||
AvailabilityOutcome::Payload(availability) => match availability {
|
||||
PayloadAvailability::Available(available_envelope) => {
|
||||
publish_fn()?;
|
||||
|
||||
// Payload envelope is fully available
|
||||
self.import_available_execution_payload_envelope(available_envelope)
|
||||
.await
|
||||
}
|
||||
PayloadAvailability::MissingComponents(block_root) => Ok(
|
||||
AvailabilityProcessingStatus::MissingComponents(slot, block_root),
|
||||
),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
/// Checks if the payload envelope is available, and imports immediately if so, otherwise caches the envelope
|
||||
/// in the data availability checker.
|
||||
#[instrument(skip_all)]
|
||||
@@ -174,9 +203,8 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
||||
.v2()
|
||||
.put_executed_payload_envelope(envelope)?,
|
||||
);
|
||||
self.process_availability(slot, availability, || Ok(()))
|
||||
self.process_payload_envelope_availability(slot, availability, || Ok(()))
|
||||
.await
|
||||
.map_err(EnvelopeError::BlockError)
|
||||
}
|
||||
|
||||
/// Accepts a fully-verified payload envelope and awaits on its payload verification handle to
|
||||
|
||||
Reference in New Issue
Block a user