Skip to content
Draft
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
8 changes: 8 additions & 0 deletions cardano-ping/src/Cardano/Network/Ping.hs
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ supportedNodeToClientVersions magic =
, NodeToClientVersionV20 magic
, NodeToClientVersionV21 magic
, NodeToClientVersionV22 magic
, NodeToClientVersionV33 magic
]

data InitiatorOnly = InitiatorOnly | InitiatorAndResponder
Expand Down Expand Up @@ -193,6 +194,7 @@ data NodeVersion
| NodeToClientVersionV20 Word32
| NodeToClientVersionV21 Word32
| NodeToClientVersionV22 Word32
| NodeToClientVersionV23 Word32
| NodeToNodeVersionV1 Word32
| NodeToNodeVersionV2 Word32
| NodeToNodeVersionV3 Word32
Expand Down Expand Up @@ -226,6 +228,7 @@ instance ToJSON NodeVersion where
NodeToClientVersionV20 m -> go2 "NodeToClientVersionV20" m
NodeToClientVersionV21 m -> go2 "NodeToClientVersionV21" m
NodeToClientVersionV22 m -> go2 "NodeToClientVersionV22" m
NodeToClientVersionV23 m -> go2 "NodeToClientVersionV23" m
NodeToNodeVersionV1 m -> go2 "NodeToNodeVersionV1" m
NodeToNodeVersionV2 m -> go2 "NodeToNodeVersionV2" m
NodeToNodeVersionV3 m -> go2 "NodeToNodeVersionV3" m
Expand Down Expand Up @@ -377,6 +380,9 @@ handshakeReqEnc versions query =
encodeVersion (NodeToClientVersionV22 magic) =
CBOR.encodeWord (22 `setBit` nodeToClientVersionBit)
<> nodeToClientDataWithQuery magic
encodeVersion (NodeToClientVersionV23 magic) =
CBOR.encodeWord (23 `setBit` nodeToClientVersionBit)
<> nodeToClientDataWithQuery magic

-- node-to-node
encodeVersion (NodeToNodeVersionV1 magic) =
Expand Down Expand Up @@ -528,6 +534,7 @@ handshakeDec = do
(20, True) -> Right . NodeToClientVersionV20 <$> (CBOR.decodeListLen *> CBOR.decodeWord32 <* (modeFromBool <$> CBOR.decodeBool))
(21, True) -> Right . NodeToClientVersionV21 <$> (CBOR.decodeListLen *> CBOR.decodeWord32 <* (modeFromBool <$> CBOR.decodeBool))
(22, True) -> Right . NodeToClientVersionV22 <$> (CBOR.decodeListLen *> CBOR.decodeWord32 <* (modeFromBool <$> CBOR.decodeBool))
(23, True) -> Right . NodeToClientVersionV23 <$> (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 @@ -853,6 +860,7 @@ isSameVersionAndMagic v1 v2 = extract v1 == extract v2
extract (NodeToClientVersionV20 m) = (-20, m)
extract (NodeToClientVersionV21 m) = (-21, m)
extract (NodeToClientVersionV22 m) = (-22, m)
extract (NodeToClientVersionV23 m) = (-23, m)
extract (NodeToNodeVersionV1 m) = (1, m)
extract (NodeToNodeVersionV2 m) = (2, m)
extract (NodeToNodeVersionV3 m) = (3, m)
Expand Down
1 change: 1 addition & 0 deletions ouroboros-network-api/ouroboros-network-api.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ library
base16-bytestring,
bytestring >=0.10 && <0.13,
cardano-binary,
cardano-crypto-class,
cardano-slotting,
cardano-strict-containers,
cborg >=0.2.1 && <0.3,
Expand Down
3 changes: 3 additions & 0 deletions ouroboros-network-api/src/Ouroboros/Network/Block.hs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ import Codec.CBOR.Read qualified as Read
import Codec.CBOR.Write qualified as Write
import Codec.Serialise (Serialise (..))
import Control.Monad (when)
import Data.Aeson (FromJSON, ToJSON)
import Data.ByteString.Base16.Lazy qualified as B16
import Data.ByteString.Lazy qualified as Lazy
import Data.ByteString.Lazy.Char8 qualified as BSC
Expand Down Expand Up @@ -216,6 +217,8 @@ deriving newtype instance StandardHash block => Ord (Point block)
deriving via (Quiet (Point block))
instance StandardHash block => Show (Point block)
deriving newtype instance StandardHash block => NoThunks (Point block)
deriving newtype instance ToJSON (Point.Block SlotNo (HeaderHash block)) => ToJSON (Point block)
deriving newtype instance FromJSON (Point.Block SlotNo (HeaderHash block)) => FromJSON (Point block)

instance ShowProxy block => ShowProxy (Point block) where
showProxy _ = "Point " ++ showProxy (Proxy :: Proxy block)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ data NodeToClientVersion
-- ^ new codecs for @PParams@ and @CompactGenesis@
| NodeToClientV_22
-- ^ support SRV records in @GetBigLedgerPeerSnapshot@ query
-- TODO: remove CBOR instances from LedgerPeers.Type when V22 support
-- is removed!
| NodeToClientV_23
-- ^ LedgerPeerSnapshot CBOR encoding contains block hash
deriving (Eq, Ord, Enum, Bounded, Show, Generic, NFData)

-- | We set 16ths bit to distinguish `NodeToNodeVersion` and
Expand All @@ -76,6 +80,7 @@ nodeToClientVersionCodec = CodecCBORTerm { encodeTerm, decodeTerm }
NodeToClientV_20 -> enc 20
NodeToClientV_21 -> enc 21
NodeToClientV_22 -> enc 22
NodeToClientV_23 -> enc 23
where
enc :: Int -> CBOR.Term
enc = CBOR.TInt . (`setBit` nodeToClientVersionBit)
Expand All @@ -89,6 +94,7 @@ nodeToClientVersionCodec = CodecCBORTerm { encodeTerm, decodeTerm }
20 -> Right NodeToClientV_20
21 -> Right NodeToClientV_21
22 -> Right NodeToClientV_22
23 -> Right NodeToClientV_23
n -> Left (unknownTag n)
where
dec :: CBOR.Term -> Either (Text, Maybe Int) Int
Expand Down
Loading
Loading