Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rbuilder-inprocess receive txns from Reth #295

Draft
wants to merge 4 commits into
base: develop
Choose a base branch
from
Draft
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
26 changes: 21 additions & 5 deletions crates/reth-rbuilder/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use rbuilder::{
live_builder::{base_config::load_config_toml_and_env, cli::LiveBuilderConfig, config::Config},
telemetry,
};
use reth::rpc::builder::config::RethRpcServerConfig;
use reth::{chainspec::EthereumChainSpecParser, cli::Cli};
use reth_db_api::Database;
use reth_node_builder::{
Expand Down Expand Up @@ -83,7 +84,12 @@ fn main() {
.with_components(EthereumNode::components())
.with_add_ons(EthereumAddOns::default())
.on_rpc_started(move |ctx, _| {
spawn_rbuilder(ctx.provider().clone(), extra_args.rbuilder_config);
let ipc_path = if ctx.config().rpc.is_ipc_enabled() {
Some(PathBuf::from(ctx.config().rpc.ipc_path()))
} else {
None
};
Comment on lines +87 to +91
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you move this insde spawn_rbuilder or as a func to avoid more copy/paste?

Copy link
Contributor Author

@ferranbt ferranbt Dec 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved it to draft, it did not show the improvement I was expecting. I have to debug more.

spawn_rbuilder(ctx.provider().clone(), extra_args.rbuilder_config, ipc_path);
Ok(())
})
.launch_with_fn(|builder| {
Expand All @@ -95,7 +101,8 @@ fn main() {
builder.launch_with(launcher)
})
.await?;
handle.node_exit_future.await

handle.node_exit_future.await
}
true => {
info!(target: "reth::cli", "Running with legacy engine");
Expand All @@ -104,7 +111,13 @@ fn main() {
.with_components(EthereumNode::components())
.with_add_ons::<EthereumAddOns<_>>(Default::default())
.on_rpc_started(move |ctx, _| {
spawn_rbuilder(ctx.provider().clone(), extra_args.rbuilder_config);
let ipc_path = if ctx.config().rpc.is_ipc_enabled() {
Some(PathBuf::from(ctx.config().rpc.ipc_path()))
} else {
None
};

spawn_rbuilder(ctx.provider().clone(), extra_args.rbuilder_config, ipc_path);
Ok(())
})
.launch().await?;
Expand All @@ -121,7 +134,7 @@ fn main() {
/// Spawns a tokio rbuilder task.
///
/// Takes down the entire process if the rbuilder errors or stops.
fn spawn_rbuilder<P, DB>(provider: P, config_path: PathBuf)
fn spawn_rbuilder<P, DB>(provider: P, config_path: PathBuf, ipc_path: Option<PathBuf>)
where
DB: Database + Clone + 'static,
P: DatabaseProviderFactory<DB = DB, Provider: BlockReader>
Expand All @@ -132,7 +145,10 @@ where
{
let _handle = task::spawn(async move {
let result = async {
let config: Config = load_config_toml_and_env(config_path)?;
let mut config: Config = load_config_toml_and_env(config_path)?;
if let Some(ipc_path) = ipc_path {
config.base_config.el_node_ipc_path = ipc_path;
}

// Spawn redacted server that is safe for tdx builders to expose
telemetry::servers::redacted::spawn(
Expand Down
Loading