Skip to content

Commit 773fa5c

Browse files
committed
Remove Shelley and Byron operation modes in cardano tools
1 parent 6b130b1 commit 773fa5c

File tree

16 files changed

+57
-529
lines changed

16 files changed

+57
-529
lines changed

ouroboros-consensus-cardano/README.md

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -68,21 +68,6 @@ A block with the corresponding slot number must exist in the ImmutableDB.
6868
For certain analyses, a snapshot at that slot number must exist in `DB_PATH/ledger/SLOT_NUMBER_db-analyser` - where `SLOT_NUMBER` is the value provided by the user with the `--analyse-from` flag.
6969
The user can use snapshots created by the node or they can create their own snapshots via db-analyser - see the `--store-ledger` command
7070

71-
#### COMMAND
72-
73-
There are three options: `byron`, `shelley`, `cardano`. When in doubt which one to use, use `cardano`.
74-
75-
* `byron`
76-
77-
User should run this if they are dealing with Byron only chain. When the command is `byron` then user must provide `--configByron PATH` pointing to a byron configuration file.
78-
79-
* `shelley`
80-
81-
User should run this if they are dealing with Shelley only chain (neither Byron nor Allegra or any other era that comes after). When the command is `shelley` then user must provide `--configShelley PATH` pointing to a shelley configuration file. They may also provide `--genesisHash HASH` and `--threshold THRESHOLD`
82-
83-
* `cardano`
84-
User should run this if they are dealing with a `cardano` chain.
85-
8671
#### --num-blocks-to-process
8772

8873
```
@@ -215,7 +200,7 @@ Suppose we have a local chain database in reachable from `$NODE_HOME`, and we
215200
want to take a snapshot of the ledger state for slot `100`. Then we can run:
216201

217202
```sh
218-
cabal run exe:db-analyser -- cardano \
203+
cabal run exe:db-analyser -- \
219204
--config $NODE_HOME/configuration/cardano/mainnet-config.json \
220205
--db $NODE_HOME/mainnet/db \
221206
--store-ledger 100
@@ -225,7 +210,7 @@ If we had a previous snapshot of the ledger state, say corresponding to slot
225210
`50`, it is possible to tell `db-analyser` to start from this snapshot:
226211

227212
```sh
228-
cabal run exe:db-analyser -- cardano \
213+
cabal run exe:db-analyser -- \
229214
--config $NODE_HOME/configuration/cardano/mainnet-config.json \
230215
--db $NODE_HOME/mainnet/db \
231216
--analyse-from 50 \
@@ -238,7 +223,7 @@ To benchmark the ledger operations, using the setup mentioned in the foregoing
238223
examples, one could run the tool as follows:
239224

240225
```sh
241-
cabal run exe:db-analyser -- cardano
226+
cabal run exe:db-analyser -- \
242227
--config $NODE_HOME/configuration/cardano/mainnet-config.json \
243228
--db $NODE_HOME/mainnet/db \
244229
--analyse-from 100 \
@@ -250,7 +235,7 @@ The benchmarking command can be combined with `--num-blocks-to-process` to
250235
specify the application of how many blocks we want to process. Eg:
251236

252237
```sh
253-
cabal run exe:db-analyser -- cardano
238+
cabal run exe:db-analyser -- \
254239
--config $NODE_HOME/configuration/cardano/mainnet-config.json \
255240
--db $NODE_HOME/mainnet/db \
256241
--analyse-from 100 \
@@ -284,7 +269,7 @@ First, run the following command for both of your ChainDBs:
284269

285270
```
286271
db-analyser --analyse-from 1234 --db /path/to/dbX --show-slot-block-no \
287-
cardano --config /path/to/config.json | cut -d ' ' -f 2- > dbX.log
272+
--config /path/to/config.json | cut -d ' ' -f 2- > dbX.log
288273
```
289274

290275
Note that specificying `--analyse-from` is optional; it means that you are

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 & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,10 @@
33
{-# LANGUAGE ScopedTypeVariables #-}
44

55
-- | Database analysis tool.
6-
--
7-
-- Usage: db-analyser --db PATH [--verbose] [--analyse-from SLOT_NUMBER]
8-
-- [--db-validation ARG]
9-
-- [--show-slot-block-no | --count-tx-outputs |
10-
-- --show-block-header-size | --show-block-txs-size |
11-
-- --show-ebbs | --store-ledger SLOT_NUMBER
12-
-- [--full-ledger-validation] |
13-
-- --count-blocks | --checkThunks BLOCK_COUNT |
14-
-- --trace-ledger | --repro-mempool-and-forge INT |
15-
-- --benchmark-ledger-ops [--out-file FILE] [--reapply] |
16-
-- --get-block-application-metrics NUM [--out-file FILE]]
17-
-- [--num-blocks-to-process INT] COMMAND
186
module Main (main) where
197

208
import Cardano.Crypto.Init (cryptoInit)
9+
import Cardano.Tools.DBAnalyser.Block.Cardano
2110
import Cardano.Tools.DBAnalyser.Run
2211
import Cardano.Tools.DBAnalyser.Types
2312
import Cardano.Tools.GitRev (gitRev)
@@ -38,13 +27,9 @@ import Options.Applicative
3827
main :: IO ()
3928
main = withStdTerminalHandles $ do
4029
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
30+
void $ uncurry analyse =<< getCmdLine
4631

47-
getCmdLine :: IO (DBAnalyserConfig, BlockType)
32+
getCmdLine :: IO (DBAnalyserConfig, CardanoBlockArgs)
4833
getCmdLine = execParser opts
4934
where
5035
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 & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -505,9 +505,6 @@ library unstable-cardano-tools
505505
hs-source-dirs: src/unstable-cardano-tools
506506
exposed-modules:
507507
Cardano.Api.Any
508-
Cardano.Api.Protocol.Types
509-
Cardano.Node.Protocol
510-
Cardano.Node.Protocol.Types
511508
Cardano.Node.Types
512509
Cardano.Tools.DBAnalyser.Analysis
513510
Cardano.Tools.DBAnalyser.Analysis.BenchmarkLedgerOps.FileWriting
@@ -608,7 +605,6 @@ executable db-analyser
608605
build-depends:
609606
base,
610607
cardano-crypto-class,
611-
cardano-crypto-wrapper,
612608
optparse-applicative,
613609
ouroboros-consensus,
614610
ouroboros-consensus-cardano:{ouroboros-consensus-cardano, unstable-cardano-tools},
@@ -666,7 +662,6 @@ executable db-truncater
666662
build-depends:
667663
base,
668664
cardano-crypto-class,
669-
cardano-crypto-wrapper,
670665
optparse-applicative,
671666
ouroboros-consensus,
672667
ouroboros-consensus-cardano:{ouroboros-consensus-cardano, unstable-cardano-tools},
@@ -697,7 +692,6 @@ executable snapshot-converter
697692
base,
698693
bytestring,
699694
cardano-crypto-class,
700-
cardano-crypto-wrapper,
701695
contra-tracer,
702696
filepath,
703697
fs-api,

0 commit comments

Comments
 (0)