Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Perf

### 2025-10-10

- Improve get_closest_nodes p2p performance [#4838](https://github.com/lambdaclass/ethrex/pull/4838)

### 2025-10-06

- Improve block headers vec handling in syncer [#4771](https://github.com/lambdaclass/ethrex/pull/4771)
Expand Down
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ rkyv = { version = "0.8.10", features = ["std", "unaligned"] }
tempfile = "3.8"
uuid = { version = "1.18.1", features = ["v4"] }
tower-http = { version = "0.6.2", features = ["cors"] }
indexmap = { version = "2.11.4" }

rocksdb = "0.24.0"

Expand Down
49 changes: 32 additions & 17 deletions crates/l2/tee/quote-gen/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/networking/p2p/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ spawned-rt.workspace = true
spawned-concurrency.workspace = true
sha2.workspace = true
futures.workspace = true
indexmap.workspace = true
rocksdb = { workspace = true, optional = true }
prometheus = "0.14.0"

Expand Down
11 changes: 6 additions & 5 deletions crates/networking/p2p/discv4/peer_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ use crate::{
types::{Node, NodeRecord},
};
use ethrex_common::{H256, U256};
use indexmap::{IndexMap, map::Entry};
use rand::seq::SliceRandom;
use spawned_concurrency::{
error::GenServerError,
tasks::{CallResponse, CastResponse, GenServer, GenServerHandle},
};
use spawned_rt::tasks::mpsc;
use std::{
collections::{BTreeMap, HashSet, btree_map::Entry},
collections::HashSet,
net::IpAddr,
sync::Arc,
time::{Duration, Instant},
Expand Down Expand Up @@ -546,8 +547,8 @@ impl PeerTableHandle {

#[derive(Debug, Default)]
pub struct PeerTable {
contacts: BTreeMap<H256, Contact>,
peers: BTreeMap<H256, PeerData>,
contacts: IndexMap<H256, Contact>,
peers: IndexMap<H256, PeerData>,
already_tried_peers: HashSet<H256>,
discarded_contacts: HashSet<H256>,
}
Expand Down Expand Up @@ -606,7 +607,7 @@ impl PeerTable {
.collect::<Vec<_>>();

for contact_to_discard_id in disposable_contacts {
self.contacts.remove(&contact_to_discard_id);
self.contacts.swap_remove(&contact_to_discard_id);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does indexmap have something like Vec::retain ? We could replace this loop with that

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i would prefer to look at this in another pr/change

self.discarded_contacts.insert(contact_to_discard_id);
}
}
Expand Down Expand Up @@ -1067,7 +1068,7 @@ impl GenServer for PeerTable {
self.peers.insert(new_peer_id, new_peer);
}
CastMessage::RemovePeer { node_id } => {
self.peers.remove(&node_id);
self.peers.swap_remove(&node_id);
}
CastMessage::SetUnwanted { node_id } => {
self.contacts
Expand Down
Loading