mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
feat(consensus): beacon consensus builder (#1119)
This commit is contained in:
@ -153,26 +153,21 @@ impl Command {
|
||||
}
|
||||
|
||||
fn init_consensus(&self) -> eyre::Result<Arc<dyn Consensus>> {
|
||||
// TODO: This should be in a builder/factory in the consensus crate
|
||||
let consensus: Arc<dyn Consensus> = {
|
||||
let beacon_consensus = BeaconConsensus::new(self.chain.clone());
|
||||
let (consensus, notifier) = BeaconConsensus::builder().build(self.chain.clone());
|
||||
|
||||
if let Some(tip) = self.tip {
|
||||
debug!(target: "reth::cli", %tip, "Tip manually set");
|
||||
beacon_consensus.notify_fork_choice_state(ForkchoiceState {
|
||||
head_block_hash: tip,
|
||||
safe_block_hash: tip,
|
||||
finalized_block_hash: tip,
|
||||
})?;
|
||||
} else {
|
||||
let warn_msg = "No tip specified. \
|
||||
reth cannot communicate with consensus clients, \
|
||||
so a tip must manually be provided for the online stages with --debug.tip <HASH>.";
|
||||
warn!(target: "reth::cli", warn_msg);
|
||||
}
|
||||
|
||||
Arc::new(beacon_consensus)
|
||||
};
|
||||
if let Some(tip) = self.tip {
|
||||
debug!(target: "reth::cli", %tip, "Tip manually set");
|
||||
notifier.send(ForkchoiceState {
|
||||
head_block_hash: tip,
|
||||
safe_block_hash: tip,
|
||||
finalized_block_hash: tip,
|
||||
})?;
|
||||
} else {
|
||||
let warn_msg = "No tip specified. \
|
||||
reth cannot communicate with consensus clients, \
|
||||
so a tip must manually be provided for the online stages with --debug.tip <HASH>.";
|
||||
warn!(target: "reth::cli", warn_msg);
|
||||
}
|
||||
|
||||
Ok(consensus)
|
||||
}
|
||||
|
||||
@ -126,8 +126,7 @@ impl Command {
|
||||
|
||||
match self.stage {
|
||||
StageEnum::Bodies => {
|
||||
let consensus: Arc<BeaconConsensus> =
|
||||
Arc::new(BeaconConsensus::new(self.chain.clone()));
|
||||
let (consensus, _) = BeaconConsensus::builder().build(self.chain.clone());
|
||||
|
||||
let mut config = config;
|
||||
config.peers.connect_trusted_nodes_only = self.network.trusted_only;
|
||||
|
||||
Reference in New Issue
Block a user