Skip to content

Commit

Permalink
Introduce NodeToNodeV_14 (#4986)
Browse files Browse the repository at this point in the history
* Added NodeToNodeV_14 to identify nodes in the Chang+1 HF era

* Update cardano-ping

* Network spec update

* changelog update
  • Loading branch information
crocodile-dentist authored Oct 11, 2024
1 parent dad8b19 commit 6ff4120
Show file tree
Hide file tree
Showing 8 changed files with 75 additions and 25 deletions.
1 change: 1 addition & 0 deletions cardano-ping/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### Breaking changes

* Added `NodeToClientVersionV18`
* Added `NodeToNodeVersion14`

## 0.4.0.1 -- 2024-08-27

Expand Down
6 changes: 6 additions & 0 deletions cardano-ping/src/Cardano/Network/Ping.hs
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ supportedNodeToNodeVersions magic =
, NodeToNodeVersionV11 magic InitiatorOnly
, NodeToNodeVersionV12 magic InitiatorOnly
, NodeToNodeVersionV13 magic InitiatorOnly PeerSharingDisabled
, NodeToNodeVersionV14 magic InitiatorOnly PeerSharingDisabled
]

supportedNodeToClientVersions :: Word32 -> [NodeVersion]
Expand Down Expand Up @@ -195,6 +196,7 @@ data NodeVersion
| NodeToNodeVersionV11 Word32 InitiatorOnly
| NodeToNodeVersionV12 Word32 InitiatorOnly
| NodeToNodeVersionV13 Word32 InitiatorOnly PeerSharing
| NodeToNodeVersionV14 Word32 InitiatorOnly PeerSharing
deriving (Eq, Ord, Show)

instance ToJSON NodeVersion where
Expand Down Expand Up @@ -223,6 +225,7 @@ instance ToJSON NodeVersion where
NodeToNodeVersionV11 m i -> go3 "NodeToNodeVersionV11" m i
NodeToNodeVersionV12 m i -> go3 "NodeToNodeVersionV12" m i
NodeToNodeVersionV13 m i ps -> go4 "NodeToNodeVersionV13" m i ps
NodeToNodeVersionV14 m i ps -> go4 "NodeToNodeVersionV14" m i ps
where
go2 (version :: String) magic = ["version" .= version, "magic" .= magic]
go3 version magic initiator = go2 version magic <> ["initiator" .= toJSON initiator]
Expand Down Expand Up @@ -369,6 +372,7 @@ handshakeReqEnc versions query =
encodeVersion (NodeToNodeVersionV11 magic mode) = encodeWithMode 11 magic mode
encodeVersion (NodeToNodeVersionV12 magic mode) = encodeWithMode 12 magic mode
encodeVersion (NodeToNodeVersionV13 magic mode _) = encodeWithMode 13 magic mode
encodeVersion (NodeToNodeVersionV14 magic mode _) = encodeWithMode 14 magic mode

nodeToClientDataWithQuery :: Word32 -> CBOR.Encoding
nodeToClientDataWithQuery magic
Expand Down Expand Up @@ -482,6 +486,7 @@ handshakeDec = do
(11, False) -> decodeWithModeAndQuery NodeToNodeVersionV11
(12, False) -> decodeWithModeAndQuery NodeToNodeVersionV12
(13, False) -> decodeWithModeQueryAndPeerSharing NodeToNodeVersionV13
(14, False) -> decodeWithModeQueryAndPeerSharing NodeToNodeVersionV14

(9, True) -> Right . NodeToClientVersionV9 <$> CBOR.decodeWord32
(10, True) -> Right . NodeToClientVersionV10 <$> CBOR.decodeWord32
Expand Down Expand Up @@ -827,3 +832,4 @@ isSameVersionAndMagic v1 v2 = extract v1 == extract v2
extract (NodeToNodeVersionV11 m _) = (11, m)
extract (NodeToNodeVersionV12 m _) = (12, m)
extract (NodeToNodeVersionV13 m _ _) = (13, m)
extract (NodeToNodeVersionV14 m _ _) = (14, m)
30 changes: 8 additions & 22 deletions docs/network-spec/miniprotocols.tex
Original file line number Diff line number Diff line change
Expand Up @@ -1494,24 +1494,15 @@ \section{Node-to-node protocol}
\begin{center}
\begin{tabular}{l|l}
version & description \\\hline\hline
$NodeToNodeV\_1*$ & initial version \\\hline
$NodeToNodeV\_2*$ & block size hints \\\hline
$NodeToNodeV\_3*$ & introduction of keep-alive mini-protocol \\\hline
$NodeToNodeV\_4*$ & introduction of diffusion mode in handshake mini-protocol \\\hline
$NodeToNodeV\_5*$ & \\\hline
$NodeToNodeV\_6*$ & transaction submission version 2 \\\hline
$NodeToNodeV\_7$ & new keep-alive, Alonzo ledger era \\\hline
$NodeToNodeV\_8$ & chain-sync \& block-fetch pipelining \\\hline
$NodeToNodeV\_9$ & Babbage ledger era \\\hline
$NodeToNodeV\_10$ & Full duplex connections \\\hline
$NodeToNodeV\_11$ & Peer sharing willingness \\\hline
$NodeToNodeV\_12$ & No observable changes \\\hline
$NodeToNodeV\_13$ & Disabled peer sharing for buggy V11 \& V12 and for InitiatorOnly nodes \\\hline
$NodeToNodeV\_14$ & No changes, identifies Chang+1 HF nodes\\\hline
\end{tabular}
\caption{Node-to-node protocol versions (* - support removed)}
\caption{Node-to-node protocol versions}
\label{table:node-to-node-protocol-versions}
\end{center}
\end{figure}
\newline
Previously supported node-to-node versions are listed in table \ref{table:historical-node-to-node-protocol-versions}.

