Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 25 additions & 4 deletions crates/optimism/node/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ where
fn add_ons(&self) -> Self::AddOns {
Self::AddOns::builder()
.with_sequencer(self.args.sequencer.clone())
.with_sequencer_headers(self.args.sequencer_headers.clone())
.with_da_config(self.da_config.clone())
.with_enable_tx_conditional(self.args.enable_tx_conditional)
.build()
Expand Down Expand Up @@ -250,6 +251,8 @@ pub struct OpAddOns<
/// Sequencer client, configured to forward submitted transactions to sequencer of given OP
/// network.
pub sequencer_url: Option<String>,
/// Headers to use for the sequencer client requests.
pub sequencer_headers: Vec<String>,
/// Enable transaction conditionals.
enable_tx_conditional: bool,
}
Expand Down Expand Up @@ -298,7 +301,13 @@ where
self,
ctx: reth_node_api::AddOnsContext<'_, N>,
) -> eyre::Result<Self::Handle> {
let Self { rpc_add_ons, da_config, sequencer_url, enable_tx_conditional } = self;
let Self {
rpc_add_ons,
da_config,
sequencer_url,
sequencer_headers,
enable_tx_conditional,
} = self;

let builder = reth_optimism_payload_builder::OpPayloadBuilder::new(
ctx.node.pool().clone(),
Expand All @@ -314,7 +323,7 @@ where
let miner_ext = OpMinerExtApi::new(da_config);

let sequencer_client = if let Some(url) = sequencer_url {
Some(SequencerClient::new(url).await?)
Some(SequencerClient::new_with_headers(url, sequencer_headers).await?)
} else {
None
};
Expand Down Expand Up @@ -411,6 +420,8 @@ pub struct OpAddOnsBuilder<NetworkT> {
/// Sequencer client, configured to forward submitted transactions to sequencer of given OP
/// network.
sequencer_url: Option<String>,
/// Headers to use for the sequencer client requests.
sequencer_headers: Vec<String>,
/// Data availability configuration for the OP builder.
da_config: Option<OpDAConfig>,
/// Enable transaction conditionals.
Expand All @@ -423,6 +434,7 @@ impl<NetworkT> Default for OpAddOnsBuilder<NetworkT> {
fn default() -> Self {
Self {
sequencer_url: None,
sequencer_headers: Vec::new(),
da_config: None,
enable_tx_conditional: false,
_nt: PhantomData,
Expand All @@ -437,6 +449,12 @@ impl<NetworkT> OpAddOnsBuilder<NetworkT> {
self
}

/// With headers to use for the sequencer client requests.
pub fn with_sequencer_headers(mut self, sequencer_headers: Vec<String>) -> Self {
self.sequencer_headers = sequencer_headers;
self
}

/// Configure the data availability configuration for the OP builder.
pub fn with_da_config(mut self, da_config: OpDAConfig) -> Self {
self.da_config = Some(da_config);
Expand All @@ -457,16 +475,19 @@ impl<NetworkT> OpAddOnsBuilder<NetworkT> {
N: FullNodeComponents<Types: NodeTypes>,
OpEthApiBuilder<NetworkT>: EthApiBuilder<N>,
{
let Self { sequencer_url, da_config, enable_tx_conditional, .. } = self;
let Self { sequencer_url, sequencer_headers, da_config, enable_tx_conditional, .. } = self;

OpAddOns {
rpc_add_ons: RpcAddOns::new(
OpEthApiBuilder::default().with_sequencer(sequencer_url.clone()),
OpEthApiBuilder::default()
.with_sequencer(sequencer_url.clone())
.with_sequencer_headers(sequencer_headers.clone()),
OpEngineValidatorBuilder::default(),
OpEngineApiBuilder::default(),
),
da_config: da_config.unwrap_or_default(),
sequencer_url,
sequencer_headers,
enable_tx_conditional,
}
}
Expand Down
16 changes: 12 additions & 4 deletions crates/optimism/rpc/src/eth/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -314,27 +314,35 @@ pub struct OpEthApiBuilder<NetworkT = Optimism> {
/// Sequencer client, configured to forward submitted transactions to sequencer of given OP
/// network.
sequencer_url: Option<String>,
/// Headers to use for the sequencer client requests.
sequencer_headers: Vec<String>,
/// Marker for network types.
_nt: PhantomData<NetworkT>,
}

impl<NetworkT> Default for OpEthApiBuilder<NetworkT> {
fn default() -> Self {
Self { sequencer_url: None, _nt: PhantomData }
Self { sequencer_url: None, sequencer_headers: Vec::new(), _nt: PhantomData }
}
}

impl<NetworkT> OpEthApiBuilder<NetworkT> {
/// Creates a [`OpEthApiBuilder`] instance from core components.
pub const fn new() -> Self {
Self { sequencer_url: None, _nt: PhantomData }
Self { sequencer_url: None, sequencer_headers: Vec::new(), _nt: PhantomData }
}

/// With a [`SequencerClient`].
pub fn with_sequencer(mut self, sequencer_url: Option<String>) -> Self {
self.sequencer_url = sequencer_url;
self
}

/// With headers to use for the sequencer client requests.
pub fn with_sequencer_headers(mut self, sequencer_headers: Vec<String>) -> Self {
self.sequencer_headers = sequencer_headers;
self
}
}

impl<N, NetworkT> EthApiBuilder<N> for OpEthApiBuilder<NetworkT>
Expand All @@ -346,7 +354,7 @@ where
type EthApi = OpEthApi<N, NetworkT>;

async fn build_eth_api(self, ctx: EthApiCtx<'_, N>) -> eyre::Result<Self::EthApi> {
let Self { sequencer_url, .. } = self;
let Self { sequencer_url, sequencer_headers, .. } = self;
let eth_api = reth_rpc::EthApiBuilder::new(
ctx.components.provider().clone(),
ctx.components.pool().clone(),
Expand All @@ -365,7 +373,7 @@ where

let sequencer_client = if let Some(url) = sequencer_url {
Some(
SequencerClient::new(&url)
SequencerClient::new_with_headers(&url, sequencer_headers)
.await
.wrap_err_with(|| "Failed to init sequencer client with: {url}")?,
)
Expand Down
Loading