Skip to content

Commit

Permalink
Complete match for has_context_bytes (#3972)
Browse files Browse the repository at this point in the history
## 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 <seananderson33@gmail.com>
  • Loading branch information
realbigsean and realbigsean committed Feb 28, 2023
1 parent b69edfd commit 8ff17b0
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions beacon_node/lighthouse_network/src/rpc/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -372,13 +372,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
}
}

Expand Down

0 comments on commit 8ff17b0

Please sign in to comment.