pub struct Deferred<E, S, A, B, ES>where
E: Rng + Spawner + Metrics + Clock,
S: Scheme,
A: Application<E>,
B: CertifiableBlock,
ES: Epocher,{ /* private fields */ }Expand description
An Application adapter that handles epoch transitions and validates block ancestry.
This wrapper intercepts consensus operations to enforce epoch boundaries and validate block ancestry. It prevents blocks from being produced outside their valid epoch, handles the special case of re-proposing boundary blocks at epoch boundaries, and ensures all blocks have valid parent linkage and contiguous heights.
§Ancestry Validation
Applications wrapped by Deferred can rely on the following ancestry checks being
performed automatically during verification:
- Parent digest matches the consensus context’s expected parent
- Block height is exactly one greater than the parent’s height
Verifying only the immediate parent is sufficient since the parent itself must have been notarized by consensus, which guarantees it was verified and accepted by a quorum. This means the entire ancestry chain back to genesis is transitively validated.
Applications do not need to re-implement these checks in their own verification logic.
§Context Recovery
With deferred verification, validators wait for data availability (DA) and verify the context
before voting. If a validator crashes after voting but before certification, they lose their in-memory
verification task. When recovering, validators extract context from a CertifiableBlock.
This embedded context is trustworthy because the notarizing quorum (which contains at least f+1 honest validators) verified that the block’s context matched the consensus context before voting.
Implementations§
Trait Implementations§
Source§impl<E, S, A, B, ES> Automaton for Deferred<E, S, A, B, ES>where
E: Rng + Spawner + Metrics + Clock,
S: Scheme,
A: VerifyingApplication<E, Block = B, SigningScheme = S, Context = Context<B::Digest, S::PublicKey>>,
B: CertifiableBlock<Context = <A as Application<E>>::Context>,
ES: Epocher,
impl<E, S, A, B, ES> Automaton for Deferred<E, S, A, B, ES>where
E: Rng + Spawner + Metrics + Clock,
S: Scheme,
A: VerifyingApplication<E, Block = B, SigningScheme = S, Context = Context<B::Digest, S::PublicKey>>,
B: CertifiableBlock<Context = <A as Application<E>>::Context>,
ES: Epocher,
Source§async fn genesis(&mut self, epoch: Epoch) -> Self::Digest
async fn genesis(&mut self, epoch: Epoch) -> Self::Digest
Returns the genesis digest for a given epoch.
For epoch 0, this returns the application’s genesis block digest. For subsequent epochs, it returns the digest of the last block from the previous epoch, which serves as the genesis block for the new epoch.
§Panics
Panics if a non-zero epoch is requested but the previous epoch’s final block is not available in storage. This indicates a critical error in the consensus engine startup sequence, as engines must always have the genesis block before starting.
Source§async fn propose(
&mut self,
consensus_context: Context<Self::Digest, S::PublicKey>,
) -> Receiver<Self::Digest>
async fn propose( &mut self, consensus_context: Context<Self::Digest, S::PublicKey>, ) -> Receiver<Self::Digest>
Proposes a new block or re-proposes the epoch boundary block.
This method builds a new block from the underlying application unless the parent block is the last block in the current epoch. When at an epoch boundary, it re-proposes the boundary block to avoid creating blocks that would be invalidated by the epoch transition.
The proposal operation is spawned in a background task and returns a receiver that will contain the proposed block’s digest when ready. The built block is cached for later broadcasting.
Source§type Digest = <B as Digestible>::Digest
type Digest = <B as Digestible>::Digest
Source§impl<E, S, A, B, ES> CertifiableAutomaton for Deferred<E, S, A, B, ES>where
E: Rng + Spawner + Metrics + Clock,
S: Scheme,
A: VerifyingApplication<E, Block = B, SigningScheme = S, Context = Context<B::Digest, S::PublicKey>>,
B: CertifiableBlock<Context = <A as Application<E>>::Context>,
ES: Epocher,
impl<E, S, A, B, ES> CertifiableAutomaton for Deferred<E, S, A, B, ES>where
E: Rng + Spawner + Metrics + Clock,
S: Scheme,
A: VerifyingApplication<E, Block = B, SigningScheme = S, Context = Context<B::Digest, S::PublicKey>>,
B: CertifiableBlock<Context = <A as Application<E>>::Context>,
ES: Epocher,
Source§impl<E, S, A, B, ES> Relay for Deferred<E, S, A, B, ES>where
E: Rng + Spawner + Metrics + Clock,
S: Scheme,
A: Application<E, Block = B, Context = Context<B::Digest, S::PublicKey>>,
B: CertifiableBlock<Context = <A as Application<E>>::Context>,
ES: Epocher,
impl<E, S, A, B, ES> Relay for Deferred<E, S, A, B, ES>where
E: Rng + Spawner + Metrics + Clock,
S: Scheme,
A: Application<E, Block = B, Context = Context<B::Digest, S::PublicKey>>,
B: CertifiableBlock<Context = <A as Application<E>>::Context>,
ES: Epocher,
Source§async fn broadcast(&mut self, digest: Self::Digest)
async fn broadcast(&mut self, digest: Self::Digest)
Broadcasts a previously built block to the network.
This uses the cached block from the last proposal operation. If no block was built or the digest does not match the cached block, the broadcast is skipped with a warning.
Source§type Digest = <B as Digestible>::Digest
type Digest = <B as Digestible>::Digest
Source§impl<E, S, A, B, ES> Reporter for Deferred<E, S, A, B, ES>where
E: Rng + Spawner + Metrics + Clock,
S: Scheme,
A: Application<E, Block = B, Context = Context<B::Digest, S::PublicKey>> + Reporter<Activity = Update<B>>,
B: CertifiableBlock<Context = <A as Application<E>>::Context>,
ES: Epocher,
impl<E, S, A, B, ES> Reporter for Deferred<E, S, A, B, ES>where
E: Rng + Spawner + Metrics + Clock,
S: Scheme,
A: Application<E, Block = B, Context = Context<B::Digest, S::PublicKey>> + Reporter<Activity = Update<B>>,
B: CertifiableBlock<Context = <A as Application<E>>::Context>,
ES: Epocher,
Auto Trait Implementations§
impl<E, S, A, B, ES> Freeze for Deferred<E, S, A, B, ES>
impl<E, S, A, B, ES> !RefUnwindSafe for Deferred<E, S, A, B, ES>
impl<E, S, A, B, ES> Send for Deferred<E, S, A, B, ES>
impl<E, S, A, B, ES> Sync for Deferred<E, S, A, B, ES>where
A: Sync,
impl<E, S, A, B, ES> Unpin for Deferred<E, S, A, B, ES>
impl<E, S, A, B, ES> UnsafeUnpin for Deferred<E, S, A, B, ES>
impl<E, S, A, B, ES> !UnwindSafe for Deferred<E, S, A, B, ES>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<B> IntoBlock<B> for B
impl<B> IntoBlock<B> for B
Source§fn into_block(self) -> B
fn into_block(self) -> B
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more