Skip to content

feat(p2p): introduce new EchoPing and EchoPong message types - #1782

Closed
pbeza wants to merge 1 commit into
mainfrom
1781-introduce-new-pingpong-message-types
Closed

pbeza wants to merge 1 commit into
mainfrom
1781-introduce-new-pingpong-message-types

Conversation

@pbeza

@pbeza pbeza commented Jan 16, 2026

Copy link
Copy Markdown
Contributor

Fixes #1781

@pbeza pbeza linked an issue Jan 16, 2026 that may be closed by this pull request
@pbeza
pbeza requested a review from netrome January 16, 2026 13:39
@pbeza
pbeza marked this pull request as ready for review January 16, 2026 13:39
Copilot AI review requested due to automatic review settings January 16, 2026 13:39

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces two new P2P message types, EchoPing and EchoPong, to support future ping-pong functionality for measuring network latency between MPC nodes. The changes add these message variants to the Packet enum and update the packet handling logic to recognize (but currently ignore) them.

Changes:

  • Added EchoPing(u64) and EchoPong(u64) message variants to the Packet enum
  • Updated packet handling to recognize these new message types alongside the existing Ping message
  • Added a comment explaining that these messages are recognized but not yet acted upon pending a future PR

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread crates/node/src/p2p.rs
Packet::Ping => {
Packet::Ping | Packet::EchoPing(_) | Packet::EchoPong(_) => {
// Do nothing. Pings are just for TCP keepalive.
// EchoPing/EchoPong are recognized but ignored until https://github.com/near/mpc/pull/1687 is merged.

Copilot AI Jan 16, 2026

Copy link

Choose a reason for hiding this comment

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

The comment references PR #1687, but the PR description says this fixes #1781. Please verify the correct issue/PR number is referenced in the comment.

Suggested change
// EchoPing/EchoPong are recognized but ignored until https://github.com/near/mpc/pull/1687 is merged.
// EchoPing/EchoPong are recognized but currently ignored until dedicated handling is implemented.

Copilot uses AI. Check for mistakes.
Comment thread crates/node/src/p2p.rs
.context("Failed to deserialize packet")?;
match packet {
Packet::Ping => {
Packet::Ping | Packet::EchoPing(_) | Packet::EchoPong(_) => {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think we should respond to ping messages in this one, otherwise new nodes won't get the expected pong messages and they will close the connection.

@pbeza

pbeza commented Jan 16, 2026

Copy link
Copy Markdown
Contributor Author

Closing this as discussed here.

Instead, we’ll simply avoid sending pings to nodes that don’t support the new protocol version, which we can determine during the handshake.

@pbeza pbeza closed this Jan 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Introduce new Ping/Pong message types

4 participants