Skip to content

Commit

Permalink
Merge pull request #514 from input-output-hk/ch/fix/query-pool-state-…
Browse files Browse the repository at this point in the history
…empty

Make `query pool-state` default to returning information on all pools
  • Loading branch information
carlhammann authored Dec 12, 2023
2 parents 0dfd17d + 6d8e69b commit 6eddc97
Show file tree
Hide file tree
Showing 24 changed files with 136 additions and 42 deletions.
2 changes: 1 addition & 1 deletion cardano-cli/src/Cardano/CLI/EraBased/Commands/Query.hs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ data QueryPoolStateCmdArgs = QueryPoolStateCmdArgs
{ nodeSocketPath :: !SocketPath
, consensusModeParams :: !ConsensusModeParams
, networkId :: !NetworkId
, poolIds :: ![Hash StakePoolKey]
, allOrOnlyPoolIds :: !(AllOrOnly [Hash StakePoolKey])
} deriving (Generic, Show)

data QueryTxMempoolCmdArgs = QueryTxMempoolCmdArgs
Expand Down
2 changes: 1 addition & 1 deletion cardano-cli/src/Cardano/CLI/EraBased/Options/Query.hs
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ pQueryPoolStateCmd envCli =
<$> pSocketPath envCli
<*> pConsensusModeParams
<*> pNetworkId envCli
<*> many (pStakePoolVerificationKeyHash Nothing)
<*> pAllStakePoolsOrOnly

pQueryTxMempoolCmd :: EnvCli -> Parser (QueryCmds era)
pQueryTxMempoolCmd envCli =
Expand Down
8 changes: 6 additions & 2 deletions cardano-cli/src/Cardano/CLI/EraBased/Run/Query.hs
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@ runQueryPoolStateCmd
{ Cmd.nodeSocketPath
, Cmd.consensusModeParams
, Cmd.networkId
, Cmd.poolIds
, Cmd.allOrOnlyPoolIds
} = do
let localNodeConnInfo = LocalNodeConnectInfo consensusModeParams networkId nodeSocketPath

Expand All @@ -633,7 +633,11 @@ runQueryPoolStateCmd

beo <- requireEon BabbageEra era

result <- lift (queryPoolState beo $ Just $ Set.fromList poolIds)
let poolFilter = case allOrOnlyPoolIds of
All -> Nothing
Only poolIds -> Just $ Set.fromList poolIds

result <- lift (queryPoolState beo poolFilter)
& onLeft (left . QueryCmdUnsupportedNtcVersion)
& onLeft (left . QueryCmdLocalStateQueryError . EraMismatchError)

Expand Down
2 changes: 1 addition & 1 deletion cardano-cli/src/Cardano/CLI/Legacy/Commands/Query.hs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ data LegacyQueryPoolStateCmdArgs = LegacyQueryPoolStateCmdArgs
{ nodeSocketPath :: !SocketPath
, consensusModeParams :: !ConsensusModeParams
, networkId :: !NetworkId
, poolIds :: ![Hash StakePoolKey]
, allOrOnlyPoolIds :: !(AllOrOnly [Hash StakePoolKey])
} deriving (Generic, Show)

data LegacyQueryTxMempoolCmdArgs = LegacyQueryTxMempoolCmdArgs
Expand Down
2 changes: 1 addition & 1 deletion cardano-cli/src/Cardano/CLI/Legacy/Options.hs
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,7 @@ pQueryCmds envCli =
<$> pSocketPath envCli
<*> pConsensusModeParams
<*> pNetworkId envCli
<*> many (pStakePoolVerificationKeyHash Nothing)
<*> pAllStakePoolsOrOnly

pQueryTxMempool :: Parser LegacyQueryCmds
pQueryTxMempool =
Expand Down
72 changes: 54 additions & 18 deletions cardano-cli/test/cardano-cli-golden/files/golden/help.cli
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,9 @@ Usage: cardano-cli shelley query pool-params --socket-path SOCKET_PATH
( --mainnet
| --testnet-magic NATURAL
)
[--stake-pool-id STAKE_POOL_ID]
[ --all-stake-pools
| [--stake-pool-id STAKE_POOL_ID]
]

