Skip to content

Commit 8249592

Browse files
committed
wrong block
1 parent bed9187 commit 8249592

File tree

5 files changed

+82
-30
lines changed

5 files changed

+82
-30
lines changed

ouroboros-consensus-diffusion/app/conformance-test-runner/Main.hs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
{-# LANGUAGE FlexibleInstances #-}
2+
{-# LANGUAGE MultiParamTypeClasses #-}
3+
{-# LANGUAGE TypeSynonymInstances #-}
4+
15
module Main (main) where
26

37
import qualified Data.Map.Merge.Lazy as M
@@ -32,6 +36,9 @@ import Ouroboros.Network.PeerSelection.State.LocalRootPeers (HotValency (..), Wa
3236
import Server (run)
3337
import Test.Consensus.PointSchedule (PointSchedule (..))
3438
import Test.Consensus.PointSchedule.Peers (PeerId (..), Peers (Peers), getPeerIds)
39+
import Test.Util.TestBlock
40+
import Ouroboros.Consensus.Node.Serialisation
41+
import Ouroboros.Consensus.Block.Abstract
3542

3643
testPointSchedule :: PointSchedule blk
3744
testPointSchedule =
@@ -86,6 +93,8 @@ main = do
8693
zipMaps :: Ord k => Map k a -> Map k b -> Map k (a, b)
8794
zipMaps = M.merge M.dropMissing M.dropMissing $ M.zipWithMatched $ const (,)
8895

96+
instance SerialiseNodeToNode TestBlock (Header TestBlock)
97+
8998
runServer :: IO ()
9099
runServer = do
91100
let peerMap = buildPeerMap 6001 testPointSchedule

ouroboros-consensus-diffusion/app/conformance-test-runner/MiniProtocols.hs

Lines changed: 55 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,32 @@
1-
{-# LANGUAGE BlockArguments #-}
2-
{-# LANGUAGE DataKinds #-}
3-
{-# LANGUAGE DeriveAnyClass #-}
4-
{-# LANGUAGE DeriveGeneric #-}
5-
{-# LANGUAGE DerivingStrategies #-}
6-
{-# LANGUAGE FlexibleContexts #-}
7-
{-# LANGUAGE LambdaCase #-}
8-
{-# LANGUAGE NamedFieldPuns #-}
9-
{-# LANGUAGE PolyKinds #-}
10-
{-# LANGUAGE RankNTypes #-}
11-
{-# LANGUAGE ScopedTypeVariables #-}
12-
{-# LANGUAGE TypeApplications #-}
1+
{-# LANGUAGE BlockArguments #-}
2+
{-# LANGUAGE DataKinds #-}
3+
{-# LANGUAGE DeriveAnyClass #-}
4+
{-# LANGUAGE DeriveGeneric #-}
5+
{-# LANGUAGE DerivingStrategies #-}
6+
{-# LANGUAGE FlexibleContexts #-}
7+
{-# LANGUAGE LambdaCase #-}
8+
{-# LANGUAGE NamedFieldPuns #-}
9+
{-# LANGUAGE PartialTypeSignatures #-}
10+
{-# LANGUAGE PolyKinds #-}
11+
{-# LANGUAGE RankNTypes #-}
12+
{-# LANGUAGE ScopedTypeVariables #-}
13+
{-# LANGUAGE TypeApplications #-}
1314

1415
-- | Implements a server that waits for an incoming connection to ChainSync or
1516
-- BlockFetch, and forwards the resulting channels to a TMVar so they can be
1617
-- picked up by the peer simulator.
1718
module MiniProtocols (peerSimServer) where
1819

20+
import Ouroboros.Consensus.Node.Serialisation
21+
import Ouroboros.Network.Protocol.ChainSync.Codec
22+
import Ouroboros.Network.Block
23+
( Serialised (..)
24+
, Tip(..)
25+
, decodePoint
26+
, decodeTip
27+
, encodePoint
28+
, encodeTip
29+
)
1930
import Ouroboros.Network.Protocol.BlockFetch.Server
2031
import Ouroboros.Network.Util.ShowProxy (ShowProxy)
2132
import Ouroboros.Network.Protocol.ChainSync.Server
@@ -57,14 +68,18 @@ import Ouroboros.Network.Protocol.Handshake.Version (Version (..))
5768
import Ouroboros.Network.Protocol.KeepAlive.Server
5869
( keepAliveServerPeer
5970
)
71+
-- import Network.TypedProtocol.Codec
72+
import Codec.CBOR.Read (DeserialiseFailure)
6073

6174
peerSimServer ::
6275
forall m blk addr.
6376
( IOLike m
64-
, SerialiseNodeToNodeConstraints blk
77+
-- , SerialiseNodeToNodeConstraints blk
6578
, SupportedNetworkProtocolVersion blk
6679
, ShowProxy blk
6780
, ShowProxy (Header blk)
81+
, ConvertRawHash blk
82+
, SerialiseNodeToNode blk (Header blk)
6883
, MonadSay m
6984
) =>
7085
PeerResources m blk ->
@@ -113,8 +128,9 @@ peerSimServer res csChanTMV bfChanTMV codecCfg encAddr decAddr networkMagic = do
113128
N2N.keepAliveProtocolLimits
114129
$ MiniProtocolCb
115130
$ \_ctx channel ->
116-
runPeer nullTracer cKeepAliveCodec channel $
117-
keepAliveServerPeer keepAliveServer
131+
undefined
132+
-- runPeer nullTracer cKeepAliveCodec channel $
133+
-- keepAliveServerPeer keepAliveServer
118134
, mkMiniProtocol
119135
Mux.StartOnDemand
120136
N2N.chainSyncMiniProtocolNum
@@ -123,7 +139,21 @@ peerSimServer res csChanTMV bfChanTMV codecCfg encAddr decAddr networkMagic = do
123139
$ \_ctx channel -> do
124140
say "hello from cs"
125141
atomically $ writeTVar csChanTMV True
126-
runPeer nullTracer cChainSyncCodec channel
142+
let p :: Proxy blk
143+
p = Proxy @blk
144+
runPeer nullTracer
145+
146+
(codecChainSync
147+
(encodeNodeToNode codecCfg blockVersion)
148+
(decodeNodeToNode codecCfg blockVersion)
149+
(encodePoint (encodeRawHash @blk p))
150+
(decodePoint (decodeRawHash @blk p))
151+
(encodeTip (encodeRawHash @blk p))
152+
(decodeTip (decodeRawHash @blk p))
153+
:: _ (_ (Header blk) (Point blk) (Tip blk)) DeserialiseFailure m BL.ByteString
154+
)
155+
156+
channel
127157
$ chainSyncServerPeer $ csrServer $ prChainSync res
128158
, mkMiniProtocol
129159
Mux.StartOnDemand
@@ -133,8 +163,9 @@ peerSimServer res csChanTMV bfChanTMV codecCfg encAddr decAddr networkMagic = do
133163
$ \_ctx channel -> do
134164
say "hello from bf"
135165
atomically $ writeTVar bfChanTMV True
136-
runPeer nullTracer cBlockFetchCodec channel
137-
$ blockFetchServerPeer $ bfrServer $ prBlockFetch res
166+
undefined
167+
-- runPeer nullTracer cBlockFetchCodec channel
168+
-- $ blockFetchServerPeer $ bfrServer $ prBlockFetch res
138169
, mkMiniProtocol
139170
Mux.StartOnDemand
140171
N2N.txSubmissionMiniProtocolNum
@@ -143,12 +174,12 @@ peerSimServer res csChanTMV bfChanTMV codecCfg encAddr decAddr networkMagic = do
143174
$ \_ctx _channel -> forever $ threadDelay 10
144175
]
145176
where
146-
Consensus.N2N.Codecs
147-
{ cKeepAliveCodec
148-
, cChainSyncCodec
149-
, cBlockFetchCodec
150-
} =
151-
Consensus.N2N.defaultCodecs codecCfg blockVersion encAddr decAddr version
177+
-- Consensus.N2N.Codecs
178+
-- { cKeepAliveCodec
179+
-- , cChainSyncCodec
180+
-- , cBlockFetchCodec
181+
-- } =
182+
-- Consensus.N2N.defaultCodecs codecCfg blockVersion encAddr decAddr version
152183

153184
mkMiniProtocol miniProtocolStart miniProtocolNum limits proto =
154185
MiniProtocol

ouroboros-consensus-diffusion/app/conformance-test-runner/Server.hs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
module Server (run) where
99

10+
import Ouroboros.Consensus.Node.Serialisation
11+
import Ouroboros.Consensus.Node.ProtocolInfo (NumCoreNodes (..))
1012
import Test.Consensus.PeerSimulator.Resources (PeerResources)
1113
import Control.ResourceRegistry
1214
import Control.Tracer
@@ -34,6 +36,8 @@ import qualified Ouroboros.Network.Protocol.Handshake as Handshake
3436
import qualified Ouroboros.Network.Server.Simple as Server
3537
import qualified Ouroboros.Network.Snocket as Snocket
3638
import Ouroboros.Network.Socket (SomeResponderApplication (..), configureSocket)
39+
import Test.Util.TestBlock (TestBlock)
40+
import qualified Test.Util.TestBlock as TB
3741

3842
-- | Glue code for using just the bits from the Diffusion Layer that we need in
3943
-- this context.
@@ -65,9 +69,10 @@ serve sockAddr application = withIOManager \iocp ->
6569
run ::
6670
forall blk.
6771
( SupportedNetworkProtocolVersion blk
68-
, SerialiseNodeToNodeConstraints blk
72+
-- , SerialiseNodeToNodeConstraints blk
73+
, SerialiseNodeToNode blk (Header blk)
6974
, ConfigSupportsNode blk
70-
, blk ~ SimpleBlock SimpleMockCrypto SimplePraosRuleExt
75+
, blk ~ TestBlock
7176
) =>
7277
PeerResources IO blk ->
7378
-- | A TMVar for the chainsync channel that we will fill in once the node connects.
@@ -78,11 +83,11 @@ run ::
7883
IO Void
7984
run res csChanTMV bfChanTMV sockAddr = withRegistry \_registry ->
8085
serve sockAddr
81-
$ peerSimServer @_ @(SimpleBlock SimpleMockCrypto SimplePraosRuleExt)
86+
$ peerSimServer @_ @TestBlock
8287
res
8388
csChanTMV
8489
bfChanTMV
85-
SimpleCodecConfig
90+
TB.TestBlockCodecConfig
8691
encodeRemoteAddress
8792
decodeRemoteAddress
88-
$ getNetworkMagic @(SimpleBlock SimpleMockCrypto SimplePraosRuleExt) SimpleBlockConfig
93+
$ getNetworkMagic @TestBlock $ TB.TestBlockConfig $ NumCoreNodes 0

ouroboros-consensus-diffusion/ouroboros-consensus-diffusion.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ executable conformance-test-runner
342342
containers,
343343
optparse-applicative,
344344
ouroboros-network:{ouroboros-network, orphan-instances},
345-
ouroboros-consensus:{ouroboros-consensus, unstable-mock-block},
345+
ouroboros-consensus:{ouroboros-consensus, unstable-mock-block, unstable-consensus-testlib},
346346
ouroboros-network-api,
347347
unstable-consensus-conformance-testlib,
348348
aeson,

ouroboros-consensus/src/unstable-consensus-testlib/Test/Util/TestBlock.hs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,13 @@ data Validity = Valid | Invalid
226226
deriving stock (Show, Eq, Ord, Enum, Bounded, Generic)
227227
deriving anyclass (Serialise, NoThunks, ToExpr)
228228

229+
230+
instance SupportedNetworkProtocolVersion (TestBlockWith ptype) where
231+
supportedNodeToNodeVersions _ = foldMap (flip Map.singleton ()) [minBound .. maxBound]
232+
supportedNodeToClientVersions _ = foldMap (flip Map.singleton ()) [minBound .. maxBound]
233+
234+
latestReleasedNodeVersion = latestReleasedNodeVersionDefault
235+
229236
-- | Test block parametrized on the payload type
230237
--
231238
-- For blocks without payload see the 'TestBlock' type alias.

0 commit comments

Comments
 (0)