Skip to content

Commit

Permalink
Validate eth68 announcements
Browse files Browse the repository at this point in the history
  • Loading branch information
emhane committed Jan 25, 2024
1 parent 4a21d91 commit ca622e8
Show file tree
Hide file tree
Showing 5 changed files with 423 additions and 1 deletion.
1 change: 1 addition & 0 deletions crates/net/network/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,5 +147,6 @@ pub use session::{
PendingSessionHandle, PendingSessionHandshakeError, SessionCommand, SessionEvent, SessionId,
SessionLimits, SessionManager, SessionsConfig,
};
pub use transactions::{Announcement68Filter, FilterAnnouncement68, ValidateTx68};

pub use reth_eth_wire::{DisconnectReason, HelloMessageWithProtocols};
7 changes: 6 additions & 1 deletion crates/net/network/src/transactions/fetcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ use std::{
use tokio::sync::{mpsc::error::TrySendError, oneshot, oneshot::error::RecvError};
use tracing::{debug, trace};

use super::{Peer, PooledTransactions, FULL_TRANSACTIONS_PACKET_SIZE_SOFT_LIMIT};
use super::{
Announcement68Filter, Peer, PooledTransactions, FULL_TRANSACTIONS_PACKET_SIZE_SOFT_LIMIT,
};

/// Maximum concurrent [`GetPooledTxRequest`]s to allow per peer.
pub(super) const MAX_CONCURRENT_TX_REQUESTS_PER_PEER: u8 = 1;
Expand Down Expand Up @@ -65,6 +67,8 @@ pub(super) struct TransactionFetcher {
pub(super) unknown_hashes: LruMap<TxHash, (u8, LruCache<PeerId>), Unlimited>,
/// Size metadata for unknown eth68 hashes.
pub(super) eth68_meta: LruMap<TxHash, usize, Unlimited>,
/// Filter for valid eth68 announcements.
pub(super) eth68_filter_valid: Announcement68Filter,
}

// === impl TransactionFetcher ===
Expand Down Expand Up @@ -723,6 +727,7 @@ impl Default for TransactionFetcher {
),
unknown_hashes: LruMap::new_unlimited(),
eth68_meta: LruMap::new_unlimited(),
eth68_filter_valid: Default::default(),
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions crates/net/network/src/transactions/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,10 @@ use tokio_stream::wrappers::{ReceiverStream, UnboundedReceiverStream};
use tracing::{debug, trace};

mod fetcher;
mod validation;

use fetcher::{FetchEvent, TransactionFetcher};
pub use validation::*;

/// Cache limit of transactions to keep track of for a single peer.
const PEER_TRANSACTION_CACHE_LIMIT: usize = 1024 * 10;
Expand Down
Loading

0 comments on commit ca622e8

Please sign in to comment.