From ac0eb39ceda492463dae7e968926789da05a4741 Mon Sep 17 00:00:00 2001 From: realbigsean Date: Wed, 15 Mar 2023 01:27:46 +0000 Subject: [PATCH] Complete match for `has_context_bytes` (#3972) ## Issue Addressed - Add a complete match for `Protocol` here. - The incomplete match was causing us not to append context bytes to the light client protocols - This is the relevant part of the spec and it looks like context bytes are defined https://github.com/ethereum/consensus-specs/blob/dev/specs/altair/light-client/p2p-interface.md#getlightclientbootstrap Disclaimer: I have no idea if people are using it but it shouldn't have been working so not sure why it wasn't caught Co-authored-by: realbigsean --- .../lighthouse_network/src/rpc/protocol.rs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/beacon_node/lighthouse_network/src/rpc/protocol.rs b/beacon_node/lighthouse_network/src/rpc/protocol.rs index 8d7b22029..a8423e47b 100644 --- a/beacon_node/lighthouse_network/src/rpc/protocol.rs +++ b/beacon_node/lighthouse_network/src/rpc/protocol.rs @@ -344,13 +344,16 @@ impl ProtocolId { /// Returns `true` if the given `ProtocolId` should expect `context_bytes` in the /// beginning of the stream, else returns `false`. pub fn has_context_bytes(&self) -> bool { - if self.version == Version::V2 { - match self.message_name { - Protocol::BlocksByRange | Protocol::BlocksByRoot => return true, - _ => return false, - } + match self.message_name { + Protocol::BlocksByRange | Protocol::BlocksByRoot => match self.version { + Version::V2 => true, + Version::V1 => false, + }, + Protocol::LightClientBootstrap => match self.version { + Version::V2 | Version::V1 => true, + }, + Protocol::Goodbye | Protocol::Ping | Protocol::Status | Protocol::MetaData => false, } - false } }