Skip to main content

Automaton

Trait Automaton 

Source
pub trait Automaton:
    Clone
    + Send
    + 'static {
    type Context;
    type Digest: Digest;

    // Required methods
    fn genesis(
        &mut self,
        epoch: Epoch,
    ) -> impl Future<Output = Self::Digest> + Send;
    fn propose(
        &mut self,
        context: Self::Context,
    ) -> impl Future<Output = Receiver<Self::Digest>> + Send;
    fn verify(
        &mut self,
        context: Self::Context,
        payload: Self::Digest,
    ) -> impl Future<Output = Receiver<bool>> + Send;
}
Expand description

Automaton is the interface responsible for driving the consensus forward by proposing new payloads and verifying payloads proposed by other participants.

Required Associated Types§

Source

type Context

Context is metadata provided by the consensus engine associated with a given payload.

This often includes things like the proposer, view number, the height, or the epoch.

Source

type Digest: Digest

Hash of an arbitrary payload.

Required Methods§

Source

fn genesis(&mut self, epoch: Epoch) -> impl Future<Output = Self::Digest> + Send

Payload used to initialize the consensus engine.

Source

fn propose( &mut self, context: Self::Context, ) -> impl Future<Output = Receiver<Self::Digest>> + Send

Generate a new payload for the given context.

If it is possible to generate a payload, the Digest should be returned over the provided channel. If it is not possible to generate a payload, the channel can be dropped. If construction takes too long, the consensus engine may drop the provided proposal.

Source

fn verify( &mut self, context: Self::Context, payload: Self::Digest, ) -> impl Future<Output = Receiver<bool>> + Send

Verify the payload is valid.

This request is single-shot for the given (context, payload). Once the returned channel resolves or closes, consensus treats verification as concluded and will not retry the same request.

Implementations should therefore keep the request pending while the verdict may still change. Return false only when the payload is permanently invalid for this context. For example, temporary conditions such as time skew, missing dependencies, or data that may arrive later should not conclude verification with false.

Closing the channel is also terminal for this request and should be reserved for cases where verification cannot ever produce a verdict anymore (for example, shutdown), not for temporary inability to decide.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

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,

Source§

type Digest = Commitment

Source§

type Context = Context<<Marshaled<E, A, B, C, H, Z, S, ES> as Automaton>::Digest, <<Z as Provider>::Scheme as Scheme>::PublicKey>

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,

Source§

type Digest = <B as Digestible>::Digest

Source§

type Context = Context<<Deferred<E, S, A, B, ES> as Automaton>::Digest, <S as Scheme>::PublicKey>

Source§

impl<E, S, A, B, ES> Automaton for Inline<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: Block + Clone, ES: Epocher,

Source§

type Digest = <B as Digestible>::Digest

Source§

type Context = Context<<Inline<E, S, A, B, ES> as Automaton>::Digest, <S as Scheme>::PublicKey>