Skip to content

feat: update handshake versions #371

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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