Skip to content

Commit dfa6f4b

Browse files
committed
Remove Shelley and Byron operation modes in cardano tools
1 parent 241b90c commit dfa6f4b

File tree

7 files changed

+42
-111
lines changed

7 files changed

+42
-111
lines changed

ouroboros-consensus-cardano/app/DBAnalyser/Parsers.hs

Lines changed: 5 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,25 @@
22
{-# LANGUAGE LambdaCase #-}
33

44
module DBAnalyser.Parsers
5-
( BlockType (..)
6-
, blockTypeParser
7-
, parseCmdLine
5+
( parseCmdLine
6+
, parseCardanoArgs
7+
, CardanoBlockArgs
88
) where
99

10-
import Cardano.Crypto (RequiresNetworkMagic (..))
1110
import Cardano.Tools.DBAnalyser.Analysis
12-
import Cardano.Tools.DBAnalyser.Block.Byron
1311
import Cardano.Tools.DBAnalyser.Block.Cardano
14-
import Cardano.Tools.DBAnalyser.Block.Shelley
1512
import Cardano.Tools.DBAnalyser.Types
1613
import qualified Data.Foldable as Foldable
1714
import Options.Applicative
1815
import Ouroboros.Consensus.Block (SlotNo (..), WithOrigin (..))
1916
import Ouroboros.Consensus.Byron.Node (PBftSignatureThreshold (..))
20-
import Ouroboros.Consensus.Shelley.Node (Nonce (..))
2117

2218
{-------------------------------------------------------------------------------
2319
Parsing
2420
-------------------------------------------------------------------------------}
2521

26-
parseCmdLine :: Parser (DBAnalyserConfig, BlockType)
27-
parseCmdLine = (,) <$> parseDBAnalyserConfig <*> blockTypeParser
22+
parseCmdLine :: Parser (DBAnalyserConfig, CardanoBlockArgs)
23+
parseCmdLine = (,) <$> parseDBAnalyserConfig <*> parseCardanoArgs
2824

2925
parseDBAnalyserConfig :: Parser DBAnalyserConfig
3026
parseDBAnalyserConfig =
@@ -259,65 +255,12 @@ pMaybeOutputFile =
259255
Parse BlockType-specific arguments
260256
-------------------------------------------------------------------------------}
261257

262-
data BlockType
263-
= ByronBlock ByronBlockArgs
264-
| ShelleyBlock ShelleyBlockArgs
265-
| CardanoBlock CardanoBlockArgs
266-
267-
blockTypeParser :: Parser BlockType
268-
blockTypeParser =
269-
subparser $
270-
mconcat
271-
[ command
272-
"byron"
273-
(info (parseByronType <**> helper) (progDesc "Analyse a Byron-only DB"))
274-
, command
275-
"shelley"
276-
(info (parseShelleyType <**> helper) (progDesc "Analyse a Shelley-only DB"))
277-
, command
278-
"cardano"
279-
(info (parseCardanoType <**> helper) (progDesc "Analyse a Cardano DB"))
280-
]
281-
282-
parseByronType :: Parser BlockType
283-
parseByronType = ByronBlock <$> parseByronArgs
284-
285-
parseShelleyType :: Parser BlockType
286-
parseShelleyType = ShelleyBlock <$> parseShelleyArgs
287-
288-
parseCardanoType :: Parser BlockType
289-
parseCardanoType = CardanoBlock <$> parseCardanoArgs
290-
291258
parseCardanoArgs :: Parser CardanoBlockArgs
292259
parseCardanoArgs =
293260
CardanoBlockArgs
294261
<$> parseConfigFile
295262
<*> parsePBftSignatureThreshold
296263

297-
parseShelleyArgs :: Parser ShelleyBlockArgs
298-
parseShelleyArgs =
299-
ShelleyBlockArgs
300-
<$> strOption
301-
( mconcat
302-
[ long "configShelley"
303-
, help "Path to config file"
304-
, metavar "PATH"
305-
]
306-
)
307-
<*> Foldable.asum
308-
[ Nonce <$> parseNonce
309-
, pure NeutralNonce
310-
]
311-
where
312-
parseNonce =
313-
strOption
314-
( mconcat
315-
[ long "nonce"
316-
, help "Initial nonce, i.e., hash of the genesis config file"
317-
, metavar "NONCE"
318-
]
319-
)
320-
321264
parseConfigFile :: Parser FilePath
322265
parseConfigFile =
323266
strOption $
@@ -337,27 +280,3 @@ parsePBftSignatureThreshold =
337280
, help "PBftSignatureThreshold"
338281
, metavar "THRESHOLD"
339282
]
340-
341-
parseByronArgs :: Parser ByronBlockArgs
342-
parseByronArgs =
343-
ByronBlockArgs
344-
<$> parseConfigFile
345-
<*> flag
346-
RequiresNoMagic
347-
RequiresMagic
348-
( mconcat
349-
[ long "requires-magic"
350-
, help "The DB contains blocks from a testnet, requiring network magic, rather than mainnet"
351-
]
352-
)
353-
<*> optional
354-
( option
355-
auto
356-
( mconcat
357-
[ long "genesisHash"
358-
, help "Expected genesis hash"
359-
, metavar "HASH"
360-
]
361-
)
362-
)
363-
<*> parsePBftSignatureThreshold

