Skip to content
Merged
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
6 changes: 3 additions & 3 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -274,14 +274,14 @@ jobs:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
toolchain: nightly-2025-07-30
toolchain: nightly-2025-08-18
- uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
- run: cargo install --locked --git https://github.com/openvm-org/openvm.git --tag v1.4.0-rc.2 cargo-openvm
- run: cargo install --locked --git https://github.com/openvm-org/openvm.git --tag v1.4.0 cargo-openvm
- name: verify openvm compatibility
env:
OPENVM_RUST_TOOLCHAIN: nightly-2025-07-30
OPENVM_RUST_TOOLCHAIN: nightly-2025-08-18
run: cargo openvm build --manifest-path crates/scroll/openvm-compat/Cargo.toml

lint-success:
Expand Down
4 changes: 2 additions & 2 deletions crates/net/network/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ tracing.workspace = true
rustc-hash.workspace = true
thiserror.workspace = true
parking_lot.workspace = true
rand.workspace = true
rand_08.workspace = true
secp256k1 = { workspace = true, features = ["global-context", "std", "recovery"] }
derive_more.workspace = true
Expand Down Expand Up @@ -96,6 +95,7 @@ alloy-genesis.workspace = true
tempfile.workspace = true
url.workspace = true
secp256k1 = { workspace = true, features = ["rand"] }
rand.workspace = true

## Benchmarks
criterion = { workspace = true, features = ["async_tokio", "html_reports"] }
Expand All @@ -114,7 +114,6 @@ serde = [
"alloy-primitives/serde",
"discv5/serde",
"parking_lot/serde",
"rand/serde",
"smallvec/serde",
"url/serde",
"reth-primitives-traits/serde",
Expand All @@ -124,6 +123,7 @@ serde = [
"reth-ethereum-primitives/serde",
"reth-network-api/serde",
"rand_08/serde",
"rand/serde",
"reth-storage-api/serde",
]
test-utils = [
Expand Down
37 changes: 10 additions & 27 deletions crates/net/network/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ use crate::{
};
use alloy_consensus::BlockHeader;
use alloy_primitives::B256;
use rand::seq::SliceRandom;
use reth_eth_wire::{
BlockHashNumber, Capabilities, DisconnectReason, EthNetworkPrimitives, NetworkPrimitives,
NewBlockHashes, NewBlockPayload, UnifiedStatus,
Expand Down Expand Up @@ -192,21 +191,13 @@ impl<N: NetworkPrimitives> NetworkState<N> {
///
/// This is supposed to be invoked after the block was validated.
///
/// > It then sends the block to a small fraction of connected peers (usually the square root of
/// > the total number of peers) using the `NewBlock` message.
/// Note: Sends a `NewBlock` message to all of the connected peers. This is okay because this
/// method is only used until we deprecate l2geth clients which don't support scroll-wire.
///
/// See also <https://github.com/ethereum/devp2p/blob/master/caps/eth.md>
pub(crate) fn announce_new_block(&mut self, msg: NewBlockMessage<N::NewBlockPayload>) {
// send a `NewBlock` message to a fraction of the connected peers (square root of the total
// number of peers)
let num_propagate = (self.active_peers.len() as f64).sqrt() as u64 + 1;

let number = msg.block.block().header().number();
let mut count = 0;

// Shuffle to propagate to a random sample of peers on every block announcement
let mut peers: Vec<_> = self.active_peers.iter_mut().collect();
peers.shuffle(&mut rand::rng());
let peers: Vec<_> = self.active_peers.iter_mut().collect();

for (peer_id, peer) in peers {
if peer.blocks.contains(&msg.hash) {
Expand All @@ -215,24 +206,16 @@ impl<N: NetworkPrimitives> NetworkState<N> {
}

// Queue a `NewBlock` message for the peer
if count < num_propagate {
self.queued_messages
.push_back(StateAction::NewBlock { peer_id: *peer_id, block: msg.clone() });

// update peer block info
if self.state_fetcher.update_peer_block(peer_id, msg.hash, number) {
peer.best_hash = msg.hash;
}
self.queued_messages
.push_back(StateAction::NewBlock { peer_id: *peer_id, block: msg.clone() });

// mark the block as seen by the peer
peer.blocks.insert(msg.hash);

count += 1;
// update peer block info
if self.state_fetcher.update_peer_block(peer_id, msg.hash, number) {
peer.best_hash = msg.hash;
}

if count >= num_propagate {
break
}
// mark the block as seen by the peer
peer.blocks.insert(msg.hash);
}
}

Expand Down
Loading