Skip to content
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

Remove NodeToNodeV_13 #5068

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
16 changes: 6 additions & 10 deletions docs/network-spec/miniprotocols.tex
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ \subsection{Node-to-node mini-protocols}
\subsection{Node-to-client mini-protocols}

Mini-protocols used by node-to-client protocol. The chain-sync mini-protocol
is shared between node-to-node and node-to-client protocols, but it is instantiated differently. In
is shared between node-to-node and node-to-client protocols, but it is instantiated differently. In
node-to-client protocol, it is used with full blocks rather than just headers.

\miniEntry
Expand Down Expand Up @@ -709,7 +709,7 @@ \subsection{CDDL encoding specification}\label{handshake-cddl}
messages. First, one is used by the node-to-node protocol, and the other is used by the
node-to-client protocol.
\subsubsection{Node-to-node handshake mini-protocol}
\lstinputlisting[style=cddl]{../../ouroboros-network-protocols/cddl/specs/handshake-node-to-node-v13.cddl}
\lstinputlisting[style=cddl]{../../ouroboros-network-protocols/cddl/specs/handshake-node-to-node-v14.cddl}

\subsubsection{Node-to-client handshake mini-protocol}
\lstinputlisting[style=cddl]{../../ouroboros-network-protocols/cddl/specs/handshake-node-to-client.cddl}
Expand All @@ -718,7 +718,7 @@ \section{Chain-Sync mini-protocol}
\label{chain-sync-protocol}
\haddockref{Ouroboros.Network.Protocol.ChainSync.Type}{ouroboros-network-protocols/Ouroboros-Network-Protocol-ChainSync-Type\#t:ChainSync}\\
\hyperref[table:node-to-node-protocol-numbers]{\textit{node-to-node mini-protocol number}}: \texttt{2}\\
\hyperref[table:node-to-client-protocol-numbers]{\textit{node-to-client mini-protocol number}}: \texttt{5}\\
\hyperref[table:node-to-client-protocol-numbers]{\textit{node-to-client mini-protocol number}}: \texttt{5}\\

\newcommand{\StCanAwait}{\state{StCanAwait}}
\newcommand{\StMustReply}{\state{StMustReply}}
Expand Down Expand Up @@ -1597,11 +1597,8 @@ \subsection{Server Implementation Details}
function application all the way to diffusion and share the relevant parts of
\texttt{PeerSelectionState} with this function via a \texttt{TVar}.

\subsection{CDDL encoding specification ($11$ to $12$)}\label{peersharing-cddl}
\lstinputlisting[style=cddl]{../../ouroboros-network-protocols/cddl/specs/peer-sharing-v11-12.cddl}

\subsection{CDDL encoding specification ($\geq 13$)}\label{peersharing-cddl}
\lstinputlisting[style=cddl]{../../ouroboros-network-protocols/cddl/specs/peer-sharing-v13.cddl}
\subsection{CDDL encoding specification ($\geq 14$)}\label{peersharing-cddl}
\lstinputlisting[style=cddl]{../../ouroboros-network-protocols/cddl/specs/peer-sharing-v14.cddl}

\section{Local Tx-Submission mini-protocol}
\haddockref{Ouroboros.Network.Protocol.LocalTxSubmission.Type}{ouroboros-network-protocols/Ouroboros-Network-Protocol-LocalTxSubmission-Type\#t:LocalTxSubmission}\\
Expand Down Expand Up @@ -1976,8 +1973,7 @@ \section{Node-to-node protocol}
\begin{center}
\begin{tabular}{l|l}
\header{version} & \header{description} \\\hline
\texttt{NodeToNodeV\_13} & Disabled peer sharing for buggy V11 \& V12 and for InitiatorOnly nodes \\
\texttt{NodeToNodeV\_14} & No changes, identifies Chang+1 HF nodes\\
\texttt{NodeToNodeV\_14} & No changes, identifies Plomin HF nodes mandatory on mainnet as of 2025.01.29\\
\end{tabular}
\caption{Node-to-node protocol versions}
\label{table:node-to-node-protocol-versions}
Expand Down
1 change: 1 addition & 0 deletions docs/network-spec/network-spec.tex
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ \section{Node-to-node protocol}
\texttt{NodeToNodeV\_10} & Full duplex connections \\
\texttt{NodeToNodeV\_11} & Peer sharing willingness \\
\texttt{NodeToNodeV\_12} & No observable changes \\
\texttt{NodeToNodeV\_13} & Disabled peer sharing for buggy V11 \& V12 and for InitiatorOnly nodes \\
\end{tabular}
\caption{Node-to-node protocol versions}
\label{table:historical-node-to-node-protocol-versions}
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 @@ -5,6 +5,7 @@
### Breaking changes

* Added `NodeToClientV_20`.
* Removed `NodeToNodeV_13` which can't cross Plomin HF on 2025.01.29

### Non-breaking changes

Expand Down
23 changes: 10 additions & 13 deletions ouroboros-network-api/src/Ouroboros/Network/NodeToNode/Version.hs
Original file line number Diff line number Diff line change
Expand Up @@ -60,24 +60,22 @@ 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
NodeToNodeV_14
-- ^ Plomin HF, mandatory on mainnet as of 2025.01.29
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)
Expand Down Expand Up @@ -150,14 +148,13 @@ instance Queryable NodeToNodeVersionData where
nodeToNodeCodecCBORTerm :: NodeToNodeVersion -> CodecCBORTerm Text NodeToNodeVersionData
nodeToNodeCodecCBORTerm =
\case
NodeToNodeV_13 -> v13
NodeToNodeV_14 -> v13
NodeToNodeV_14 -> v14

where
v13 = CodecCBORTerm { encodeTerm = encodeTerm13, decodeTerm = decodeTerm13 }
v14 = CodecCBORTerm { encodeTerm = encodeTerm14, decodeTerm = decodeTerm14 }

encodeTerm13 :: NodeToNodeVersionData -> CBOR.Term
encodeTerm13 NodeToNodeVersionData { networkMagic, diffusionMode, peerSharing, query }
encodeTerm14 :: NodeToNodeVersionData -> CBOR.Term
encodeTerm14 NodeToNodeVersionData { networkMagic, diffusionMode, peerSharing, query }
= CBOR.TList
[ CBOR.TInt (fromIntegral $ unNetworkMagic networkMagic)
, CBOR.TBool (case diffusionMode of
Expand All @@ -169,8 +166,8 @@ nodeToNodeCodecCBORTerm =
, CBOR.TBool query
]

decodeTerm13 :: CBOR.Term -> Either Text NodeToNodeVersionData
decodeTerm13 (CBOR.TList [CBOR.TInt x, CBOR.TBool diffusionMode, CBOR.TInt peerSharing, CBOR.TBool query])
decodeTerm14 :: CBOR.Term -> Either Text NodeToNodeVersionData
decodeTerm14 (CBOR.TList [CBOR.TInt x, CBOR.TBool diffusionMode, CBOR.TInt peerSharing, CBOR.TBool query])
| x >= 0
, x <= 0xffffffff
, Just ps <- case peerSharing of
Expand All @@ -190,7 +187,7 @@ nodeToNodeCodecCBORTerm =
= Left $ T.pack $ "networkMagic out of bound: " <> show x
| otherwise -- peerSharing < 0 || peerSharing > 1
= Left $ T.pack $ "peerSharing is out of bound: " <> show peerSharing
decodeTerm13 t
decodeTerm14 t
= Left $ T.pack $ "unknown encoding: " ++ show t


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ decodePortNumber = fromIntegral <$> CBOR.decodeWord16
encodeRemoteAddress :: NodeToNodeVersion -> SockAddr -> CBOR.Encoding
encodeRemoteAddress =
\case
NodeToNodeV_13 -> sockAddr
NodeToNodeV_14 -> sockAddr

where
Expand All @@ -56,11 +55,10 @@ encodeRemoteAddress =
decodeRemoteAddress :: NodeToNodeVersion -> CBOR.Decoder s SockAddr
decodeRemoteAddress =
\case
NodeToNodeV_13 -> decoder13
NodeToNodeV_14 -> decoder13
NodeToNodeV_14 -> decoder14

where
decoder13 = do
decoder14 = do
_ <- CBOR.decodeListLen
tok <- CBOR.decodeWord
case tok of
Expand Down
104 changes: 52 additions & 52 deletions ouroboros-network-protocols/cddl/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -150,18 +150,18 @@ tests CDDLSpecs { cddlChainSync
, cddlTxSubmission2
, cddlKeepAlive
, cddlLocalStateQuery
, cddlHandshakeNodeToNodeV13ToLast
, cddlHandshakeNodeToNodeV14ToLast
, cddlHandshakeNodeToClient
, cddlPeerSharingNodeToNodeV13ToLast
, cddlNodeToNodeVersionDataV13ToLast
, cddlPeerSharingNodeToNodeV14ToLast
, cddlNodeToNodeVersionDataV14ToLast
} =
adjustOption (const $ QuickCheckMaxSize 10) $
testGroup "cddl"
[ testGroup "encoding"
-- validate encoding against a specification
[ testProperty "NodeToNode.Handshake V13 to Last"
(prop_encodeHandshakeNodeToNodeV13ToLast
cddlHandshakeNodeToNodeV13ToLast)
[ testProperty "NodeToNode.Handshake V14 to Last"
(prop_encodeHandshakeNodeToNodeV14ToLast
cddlHandshakeNodeToNodeV14ToLast)
, -- If this fails whilst adding a new node-to-client version, ensure that
-- all the necessary changes are included:
--
Expand All @@ -186,17 +186,17 @@ tests CDDLSpecs { cddlChainSync
, testProperty "LocalStateQuery" (prop_encodeLocalStateQuery
cddlLocalStateQuery)

, testProperty "PeerSharing V13 to Last" (prop_encodePeerSharingV13ToLast
cddlPeerSharingNodeToNodeV13ToLast)
, testProperty "PeerSharing V14 to Last" (prop_encodePeerSharingV14ToLast
cddlPeerSharingNodeToNodeV14ToLast)

, testProperty "NodeToNodeVersionData V13 to Last" (prop_encodeNodeToNodeVersionDataV13ToLast
cddlNodeToNodeVersionDataV13ToLast)
, testProperty "NodeToNodeVersionData V14 to Last" (prop_encodeNodeToNodeVersionDataV14ToLast
cddlNodeToNodeVersionDataV14ToLast)
]
, testGroup "decoder"
-- validate decoder by generating messages from the specification
[ testCase "NodeToNode.Handshake V13 to Last"
[ testCase "NodeToNode.Handshake V14 to Last"
(unit_decodeHandshakeNodeToNode
cddlHandshakeNodeToNodeV13ToLast)
cddlHandshakeNodeToNodeV14ToLast)
, testCase "NodeToClient.Handshake"
(unit_decodeHandshakeNodeToClient
cddlHandshakeNodeToClient)
Expand All @@ -215,11 +215,11 @@ tests CDDLSpecs { cddlChainSync
, testCase "LocalStateQuery" (unit_decodeLocalStateQuery
cddlLocalStateQuery)

, testCase "PeerSharing V13 to Last" (unit_decodePeerSharingV13ToLast
cddlPeerSharingNodeToNodeV13ToLast)
, testCase "PeerSharing V14 to Last" (unit_decodePeerSharingV14ToLast
cddlPeerSharingNodeToNodeV14ToLast)

, testCase "NodeToNodeVersionData V13 to Last" (unit_decodeNodeToNodeVersionDataV13ToLast
cddlNodeToNodeVersionDataV13ToLast)
, testCase "NodeToNodeVersionData V14 to Last" (unit_decodeNodeToNodeVersionDataV14ToLast
cddlNodeToNodeVersionDataV14ToLast)
]
]

Expand All @@ -229,7 +229,7 @@ newtype CDDLSpec ps = CDDLSpec BL.ByteString

data CDDLSpecs = CDDLSpecs {
cddlHandshakeNodeToClient :: CDDLSpec (Handshake NodeToClientVersion CBOR.Term),
cddlHandshakeNodeToNodeV13ToLast :: CDDLSpec (Handshake NodeToNodeVersion CBOR.Term),
cddlHandshakeNodeToNodeV14ToLast :: CDDLSpec (Handshake NodeToNodeVersion CBOR.Term),
cddlChainSync :: CDDLSpec (ChainSync BlockHeader HeaderPoint HeaderTip),
cddlBlockFetch :: CDDLSpec (BlockFetch Block BlockPoint),
cddlTxSubmission2 :: CDDLSpec (TxSubmission2 TxId Tx),
Expand All @@ -240,9 +240,9 @@ data CDDLSpecs = CDDLSpecs {
cddlLocalTxMonitor :: CDDLSpec (LocalTxMonitor TxId Tx SlotNo),
cddlLocalStateQuery :: CDDLSpec (LocalStateQuery Block BlockPoint Query),

cddlPeerSharingNodeToNodeV13ToLast :: CDDLSpec (PeerSharing.PeerSharing SockAddr),
cddlPeerSharingNodeToNodeV14ToLast :: CDDLSpec (PeerSharing.PeerSharing SockAddr),

cddlNodeToNodeVersionDataV13ToLast :: CDDLSpec NodeToNodeVersionData
cddlNodeToNodeVersionDataV14ToLast :: CDDLSpec NodeToNodeVersionData
}


Expand All @@ -253,7 +253,7 @@ readCDDLSpecs = do
<$> doesDirectoryExist "ouroboros-network-protocols"
common <- BL.readFile (dir </> "common.cddl")
handshakeNodeToClient <- BL.readFile (dir </> "handshake-node-to-client.cddl")
handshakeNodeToNodeV13ToLast <- BL.readFile (dir </> "handshake-node-to-node-v13.cddl")
handshakeNodeToNodeV14ToLast <- BL.readFile (dir </> "handshake-node-to-node-v14.cddl")
chainSync <- BL.readFile (dir </> "chain-sync.cddl")
blockFetch <- BL.readFile (dir </> "block-fetch.cddl")
txSubmission2 <- BL.readFile (dir </> "tx-submission2.cddl")
Expand All @@ -262,14 +262,14 @@ readCDDLSpecs = do
localTxMonitor <- BL.readFile (dir </> "local-tx-monitor.cddl")
localStateQuery <- BL.readFile (dir </> "local-state-query.cddl")

peerSharingNodeToNodeV13ToLast <- BL.readFile (dir </> "peer-sharing-v13.cddl")
peerSharingNodeToNodeV14ToLast <- BL.readFile (dir </> "peer-sharing-v14.cddl")

nodeToNodeVersionDataV13ToLast <- BL.readFile (dir </> "node-to-node-version-data-v13.cddl")
nodeToNodeVersionDataV14ToLast <- BL.readFile (dir </> "node-to-node-version-data-v14.cddl")
-- append common definitions; they must be appended since the first
-- definition is the entry point for a cddl spec.
return CDDLSpecs {
cddlHandshakeNodeToClient = CDDLSpec handshakeNodeToClient,
cddlHandshakeNodeToNodeV13ToLast = CDDLSpec handshakeNodeToNodeV13ToLast,
cddlHandshakeNodeToNodeV14ToLast = CDDLSpec handshakeNodeToNodeV14ToLast,
cddlChainSync = CDDLSpec $ chainSync
<> common,
cddlBlockFetch = CDDLSpec $ blockFetch
Expand All @@ -284,10 +284,10 @@ readCDDLSpecs = do
cddlLocalStateQuery = CDDLSpec $ localStateQuery
<> common,

cddlPeerSharingNodeToNodeV13ToLast = CDDLSpec $ peerSharingNodeToNodeV13ToLast
cddlPeerSharingNodeToNodeV14ToLast = CDDLSpec $ peerSharingNodeToNodeV14ToLast
<> common,

cddlNodeToNodeVersionDataV13ToLast = CDDLSpec nodeToNodeVersionDataV13ToLast
cddlNodeToNodeVersionDataV14ToLast = CDDLSpec nodeToNodeVersionDataV14ToLast
}

--
Expand Down Expand Up @@ -409,8 +409,8 @@ validateCBOR (CDDLSpec spec) blob =
-- with Peer Sharing required yet another parameter ((see
-- specs/handshake-node-to-node-v13.cddl)
--
newtype NtNHandshakeV13ToLast =
NtNHandshakeV13ToLast
newtype NtNHandshakeV14ToLast =
NtNHandshakeV14ToLast
(AnyMessage (Handshake NodeToNodeVersion CBOR.Term))
deriving Show

Expand Down Expand Up @@ -458,16 +458,16 @@ genNtNHandshake genVersion = oneof
<*> (Text.pack <$> arbitrary)
]

instance Arbitrary NtNHandshakeV13ToLast where
instance Arbitrary NtNHandshakeV14ToLast where
arbitrary = do
let genVersion = elements [NodeToNodeV_13 ..]
NtNHandshakeV13ToLast <$> genNtNHandshake genVersion
let genVersion = elements [NodeToNodeV_14 ..]
NtNHandshakeV14ToLast <$> genNtNHandshake genVersion

prop_encodeHandshakeNodeToNodeV13ToLast
prop_encodeHandshakeNodeToNodeV14ToLast
:: CDDLSpec (Handshake NodeToNodeVersion CBOR.Term)
-> NtNHandshakeV13ToLast
-> NtNHandshakeV14ToLast
-> Property
prop_encodeHandshakeNodeToNodeV13ToLast spec (NtNHandshakeV13ToLast x) =
prop_encodeHandshakeNodeToNodeV14ToLast spec (NtNHandshakeV14ToLast x) =
validateEncoder spec nodeToNodeHandshakeCodec x

-- TODO: add our regular tests for `Handshake NodeToClientVerision CBOR.Term`
Expand Down Expand Up @@ -586,19 +586,19 @@ instance Arbitrary SockAddr where
<*> arbitrary
]

prop_encodePeerSharingV13ToLast
prop_encodePeerSharingV14ToLast
:: CDDLSpec (PeerSharing.PeerSharing SockAddr)
-> NtNVersionV13ToLast
-> NtNVersionV14ToLast
-> AnyMessage (PeerSharing.PeerSharing SockAddr)
-> Property
prop_encodePeerSharingV13ToLast spec (NtNVersionV13ToLast ntnVersion) =
prop_encodePeerSharingV14ToLast spec (NtNVersionV14ToLast ntnVersion) =
validateEncoder spec (peerSharingCodec ntnVersion)

newtype NtNVersionV13ToLast = NtNVersionV13ToLast NodeToNodeVersion
newtype NtNVersionV14ToLast = NtNVersionV14ToLast NodeToNodeVersion
deriving Show

instance Arbitrary NtNVersionV13ToLast where
arbitrary = NtNVersionV13ToLast <$> elements [NodeToNodeV_13 ..]
instance Arbitrary NtNVersionV14ToLast where
arbitrary = NtNVersionV14ToLast <$> elements [NodeToNodeV_14 ..]

instance Arbitrary NodeToNodeVersionData where
arbitrary =
Expand All @@ -612,20 +612,20 @@ instance Arbitrary NodeToNodeVersionData where
]
<*> arbitrary

newtype NtNVersionDataV13ToLast = NtNVersionDataV13ToLast (NodeToNodeVersion, NodeToNodeVersionData)
newtype NtNVersionDataV14ToLast = NtNVersionDataV14ToLast (NodeToNodeVersion, NodeToNodeVersionData)
deriving Show

instance Arbitrary NtNVersionDataV13ToLast where
instance Arbitrary NtNVersionDataV14ToLast where
arbitrary = do
NtNVersionV13ToLast ntnVersion <- arbitrary
NtNVersionV14ToLast ntnVersion <- arbitrary
ntnVersionData <- arbitrary
return (NtNVersionDataV13ToLast (ntnVersion, ntnVersionData))
return (NtNVersionDataV14ToLast (ntnVersion, ntnVersionData))

prop_encodeNodeToNodeVersionDataV13ToLast
prop_encodeNodeToNodeVersionDataV14ToLast
:: CDDLSpec NodeToNodeVersionData
-> NtNVersionDataV13ToLast
-> NtNVersionDataV14ToLast
-> Property
prop_encodeNodeToNodeVersionDataV13ToLast spec (NtNVersionDataV13ToLast (v, a)) =
prop_encodeNodeToNodeVersionDataV14ToLast spec (NtNVersionDataV14ToLast (v, a)) =
validateCBORTermEncoder spec (nodeToNodeCodecCBORTerm v) a

--
Expand Down Expand Up @@ -939,23 +939,23 @@ unit_decodeLocalStateQuery spec =
]
100

unit_decodePeerSharingV13ToLast
unit_decodePeerSharingV14ToLast
:: CDDLSpec (PeerSharing.PeerSharing SockAddr)
-> Assertion
unit_decodePeerSharingV13ToLast spec =
forM_ [NodeToNodeV_13 ..] $ \v ->
unit_decodePeerSharingV14ToLast spec =
forM_ [NodeToNodeV_14 ..] $ \v ->
validateDecoder Nothing
spec (peerSharingCodec v)
[ SomeAgency PeerSharing.SingIdle
, SomeAgency PeerSharing.SingBusy
]
100

unit_decodeNodeToNodeVersionDataV13ToLast
unit_decodeNodeToNodeVersionDataV14ToLast
:: CDDLSpec NodeToNodeVersionData
-> Assertion
unit_decodeNodeToNodeVersionDataV13ToLast spec =
forM_ [NodeToNodeV_13 ..] $ \v ->
unit_decodeNodeToNodeVersionDataV14ToLast spec =
forM_ [NodeToNodeV_14 ..] $ \v ->
validateCBORTermDecoder Nothing spec (nodeToNodeCodecCBORTerm v) 100

--
Expand Down
Loading