Skip to content

Commit

Permalink
Complete match for has_context_bytes (sigp#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
2 people authored and Woodpile37 committed Jan 6, 2024
1 parent 466b4e1 commit 372ff9e
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions beacon_node/lighthouse_network/src/rpc/protocol.rs
Expand Up @@ -365,13 +365,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 372ff9e

Please sign in to comment.