\section{Node-to-client protocol}
\label{section:node-to-client-protocol}
Expand All @@ -1530,14 +1521,6 @@ \section{Node-to-client protocol}
\begin{center}
\begin{tabular}{l|l}
version & description \\\hline\hline
$NodeToClientV\_1*$ & initial version\\\hline
$NodeToClientV\_2*$ & added local-query mini-protocol\\\hline
$NodeToClientV\_3*$ & \\\hline
$NodeToClientV\_4*$ & new queries added to local state query mini-protocol\\\hline
$NodeToClientV\_5*$ & allegra \\\hline
$NodeToClientV\_6*$ & mary \\\hline
$NodeToClientV\_7*$ & new queries added to local state query mini-protocol\\\hline
$NodeToClientV\_8*$ & codec changed for local state query mini-protocol\\\hline
$NodeToClientV\_9$ & alonzo \\\hline
$NodeToClientV\_10$ & GetChainBlock \& GetChainPoint queries \\\hline
$NodeToClientV\_11$ & GetRewardInfoPools query \\\hline
Expand All @@ -1547,8 +1530,11 @@ \section{Node-to-client protocol}
$NodeToClientV\_15$ & internal changes \\\hline
$NodeToClientV\_16$ & Add ImmutableTip to LocalStateQuery, conway, GetStakeDelegDeposits query \\\hline
$NodeToClientV\_17$ & GetProposals, GetRatifyState queries \\\hline
$NodeToClientV\_18$ & GetFuturePParams query \\\hline
\end{tabular}
\caption{Node-to-client protocol versions (* - support removed)}
\caption{Node-to-client protocol versions}
\label{table:node-to-client-protocol-versions}
\end{center}
\end{figure}
\newline
Previously supported node-to-client versions are listed in table \ref{table:historical-node-to-client-protocol-versions}.
48 changes: 48 additions & 0 deletions docs/network-spec/network-spec.tex
Original file line number Diff line number Diff line change
Expand Up @@ -195,10 +195,58 @@ \section*{Version history}
% \include{rest}

\appendix

\chapter{Common CDDL definitions}
\label{cddl-common}
\lstinputlisting[style=cddl]{../../ouroboros-network-protocols/test-cddl/specs/common.cddl}

\chapter{Historical protocol versions}
\label{historical-protocol-versions}

Previously supported versions of the \textit{node-to-node protocol} are listed
in table~\ref{table:historical-node-to-node-protocol-versions}.
\begin{figure}[h]
\begin{center}
\begin{tabular}{l|l}
version & description \\\hline\hline
$NodeToNodeV\_1$ & initial version \\\hline
$NodeToNodeV\_2$ & block size hints \\\hline
$NodeToNodeV\_3$ & introduction of keep-alive mini-protocol \\\hline
$NodeToNodeV\_4$ & introduction of diffusion mode in handshake mini-protocol \\\hline
$NodeToNodeV\_5$ & \\\hline
$NodeToNodeV\_6$ & transaction submission version 2 \\\hline
$NodeToNodeV\_7$ & new keep-alive, Alonzo ledger era \\\hline
$NodeToNodeV\_8$ & chain-sync \& block-fetch pipelining \\\hline
$NodeToNodeV\_9$ & Babbage ledger era \\\hline
$NodeToNodeV\_10$ & Full duplex connections \\\hline
$NodeToNodeV\_11$ & Peer sharing willingness \\\hline
$NodeToNodeV\_12$ & No observable changes \\\hline
\end{tabular}
\caption{Node-to-node protocol versions}
\label{table:historical-node-to-node-protocol-versions}
\end{center}
\end{figure}

