aztec-packages icon indicating copy to clipboard operation
aztec-packages copied to clipboard

[FEATURE] Improve P2P Status Message

Open mralj opened this issue 7 months ago • 0 comments

Problem Statement

P2P Status message should be upgraded to Status handshake.

Proposed Solution

The Status handshake should work similarly to the Ethereum Beacon client Status handshake, i.e.

  1. The Status message MUST be the first message exchanged between peers (in both directions).
  2. The Status message MUST pass validation*.
  3. If the Status handshake validation fails, the peer MUST be disconnected. Depending on the reason, the peer SHOULD be banned**.
  4. Any other messages SHOULD NOT be exchanged until the Status handshake is validated.

Status message content

  1. compressedComponentsVersion
  2. latestBlockNumber
  3. latestBlockHash
  4. finalizedBlockNumber
  5. finalizedBlockHash

*Status message validation

Again, the validation should mimic the one implemented on Ethereum Beacon Chain (link):

  1. CompressedComponentsVersion MUST be valid and equal
  2. latestBlockHash and finalizedBlockHash MUST be valid (check against the current node's values) 2.1. Our node might be out of sync and not have these values. If the sent numbers are equal to or smaller than our node's, we should ensure they exist and correspond to the correct block numbers. Otherwise, we might be out of sync and should skip this check.

NOTE: In the future, we can upgrade the P2P service as follows:

  1. If latestBlockNumber and finalizedBlockNumber have a difference larger than D (e.g., 100) from the current node's values, disconnect this peer. The reason is that either our peer or our node is synced, so they should not participate in P2P exchange while the sync is in progress.

**Reasons for banning

  1. Status message not received
  2. CompressedComponentsVersion invalid

Example Use Case

No response

Alternative Solutions

No response

Additional Context

No response

mralj avatar May 19 '25 15:05 mralj