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

Update branch #1

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
33 changes: 11 additions & 22 deletions 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 @@ -41,3 +41,5 @@ default-members = ["bin/reth"]
[patch.crates-io]
revm = { git = "https://github.com/bluealloy/revm" }
revm-primitives = { git = "https://github.com/bluealloy/revm" }
# patched for quantity U256 responses <https://github.com/recmo/uint/issues/224>
ruint = { git = "https://github.com/mattsse/uint", branch = "matt/skip-leading-zeros" }
3 changes: 2 additions & 1 deletion bin/reth/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ reth-transaction-pool = { path = "../../crates/transaction-pool", features = ["t
reth-consensus = { path = "../../crates/consensus" }
reth-executor = { path = "../../crates/executor" }
reth-eth-wire = { path = "../../crates/net/eth-wire" }
reth-rpc-engine-api = { path = "../../crates/rpc/rpc-engine-api" }
reth-rpc-builder = { path = "../../crates/rpc/rpc-builder" }
reth-rpc = { path = "../../crates/rpc/rpc" }
reth-rlp = { path = "../../crates/rlp" }
Expand Down Expand Up @@ -58,7 +59,7 @@ tokio = { version = "1.21", features = ["sync", "macros", "rt-multi-thread"] }
tokio-stream = "0.1"
futures = "0.3.25"
tempfile = { version = "3.3.0" }
backon = "0.2.0"
backon = "0.4"
comfy-table = "6.1.4"
crossterm = "0.25.0"
tui = "0.19.0"
Expand Down
60 changes: 46 additions & 14 deletions bin/reth/src/args/rpc_server_args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@

use crate::dirs::{JwtSecretPath, PlatformPath};
use clap::Args;
use jsonrpsee::core::Error as RpcError;
use jsonrpsee::{core::Error as RpcError, server::ServerHandle};
use reth_network_api::{NetworkInfo, Peers};
use reth_provider::{BlockProvider, HeaderProvider, StateProviderFactory};
use reth_rpc::{JwtError, JwtSecret};
use reth_rpc_builder::{
IpcServerBuilder, RethRpcModule, RpcModuleSelection, RpcServerConfig, RpcServerHandle,
ServerBuilder, TransportRpcModuleConfig, DEFAULT_HTTP_RPC_PORT, DEFAULT_IPC_ENDPOINT,
constants, IpcServerBuilder, RethRpcModule, RpcModuleSelection, RpcServerConfig,
RpcServerHandle, ServerBuilder, TransportRpcModuleConfig,
};
use reth_rpc_engine_api::EngineApiHandle;
use reth_transaction_pool::TransactionPool;
use std::{
net::{IpAddr, Ipv4Addr, SocketAddr},
Expand Down Expand Up @@ -48,7 +49,7 @@ pub struct RpcServerArgs {
#[arg(long = "ws.addr")]
pub ws_addr: Option<IpAddr>,

/// Http server port to listen on
/// Ws server port to listen on
#[arg(long = "ws.port")]
pub ws_port: Option<u16>,

Expand All @@ -64,9 +65,17 @@ pub struct RpcServerArgs {
#[arg(long)]
pub ipcpath: Option<String>,

/// Auth server address to listen on
#[arg(long = "authrpc.addr")]
pub auth_addr: Option<IpAddr>,

/// Auth server port to listen on
#[arg(long = "authrpc.port")]
pub auth_port: Option<u16>,

/// Path to a JWT secret to use for authenticated RPC endpoints
#[arg(long = "authrpc.jwtsecret", value_name = "PATH", global = true, required = false)]
authrpc_jwtsecret: Option<PlatformPath<JwtSecretPath>>,
auth_jwtsecret: Option<PlatformPath<JwtSecretPath>>,
}

impl RpcServerArgs {
Expand All @@ -81,7 +90,7 @@ impl RpcServerArgs {
/// duration of the execution, and SHOULD store the hex-encoded secret as a jwt.hex file on
/// the filesystem. This file can then be used to provision the counterpart client.
pub(crate) fn jwt_secret(&self) -> Result<JwtSecret, JwtError> {
let arg = self.authrpc_jwtsecret.as_ref();
let arg = self.auth_jwtsecret.as_ref();
let path: Option<&Path> = arg.map(|p| p.as_ref());
match path {
Some(fpath) => JwtSecret::from_file(fpath),
Expand All @@ -94,7 +103,7 @@ impl RpcServerArgs {
}

/// Convenience function for starting a rpc server with configs which extracted from cli args.
pub(crate) async fn start_server<Client, Pool, Network>(
pub(crate) async fn start_rpc_server<Client, Pool, Network>(
&self,
client: Client,
pool: Pool,
Expand All @@ -115,6 +124,27 @@ impl RpcServerArgs {
.await
}

/// Create Engine API server.
pub(crate) async fn start_auth_server<Client, Pool, Network>(
&self,
client: Client,
pool: Pool,
network: Network,
handle: EngineApiHandle,
) -> Result<ServerHandle, RpcError>
where
Client: BlockProvider + HeaderProvider + StateProviderFactory + Clone + 'static,
Pool: TransactionPool + Clone + 'static,
Network: NetworkInfo + Peers + Clone + 'static,
{
let socket_address = SocketAddr::new(
self.auth_addr.unwrap_or(IpAddr::V4(Ipv4Addr::UNSPECIFIED)),
self.auth_port.unwrap_or(constants::DEFAULT_AUTH_PORT),
);
let secret = self.jwt_secret().map_err(|err| RpcError::Custom(err.to_string()))?;
reth_rpc_builder::auth::launch(client, pool, network, handle, socket_address, secret).await
}

/// Creates the [TransportRpcModuleConfig] from cli args.
fn transport_rpc_module_config(&self) -> TransportRpcModuleConfig {
let mut config = TransportRpcModuleConfig::default();
Expand All @@ -138,7 +168,7 @@ impl RpcServerArgs {
if self.http {
let socket_address = SocketAddr::new(
self.http_addr.unwrap_or(IpAddr::V4(Ipv4Addr::UNSPECIFIED)),
self.http_port.unwrap_or(DEFAULT_HTTP_RPC_PORT),
self.http_port.unwrap_or(constants::DEFAULT_HTTP_RPC_PORT),
);
config = config
.with_http_address(socket_address)
Expand All @@ -149,15 +179,15 @@ impl RpcServerArgs {
if self.ws {
let socket_address = SocketAddr::new(
self.ws_addr.unwrap_or(IpAddr::V4(Ipv4Addr::UNSPECIFIED)),
self.ws_port.unwrap_or(DEFAULT_HTTP_RPC_PORT),
self.ws_port.unwrap_or(constants::DEFAULT_HTTP_RPC_PORT),
);
config = config.with_ws_address(socket_address).with_http(ServerBuilder::new());
}

if !self.ipcdisable {
let ipc_builder = IpcServerBuilder::default();
config = config.with_ipc(ipc_builder).with_ipc_endpoint(
self.ipcpath.as_ref().unwrap_or(&DEFAULT_IPC_ENDPOINT.to_string()),
self.ipcpath.as_ref().unwrap_or(&constants::DEFAULT_IPC_ENDPOINT.to_string()),
);
}

Expand All @@ -167,10 +197,9 @@ impl RpcServerArgs {

#[cfg(test)]
mod tests {
use std::net::SocketAddrV4;

use super::*;
use clap::Parser;
use std::net::SocketAddrV4;

/// A helper type to parse Args more easily
#[derive(Parser)]
Expand Down Expand Up @@ -227,12 +256,15 @@ mod tests {
let config = args.rpc_server_config();
assert_eq!(
config.http_address().unwrap(),
SocketAddr::V4(SocketAddrV4::new(Ipv4Addr::UNSPECIFIED, DEFAULT_HTTP_RPC_PORT))
SocketAddr::V4(SocketAddrV4::new(
Ipv4Addr::UNSPECIFIED,
constants::DEFAULT_HTTP_RPC_PORT
))
);
assert_eq!(
config.ws_address().unwrap(),
SocketAddr::V4(SocketAddrV4::new(Ipv4Addr::new(127, 0, 0, 1), 8888))
);
assert_eq!(config.ipc_endpoint().unwrap().path(), DEFAULT_IPC_ENDPOINT);
assert_eq!(config.ipc_endpoint().unwrap().path(), constants::DEFAULT_IPC_ENDPOINT);
}
}
14 changes: 14 additions & 0 deletions bin/reth/src/chain/import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,3 +173,17 @@ impl ImportCommand {
confy::load_path::<Config>(&self.config).wrap_err("Could not load config")
}
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn parse_common_import_command_chain_args() {
for chain in ["mainnet", "sepolia", "goerli"] {
let args: ImportCommand =
ImportCommand::parse_from(["reth", "--chain", chain, "--path", "."]);
assert_eq!(args.chain.chain, chain.parse().unwrap());
}
}
}
1 change: 1 addition & 0 deletions bin/reth/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ pub mod runner;
pub mod stage;
pub mod test_eth_chain;
pub mod test_vectors;
pub mod utils;
Loading