mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 02:49:55 +00:00
feat: Add debug CLI flag to enforce latest blocks (--debug-cutoff-height)
This is useful when syncing to specific testnet blocks
This commit is contained in:
@ -35,6 +35,12 @@ pub struct HlNodeArgs {
|
||||
#[command(flatten)]
|
||||
pub block_source_args: BlockSourceArgs,
|
||||
|
||||
/// Debug cutoff height.
|
||||
///
|
||||
/// This option is used to cut off the block import at a specific height.
|
||||
#[arg(long, env = "DEBUG_CUTOFF_HEIGHT")]
|
||||
pub debug_cutoff_height: Option<u64>,
|
||||
|
||||
/// Upstream RPC URL to forward incoming transactions.
|
||||
///
|
||||
/// Default to Hyperliquid's RPC URL when not provided (https://rpc.hyperliquid.xyz/evm).
|
||||
|
||||
@ -49,14 +49,23 @@ pub type HlNodeAddOns<N> =
|
||||
pub struct HlNode {
|
||||
engine_handle_rx: Arc<Mutex<Option<oneshot::Receiver<ConsensusEngineHandle<HlPayloadTypes>>>>>,
|
||||
block_source_config: BlockSourceConfig,
|
||||
debug_cutoff_height: Option<u64>,
|
||||
}
|
||||
|
||||
impl HlNode {
|
||||
pub fn new(
|
||||
block_source_config: BlockSourceConfig,
|
||||
debug_cutoff_height: Option<u64>,
|
||||
) -> (Self, oneshot::Sender<ConsensusEngineHandle<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,
|
||||
debug_cutoff_height,
|
||||
},
|
||||
tx,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@ -84,6 +93,7 @@ impl HlNode {
|
||||
.network(HlNetworkBuilder {
|
||||
engine_handle_rx: self.engine_handle_rx.clone(),
|
||||
block_source_config: self.block_source_config.clone(),
|
||||
debug_cutoff_height: self.debug_cutoff_height,
|
||||
})
|
||||
.consensus(HlConsensusBuilder::default())
|
||||
}
|
||||
|
||||
@ -142,6 +142,8 @@ pub struct HlNetworkBuilder {
|
||||
Arc<Mutex<Option<oneshot::Receiver<ConsensusEngineHandle<HlPayloadTypes>>>>>,
|
||||
|
||||
pub(crate) block_source_config: BlockSourceConfig,
|
||||
|
||||
pub(crate) debug_cutoff_height: Option<u64>,
|
||||
}
|
||||
|
||||
impl HlNetworkBuilder {
|
||||
@ -203,6 +205,7 @@ where
|
||||
pool: Pool,
|
||||
) -> eyre::Result<Self::Network> {
|
||||
let block_source_config = self.block_source_config.clone();
|
||||
let debug_cutoff_height = self.debug_cutoff_height;
|
||||
let handle =
|
||||
ctx.start_network(NetworkManager::builder(self.network_config(ctx)?).await?, pool);
|
||||
let local_node_record = handle.local_node_record();
|
||||
@ -223,6 +226,7 @@ where
|
||||
block_source_config
|
||||
.create_cached_block_source((*chain_spec).clone(), next_block_number)
|
||||
.await,
|
||||
debug_cutoff_height,
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
Reference in New Issue
Block a user