Skip to main content

HostMsg

Enum HostMsg 

Source
pub enum HostMsg<Ctx: Context> {
    ConsensusReady {
        reply_to: RpcReplyPort<(Ctx::Height, HeightParams<Ctx>)>,
    },
    StartedRound {
        height: Ctx::Height,
        round: Round,
        proposer: Ctx::Address,
        role: Role,
        reply_to: RpcReplyPort<Vec<ProposedValue<Ctx>>>,
    },
    GetValue {
        height: Ctx::Height,
        round: Round,
        timeout: Duration,
        reply_to: RpcReplyPort<LocallyProposedValue<Ctx>>,
    },
    ExtendVote {
        height: Ctx::Height,
        round: Round,
        value_id: ValueId<Ctx>,
        reply_to: RpcReplyPort<Option<Ctx::Extension>>,
    },
    VerifyVoteExtension {
        height: Ctx::Height,
        round: Round,
        value_id: ValueId<Ctx>,
        extension: Ctx::Extension,
        reply_to: RpcReplyPort<Result<(), VoteExtensionError>>,
    },
    RestreamValue {
        height: Ctx::Height,
        round: Round,
        valid_round: Round,
        address: Ctx::Address,
        value_id: ValueId<Ctx>,
    },
    GetHistoryMinHeight {
        reply_to: RpcReplyPort<Ctx::Height>,
    },
    ReceivedProposalPart {
        from: PeerId,
        part: StreamMessage<Ctx::ProposalPart>,
        reply_to: RpcReplyPort<ProposedValue<Ctx>>,
    },
    Decided {
        certificate: CommitCertificate<Ctx>,
        extensions: VoteExtensions<Ctx>,
    },
    Finalized {
        certificate: CommitCertificate<Ctx>,
        extensions: VoteExtensions<Ctx>,
        evidence: MisbehaviorEvidence<Ctx>,
        reply_to: RpcReplyPort<Next<Ctx>>,
    },
    GetDecidedValues {
        range: RangeInclusive<Ctx::Height>,
        reply_to: RpcReplyPort<Vec<RawDecidedValue<Ctx>>>,
    },
    ProcessSyncedValue {
        height: Ctx::Height,
        round: Round,
        proposer: Ctx::Address,
        value_bytes: Bytes,
        reply_to: RpcReplyPort<ProposedValue<Ctx>>,
    },
}
Expand description

Messages that need to be handled by the host actor.

Variants§

§

ConsensusReady

Notifies the application that consensus is ready.

The application MUST reply with a message to instruct consensus to start at a given height.

Fields

§reply_to: RpcReplyPort<(Ctx::Height, HeightParams<Ctx>)>

Use this reply port to instruct consensus to start the first height.

§

StartedRound

Consensus has started a new round.

Fields

§height: Ctx::Height

The height at which the round started.

§round: Round

The round number that started.

§proposer: Ctx::Address

The address of the proposer for this round.

§role: Role

The role of the node in this round.

§reply_to: RpcReplyPort<Vec<ProposedValue<Ctx>>>

Use this reply port to send the undecided values that were already seen for this round. This is needed when recovering from a crash.

The application MUST reply immediately with the values it has, or with an empty vector.

§

GetValue

Request to build a local value to propose

The application MUST reply to this message with the requested value within the specified timeout duration.

Fields

§height: Ctx::Height

The height at which the value should be proposed.

§round: Round

The round in which the value should be proposed.

§timeout: Duration

The amount of time the application has to build the value.

§reply_to: RpcReplyPort<LocallyProposedValue<Ctx>>

Use this reply port to send the value that was built.

§

ExtendVote

ExtendVote allows the application to extend the pre-commit vote with arbitrary data.

When consensus is preparing to send a pre-commit vote, it first calls ExtendVote. The application then returns a blob of data called a vote extension. This data is opaque to the consensus algorithm but can contain application-specific information. The proposer of the next block will receive all vote extensions along with the commit certificate.

Fields

§height: Ctx::Height

The height at which the vote is being extended.

§round: Round

The round in which the vote is being extended.

§value_id: ValueId<Ctx>

The ID of the value that is being voted on.

§reply_to: RpcReplyPort<Option<Ctx::Extension>>

The vote extension to be added to the vote, if any.

§

VerifyVoteExtension

Verify a vote extension

If the vote extension is deemed invalid, the vote it was part of will be discarded altogether.

Fields

§height: Ctx::Height

The height for which the vote is.

§round: Round

The round for which the vote is.

§value_id: ValueId<Ctx>

The ID of the value that the vote extension is for.

§extension: Ctx::Extension

The vote extension to verify.

§reply_to: RpcReplyPort<Result<(), VoteExtensionError>>

Use this reply port to send the result of the verification.

§

RestreamValue

