pub struct Marshaled<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 Marshaled can rely on the following ancestry checks being
performed automatically during verification:
- Parent commitment 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§
Source§impl<E, S, A, B, ES> Marshaled<E, S, A, B, ES>where
E: Rng + Spawner + Metrics + Clock,
S: Scheme,
A: VerifyingApplication<E, Block = B, SigningScheme = S, Context = Context<B::Commitment, S::PublicKey>>,
B: CertifiableBlock<Context = <A as Application<E>>::Context>,
ES: Epocher,
impl<E, S, A, B, ES> Marshaled<E, S, A, B, ES>where
E: Rng + Spawner + Metrics + Clock,
S: Scheme,
A: VerifyingApplication<E, Block = B, SigningScheme = S, Context = Context<B::Commitment, S::PublicKey>>,
B: CertifiableBlock<Context = <A as Application<E>>::Context>,
ES: Epocher,
Trait Implementations§
Source§impl<E, S, A, B, ES> Automaton for Marshaled<E, S, A, B, ES>where
E: Rng + Spawner + Metrics + Clock,
S: Scheme,
A: VerifyingApplication<E, Block = B, SigningScheme = S, Context = Context<B::Commitment, S::PublicKey>>,
B: CertifiableBlock<Context = <A as Application<E>>::Context>,
ES: Epocher,
impl<E, S, A, B, ES> Automaton for Marshaled<E, S, A, B, ES>where
E: Rng + Spawner + Metrics + Clock,
S: Scheme,
A: VerifyingApplication<E, Block = B, SigningScheme = S, Context = Context<B::Commitment, 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 commitment for a given epoch.
For epoch 0, this returns the application’s genesis block commitment. For subsequent epochs, it returns the commitment 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 commitment when ready. The built block is cached for later broadcasting.
Source§type Digest = <B as Committable>::Commitment
type Digest = <B as Committable>::Commitment
Source§impl<E, S, A, B, ES> CertifiableAutomaton for Marshaled<E, S, A, B, ES>where
E: Rng + Spawner + Metrics + Clock,
S: Scheme,
A: VerifyingApplication<E, Block = B, SigningScheme = S, Context = Context<B::Commitment, S::PublicKey>>,
B: CertifiableBlock<Context = <A as Application<E>>::Context>,
ES: Epocher,
impl<E, S, A, B, ES> CertifiableAutomaton for Marshaled<E, S, A, B, ES>where
E: Rng + Spawner + Metrics + Clock,
S: Scheme,
A: VerifyingApplication<E, Block = B, SigningScheme = S, Context = Context<B::Commitment, S::PublicKey>>,
B: CertifiableBlock<Context = <A as Application<E>>::Context>,
ES: Epocher,
Source§impl<E, S, A, B, ES> Relay for Marshaled<E, S, A, B, ES>where
E: Rng + Spawner + Metrics + Clock,
S: Scheme,
A: Application<E, Block = B, Context = Context<B::Commitment, S::PublicKey>>,
B: CertifiableBlock<Context = <A as Application<E>>::Context>,
ES: Epocher,
impl<E, S, A, B, ES> Relay for Marshaled<E, S, A, B, ES>where
E: Rng + Spawner + Metrics + Clock,
S: Scheme,
A: Application<E, Block = B, Context = Context<B::Commitment, S::PublicKey>>,
B: CertifiableBlock<Context = <A as Application<E>>::Context>,
ES: Epocher,
Source§async fn broadcast(&mut self, commitment: Self::Digest)
async fn broadcast(&mut self, commitment: 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 commitment does not match the cached block, the broadcast is skipped with a warning.
Source§type Digest = <B as Committable>::Commitment
type Digest = <B as Committable>::Commitment
Source§impl<E, S, A, B, ES> Reporter for Marshaled<E, S, A, B, ES>where
E: Rng + Spawner + Metrics + Clock,
S: Scheme,
A: Application<E, Block = B, Context = Context<B::Commitment, S::PublicKey>> + Reporter<Activity = Update<B>>,
B: CertifiableBlock<Context = <A as Application<E>>::Context>,
ES: Epocher,
impl<E, S, A, B, ES> Reporter for Marshaled<E, S, A, B, ES>where
E: Rng + Spawner + Metrics + Clock,
S: Scheme,
A: Application<E, Block = B, Context = Context<B::Commitment, 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 Marshaled<E, S, A, B, ES>
impl<E, S, A, B, ES> !RefUnwindSafe for Marshaled<E, S, A, B, ES>
impl<E, S, A, B, ES> Send for Marshaled<E, S, A, B, ES>
impl<E, S, A, B, ES> Sync for Marshaled<E, S, A, B, ES>where
A: Sync,
impl<E, S, A, B, ES> Unpin for Marshaled<E, S, A, B, ES>
impl<E, S, A, B, ES> !UnwindSafe for Marshaled<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<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