Trait reth_payload_builder::PayloadJob

source ·
pub trait PayloadJob:
    Future<Output = Result<(), PayloadBuilderError>>
    + Send
    + Sync {
    type PayloadAttributes: PayloadBuilderAttributes + Debug;
    type ResolvePayloadFuture: Future<Output = Result<Self::BuiltPayload, PayloadBuilderError>> + Send + Sync + 'static;
    type BuiltPayload: BuiltPayload + Clone + Debug;

    // Required methods
    fn best_payload(&self) -> Result<Self::BuiltPayload, PayloadBuilderError>;
    fn payload_attributes(
        &self,
    ) -> Result<Self::PayloadAttributes, PayloadBuilderError>;
    fn resolve(&mut self) -> (Self::ResolvePayloadFuture, KeepPayloadJobAlive);
}
Expand description

A type that can build a payload.

This type is a Future that resolves when the job is done (e.g. complete, timed out) or it failed. It’s not supposed to return the best payload built when it resolves, instead PayloadJob::best_payload should be used for that.

A PayloadJob must always be prepared to return the best payload built so far to ensure there is a valid payload to deliver to the CL, so it does not miss a slot, even if the payload is empty.

Note: A PayloadJob need to be cancel safe because it might be dropped after the CL has requested the payload via engine_getPayloadV1 (see also engine API docs)

Required Associated Types§

source

type PayloadAttributes: PayloadBuilderAttributes + Debug

Represents the payload attributes type that is used to spawn this payload job.

source

type ResolvePayloadFuture: Future<Output = Result<Self::BuiltPayload, PayloadBuilderError>> + Send + Sync + 'static

Represents the future that resolves the block that’s returned to the CL.

source

type BuiltPayload: BuiltPayload + Clone + Debug

Represents the built payload type that is returned to the CL.

Required Methods§

source

fn best_payload(&self) -> Result<Self::BuiltPayload, PayloadBuilderError>

Returns the best payload that has been built so far.

Note: This is never called by the CL.

source

fn payload_attributes( &self, ) -> Result<Self::PayloadAttributes, PayloadBuilderError>

Returns the payload attributes for the payload being built.

source

fn resolve(&mut self) -> (Self::ResolvePayloadFuture, KeepPayloadJobAlive)

Called when the payload is requested by the CL.

This is invoked on engine_getPayloadV2 and engine_getPayloadV1.

The timeout for returning the payload to the CL is 1s, thus the future returned should resolve in under 1 second.

Ideally this is the best payload built so far, or an empty block without transactions, if nothing has been built yet.

According to the spec:

Client software MAY stop the corresponding build process after serving this call.

It is at the discretion of the implementer whether the build job should be kept alive or terminated.

If this returns KeepPayloadJobAlive::Yes, then the PayloadJob will be polled once more. If this returns KeepPayloadJobAlive::No then the PayloadJob will be dropped after this call.

Implementors§