Skip to content

Commit 8f3933e

Browse files
committed
Update to cardano-api-10.21
1 parent 976802a commit 8f3933e

File tree

3 files changed

+25
-65
lines changed

3 files changed

+25
-65
lines changed

cardano-cli/cardano-cli.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ library
241241
binary,
242242
bytestring,
243243
canonical-json,
244-
cardano-api ^>=10.20,
244+
cardano-api ^>=10.21,
245245
cardano-binary,
246246
cardano-crypto,
247247
cardano-crypto-class ^>=2.2.3.2,

cardano-cli/src/Cardano/CLI/EraIndependent/Debug/CheckNodeConfiguration/Run.hs

Lines changed: 24 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import Cardano.CLI.Type.Error.DebugCmdError
1414
import Cardano.Crypto.Hash qualified as Crypto
1515

1616
import Control.Monad
17+
import Data.Foldable (for_)
1718
import Data.Text qualified as Text
1819
import Data.Yaml qualified as Yaml
1920
import System.FilePath (takeDirectory, (</>))
@@ -33,61 +34,39 @@ checkNodeGenesisConfiguration
3334
-- ^ The parsed node configuration file
3435
-> CIO e ()
3536
checkNodeGenesisConfiguration configFile nodeConfig = do
36-
let byronGenFile = adjustFilepath $ unFile $ ncByronGenesisFile nodeConfig
37-
alonzoGenFile = adjustFilepath $ unFile $ ncAlonzoGenesisFile nodeConfig
38-
shelleyGenFile = adjustFilepath $ unFile $ ncShelleyGenesisFile nodeConfig
39-
conwayGenFile <- case ncConwayGenesisFile nodeConfig of
40-
Nothing -> throwCliError $ DebugNodeConfigNoConwayFileCmdError configFilePath
41-
Just conwayGenesisFile -> pure $ adjustFilepath $ unFile conwayGenesisFile
37+
let byronGenFile = adjustFilepath $ ncByronGenesisFile nodeConfig
38+
alonzoGenFile = adjustFilepath $ ncAlonzoGenesisFile nodeConfig
39+
shelleyGenFile = adjustFilepath $ ncShelleyGenesisFile nodeConfig
40+
conwayGenFile = adjustFilepath $ ncConwayGenesisFile nodeConfig
4241

4342
liftIO $ putStrLn $ "Checking byron genesis file: " <> byronGenFile
4443

45-
let expectedByronHash = unGenesisHashByron $ ncByronGenesisHash nodeConfig
46-
expectedAlonzoHash = Crypto.hashToTextAsHex $ unGenesisHashAlonzo $ ncAlonzoGenesisHash nodeConfig
47-
expectedShelleyHash = Crypto.hashToTextAsHex $ unGenesisHashShelley $ ncShelleyGenesisHash nodeConfig
48-
expectedConwayHash <- case ncConwayGenesisHash nodeConfig of
49-
Nothing -> throwCliError $ DebugNodeConfigNoConwayHashCmdError configFilePath
50-
Just conwayGenesisHash -> pure $ Crypto.hashToTextAsHex $ unGenesisHashConway conwayGenesisHash
44+
let mExpectedByronHash = unGenesisHashByron <$> ncByronGenesisHash nodeConfig
45+
mExpectedAlonzoHash = Crypto.hashToTextAsHex . unGenesisHashAlonzo <$> ncAlonzoGenesisHash nodeConfig
46+
mExpectedShelleyHash = Crypto.hashToTextAsHex . unGenesisHashShelley <$> ncShelleyGenesisHash nodeConfig
47+
mExpectedConwayHash = Crypto.hashToTextAsHex . unGenesisHashConway <$> ncConwayGenesisHash nodeConfig
5148

52-
(_, Byron.GenesisHash byronHash) <-
53-
fromExceptTCli $
54-
Byron.readGenesisData byronGenFile
55-
let actualByronHash = Text.pack $ show byronHash
49+
(_, Byron.GenesisHash byronHash) <- fromExceptTCli $ Byron.readGenesisData byronGenFile
50+
let actualByronHash = Text.show byronHash
5651
actualAlonzoHash <- Crypto.hashToTextAsHex <$> Read.readShelleyOnwardsGenesisAndHash alonzoGenFile
5752
actualShelleyHash <- Crypto.hashToTextAsHex <$> Read.readShelleyOnwardsGenesisAndHash shelleyGenFile
5853
actualConwayHash <- Crypto.hashToTextAsHex <$> Read.readShelleyOnwardsGenesisAndHash conwayGenFile
5954

