Skip to content
This repository has been archived by the owner on Nov 5, 2023. It is now read-only.

Commit

Permalink
Set forkchoice state on startup
Browse files Browse the repository at this point in the history
Add param for enabling genesis walkback
  • Loading branch information
clabby committed Oct 21, 2023
1 parent ba309ec commit 66e9ba0
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
5 changes: 5 additions & 0 deletions bin/reth/src/args/rollup_args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,9 @@ pub struct RollupArgs {
/// Disable transaction pool gossip
#[arg(long = "rollup.disable-tx-pool-gossip")]
pub disable_txpool_gossip: bool,

/// Enable walkback to genesis on startup. This is useful for re-validating the existing DB
/// prior to beginning normal syncing.
#[arg(long = "rollup.enable-genesis-walkback")]
pub enable_genesis_walkback: bool,
}
20 changes: 20 additions & 0 deletions bin/reth/src/node/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ use std::{
use tokio::sync::{mpsc::unbounded_channel, oneshot, watch};
use tracing::*;

#[cfg(feature = "optimism")]
use reth_rpc_api::EngineApiClient;
#[cfg(feature = "optimism")]
use reth_rpc_types::engine::ForkchoiceState;

pub mod cl_events;
pub mod events;

Expand Down Expand Up @@ -551,6 +556,21 @@ impl<Ext: RethCliExt> NodeCommand<Ext> {

self.ext.on_node_started(&components)?;

#[cfg(feature = "optimism")]
if self.chain.optimism && !self.rollup.enable_genesis_walkback {
let client = _rpc_server_handles.auth.http_client();
EngineApiClient::fork_choice_updated_v2(
&client,
ForkchoiceState {
head_block_hash: head.hash,
safe_block_hash: head.hash,
finalized_block_hash: head.hash,
},
None,
)
.await?;
}

rx.await??;

info!(target: "reth::cli", "Consensus engine has exited.");
Expand Down
1 change: 1 addition & 0 deletions crates/net/network/tests/it/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ mod geth;
mod requests;
mod session;
mod startup;
#[cfg(not(feature = "optimism"))]
mod txgossip;

fn main() {}

0 comments on commit 66e9ba0

Please sign in to comment.