Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delayed RPC Send Using Tokens #5923

Open
wants to merge 71 commits into
base: unstable
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
0154359
trickle responses
ackintosh Jun 7, 2024
d5fe64e
pruning
ackintosh Jun 9, 2024
aab59f5
cargo fmt
ackintosh Jun 10, 2024
e00e679
Test that the receiver delays the responses
ackintosh Jun 10, 2024
670ec96
Add doc comments
ackintosh Jun 11, 2024
c0ae632
Fix typo
ackintosh Jun 13, 2024
7e0c630
Add inbound request size limiter
ackintosh Jun 14, 2024
6322210
Merge branch 'refs/heads/unstable' into delayed-rpc-response
ackintosh Jun 20, 2024
3947bf6
Fix compile error
ackintosh Jun 20, 2024
933dc00
Add doc comment and rename
ackintosh Jun 20, 2024
b62537f
Extract a function that calculates tau and t from the quota
ackintosh Jun 20, 2024
86cf8fb
unwrap
ackintosh Jun 22, 2024
8fd37c5
Remove unused limiter
ackintosh Jun 22, 2024
6c1015e
Restrict more than two requests from running simultaneously on the sa…
ackintosh Jun 26, 2024
817ce97
Rename from self_limiter to outbound_request_limiter
ackintosh Jun 29, 2024
7e42568
Fix clippy errors
ackintosh Jun 29, 2024
94c2493
Merge branch 'refs/heads/unstable' into delayed-rpc-response
ackintosh Jul 1, 2024
9ad4eb7
Fix import
ackintosh Jul 1, 2024
de9d943
Fix clippy errors
ackintosh Jul 6, 2024
7adb142
Merge branch 'refs/heads/unstable' into delayed-rpc-response
ackintosh Jul 7, 2024
627fd33
Merge branch 'refs/heads/unstable' into delayed-rpc-response
ackintosh Jul 11, 2024
b55ffca
Update request_id with AppRequestId
ackintosh Jul 11, 2024
73e9879
Merge branch 'unstable' into delayed-rpc-response
ackintosh Jul 13, 2024
cdef58d
Update beacon_node/lighthouse_network/src/rpc/active_requests_limiter.rs
ackintosh Jul 23, 2024
3190d9a
Update beacon_node/lighthouse_network/src/rpc/mod.rs
ackintosh Jul 23, 2024
19fe6b0
Merge branch 'unstable' into delayed-rpc-response
ackintosh Jul 25, 2024
5a9237f
Remove the RequestSizeLimiter and check if the count of requested blo…
ackintosh Jul 29, 2024
4609624
Revert extracting `tau_and_t()` because no longer need to do that
ackintosh Jul 29, 2024
a325438
Remove Instant from the requests field
ackintosh Sep 9, 2024
3b6edab
Remove unused field
ackintosh Sep 9, 2024
2ab853c
Merge branch 'unstable' into delayed-rpc-response
ackintosh Sep 9, 2024
2621ce8
Add DataColumnsBy***
ackintosh Sep 9, 2024
51247e3
Merge branch 'unstable' into delayed-rpc-response
ackintosh Sep 26, 2024
5ed47b7
Fix the mistakes made during the merge
ackintosh Sep 27, 2024
cbfb2ea
cargo fmt
ackintosh Sep 27, 2024
9f6177d
Update beacon_node/lighthouse_network/src/rpc/active_requests_limiter.rs
ackintosh Sep 27, 2024
9008d3e
Merge branch 'unstable' into delayed-rpc-response
ackintosh Oct 1, 2024
bd9f13c
merge unstable
ackintosh Oct 1, 2024
5dbac58
Move the response limiter logic from handler to behaviour
ackintosh Oct 5, 2024
ae67804
Remove Mutex from response_limiter
ackintosh Oct 5, 2024
4852b20
Fix clippy error
ackintosh Oct 7, 2024
156565c
Add the request back to active requests if the response is not a stre…
ackintosh Oct 7, 2024
0e1e58b
Add ResponseLimiter to make RPC cleaner
ackintosh Oct 10, 2024
cb87af0
Remove pending responses on disconnect
ackintosh Oct 11, 2024
023c542
Add ConnectionId to Request
ackintosh Oct 18, 2024
14ffeec
Add a comment
ackintosh Oct 20, 2024
5c9e063
Return early if the request is too large
ackintosh Oct 20, 2024
3c058b3
Remove ActiveRequestsLimiter
ackintosh Oct 21, 2024
a9a675a
Merge branch 'unstable' into delayed-rpc-response
ackintosh Oct 22, 2024
5d70573
Merge branch 'unstable' into delayed-rpc-response
ackintosh Oct 23, 2024
4e872a0
merge unstable
ackintosh Oct 23, 2024
450326c
Tweak for readability
ackintosh Oct 29, 2024
14fb84c
Merge branch 'unstable' into delayed-rpc-response
ackintosh Nov 19, 2024
636224c
Limit concurrent requests on self-limiter
ackintosh Nov 23, 2024
f6fd85b
Make the self-limiter mandatory, and make the rate-limiter optional w…
ackintosh Nov 23, 2024
95f8378
Inform the limiter that a response has been received
ackintosh Nov 25, 2024
9d2b263
Remove active requests belonging to the peer that disconnected
ackintosh Nov 26, 2024
2d7a679
Fix unused variable error
ackintosh Nov 27, 2024
b73a336
Fix clippy errors
ackintosh Nov 29, 2024
dfd092d
Merge branch 'unstable' into delayed-rpc-response
ackintosh Dec 1, 2024
810c5de
Fix clippy errors
ackintosh Dec 1, 2024
d46cbe8
Update test
ackintosh Dec 1, 2024
540436c
Adding a slight margin to the elapsed time check to account for poten…
ackintosh Dec 1, 2024
3d39f2c
Merge branch 'unstable' into delayed-rpc-response
ackintosh Dec 4, 2024
60c9900
Remove an active request when it ends with an error
ackintosh Dec 8, 2024
eec6b4a
Merge branch 'unstable' into delayed-rpc-response
ackintosh Dec 10, 2024
9a6eb72
Merge branch 'unstable' into delayed-rpc-response
ackintosh Feb 6, 2025
0d0f48d
Sync with further updates from unstable
ackintosh Feb 7, 2025
ce7ae4b
Sync with further updates from unstable
ackintosh Feb 7, 2025
cfea9d2
Remove RPC::is_request_size_too_large
ackintosh Feb 14, 2025
9850bce
Merge branch 'unstable' into delayed-rpc-response
ackintosh Feb 16, 2025
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
21 changes: 18 additions & 3 deletions beacon_node/lighthouse_network/src/rpc/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ use libp2p::swarm::handler::{
ConnectionEvent, ConnectionHandler, ConnectionHandlerEvent, DialUpgradeError,
FullyNegotiatedInbound, FullyNegotiatedOutbound, StreamUpgradeError, SubstreamProtocol,
};
use libp2p::swarm::Stream;
use libp2p::swarm::{ConnectionId, Stream};
use libp2p::PeerId;
use slog::{crit, debug, trace};
use smallvec::SmallVec;
use std::{
Expand Down Expand Up @@ -89,6 +90,12 @@ pub struct RPCHandler<Id, E>
where
E: EthSpec,
{
/// This `ConnectionId`.
connection_id: ConnectionId,

/// The matching `PeerId` of this connection.
peer_id: PeerId,

/// The upgrade for inbound substreams.
listen_protocol: SubstreamProtocol<RPCProtocol<E>, ()>,

Expand Down Expand Up @@ -138,7 +145,7 @@ where
/// Logger for handling RPC streams
log: slog::Logger,

/// Timeout that will me used for inbound and outbound responses.
/// Timeout that will be used for inbound and outbound responses.
resp_timeout: Duration,
}

Expand Down Expand Up @@ -219,12 +226,16 @@ where
E: EthSpec,
{
pub fn new(
connection_id: ConnectionId,
peer_id: PeerId,
listen_protocol: SubstreamProtocol<RPCProtocol<E>, ()>,
fork_context: Arc<ForkContext>,
log: &slog::Logger,
resp_timeout: Duration,
) -> Self {
RPCHandler {
connection_id,
peer_id,
listen_protocol,
events_out: SmallVec::new(),
dial_queue: SmallVec::new(),
Expand Down Expand Up @@ -302,6 +313,7 @@ where
}
return;
};

// If the response we are sending is an error, report back for handling
if let RpcResponse::Error(ref code, ref reason) = response {
self.events_out.push(HandlerEvent::Err(HandlerErr::Inbound {
Expand All @@ -314,9 +326,10 @@ where
if matches!(self.state, HandlerState::Deactivated) {
// we no longer send responses after the handler is deactivated
debug!(self.log, "Response not sent. Deactivated handler";
"response" => %response, "id" => inbound_id);
"response" => %response, "id" => inbound_id);
return;
}

inbound_info.pending_items.push_back(response);
}
}
Expand Down Expand Up @@ -938,6 +951,8 @@ where
self.events_out
.push(HandlerEvent::Ok(RPCReceived::Request(Request {
id: RequestId::next(),
peer_id: self.peer_id,
connection_id: self.connection_id,
substream_id: self.current_inbound_substream_id,
r#type: req,
})));
Expand Down
14 changes: 14 additions & 0 deletions beacon_node/lighthouse_network/src/rpc/methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,20 @@ pub enum ResponseTermination {
LightClientUpdatesByRange,
}

impl ResponseTermination {
pub fn protocol(&self) -> Protocol {
match self {
ResponseTermination::BlocksByRange => Protocol::BlocksByRange,
ResponseTermination::BlocksByRoot => Protocol::BlocksByRoot,
ResponseTermination::BlobsByRange => Protocol::BlobsByRange,
ResponseTermination::BlobsByRoot => Protocol::BlobsByRoot,
ResponseTermination::DataColumnsByRoot => Protocol::DataColumnsByRoot,
ResponseTermination::DataColumnsByRange => Protocol::DataColumnsByRange,
ResponseTermination::LightClientUpdatesByRange => Protocol::LightClientUpdatesByRange,
}
}
}

/// The structured response containing a result/code indicating success or failure
/// and the contents of the response
#[derive(Debug, Clone)]
Expand Down
Loading