mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
feat: Pseudo peer and staged sync
For simplicity, we use with_pow() + pseudo peer that connects to reth itself, so that it can support 1. StateFetcher via NetworkState 2. Block announcement (which requires with_pow()). For block announcement, another way was using ImportService like before, or calling engine_api. But for simplicitiy, for now we just publish from pseudo peer like pre-PoS, hence with_pow().
This commit is contained in:
54
src/pseudo_peer/cli.rs
Normal file
54
src/pseudo_peer/cli.rs
Normal file
@ -0,0 +1,54 @@
|
||||
use super::config::BlockSourceConfig;
|
||||
use clap::{Args, Parser};
|
||||
use reth_node_core::args::LogArgs;
|
||||
|
||||
#[derive(Debug, Clone, Args)]
|
||||
pub struct BlockSourceArgs {
|
||||
/// Block source to use for the benchmark.
|
||||
/// Example: s3://hl-mainnet-evm-blocks
|
||||
/// Example: /home/user/personal/evm-blocks
|
||||
///
|
||||
/// For S3, you can use environment variables like AWS_PROFILE, etc.
|
||||
#[arg(long)]
|
||||
block_source: Option<String>,
|
||||
|
||||
/// Shorthand of --block-source=s3://hl-mainnet-evm-blocks
|
||||
#[arg(long = "s3", default_value_t = false)]
|
||||
s3: bool,
|
||||
}
|
||||
|
||||
impl BlockSourceArgs {
|
||||
pub async fn parse(&self) -> eyre::Result<BlockSourceConfig> {
|
||||
if self.s3 {
|
||||
return Ok(BlockSourceConfig::s3_default().await);
|
||||
}
|
||||
|
||||
let Some(value) = self.block_source.as_ref() else {
|
||||
return Err(eyre::eyre!(
|
||||
"You need to specify a block source e.g., --s3 or --block-source=/path/to/blocks"
|
||||
));
|
||||
};
|
||||
|
||||
let config = if let Some(bucket) = value.strip_prefix("s3://") {
|
||||
BlockSourceConfig::s3(bucket.to_string()).await
|
||||
} else {
|
||||
BlockSourceConfig::local(value.to_string())
|
||||
};
|
||||
|
||||
Ok(config)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct PseudoPeerCommand {
|
||||
#[command(flatten)]
|
||||
pub logs: LogArgs,
|
||||
|
||||
#[command(flatten)]
|
||||
pub source: BlockSourceArgs,
|
||||
|
||||
/// Destination peer to connect to.
|
||||
/// Example: enode://412...1a@0.0.0.0:30304
|
||||
#[arg(long)]
|
||||
pub destination_peer: String,
|
||||
}
|
||||
Reference in New Issue
Block a user