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

Add NodeToClientV_20 #5055

Open
wants to merge 2 commits 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
6 changes: 6 additions & 0 deletions cardano-ping/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Revision history for cardano-ping

## next version

### Breaking changes

* Added `NodeToClientVersionV20`

## 0.7.0.0 -- 2024-10-17

### Breaking changes
Expand Down
11 changes: 10 additions & 1 deletion cardano-ping/src/Cardano/Network/Ping.hs
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ supportedNodeToClientVersions magic =
, NodeToClientVersionV17 magic
, NodeToClientVersionV18 magic
, NodeToClientVersionV19 magic
, NodeToClientVersionV20 magic
]

data InitiatorOnly = InitiatorOnly | InitiatorAndResponder
Expand Down Expand Up @@ -187,6 +188,7 @@ data NodeVersion
| NodeToClientVersionV17 Word32
| NodeToClientVersionV18 Word32
| NodeToClientVersionV19 Word32
| NodeToClientVersionV20 Word32
| NodeToNodeVersionV1 Word32
| NodeToNodeVersionV2 Word32
| NodeToNodeVersionV3 Word32
Expand Down Expand Up @@ -217,6 +219,7 @@ instance ToJSON NodeVersion where
NodeToClientVersionV17 m -> go2 "NodeToClientVersionV17" m
NodeToClientVersionV18 m -> go2 "NodeToClientVersionV18" m
NodeToClientVersionV19 m -> go2 "NodeToClientVersionV19" m
NodeToClientVersionV20 m -> go2 "NodeToClientVersionV20" m
NodeToNodeVersionV1 m -> go2 "NodeToNodeVersionV1" m
NodeToNodeVersionV2 m -> go2 "NodeToNodeVersionV2" m
NodeToNodeVersionV3 m -> go2 "NodeToNodeVersionV3" m
Expand Down Expand Up @@ -357,9 +360,13 @@ handshakeReqEnc versions query =
CBOR.encodeWord (18 `setBit` nodeToClientVersionBit)
<> nodeToClientDataWithQuery magic
encodeVersion (NodeToClientVersionV19 magic) =
CBOR.encodeWord (18 `setBit` nodeToClientVersionBit)
CBOR.encodeWord (19 `setBit` nodeToClientVersionBit)
<> nodeToClientDataWithQuery magic
encodeVersion (NodeToClientVersionV20 magic) =
CBOR.encodeWord (20 `setBit` nodeToClientVersionBit)
<> nodeToClientDataWithQuery magic


-- node-to-node
encodeVersion (NodeToNodeVersionV1 magic) =
CBOR.encodeWord 1
Expand Down Expand Up @@ -507,6 +514,7 @@ handshakeDec = do
(17, True) -> Right . NodeToClientVersionV17 <$> (CBOR.decodeListLen *> CBOR.decodeWord32 <* (modeFromBool <$> CBOR.decodeBool))
(18, True) -> Right . NodeToClientVersionV18 <$> (CBOR.decodeListLen *> CBOR.decodeWord32 <* (modeFromBool <$> CBOR.decodeBool))
(19, True) -> Right . NodeToClientVersionV19 <$> (CBOR.decodeListLen *> CBOR.decodeWord32 <* (modeFromBool <$> CBOR.decodeBool))
(20, True) -> Right . NodeToClientVersionV20 <$> (CBOR.decodeListLen *> CBOR.decodeWord32 <* (modeFromBool <$> CBOR.decodeBool))
_ -> return $ Left $ UnknownVersionInRsp version

decodeWithMode :: (Word32 -> InitiatorOnly -> NodeVersion) -> CBOR.Decoder s (Either HandshakeFailure NodeVersion)
Expand Down Expand Up @@ -829,6 +837,7 @@ isSameVersionAndMagic v1 v2 = extract v1 == extract v2
extract (NodeToClientVersionV17 m) = (-17, m)
extract (NodeToClientVersionV18 m) = (-18, m)
extract (NodeToClientVersionV19 m) = (-19, m)
extract (NodeToClientVersionV20 m) = (-20, m)
extract (NodeToNodeVersionV1 m) = (1, m)
extract (NodeToNodeVersionV2 m) = (2, m)
extract (NodeToNodeVersionV3 m) = (3, m)
Expand Down
2 changes: 2 additions & 0 deletions ouroboros-network-api/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

### Breaking changes

* Added `NodeToClientV_20`.

### Non-breaking changes

## 0.12.0.0 -- 2025-01-02
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ data NodeToClientVersion
-- ^ added @GetFuturePParams@ query
| NodeToClientV_19
-- ^ added @GetLedgerPeerSnapshot@
| NodeToClientV_20
-- ^ added @QueryStakePoolDefaultVote@
deriving (Eq, Ord, Enum, Bounded, Show, Typeable, Generic, NFData)

-- | We set 16ths bit to distinguish `NodeToNodeVersion` and
Expand All @@ -68,6 +70,7 @@ nodeToClientVersionCodec = CodecCBORTerm { encodeTerm, decodeTerm }
NodeToClientV_17 -> enc 17
NodeToClientV_18 -> enc 18
NodeToClientV_19 -> enc 19
NodeToClientV_20 -> enc 20
where
enc :: Int -> CBOR.Term
enc = CBOR.TInt . (`setBit` nodeToClientVersionBit)
Expand All @@ -78,6 +81,7 @@ nodeToClientVersionCodec = CodecCBORTerm { encodeTerm, decodeTerm }
17 -> Right NodeToClientV_17
18 -> Right NodeToClientV_18
19 -> Right NodeToClientV_19
20 -> Right NodeToClientV_20
n -> Left (unknownTag n)
where
dec :: CBOR.Term -> Either (Text, Maybe Int) Int
Expand Down
3 changes: 2 additions & 1 deletion ouroboros-network-protocols/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

### Breaking changes

* Added kind signatures to protocol types:
* Adapt the `versionNumber` cddl definition to account for `NodeToClientVersionV20`.
* Added kind signatures to protocol types:
* `ChainSync`,
* `BlockFetch`,
* `TxSubmission2`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ versionTable = { * versionNumber => nodeToClientVersionData }


; as of version 2 (which is no longer supported) we set 15th bit to 1
; 16 / 17 / 18 / 19
versionNumber = 32784 / 32785 / 32786 / 32787
; 16 / 17 / 18 / 19 / 20
versionNumber = 32784 / 32785 / 32786 / 32787 / 32788

; As of version 15 and higher
nodeToClientVersionData = [networkMagic, query]
Expand Down