From ddbc34808059f1fb5e9b7a7a0e2095f08da5c414 Mon Sep 17 00:00:00 2001 From: Aurora Gaffney Date: Wed, 16 Aug 2023 15:46:24 -0500 Subject: [PATCH] feat: update handshake versions --- docker-compose.yml | 2 +- protocol/handshake/client.go | 20 ++++++------ protocol/handshake/handshake.go | 17 +++++++--- versions.go | 56 +++++++++++++++++++++++++-------- 4 files changed, 68 insertions(+), 27 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 1d53d85b..502ff3fe 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,7 +5,7 @@ volumes: services: cardano-node: - image: ghcr.io/blinklabs-io/cardano-node:1.35.7 + image: ghcr.io/blinklabs-io/cardano-node:8.1.2 environment: NETWORK: ${CARDANO_NETWORK:-preview} ports: diff --git a/protocol/handshake/client.go b/protocol/handshake/client.go index 9629fb8b..284dfb77 100644 --- a/protocol/handshake/client.go +++ b/protocol/handshake/client.go @@ -72,16 +72,18 @@ func (c *Client) Start() { } for _, version := range c.config.ProtocolVersions { if c.Mode() == protocol.ProtocolModeNodeToNode { - // NOTE: it seems that protocol version 11 is still in flux, so we disable for now - /* - if version >= 11 { - // TODO: make peer sharing mode configurable - versionMap[version] = []interface{}{c.config.NetworkMagic, diffusionMode, PeerSharingModePeerSharingPrivate} - } else { - */ - versionMap[version] = []interface{}{c.config.NetworkMagic, diffusionMode} + if version >= 11 { + // TODO: make peer sharing mode configurable once it actually works + versionMap[version] = []interface{}{c.config.NetworkMagic, diffusionMode, PeerSharingModeNoPeerSharing, QueryModeDisabled} + } else { + versionMap[version] = []interface{}{c.config.NetworkMagic, diffusionMode} + } } else { - versionMap[version] = c.config.NetworkMagic + if (version - NodeToClientVersionOffset) >= 15 { + versionMap[version] = []any{c.config.NetworkMagic, QueryModeDisabled} + } else { + versionMap[version] = c.config.NetworkMagic + } } } msg := NewMsgProposeVersions(versionMap) diff --git a/protocol/handshake/handshake.go b/protocol/handshake/handshake.go index 3b6588c6..105f2328 100644 --- a/protocol/handshake/handshake.go +++ b/protocol/handshake/handshake.go @@ -29,17 +29,26 @@ const ( // Diffusion modes const ( - DiffusionModeInitiatorOnly = false - DiffusionModeInitiatorAndResponder = true + DiffusionModeInitiatorOnly = true + DiffusionModeInitiatorAndResponder = false ) // Peer sharing modes const ( PeerSharingModeNoPeerSharing = 0 - PeerSharingModePeerSharingPublic = 1 - PeerSharingModePeerSharingPrivate = 2 + PeerSharingModePeerSharingPrivate = 1 + PeerSharingModePeerSharingPublic = 2 ) +// Query modes +const ( + QueryModeDisabled = false + QueryModeEnabled = true +) + +// NtC version numbers have the 15th bit set +const NodeToClientVersionOffset = 0x8000 + var ( statePropose = protocol.NewState(1, "Propose") stateConfirm = protocol.NewState(2, "Confirm") diff --git a/versions.go b/versions.go index 01b355ce..49bcd4b5 100644 --- a/versions.go +++ b/versions.go @@ -26,6 +26,7 @@ type ProtocolVersionNtC struct { EnableMaryEra bool EnableAlonzoEra bool EnableBabbageEra bool + EnableConwayEra bool EnableLocalTxMonitorProtocol bool } @@ -83,6 +84,26 @@ var protocolVersionMapNtC = map[uint16]ProtocolVersionNtC{ EnableBabbageEra: true, EnableLocalTxMonitorProtocol: true, }, + // added query param to handshake + 15: ProtocolVersionNtC{ + EnableLocalQueryProtocol: true, + EnableShelleyEra: true, + EnableAllegraEra: true, + EnableMaryEra: true, + EnableAlonzoEra: true, + EnableBabbageEra: true, + EnableLocalTxMonitorProtocol: true, + }, + 16: ProtocolVersionNtC{ + EnableLocalQueryProtocol: true, + EnableShelleyEra: true, + EnableAllegraEra: true, + EnableMaryEra: true, + EnableAlonzoEra: true, + EnableBabbageEra: true, + EnableConwayEra: true, + EnableLocalTxMonitorProtocol: true, + }, } type ProtocolVersionNtN struct { @@ -94,6 +115,7 @@ type ProtocolVersionNtN struct { EnableMaryEra bool EnableAlonzoEra bool EnableBabbageEra bool + EnableConwayEra bool EnableFullDuplex bool EnablePeerSharingProtocol bool } @@ -133,19 +155,27 @@ var protocolVersionMapNtN = map[uint16]ProtocolVersionNtN{ EnableBabbageEra: true, EnableFullDuplex: true, }, - // NOTE: this protocol version seems to still be in flux, so it's disabled for now - /* - 11: ProtocolVersionNtN{ - EnableShelleyEra: true, - EnableKeepAliveProtocol: true, - EnableAllegraEra: true, - EnableMaryEra: true, - EnableAlonzoEra: true, - EnableBabbageEra: true, - EnableFullDuplex: true, - EnablePeerSharingProtocol: true, - }, - */ + 11: ProtocolVersionNtN{ + EnableShelleyEra: true, + EnableKeepAliveProtocol: true, + EnableAllegraEra: true, + EnableMaryEra: true, + EnableAlonzoEra: true, + EnableBabbageEra: true, + EnableFullDuplex: true, + EnablePeerSharingProtocol: true, + }, + 12: ProtocolVersionNtN{ + EnableShelleyEra: true, + EnableKeepAliveProtocol: true, + EnableAllegraEra: true, + EnableMaryEra: true, + EnableAlonzoEra: true, + EnableBabbageEra: true, + EnableConwayEra: true, + EnableFullDuplex: true, + EnablePeerSharingProtocol: true, + }, } // GetProtocolVersionNtC returns a list of supported NtC protocol versions