pub struct Marshaled<E, S, A, B, ES>{ /* 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 during epoch transitions, 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.
Implementations§
Trait Implementations§
Source§impl<E, S, A, B, ES> Automaton for Marshaled<E, S, A, B, ES>
impl<E, S, A, B, ES> Automaton for Marshaled<E, S, A, B, ES>
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§async fn verify(
&mut self,
context: Context<Self::Digest, S::PublicKey>,
digest: Self::Digest,
) -> Receiver<bool>
async fn verify( &mut self, context: Context<Self::Digest, S::PublicKey>, digest: Self::Digest, ) -> Receiver<bool>
Verifies a proposed block within epoch boundaries.
This method validates that:
- The block is within the current epoch (unless it’s a boundary block re-proposal)
- Re-proposals are only allowed for the last block in an epoch
- The block’s parent commitment matches the consensus context’s expected parent
- The block’s height is exactly one greater than the parent’s height
- The underlying application’s verification logic passes
Verification is spawned in a background task and returns a receiver that will contain the verification result. Valid blocks are reported to the marshal as verified.
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>
impl<E, S, A, B, ES> CertifiableAutomaton for Marshaled<E, S, A, B, ES>
Source§impl<E, S, A, B, ES> Relay for Marshaled<E, S, A, B, ES>
impl<E, S, A, B, ES> Relay for Marshaled<E, S, A, B, ES>
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
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§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
clone_to_uninit)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