Skip to content

Commit e88d5af

Browse files
authored
Merge pull request IntersectMBO#5518 from input-output-hk/newhoggy/remove-ByronMode-and-ShelleyMode-support
Remove `ByronMode` and `ShelleyMode` support
2 parents 865b996 + 5d56fdd commit e88d5af

File tree

10 files changed

+151
-153
lines changed

10 files changed

+151
-153
lines changed

bench/tx-generator/src/Cardano/TxGenerator/Setup/NodeConfig.hs

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,19 +40,17 @@ getGenesis (SomeConsensusProtocol CardanoBlockType proto)
4040

4141
-- | extract the path to genesis file from a NodeConfiguration for Cardano protocol
4242
getGenesisPath :: NodeConfiguration -> Maybe GenesisFile
43-
getGenesisPath nodeConfig
44-
= case ncProtocolConfig nodeConfig of
45-
NodeProtocolConfigurationCardano _ shelleyConfig _ _ _ -> Just $ npcShelleyGenesisFile shelleyConfig
46-
_ -> Nothing
43+
getGenesisPath nodeConfig =
44+
case ncProtocolConfig nodeConfig of
45+
NodeProtocolConfigurationCardano _ shelleyConfig _ _ _ ->
46+
Just $ npcShelleyGenesisFile shelleyConfig
4747

4848
mkConsensusProtocol :: NodeConfiguration -> IO (Either TxGenError SomeConsensusProtocol)
49-
mkConsensusProtocol nodeConfig
50-
= case ncProtocolConfig nodeConfig of
51-
NodeProtocolConfigurationByron _ -> pure $ Left $ TxGenError "NodeProtocolConfigurationByron not supported"
52-
NodeProtocolConfigurationShelley _ -> pure $ Left $ TxGenError "NodeProtocolConfigurationShelley not supported"
53-
NodeProtocolConfigurationCardano byronConfig shelleyConfig alonzoConfig conwayConfig hardforkConfig
54-
-> first ProtocolError
55-
<$> runExceptT (mkSomeConsensusProtocolCardano byronConfig shelleyConfig alonzoConfig conwayConfig hardforkConfig Nothing)
49+
mkConsensusProtocol nodeConfig =
50+
case ncProtocolConfig nodeConfig of
51+
NodeProtocolConfigurationCardano byronConfig shelleyConfig alonzoConfig conwayConfig hardforkConfig ->
52+
first ProtocolError
53+
<$> runExceptT (mkSomeConsensusProtocolCardano byronConfig shelleyConfig alonzoConfig conwayConfig hardforkConfig Nothing)
5654

5755
-- | Creates a NodeConfiguration from a config file;
5856
-- the result is devoid of any keys/credentials

cardano-node-chairman/app/Cardano/Chairman.hs

Lines changed: 34 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ import qualified Ouroboros.Network.Block as Block
3535
import Ouroboros.Network.Protocol.ChainSync.Client
3636

3737
import Cardano.Api
38-
import Cardano.Api.Byron
3938
import Cardano.Api.Shelley
4039

4140
-- | The chairman checks for consensus and progress.
@@ -51,17 +50,16 @@ import Cardano.Api.Shelley
5150
-- The consensus condition is checked incrementally as well as at the end, so
5251
-- that failures can be detected as early as possible. The progress condition
5352
-- is only checked at the end.
54-
chairmanTest
55-
:: Tracer IO String
53+
chairmanTest :: ()
54+
=> Tracer IO String
5655
-> NetworkId
5756
-> DiffTime
5857
-> BlockNo
5958
-> [SocketPath]
60-
-> AnyConsensusModeParams
59+
-> ConsensusModeParams CardanoMode
6160
-> SecurityParam
6261
-> IO ()
63-
chairmanTest tracer nw runningTime progressThreshold socketPaths
64-
(AnyConsensusModeParams cModeParams) secParam = do
62+
chairmanTest tracer nw runningTime progressThreshold socketPaths cModeParams secParam = do
6563
traceWith tracer ("Will observe nodes for " ++ show runningTime)
6664
traceWith tracer ("Will require chain growth of " ++ show progressThreshold)
6765

