Skip to content

Commit cc94686

Browse files
committed
Merge branch 'rpc_testing_2' into lc-reqresp
2 parents 1458178 + 1e92a3f commit cc94686

File tree

7 files changed

+1012
-24
lines changed

7 files changed

+1012
-24
lines changed

beacon_node/lighthouse_network/src/rpc/codec/mod.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
pub(crate) mod base;
22
pub(crate) mod ssz_snappy;
33

4-
use self::base::{BaseInboundCodec, BaseOutboundCodec};
5-
use self::ssz_snappy::{SSZSnappyInboundCodec, SSZSnappyOutboundCodec};
4+
use self::base::BaseInboundCodec;
5+
pub use self::base::BaseOutboundCodec;
6+
use self::ssz_snappy::SSZSnappyInboundCodec;
7+
pub use self::ssz_snappy::SSZSnappyOutboundCodec;
68
use crate::rpc::protocol::RPCError;
79
use crate::rpc::{InboundRequest, OutboundRequest, RPCCodedResponse};
810
use libp2p::bytes::BytesMut;

beacon_node/lighthouse_network/src/rpc/handler.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ const MAX_INBOUND_SUBSTREAMS: usize = 32;
4545

4646
/// Identifier of inbound and outbound substreams from the handler's perspective.
4747
#[derive(Debug, Clone, Copy, Hash, Eq, PartialEq)]
48-
pub struct SubstreamId(usize);
48+
pub struct SubstreamId(pub usize);
4949

5050
type InboundSubstream<TSpec> = InboundFramed<NegotiatedSubstream, TSpec>;
5151

@@ -133,7 +133,7 @@ where
133133
log: slog::Logger,
134134
}
135135

136-
enum HandlerState {
136+
pub enum HandlerState {
137137
/// The handler is active. All messages are sent and received.
138138
Active,
139139
/// The handler is shutting_down.
@@ -164,17 +164,17 @@ struct InboundInfo<TSpec: EthSpec> {
164164
}
165165

166166
/// Contains the information the handler keeps on established outbound substreams.
167-
struct OutboundInfo<Id, TSpec: EthSpec> {
167+
pub struct OutboundInfo<Id, TSpec: EthSpec> {
168168
/// State of the substream.
169-
state: OutboundSubstreamState<TSpec>,
169+
pub state: OutboundSubstreamState<TSpec>,
170170
/// Key to keep track of the substream's timeout via `self.outbound_substreams_delay`.
171-
delay_key: delay_queue::Key,
171+
pub delay_key: delay_queue::Key,
172172
/// Info over the protocol this substream is handling.
173-
proto: Protocol,
173+
pub proto: Protocol,
174174
/// Number of chunks to be seen from the peer's response.
175-
remaining_chunks: Option<u64>,
175+
pub remaining_chunks: Option<u64>,
176176
/// `Id` as given by the application that sent the request.
177-
req_id: Id,
177+
pub req_id: Id,
178178
}
179179

180180
/// State of an inbound substream connection.

beacon_node/lighthouse_network/src/rpc/mod.rs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
//! syncing.
66
77
use futures::future::FutureExt;
8-
use handler::{HandlerEvent, RPCHandler};
98
use libp2p::core::connection::ConnectionId;
109
use libp2p::swarm::{
1110
handler::ConnectionHandler, NetworkBehaviour, NetworkBehaviourAction, NotifyHandler,
@@ -20,17 +19,23 @@ use std::task::{Context, Poll};
2019
use std::time::Duration;
2120
use types::{EthSpec, ForkContext};
2221

23-
pub(crate) use handler::HandlerErr;
2422
pub(crate) use methods::{MetaData, MetaDataV1, MetaDataV2, Ping, RPCCodedResponse, RPCResponse};
25-
pub(crate) use protocol::{InboundRequest, RPCProtocol};
23+
pub(crate) use protocol::InboundRequest;
2624

27-
pub use handler::SubstreamId;
25+
pub use codec::{BaseOutboundCodec, OutboundCodec, SSZSnappyOutboundCodec};
26+
pub use handler::{
27+
HandlerErr, HandlerEvent, HandlerState,
28+
OutboundInfo, OutboundSubstreamState, RPCHandler, SubstreamId,
29+
};
2830
pub use methods::{
2931
BlocksByRangeRequest, BlocksByRootRequest, GoodbyeReason, LightClientBootstrapRequest, MaxRequestBlocks,
3032
RPCResponseErrorCode, ResponseTermination, StatusMessage, MAX_REQUEST_BLOCKS,
3133
};
32-
pub(crate) use outbound::OutboundRequest;
33-
pub use protocol::{max_rpc_size, Protocol, RPCError};
34+
pub use outbound::OutboundFramed;
35+
pub use outbound::OutboundRequest;
36+
pub use protocol::{
37+
max_rpc_size, Encoding, Protocol, ProtocolId, RPCError, RPCProtocol, Version,
38+
};
3439

3540
use self::config::OutboundRateLimiterConfig;
3641
use self::self_limiter::SelfRateLimiter;

beacon_node/lighthouse_network/src/rpc/protocol.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -352,10 +352,7 @@ impl ProtocolId {
352352
<MetaDataV1<T> as Encode>::ssz_fixed_len(),
353353
<MetaDataV2<T> as Encode>::ssz_fixed_len(),
354354
),
355-
Protocol::LightClientBootstrap => RpcLimits::new(
356-
<LightClientBootstrapRequest as Encode>::ssz_fixed_len(),
357-
<LightClientBootstrapRequest as Encode>::ssz_fixed_len(),
358-
),
355+
Protocol::LightClientBootstrap => rpc_block_limits_by_fork(fork_context.current_fork()),
359356
Protocol::LightClientOptimisticUpdate => RpcLimits::new(
360357
<LightClientOptimisticUpdate<T> as Encode>::ssz_fixed_len(),
361358
<LightClientOptimisticUpdate<T> as Encode>::ssz_fixed_len(),

0 commit comments

Comments
 (0)