ouroboros-consensus-cardano/app/DBTruncater/Parsers.hs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import DBAnalyser.Parsers
55
import Options.Applicative
66
import Ouroboros.Consensus.Block.Abstract
77

8-
commandLineParser :: Parser (DBTruncaterConfig, BlockType)
9-
commandLineParser = (,) <$> parseDBTruncaterConfig <*> blockTypeParser
8+
commandLineParser :: Parser (DBTruncaterConfig, CardanoBlockArgs)
9+
commandLineParser = (,) <$> parseDBTruncaterConfig <*> parseCardanoArgs
1010

1111
parseDBTruncaterConfig :: Parser DBTruncaterConfig
1212
parseDBTruncaterConfig =
@@ -23,6 +23,7 @@ parseDBTruncaterConfig =
2323
, metavar "PATH"
2424
]
2525
parseVerbose = switch (long "verbose" <> help "Enable verbose logging")
26+
2627
parseTruncateAfter :: Parser TruncateAfter
2728
parseTruncateAfter =
2829
fmap TruncateAfterSlot slotNoOption <|> fmap TruncateAfterBlock blockNoOption

ouroboros-consensus-cardano/app/db-analyser.hs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
module Main (main) where
1919

2020
import Cardano.Crypto.Init (cryptoInit)
21+
import Cardano.Tools.DBAnalyser.Block.Cardano
2122
import Cardano.Tools.DBAnalyser.Run
2223
import Cardano.Tools.DBAnalyser.Types
2324
import Cardano.Tools.GitRev (gitRev)
@@ -38,13 +39,9 @@ import Options.Applicative
3839
main :: IO ()
3940
main = withStdTerminalHandles $ do
4041
cryptoInit
41-
(conf, blocktype) <- getCmdLine
42-
void $ case blocktype of
43-
ByronBlock args -> analyse conf args
44-
ShelleyBlock args -> analyse conf args
45-
CardanoBlock args -> analyse conf args
42+
void $ uncurry analyse =<< getCmdLine
4643

47-
getCmdLine :: IO (DBAnalyserConfig, BlockType)
44+
getCmdLine :: IO (DBAnalyserConfig, CardanoBlockArgs)
4845
getCmdLine = execParser opts
4946
where
5047
opts =

