Struct EngineClient

Source
pub struct EngineClient { /* private fields */ }
Expand description

An Engine API client that provides authenticated HTTP communication with an execution layer.

The EngineClient handles JWT authentication and manages connections to both L1 and L2 execution layers. It automatically selects the appropriate Engine API version based on the rollup configuration and block timestamps.

§Examples

use alloy_rpc_types_engine::JwtSecret;
use kona_engine::EngineClient;
use kona_genesis::RollupConfig;
use std::sync::Arc;
use url::Url;

let engine_url = Url::parse("http://localhost:8551")?;
let l1_url = Url::parse("http://localhost:8545")?;
let config = Arc::new(RollupConfig::default());
let jwt = JwtSecret::from_hex("0xabcd")?;

let client = EngineClient::new_http(engine_url, l1_url, config, jwt);

Implementations§

Source§

impl EngineClient

Source

pub fn new_http( engine: Url, l1_rpc: Url, cfg: Arc<RollupConfig>, jwt: JwtSecret, ) -> Self

Creates a new EngineClient with authenticated HTTP connections.

Sets up JWT-authenticated connections to the Engine API endpoint, along with an unauthenticated connection to the L1 chain.

§Arguments
  • engine - L2 Engine API endpoint URL (typically port 8551)
  • l1_rpc - L1 chain RPC endpoint URL
  • cfg - Rollup configuration for version selection
  • jwt - JWT secret for authentication
Source

pub const fn l2_engine(&self) -> &RootProvider<Optimism>

Returns a reference to the inner L2 RootProvider.

Source

pub const fn l1_provider(&self) -> &RootProvider

Returns a reference to the inner L1 RootProvider.

Source

pub fn cfg(&self) -> &RollupConfig

Returns a reference to the inner RollupConfig.

Source

pub async fn l2_block_by_label( &self, numtag: BlockNumberOrTag, ) -> Result<Option<Block<Transaction>>, EngineClientError>

Fetches the Block<T> for the given BlockNumberOrTag.

Source

pub async fn l2_block_info_by_label( &self, numtag: BlockNumberOrTag, ) -> Result<Option<L2BlockInfo>, EngineClientError>

Fetches the L2BlockInfo by BlockNumberOrTag.

Methods from Deref<Target = RootProvider<Optimism>>§

Source

pub async fn get_subscription<R>( &self, id: FixedBytes<32>, ) -> Result<Subscription<R>, RpcError<TransportErrorKind>>
where R: RpcRecv,

Gets the subscription corresponding to the given RPC subscription ID.

Source

pub fn unsubscribe( &self, id: FixedBytes<32>, ) -> Result<(), RpcError<TransportErrorKind>>

Unsubscribes from the subscription corresponding to the given RPC subscription ID.

Trait Implementations§

Source§

impl Clone for EngineClient

Source§

fn clone(&self) -> EngineClient

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for EngineClient

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Deref for EngineClient

Source§

type Target = RootProvider<Optimism>

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl OpEngineApi<Optimism, Http<HyperClient<Full<Bytes>, AuthService<Client<HttpConnector, Full<Bytes>>>>>> for EngineClient

Source§

fn new_payload_v2<'life0, 'async_trait>( &'life0 self, payload: ExecutionPayloadInputV2, ) -> Pin<Box<dyn Future<Output = TransportResult<PayloadStatus>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Sends the given payload to the execution layer client, as specified for the Shanghai fork. Read more
Source§

fn new_payload_v3<'life0, 'async_trait>( &'life0 self, payload: ExecutionPayloadV3, parent_beacon_block_root: B256, ) -> Pin<Box<dyn Future<Output = TransportResult<PayloadStatus>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Sends the given payload to the execution layer client, as specified for the Cancun fork. Read more
Source§

fn new_payload_v4<'life0, 'async_trait>( &'life0 self, payload: OpExecutionPayloadV4, parent_beacon_block_root: B256, ) -> Pin<Box<dyn Future<Output = TransportResult<PayloadStatus>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Sends the given payload to the execution layer client, as specified for the Prague fork. Read more
Source§

fn fork_choice_updated_v2<'life0, 'async_trait>( &'life0 self, fork_choice_state: ForkchoiceState, payload_attributes: Option<OpPayloadAttributes>, ) -> Pin<Box<dyn Future<Output = TransportResult<ForkchoiceUpdated>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Updates the execution layer client with the given fork choice, as specified for the Shanghai fork. Read more
Source§

fn fork_choice_updated_v3<'life0, 'async_trait>( &'life0 self, fork_choice_state: ForkchoiceState, payload_attributes: Option<OpPayloadAttributes>, ) -> Pin<Box<dyn Future<Output = TransportResult<ForkchoiceUpdated>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Updates the execution layer client with the given fork choice, as specified for the Cancun fork. Read more
Source§

fn get_payload_v2<'life0, 'async_trait>( &'life0 self, payload_id: PayloadId, ) -> Pin<Box<dyn Future<Output = TransportResult<ExecutionPayloadEnvelopeV2>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Retrieves an execution payload from a previously started build process, as specified for the Shanghai fork. Read more
Source§

fn get_payload_v3<'life0, 'async_trait>( &'life0 self, payload_id: PayloadId, ) -> Pin<Box<dyn Future<Output = TransportResult<OpExecutionPayloadEnvelopeV3>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Retrieves an execution payload from a previously started build process, as specified for the Cancun fork. Read more
Source§

fn get_payload_v4<'life0, 'async_trait>( &'life0 self, payload_id: PayloadId, ) -> Pin<Box<dyn Future<Output = TransportResult<OpExecutionPayloadEnvelopeV4>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Returns the most recent version of the payload that is available in the corresponding payload build process at the time of receiving this call. Read more
Source§

fn get_payload_bodies_by_hash_v1<'life0, 'async_trait>( &'life0 self, block_hashes: Vec<BlockHash>, ) -> Pin<Box<dyn Future<Output = TransportResult<ExecutionPayloadBodiesV1>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Returns the execution payload bodies by the given hash. Read more
Source§

fn get_payload_bodies_by_range_v1<'life0, 'async_trait>( &'life0 self, start: u64, count: u64, ) -> Pin<Box<dyn Future<Output = TransportResult<ExecutionPayloadBodiesV1>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Returns the execution payload bodies by the range starting at start, containing count blocks. Read more
Source§

fn get_client_version_v1<'life0, 'async_trait>( &'life0 self, client_version: ClientVersionV1, ) -> Pin<Box<dyn Future<Output = TransportResult<Vec<ClientVersionV1>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Returns the execution client version information. Read more
Source§

fn signal_superchain_v1<'life0, 'async_trait>( &'life0 self, recommended: ProtocolVersion, required: ProtocolVersion, ) -> Pin<Box<dyn Future<Output = TransportResult<ProtocolVersion>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Optional extension to the Engine API. Read more
Source§

fn exchange_capabilities<'life0, 'async_trait>( &'life0 self, capabilities: Vec<String>, ) -> Pin<Box<dyn Future<Output = TransportResult<Vec<String>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Returns the list of Engine API methods supported by the execution layer client software. Read more

Auto Trait Implementations§

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<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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit #126799)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types #44874)
The target type on which the method may be called.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> TryClone for T
where T: Clone,

Source§

fn try_clone(&self) -> Result<T, Error>

Clones self, possibly returning an error.
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> ErasedDestructor for T
where T: 'static,