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
impl EngineClient
Sourcepub fn new_http(
engine: Url,
l1_rpc: Url,
cfg: Arc<RollupConfig>,
jwt: JwtSecret,
) -> Self
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 URLcfg- Rollup configuration for version selectionjwt- JWT secret for authentication
Sourcepub const fn l2_engine(&self) -> &RootProvider<Optimism>
pub const fn l2_engine(&self) -> &RootProvider<Optimism>
Returns a reference to the inner L2 RootProvider.
Sourcepub const fn l1_provider(&self) -> &RootProvider
pub const fn l1_provider(&self) -> &RootProvider
Returns a reference to the inner L1 RootProvider.
Sourcepub fn cfg(&self) -> &RollupConfig
pub fn cfg(&self) -> &RollupConfig
Returns a reference to the inner RollupConfig.
Sourcepub async fn l2_block_by_label(
&self,
numtag: BlockNumberOrTag,
) -> Result<Option<Block<Transaction>>, EngineClientError>
pub async fn l2_block_by_label( &self, numtag: BlockNumberOrTag, ) -> Result<Option<Block<Transaction>>, EngineClientError>
Fetches the Block<T> for the given BlockNumberOrTag.
Sourcepub async fn l2_block_info_by_label(
&self,
numtag: BlockNumberOrTag,
) -> Result<Option<L2BlockInfo>, EngineClientError>
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>>§
Sourcepub async fn get_subscription<R>(
&self,
id: FixedBytes<32>,
) -> Result<Subscription<R>, RpcError<TransportErrorKind>>where
R: RpcRecv,
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.
Sourcepub fn unsubscribe(
&self,
id: FixedBytes<32>,
) -> Result<(), RpcError<TransportErrorKind>>
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
impl Clone for EngineClient
Source§fn clone(&self) -> EngineClient
fn clone(&self) -> EngineClient
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for EngineClient
impl Debug for EngineClient
Source§impl Deref for EngineClient
impl Deref for EngineClient
Source§impl OpEngineApi<Optimism, Http<HyperClient<Full<Bytes>, AuthService<Client<HttpConnector, Full<Bytes>>>>>> for EngineClient
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,
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,
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,
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,
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,
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,
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,
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,
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,
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,
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,
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,
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,
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,
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,
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,
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,
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,
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,
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,
start, containing count
blocks. Read moreSource§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,
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,
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,
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,
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,
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,
Auto Trait Implementations§
impl Freeze for EngineClient
impl !RefUnwindSafe for EngineClient
impl Send for EngineClient
impl Sync for EngineClient
impl Unpin for EngineClient
impl !UnwindSafe for EngineClient
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> 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<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