Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions src/node/network/block_import/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ use reth_payload_builder_primitives::Events;
use reth_payload_primitives::{BuiltPayload, EngineApiMessageVersion, PayloadTypes};
use reth_primitives::NodePrimitives;
use reth_primitives_traits::{AlloyBlockHeader, Block};
use reth_chainspec::Head;
use reth_provider::{BlockHashReader, BlockNumReader, BlockReaderIdExt, HeaderProvider};
use std::{
future::Future,
Expand Down Expand Up @@ -221,6 +222,20 @@ where
tracing::warn!(target: "bsc::block_import", "Failed to update fork choice: {}", e);
} else {
tracing::debug!(target: "bsc::block_import", "Succeed to update fork choice for new payload: number = {:?}, hash = {:?}", header.number, block_hash);
if let Some(net) = crate::shared::get_network_handle() {
let td = forkchoice_engine.provider
.header_td_by_number(header.number)
.ok()
.flatten()
.unwrap_or_default();
net.update_status(Head {
number: header.number,
hash: block_hash,
timestamp: header.timestamp,
difficulty: header.difficulty,
total_difficulty: td,
});
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/bnb-chain/reth/blob/develop/crates/node/builder/src/launch/engine.rs#L447

There is a update_status in the Reth engine, that is not work?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh good point, let me check

}
}
Outcome { peer: peer_id, result: Ok(BlockValidation::ValidBlock { block }) }
.into()
Expand Down Expand Up @@ -435,6 +450,20 @@ where
block_hash = %block_hash,
"Succeeded to update fork choice for mined block"
);
if let Some(net) = crate::shared::get_network_handle() {
let td = forkchoice_engine.provider
.header_td_by_number(header_for_fcu.number)
.ok()
.flatten()
.unwrap_or_default();
net.update_status(Head {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto.

number: header_for_fcu.number,
hash: block_hash,
timestamp: header_for_fcu.timestamp,
difficulty: header_for_fcu.difficulty,
total_difficulty: td,
});
}
}
});
}
Expand Down
5 changes: 1 addition & 4 deletions src/node/network/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -310,10 +310,9 @@ impl BscNetworkBuilder {
.unwrap();
});

// TODO: update network with the latest canonical head, but has a fork id issue, can fix it later.
let mut network_builder = network_builder
.boot_nodes(ctx.chain_spec().bootnodes().unwrap_or_default())
.set_head(ctx.chain_spec().head())
.set_head(ctx.head())
.with_pow()
.block_import(Box::new(BscBlockImport::new(handle)))
.eth_rlpx_handshake(Arc::new(BscHandshake::default()))
Expand All @@ -332,8 +331,6 @@ impl BscNetworkBuilder {
&mut network_config.discovery_v4_config,
ctx.chain_spec().bootnodes(),
);
network_config.status.forkid = network_config.fork_filter.current();

// Initialize BSC protocol registry with proxied peers from config
// This mirrors the same functionality in the main peer manager
let proxied_node_ids = network_config.peers_config.proxied_node_ids.clone();
Expand Down
Loading