Requests the application to re-stream a proposal that it has already seen.

The application MUST re-publish again all the proposal parts pertaining to that value by sending [NetworkMsg::PublishProposalPart] messages through the [Channels::network] channel.

Fields

§height: Ctx::Height

The height at which the value was proposed.

§round: Round

The round in which the value was proposed.

§valid_round: Round

The round in which the value was valid.

§address: Ctx::Address

The address of the proposer of the value.

§value_id: ValueId<Ctx>

The ID of the value to restream.

§

GetHistoryMinHeight

Requests the earliest height available in the history maintained by the application.

The application MUST respond with its earliest available height.

Fields

§reply_to: RpcReplyPort<Ctx::Height>
§

ReceivedProposalPart

Notifies the application that consensus has received a proposal part over the network.

If this part completes the full proposal, the application MUST respond with the complete proposed value. Otherwise, it MUST respond with None.

Fields

§from: PeerId
§

Decided

Notifies the application that consensus has decided on a value.

This message includes a commit certificate containing the ID of the value that was decided on, the height and round at which it was decided, and the aggregated signatures of the validators that committed to it. It also includes to the vote extensions received for that height.

Fields

§certificate: CommitCertificate<Ctx>

The commit certificate containing the ID of the value that was decided on, the the height and round at which it was decided, and the aggregated signatures of the validators that committed to it.

§extensions: VoteExtensions<Ctx>

Vote extensions that were received for this height.

§

Finalized

Notifies the application that consensus has finalized a height after collecting additional precommits.

This message is sent when the target time for the height has been reached, which may include a delay between Decided and Finalized messages. During this delay, additional precommits may have been collected. The certificate may contain more signatures than the one sent in the initial Decided message.

In response to this message, the application MUST send a Next message back to consensus, instructing it to either start the next height if the application was able to commit the decided value, or to restart the current height otherwise.

If the application does not reply, consensus will stall.

Fields

§certificate: CommitCertificate<Ctx>

The commit certificate with extended signatures collected during finalization period.

§extensions: VoteExtensions<Ctx>

Vote extensions that were received for this height (including additional ones).

§evidence: MisbehaviorEvidence<Ctx>

Misbehavior evidence collected since last height was decided.

§reply_to: RpcReplyPort<Next<Ctx>>

Use this reply port to instruct consensus to start the next height.

§

GetDecidedValues

Requests a range of previously decided values from the application’s storage.

The application MUST respond with those values if available, or None otherwise.

§Important

The range is NOT checked for validity by consensus. It is the application’s responsibility to ensure that the the range is within valid bounds.

Fields

§range: RangeInclusive<Ctx::Height>

Range of decided values to retrieve

§reply_to: RpcReplyPort<Vec<RawDecidedValue<Ctx>>>

Channel for sending back the decided value

§

ProcessSyncedValue

Notifies the application that a value has been synced from the network. This may happen when the node is catching up with the network.

If a value can be decoded from the bytes provided, then the application MUST reply to this message with the decoded value. Otherwise, it MUST reply with None.

Fields

§height: Ctx::Height

Height of the synced value

§round: Round

Round of the synced value

§proposer: Ctx::Address

Address of the original proposer

§value_bytes: Bytes

Raw encoded value data

§reply_to: RpcReplyPort<ProposedValue<Ctx>>

Channel for sending back the proposed value, if successfully decoded or None if the value could not be decoded

Trait Implementations§

Source§

impl<Ctx: Context> Debug for HostMsg<Ctx>

Source§

fn fmt(&self, __f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<Ctx> !Freeze for HostMsg<Ctx>

§

impl<Ctx> !RefUnwindSafe for HostMsg<Ctx>

§

impl<Ctx> Send for HostMsg<Ctx>

§

impl<Ctx> Sync for HostMsg<Ctx>

§

impl<Ctx> Unpin for HostMsg<Ctx>
where <Ctx as Context>::Height: Unpin, <Ctx as Context>::Address: Unpin, <<Ctx as Context>::Value as Value>::Id: Unpin, <Ctx as Context>::Extension: Unpin, <Ctx as Context>::ProposalPart: Unpin, <<Ctx as Context>::SigningScheme as SigningScheme>::Signature: Unpin,

§

impl<Ctx> UnsafeUnpin for HostMsg<Ctx>

§

impl<Ctx> !UnwindSafe for HostMsg<Ctx>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Message for T
where T: Any + Send + 'static,

Source§

fn from_boxed(m: BoxedMessage) -> Result<Self, BoxedDowncastErr>

Convert a BoxedMessage to this concrete type
Source§

fn box_message(self, pid: &ActorId) -> Result<BoxedMessage, BoxedDowncastErr>

Convert this message to a BoxedMessage
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> State for T
where T: Any + Send + 'static,