mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 02:49:55 +00:00
feat: Add --hl-node-compliant
This commit is contained in:
11
src/main.rs
11
src/main.rs
@ -2,6 +2,7 @@ use clap::Parser;
|
||||
use reth::builder::NodeHandle;
|
||||
use reth_hl::{
|
||||
chainspec::parser::HlChainSpecParser,
|
||||
hl_node_compliance::install_hl_node_compliance,
|
||||
node::{
|
||||
cli::{Cli, HlNodeArgs},
|
||||
storage::tables::Tables,
|
||||
@ -26,10 +27,11 @@ fn main() -> eyre::Result<()> {
|
||||
|
||||
Cli::<HlChainSpecParser, HlNodeArgs>::parse().run(|builder, ext| async move {
|
||||
builder.builder.database.create_tables_for::<Tables>()?;
|
||||
let (node, engine_handle_tx) = HlNode::new(ext.block_source_args.parse().await?);
|
||||
let (node, engine_handle_tx) =
|
||||
HlNode::new(ext.block_source_args.parse().await?, ext.hl_node_compliant);
|
||||
let NodeHandle { node, node_exit_future: exit_future } = builder
|
||||
.node(node)
|
||||
.extend_rpc_modules(|ctx| {
|
||||
.extend_rpc_modules(move |ctx| {
|
||||
let upstream_rpc_url = ext.upstream_rpc_url;
|
||||
if let Some(upstream_rpc_url) = upstream_rpc_url {
|
||||
ctx.modules.replace_configured(
|
||||
@ -38,6 +40,11 @@ fn main() -> eyre::Result<()> {
|
||||
|
||||
info!("Transaction forwarding enabled");
|
||||
}
|
||||
|
||||
if ext.hl_node_compliant {
|
||||
install_hl_node_compliance(ctx)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
})
|
||||
.launch()
|
||||
|
||||
@ -34,6 +34,9 @@ pub struct HlNodeArgs {
|
||||
|
||||
#[arg(long, env = "UPSTREAM_RPC_URL")]
|
||||
pub upstream_rpc_url: Option<String>,
|
||||
|
||||
#[arg(long, env = "HL_NODE_COMPLIANT")]
|
||||
pub hl_node_compliant: bool,
|
||||
}
|
||||
|
||||
/// The main reth_hl cli interface.
|
||||
|
||||
@ -51,14 +51,23 @@ pub struct HlNode {
|
||||
engine_handle_rx:
|
||||
Arc<Mutex<Option<oneshot::Receiver<BeaconConsensusEngineHandle<HlPayloadTypes>>>>>,
|
||||
block_source_config: BlockSourceConfig,
|
||||
hl_node_compliant: bool,
|
||||
}
|
||||
|
||||
impl HlNode {
|
||||
pub fn new(
|
||||
block_source_config: BlockSourceConfig,
|
||||
hl_node_compliant: bool,
|
||||
) -> (Self, oneshot::Sender<BeaconConsensusEngineHandle<HlPayloadTypes>>) {
|
||||
let (tx, rx) = oneshot::channel();
|
||||
(Self { engine_handle_rx: Arc::new(Mutex::new(Some(rx))), block_source_config }, tx)
|
||||
(
|
||||
Self {
|
||||
engine_handle_rx: Arc::new(Mutex::new(Some(rx))),
|
||||
block_source_config,
|
||||
hl_node_compliant,
|
||||
},
|
||||
tx,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@ -121,7 +130,12 @@ where
|
||||
}
|
||||
|
||||
fn add_ons(&self) -> Self::AddOns {
|
||||
HlNodeAddOns::default()
|
||||
HlNodeAddOns::new(
|
||||
HlEthApiBuilder { hl_node_compliant: self.hl_node_compliant },
|
||||
Default::default(),
|
||||
Default::default(),
|
||||
Default::default(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -250,9 +250,18 @@ where
|
||||
}
|
||||
|
||||
/// Builds [`HlEthApi`] for HL.
|
||||
#[derive(Debug, Default)]
|
||||
#[derive(Debug)]
|
||||
#[non_exhaustive]
|
||||
pub struct HlEthApiBuilder;
|
||||
pub struct HlEthApiBuilder {
|
||||
/// Whether the node is in HL node compliant mode.
|
||||
pub(crate) hl_node_compliant: bool,
|
||||
}
|
||||
|
||||
impl Default for HlEthApiBuilder {
|
||||
fn default() -> Self {
|
||||
Self { hl_node_compliant: false }
|
||||
}
|
||||
}
|
||||
|
||||
impl<N> EthApiBuilder<N> for HlEthApiBuilder
|
||||
where
|
||||
@ -280,6 +289,7 @@ where
|
||||
Ok(HlEthApi {
|
||||
inner: Arc::new(HlEthApiInner { eth_api }),
|
||||
tx_resp_builder: Default::default(),
|
||||
hl_node_compliant: self.hl_node_compliant,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user