diff --git a/Node/src/ethereum_l1/mod.rs b/Node/src/ethereum_l1/mod.rs index 13f548a..20c3e9a 100644 --- a/Node/src/ethereum_l1/mod.rs +++ b/Node/src/ethereum_l1/mod.rs @@ -8,6 +8,7 @@ pub mod slot_clock; mod ws_provider; use crate::{bls::BLSService, utils::config::ContractAddresses}; +use anyhow::Error; use consensus_layer::ConsensusLayer; #[cfg(not(test))] use execution_layer::ExecutionLayer; @@ -37,7 +38,7 @@ impl EthereumL1 { preconf_registry_expiry_sec: u64, bls_service: Arc, l1_chain_id: u64, - ) -> Result { + ) -> Result { let consensus_layer = ConsensusLayer::new(consensus_rpc_url)?; let genesis_details = consensus_layer.get_genesis_details().await?; let slot_clock = Arc::new(SlotClock::new( @@ -64,4 +65,25 @@ impl EthereumL1 { execution_layer, }) } + + pub async fn force_push_lookahead(&self) -> Result<(), Error> { + // Get next epoch + let next_epoch = self.slot_clock.get_current_epoch()? + 1; + // Get CL lookahead for the next epoch + let cl_lookahead = self.consensus_layer.get_lookahead(next_epoch).await?; + // Get lookahead params for contract call + let lookahead_params = self + .execution_layer + .get_lookahead_params_for_epoch_using_cl_lookahead( + self.slot_clock.get_epoch_begin_timestamp(next_epoch)?, + &cl_lookahead, + ) + .await?; + // Force push lookahead to the contract + self.execution_layer + .force_push_lookahead(lookahead_params) + .await?; + + Ok(()) + } } diff --git a/Node/src/main.rs b/Node/src/main.rs index df5be06..a0cbda4 100644 --- a/Node/src/main.rs +++ b/Node/src/main.rs @@ -24,6 +24,8 @@ struct Cli { register: bool, #[clap(long, help = "Add validator to preconfer")] add_validator: bool, + #[clap(long, help = "Force Push lookahead to the PreconfTaskManager contract")] + force_push_lookahead: bool, } #[tokio::main] @@ -59,6 +61,11 @@ async fn main() -> Result<(), Error> { return Ok(()); } + if args.force_push_lookahead { + ethereum_l1.force_push_lookahead().await?; + return Ok(()); + } + let (node_to_p2p_tx, node_to_p2p_rx) = mpsc::channel(MESSAGE_QUEUE_SIZE); let (p2p_to_node_tx, p2p_to_node_rx) = mpsc::channel(MESSAGE_QUEUE_SIZE); let (block_proposed_tx, block_proposed_rx) = mpsc::channel(MESSAGE_QUEUE_SIZE); diff --git a/Node/src/node/mod.rs b/Node/src/node/mod.rs index 2e816d4..d987ce7 100644 --- a/Node/src/node/mod.rs +++ b/Node/src/node/mod.rs @@ -309,30 +309,7 @@ impl Node { .is_lookahead_tail_zero() .await?; if is_zero { - // Get next epoch - let next_epoch = self.ethereum_l1.slot_clock.get_current_epoch()? + 1; - // Get CL lookahead for the next epoch - self.cl_lookahead = self - .ethereum_l1 - .consensus_layer - .get_lookahead(next_epoch) - .await?; - // Get lookahead params for contract call - let lookahead_params = self - .ethereum_l1 - .execution_layer - .get_lookahead_params_for_epoch_using_cl_lookahead( - self.ethereum_l1 - .slot_clock - .get_epoch_begin_timestamp(next_epoch)?, - &self.cl_lookahead, - ) - .await?; - // Force push lookahead to the contract - self.ethereum_l1 - .execution_layer - .force_push_lookahead(lookahead_params) - .await?; + self.ethereum_l1.force_push_lookahead().await?; } Ok(()) }