Skip to content

Commit

Permalink
Merge pull request #371 from blinklabs-io/feat/update-handshake-versions
Browse files Browse the repository at this point in the history
feat: update handshake versions
  • Loading branch information
agaffney authored Aug 18, 2023
2 parents 13fd829 + ddbc348 commit 6f41c4c
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 27 deletions.
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
20 changes: 11 additions & 9 deletions protocol/handshake/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
17 changes: 13 additions & 4 deletions protocol/handshake/handshake.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
56 changes: 43 additions & 13 deletions versions.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ type ProtocolVersionNtC struct {
EnableMaryEra bool
EnableAlonzoEra bool
EnableBabbageEra bool
EnableConwayEra bool
EnableLocalTxMonitorProtocol bool
}

Expand Down Expand Up @@ -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 {
Expand All @@ -94,6 +115,7 @@ type ProtocolVersionNtN struct {
EnableMaryEra bool
EnableAlonzoEra bool
EnableBabbageEra bool
EnableConwayEra bool
EnableFullDuplex bool
EnablePeerSharingProtocol bool
}
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 6f41c4c

Please sign in to comment.