Previously supported versions of the \textit{node-to-client protocol} are listed
in table~\ref{table:historical-node-to-client-protocol-versions}.
\begin{figure}[h]
\begin{center}
\begin{tabular}{l|l}
version & description \\\hline\hline
$NodeToClientV\_1$ & initial version\\\hline
$NodeToClientV\_2$ & added local-query mini-protocol\\\hline
$NodeToClientV\_3$ & \\\hline
$NodeToClientV\_4$ & new queries added to local state query mini-protocol\\\hline
$NodeToClientV\_5$ & allegra \\\hline
$NodeToClientV\_6$ & mary \\\hline
$NodeToClientV\_7$ & new queries added to local state query mini-protocol\\\hline
$NodeToClientV\_8$ & codec changed for local state query mini-protocol\\\hline
\end{tabular}
\caption{Node-to-client protocol versions}
\label{table:historical-node-to-client-protocol-versions}
\end{center}
\end{figure}

\bibliographystyle{apalike}
\bibliography{references}

Expand Down
1 change: 1 addition & 0 deletions ouroboros-network-api/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* Removed `WhetherReceivingTentativeBlocks` used to
distinguish whether a node version is pipelining-enabled,
used in older `NodeToNodeVersion`
* Added NodeToNodeV_14 to identify nodes supporting Chang+1 HF

### Non-breaking changes

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,21 +60,25 @@ data NodeToNodeVersion =
-- --
-- -- (In the past, this enabled Conway, but the negotiated 'NodeToNodeVersion'
-- -- no longer en-/disables eras.)
NodeToNodeV_13
NodeToNodeV_13
-- ^ Changes:
--
-- * Removed PeerSharingPrivate constructor
-- * Fixed Codec to disable PeerSharing with buggy versions 11 and 12.
-- * Disable PeerSharing with InitiatorOnly nodes, since they do not run
-- peer sharing server side and can not reply to requests.
| NodeToNodeV_14
-- ^ Chang+1 HF
deriving (Eq, Ord, Enum, Bounded, Show, Typeable, Generic, NFData)

nodeToNodeVersionCodec :: CodecCBORTerm (Text, Maybe Int) NodeToNodeVersion
nodeToNodeVersionCodec = CodecCBORTerm { encodeTerm, decodeTerm }
where
encodeTerm NodeToNodeV_13 = CBOR.TInt 13
encodeTerm NodeToNodeV_14 = CBOR.TInt 14

decodeTerm (CBOR.TInt 13) = Right NodeToNodeV_13
decodeTerm (CBOR.TInt 14) = Right NodeToNodeV_14
decodeTerm (CBOR.TInt n) = Left ( T.pack "decode NodeToNodeVersion: unknown tag: "
<> T.pack (show n)
, Just n
Expand Down Expand Up @@ -147,6 +151,7 @@ nodeToNodeCodecCBORTerm :: NodeToNodeVersion -> CodecCBORTerm Text NodeToNodeVer
nodeToNodeCodecCBORTerm =
\case
NodeToNodeV_13 -> v13
NodeToNodeV_14 -> v13

where
v13 = CodecCBORTerm { encodeTerm = encodeTerm13, decodeTerm = decodeTerm13 }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ encodeRemoteAddress :: NodeToNodeVersion -> SockAddr -> CBOR.Encoding
encodeRemoteAddress =
\case
NodeToNodeV_13 -> sockAddr
NodeToNodeV_14 -> sockAddr

where
sockAddr = \case
SockAddrInet pn w -> CBOR.encodeListLen 3
Expand All @@ -55,6 +57,8 @@ decodeRemoteAddress :: NodeToNodeVersion -> CBOR.Decoder s SockAddr
decodeRemoteAddress =
\case
NodeToNodeV_13 -> decoder13
NodeToNodeV_14 -> decoder13

where
decoder13 = do
_ <- CBOR.decodeListLen
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ msgQueryReply = [3, versionTable]

versionTable = { * versionNumber => nodeToNodeVersionData }

versionNumber = 13
versionNumber = 13 / 14

nodeToNodeVersionData = [ networkMagic, initiatorOnlyDiffusionMode, peerSharing, query ]

Expand All @@ -33,4 +33,3 @@ refuseReason
refuseReasonVersionMismatch = [0, [ *versionNumber ] ]
refuseReasonHandshakeDecodeError = [1, versionNumber, tstr]
refuseReasonRefused = [2, versionNumber, tstr]

0 comments on commit 6ff4120

Please sign in to comment.