pub struct Marshaled<E, A, B, C, H, Z, S, ES>where
E: Rng + Storage + Spawner + Metrics + Clock,
A: Application<E>,
B: CertifiableBlock<Context = Context<Commitment, <Z::Scheme as CertificateScheme>::PublicKey>>,
C: CodingScheme,
H: Hasher,
Z: Provider<Scope = Epoch, Scheme: Scheme<Commitment>>,
S: Strategy,
ES: Epocher,{ /* private fields */ }Expand description
An Application adapter that handles epoch transitions and erasure coded broadcast.
This wrapper intercepts consensus operations to enforce epoch boundaries. It prevents blocks from being produced outside their valid epoch and handles the special case of re-proposing boundary blocks during epoch transitions.
Implementations§
Source§impl<E, A, B, C, H, Z, S, ES> Marshaled<E, A, B, C, H, Z, S, ES>where
E: Rng + Storage + Spawner + Metrics + Clock,
A: VerifyingApplication<E, Block = B, SigningScheme = Z::Scheme, Context = Context<Commitment, <Z::Scheme as CertificateScheme>::PublicKey>>,
B: CertifiableBlock<Context = <A as Application<E>>::Context>,
C: CodingScheme,
H: Hasher,
Z: Provider<Scope = Epoch, Scheme: Scheme<Commitment>>,
S: Strategy,
ES: Epocher,
impl<E, A, B, C, H, Z, S, ES> Marshaled<E, A, B, C, H, Z, S, ES>where
E: Rng + Storage + Spawner + Metrics + Clock,
A: VerifyingApplication<E, Block = B, SigningScheme = Z::Scheme, Context = Context<Commitment, <Z::Scheme as CertificateScheme>::PublicKey>>,
B: CertifiableBlock<Context = <A as Application<E>>::Context>,
C: CodingScheme,
H: Hasher,
Z: Provider<Scope = Epoch, Scheme: Scheme<Commitment>>,
S: Strategy,
ES: Epocher,
Sourcepub fn new(context: E, cfg: MarshaledConfig<A, B, C, H, Z, S, ES>) -> Self
pub fn new(context: E, cfg: MarshaledConfig<A, B, C, H, Z, S, ES>) -> Self
Trait Implementations§
Source§impl<E, A, B, C, H, Z, S, ES> Automaton for Marshaled<E, A, B, C, H, Z, S, ES>where
E: Rng + Storage + Spawner + Metrics + Clock,
A: VerifyingApplication<E, Block = B, SigningScheme = Z::Scheme, Context = Context<Commitment, <Z::Scheme as CertificateScheme>::PublicKey>>,
B: CertifiableBlock<Context = <A as Application<E>>::Context>,
C: CodingScheme,
H: Hasher,
Z: Provider<Scope = Epoch, Scheme: Scheme<Commitment>>,
S: Strategy,
ES: Epocher,
impl<E, A, B, C, H, Z, S, ES> Automaton for Marshaled<E, A, B, C, H, Z, S, ES>where
E: Rng + Storage + Spawner + Metrics + Clock,
A: VerifyingApplication<E, Block = B, SigningScheme = Z::Scheme, Context = Context<Commitment, <Z::Scheme as CertificateScheme>::PublicKey>>,
B: CertifiableBlock<Context = <A as Application<E>>::Context>,
C: CodingScheme,
H: Hasher,
Z: Provider<Scope = Epoch, Scheme: Scheme<Commitment>>,
S: Strategy,
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<Commitment, <Z::Scheme as CertificateScheme>::PublicKey>,
) -> Receiver<Self::Digest>
async fn propose( &mut self, consensus_context: Context<Commitment, <Z::Scheme as CertificateScheme>::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§async fn verify(
&mut self,
consensus_context: Context<Self::Digest, <Z::Scheme as CertificateScheme>::PublicKey>,
payload: Self::Digest,
) -> Receiver<bool>
async fn verify( &mut self, consensus_context: Context<Self::Digest, <Z::Scheme as CertificateScheme>::PublicKey>, payload: Self::Digest, ) -> Receiver<bool>
Verifies a received shard for a given round.
This method validates that:
- The coding configuration matches the expected configuration for the current scheme.
- The commitment’s context digest matches the consensus context (unless this is a re-proposal).
- The shard is contained within the consensus commitment.
Verification is spawned in a background task and returns a receiver that will contain the verification result. Additionally, this method kicks off deferred verification to start block verification early (hidden behind shard validity and network latency).
Source§type Digest = Commitment
type Digest = Commitment
Source§impl<E, A, B, C, H, Z, S, ES> CertifiableAutomaton for Marshaled<E, A, B, C, H, Z, S, ES>where
E: Rng + Storage + Spawner + Metrics + Clock,
A: VerifyingApplication<E, Block = B, SigningScheme = Z::Scheme, Context = Context<Commitment, <Z::Scheme as CertificateScheme>::PublicKey>>,
B: CertifiableBlock<Context = <A as Application<E>>::Context>,
C: CodingScheme,
H: Hasher,
Z: Provider<Scope = Epoch, Scheme: Scheme<Commitment>>,
S: Strategy,
ES: Epocher,
impl<E, A, B, C, H, Z, S, ES> CertifiableAutomaton for Marshaled<E, A, B, C, H, Z, S, ES>where
E: Rng + Storage + Spawner + Metrics + Clock,
A: VerifyingApplication<E, Block = B, SigningScheme = Z::Scheme, Context = Context<Commitment, <Z::Scheme as CertificateScheme>::PublicKey>>,
B: CertifiableBlock<Context = <A as Application<E>>::Context>,
C: CodingScheme,
H: Hasher,
Z: Provider<Scope = Epoch, Scheme: Scheme<Commitment>>,
S: Strategy,
ES: Epocher,
Source§impl<E, A, B, C, H, Z, S, ES> Clone for Marshaled<E, A, B, C, H, Z, S, ES>where
E: Rng + Storage + Spawner + Metrics + Clock + Clone,
A: Application<E> + Clone,
B: CertifiableBlock<Context = Context<Commitment, <Z::Scheme as CertificateScheme>::PublicKey>> + Clone,
C: CodingScheme + Clone,
H: Hasher + Clone,
Z: Provider<Scope = Epoch, Scheme: Scheme<Commitment>> + Clone,
S: Strategy + Clone,
ES: Epocher + Clone,
Z::Scheme: Clone,
impl<E, A, B, C, H, Z, S, ES> Clone for Marshaled<E, A, B, C, H, Z, S, ES>where
E: Rng + Storage + Spawner + Metrics + Clock + Clone,
A: Application<E> + Clone,
B: CertifiableBlock<Context = Context<Commitment, <Z::Scheme as CertificateScheme>::PublicKey>> + Clone,
C: CodingScheme + Clone,
H: Hasher + Clone,
Z: Provider<Scope = Epoch, Scheme: Scheme<Commitment>> + Clone,
S: Strategy + Clone,
ES: Epocher + Clone,
Z::Scheme: Clone,
Source§impl<E, A, B, C, H, Z, S, ES> Relay for Marshaled<E, A, B, C, H, Z, S, ES>where
E: Rng + Storage + Spawner + Metrics + Clock,
A: Application<E, Block = B, Context = Context<Commitment, <Z::Scheme as CertificateScheme>::PublicKey>>,
B: CertifiableBlock<Context = <A as Application<E>>::Context>,
C: CodingScheme,
H: Hasher,
Z: Provider<Scope = Epoch, Scheme: Scheme<Commitment>>,
S: Strategy,
ES: Epocher,
impl<E, A, B, C, H, Z, S, ES> Relay for Marshaled<E, A, B, C, H, Z, S, ES>where
E: Rng + Storage + Spawner + Metrics + Clock,
A: Application<E, Block = B, Context = Context<Commitment, <Z::Scheme as CertificateScheme>::PublicKey>>,
B: CertifiableBlock<Context = <A as Application<E>>::Context>,
C: CodingScheme,
H: Hasher,
Z: Provider<Scope = Epoch, Scheme: Scheme<Commitment>>,
S: Strategy,
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 digest does not match the cached block, the broadcast is skipped with a warning.
Source§type Digest = Commitment
type Digest = Commitment
Source§impl<E, A, B, C, H, Z, S, ES> Reporter for Marshaled<E, A, B, C, H, Z, S, ES>where
E: Rng + Storage + Spawner + Metrics + Clock,
A: Application<E, Block = B, Context = Context<Commitment, <Z::Scheme as CertificateScheme>::PublicKey>> + Reporter<Activity = Update<B>>,
B: CertifiableBlock<Context = <A as Application<E>>::Context>,
C: CodingScheme,
H: Hasher,
Z: Provider<Scope = Epoch, Scheme: Scheme<Commitment>>,
S: Strategy,
ES: Epocher,
impl<E, A, B, C, H, Z, S, ES> Reporter for Marshaled<E, A, B, C, H, Z, S, ES>where
E: Rng + Storage + Spawner + Metrics + Clock,
A: Application<E, Block = B, Context = Context<Commitment, <Z::Scheme as CertificateScheme>::PublicKey>> + Reporter<Activity = Update<B>>,
B: CertifiableBlock<Context = <A as Application<E>>::Context>,
C: CodingScheme,
H: Hasher,
Z: Provider<Scope = Epoch, Scheme: Scheme<Commitment>>,
S: Strategy,
ES: Epocher,
Auto Trait Implementations§
impl<E, A, B, C, H, Z, S, ES> Freeze for Marshaled<E, A, B, C, H, Z, S, ES>
impl<E, A, B, C, H, Z, S, ES> !RefUnwindSafe for Marshaled<E, A, B, C, H, Z, S, ES>
impl<E, A, B, C, H, Z, S, ES> Send for Marshaled<E, A, B, C, H, Z, S, ES>
impl<E, A, B, C, H, Z, S, ES> Sync for Marshaled<E, A, B, C, H, Z, S, ES>
impl<E, A, B, C, H, Z, S, ES> Unpin for Marshaled<E, A, B, C, H, Z, S, ES>
impl<E, A, B, C, H, Z, S, ES> UnsafeUnpin for Marshaled<E, A, B, C, H, Z, S, ES>where
<Z as Provider>::Scheme: for<'a> Sized,
E: UnsafeUnpin,
A: UnsafeUnpin,
Z: UnsafeUnpin,
ES: UnsafeUnpin,
S: UnsafeUnpin,
impl<E, A, B, C, H, Z, S, ES> !UnwindSafe for Marshaled<E, A, B, C, H, Z, S, 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