Skip to content
Draft
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
89 changes: 88 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ alloy-op-evm = { version = "0.27", default-features = false }
alloy-evm = { version = "0.27", default-features = false }

# rpc
axum = "0.8"
jsonrpsee = { version = "0.26.0", features = ["server", "client", "macros"] }
jsonrpsee-core = { version = "0.26.0" }
jsonrpsee-types = "0.26.0"
Expand All @@ -210,6 +211,7 @@ metrics = "0.24.0"
metrics-derive = "0.1"

tokio = { version = "1.44.2", features = ["full"] }
nix = { version = "0.29", features = ["fs"] }
tokio-util = "0.7.15"
tokio-stream = "0.1.17"
tokio-tungstenite = "0.28.0"
Expand Down
1 change: 1 addition & 0 deletions crates/flashblocks/node/tests/p2p.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ async fn setup_node_extended_cfg(
access_list: true,
}),
tx_peers: None,
health: Default::default(),
},
builder_config: Default::default(),
};
Expand Down
4 changes: 1 addition & 3 deletions crates/tests/sepolia/src/cli/transactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -443,8 +443,7 @@ pub async fn bundle_transactions(args: &BundleArgs) -> eyre::Result<Vec<Bytes>>
let signer = args.std_private_key.parse::<PrivateKeySigner>()?;
let sender = signer.address();
let mut txs = vec![];
let mut nonce = args.std_nonce;
for _ in 0..args.tx_batch_size {
for (nonce, _) in (args.std_nonce..).zip(0..args.tx_batch_size) {
let tx = TransactionRequest {
nonce: Some(nonce),
value: None,
Expand All @@ -461,7 +460,6 @@ pub async fn bundle_transactions(args: &BundleArgs) -> eyre::Result<Vec<Bytes>>
..Default::default()
};

nonce += 1;
txs.push(sign_transaction(tx, signer.clone()).await?)
}

Expand Down
19 changes: 17 additions & 2 deletions crates/world/bin/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
use std::net::SocketAddr;

use clap::Parser;
use eyre::config::HookBuilder;
use reth_node_builder::NodeHandle;
use reth_optimism_cli::{Cli, chainspec::OpChainSpecParser};
use reth_tracing::tracing::info;
use world_chain_node::{
FlashblocksOpApi, OpApiExtServer, args::WorldChainArgs, config::WorldChainNodeConfig,
context::FlashblocksContext, node::WorldChainNode,
context::FlashblocksContext, health::HealthConfig, node::WorldChainNode,
};
use world_chain_rpc::{EthApiExtServer, SequencerClient, WorldChainEthApiExt};

Expand Down Expand Up @@ -46,7 +48,7 @@ fn main() {
let node = WorldChainNode::<FlashblocksContext>::new(config.clone());
let NodeHandle {
node_exit_future,
node: _node,
node,
} = builder
.node(node)
.extend_rpc_modules(move |ctx| {
Expand All @@ -61,6 +63,19 @@ fn main() {
})
.launch()
.await?;

if config.args.health.enabled {
let health_addr =
SocketAddr::new(config.args.health.addr, config.args.health.port);
let health_config = match &config.args.health.config {
Some(path) => HealthConfig::from_file(path)?,
None => HealthConfig::default(),
};
let health_server =
health_config.build(health_addr, node.provider.clone(), node.network.clone());
node.task_executor.spawn(health_server.serve());
}

node_exit_future.await?;

Ok(())
Expand Down
11 changes: 11 additions & 0 deletions crates/world/node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,14 @@ alloy-signer-local.workspace = true

op-alloy-consensus.workspace = true

reth-network-api.workspace = true

axum.workspace = true
serde.workspace = true
serde_json.workspace = true
async-trait.workspace = true
nix.workspace = true
alloy-consensus.workspace = true
tokio.workspace = true
eyre.workspace = true
clap.workspace = true
Expand All @@ -59,6 +67,8 @@ world-chain-pool.workspace = true
world-chain-test.workspace = true
world-chain-node.workspace = true

reth-chainspec.workspace = true
tokio = { version = "1", features = ["test-util"] }
reth-db.workspace = true
reth-e2e-test-utils.workspace = true
reth-engine-primitives.workspace = true
Expand All @@ -68,6 +78,7 @@ reth-optimism-node = { workspace = true, features = ["test-utils"] }
revm-primitives.workspace = true
reth-basic-payload-builder.workspace = true
reth-primitives.workspace = true
reth-primitives-traits.workspace = true
reth-tracing.workspace = true
reth-network-api.workspace = true
reth-eth-wire.workspace = true
Expand Down
45 changes: 39 additions & 6 deletions crates/world/node/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ use reth_network_peers::{PeerId, TrustedPeer};
use reth_node_builder::NodeConfig;
use reth_optimism_chainspec::OpChainSpec;
use reth_optimism_node::args::RollupArgs;
use std::str::FromStr;
use tracing::{debug, info, warn};
use std::{net::{IpAddr, Ipv4Addr}, path::PathBuf, str::FromStr};
use tracing::{info, warn};

pub const DEFAULT_FLASHBLOCKS_BOOTNODES: &str = "enode://78ca7daeb63956cbc3985853d5699a6404d976a2612575563f46876968fdca2383a195ee7db40de348757b2256195996933708f351169ca3f3fe93ab2a774608@16.62.98.53:30303,enode://c96dcadf4cdea4c39ec3fd775637d9e67d455b856b1514cfcf55b72f873a34b96d69e47ccea9fc797a446d4e6948aa80f6b9d479a1727ca166758a900b08f422@16.63.14.166:30303,enode://15688a7b281c32a4da633252dcc5019d60f037ee9eb46d05093dd3023bdd688b9b207d10a39e054a5ed87db666b2cb75696f6537de74d1e1f8dcabc53dc8d2ab@16.63.123.160:30303";

Expand All @@ -38,6 +38,10 @@ pub struct WorldChainArgs {
/// Comma-separated list of peer IDs to which transactions should be propagated
#[arg(long = "tx-peers", value_delimiter = ',', value_name = "PEER_ID")]
pub tx_peers: Option<Vec<PeerId>>,

/// Health check args
#[command(flatten)]
pub health: HealthArgs,
}

impl WorldChainArgs {
Expand Down Expand Up @@ -76,10 +80,11 @@ impl WorldChainArgs {
)?);
}

if config.network.bootnodes.is_none() && self.flashblocks.is_some() {
let bootnodes = parse_trusted_peer(DEFAULT_FLASHBLOCKS_BOOTNODES)?;
debug!(target: "world_chain::network", ?bootnodes, "Setting default flashblocks bootnodes");
config.network.bootnodes = Some(bootnodes);
if let Some(bootnodes) = &mut config.network.bootnodes
&& bootnodes.is_empty()
&& self.flashblocks.is_some()
{
*bootnodes = parse_trusted_peer(DEFAULT_FLASHBLOCKS_BOOTNODES)?;
}

if self.pbh.entrypoint == Address::default() {
Expand Down Expand Up @@ -193,6 +198,33 @@ pub struct PbhArgs {
pub signature_aggregator: Address,
}

#[derive(Debug, Clone, clap::Args)]
#[command(next_help_heading = "Health")]
pub struct HealthArgs {
/// Enable the health HTTP server.
#[arg(long = "health.enabled", id = "health.enabled", required = false)]
pub enabled: bool,

/// Address for the health HTTP server.
#[arg(long = "health.addr", id = "health.addr", default_value_t = IpAddr::V4(Ipv4Addr::LOCALHOST))]
pub addr: IpAddr,

/// Port for the health HTTP server.
#[arg(long = "health.port", id = "health.port", default_value_t = 8080)]
pub port: u16,

/// Path to health check configuration file (JSON).
/// If omitted, all probes return 200 OK unconditionally.
#[arg(long = "health.config", id = "health.config", required = false)]
pub config: Option<PathBuf>,
}

impl Default for HealthArgs {
fn default() -> Self {
Self { enabled: false, addr: IpAddr::V4(Ipv4Addr::LOCALHOST), port: 8080, config: None }
}
}

/// Parameters for pbh builder configuration
#[derive(Debug, Clone, PartialEq, clap::Args)]
#[command(next_help_heading = "Block Builder")]
Expand Down Expand Up @@ -336,6 +368,7 @@ mod tests {
},
flashblocks: None,
tx_peers: Some(vec![peer_id.parse().unwrap()]),
health: HealthArgs::default(),
};

let spec = reth_optimism_chainspec::OpChainSpec::from_genesis(Genesis::default());
Expand Down
Loading
Loading