Skip to content

Commit 6f41c4c

Browse files
authored
Merge pull request #371 from blinklabs-io/feat/update-handshake-versions
feat: update handshake versions
2 parents 13fd829 + ddbc348 commit 6f41c4c

File tree

4 files changed

+68
-27
lines changed

4 files changed

+68
-27
lines changed

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ volumes:
55

66
services:
77
cardano-node:
8-
image: ghcr.io/blinklabs-io/cardano-node:1.35.7
8+
image: ghcr.io/blinklabs-io/cardano-node:8.1.2
99
environment:
1010
NETWORK: ${CARDANO_NETWORK:-preview}
1111
ports:

protocol/handshake/client.go

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -72,16 +72,18 @@ func (c *Client) Start() {
7272
}
7373
for _, version := range c.config.ProtocolVersions {
7474
if c.Mode() == protocol.ProtocolModeNodeToNode {
75-
// NOTE: it seems that protocol version 11 is still in flux, so we disable for now
76-
/*
77-
if version >= 11 {
78-
// TODO: make peer sharing mode configurable
79-
versionMap[version] = []interface{}{c.config.NetworkMagic, diffusionMode, PeerSharingModePeerSharingPrivate}
80-
} else {
81-
*/
82-
versionMap[version] = []interface{}{c.config.NetworkMagic, diffusionMode}
75+
if version >= 11 {
76+
// TODO: make peer sharing mode configurable once it actually works
77+
versionMap[version] = []interface{}{c.config.NetworkMagic, diffusionMode, PeerSharingModeNoPeerSharing, QueryModeDisabled}
78+
} else {
79+
versionMap[version] = []interface{}{c.config.NetworkMagic, diffusionMode}
80+
}
8381
} else {
84-
versionMap[version] = c.config.NetworkMagic
82+
if (version - NodeToClientVersionOffset) >= 15 {
83+
versionMap[version] = []any{c.config.NetworkMagic, QueryModeDisabled}
84+
} else {
85+
versionMap[version] = c.config.NetworkMagic
86+
}
8587
}
8688
}
8789
msg := NewMsgProposeVersions(versionMap)

protocol/handshake/handshake.go

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,26 @@ const (
2929

3030
// Diffusion modes
3131
const (
32-
DiffusionModeInitiatorOnly = false
33-
DiffusionModeInitiatorAndResponder = true
32+
DiffusionModeInitiatorOnly = true
33+
DiffusionModeInitiatorAndResponder = false
3434
)
3535

3636
// Peer sharing modes
3737
const (
3838
PeerSharingModeNoPeerSharing = 0
39-
PeerSharingModePeerSharingPublic = 1
40-
PeerSharingModePeerSharingPrivate = 2
39+
PeerSharingModePeerSharingPrivate = 1
40+
PeerSharingModePeerSharingPublic = 2
4141
)
4242

43+
// Query modes
44+
const (
45+
QueryModeDisabled = false
46+
QueryModeEnabled = true
47+
)
48+
49+
// NtC version numbers have the 15th bit set
50+
const NodeToClientVersionOffset = 0x8000
51+
4352
var (
4453
statePropose = protocol.NewState(1, "Propose")
4554
stateConfirm = protocol.NewState(2, "Confirm")

versions.go

Lines changed: 43 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ type ProtocolVersionNtC struct {
2626
EnableMaryEra bool
2727
EnableAlonzoEra bool
2828
EnableBabbageEra bool
29+
EnableConwayEra bool
2930
EnableLocalTxMonitorProtocol bool
3031
}
3132

@@ -83,6 +84,26 @@ var protocolVersionMapNtC = map[uint16]ProtocolVersionNtC{
8384
EnableBabbageEra: true,
8485
EnableLocalTxMonitorProtocol: true,
8586
},
87+
// added query param to handshake
88+
15: ProtocolVersionNtC{
89+
EnableLocalQueryProtocol: true,
90+
EnableShelleyEra: true,
91+
EnableAllegraEra: true,
92+
EnableMaryEra: true,
93+
EnableAlonzoEra: true,
94+
EnableBabbageEra: true,
95+
EnableLocalTxMonitorProtocol: true,
96+
},
97+
16: ProtocolVersionNtC{
98+
EnableLocalQueryProtocol: true,
99+
EnableShelleyEra: true,
100+
EnableAllegraEra: true,
101+
EnableMaryEra: true,
102+
EnableAlonzoEra: true,
103+
EnableBabbageEra: true,
104+
EnableConwayEra: true,
105+
EnableLocalTxMonitorProtocol: true,
106+
},
86107
}
87108

88109
type ProtocolVersionNtN struct {
@@ -94,6 +115,7 @@ type ProtocolVersionNtN struct {
94115
EnableMaryEra bool
95116
EnableAlonzoEra bool
96117
EnableBabbageEra bool
118+
EnableConwayEra bool
97119
EnableFullDuplex bool
98120
EnablePeerSharingProtocol bool
99121
}
@@ -133,19 +155,27 @@ var protocolVersionMapNtN = map[uint16]ProtocolVersionNtN{
133155
EnableBabbageEra: true,
134156
EnableFullDuplex: true,
135157
},
136-
// NOTE: this protocol version seems to still be in flux, so it's disabled for now
137-
/*
138-
11: ProtocolVersionNtN{
139-
EnableShelleyEra: true,
140-
EnableKeepAliveProtocol: true,
141-
EnableAllegraEra: true,
142-
EnableMaryEra: true,
143-
EnableAlonzoEra: true,
144-
EnableBabbageEra: true,
145-
EnableFullDuplex: true,
146-
EnablePeerSharingProtocol: true,
147-
},
148-
*/
158+
11: ProtocolVersionNtN{
159+
EnableShelleyEra: true,
160+
EnableKeepAliveProtocol: true,
161+
EnableAllegraEra: true,
162+
EnableMaryEra: true,
163+
EnableAlonzoEra: true,
164+
EnableBabbageEra: true,
165+
EnableFullDuplex: true,
166+
EnablePeerSharingProtocol: true,
167+
},
168+
12: ProtocolVersionNtN{
169+
EnableShelleyEra: true,
170+
EnableKeepAliveProtocol: true,
171+
EnableAllegraEra: true,
172+
EnableMaryEra: true,
173+
EnableAlonzoEra: true,
174+
EnableBabbageEra: true,
175+
EnableConwayEra: true,
176+
EnableFullDuplex: true,
177+
EnablePeerSharingProtocol: true,
178+
},
149179
}
150180

151181
// GetProtocolVersionNtC returns a list of supported NtC protocol versions

0 commit comments

Comments
 (0)