mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-30 12:47:05 +00:00
get rid of unneded type
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use bls::Hash256;
|
||||
use slot_clock::SlotClock;
|
||||
use state_processing::{VerifySignatures, envelope_processing::verify_execution_payload_envelope};
|
||||
use std::sync::Arc;
|
||||
use types::EthSpec;
|
||||
|
||||
use crate::{
|
||||
@@ -9,15 +9,14 @@ use crate::{
|
||||
PayloadVerificationOutcome,
|
||||
block_verification::PayloadVerificationHandle,
|
||||
payload_envelope_verification::{
|
||||
EnvelopeError, EnvelopeImportData, MaybeAvailableEnvelope,
|
||||
gossip_verified_envelope::GossipVerifiedEnvelope, load_snapshot_from_state_root,
|
||||
payload_notifier::PayloadNotifier,
|
||||
EnvelopeError, MaybeAvailableEnvelope, gossip_verified_envelope::GossipVerifiedEnvelope,
|
||||
load_snapshot_from_state_root, payload_notifier::PayloadNotifier,
|
||||
},
|
||||
};
|
||||
|
||||
pub struct ExecutionPendingEnvelope<E: EthSpec> {
|
||||
pub signed_envelope: MaybeAvailableEnvelope<E>,
|
||||
pub import_data: EnvelopeImportData<E>,
|
||||
pub block_root: Hash256,
|
||||
pub payload_verification_handle: PayloadVerificationHandle,
|
||||
}
|
||||
|
||||
@@ -91,10 +90,7 @@ impl<T: BeaconChainTypes> GossipVerifiedEnvelope<T> {
|
||||
block_hash: payload.block_hash,
|
||||
envelope: signed_envelope,
|
||||
},
|
||||
import_data: EnvelopeImportData {
|
||||
block_root,
|
||||
_phantom: Default::default(),
|
||||
},
|
||||
payload_verification_handle,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -9,8 +9,8 @@ use tracing::{debug, error, info, info_span, instrument, warn};
|
||||
use types::{BlockImportSource, Hash256, SignedExecutionPayloadEnvelope, Slot};
|
||||
|
||||
use super::{
|
||||
AvailableEnvelope, AvailableExecutedEnvelope, EnvelopeError, EnvelopeImportData,
|
||||
ExecutedEnvelope, gossip_verified_envelope::GossipVerifiedEnvelope,
|
||||
AvailableEnvelope, AvailableExecutedEnvelope, EnvelopeError, ExecutedEnvelope,
|
||||
gossip_verified_envelope::GossipVerifiedEnvelope,
|
||||
};
|
||||
use crate::pending_payload_cache::Availability as PayloadAvailability;
|
||||
use crate::{
|
||||
@@ -203,7 +203,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
||||
) -> Result<ExecutedEnvelope<T::EthSpec>, EnvelopeError> {
|
||||
let ExecutionPendingEnvelope {
|
||||
signed_envelope,
|
||||
import_data,
|
||||
block_root,
|
||||
payload_verification_handle,
|
||||
} = pending_envelope;
|
||||
|
||||
@@ -217,14 +217,12 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
||||
.payload_verification_status
|
||||
.is_optimistic()
|
||||
{
|
||||
return Err(EnvelopeError::OptimisticSyncNotSupported {
|
||||
block_root: import_data.block_root,
|
||||
});
|
||||
return Err(EnvelopeError::OptimisticSyncNotSupported { block_root });
|
||||
}
|
||||
|
||||
Ok(ExecutedEnvelope::new(
|
||||
signed_envelope,
|
||||
import_data,
|
||||
block_root,
|
||||
payload_verification_outcome,
|
||||
))
|
||||
}
|
||||
@@ -236,15 +234,10 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
||||
) -> Result<AvailabilityProcessingStatus, EnvelopeError> {
|
||||
let AvailableExecutedEnvelope {
|
||||
envelope,
|
||||
import_data,
|
||||
block_root,
|
||||
payload_verification_outcome,
|
||||
} = *envelope;
|
||||
|
||||
let EnvelopeImportData {
|
||||
block_root,
|
||||
_phantom,
|
||||
} = import_data;
|
||||
|
||||
let block_root = {
|
||||
let chain = self.clone();
|
||||
self.spawn_blocking_handle(
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
//!
|
||||
//! ```
|
||||
|
||||
use std::marker::PhantomData;
|
||||
use std::sync::Arc;
|
||||
|
||||
use state_processing::{BlockProcessingError, envelope_processing::EnvelopeProcessingError};
|
||||
@@ -42,15 +41,7 @@ mod payload_notifier;
|
||||
use crate::data_availability_checker::AvailabilityCheckError;
|
||||
pub use execution_pending_envelope::ExecutionPendingEnvelope;
|
||||
|
||||
// TODO(gloas): could remove this type completely, or remove the generic
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub struct EnvelopeImportData<E: EthSpec> {
|
||||
pub block_root: Hash256,
|
||||
pub _phantom: PhantomData<E>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
#[allow(dead_code)]
|
||||
pub struct AvailableEnvelope<E: EthSpec> {
|
||||
pub execution_block_hash: ExecutionBlockHash,
|
||||
pub envelope: Arc<SignedExecutionPayloadEnvelope<E>>,
|
||||
@@ -127,14 +118,14 @@ pub enum ExecutedEnvelope<E: EthSpec> {
|
||||
impl<E: EthSpec> ExecutedEnvelope<E> {
|
||||
pub fn new(
|
||||
envelope: MaybeAvailableEnvelope<E>,
|
||||
import_data: EnvelopeImportData<E>,
|
||||
block_root: Hash256,
|
||||
payload_verification_outcome: PayloadVerificationOutcome,
|
||||
) -> Self {
|
||||
match envelope {
|
||||
MaybeAvailableEnvelope::Available(available_envelope) => {
|
||||
Self::Available(AvailableExecutedEnvelope::new(
|
||||
available_envelope,
|
||||
import_data,
|
||||
block_root,
|
||||
payload_verification_outcome,
|
||||
))
|
||||
}
|
||||
@@ -143,7 +134,7 @@ impl<E: EthSpec> ExecutedEnvelope<E> {
|
||||
envelope,
|
||||
} => Self::AvailabilityPending(AvailabilityPendingExecutedEnvelope::new(
|
||||
envelope,
|
||||
import_data,
|
||||
block_root,
|
||||
payload_verification_outcome,
|
||||
)),
|
||||
}
|
||||
@@ -155,19 +146,19 @@ impl<E: EthSpec> ExecutedEnvelope<E> {
|
||||
/// fork choice.
|
||||
pub struct AvailabilityPendingExecutedEnvelope<E: EthSpec> {
|
||||
pub envelope: Arc<SignedExecutionPayloadEnvelope<E>>,
|
||||
pub import_data: EnvelopeImportData<E>,
|
||||
pub block_root: Hash256,
|
||||
pub payload_verification_outcome: PayloadVerificationOutcome,
|
||||
}
|
||||
|
||||
impl<E: EthSpec> AvailabilityPendingExecutedEnvelope<E> {
|
||||
pub fn new(
|
||||
envelope: Arc<SignedExecutionPayloadEnvelope<E>>,
|
||||
import_data: EnvelopeImportData<E>,
|
||||
block_root: Hash256,
|
||||
payload_verification_outcome: PayloadVerificationOutcome,
|
||||
) -> Self {
|
||||
Self {
|
||||
envelope,
|
||||
import_data,
|
||||
block_root,
|
||||
payload_verification_outcome,
|
||||
}
|
||||
}
|
||||
@@ -181,19 +172,19 @@ impl<E: EthSpec> AvailabilityPendingExecutedEnvelope<E> {
|
||||
/// by an EL client **and** has all requisite blob data to be imported into fork choice.
|
||||
pub struct AvailableExecutedEnvelope<E: EthSpec> {
|
||||
pub envelope: AvailableEnvelope<E>,
|
||||
pub import_data: EnvelopeImportData<E>,
|
||||
pub block_root: Hash256,
|
||||
pub payload_verification_outcome: PayloadVerificationOutcome,
|
||||
}
|
||||
|
||||
impl<E: EthSpec> AvailableExecutedEnvelope<E> {
|
||||
pub fn new(
|
||||
envelope: AvailableEnvelope<E>,
|
||||
import_data: EnvelopeImportData<E>,
|
||||
block_root: Hash256,
|
||||
payload_verification_outcome: PayloadVerificationOutcome,
|
||||
) -> Self {
|
||||
Self {
|
||||
envelope,
|
||||
import_data,
|
||||
block_root,
|
||||
payload_verification_outcome,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,7 +99,7 @@ impl<E: EthSpec> Debug for Availability<E> {
|
||||
}
|
||||
// TODO(gloas) fix success case
|
||||
Self::Available(envelope) => {
|
||||
write!(f, "Available({:?})", envelope.import_data.block_root)
|
||||
write!(f, "Available({:?})", envelope.block_root)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -299,19 +299,11 @@ impl<T: BeaconChainTypes> PendingPayloadCache<T> {
|
||||
block_root: Hash256,
|
||||
kzg_verified_data_columns: Vec<KzgVerifiedCustodyDataColumn<T::EthSpec>>,
|
||||
) -> Result<Availability<T::EthSpec>, AvailabilityCheckError> {
|
||||
let mut kzg_verified_data_columns = kzg_verified_data_columns.into_iter().peekable();
|
||||
let Some(epoch) = kzg_verified_data_columns
|
||||
.peek()
|
||||
.map(|verified_col| verified_col.as_data_column().epoch())
|
||||
else {
|
||||
return Ok(Availability::MissingComponents(block_root));
|
||||
};
|
||||
|
||||
let pending_components = self.get_pending_components(block_root, |pending_components| {
|
||||
pending_components.merge_data_columns(kzg_verified_data_columns)
|
||||
})?;
|
||||
|
||||
let num_expected_columns = self.get_num_expected_columns(epoch);
|
||||
let num_expected_columns = self.get_num_expected_columns(pending_components.epoch());
|
||||
|
||||
pending_components.span.in_scope(|| {
|
||||
debug!(
|
||||
@@ -644,11 +636,9 @@ async fn availability_cache_maintenance_service<T: BeaconChainTypes>(
|
||||
#[cfg(test)]
|
||||
mod data_availability_checker_tests {
|
||||
use super::*;
|
||||
use std::marker::PhantomData;
|
||||
|
||||
use crate::block_verification::PayloadVerificationOutcome;
|
||||
use crate::data_column_verification::{KzgVerifiedCustodyDataColumn, KzgVerifiedDataColumn};
|
||||
use crate::payload_envelope_verification::EnvelopeImportData;
|
||||
use crate::test_utils::{
|
||||
NumBlobs, generate_data_column_indices_rand_order, generate_rand_block_and_data_columns,
|
||||
test_spec,
|
||||
@@ -664,8 +654,8 @@ mod data_availability_checker_tests {
|
||||
use store::{HotColdDB, StoreConfig, database::interface::BeaconNodeBackend};
|
||||
use tempfile::{TempDir, tempdir};
|
||||
use types::{
|
||||
ExecutionPayloadEnvelope, ExecutionPayloadGloas, ExecutionRequests, ForkName, FullPayload,
|
||||
MinimalEthSpec, SignedBeaconBlock, SignedExecutionPayloadEnvelope, Slot,
|
||||
ExecutionPayloadEnvelope, ExecutionPayloadGloas, ExecutionRequests, ForkName,
|
||||
MinimalEthSpec, SignedExecutionPayloadEnvelope, Slot,
|
||||
};
|
||||
|
||||
type E = MinimalEthSpec;
|
||||
@@ -784,10 +774,7 @@ mod data_availability_checker_tests {
|
||||
fn make_test_executed_envelope(block_root: Hash256) -> AvailabilityPendingExecutedEnvelope<E> {
|
||||
AvailabilityPendingExecutedEnvelope {
|
||||
envelope: make_test_signed_envelope(block_root),
|
||||
import_data: EnvelopeImportData {
|
||||
block_root,
|
||||
_phantom: PhantomData,
|
||||
},
|
||||
payload_verification_outcome: PayloadVerificationOutcome {
|
||||
payload_verification_status: PayloadVerificationStatus::Verified,
|
||||
},
|
||||
|
||||
@@ -110,7 +110,7 @@ impl<E: EthSpec> PendingComponents<E> {
|
||||
|
||||
let AvailabilityPendingExecutedEnvelope {
|
||||
envelope,
|
||||
import_data,
|
||||
block_root,
|
||||
payload_verification_outcome,
|
||||
} = envelope;
|
||||
|
||||
@@ -161,7 +161,7 @@ impl<E: EthSpec> PendingComponents<E> {
|
||||
|
||||
Ok(Some(AvailableExecutedEnvelope {
|
||||
envelope: available_envelope,
|
||||
import_data: import_data.clone(),
|
||||
block_root: *block_root,
|
||||
payload_verification_outcome: payload_verification_outcome.clone(),
|
||||
}))
|
||||
}
|
||||
@@ -186,7 +186,8 @@ impl<E: EthSpec> PendingComponents<E> {
|
||||
|
||||
pub fn status_str(&self, num_expected_columns: usize) -> String {
|
||||
format!(
|
||||
"data_columns {}/{}",
|
||||
"envelope {}, data_columns {}/{}",
|
||||
self.envelope.is_some(),
|
||||
self.verified_data_columns.len(),
|
||||
num_expected_columns
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user