[go: up one dir, main page]

Gossipsub: control message every n hearthbeat

What

  • Add a p2p Ping whose encoding is equivalent to a Subscribe message with the following payload, where tz1Ke2h7sDdakHJQh8WX4Z372du1KChsksyU is the zero/null address.
  let ping_topic =
    Types.Topic.
      {
        slot_index = 0;
        pkh = Signature.Public_key_hash.zero;
      }
  • Add an issue #7768 (closed) to integrate the Ping message when bumping the p2p message version
  • Add an issue for implementing metrics for the Ping message #7770 (closed)
  • Add periodic emission of Subscribe messages for topics the DAL node is subscribed to every 45s. The chosen value is motivated by the following text.
  (* The ping should be performed by the heartbeat handler at least
     every 45s, hence every [heartbeat_ping_interval] ticks when_
     [heartbeat_interval] = 1s.

     A 45-second ping interval is a reasonable choice as it sits in
     the middle of the commonly recommended 30-60 second range for P2P
     networks.

     This timing provides a good balance between maintaining
     reliable connections and managing network overhead.

     It's frequent enough to detect stale peers before most
     NAT/firewall timeouts (which typically occur after 60-120
     seconds)
  *)

Why

  • Improves network resilience by ensuring subscription state remains consistent across peers

How

  • Added a new heartbeat interval constant hearbeat_ping_interval set to 180s in terms of hearbeat_interval
  • During each heartbeat, check if heartbeat_ticks mod hearbeat_ping_interval = 0
    • If it is, iterate through all connections and emit a Ping message to each peer
  • Reuse existing emit_p2p_message function to send the Ping messages

Manually testing the MR

Checklist

  • Document the interface of any function added or modified (see the coding guidelines)
  • Document any change to the user interface, including configuration parameters (see node configuration)
  • Provide automatic testing (see the testing guide).
  • For new features and bug fixes, add an item in the appropriate changelog (docs/protocols/alpha.rst for the protocol and the environment, CHANGES.rst at the root of the repository for everything else).
  • Select suitable reviewers using the Reviewers field below.
  • Select as Assignee the next person who should take action on that MR
Edited by Paul Laforgue

Merge request reports

Loading