@@ -110,11 +108,11 @@ instance Exception ConsensusFailure where
110108
-- | For this test we define consensus as follows: for all pairs of chains,
111109
-- the intersection of each pair is within K blocks of each tip.
112110

113-
consensusCondition
114-
:: ConsensusBlockForMode mode ~ blk
111+
consensusCondition :: ()
112+
=> ConsensusBlockForMode CardanoMode ~ blk
115113
=> HasHeader (Header blk)
116114
=> ConvertRawHash blk
117-
=> ConsensusMode mode
115+
=> ConsensusMode CardanoMode
118116
-> Map PeerId (AnchoredFragment (Header blk))
119117
-> SecurityParam
120118
-> Either ConsensusFailure ConsensusSuccess
@@ -246,9 +244,9 @@ progressCondition minBlockNo (ConsensusSuccess _ tips) = do
246244
getBlockNo (ChainTip _ _ bNum) = bNum
247245
getBlockNo ChainTipAtGenesis = 0
248246

249-
runChairman
250-
:: forall mode blk. ConsensusBlockForMode mode ~ blk
251-
=> GetHeader (ConsensusBlockForMode mode)
247+
runChairman :: forall blk. ()
248+
=> ConsensusBlockForMode CardanoMode ~ blk
249+
=> GetHeader (ConsensusBlockForMode CardanoMode)
252250
=> Tracer IO String
253251
-> NetworkId
254252
-- ^ Security parameter, if a fork is deeper than it 'runChairman'
@@ -257,7 +255,7 @@ runChairman
257255
-- ^ Run for this much time.
258256
-> [SocketPath]
259257
-- ^ Local socket directory
260-
-> ConsensusModeParams mode
258+
-> ConsensusModeParams CardanoMode
261259
-> SecurityParam
262260
-> IO (Map SocketPath
263261
(AF.AnchoredSeq
@@ -312,41 +310,41 @@ addBlock sockPath chainsVar blk =
312310

313311
-- | Rollback a single block. If the rollback point is not found, we simply
314312
-- error. It should never happen if the security parameter is set up correctly.
315-
rollback
316-
:: forall mode blk. ConsensusBlockForMode mode ~ blk
313+
rollback :: forall blk. ()
314+
=> ConsensusBlockForMode CardanoMode ~ blk
317315
=> HasHeader (Header blk)
318316
=> SocketPath
319-
-> StrictTVar IO (Map SocketPath (AnchoredFragment (Header (ConsensusBlockForMode mode))))
320-
-> ConsensusMode mode
317+
-> StrictTVar IO (Map SocketPath (AnchoredFragment (Header (ConsensusBlockForMode CardanoMode))))
318+
-> ConsensusMode CardanoMode
321319
-> ChainPoint
322320
-> STM IO ()
323321
rollback sockPath chainsVar cMode p =
324322
modifyTVar chainsVar (Map.adjust fn sockPath)
325323
where
326-
p' :: Point (Header (ConsensusBlockForMode mode))
324+
p' :: Point (Header (ConsensusBlockForMode CardanoMode))
327325
p' = coerce $ toConsensusPointInMode cMode p
328326

329-
fn :: AnchoredFragment (Header (ConsensusBlockForMode mode))
330-
-> AnchoredFragment (Header (ConsensusBlockForMode mode))
327+
fn :: AnchoredFragment (Header (ConsensusBlockForMode CardanoMode))
328+
-> AnchoredFragment (Header (ConsensusBlockForMode CardanoMode))
331329
fn cf = case AF.rollback p' cf of
332330
Nothing -> error "rollback error: rollback beyond chain fragment"
333331
Just cf' -> cf'
334332

335333
-- Chain-Sync client
336334
type ChairmanTrace' = ConsensusSuccess
337335

338-
type ChainVar mode = StrictTVar IO (Map SocketPath (AnchoredFragment (Header (ConsensusBlockForMode mode))))
336+
type ChainVar = StrictTVar IO (Map SocketPath (AnchoredFragment (Header (ConsensusBlockForMode CardanoMode))))
339337

340338
-- | 'chainSyncClient which build chain fragment; on every roll forward it will
341339
-- check if there is consensus on immutable chain.
342340
chainSyncClient
343-
:: forall mode. GetHeader (ConsensusBlockForMode mode)
341+
:: GetHeader (ConsensusBlockForMode CardanoMode)
344342
=> Tracer IO ChairmanTrace'
345343
-> SocketPath
346-
-> ChainVar mode
347-
-> ConsensusModeParams mode
344+
-> ChainVar
345+
-> ConsensusModeParams CardanoMode
348346
-> SecurityParam
349-
-> ChainSyncClient (BlockInMode mode) ChainPoint ChainTip IO ()
347+
-> ChainSyncClient (BlockInMode CardanoMode) ChainPoint ChainTip IO ()
350348
chainSyncClient tracer sockPath chainsVar cModeP secParam = ChainSyncClient $ pure $
351349
-- Notify the core node about the our latest points at which we are
352350
-- synchronised. This client is not persistent and thus it just
@@ -359,10 +357,10 @@ chainSyncClient tracer sockPath chainsVar cModeP secParam = ChainSyncClient $ pu
359357
, recvMsgIntersectNotFound = \ _ -> ChainSyncClient $ pure clientStIdle
360358
}
361359
where
362-
clientStIdle :: ClientStIdle (BlockInMode mode) ChainPoint ChainTip IO ()
360+
clientStIdle :: ClientStIdle (BlockInMode CardanoMode) ChainPoint ChainTip IO ()
363361
clientStIdle = SendMsgRequestNext clientStNext (pure clientStNext)
364362

365-
clientStNext :: ClientStNext (BlockInMode mode) ChainPoint ChainTip IO ()
363+
clientStNext :: ClientStNext (BlockInMode CardanoMode) ChainPoint ChainTip IO ()
366364
clientStNext = ClientStNext
367365
{ recvMsgRollForward = \blk _tip -> ChainSyncClient $ do
368366
-- add block & check if there is consensus on immutable chain
@@ -384,33 +382,27 @@ chainSyncClient tracer sockPath chainsVar cModeP secParam = ChainSyncClient $ pu
384382
-- Helpers
385383

386384
obtainHasHeader
387-
:: ConsensusBlockForMode mode ~ blk
388-
=> ConsensusMode mode
389-
-> ((HasHeader (Header blk), ConvertRawHash (ConsensusBlockForMode mode)) => a)
385+
:: ConsensusBlockForMode CardanoMode ~ blk
386+
=> ConsensusMode CardanoMode
387+
-> ((HasHeader (Header blk), ConvertRawHash (ConsensusBlockForMode CardanoMode)) => a)
390388
-> a
391-
obtainHasHeader ByronMode f = f
392-
obtainHasHeader ShelleyMode f = f
393389
obtainHasHeader CardanoMode f = f
394390

395391
obtainGetHeader
396-
:: ConsensusMode mode
397-
-> ( (GetHeader (ConsensusBlockForMode mode)
392+
:: ConsensusMode CardanoMode
393+
-> ( (GetHeader (ConsensusBlockForMode CardanoMode)
398394
) => a)
399395
-> a
400-
obtainGetHeader ByronMode f = f
401-
obtainGetHeader ShelleyMode f = f
402396
obtainGetHeader CardanoMode f = f
403397

404398
-- | Check that all nodes agree with each other, within the security parameter.
405399
checkConsensus
406-
:: HasHeader (Header (ConsensusBlockForMode mode))
407-
=> ConvertRawHash (ConsensusBlockForMode mode)
408-
=> ConsensusMode mode
409-
-> ChainVar mode
400+
:: HasHeader (Header (ConsensusBlockForMode CardanoMode))
401+
=> ConvertRawHash (ConsensusBlockForMode CardanoMode)
402+
=> ConsensusMode CardanoMode
403+
-> ChainVar
410404
-> SecurityParam
411405
-> STM IO ConsensusSuccess
412406
checkConsensus cMode chainsVar secParam = do
413407
chainsSnapshot <- readTVar chainsVar
414408
either throwIO return $ consensusCondition cMode chainsSnapshot secParam
415-
416-

cardano-node-chairman/app/Cardano/Chairman/Commands/Run.hs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -139,15 +139,11 @@ run RunOpts
139139

140140
return ()
141141
where
142-
getConsensusMode :: SecurityParam -> NodeProtocolConfiguration -> AnyConsensusModeParams
142+
getConsensusMode :: SecurityParam -> NodeProtocolConfiguration -> ConsensusModeParams CardanoMode
143143
getConsensusMode (SecurityParam k) ncProtocolConfig =
144144
case ncProtocolConfig of
145-
NodeProtocolConfigurationByron{} ->
146-
AnyConsensusModeParams $ ByronModeParams $ EpochSlots k
147-
NodeProtocolConfigurationShelley{} ->
148-
AnyConsensusModeParams ShelleyModeParams
149145
NodeProtocolConfigurationCardano{} ->
150-
AnyConsensusModeParams $ CardanoModeParams $ EpochSlots k
146+
CardanoModeParams $ EpochSlots k
151147

152148
getProtocolConfiguration
153149
:: PartialNodeConfiguration

cardano-node/cardano-node.cabal

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ test-suite cardano-node-test
238238
, aeson
239239
, bytestring
240240
, cardano-crypto-class
241+
, cardano-crypto-wrapper
241242
, cardano-api
242243
, cardano-ledger-core
243244
, cardano-node

cardano-node/src/Cardano/Node/Configuration/POM.hs

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -257,21 +257,17 @@ instance FromJSON PartialNodeConfiguration where
257257
else return $ Last $ Just PartialTracingOff
258258

259259
-- Protocol parameters
260-
protocol <- v .:? "Protocol" .!= ByronProtocol
260+
protocol <- v .:? "Protocol" .!= CardanoProtocol
261261
pncProtocolConfig <-
262262
case protocol of
263-
ByronProtocol ->
264-
Last . Just . NodeProtocolConfigurationByron <$> parseByronProtocol v
265-
266-
ShelleyProtocol ->
267-
Last . Just . NodeProtocolConfigurationShelley <$> parseShelleyProtocol v
268-
269263
CardanoProtocol ->
270-
Last . Just <$> (NodeProtocolConfigurationCardano <$> parseByronProtocol v
271-
<*> parseShelleyProtocol v
272-
<*> parseAlonzoProtocol v
273-
<*> parseConwayProtocol v
274-
<*> parseHardForkProtocol v)
264+
fmap (Last . Just) $
265+
NodeProtocolConfigurationCardano
266+
<$> parseByronProtocol v
267+
<*> parseShelleyProtocol v
268+
<*> parseAlonzoProtocol v
269+
<*> parseConwayProtocol v
270+
<*> parseHardForkProtocol v
275271
pncMaybeMempoolCapacityOverride <- Last <$> parseMempoolCapacityBytesOverride v
276272

277273
-- Network timeouts
@@ -619,16 +615,14 @@ makeNodeConfiguration pnc = do
619615
ncProtocol :: NodeConfiguration -> Protocol
620616
ncProtocol nc =
621617
case ncProtocolConfig nc of
622-
NodeProtocolConfigurationByron{} -> ByronProtocol
623-
NodeProtocolConfigurationShelley{} -> ShelleyProtocol
618+
-- NodeProtocolConfigurationByron{} -> ByronProtocol -- jky delete me
619+
-- NodeProtocolConfigurationShelley{} -> ShelleyProtocol -- jky delete me
624620
NodeProtocolConfigurationCardano{} -> CardanoProtocol
625621

626622
pncProtocol :: PartialNodeConfiguration -> Either Text Protocol
627623
pncProtocol pnc =
628624
case pncProtocolConfig pnc of
629625
Last Nothing -> Left "Node protocol configuration not found"
630-
Last (Just NodeProtocolConfigurationByron{}) -> Right ByronProtocol
631-
Last (Just NodeProtocolConfigurationShelley{}) -> Right ShelleyProtocol
632626
Last (Just NodeProtocolConfigurationCardano{}) -> Right CardanoProtocol
633627

634628
parseNodeConfigurationFP :: Maybe ConfigYamlFilePath -> IO PartialNodeConfiguration

cardano-node/src/Cardano/Node/Protocol.hs

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -27,29 +27,21 @@ mkConsensusProtocol
2727
-> Maybe ProtocolFilepaths
2828
-> ExceptT ProtocolInstantiationError IO SomeConsensusProtocol
2929
mkConsensusProtocol ncProtocolConfig mProtocolFiles =
30-
case ncProtocolConfig of
31-
32-
NodeProtocolConfigurationByron config ->
33-
firstExceptT ByronProtocolInstantiationError $
34-
mkSomeConsensusProtocolByron config mProtocolFiles
35-
36-
NodeProtocolConfigurationShelley config ->
37-
firstExceptT ShelleyProtocolInstantiationError $
38-
mkSomeConsensusProtocolShelley config mProtocolFiles
39-
40-
NodeProtocolConfigurationCardano byronConfig
41-
shelleyConfig
42-
alonzoConfig
43-
conwayConfig
44-
hardForkConfig ->
45-
firstExceptT CardanoProtocolInstantiationError $
46-
mkSomeConsensusProtocolCardano
47-
byronConfig
48-
shelleyConfig
49-
alonzoConfig
50-
conwayConfig
51-
hardForkConfig
52-
mProtocolFiles
30+
case ncProtocolConfig of
31+
NodeProtocolConfigurationCardano
32+
byronConfig
33+
shelleyConfig
34+
alonzoConfig
35+
conwayConfig
36+
hardForkConfig ->
37+
firstExceptT CardanoProtocolInstantiationError $
38+
mkSomeConsensusProtocolCardano
39+
byronConfig
40+
shelleyConfig
41+
alonzoConfig
42+
conwayConfig
43+
hardForkConfig
44+
mProtocolFiles
5345

5446
------------------------------------------------------------------------------
5547
-- Errors

cardano-node/src/Cardano/Node/Protocol/Types.hs

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,10 @@ import GHC.Generics (Generic)
2424
import NoThunks.Class (NoThunks)
2525

2626

27-
data Protocol = ByronProtocol
28-
| ShelleyProtocol
29-
| CardanoProtocol
27+
data Protocol = CardanoProtocol
3028
deriving (Eq, Generic)
3129

3230
instance Show Protocol where
33-
show ByronProtocol = "Byron"
34-
show ShelleyProtocol = "Shelley"
3531
show CardanoProtocol = "Byron; Shelley"
3632

3733
deriving instance NFData Protocol
@@ -40,18 +36,8 @@ deriving instance NoThunks Protocol
4036
instance FromJSON Protocol where
4137
parseJSON =
4238
withText "Protocol" $ \str -> case str of
43-
44-
-- The new names
45-
"Byron" -> pure ByronProtocol
46-
"Shelley" -> pure ShelleyProtocol
4739
"Cardano" -> pure CardanoProtocol
48-
49-
-- The old names
50-
"RealPBFT" -> pure ByronProtocol
51-
"TPraos" -> pure ShelleyProtocol
52-
53-
_ -> fail $ "Parsing of Protocol failed. "
54-
<> show str <> " is not a valid protocol"
40+
_ -> fail $ "Parsing of Protocol failed. " <> show str <> " is not a valid protocol"
5541

5642
data SomeConsensusProtocol where
5743

0 commit comments

Comments
 (0)