Skip to content

Commit 9b73556

Browse files
authored
Merge pull request #4843 from input-output-hk/jasagredo/test-parser
UTxO-HD: Make devops-shell compile again and fix cli parser
2 parents a6a820c + bdc3524 commit 9b73556

File tree

8 files changed

+31
-40
lines changed

8 files changed

+31
-40
lines changed

.github/workflows/haskell.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ jobs:
7474
sudo apt-get update
7575
sudo apt-get -y install libsodium23 libsodium-dev
7676
sudo apt-get -y install libsystemd0 libsystemd-dev
77-
sudo apt-get -y install liblmdb
77+
sudo apt-get -y install liblmdb-dev
7878
sudo apt-get -y remove --purge software-properties-common
7979
sudo apt-get -y autoremove
8080
@@ -86,6 +86,7 @@ jobs:
8686
if: runner.os == 'macOS'
8787
run: |
8888
brew install libsodium lmdb
89+
cp ./.github/workflows/lmdb.pc /usr/local/lib/pkgconfig
8990
9091
- name: "MAC: Install build environment (for secp256k1)"
9192
if: runner.os == 'macOS'

cabal.project

+1
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ source-repository-package
156156
ouroboros-consensus
157157
ouroboros-consensus-byron
158158
ouroboros-consensus-cardano
159+
ouroboros-consensus-cardano-tools
159160
ouroboros-consensus-diffusion
160161
ouroboros-consensus-protocol
161162
ouroboros-consensus-shelley

cardano-cli/src/Cardano/CLI/Helpers.hs

+7
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
module Cardano.CLI.Helpers
55
( HelpersError(..)
6+
, Some(..)
67
, printWarning
78
, deprecationWarning
89
, ensureNewFile
@@ -129,3 +130,9 @@ hushM :: forall e m a. Monad m => Either e a -> (e -> m ()) -> m (Maybe a)
129130
hushM r f = case r of
130131
Right a -> return (Just a)
131132
Left e -> f e >> return Nothing
133+
134+
data Some (f :: k -> Type) where
135+
Some :: f a -> Some f
136+
137+
instance Show (Some f) where
138+
show = const "Some(..)"

cardano-cli/src/Cardano/CLI/Shelley/Commands.hs

+4-6
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,14 @@ import Cardano.Api.Shelley
5252

5353
import Data.Text (Text)
5454

55-
import Ouroboros.Network.Protocol.LocalStateQuery.Type
56-
55+
import Cardano.CLI.Helpers (Some(..))
5756
import Cardano.CLI.Shelley.Key (PaymentVerifier, StakeVerifier, VerificationKeyOrFile,
5857
VerificationKeyOrHashOrFile, VerificationKeyTextOrFile)
5958
import Cardano.CLI.Types
6059

6160
import Cardano.Chain.Common (BlockCount)
6261
import Cardano.Ledger.Shelley.TxBody (MIRPot)
62+
6363
--
6464
-- Shelley CLI command data types
6565
--
@@ -361,8 +361,7 @@ data QueryCmd =
361361
| QueryStakePools' AnyConsensusModeParams NetworkId (Maybe OutputFile)
362362
| QueryStakeDistribution' AnyConsensusModeParams NetworkId (Maybe OutputFile)
363363
| QueryStakeAddressInfo AnyConsensusModeParams StakeAddress NetworkId (Maybe OutputFile)
364-
| QueryUTxOWhole' AnyConsensusModeParams (QueryUTxOFilter 'WholeL) NetworkId (Maybe OutputFile)
365-
| QueryUTxOLarge' AnyConsensusModeParams (QueryUTxOFilter 'LargeL) NetworkId (Maybe OutputFile)
364+
| QueryUTxO' AnyConsensusModeParams (Some QueryUTxOFilter) NetworkId (Maybe OutputFile)
366365
| QueryDebugLedgerState' AnyConsensusModeParams NetworkId (Maybe OutputFile)
367366
| QueryProtocolState' AnyConsensusModeParams NetworkId (Maybe OutputFile)
368367
| QueryStakeSnapshot'
@@ -389,8 +388,7 @@ renderQueryCmd cmd =
389388
QueryStakePools' {} -> "query stake-pools"
390389
QueryStakeDistribution' {} -> "query stake-distribution"
391390
QueryStakeAddressInfo {} -> "query stake-address-info"
392-
QueryUTxOWhole' {} -> "query utxo"
393-
QueryUTxOLarge' {} -> "query utxo"
391+
QueryUTxO' {} -> "query utxo"
394392
QueryDebugLedgerState' {} -> "query ledger-state"
395393
QueryProtocolState' {} -> "query protocol-state"
396394
QueryStakeSnapshot' {} -> "query stake-snapshot"

cardano-cli/src/Cardano/CLI/Shelley/Parsers.hs

+12-24
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ import Cardano.Api.Shelley
5252

5353
import Cardano.Chain.Common (BlockCount (BlockCount))
5454
import Cardano.CLI.Shelley.Commands
55+
import Cardano.CLI.Shelley.Helpers (Some (..))
5556
import Cardano.CLI.Shelley.Key (PaymentVerifier (..), StakeVerifier (..),
5657
VerificationKeyOrFile (..), VerificationKeyOrHashOrFile (..),
5758
VerificationKeyTextOrFile (..))
@@ -951,23 +952,13 @@ pQueryCmd =
951952
<*> pMaybeOutputFile
952953

