Skip to content

Conversation

@0xKarl98
Copy link
Contributor

@0xKarl98 0xKarl98 commented Nov 21, 2025

This is on issue #19882 #19883
Changes as bellow :

  • Introduce a snap capability toggle: with_snap on HelloMessage/NetworkConfigBuilder to optionally announce snap/1 during handshake
  • Extend the protocol stack to snap: use EthSnapStream as the combined eth+snap stream; add snap request/response enums and route them via PeerMessage::SnapRequest
  • Added snap RawCapability encoding tests and snap toggle test
  • Snap requests currently return noop/empty responses to keep the pipeline stable while integration lands

cc @mattsse

Copy link
Collaborator

@mattsse mattsse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks amazing already

I have a few more questions and smol requests

still need to look into this in detail

PooledTransactions(NewPooledTransactionHashes),
/// All `eth` request variants.
EthRequest(PeerRequest<N>),
/// All `snap` request variants (wrapped in `PeerRequest`).
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we even need this additional variant if we added snap variants to peerrequest?

Copy link
Contributor Author

@0xKarl98 0xKarl98 Nov 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right , agree that this is redundant

The snap requests would flow the same if we just sent them via PeerMessage::EthRequest because the inner PeerRequest discriminates the snap cases.

Comment on lines +667 to +669
if snap_enabled {
hello_message = hello_message.with_snap();
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool, this should do it

direction,
error: Some(PendingSessionHandshakeError::Eth(err)),
let supports_snap =
multiplex_stream.shared_capabilities().iter_caps().any(|cap| cap.name() == "snap");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we add a helper type for this on sharecap?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good idea

Comment on lines 199 to 204
// Sending snap message over eth-only connection is unsupported
(
EthRlpxConnProj::EthOnly(_) | EthRlpxConnProj::Satellite(_),
EthSnapMessage::Snap(_),
) => Err(EthStreamError::UnsupportedMessage {
message_id: SnapMessageId::GetAccountRange as u8,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this should fail regardless

type Error = EthStreamError;

fn poll_ready(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
delegate_call!(self.poll_ready(cx))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why can we no longer use this macro?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think dropping it is a right call , as delegate_call! is for single-field delegation , can’t express the current per-variant behavior .

mut self,
cap: &Capability,
handshake: F,
additional_caps: Vec<SharedCapability>,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this needed now?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need it so the primary stream can own more than one capability (e.g., eth + snap). additional_caps tells the multiplexer to route those extra capabilities to the primary; without it, only the main cap goes to primary and snap messages would be treated as “non-primary” and misrouted.

@github-project-automation github-project-automation bot moved this from Backlog to In Progress in Reth Tracker Nov 21, 2025
@mattsse mattsse added C-enhancement New feature or request A-devp2p Related to the Ethereum P2P protocol labels Nov 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-devp2p Related to the Ethereum P2P protocol C-enhancement New feature or request

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

2 participants