mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-07 00:42:42 +00:00
temp
This commit is contained in:
@@ -5,7 +5,7 @@ use state_processing::{
|
|||||||
VerifySignatures,
|
VerifySignatures,
|
||||||
envelope_processing::{VerifyStateRoot, process_execution_payload_envelope},
|
envelope_processing::{VerifyStateRoot, process_execution_payload_envelope},
|
||||||
};
|
};
|
||||||
use types::{EthSpec, SignedExecutionPayloadEnvelope};
|
use types::EthSpec;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
BeaconChain, BeaconChainError, BeaconChainTypes, NotifyExecutionLayer,
|
BeaconChain, BeaconChainError, BeaconChainTypes, NotifyExecutionLayer,
|
||||||
@@ -18,24 +18,14 @@ use crate::{
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
pub trait IntoExecutionPendingEnvelope<T: BeaconChainTypes>: Sized {
|
|
||||||
fn into_execution_pending_envelope(
|
|
||||||
self,
|
|
||||||
chain: &Arc<BeaconChain<T>>,
|
|
||||||
notify_execution_layer: NotifyExecutionLayer,
|
|
||||||
) -> Result<ExecutionPendingEnvelope<T::EthSpec>, EnvelopeError>;
|
|
||||||
|
|
||||||
fn envelope(&self) -> &Arc<SignedExecutionPayloadEnvelope<T::EthSpec>>;
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct ExecutionPendingEnvelope<E: EthSpec> {
|
pub struct ExecutionPendingEnvelope<E: EthSpec> {
|
||||||
pub signed_envelope: MaybeAvailableEnvelope<E>,
|
pub signed_envelope: MaybeAvailableEnvelope<E>,
|
||||||
pub import_data: EnvelopeImportData<E>,
|
pub import_data: EnvelopeImportData<E>,
|
||||||
pub payload_verification_handle: PayloadVerificationHandle,
|
pub payload_verification_handle: PayloadVerificationHandle,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: BeaconChainTypes> IntoExecutionPendingEnvelope<T> for GossipVerifiedEnvelope<T> {
|
impl<T: BeaconChainTypes> GossipVerifiedEnvelope<T> {
|
||||||
fn into_execution_pending_envelope(
|
pub fn into_execution_pending_envelope(
|
||||||
self,
|
self,
|
||||||
chain: &Arc<BeaconChain<T>>,
|
chain: &Arc<BeaconChain<T>>,
|
||||||
notify_execution_layer: NotifyExecutionLayer,
|
notify_execution_layer: NotifyExecutionLayer,
|
||||||
@@ -68,8 +58,6 @@ impl<T: BeaconChainTypes> IntoExecutionPendingEnvelope<T> for GossipVerifiedEnve
|
|||||||
let payload_verification_status = payload_notifier.notify_new_payload().await?;
|
let payload_verification_status = payload_notifier.notify_new_payload().await?;
|
||||||
Ok(PayloadVerificationOutcome {
|
Ok(PayloadVerificationOutcome {
|
||||||
payload_verification_status,
|
payload_verification_status,
|
||||||
// This fork is after the merge so it'll never be the merge transition block
|
|
||||||
is_valid_merge_transition_block: false,
|
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
// Spawn the payload verification future as a new task, but don't wait for it to complete.
|
// Spawn the payload verification future as a new task, but don't wait for it to complete.
|
||||||
@@ -118,25 +106,4 @@ impl<T: BeaconChainTypes> IntoExecutionPendingEnvelope<T> for GossipVerifiedEnve
|
|||||||
payload_verification_handle,
|
payload_verification_handle,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn envelope(&self) -> &Arc<SignedExecutionPayloadEnvelope<T::EthSpec>> {
|
|
||||||
&self.signed_envelope
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<T: BeaconChainTypes> IntoExecutionPendingEnvelope<T>
|
|
||||||
for Arc<SignedExecutionPayloadEnvelope<T::EthSpec>>
|
|
||||||
{
|
|
||||||
fn into_execution_pending_envelope(
|
|
||||||
self,
|
|
||||||
chain: &Arc<BeaconChain<T>>,
|
|
||||||
notify_execution_layer: NotifyExecutionLayer,
|
|
||||||
) -> Result<ExecutionPendingEnvelope<T::EthSpec>, EnvelopeError> {
|
|
||||||
GossipVerifiedEnvelope::new(self, &chain.gossip_verification_context())?
|
|
||||||
.into_execution_pending_envelope(chain, notify_execution_layer)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn envelope(&self) -> &Arc<SignedExecutionPayloadEnvelope<T::EthSpec>> {
|
|
||||||
self
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ use types::{BeaconState, BlockImportSource, Hash256, SignedBeaconBlock, Slot};
|
|||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
AvailableEnvelope, AvailableExecutedEnvelope, EnvelopeError, EnvelopeImportData,
|
AvailableEnvelope, AvailableExecutedEnvelope, EnvelopeError, EnvelopeImportData,
|
||||||
ExecutedEnvelope, IntoExecutionPendingEnvelope,
|
ExecutedEnvelope, gossip_verified_envelope::GossipVerifiedEnvelope,
|
||||||
};
|
};
|
||||||
use crate::{
|
use crate::{
|
||||||
AvailabilityProcessingStatus, BeaconChain, BeaconChainError, BeaconChainTypes,
|
AvailabilityProcessingStatus, BeaconChain, BeaconChainError, BeaconChainTypes,
|
||||||
@@ -25,25 +25,20 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
|||||||
/// Returns `Ok(block_root)` if the given `unverified_envelope` was successfully verified and
|
/// Returns `Ok(block_root)` if the given `unverified_envelope` was successfully verified and
|
||||||
/// imported into the chain.
|
/// imported into the chain.
|
||||||
///
|
///
|
||||||
/// Items that implement `IntoExecutionPendingEnvelope` include:
|
|
||||||
///
|
|
||||||
/// - `GossipVerifiedEnvelope`
|
|
||||||
/// - TODO(gloas) implement for envelopes recieved over RPC
|
|
||||||
///
|
|
||||||
/// ## Errors
|
/// ## Errors
|
||||||
///
|
///
|
||||||
/// Returns an `Err` if the given block was invalid, or an error was encountered during
|
/// Returns an `Err` if the given block was invalid, or an error was encountered during
|
||||||
/// verification.
|
/// verification.
|
||||||
#[instrument(skip_all, fields(block_root = ?block_root, block_source = %block_source))]
|
#[instrument(skip_all, fields(block_root = ?block_root, block_source = %block_source))]
|
||||||
pub async fn process_execution_payload_envelope<P: IntoExecutionPendingEnvelope<T>>(
|
pub async fn process_execution_payload_envelope(
|
||||||
self: &Arc<Self>,
|
self: &Arc<Self>,
|
||||||
block_root: Hash256,
|
block_root: Hash256,
|
||||||
unverified_envelope: P,
|
unverified_envelope: GossipVerifiedEnvelope<T>,
|
||||||
notify_execution_layer: NotifyExecutionLayer,
|
notify_execution_layer: NotifyExecutionLayer,
|
||||||
block_source: BlockImportSource,
|
block_source: BlockImportSource,
|
||||||
publish_fn: impl FnOnce() -> Result<(), EnvelopeError>,
|
publish_fn: impl FnOnce() -> Result<(), EnvelopeError>,
|
||||||
) -> Result<AvailabilityProcessingStatus, EnvelopeError> {
|
) -> Result<AvailabilityProcessingStatus, EnvelopeError> {
|
||||||
let block_slot = unverified_envelope.envelope().slot();
|
let block_slot = unverified_envelope.signed_envelope.slot();
|
||||||
|
|
||||||
// Set observed time if not already set. Usually this should be set by gossip or RPC,
|
// Set observed time if not already set. Usually this should be set by gossip or RPC,
|
||||||
// but just in case we set it again here (useful for tests).
|
// but just in case we set it again here (useful for tests).
|
||||||
|
|||||||
@@ -3,27 +3,18 @@
|
|||||||
//! types, starting at a `SignedExecutionPayloadEnvelope` and finishing with an `AvailableExecutedEnvelope` (see
|
//! types, starting at a `SignedExecutionPayloadEnvelope` and finishing with an `AvailableExecutedEnvelope` (see
|
||||||
//! diagram below).
|
//! diagram below).
|
||||||
//!
|
//!
|
||||||
//! // TODO(gloas) we might want to update this diagram to include `AvailabelExecutedEnvelope`
|
|
||||||
//! ```ignore
|
//! ```ignore
|
||||||
//! START
|
|
||||||
//! |
|
|
||||||
//! ▼
|
|
||||||
//! SignedExecutionPayloadEnvelope
|
//! SignedExecutionPayloadEnvelope
|
||||||
//! |
|
//! |
|
||||||
//! |---------------
|
//! ▼
|
||||||
//! | |
|
//! GossipVerifiedEnvelope
|
||||||
//! | ▼
|
|
||||||
//! | GossipVerifiedEnvelope
|
|
||||||
//! | |
|
|
||||||
//! |---------------
|
|
||||||
//! |
|
//! |
|
||||||
//! ▼
|
//! ▼
|
||||||
//! ExecutionPendingEnvelope
|
//! ExecutionPendingEnvelope
|
||||||
//! |
|
//! |
|
||||||
//! await
|
//! await
|
||||||
//! |
|
|
||||||
//! ▼
|
//! ▼
|
||||||
//! END
|
//! ExecutedEnvelope
|
||||||
//!
|
//!
|
||||||
//! ```
|
//! ```
|
||||||
|
|
||||||
@@ -48,7 +39,7 @@ pub mod gossip_verified_envelope;
|
|||||||
pub mod import;
|
pub mod import;
|
||||||
mod payload_notifier;
|
mod payload_notifier;
|
||||||
|
|
||||||
pub use execution_pending_envelope::{ExecutionPendingEnvelope, IntoExecutionPendingEnvelope};
|
pub use execution_pending_envelope::ExecutionPendingEnvelope;
|
||||||
|
|
||||||
#[derive(PartialEq)]
|
#[derive(PartialEq)]
|
||||||
pub struct EnvelopeImportData<E: EthSpec> {
|
pub struct EnvelopeImportData<E: EthSpec> {
|
||||||
|
|||||||
Reference in New Issue
Block a user