DEPRECATED. Use query pool-state instead. Dump the pool parameters
(Ledger.NewEpochState.esLState._delegationState._pState._pParams -- advanced
Expand Down Expand Up @@ -593,7 +595,9 @@ Usage: cardano-cli shelley query pool-state --socket-path SOCKET_PATH
( --mainnet
| --testnet-magic NATURAL
)
[--stake-pool-id STAKE_POOL_ID]
[ --all-stake-pools
| [--stake-pool-id STAKE_POOL_ID]
]

Dump the pool state

Expand Down Expand Up @@ -1709,7 +1713,9 @@ Usage: cardano-cli allegra query pool-params --socket-path SOCKET_PATH
( --mainnet
| --testnet-magic NATURAL
)
[--stake-pool-id STAKE_POOL_ID]
[ --all-stake-pools
| [--stake-pool-id STAKE_POOL_ID]
]

DEPRECATED. Use query pool-state instead. Dump the pool parameters
(Ledger.NewEpochState.esLState._delegationState._pState._pParams -- advanced
Expand Down Expand Up @@ -1750,7 +1756,9 @@ Usage: cardano-cli allegra query pool-state --socket-path SOCKET_PATH
( --mainnet
| --testnet-magic NATURAL
)
[--stake-pool-id STAKE_POOL_ID]
[ --all-stake-pools
| [--stake-pool-id STAKE_POOL_ID]
]

Dump the pool state

Expand Down Expand Up @@ -2863,7 +2871,9 @@ Usage: cardano-cli mary query pool-params --socket-path SOCKET_PATH
( --mainnet
| --testnet-magic NATURAL
)
[--stake-pool-id STAKE_POOL_ID]
[ --all-stake-pools
| [--stake-pool-id STAKE_POOL_ID]
]

DEPRECATED. Use query pool-state instead. Dump the pool parameters
(Ledger.NewEpochState.esLState._delegationState._pState._pParams -- advanced
Expand Down Expand Up @@ -2902,7 +2912,9 @@ Usage: cardano-cli mary query pool-state --socket-path SOCKET_PATH
[--cardano-mode
[--epoch-slots SLOTS]]
(--mainnet | --testnet-magic NATURAL)
[--stake-pool-id STAKE_POOL_ID]
[ --all-stake-pools
| [--stake-pool-id STAKE_POOL_ID]
]

Dump the pool state

Expand Down Expand Up @@ -4009,7 +4021,9 @@ Usage: cardano-cli alonzo query pool-params --socket-path SOCKET_PATH
( --mainnet
| --testnet-magic NATURAL
)
[--stake-pool-id STAKE_POOL_ID]
[ --all-stake-pools
| [--stake-pool-id STAKE_POOL_ID]
]

DEPRECATED. Use query pool-state instead. Dump the pool parameters
(Ledger.NewEpochState.esLState._delegationState._pState._pParams -- advanced
Expand Down Expand Up @@ -4050,7 +4064,9 @@ Usage: cardano-cli alonzo query pool-state --socket-path SOCKET_PATH
( --mainnet
| --testnet-magic NATURAL
)
[--stake-pool-id STAKE_POOL_ID]
[ --all-stake-pools
| [--stake-pool-id STAKE_POOL_ID]
]

Dump the pool state

Expand Down Expand Up @@ -5191,7 +5207,9 @@ Usage: cardano-cli babbage query pool-params --socket-path SOCKET_PATH
( --mainnet
| --testnet-magic NATURAL
)
[--stake-pool-id STAKE_POOL_ID]
[ --all-stake-pools
| [--stake-pool-id STAKE_POOL_ID]
]

DEPRECATED. Use query pool-state instead. Dump the pool parameters
(Ledger.NewEpochState.esLState._delegationState._pState._pParams -- advanced
Expand Down Expand Up @@ -5232,7 +5250,9 @@ Usage: cardano-cli babbage query pool-state --socket-path SOCKET_PATH
( --mainnet
| --testnet-magic NATURAL
)
[--stake-pool-id STAKE_POOL_ID]
[ --all-stake-pools
| [--stake-pool-id STAKE_POOL_ID]
]

Dump the pool state

Expand Down Expand Up @@ -6580,7 +6600,9 @@ Usage: cardano-cli conway query pool-params --socket-path SOCKET_PATH
( --mainnet
| --testnet-magic NATURAL
)
[--stake-pool-id STAKE_POOL_ID]
[ --all-stake-pools
| [--stake-pool-id STAKE_POOL_ID]
]

DEPRECATED. Use query pool-state instead. Dump the pool parameters
(Ledger.NewEpochState.esLState._delegationState._pState._pParams -- advanced
Expand Down Expand Up @@ -6621,7 +6643,9 @@ Usage: cardano-cli conway query pool-state --socket-path SOCKET_PATH
( --mainnet
| --testnet-magic NATURAL
)
[--stake-pool-id STAKE_POOL_ID]
[ --all-stake-pools
| [--stake-pool-id STAKE_POOL_ID]
]

Dump the pool state

Expand Down Expand Up @@ -7875,7 +7899,9 @@ Usage: cardano-cli latest query pool-params --socket-path SOCKET_PATH
( --mainnet
| --testnet-magic NATURAL
)
[--stake-pool-id STAKE_POOL_ID]
[ --all-stake-pools
| [--stake-pool-id STAKE_POOL_ID]
]

DEPRECATED. Use query pool-state instead. Dump the pool parameters
(Ledger.NewEpochState.esLState._delegationState._pState._pParams -- advanced
Expand Down Expand Up @@ -7916,7 +7942,9 @@ Usage: cardano-cli latest query pool-state --socket-path SOCKET_PATH
( --mainnet
| --testnet-magic NATURAL
)
[--stake-pool-id STAKE_POOL_ID]
[ --all-stake-pools
| [--stake-pool-id STAKE_POOL_ID]
]

Dump the pool state

Expand Down Expand Up @@ -8889,7 +8917,9 @@ Usage: cardano-cli legacy query pool-params --socket-path SOCKET_PATH
( --mainnet
| --testnet-magic NATURAL
)
[--stake-pool-id STAKE_POOL_ID]
[ --all-stake-pools
| [--stake-pool-id STAKE_POOL_ID]
]

DEPRECATED. Use query pool-state instead. Dump the pool parameters
(Ledger.NewEpochState.esLState._delegationState._pState._pParams -- advanced
Expand Down Expand Up @@ -8930,7 +8960,9 @@ Usage: cardano-cli legacy query pool-state --socket-path SOCKET_PATH
( --mainnet
| --testnet-magic NATURAL
)
[--stake-pool-id STAKE_POOL_ID]
[ --all-stake-pools
| [--stake-pool-id STAKE_POOL_ID]
]

Dump the pool state

Expand Down Expand Up @@ -10111,7 +10143,9 @@ Usage: cardano-cli query stake-snapshot --socket-path SOCKET_PATH
Usage: cardano-cli query pool-params --socket-path SOCKET_PATH
[--cardano-mode [--epoch-slots SLOTS]]
(--mainnet | --testnet-magic NATURAL)
[--stake-pool-id STAKE_POOL_ID]
[ --all-stake-pools
| [--stake-pool-id STAKE_POOL_ID]
]

DEPRECATED. Use query pool-state instead. Dump the pool parameters
(Ledger.NewEpochState.esLState._delegationState._pState._pParams -- advanced
Expand Down Expand Up @@ -10147,7 +10181,9 @@ Usage: cardano-cli query kes-period-info --socket-path SOCKET_PATH
Usage: cardano-cli query pool-state --socket-path SOCKET_PATH
[--cardano-mode [--epoch-slots SLOTS]]
(--mainnet | --testnet-magic NATURAL)
[--stake-pool-id STAKE_POOL_ID]
[ --all-stake-pools
| [--stake-pool-id STAKE_POOL_ID]
]

Dump the pool state

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ Usage: cardano-cli allegra query pool-params --socket-path SOCKET_PATH
( --mainnet
| --testnet-magic NATURAL
)
[--stake-pool-id STAKE_POOL_ID]
[ --all-stake-pools
| [--stake-pool-id STAKE_POOL_ID]
]

DEPRECATED. Use query pool-state instead. Dump the pool parameters
(Ledger.NewEpochState.esLState._delegationState._pState._pParams -- advanced
Expand All @@ -24,6 +26,7 @@ Available options:
CARDANO_NODE_NETWORK_ID environment variable
--testnet-magic NATURAL Specify a testnet magic id. This overrides the
CARDANO_NODE_NETWORK_ID environment variable
--all-stake-pools Query for all stake pools
--stake-pool-id STAKE_POOL_ID
Stake pool ID/verification key hash (either
Bech32-encoded or hex-encoded). Zero or more
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ Usage: cardano-cli allegra query pool-state --socket-path SOCKET_PATH
( --mainnet
| --testnet-magic NATURAL
)
[--stake-pool-id STAKE_POOL_ID]
[ --all-stake-pools
| [--stake-pool-id STAKE_POOL_ID]
]

Dump the pool state

Expand All @@ -22,6 +24,7 @@ Available options:
CARDANO_NODE_NETWORK_ID environment variable
--testnet-magic NATURAL Specify a testnet magic id. This overrides the
CARDANO_NODE_NETWORK_ID environment variable
--all-stake-pools Query for all stake pools
--stake-pool-id STAKE_POOL_ID
Stake pool ID/verification key hash (either
Bech32-encoded or hex-encoded). Zero or more
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ Usage: cardano-cli alonzo query pool-params --socket-path SOCKET_PATH
( --mainnet
| --testnet-magic NATURAL
)
[--stake-pool-id STAKE_POOL_ID]
[ --all-stake-pools
| [--stake-pool-id STAKE_POOL_ID]
]

DEPRECATED. Use query pool-state instead. Dump the pool parameters
(Ledger.NewEpochState.esLState._delegationState._pState._pParams -- advanced
Expand All @@ -24,6 +26,7 @@ Available options:
CARDANO_NODE_NETWORK_ID environment variable
--testnet-magic NATURAL Specify a testnet magic id. This overrides the
CARDANO_NODE_NETWORK_ID environment variable
--all-stake-pools Query for all stake pools
--stake-pool-id STAKE_POOL_ID
Stake pool ID/verification key hash (either
Bech32-encoded or hex-encoded). Zero or more
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ Usage: cardano-cli alonzo query pool-state --socket-path SOCKET_PATH
( --mainnet
| --testnet-magic NATURAL
)
[--stake-pool-id STAKE_POOL_ID]
[ --all-stake-pools
| [--stake-pool-id STAKE_POOL_ID]
]

Dump the pool state

Expand All @@ -22,6 +24,7 @@ Available options:
CARDANO_NODE_NETWORK_ID environment variable
--testnet-magic NATURAL Specify a testnet magic id. This overrides the
CARDANO_NODE_NETWORK_ID environment variable
--all-stake-pools Query for all stake pools
--stake-pool-id STAKE_POOL_ID
Stake pool ID/verification key hash (either
Bech32-encoded or hex-encoded). Zero or more
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ Usage: cardano-cli babbage query pool-params --socket-path SOCKET_PATH
( --mainnet
| --testnet-magic NATURAL
)
[--stake-pool-id STAKE_POOL_ID]
[ --all-stake-pools
| [--stake-pool-id STAKE_POOL_ID]
]

DEPRECATED. Use query pool-state instead. Dump the pool parameters
(Ledger.NewEpochState.esLState._delegationState._pState._pParams -- advanced
Expand All @@ -24,6 +26,7 @@ Available options:
CARDANO_NODE_NETWORK_ID environment variable
--testnet-magic NATURAL Specify a testnet magic id. This overrides the
CARDANO_NODE_NETWORK_ID environment variable
--all-stake-pools Query for all stake pools
--stake-pool-id STAKE_POOL_ID
Stake pool ID/verification key hash (either
Bech32-encoded or hex-encoded). Zero or more
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ Usage: cardano-cli babbage query pool-state --socket-path SOCKET_PATH
( --mainnet
| --testnet-magic NATURAL
)
[--stake-pool-id STAKE_POOL_ID]
[ --all-stake-pools
| [--stake-pool-id STAKE_POOL_ID]
]

Dump the pool state

Expand All @@ -22,6 +24,7 @@ Available options:
CARDANO_NODE_NETWORK_ID environment variable
--testnet-magic NATURAL Specify a testnet magic id. This overrides the
CARDANO_NODE_NETWORK_ID environment variable
--all-stake-pools Query for all stake pools
--stake-pool-id STAKE_POOL_ID
Stake pool ID/verification key hash (either
Bech32-encoded or hex-encoded). Zero or more
Expand Down
Loading

0 comments on commit 6eddc97

Please sign in to comment.