Merge branch 'deneb-merge-from-unstable-20230627' of github.com:jimmygchen/lighthouse into deneb-merge-from-unstable-20230627

This commit is contained in:
Jimmy Chen 2023-06-28 16:26:38 +10:00
commit 5c4485e45e
No known key found for this signature in database
GPG Key ID: 7AAEE02659DCF690
4 changed files with 23 additions and 10 deletions

View File

@ -309,7 +309,7 @@ impl<TSpec: EthSpec> Decoder for SSZSnappyOutboundCodec<TSpec> {
let _read_bytes = src.split_to(n as usize);
// Safe to `take` from `self.fork_name` as we have all the bytes we need to
// decode an ssz object at this point.
let fork_name = &mut self.fork_name.take();
let fork_name = self.fork_name.take();
handle_rpc_response(self.protocol.versioned_protocol, &decoded_buffer, fork_name)
}
Err(e) => handle_error(e, reader.get_ref().get_ref().position(), max_compressed_len),
@ -530,7 +530,7 @@ fn handle_rpc_request<T: EthSpec>(
fn handle_rpc_response<T: EthSpec>(
versioned_protocol: SupportedProtocol,
decoded_buffer: &[u8],
fork_name: &mut Option<ForkName>,
mut fork_name: Option<ForkName>,
) -> Result<Option<RPCResponse<T>>, RPCError> {
match versioned_protocol {
SupportedProtocol::StatusV1 => Ok(Some(RPCResponse::Status(

View File

@ -7,7 +7,6 @@ use super::protocol::{max_rpc_size, InboundRequest, Protocol, RPCError, RPCProto
use super::{RPCReceived, RPCSend, ReqId};
use crate::rpc::outbound::{OutboundFramed, OutboundRequest};
use crate::rpc::protocol::InboundFramed;
use crate::rpc::ResponseTermination;
use fnv::FnvHashMap;
use futures::prelude::*;
use futures::{Sink, SinkExt};
@ -934,13 +933,8 @@ where
// continue sending responses beyond what we would expect. Here
// we simply terminate the stream and report a stream
// termination to the application
let termination = match protocol {
Protocol::BlocksByRange => Some(ResponseTermination::BlocksByRange),
Protocol::BlocksByRoot => Some(ResponseTermination::BlocksByRoot),
_ => None, // all other protocols are do not have multiple responses and we do not inform the user, we simply drop the stream.
};
if let Some(termination) = termination {
if let Some(termination) = protocol.terminator() {
return Poll::Ready(ConnectionHandlerEvent::Custom(Ok(
RPCReceived::EndOfStream(request_id, termination),
)));

View File

@ -340,7 +340,10 @@ impl OldBlocksByRangeRequest {
}
/// Request a number of beacon block bodies from a peer.
#[superstruct(variants(V1, V2), variant_attributes(derive(Clone, Debug, PartialEq)))]
#[superstruct(
variants(V1, V2),
variant_attributes(derive(Encode, Decode, Clone, Debug, PartialEq))
)]
#[derive(Clone, Debug, PartialEq)]
pub struct BlocksByRootRequest {
/// The list of beacon block bodies being requested.

View File

@ -205,6 +205,22 @@ pub enum Protocol {
LightClientBootstrap,
}
impl Protocol {
pub(crate) fn terminator(self) -> Option<ResponseTermination> {
match self {
Protocol::Status => None,
Protocol::Goodbye => None,
Protocol::BlocksByRange => Some(ResponseTermination::BlocksByRange),
Protocol::BlocksByRoot => Some(ResponseTermination::BlocksByRoot),
Protocol::BlobsByRange => Some(ResponseTermination::BlobsByRange),
Protocol::BlobsByRoot => Some(ResponseTermination::BlobsByRoot),
Protocol::Ping => None,
Protocol::MetaData => None,
Protocol::LightClientBootstrap => None,
}
}
}
/// RPC Encondings supported.
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum Encoding {