Skip to content

Commit 502b5e9

Browse files
authored
Merge pull request #5149 from IntersectMBO/coot/random-1.2
Consensus integration changes
2 parents 47e25d0 + 9f2223d commit 502b5e9

File tree

26 files changed

+124
-70
lines changed

26 files changed

+124
-70
lines changed

decentralized-message-queue/app/Main.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import Control.Tracer (Tracer (..))
99
import Data.Void (Void)
1010
import Debug.Trace (traceShowM)
1111
import Options.Applicative
12-
import System.Random (newStdGen, splitGen)
12+
import System.Random (newStdGen, split)
1313

1414
import DMQ.Configuration (mkDiffusionConfiguration,
1515
readConfigurationFileOrError)
@@ -44,7 +44,7 @@ runDMQ cliopts@CLIOptions {
4444
nt <- readTopologyFileOrError @() @() topologyFile
4545

4646
stdGen <- newStdGen
47-
let (psRng, policyRng) = splitGen stdGen
47+
let (psRng, policyRng) = split stdGen
4848

4949
nodeKernel <- newNodeKernel psRng
5050

decentralized-message-queue/decentralized-message-queue.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ library
9292
ouroboros-network-api ^>=0.14,
9393
ouroboros-network-framework ^>=0.18,
9494
ouroboros-network-protocols ^>=0.14.0.1,
95-
random >=1 && <1.4,
95+
random ^>=1.2,
9696
text >=1.2.4 && <2.2,
9797
typed-protocols ^>=1.0,
9898

docs/network-spec/miniprotocols.tex

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2253,9 +2253,13 @@ \section{Node-to-client protocol}
22532253
\begin{center}
22542254
\begin{tabular}{l|l}
22552255
\header{version} & \header{description} \\\hline
2256-
\texttt{NodeToClientV\_16} & Add ImmutableTip to LocalStateQuery, Conway, GetStakeDelegDeposits query \\
2257-
\texttt{NodeToClientV\_17} & GetProposals, GetRatifyState queries \\
2258-
\texttt{NodeToClientV\_18} & GetFuturePParams query \\
2256+
\texttt{NodeToClientV\_16} & Conway era, \texttt{ImmutableTip} and \texttt{GetStakeDelegDeposits} queries \\
2257+
\texttt{NodeToClientV\_17} & \texttt{GetProposals}, \texttt{GetRatifyState} queries \\
2258+
\texttt{NodeToClientV\_18} & \texttt{GetFuturePParams} query \\
2259+
\texttt{NodeToClientV\_19} & \texttt{GetBigLedgerPeerSnapshot} query\\
2260+
\texttt{NodeToClientV\_20} & \texttt{QueryStakePoolDefaultVote} query; \\
2261+
& added \texttt{MsgGetMeasures} and \texttt{MsgReplyGetMeasures} queries \\
2262+
\texttt{NodeToClientV\_21} & new codecs for \texttt{PParams} and \texttt{CompactGenesis} \\
22592263
\end{tabular}
22602264
\caption{Node-to-client protocol versions}
22612265
\label{table:node-to-client-protocol-versions}

ouroboros-network-api/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
### Breaking changes
66

7+
* Added `NodeToClientV_21`.
8+
79
### Non-breaking changes
810

911
* `IsLedgerPeer` added to `Ouroboros.Network.LedgerPeers.Types` module.

ouroboros-network-api/src/Ouroboros/Network/NodeToClient/Version.hs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,19 @@ data NodeToClientVersion
4141
-- | NodeToClientV_15
4242
-- -- ^ added `query` to NodeToClientVersionData
4343
= NodeToClientV_16
44-
-- ^ added @ImmutableTip@ to @LocalStateQuery@, enabled
45-
-- @CardanoNodeToClientVersion11@, i.e., Conway and
46-
-- @GetStakeDelegDeposits@.
44+
-- ^ Conway era (enabled @CardanoNodeToClientVersion11@);
45+
-- added @ImmutableTip@ and @GetStakeDelegDeposits@ queries to @LocalStateQuery@
4746
| NodeToClientV_17
4847
-- ^ added @GetProposals@ and @GetRatifyState@ queries
4948
| NodeToClientV_18
5049
-- ^ added @GetFuturePParams@ query
5150
| NodeToClientV_19
52-
-- ^ added @GetLedgerPeerSnapshot@
51+
-- ^ added @GetBigLedgerPeerSnapshot@ query
5352
| NodeToClientV_20
54-
-- ^ added @QueryStakePoolDefaultVote@,
55-
-- added @MsgGetMeasures@ / @MsgReplyGetMeasures@ to @LocalTxMonitor@
53+
-- ^ added @QueryStakePoolDefaultVote@ query;
54+
-- added @MsgGetMeasures@ and @MsgReplyGetMeasures@ to @LocalTxMonitor@
55+
| NodeToClientV_21
56+
-- ^ new codecs for @PParams@ and @CompactGenesis@
5657
deriving (Eq, Ord, Enum, Bounded, Show, Generic, NFData)
5758

5859
-- | We set 16ths bit to distinguish `NodeToNodeVersion` and
@@ -71,6 +72,7 @@ nodeToClientVersionCodec = CodecCBORTerm { encodeTerm, decodeTerm }
7172
NodeToClientV_18 -> enc 18
7273
NodeToClientV_19 -> enc 19
7374
NodeToClientV_20 -> enc 20
75+
NodeToClientV_21 -> enc 21
7476
where
7577
enc :: Int -> CBOR.Term
7678
enc = CBOR.TInt . (`setBit` nodeToClientVersionBit)
@@ -82,6 +84,7 @@ nodeToClientVersionCodec = CodecCBORTerm { encodeTerm, decodeTerm }
8284
18 -> Right NodeToClientV_18
8385
19 -> Right NodeToClientV_19
8486
20 -> Right NodeToClientV_20
87+
21 -> Right NodeToClientV_21
8588
n -> Left (unknownTag n)
8689
where
8790
dec :: CBOR.Term -> Either (Text, Maybe Int) Int

ouroboros-network-framework/demo/connection-manager.hs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ import Network.TypedProtocol.Peer
5050

5151
import Options.Applicative
5252

53-
import System.Random (SplitGen)
53+
import System.Random (RandomGen)
5454
import System.Random qualified as Random
5555

5656
import Network.TypedProtocol.ReqResp.Client
@@ -105,32 +105,32 @@ data ClientAndServerData = ClientAndServerData {
105105

106106

107107
{-
108-
genList :: SplitGen g => (g -> a) -> Int -> g -> [a]
108+
genList :: RandomGen g => (g -> a) -> Int -> g -> [a]
109109
genList gen = go []
110110
where
111111
go !acc len _g | len < 0 = acc
112112
go !acc len g =
113113
go (a : acc) (pred len) g''
114114
where
115-
(g', g'') = Random.splitGen g
115+
(g', g'') = Random.split g
116116
!a = gen g'
117117
-}
118118

119-
genInfList :: SplitGen g => (g -> a) -> g -> [a]
119+
genInfList :: RandomGen g => (g -> a) -> g -> [a]
120120
genInfList gen g =
121-
case Random.splitGen g of
121+
case Random.split g of
122122
(g', g'') -> gen g' : genInfList gen g''
123123

124124

125-
genClientAndServerData :: forall g. SplitGen g
125+
genClientAndServerData :: forall g. RandomGen g
126126
=> g -> Int -> ClientAndServerData
127127
genClientAndServerData g0 len = ClientAndServerData {
128128
hotInitiatorRequests = genListOfLists g1,
129129
warmInitiatorRequests = genListOfLists g2,
130130
establishedInitiatorRequests = genListOfLists g3
131131
}
132132
where
133-
(g1, (g2, g3)) = Random.splitGen <$> Random.splitGen g0
133+
(g1, (g2, g3)) = Random.split <$> Random.split g0
134134

135135
genListOfLists :: g -> [[Int]]
136136
genListOfLists = \g -> genInfList (take len . Random.randoms) g

ouroboros-network-framework/ouroboros-network-framework.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ library
8383
ouroboros-network-testing,
8484
psqueues,
8585
quiet,
86-
random,
86+
random ^>=1.2,
8787
text,
8888
typed-protocols:{typed-protocols, cborg, stateful} ^>=1.0,
8989

ouroboros-network-framework/sim-tests/Test/Ouroboros/Network/Server/Sim.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ import Data.Proxy (Proxy (..))
5959
import Data.Set (Set)
6060
import Data.Set qualified as Set
6161
import Data.Typeable (Typeable)
62-
import System.Random (StdGen, mkStdGen, splitGen)
62+
import System.Random (StdGen, mkStdGen, split)
6363

6464
import Text.Printf
6565

@@ -745,7 +745,7 @@ multinodeExperiment inboundTrTracer trTracer inboundTracer debugTracer cmTracer
745745
connVar <- newTVarIO Map.empty
746746
labelTVarIO connVar $ "connVar/" ++ show name
747747
threadId <- myThreadId
748-
stdGen <- atomically (stateTVar stdGenVar splitGen)
748+
stdGen <- atomically (stateTVar stdGenVar split)
749749
forkJob jobpool
750750
$ Job
751751
( withInitiatorOnlyConnectionManager
@@ -779,7 +779,7 @@ multinodeExperiment inboundTrTracer trTracer inboundTracer debugTracer cmTracer
779779
connVar <- newTVarIO Map.empty
780780
labelTVarIO connVar $ "connVar/" ++ show name
781781
threadId <- myThreadId
782-
stdGen <- atomically (stateTVar stdGenVar splitGen)
782+
stdGen <- atomically (stateTVar stdGenVar split)
783783
let job =
784784
case dataFlow of
785785
Duplex ->

ouroboros-network-framework/src/Ouroboros/Network/ConnectionManager/Core.hs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ import Data.Functor (void, ($>))
4444
import Data.Proxy (Proxy (..))
4545
import Data.Typeable (Typeable)
4646
import GHC.Stack (CallStack, HasCallStack, callStack)
47-
import System.Random (StdGen, splitGen)
47+
import System.Random (StdGen)
48+
import System.Random qualified as Random
4849

4950
import Data.List qualified as List
5051
import Data.Map.Strict (Map)
@@ -826,7 +827,7 @@ with args@Arguments {
826827
Just a -> Map.insert connId (a, connThread, connVar)
827828
choiceMap'
828829

829-
stdGen <- stateTVar stdGenVar splitGen
830+
stdGen <- stateTVar stdGenVar Random.split
830831
let pruneSet = prunePolicy
831832
stdGen
832833
((\(a,_,_) -> a) <$> choiceMap)
@@ -1330,7 +1331,7 @@ with args@Arguments {
13301331
(trace, mutableConnState@MutableConnState { connVar, connStateId }
13311332
, eHandleWedge) <- atomically $ do
13321333
state <- readTMVar stateVar
1333-
stdGen <- stateTVar stdGenVar splitGen
1334+
stdGen <- stateTVar stdGenVar Random.split
13341335
case State.lookupByRemoteAddr stdGen peerAddr state of
13351336
Just mutableConnState@MutableConnState { connVar, connStateId } -> do
13361337
connState <- readTVar connVar

ouroboros-network-framework/testlib/Test/Ouroboros/Network/ConnectionManager/Experiments.hs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ import Data.Proxy (Proxy (..))
5959
import Data.Typeable (Typeable)
6060
import Data.Void (Void)
6161

62-
import System.Random (StdGen, splitGen)
62+
import System.Random (StdGen)
63+
import System.Random qualified as Random
6364

6465
import Test.QuickCheck
6566

@@ -738,7 +739,7 @@ unidirectionalExperiment
738739
-> ClientAndServerData req
739740
-> m Property
740741
unidirectionalExperiment stdGen timeouts snocket makeBearer confSock socket clientAndServerData = do
741-
let (stdGen', stdGen'') = splitGen stdGen
742+
let (stdGen', stdGen'') = Random.split stdGen
742743
nextReqs <- oneshotNextRequests clientAndServerData
743744
connStateIdSupply <- atomically $ CM.newConnStateIdSupply (Proxy @m)
744745
withInitiatorOnlyConnectionManager
@@ -825,7 +826,7 @@ bidirectionalExperiment
825826
bidirectionalExperiment
826827
useLock stdGen timeouts snocket makeBearer confSock socket0 socket1 localAddr0 localAddr1
827828
clientAndServerData0 clientAndServerData1 = do
828-
let (stdGen', stdGen'') = splitGen stdGen
829+
let (stdGen', stdGen'') = Random.split stdGen
829830
lock <- newTMVarIO ()
830831
connStateIdSupply <- atomically $ CM.newConnStateIdSupply (Proxy @m)
831832
nextRequests0 <- oneshotNextRequests clientAndServerData0

0 commit comments

Comments
 (0)