-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Restore stable query cmds #955
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -5,6 +5,7 @@ | |||||
|
||||||
module Cardano.CLI.EraBased.Options.Query | ||||||
( pQueryCmds | ||||||
, pQueryCmdsTopLevel | ||||||
) | ||||||
where | ||||||
|
||||||
|
@@ -27,6 +28,142 @@ import qualified Options.Applicative as Opt | |||||
{- HLINT ignore "Use <$>" -} | ||||||
{- HLINT ignore "Move brackets to avoid $" -} | ||||||
|
||||||
pQueryCmdsTopLevel :: EnvCli -> Parser (QueryCmds ConwayEra) | ||||||
pQueryCmdsTopLevel envCli = | ||||||
let parsers = | ||||||
[ pProtocolParams envCli | ||||||
, pTip envCli | ||||||
, pStakePools envCli | ||||||
, pStakeDistribution envCli | ||||||
, pStakeAddressInfo envCli | ||||||
, pUTxO envCli | ||||||
, pLedgerState envCli | ||||||
, pProtocolState envCli | ||||||
, pStakeSnapshot envCli | ||||||
, pPoolParams envCli | ||||||
, pLeadershipSchedule envCli | ||||||
, pKesPeriodInfo envCli | ||||||
, pPoolState envCli | ||||||
, pTxMempool envCli | ||||||
, pSlotNumber envCli | ||||||
] | ||||||
i = | ||||||
Opt.progDesc $ | ||||||
mconcat | ||||||
[ "Node query commands. Will query the local node whose Unix domain socket is " | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be nice to mention why this commands set is narrowed down in comparison to |
||||||
, "obtained from the CARDANO_NODE_SOCKET_PATH environment variable." | ||||||
] | ||||||
in subParser "query" $ Opt.info (asum parsers) i | ||||||
|
||||||
pProtocolParams :: EnvCli -> Parser (QueryCmds era) | ||||||
pProtocolParams envCli = | ||||||
subParser "protocol-parameters" $ | ||||||
Opt.info (pQueryProtocolParametersCmd envCli) $ | ||||||
Opt.progDesc "Get the node's current protocol parameters" | ||||||
|
||||||
pTip :: EnvCli -> Parser (QueryCmds ConwayEra) | ||||||
pTip envCli = | ||||||
subParser "tip" $ | ||||||
Opt.info (pQueryTipCmd ShelleyBasedEraConway envCli) $ | ||||||
Opt.progDesc "Get the node's current tip (slot no, hash, block no)" | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Optional. Rationale: I think abbreviations can be misleading, in particular to non-native. |
||||||
|
||||||
pStakePools :: EnvCli -> Parser (QueryCmds ConwayEra) | ||||||
pStakePools envCli = | ||||||
subParser "stake-pools" $ | ||||||
Opt.info (pQueryStakePoolsCmd ShelleyBasedEraConway envCli) $ | ||||||
Opt.progDesc "Get the node's current set of stake pool ids" | ||||||
|
||||||
pStakeDistribution :: EnvCli -> Parser (QueryCmds ConwayEra) | ||||||
pStakeDistribution envCli = | ||||||
subParser "stake-distribution" $ | ||||||
Opt.info (pQueryStakeDistributionCmd ShelleyBasedEraConway envCli) $ | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's not hardcode eras in multiple places. The current era |
||||||
Opt.progDesc "Get the node's current aggregated stake distribution" | ||||||
|
||||||
pStakeAddressInfo :: EnvCli -> Parser (QueryCmds ConwayEra) | ||||||
pStakeAddressInfo envCli = | ||||||
subParser "stake-address-info" $ | ||||||
Opt.info (pQueryStakeAddressInfoCmd ShelleyBasedEraConway envCli) $ | ||||||
Opt.progDesc $ | ||||||
mconcat | ||||||
[ "Get the current delegations and reward accounts filtered by stake address." | ||||||
] | ||||||
|
||||||
pUTxO :: EnvCli -> Parser (QueryCmds ConwayEra) | ||||||
pUTxO envCli = | ||||||
subParser "utxo" $ | ||||||
Opt.info (pQueryUTxOCmd ShelleyBasedEraConway envCli) $ | ||||||
Opt.progDesc $ | ||||||
mconcat | ||||||
[ "Get a portion of the current UTxO: by tx in, by address or the whole." | ||||||
] | ||||||
|
||||||
pLedgerState :: EnvCli -> Parser (QueryCmds ConwayEra) | ||||||
pLedgerState envCli = | ||||||
subParser "ledger-state" $ | ||||||
Opt.info (pQueryLedgerStateCmd ShelleyBasedEraConway envCli) $ | ||||||
Opt.progDesc $ | ||||||
mconcat | ||||||
[ "Dump the current ledger state of the node (Ledger.NewEpochState -- advanced command)" | ||||||
] | ||||||
|
||||||
pProtocolState :: EnvCli -> Parser (QueryCmds ConwayEra) | ||||||
pProtocolState envCli = | ||||||
subParser "protocol-state" $ | ||||||
Opt.info (pQueryProtocolStateCmd ShelleyBasedEraConway envCli) $ | ||||||
Opt.progDesc $ | ||||||
mconcat | ||||||
[ "Dump the current protocol state of the node (Ledger.ChainDepState -- advanced command)" | ||||||
] | ||||||
|
||||||
pStakeSnapshot :: EnvCli -> Parser (QueryCmds ConwayEra) | ||||||
pStakeSnapshot envCli = | ||||||
subParser "stake-snapshot" $ | ||||||
Opt.info (pQueryStakeSnapshotCmd ShelleyBasedEraConway envCli) $ | ||||||
Opt.progDesc $ | ||||||
mconcat | ||||||
[ "Obtain the three stake snapshots for a pool, plus the total active stake (advanced command)" | ||||||
] | ||||||
|
||||||
pPoolParams :: EnvCli -> Parser (QueryCmds ConwayEra) | ||||||
pPoolParams envCli = | ||||||
hiddenSubParser "pool-params" $ | ||||||
Opt.info (pQueryPoolStateCmd ShelleyBasedEraConway envCli) $ | ||||||
Opt.progDesc $ | ||||||
mconcat | ||||||
[ "DEPRECATED. Use query pool-state instead. Dump the pool parameters " | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since this was deprecated, maybe not reintroduce it? |
||||||
, "(Ledger.NewEpochState.esLState._delegationState._pState._pParams -- advanced command)" | ||||||
] | ||||||
|
||||||
pLeadershipSchedule :: EnvCli -> Parser (QueryCmds ConwayEra) | ||||||
pLeadershipSchedule envCli = | ||||||
subParser "leadership-schedule" $ | ||||||
Opt.info (pLeadershipScheduleCmd ShelleyBasedEraConway envCli) $ | ||||||
Opt.progDesc "Get the slots the node is expected to mint a block in (advanced command)" | ||||||
|
||||||
pKesPeriodInfo :: EnvCli -> Parser (QueryCmds ConwayEra) | ||||||
pKesPeriodInfo envCli = | ||||||
subParser "kes-period-info" $ | ||||||
Opt.info (pKesPeriodInfoCmd ShelleyBasedEraConway envCli) $ | ||||||
Opt.progDesc "Get information about the current KES period and your node's operational certificate." | ||||||
|
||||||
pPoolState :: EnvCli -> Parser (QueryCmds ConwayEra) | ||||||
pPoolState envCli = | ||||||
subParser "pool-state" $ | ||||||
Opt.info (pQueryPoolStateCmd ShelleyBasedEraConway envCli) $ | ||||||
Opt.progDesc "Dump the pool state" | ||||||
|
||||||
pTxMempool :: EnvCli -> Parser (QueryCmds era) | ||||||
pTxMempool envCli = | ||||||
subParser "tx-mempool" $ | ||||||
Opt.info (pQueryTxMempoolCmd envCli) $ | ||||||
Opt.progDesc "Local Mempool info" | ||||||
|
||||||
pSlotNumber :: EnvCli -> Parser (QueryCmds ConwayEra) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All those parsers should accept era parameter (instead of hardcoding an era) and get reused in |
||||||
pSlotNumber envCli = | ||||||
subParser "slot-number" $ | ||||||
Opt.info (pQuerySlotNumberCmd ShelleyBasedEraConway envCli) $ | ||||||
Opt.progDesc "Query slot number for UTC timestamp" | ||||||
|
||||||
pQueryCmds | ||||||
:: () | ||||||
=> ShelleyBasedEra era | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ import Cardano.CLI.Compatible.Commands | |
import Cardano.CLI.Environment (EnvCli) | ||
import Cardano.CLI.EraBased.Commands | ||
import Cardano.CLI.EraBased.Options.Common | ||
import Cardano.CLI.EraBased.Options.Query (pQueryCmdsTopLevel) | ||
import Cardano.CLI.Legacy.Options (parseLegacyCmds) | ||
import Cardano.CLI.Options.Address | ||
import Cardano.CLI.Options.Debug | ||
|
@@ -60,6 +61,13 @@ addressCmdsTopLevel envCli = AddressCommand <$> pAddressCmds envCli | |
nodeCmdsTopLevel :: Parser ClientCommand | ||
nodeCmdsTopLevel = NodeCommands <$> pNodeCmds | ||
|
||
-- Queries actually depend on the node to client version which may coincide | ||
-- with a hardfork but not necessarily. We will expose commands at the top level | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I don't think mentioning our intentions in the comments brings any value. Unless it's a TODO, which is easier to spot and correct than a prose with wishes. |
||
-- regardless if they are compatible with the era or not. The help text should be | ||
-- updated to make this clear. Gating commands behind eras | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This comment's last sentence is incomplete. |
||
queryCmdsTopLevel :: EnvCli -> Parser ClientCommand | ||
queryCmdsTopLevel envCli = QueryCommands <$> pQueryCmdsTopLevel envCli | ||
|
||
keyCmdsTopLevel :: Parser ClientCommand | ||
keyCmdsTopLevel = KeyCommands <$> pKeyCmds | ||
|
||
|
@@ -72,6 +80,7 @@ parseClientCommand envCli = | |
[ addressCmdsTopLevel envCli | ||
, keyCmdsTopLevel | ||
, nodeCmdsTopLevel | ||
, queryCmdsTopLevel envCli | ||
, parseLegacy envCli | ||
, parseByron envCli | ||
, parseAnyEra envCli | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pQueryCmdsTopLevel
is instantiated byConwayEra
, so we can avoid the existential quantifier here if we want.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this idea. I think we should define
and use it wherever we need to reference the currently supported era.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I have a way to remove all mention of era.