Open
Conversation
iamquang95
reviewed
Apr 30, 2026
| && let Some(peer) = self.relay_peers.get(&peer_id).cloned() | ||
| { | ||
| self.pending_relays.remove(&peer_id); | ||
| Self::queue_relay_dial( |
Collaborator
There was a problem hiding this comment.
This should have a back-off delay: https://github.com/ObolNetwork/charon/blob/v1.7.1/p2p/relay.go#L47
| } | ||
|
|
||
| /// Encodes bytes as lowercase `0x`-prefixed hex. | ||
| /// In case of empty bytes, returns an empty string. |
Collaborator
There was a problem hiding this comment.
This change will affect the eth2util serialization.
From here: https://github.com/NethermindEth/pluto/blob/main/crates/eth2api/src/spec/bellatrix.rs#L121
The bellatrix extra_data use the Hex0x which uses encode_0x_hex.
In go-eth2-client, this field expect "0x" when the extra_data is empty: https://github.com/attestantio/go-eth2-client/blob/master/spec/bellatrix/executionpayload.go#L91
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes several bugs discovered during DKG integration testing, primarily around relay connection lifecycle management in the P2P layer.
Relay reconnection on disconnect / dial failure (
relay.rs)Previously, if a relay connection dropped or a dial attempt failed, the node would not attempt to re-establish the connection, leaving it permanently unable to route traffic through that relay.
relay_peers: HashMap<PeerId, Peer>toMutableRelayReservationto remember all known relay peers so they can be re-dialed when a connection is lost.connected_relays: HashSet<PeerId>to skip redundant dials when a connection is already established or in-flight.on_swarm_eventnow handlesConnectionClosed(last connection dropped) andDialFailureto trigger a re-dial, clearing stale pending/connected state first.DialOpts::unknown_peer_id()toDialOpts::peer_id(...).condition(DisconnectedAndNotDialing)so libp2p can deduplicate concurrent dial attempts.Relay-ready settling delay (
relay.rs)RelayRouterwas immediately attempting to route peers through a relay the moment the connection was established, before the relay reservation handshake could complete. This caused circuit-dial attempts to fail silently.connected_relays: HashMap<PeerId, Instant>toRelayRouterto record when each relay became connected.relay_ready()which gates routing behind a 2-secondRELAY_READY_DELAYso the reservation handshake has time to finish.RelayRouter::run_relay_routernow iterates overconnected_relays(only relays with an active connection) instead of all configured relays, and skips any that haven't settled yet.DisconnectedAndNotDialingto avoid redundant dial attempts.Fix malformed circuit multiaddresses (
relay.rs,utils.rs)Relay peer addresses stored in the
Peerstruct sometimes already included a trailing/p2p/<peer-id>component. Appending another/p2p/<relay-id>/p2p-circuit(or/p2p-circuit/p2p/<target-id>) on top produced invalid multiaddresses that libp2p silently rejected.queue_relay_dialandmulti_addrs_via_relaynow strip any existing/p2p/...protocol components from the base address before constructing circuit or direct-dial addresses.Fix
encode_0x_hexfor empty input (serde_utils.rs)encode_0x_hex(&[])previously returned"0x"instead of"", which caused downstream deserialization failures for optional byte fields encoded as empty strings.