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
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-14

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

### 2025-10-13

- Remove unnecesary mul in ecpairing [#4843](https://github.com/lambdaclass/ethrex/pull/4843)
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
36 changes: 24 additions & 12 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,13 +5,14 @@ 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 std::{
collections::{BTreeMap, HashSet, btree_map::Entry},
collections::HashSet,
net::IpAddr,
time::{Duration, Instant},
};
Expand Down Expand Up @@ -502,8 +503,8 @@ impl PeerTable {

#[derive(Debug, Default)]
struct PeerTableServer {
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 @@ -550,7 +551,7 @@ impl PeerTableServer {
.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 @@ -984,7 +985,7 @@ impl GenServer for PeerTableServer {
self.peers.insert(new_peer_id, new_peer);
}
CastMessage::RemovePeer { node_id } => {
self.peers.remove(&node_id);
self.peers.swap_remove(&node_id);
}
CastMessage::IncRequests { node_id } => {
self.peers
Expand Down
Loading