Skip to content

Commit

Permalink
feat: update handshake versions
Browse files Browse the repository at this point in the history
  • Loading branch information
agaffney committed Aug 16, 2023
1 parent 199fc0e commit c0174ef
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 22 deletions.
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
versionMap[version] = []interface{}{c.config.NetworkMagic, diffusionMode, PeerSharingModePeerSharingPrivate, 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
9 changes: 9 additions & 0 deletions protocol/handshake/handshake.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,15 @@ const (
PeerSharingModePeerSharingPrivate = 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 c0174ef

Please sign in to comment.