953954
pQueryUTxO :: Parser QueryCmd
954-
pQueryUTxO = pQueryUTxOWhole <|> pQueryUTxOLarge
955+
pQueryUTxO =
956+
(QueryUTxO'
957+
<$> pConsensusModeParams
958+
<*> pQueryUTxOFilterWhole
959+
<*> pNetworkId
960+
<*> pMaybeOutputFile)
955961

956-
pQueryUTxOWhole :: Parser QueryCmd
957-
pQueryUTxOWhole =
958-
QueryUTxOWhole'
959-
<$> pConsensusModeParams
960-
<*> pQueryUTxOFilterWhole
961-
<*> pNetworkId
962-
<*> pMaybeOutputFile
963-
964-
pQueryUTxOLarge :: Parser QueryCmd
965-
pQueryUTxOLarge =
966-
QueryUTxOLarge'
967-
<$> pConsensusModeParams
968-
<*> pQueryUTxOFilterLarge
969-
<*> pNetworkId
970-
<*> pMaybeOutputFile
971962

972963
pQueryStakePools :: Parser QueryCmd
973964
pQueryStakePools =
@@ -2471,10 +2462,11 @@ pTxByronWitnessCount =
24712462
<> Opt.value 0
24722463
)
24732464

2474-
pQueryUTxOFilterWhole :: Parser (QueryUTxOFilter 'WholeL)
2475-
pQueryUTxOFilterWhole =
2476-
pQueryUTxOWhole
2477-
<|> pQueryUTxOByAddress
2465+
pQueryUTxOFilterWhole :: Parser (Some QueryUTxOFilter)
2466+
pQueryUTxOFilterWhole = (
2467+
Some <$> pQueryUTxOWhole
2468+
<|> Some <$> pQueryUTxOByAddress
2469+
<|> Some <$> pQueryUTxOByTxIn)
24782470
where
24792471
pQueryUTxOWhole =
24802472
Opt.flag' QueryUTxOWhole
@@ -2493,10 +2485,6 @@ pQueryUTxOFilterWhole =
24932485
<> Opt.help "Filter by Cardano address(es) (Bech32-encoded)."
24942486
)
24952487

2496-
pQueryUTxOFilterLarge :: Parser (QueryUTxOFilter 'LargeL)
2497-
pQueryUTxOFilterLarge =
2498-
pQueryUTxOByTxIn
2499-
where
25002488
pQueryUTxOByTxIn :: Parser (QueryUTxOFilter 'LargeL)
25012489
pQueryUTxOByTxIn = QueryUTxOByTxIn . Set.fromList <$> some pByTxIn
25022490

cardano-cli/src/Cardano/CLI/Shelley/Run/Query.hs

+5-6
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ import qualified System.IO as IO
5959
import Text.Printf (printf)
6060

6161
import Cardano.Binary (DecoderError)
62-
import Cardano.CLI.Helpers (HelpersError (..), hushM, pPrintCBOR, renderHelpersError)
62+
import Cardano.CLI.Helpers (HelpersError (..), Some (..), hushM,
63+
pPrintCBOR, renderHelpersError)
6364
import Cardano.CLI.Shelley.Commands
6465
import Cardano.CLI.Shelley.Key (VerificationKeyOrHashOrFile,
6566
readVerificationKeyOrHashOrFile)
@@ -190,9 +191,7 @@ runQueryCmd cmd =
190191
runQueryStakeSnapshot consensusModeParams network allOrOnlyPoolIds mOutFile
191192
QueryProtocolState' consensusModeParams network mOutFile ->
192193
runQueryProtocolState consensusModeParams network mOutFile
193-
QueryUTxOWhole' consensusModeParams qFilter networkId mOutFile ->
194-
runQueryUTxO consensusModeParams qFilter networkId mOutFile
195-
QueryUTxOLarge' consensusModeParams qFilter networkId mOutFile ->
194+
QueryUTxO' consensusModeParams qFilter networkId mOutFile ->
196195
runQueryUTxO consensusModeParams qFilter networkId mOutFile
197196
QueryKesPeriodInfo consensusModeParams network nodeOpCert mOutFile ->
198197
runQueryKesPeriodInfo consensusModeParams network nodeOpCert mOutFile
@@ -366,12 +365,12 @@ runQueryTip (AnyConsensusModeParams cModeParams) network mOutFile = do
366365

367366
runQueryUTxO
368367
:: AnyConsensusModeParams
369-
-> QueryUTxOFilter fp
368+
-> Some QueryUTxOFilter
370369
-> NetworkId
371370
-> Maybe OutputFile
372371
-> ExceptT ShelleyQueryCmdError IO ()
373372
runQueryUTxO (AnyConsensusModeParams cModeParams)
374-
qfilter network mOutFile = do
373+
(Some qfilter) network mOutFile = do
375374
SocketPath sockPath <- firstExceptT ShelleyQueryCmdEnvVarSocketErr
376375
$ newExceptT readEnvSocketPath
377376
let localNodeConnInfo = LocalNodeConnectInfo cModeParams network sockPath

flake.nix

-1
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,6 @@
196196
inherit (ouroboros-consensus-cardano-tools.components.exes) db-analyser db-synthesizer;
197197
inherit (bech32.components.exes) bech32;
198198
} // lib.optionalAttrs hostPlatform.isUnix {
199-
inherit (network-mux.components.exes) cardano-ping;
200199
inherit plutus-example;
201200
});
202201
};

shell.nix

-2
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,6 @@ let
100100
nixWrapped
101101
cardano-cli
102102
bech32
103-
cardano-ping
104-
cardano-cli
105103
cardano-node
106104
cardano-topology
107105
cardano-tracer

0 commit comments

Comments
 (0)