[go: up one dir, main page]

Skip to content

Commit

Permalink
feat: integrate engine2 for optimism (paradigmxyz#10222)
Browse files Browse the repository at this point in the history
  • Loading branch information
fgimenez authored Aug 8, 2024
1 parent aa278bc commit d2b0ff4
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 17 deletions.
70 changes: 53 additions & 17 deletions bin/reth/src/optimism.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@

use clap::Parser;
use reth::cli::Cli;
use reth_node_optimism::{args::RollupArgs, rpc::SequencerClient, OptimismNode};
use reth_node_builder::EngineNodeLauncher;
use reth_node_optimism::{
args::RollupArgs, node::OptimismAddOns, rpc::SequencerClient, OptimismNode,
};
use reth_provider::providers::BlockchainProvider2;
use std::sync::Arc;

// We use jemalloc for performance reasons
Expand All @@ -23,22 +27,54 @@ fn main() {
}

if let Err(err) = Cli::<RollupArgs>::parse().run(|builder, rollup_args| async move {
let handle = builder
.node(OptimismNode::new(rollup_args.clone()))
.extend_rpc_modules(move |ctx| {
// register sequencer tx forwarder
if let Some(sequencer_http) = rollup_args.sequencer_http {
ctx.registry.set_eth_raw_transaction_forwarder(Arc::new(SequencerClient::new(
sequencer_http,
)));
}

Ok(())
})
.launch()
.await?;

handle.node_exit_future.await
let enable_engine2 = rollup_args.experimental;
let sequencer_http_arg = rollup_args.sequencer_http.clone();
match enable_engine2 {
true => {
let handle = builder
.with_types_and_provider::<OptimismNode, BlockchainProvider2<_>>()
.with_components(OptimismNode::components(rollup_args))
.with_add_ons::<OptimismAddOns>()
.extend_rpc_modules(move |ctx| {
// register sequencer tx forwarder
if let Some(sequencer_http) = sequencer_http_arg {
ctx.registry.set_eth_raw_transaction_forwarder(Arc::new(
SequencerClient::new(sequencer_http),
));
}

Ok(())
})
.launch_with_fn(|builder| {
let launcher = EngineNodeLauncher::new(
builder.task_executor().clone(),
builder.config().datadir(),
);
builder.launch_with(launcher)
})
.await?;

handle.node_exit_future.await
}
false => {
let handle = builder
.node(OptimismNode::new(rollup_args.clone()))
.extend_rpc_modules(move |ctx| {
// register sequencer tx forwarder
if let Some(sequencer_http) = sequencer_http_arg {
ctx.registry.set_eth_raw_transaction_forwarder(Arc::new(
SequencerClient::new(sequencer_http),
));
}

Ok(())
})
.launch()
.await?;

handle.node_exit_future.await
}
}
}) {
eprintln!("Error: {err:?}");
std::process::exit(1);
Expand Down
4 changes: 4 additions & 0 deletions crates/optimism/node/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ pub struct RollupArgs {
/// enables discovery v4 if provided
#[arg(long = "rollup.discovery.v4", default_value = "false")]
pub discovery_v4: bool,

/// Enable the engine2 experimental features on op-reth binary
#[arg(long = "engine.experimental", default_value = "false")]
pub experimental: bool,
}

#[cfg(test)]
Expand Down

0 comments on commit d2b0ff4

Please sign in to comment.