From 7252ef0b6ba75bc23a74e69ef71e7c4b3dd76e0c Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Fri, 13 Dec 2024 14:10:50 +0100 Subject: [PATCH] chore: use pow for bsc p2p example (#13380) --- crates/net/network/src/config.rs | 11 +++++++++++ examples/bsc-p2p/src/main.rs | 2 ++ 2 files changed, 13 insertions(+) diff --git a/crates/net/network/src/config.rs b/crates/net/network/src/config.rs index 324cd518916d..6047ab3caa1c 100644 --- a/crates/net/network/src/config.rs +++ b/crates/net/network/src/config.rs @@ -266,6 +266,17 @@ impl NetworkConfigBuilder { self } + /// Configures the network to use proof-of-work. + /// + /// This effectively allows block propagation in the `eth` sub-protocol, which has been + /// soft-deprecated with ethereum `PoS` after the merge. Even if block propagation is + /// technically allowed, according to the eth protocol, it is not expected to be used in `PoS` + /// networks and peers are supposed to terminate the connection if they receive a `NewBlock` + /// message. + pub const fn with_pow(self) -> Self { + self.network_mode(NetworkMode::Work) + } + /// Sets the highest synced block. /// /// This is used to construct the appropriate [`ForkFilter`] and [`Status`] message. diff --git a/examples/bsc-p2p/src/main.rs b/examples/bsc-p2p/src/main.rs index cea87918322b..a2dec469591b 100644 --- a/examples/bsc-p2p/src/main.rs +++ b/examples/bsc-p2p/src/main.rs @@ -55,6 +55,8 @@ async fn main() { // The network configuration let mut net_cfg = NetworkConfig::builder(secret_key) .listener_addr(local_addr) + // we need to explicitly set the network mode to PoW to allow block propagation, see docs + .with_pow() .build_with_noop_provider(bsc_chain_spec()) .set_discovery_v4( Discv4ConfigBuilder::default()