diff --git a/crates/optimism/node/src/node.rs b/crates/optimism/node/src/node.rs index 1bb57b3652..1ab662e72d 100644 --- a/crates/optimism/node/src/node.rs +++ b/crates/optimism/node/src/node.rs @@ -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() @@ -250,6 +251,8 @@ pub struct OpAddOns< /// Sequencer client, configured to forward submitted transactions to sequencer of given OP /// network. pub sequencer_url: Option, + /// Headers to use for the sequencer client requests. + pub sequencer_headers: Vec, /// Enable transaction conditionals. enable_tx_conditional: bool, } @@ -298,7 +301,13 @@ where self, ctx: reth_node_api::AddOnsContext<'_, N>, ) -> eyre::Result { - 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(), @@ -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 }; @@ -411,6 +420,8 @@ pub struct OpAddOnsBuilder { /// Sequencer client, configured to forward submitted transactions to sequencer of given OP /// network. sequencer_url: Option, + /// Headers to use for the sequencer client requests. + sequencer_headers: Vec, /// Data availability configuration for the OP builder. da_config: Option, /// Enable transaction conditionals. @@ -423,6 +434,7 @@ impl Default for OpAddOnsBuilder { fn default() -> Self { Self { sequencer_url: None, + sequencer_headers: Vec::new(), da_config: None, enable_tx_conditional: false, _nt: PhantomData, @@ -437,6 +449,12 @@ impl OpAddOnsBuilder { self } + /// With headers to use for the sequencer client requests. + pub fn with_sequencer_headers(mut self, sequencer_headers: Vec) -> 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); @@ -457,16 +475,19 @@ impl OpAddOnsBuilder { N: FullNodeComponents, OpEthApiBuilder: EthApiBuilder, { - 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, } } diff --git a/crates/optimism/rpc/src/eth/mod.rs b/crates/optimism/rpc/src/eth/mod.rs index 9946361f72..bbd96c1503 100644 --- a/crates/optimism/rpc/src/eth/mod.rs +++ b/crates/optimism/rpc/src/eth/mod.rs @@ -314,20 +314,22 @@ pub struct OpEthApiBuilder { /// Sequencer client, configured to forward submitted transactions to sequencer of given OP /// network. sequencer_url: Option, + /// Headers to use for the sequencer client requests. + sequencer_headers: Vec, /// Marker for network types. _nt: PhantomData, } impl Default for OpEthApiBuilder { fn default() -> Self { - Self { sequencer_url: None, _nt: PhantomData } + Self { sequencer_url: None, sequencer_headers: Vec::new(), _nt: PhantomData } } } impl OpEthApiBuilder { /// 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`]. @@ -335,6 +337,12 @@ impl OpEthApiBuilder { 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) -> Self { + self.sequencer_headers = sequencer_headers; + self + } } impl EthApiBuilder for OpEthApiBuilder @@ -346,7 +354,7 @@ where type EthApi = OpEthApi; async fn build_eth_api(self, ctx: EthApiCtx<'_, N>) -> eyre::Result { - 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(), @@ -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}")?, )