ouroboros-consensus-cardano/app/db-truncater.hs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module Main (main) where
33
import Cardano.Crypto.Init (cryptoInit)
44
import Cardano.Tools.DBTruncater.Run
55
import Cardano.Tools.DBTruncater.Types
6-
import DBAnalyser.Parsers (BlockType (..))
6+
import DBAnalyser.Parsers
77
import qualified DBTruncater.Parsers as DBTruncater
88
import Main.Utf8 (withStdTerminalHandles)
99
import Options.Applicative
@@ -20,13 +20,9 @@ import Prelude hiding (truncate)
2020
main :: IO ()
2121
main = withStdTerminalHandles $ do
2222
cryptoInit
23-
(conf, blocktype) <- getCommandLineConfig
24-
case blocktype of
25-
ByronBlock args -> truncate conf args
26-
ShelleyBlock args -> truncate conf args
27-
CardanoBlock args -> truncate conf args
23+
uncurry truncate =<< getCommandLineConfig
2824

29-
getCommandLineConfig :: IO (DBTruncaterConfig, BlockType)
25+
getCommandLineConfig :: IO (DBTruncaterConfig, CardanoBlockArgs)
3026
getCommandLineConfig = execParser opts
3127
where
3228
opts =

ouroboros-consensus-cardano/app/snapshot-converter.hs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,11 @@ data Config = Config
6666
-- ^ Path to the output snapshot
6767
}
6868

69-
getCommandLineConfig :: IO (Config, BlockType)
69+
getCommandLineConfig :: IO (Config, CardanoBlockArgs)
7070
getCommandLineConfig =
7171
execParser $
7272
info
73-
((,) <$> parseConfig <*> blockTypeParser <**> helper)
73+
((,) <$> parseConfig <*> parseCardanoArgs <**> helper)
7474
(fullDesc <> progDesc "Utility for converting snapshots to and from UTxO-HD")
7575

7676
parseConfig :: Parser Config
@@ -260,11 +260,7 @@ store _ _ _ _ = error "Malformed output path!"
260260
main :: IO ()
261261
main = withStdTerminalHandles $ do
262262
cryptoInit
263-
(conf, blocktype) <- getCommandLineConfig
264-
case blocktype of
265-
ByronBlock args -> run conf args
266-
ShelleyBlock args -> run conf args
267-
CardanoBlock args -> run conf args
263+
uncurry run =<< getCommandLineConfig
268264
where
269265
run conf args = do
270266
ccfg <- configCodec . pInfoConfig <$> mkProtocolInfo args
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<!--
2+
A new scriv changelog fragment.
3+
4+
Uncomment the section that is right (remove the HTML comment wrapper).
5+
For top level release notes, leave all the headers commented out.
6+
-->
7+
8+
<!--
9+
### Patch
10+
11+
- A bullet item for the Patch category.
12+
13+
-->
14+
<!--
15+
### Non-Breaking
16+
17+
- A bullet item for the Non-Breaking category.
18+
19+
-->
20+
<!--
21+
### Breaking
22+
23+
- A bullet item for the Breaking category.
24+
25+
-->

ouroboros-consensus-cardano/ouroboros-consensus-cardano.cabal

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,6 @@ executable db-analyser
608608
build-depends:
609609
base,
610610
cardano-crypto-class,
611-
cardano-crypto-wrapper,
612611
optparse-applicative,
613612
ouroboros-consensus,
614613
ouroboros-consensus-cardano:{ouroboros-consensus-cardano, unstable-cardano-tools},
@@ -666,7 +665,6 @@ executable db-truncater
666665
build-depends:
667666
base,
668667
cardano-crypto-class,
669-
cardano-crypto-wrapper,
670668
optparse-applicative,
671669
ouroboros-consensus,
672670
ouroboros-consensus-cardano:{ouroboros-consensus-cardano, unstable-cardano-tools},
@@ -697,7 +695,6 @@ executable snapshot-converter
697695
base,
698696
bytestring,
699697
cardano-crypto-class,
700-
cardano-crypto-wrapper,
701698
contra-tracer,
702699
filepath,
703700
fs-api,

0 commit comments

Comments
 (0)