60-
when (actualByronHash /= expectedByronHash) $
61-
throwCliError $
62-
DebugNodeConfigWrongGenesisHashCmdError
63-
configFilePath
64-
byronGenFile
65-
actualByronHash
66-
expectedByronHash
67-
when (actualAlonzoHash /= expectedAlonzoHash) $
68-
throwCliError $
69-
DebugNodeConfigWrongGenesisHashCmdError
70-
configFilePath
71-
alonzoGenFile
72-
actualAlonzoHash
73-
expectedAlonzoHash
74-
when (actualShelleyHash /= expectedShelleyHash) $
75-
throwCliError $
76-
DebugNodeConfigWrongGenesisHashCmdError
77-
configFilePath
78-
shelleyGenFile
79-
actualShelleyHash
80-
expectedShelleyHash
81-
when (actualConwayHash /= expectedConwayHash) $
82-
throwCliError $
83-
DebugNodeConfigWrongGenesisHashCmdError
84-
configFilePath
85-
conwayGenFile
86-
actualConwayHash
87-
expectedConwayHash
55+
-- check only hashes which were specified for the genesis
56+
for_
57+
[ (mExpectedByronHash, actualByronHash, byronGenFile)
58+
, (mExpectedShelleyHash, actualShelleyHash, shelleyGenFile)
59+
, (mExpectedAlonzoHash, actualAlonzoHash, alonzoGenFile)
60+
, (mExpectedConwayHash, actualConwayHash, conwayGenFile)
61+
]
62+
$ \(mExpected, actual, genFile) ->
63+
for_ mExpected $ \expected ->
64+
when (actual /= expected) $
65+
throwCliError $
66+
DebugNodeConfigWrongGenesisHashCmdError configFilePath genFile actual expected
8867
where
8968
configFilePath = unFile configFile
9069
-- We make the genesis filepath relative to the node configuration file, like the node does:
9170
-- https://github.com/IntersectMBO/cardano-node/blob/9671e7b6a1b91f5a530722937949b86deafaad43/cardano-node/src/Cardano/Node/Configuration/POM.hs#L668
9271
-- Note that, if the genesis filepath is absolute, the node configuration file's directory is ignored (by property of </>)
93-
adjustFilepath f = takeDirectory configFilePath </> f
72+
adjustFilepath (File f) = takeDirectory configFilePath </> f

cardano-cli/src/Cardano/CLI/Type/Error/DebugCmdError.hs

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,6 @@ data DebugCmdError
3030
-- ^ The actual hash (the hash found by hashing the genesis file)
3131
!Text
3232
-- ^ The expected hash (the hash mentioned in the configuration file)
33-
| -- | @DebugNodeConfigNoConwayFileCmdError filepath@ represents a user error
34-
-- that the genesis file for Conway in @filepath@ is not specified
35-
DebugNodeConfigNoConwayFileCmdError
36-
!FilePath
37-
| -- | @DebugNodeConfigNoConwayHashCmdError filepath@ represents a user error
38-
-- that the hash for the Conway genesis file in @filepath@ is not specified
39-
DebugNodeConfigNoConwayHashCmdError
40-
!FilePath
41-
-- ^ The file path of the node configuration file
4233
| DebugTxCmdError !TxCmdError
4334
deriving Show
4435

@@ -50,16 +41,6 @@ instance Error DebugCmdError where
5041
<> pretty fp
5142
<> ": "
5243
<> pretty (Text.toLazyText $ build err)
53-
DebugNodeConfigNoConwayFileCmdError fp ->
54-
"Conway genesis file not specified in "
55-
<> pretty fp
56-
<> ". Please add a \"ConwayGenesisFile\" key to the file at "
57-
<> pretty fp
58-
DebugNodeConfigNoConwayHashCmdError fp ->
59-
"Conway genesis hash not specified in "
60-
<> pretty fp
61-
<> ". Please add a \"ConwayGenesisHash\" key to the file at "
62-
<> pretty fp
6344
DebugNodeConfigWrongGenesisHashCmdError nodeFp genesisFp actualHash expectedHash ->
6445
"Wrong genesis hash for "
6546
<> pretty genesisFp

0 commit comments

Comments
 (0)