From 824093fd74b322b752c6d413dfb88632dfebca59 Mon Sep 17 00:00:00 2001 From: Pablo Lamela Date: Fri, 9 Feb 2024 22:54:53 +0100 Subject: [PATCH 1/5] Add immutable tip parameter to conway tip query --- .../Cardano/CLI/EraBased/Commands/Query.hs | 2 ++ .../Cardano/CLI/EraBased/Options/Common.hs | 27 ++++++++++++++++++- .../src/Cardano/CLI/EraBased/Options/Query.hs | 7 ++--- .../src/Cardano/CLI/EraBased/Run/Query.hs | 3 ++- .../src/Cardano/CLI/Legacy/Run/Query.hs | 3 ++- .../cardano-cli-golden/files/golden/help.cli | 1 + .../files/golden/help/conway_query_tip.cli | 4 +++ 7 files changed, 41 insertions(+), 6 deletions(-) diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Commands/Query.hs b/cardano-cli/src/Cardano/CLI/EraBased/Commands/Query.hs index 2f77c9a81d..19fa87bd33 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Commands/Query.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Commands/Query.hs @@ -31,6 +31,7 @@ import Cardano.Api.Shelley hiding (QueryInShelleyBasedEra (..)) import Cardano.CLI.Types.Common import Cardano.CLI.Types.Key +import qualified Ouroboros.Network.Protocol.LocalStateQuery.Type as Consensus import Data.Text (Text) import Data.Time.Clock @@ -88,6 +89,7 @@ data QueryTipCmdArgs = QueryTipCmdArgs { nodeSocketPath :: !SocketPath , consensusModeParams :: !ConsensusModeParams , networkId :: !NetworkId + , target :: !(Consensus.Target ChainPoint) , mOutFile :: !(Maybe (File () Out)) } deriving (Generic, Show) diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Options/Common.hs b/cardano-cli/src/Cardano/CLI/EraBased/Options/Common.hs index be50d8e522..ae1ab22096 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Options/Common.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Options/Common.hs @@ -28,6 +28,7 @@ import qualified Cardano.Ledger.BaseTypes as L import qualified Cardano.Ledger.Crypto as Crypto import qualified Cardano.Ledger.SafeHash as L import qualified Cardano.Ledger.Shelley.API as Shelley +import qualified Ouroboros.Network.Protocol.LocalStateQuery.Type as Consensus import Control.Monad (mfilter) import qualified Data.Aeson as Aeson @@ -102,6 +103,30 @@ pNetworkId envCli = asum $ mconcat pure <$> maybeToList (envCliNetworkId envCli) ] +pTarget :: CardanoEra era -> Parser (Consensus.Target ChainPoint) +pTarget = + inEonForEra (pure Consensus.VolatileTip) conwayOnwardsTargetParser + where + conwayOnwardsTargetParser :: ConwayEraOnwards era -> Parser (Consensus.Target ChainPoint) + conwayOnwardsTargetParser ConwayEraOnwardsConway = + asum $ mconcat + [ [ Opt.flag' Consensus.VolatileTip $ mconcat + [ Opt.long "volatile-tip" + , Opt.help $ mconcat + [ "Use the volatile tip as a target. (This is the default)" + ] + ] + , Opt.flag' Consensus.ImmutableTip $ mconcat + [ Opt.long "immutable-tip" + , Opt.help $ mconcat + [ "Use the immutable tip as a target." + ] + ] + ] + , -- Default to volatile tip if not specified + [ pure Consensus.VolatileTip ] + ] + toUnitIntervalOrErr :: Rational -> L.UnitInterval toUnitIntervalOrErr r = case Ledger.boundRational r of Nothing -> @@ -3217,7 +3242,7 @@ pNetworkIdForTestnetData envCli = asum $ mconcat [ Opt.long "testnet-magic" , Opt.metavar "NATURAL" , Opt.help $ mconcat - [ "Specify a testnet magic id for the cluster. " + [ "Specify a testnet magic id for the cluster. " , "This overrides both the network magic from the " , "spec file and CARDANO_NODE_NETWORK_ID environment variable." ] diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Options/Query.hs b/cardano-cli/src/Cardano/CLI/EraBased/Options/Query.hs index 028201d99d..d3c1a65c27 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Options/Query.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Options/Query.hs @@ -41,7 +41,7 @@ pQueryCmds era envCli = $ Opt.progDesc "Get the node's current protocol parameters" , Just $ subParser "tip" - $ Opt.info (pQueryTipCmd envCli) + $ Opt.info (pQueryTipCmd era envCli) $ Opt.progDesc "Get the node's current tip (slot no, hash, block no)" , Just $ subParser "stake-pools" @@ -124,13 +124,14 @@ pQueryProtocolParametersCmd envCli = <*> pNetworkId envCli <*> pMaybeOutputFile -pQueryTipCmd :: EnvCli -> Parser (QueryCmds era) -pQueryTipCmd envCli = +pQueryTipCmd :: CardanoEra era -> EnvCli -> Parser (QueryCmds era) +pQueryTipCmd era envCli = fmap QueryTipCmd $ QueryTipCmdArgs <$> pSocketPath envCli <*> pConsensusModeParams <*> pNetworkId envCli + <*> pTarget era <*> pMaybeOutputFile pQueryUTxOCmd :: EnvCli -> Parser (QueryCmds era) diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Run/Query.hs b/cardano-cli/src/Cardano/CLI/EraBased/Run/Query.hs index 6d13ed0e15..d34b778025 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Run/Query.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Run/Query.hs @@ -245,12 +245,13 @@ runQueryTipCmd { Cmd.nodeSocketPath , Cmd.consensusModeParams , Cmd.networkId + , Cmd.target , Cmd.mOutFile } = do let localNodeConnInfo = LocalNodeConnectInfo consensusModeParams networkId nodeSocketPath eLocalState <- ExceptT $ fmap sequence $ - executeLocalStateQueryExpr localNodeConnInfo Consensus.VolatileTip $ runExceptT $ do + executeLocalStateQueryExpr localNodeConnInfo target $ runExceptT $ do era <- lift queryCurrentEra & onLeft (left . QueryCmdUnsupportedNtcVersion) eraHistory <- lift queryEraHistory & onLeft (left . QueryCmdUnsupportedNtcVersion) mChainBlockNo <- lift queryChainBlockNo & onLeft (left . QueryCmdUnsupportedNtcVersion) & fmap Just diff --git a/cardano-cli/src/Cardano/CLI/Legacy/Run/Query.hs b/cardano-cli/src/Cardano/CLI/Legacy/Run/Query.hs index c7cb76daca..ebb141d5cb 100644 --- a/cardano-cli/src/Cardano/CLI/Legacy/Run/Query.hs +++ b/cardano-cli/src/Cardano/CLI/Legacy/Run/Query.hs @@ -13,6 +13,7 @@ import qualified Cardano.CLI.EraBased.Commands.Query as EraBased import qualified Cardano.CLI.EraBased.Run.Query as EraBased import qualified Cardano.CLI.Legacy.Commands.Query as Cmd import Cardano.CLI.Types.Errors.QueryCmdError +import qualified Ouroboros.Network.Protocol.LocalStateQuery.Type as Consensus import Control.Monad.Trans.Except @@ -43,7 +44,7 @@ runLegacyQueryTipCmd :: () => Cmd.LegacyQueryTipCmdArgs -> ExceptT QueryCmdError IO () runLegacyQueryTipCmd Cmd.LegacyQueryTipCmdArgs {..} = - EraBased.runQueryTipCmd EraBased.QueryTipCmdArgs {..} + EraBased.runQueryTipCmd EraBased.QueryTipCmdArgs {target = Consensus.VolatileTip, ..} -- | Query the UTxO, filtered by a given set of addresses, from a Shelley node -- via the local state query protocol. diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help.cli index 1cd2055c2c..5450237411 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help.cli @@ -6509,6 +6509,7 @@ Usage: cardano-cli conway query protocol-parameters --socket-path SOCKET_PATH Usage: cardano-cli conway query tip --socket-path SOCKET_PATH [--cardano-mode [--epoch-slots SLOTS]] (--mainnet | --testnet-magic NATURAL) + [--volatile-tip | --immutable-tip] [--out-file FILE] Get the node's current tip (slot no, hash, block no) diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_query_tip.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_query_tip.cli index f3171d6165..4228e28327 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_query_tip.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_query_tip.cli @@ -1,6 +1,7 @@ Usage: cardano-cli conway query tip --socket-path SOCKET_PATH [--cardano-mode [--epoch-slots SLOTS]] (--mainnet | --testnet-magic NATURAL) + [--volatile-tip | --immutable-tip] [--out-file FILE] Get the node's current tip (slot no, hash, block no) @@ -19,5 +20,8 @@ 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 + --volatile-tip Use the volatile tip as a target. (This is the + default) + --immutable-tip Use the immutable tip as a target. --out-file FILE Optional output file. Default is to write to stdout. -h,--help Show this help text From bb090094b1130156cc5c94ed3b1e37fa3c21e131 Mon Sep 17 00:00:00 2001 From: Pablo Lamela Date: Fri, 9 Feb 2024 23:51:02 +0100 Subject: [PATCH 2/5] Add immutable tip parameter to other conway queries --- .../Cardano/CLI/EraBased/Commands/Query.hs | 10 +++ .../src/Cardano/CLI/EraBased/Options/Query.hs | 72 +++++++++++-------- .../src/Cardano/CLI/EraBased/Run/Query.hs | 30 +++++--- .../src/Cardano/CLI/Legacy/Run/Query.hs | 20 +++--- .../cardano-cli-golden/files/golden/help.cli | 25 +++++++ .../help/conway_query_kes-period-info.cli | 6 ++ .../help/conway_query_leadership-schedule.cli | 6 ++ .../golden/help/conway_query_ledger-state.cli | 6 ++ .../golden/help/conway_query_pool-params.cli | 4 ++ .../golden/help/conway_query_pool-state.cli | 4 ++ .../help/conway_query_protocol-state.cli | 6 ++ .../help/conway_query_stake-address-info.cli | 6 ++ .../help/conway_query_stake-distribution.cli | 6 ++ .../golden/help/conway_query_stake-pools.cli | 4 ++ .../help/conway_query_stake-snapshot.cli | 6 ++ .../files/golden/help/conway_query_utxo.cli | 4 ++ 16 files changed, 164 insertions(+), 51 deletions(-) diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Commands/Query.hs b/cardano-cli/src/Cardano/CLI/EraBased/Commands/Query.hs index 19fa87bd33..98b973a988 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Commands/Query.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Commands/Query.hs @@ -68,6 +68,7 @@ data QueryLeadershipScheduleCmdArgs = QueryLeadershipScheduleCmdArgs , poolColdVerKeyFile :: !(VerificationKeyOrHashOrFile StakePoolKey) , vrkSkeyFp :: !(SigningKeyFile In) , whichSchedule :: !EpochLeadershipSchedule + , target :: !(Consensus.Target ChainPoint) , mOutFile :: !(Maybe (File () Out)) } deriving (Generic, Show) @@ -97,6 +98,7 @@ data QueryStakePoolsCmdArgs = QueryStakePoolsCmdArgs { nodeSocketPath :: !SocketPath , consensusModeParams :: !ConsensusModeParams , networkId :: !NetworkId + , target :: !(Consensus.Target ChainPoint) , mOutFile :: !(Maybe (File () Out)) } deriving (Generic, Show) @@ -104,6 +106,7 @@ data QueryStakeDistributionCmdArgs = QueryStakeDistributionCmdArgs { nodeSocketPath :: !SocketPath , consensusModeParams :: !ConsensusModeParams , networkId :: !NetworkId + , target :: !(Consensus.Target ChainPoint) , mOutFile :: !(Maybe (File () Out)) } deriving (Generic, Show) @@ -112,6 +115,7 @@ data QueryStakeAddressInfoCmdArgs = QueryStakeAddressInfoCmdArgs , consensusModeParams :: !ConsensusModeParams , addr :: !StakeAddress , networkId :: !NetworkId + , target :: !(Consensus.Target ChainPoint) , mOutFile :: !(Maybe (File () Out)) } deriving (Generic, Show) @@ -120,6 +124,7 @@ data QueryUTxOCmdArgs = QueryUTxOCmdArgs , consensusModeParams :: !ConsensusModeParams , queryFilter :: !QueryUTxOFilter , networkId :: !NetworkId + , target :: !(Consensus.Target ChainPoint) , mOutFile :: !(Maybe (File () Out)) } deriving (Generic, Show) @@ -127,6 +132,7 @@ data QueryLedgerStateCmdArgs = QueryLedgerStateCmdArgs { nodeSocketPath :: !SocketPath , consensusModeParams :: !ConsensusModeParams , networkId :: !NetworkId + , target :: !(Consensus.Target ChainPoint) , mOutFile :: !(Maybe (File () Out)) } deriving (Generic, Show) @@ -134,6 +140,7 @@ data QueryProtocolStateCmdArgs = QueryProtocolStateCmdArgs { nodeSocketPath :: !SocketPath , consensusModeParams :: !ConsensusModeParams , networkId :: !NetworkId + , target :: !(Consensus.Target ChainPoint) , mOutFile :: !(Maybe (File () Out)) } deriving (Generic, Show) @@ -142,6 +149,7 @@ data QueryStakeSnapshotCmdArgs = QueryStakeSnapshotCmdArgs , consensusModeParams :: !ConsensusModeParams , networkId :: !NetworkId , allOrOnlyPoolIds :: !(AllOrOnly (Hash StakePoolKey)) + , target :: !(Consensus.Target ChainPoint) , mOutFile :: !(Maybe (File () Out)) } deriving (Generic, Show) @@ -150,6 +158,7 @@ data QueryKesPeriodInfoCmdArgs = QueryKesPeriodInfoCmdArgs , consensusModeParams :: !ConsensusModeParams , networkId :: !NetworkId , nodeOpCertFp :: !(File () In) -- ^ Node operational certificate + , target :: !(Consensus.Target ChainPoint) , mOutFile :: !(Maybe (File () Out)) } deriving (Generic, Show) @@ -158,6 +167,7 @@ data QueryPoolStateCmdArgs = QueryPoolStateCmdArgs , consensusModeParams :: !ConsensusModeParams , networkId :: !NetworkId , allOrOnlyPoolIds :: !(AllOrOnly (Hash StakePoolKey)) + , target :: !(Consensus.Target ChainPoint) } deriving (Generic, Show) data QueryTxMempoolCmdArgs = QueryTxMempoolCmdArgs diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Options/Query.hs b/cardano-cli/src/Cardano/CLI/EraBased/Options/Query.hs index d3c1a65c27..7b5f308109 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Options/Query.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Options/Query.hs @@ -45,60 +45,60 @@ pQueryCmds era envCli = $ Opt.progDesc "Get the node's current tip (slot no, hash, block no)" , Just $ subParser "stake-pools" - $ Opt.info (pQueryStakePoolsCmd envCli) + $ Opt.info (pQueryStakePoolsCmd era envCli) $ Opt.progDesc "Get the node's current set of stake pool ids" , Just $ subParser "stake-distribution" - $ Opt.info (pQueryStakeDistributionCmd envCli) + $ Opt.info (pQueryStakeDistributionCmd era envCli) $ Opt.progDesc "Get the node's current aggregated stake distribution" , Just $ subParser "stake-address-info" - $ Opt.info (pQueryStakeAddressInfoCmd envCli) + $ Opt.info (pQueryStakeAddressInfoCmd era envCli) $ Opt.progDesc $ mconcat [ "Get the current delegations and reward accounts filtered by stake address." ] , Just $ subParser "utxo" - $ Opt.info (pQueryUTxOCmd envCli) + $ Opt.info (pQueryUTxOCmd era envCli) $ Opt.progDesc $ mconcat [ "Get a portion of the current UTxO: by tx in, by address or the whole." ] , Just $ subParser "ledger-state" - $ Opt.info (pQueryLedgerStateCmd envCli) + $ Opt.info (pQueryLedgerStateCmd era envCli) $ Opt.progDesc $ mconcat [ "Dump the current ledger state of the node (Ledger.NewEpochState -- advanced command)" ] , Just $ subParser "protocol-state" - $ Opt.info (pQueryProtocolStateCmd envCli) + $ Opt.info (pQueryProtocolStateCmd era envCli) $ Opt.progDesc $ mconcat [ "Dump the current protocol state of the node (Ledger.ChainDepState -- advanced command)" ] , Just $ subParser "stake-snapshot" - $ Opt.info (pQueryStakeSnapshotCmd envCli) + $ Opt.info (pQueryStakeSnapshotCmd era envCli) $ Opt.progDesc $ mconcat [ "Obtain the three stake snapshots for a pool, plus the total active stake (advanced command)" ] , Just $ hiddenSubParser "pool-params" - $ Opt.info (pQueryPoolStateCmd envCli) + $ Opt.info (pQueryPoolStateCmd era envCli) $ Opt.progDesc $ mconcat [ "DEPRECATED. Use query pool-state instead. Dump the pool parameters " , "(Ledger.NewEpochState.esLState._delegationState._pState._pParams -- advanced command)" ] , Just $ subParser "leadership-schedule" - $ Opt.info (pLeadershipScheduleCmd envCli) + $ Opt.info (pLeadershipScheduleCmd era envCli) $ Opt.progDesc "Get the slots the node is expected to mint a block in (advanced command)" , Just $ subParser "kes-period-info" - $ Opt.info (pKesPeriodInfoCmd envCli) + $ Opt.info (pKesPeriodInfoCmd era envCli) $ Opt.progDesc "Get information about the current KES period and your node's operational certificate." , Just $ subParser "pool-state" - $ Opt.info (pQueryPoolStateCmd envCli) + $ Opt.info (pQueryPoolStateCmd era envCli) $ Opt.progDesc "Dump the pool state" , Just $ subParser "tx-mempool" @@ -134,60 +134,66 @@ pQueryTipCmd era envCli = <*> pTarget era <*> pMaybeOutputFile -pQueryUTxOCmd :: EnvCli -> Parser (QueryCmds era) -pQueryUTxOCmd envCli = +pQueryUTxOCmd :: CardanoEra era -> EnvCli -> Parser (QueryCmds era) +pQueryUTxOCmd era envCli = fmap QueryUTxOCmd $ QueryUTxOCmdArgs <$> pSocketPath envCli <*> pConsensusModeParams <*> pQueryUTxOFilter <*> pNetworkId envCli + <*> pTarget era <*> pMaybeOutputFile -pQueryStakePoolsCmd :: EnvCli -> Parser (QueryCmds era) -pQueryStakePoolsCmd envCli = +pQueryStakePoolsCmd :: CardanoEra era -> EnvCli -> Parser (QueryCmds era) +pQueryStakePoolsCmd era envCli = fmap QueryStakePoolsCmd $ QueryStakePoolsCmdArgs <$> pSocketPath envCli <*> pConsensusModeParams <*> pNetworkId envCli + <*> pTarget era <*> pMaybeOutputFile -pQueryStakeDistributionCmd :: EnvCli -> Parser (QueryCmds era) -pQueryStakeDistributionCmd envCli = +pQueryStakeDistributionCmd :: CardanoEra era -> EnvCli -> Parser (QueryCmds era) +pQueryStakeDistributionCmd era envCli = fmap QueryStakeDistributionCmd $ QueryStakeDistributionCmdArgs <$> pSocketPath envCli <*> pConsensusModeParams <*> pNetworkId envCli + <*> pTarget era <*> pMaybeOutputFile -pQueryStakeAddressInfoCmd :: EnvCli -> Parser (QueryCmds era) -pQueryStakeAddressInfoCmd envCli = +pQueryStakeAddressInfoCmd :: CardanoEra era -> EnvCli -> Parser (QueryCmds era) +pQueryStakeAddressInfoCmd era envCli = fmap QueryStakeAddressInfoCmd $ QueryStakeAddressInfoCmdArgs <$> pSocketPath envCli <*> pConsensusModeParams <*> pFilterByStakeAddress <*> pNetworkId envCli + <*> pTarget era <*> pMaybeOutputFile -pQueryLedgerStateCmd :: EnvCli -> Parser (QueryCmds era) -pQueryLedgerStateCmd envCli = +pQueryLedgerStateCmd :: CardanoEra era -> EnvCli -> Parser (QueryCmds era) +pQueryLedgerStateCmd era envCli = fmap QueryLedgerStateCmd $ QueryLedgerStateCmdArgs <$> pSocketPath envCli <*> pConsensusModeParams <*> pNetworkId envCli + <*> pTarget era <*> pMaybeOutputFile -pQueryProtocolStateCmd :: EnvCli -> Parser (QueryCmds era) -pQueryProtocolStateCmd envCli = +pQueryProtocolStateCmd :: CardanoEra era -> EnvCli -> Parser (QueryCmds era) +pQueryProtocolStateCmd era envCli = fmap QueryProtocolStateCmd $ QueryProtocolStateCmdArgs <$> pSocketPath envCli <*> pConsensusModeParams <*> pNetworkId envCli + <*> pTarget era <*> pMaybeOutputFile pAllStakePoolsOrSome :: Parser (AllOrOnly (Hash StakePoolKey)) @@ -200,24 +206,26 @@ pAllStakePoolsOrSome = pAll <|> pOnly pOnly :: Parser (AllOrOnly (Hash StakePoolKey)) pOnly = Only <$> some (pStakePoolVerificationKeyHash Nothing) -pQueryStakeSnapshotCmd :: EnvCli -> Parser (QueryCmds era) -pQueryStakeSnapshotCmd envCli = +pQueryStakeSnapshotCmd :: CardanoEra era -> EnvCli -> Parser (QueryCmds era) +pQueryStakeSnapshotCmd era envCli = fmap QueryStakeSnapshotCmd $ QueryStakeSnapshotCmdArgs <$> pSocketPath envCli <*> pConsensusModeParams <*> pNetworkId envCli <*> pAllStakePoolsOrSome + <*> pTarget era <*> pMaybeOutputFile -pQueryPoolStateCmd :: EnvCli -> Parser (QueryCmds era) -pQueryPoolStateCmd envCli = +pQueryPoolStateCmd :: CardanoEra era -> EnvCli -> Parser (QueryCmds era) +pQueryPoolStateCmd era envCli = fmap QueryPoolStateCmd $ QueryPoolStateCmdArgs <$> pSocketPath envCli <*> pConsensusModeParams <*> pNetworkId envCli <*> pAllStakePoolsOrSome + <*> pTarget era pQueryTxMempoolCmd :: EnvCli -> Parser (QueryCmds era) pQueryTxMempoolCmd envCli = @@ -241,8 +249,8 @@ pQueryTxMempoolCmd envCli = $ Opt.info (TxMempoolQueryTxExists <$> argument Opt.str (metavar "TX_ID")) $ Opt.progDesc "Query if a particular transaction exists in the mempool" ] -pLeadershipScheduleCmd :: EnvCli -> Parser (QueryCmds era) -pLeadershipScheduleCmd envCli = +pLeadershipScheduleCmd :: CardanoEra era -> EnvCli -> Parser (QueryCmds era) +pLeadershipScheduleCmd era envCli = fmap QueryLeadershipScheduleCmd $ QueryLeadershipScheduleCmdArgs <$> pSocketPath envCli @@ -252,16 +260,18 @@ pLeadershipScheduleCmd envCli = <*> pStakePoolVerificationKeyOrHashOrFile Nothing <*> pVrfSigningKeyFile <*> pWhichLeadershipSchedule + <*> pTarget era <*> pMaybeOutputFile -pKesPeriodInfoCmd :: EnvCli -> Parser (QueryCmds era) -pKesPeriodInfoCmd envCli = +pKesPeriodInfoCmd :: CardanoEra era -> EnvCli -> Parser (QueryCmds era) +pKesPeriodInfoCmd era envCli = fmap QueryKesPeriodInfoCmd $ QueryKesPeriodInfoCmdArgs <$> pSocketPath envCli <*> pConsensusModeParams <*> pNetworkId envCli <*> pOperationalCertificateFile + <*> pTarget era <*> pMaybeOutputFile pQuerySlotNumberCmd :: EnvCli -> Parser (QueryCmds era) diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Run/Query.hs b/cardano-cli/src/Cardano/CLI/EraBased/Run/Query.hs index d34b778025..e7e59f894f 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Run/Query.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Run/Query.hs @@ -330,12 +330,13 @@ runQueryUTxOCmd , Cmd.consensusModeParams , Cmd.queryFilter , Cmd.networkId + , Cmd.target , Cmd.mOutFile } = do let localNodeConnInfo = LocalNodeConnectInfo consensusModeParams networkId nodeSocketPath join $ lift - ( executeLocalStateQueryExpr localNodeConnInfo Consensus.VolatileTip $ runExceptT $ do + ( executeLocalStateQueryExpr localNodeConnInfo target $ runExceptT $ do AnyCardanoEra era <- lift queryCurrentEra & onLeft (left . QueryCmdUnsupportedNtcVersion) @@ -361,6 +362,7 @@ runQueryKesPeriodInfoCmd , Cmd.consensusModeParams , Cmd.networkId , Cmd.nodeOpCertFp + , Cmd.target , Cmd.mOutFile } = do opCert <- lift (readFileTextEnvelope AsOperationalCertificate nodeOpCertFp) @@ -369,7 +371,7 @@ runQueryKesPeriodInfoCmd let localNodeConnInfo = LocalNodeConnectInfo consensusModeParams networkId nodeSocketPath join $ lift - ( executeLocalStateQueryExpr localNodeConnInfo Consensus.VolatileTip $ runExceptT $ do + ( executeLocalStateQueryExpr localNodeConnInfo target $ runExceptT $ do AnyCardanoEra era <- lift queryCurrentEra & onLeft (left . QueryCmdUnsupportedNtcVersion) @@ -622,11 +624,12 @@ runQueryPoolStateCmd , Cmd.consensusModeParams , Cmd.networkId , Cmd.allOrOnlyPoolIds + , Cmd.target } = do let localNodeConnInfo = LocalNodeConnectInfo consensusModeParams networkId nodeSocketPath join $ lift - ( executeLocalStateQueryExpr localNodeConnInfo Consensus.VolatileTip $ runExceptT $ do + ( executeLocalStateQueryExpr localNodeConnInfo target $ runExceptT $ do AnyCardanoEra era <- lift queryCurrentEra & onLeft (left . QueryCmdUnsupportedNtcVersion) @@ -703,12 +706,13 @@ runQueryStakeSnapshotCmd , Cmd.consensusModeParams , Cmd.networkId , Cmd.allOrOnlyPoolIds + , Cmd.target , Cmd.mOutFile } = do let localNodeConnInfo = LocalNodeConnectInfo consensusModeParams networkId nodeSocketPath join $ lift - ( executeLocalStateQueryExpr localNodeConnInfo Consensus.VolatileTip $ runExceptT $ do + ( executeLocalStateQueryExpr localNodeConnInfo target $ runExceptT $ do AnyCardanoEra era <- lift queryCurrentEra & onLeft (left . QueryCmdUnsupportedNtcVersion) @@ -739,12 +743,13 @@ runQueryLedgerStateCmd { Cmd.nodeSocketPath , Cmd.consensusModeParams , Cmd.networkId + , Cmd.target , Cmd.mOutFile } = do let localNodeConnInfo = LocalNodeConnectInfo consensusModeParams networkId nodeSocketPath join $ lift - ( executeLocalStateQueryExpr localNodeConnInfo Consensus.VolatileTip $ runExceptT $ do + ( executeLocalStateQueryExpr localNodeConnInfo target $ runExceptT $ do AnyCardanoEra era <- lift queryCurrentEra & onLeft (left . QueryCmdUnsupportedNtcVersion) @@ -769,12 +774,13 @@ runQueryProtocolStateCmd { Cmd.nodeSocketPath , Cmd.consensusModeParams , Cmd.networkId + , Cmd.target , Cmd.mOutFile } = do let localNodeConnInfo = LocalNodeConnectInfo consensusModeParams networkId nodeSocketPath join $ lift - ( executeLocalStateQueryExpr localNodeConnInfo Consensus.VolatileTip $ runExceptT $ do + ( executeLocalStateQueryExpr localNodeConnInfo target $ runExceptT $ do AnyCardanoEra era <- lift queryCurrentEra & onLeft (left . QueryCmdUnsupportedNtcVersion) @@ -802,12 +808,13 @@ runQueryStakeAddressInfoCmd , Cmd.consensusModeParams , Cmd.addr = StakeAddress _ addr , Cmd.networkId + , Cmd.target , Cmd.mOutFile } = do let localNodeConnInfo = LocalNodeConnectInfo consensusModeParams networkId nodeSocketPath join $ lift - ( executeLocalStateQueryExpr localNodeConnInfo Consensus.VolatileTip $ runExceptT $ do + ( executeLocalStateQueryExpr localNodeConnInfo target $ runExceptT $ do AnyCardanoEra era <- lift queryCurrentEra & onLeft (left . QueryCmdUnsupportedNtcVersion) @@ -1124,12 +1131,13 @@ runQueryStakePoolsCmd { Cmd.nodeSocketPath , Cmd.consensusModeParams , Cmd.networkId + , Cmd.target , Cmd.mOutFile } = do let localNodeConnInfo = LocalNodeConnectInfo consensusModeParams networkId nodeSocketPath join $ lift - ( executeLocalStateQueryExpr localNodeConnInfo Consensus.VolatileTip $ runExceptT @QueryCmdError $ do + ( executeLocalStateQueryExpr localNodeConnInfo target $ runExceptT @QueryCmdError $ do AnyCardanoEra era <- lift queryCurrentEra & onLeft (left . QueryCmdUnsupportedNtcVersion) sbe <- requireShelleyBasedEra era @@ -1164,12 +1172,13 @@ runQueryStakeDistributionCmd { Cmd.nodeSocketPath , Cmd.consensusModeParams , Cmd.networkId + , Cmd.target , Cmd.mOutFile } = do let localNodeConnInfo = LocalNodeConnectInfo consensusModeParams networkId nodeSocketPath join $ lift - ( executeLocalStateQueryExpr localNodeConnInfo Consensus.VolatileTip $ runExceptT $ do + ( executeLocalStateQueryExpr localNodeConnInfo target $ runExceptT $ do AnyCardanoEra era <- lift queryCurrentEra & onLeft (left . QueryCmdUnsupportedNtcVersion) @@ -1233,6 +1242,7 @@ runQueryLeadershipScheduleCmd , Cmd.poolColdVerKeyFile , Cmd.vrkSkeyFp , Cmd.whichSchedule + , Cmd.target , Cmd.mOutFile } = do let localNodeConnInfo = LocalNodeConnectInfo consensusModeParams networkId nodeSocketPath @@ -1247,7 +1257,7 @@ runQueryLeadershipScheduleCmd & onLeft (left . QueryCmdGenesisReadError) join $ lift - ( executeLocalStateQueryExpr localNodeConnInfo Consensus.VolatileTip $ runExceptT $ do + ( executeLocalStateQueryExpr localNodeConnInfo target $ runExceptT $ do AnyCardanoEra era <- lift queryCurrentEra & onLeft (left . QueryCmdUnsupportedNtcVersion) diff --git a/cardano-cli/src/Cardano/CLI/Legacy/Run/Query.hs b/cardano-cli/src/Cardano/CLI/Legacy/Run/Query.hs index ebb141d5cb..2970a874f2 100644 --- a/cardano-cli/src/Cardano/CLI/Legacy/Run/Query.hs +++ b/cardano-cli/src/Cardano/CLI/Legacy/Run/Query.hs @@ -52,13 +52,13 @@ runLegacyQueryUTxOCmd :: () => Cmd.LegacyQueryUTxOCmdArgs -> ExceptT QueryCmdError IO () runLegacyQueryUTxOCmd Cmd.LegacyQueryUTxOCmdArgs {..} = - EraBased.runQueryUTxOCmd EraBased.QueryUTxOCmdArgs {..} + EraBased.runQueryUTxOCmd EraBased.QueryUTxOCmdArgs {target = Consensus.VolatileTip, ..} runLegacyQueryKesPeriodInfoCmd :: () => Cmd.LegacyQueryKesPeriodInfoCmdArgs -> ExceptT QueryCmdError IO () runLegacyQueryKesPeriodInfoCmd Cmd.LegacyQueryKesPeriodInfoCmdArgs {..} = - EraBased.runQueryKesPeriodInfoCmd EraBased.QueryKesPeriodInfoCmdArgs {..} + EraBased.runQueryKesPeriodInfoCmd EraBased.QueryKesPeriodInfoCmdArgs {target = Consensus.VolatileTip, ..} -- | Query the current and future parameters for a stake pool, including the retirement date. -- Any of these may be empty (in which case a null will be displayed). @@ -67,7 +67,7 @@ runLegacyQueryPoolStateCmd :: () => Cmd.LegacyQueryPoolStateCmdArgs -> ExceptT QueryCmdError IO () runLegacyQueryPoolStateCmd Cmd.LegacyQueryPoolStateCmdArgs {..} = - EraBased.runQueryPoolStateCmd EraBased.QueryPoolStateCmdArgs {..} + EraBased.runQueryPoolStateCmd EraBased.QueryPoolStateCmdArgs {target = Consensus.VolatileTip, ..} -- | Query the local mempool state runLegacyQueryTxMempoolCmd :: () @@ -89,19 +89,19 @@ runLegacyQueryStakeSnapshotCmd :: () => Cmd.LegacyQueryStakeSnapshotCmdArgs -> ExceptT QueryCmdError IO () runLegacyQueryStakeSnapshotCmd Cmd.LegacyQueryStakeSnapshotCmdArgs {..} = - EraBased.runQueryStakeSnapshotCmd EraBased.QueryStakeSnapshotCmdArgs {..} + EraBased.runQueryStakeSnapshotCmd EraBased.QueryStakeSnapshotCmdArgs {target = Consensus.VolatileTip, ..} runLegacyQueryLedgerStateCmd :: () => Cmd.LegacyQueryLedgerStateCmdArgs -> ExceptT QueryCmdError IO () runLegacyQueryLedgerStateCmd Cmd.LegacyQueryLedgerStateCmdArgs {..} = - EraBased.runQueryLedgerStateCmd EraBased.QueryLedgerStateCmdArgs {..} + EraBased.runQueryLedgerStateCmd EraBased.QueryLedgerStateCmdArgs {target = Consensus.VolatileTip, ..} runLegacyQueryProtocolStateCmd :: () => Cmd.LegacyQueryProtocolStateCmdArgs -> ExceptT QueryCmdError IO () runLegacyQueryProtocolStateCmd Cmd.LegacyQueryProtocolStateCmdArgs {..} = - EraBased.runQueryProtocolStateCmd EraBased.QueryProtocolStateCmdArgs {..} + EraBased.runQueryProtocolStateCmd EraBased.QueryProtocolStateCmdArgs {target = Consensus.VolatileTip, ..} -- | Query the current delegations and reward accounts, filtered by a given -- set of addresses, from a Shelley node via the local state query protocol. @@ -110,22 +110,22 @@ runLegacyQueryStakeAddressInfoCmd :: () => Cmd.LegacyQueryStakeAddressInfoCmdArgs -> ExceptT QueryCmdError IO () runLegacyQueryStakeAddressInfoCmd Cmd.LegacyQueryStakeAddressInfoCmdArgs {..} = - EraBased.runQueryStakeAddressInfoCmd EraBased.QueryStakeAddressInfoCmdArgs {..} + EraBased.runQueryStakeAddressInfoCmd EraBased.QueryStakeAddressInfoCmdArgs {target = Consensus.VolatileTip, ..} runLegacyQueryStakePoolsCmd :: () => Cmd.LegacyQueryStakePoolsCmdArgs -> ExceptT QueryCmdError IO () runLegacyQueryStakePoolsCmd Cmd.LegacyQueryStakePoolsCmdArgs {..} = - EraBased.runQueryStakePoolsCmd EraBased.QueryStakePoolsCmdArgs {..} + EraBased.runQueryStakePoolsCmd EraBased.QueryStakePoolsCmdArgs {target = Consensus.VolatileTip, ..} runLegacyQueryStakeDistributionCmd :: () => Cmd.LegacyQueryStakeDistributionCmdArgs -> ExceptT QueryCmdError IO () runLegacyQueryStakeDistributionCmd Cmd.LegacyQueryStakeDistributionCmdArgs {..} = - EraBased.runQueryStakeDistributionCmd EraBased.QueryStakeDistributionCmdArgs {..} + EraBased.runQueryStakeDistributionCmd EraBased.QueryStakeDistributionCmdArgs {target = Consensus.VolatileTip, ..} runLegacyQueryLeadershipScheduleCmd :: () => Cmd.LegacyQueryLeadershipScheduleCmdArgs -> ExceptT QueryCmdError IO () runLegacyQueryLeadershipScheduleCmd Cmd.LegacyQueryLeadershipScheduleCmdArgs {..} = - EraBased.runQueryLeadershipScheduleCmd EraBased.QueryLeadershipScheduleCmdArgs {..} + EraBased.runQueryLeadershipScheduleCmd EraBased.QueryLeadershipScheduleCmdArgs {target = Consensus.VolatileTip, ..} diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help.cli index 5450237411..68f472163b 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help.cli @@ -6520,6 +6520,7 @@ Usage: cardano-cli conway query stake-pools --socket-path SOCKET_PATH ( --mainnet | --testnet-magic NATURAL ) + [--volatile-tip | --immutable-tip] [--out-file FILE] Get the node's current set of stake pool ids @@ -6530,6 +6531,9 @@ Usage: cardano-cli conway query stake-distribution --socket-path SOCKET_PATH ( --mainnet | --testnet-magic NATURAL ) + [ --volatile-tip + | --immutable-tip + ] [--out-file FILE] Get the node's current aggregated stake distribution @@ -6541,6 +6545,9 @@ Usage: cardano-cli conway query stake-address-info --socket-path SOCKET_PATH ( --mainnet | --testnet-magic NATURAL ) + [ --volatile-tip + | --immutable-tip + ] [--out-file FILE] Get the current delegations and reward accounts filtered by stake address. @@ -6552,6 +6559,7 @@ Usage: cardano-cli conway query utxo --socket-path SOCKET_PATH | (--tx-in TX-IN) ) (--mainnet | --testnet-magic NATURAL) + [--volatile-tip | --immutable-tip] [--out-file FILE] Get a portion of the current UTxO: by tx in, by address or the whole. @@ -6562,6 +6570,9 @@ Usage: cardano-cli conway query ledger-state --socket-path SOCKET_PATH ( --mainnet | --testnet-magic NATURAL ) + [ --volatile-tip + | --immutable-tip + ] [--out-file FILE] Dump the current ledger state of the node (Ledger.NewEpochState -- advanced @@ -6573,6 +6584,9 @@ Usage: cardano-cli conway query protocol-state --socket-path SOCKET_PATH ( --mainnet | --testnet-magic NATURAL ) + [ --volatile-tip + | --immutable-tip + ] [--out-file FILE] Dump the current protocol state of the node (Ledger.ChainDepState -- advanced @@ -6587,6 +6601,9 @@ Usage: cardano-cli conway query stake-snapshot --socket-path SOCKET_PATH ( --all-stake-pools | (--stake-pool-id STAKE_POOL_ID) ) + [ --volatile-tip + | --immutable-tip + ] [--out-file FILE] Obtain the three stake snapshots for a pool, plus the total active stake @@ -6601,6 +6618,7 @@ Usage: cardano-cli conway query pool-params --socket-path SOCKET_PATH ( --all-stake-pools | (--stake-pool-id STAKE_POOL_ID) ) + [--volatile-tip | --immutable-tip] DEPRECATED. Use query pool-state instead. Dump the pool parameters (Ledger.NewEpochState.esLState._delegationState._pState._pParams -- advanced @@ -6619,6 +6637,9 @@ Usage: cardano-cli conway query leadership-schedule --socket-path SOCKET_PATH ) --vrf-signing-key-file FILE (--current | --next) + [ --volatile-tip + | --immutable-tip + ] [--out-file FILE] Get the slots the node is expected to mint a block in (advanced command) @@ -6630,6 +6651,9 @@ Usage: cardano-cli conway query kes-period-info --socket-path SOCKET_PATH | --testnet-magic NATURAL ) --op-cert-file FILE + [ --volatile-tip + | --immutable-tip + ] [--out-file FILE] Get information about the current KES period and your node's operational @@ -6644,6 +6668,7 @@ Usage: cardano-cli conway query pool-state --socket-path SOCKET_PATH ( --all-stake-pools | (--stake-pool-id STAKE_POOL_ID) ) + [--volatile-tip | --immutable-tip] Dump the pool state diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_query_kes-period-info.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_query_kes-period-info.cli index 4f7f72d8d7..d522cc977b 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_query_kes-period-info.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_query_kes-period-info.cli @@ -5,6 +5,9 @@ Usage: cardano-cli conway query kes-period-info --socket-path SOCKET_PATH | --testnet-magic NATURAL ) --op-cert-file FILE + [ --volatile-tip + | --immutable-tip + ] [--out-file FILE] Get information about the current KES period and your node's operational @@ -25,5 +28,8 @@ Available options: --testnet-magic NATURAL Specify a testnet magic id. This overrides the CARDANO_NODE_NETWORK_ID environment variable --op-cert-file FILE Filepath of the node's operational certificate. + --volatile-tip Use the volatile tip as a target. (This is the + default) + --immutable-tip Use the immutable tip as a target. --out-file FILE Optional output file. Default is to write to stdout. -h,--help Show this help text diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_query_leadership-schedule.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_query_leadership-schedule.cli index fc956363bd..fa4c384636 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_query_leadership-schedule.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_query_leadership-schedule.cli @@ -11,6 +11,9 @@ Usage: cardano-cli conway query leadership-schedule --socket-path SOCKET_PATH ) --vrf-signing-key-file FILE (--current | --next) + [ --volatile-tip + | --immutable-tip + ] [--out-file FILE] Get the slots the node is expected to mint a block in (advanced command) @@ -41,5 +44,8 @@ Available options: Input filepath of the VRF signing key. --current Get the leadership schedule for the current epoch. --next Get the leadership schedule for the following epoch. + --volatile-tip Use the volatile tip as a target. (This is the + default) + --immutable-tip Use the immutable tip as a target. --out-file FILE Optional output file. Default is to write to stdout. -h,--help Show this help text diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_query_ledger-state.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_query_ledger-state.cli index fba287458b..cc6b29268d 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_query_ledger-state.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_query_ledger-state.cli @@ -4,6 +4,9 @@ Usage: cardano-cli conway query ledger-state --socket-path SOCKET_PATH ( --mainnet | --testnet-magic NATURAL ) + [ --volatile-tip + | --immutable-tip + ] [--out-file FILE] Dump the current ledger state of the node (Ledger.NewEpochState -- advanced @@ -23,5 +26,8 @@ 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 + --volatile-tip Use the volatile tip as a target. (This is the + default) + --immutable-tip Use the immutable tip as a target. --out-file FILE Optional output file. Default is to write to stdout. -h,--help Show this help text diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_query_pool-params.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_query_pool-params.cli index abbd2e1db9..0a2a362704 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_query_pool-params.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_query_pool-params.cli @@ -7,6 +7,7 @@ Usage: cardano-cli conway query pool-params --socket-path SOCKET_PATH ( --all-stake-pools | (--stake-pool-id STAKE_POOL_ID) ) + [--volatile-tip | --immutable-tip] DEPRECATED. Use query pool-state instead. Dump the pool parameters (Ledger.NewEpochState.esLState._delegationState._pState._pParams -- advanced @@ -30,4 +31,7 @@ Available options: --stake-pool-id STAKE_POOL_ID Stake pool ID/verification key hash (either Bech32-encoded or hex-encoded). + --volatile-tip Use the volatile tip as a target. (This is the + default) + --immutable-tip Use the immutable tip as a target. -h,--help Show this help text diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_query_pool-state.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_query_pool-state.cli index 627d291e0a..64b5b2cd65 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_query_pool-state.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_query_pool-state.cli @@ -7,6 +7,7 @@ Usage: cardano-cli conway query pool-state --socket-path SOCKET_PATH ( --all-stake-pools | (--stake-pool-id STAKE_POOL_ID) ) + [--volatile-tip | --immutable-tip] Dump the pool state @@ -28,4 +29,7 @@ Available options: --stake-pool-id STAKE_POOL_ID Stake pool ID/verification key hash (either Bech32-encoded or hex-encoded). + --volatile-tip Use the volatile tip as a target. (This is the + default) + --immutable-tip Use the immutable tip as a target. -h,--help Show this help text diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_query_protocol-state.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_query_protocol-state.cli index 896ee78795..7b35f4e1a1 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_query_protocol-state.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_query_protocol-state.cli @@ -4,6 +4,9 @@ Usage: cardano-cli conway query protocol-state --socket-path SOCKET_PATH ( --mainnet | --testnet-magic NATURAL ) + [ --volatile-tip + | --immutable-tip + ] [--out-file FILE] Dump the current protocol state of the node (Ledger.ChainDepState -- advanced @@ -23,5 +26,8 @@ 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 + --volatile-tip Use the volatile tip as a target. (This is the + default) + --immutable-tip Use the immutable tip as a target. --out-file FILE Optional output file. Default is to write to stdout. -h,--help Show this help text diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_query_stake-address-info.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_query_stake-address-info.cli index 9a9a7c3c91..344f38d569 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_query_stake-address-info.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_query_stake-address-info.cli @@ -5,6 +5,9 @@ Usage: cardano-cli conway query stake-address-info --socket-path SOCKET_PATH ( --mainnet | --testnet-magic NATURAL ) + [ --volatile-tip + | --immutable-tip + ] [--out-file FILE] Get the current delegations and reward accounts filtered by stake address. @@ -24,5 +27,8 @@ 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 + --volatile-tip Use the volatile tip as a target. (This is the + default) + --immutable-tip Use the immutable tip as a target. --out-file FILE Optional output file. Default is to write to stdout. -h,--help Show this help text diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_query_stake-distribution.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_query_stake-distribution.cli index c71a9f2beb..fc6ac6faf4 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_query_stake-distribution.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_query_stake-distribution.cli @@ -4,6 +4,9 @@ Usage: cardano-cli conway query stake-distribution --socket-path SOCKET_PATH ( --mainnet | --testnet-magic NATURAL ) + [ --volatile-tip + | --immutable-tip + ] [--out-file FILE] Get the node's current aggregated stake distribution @@ -22,5 +25,8 @@ 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 + --volatile-tip Use the volatile tip as a target. (This is the + default) + --immutable-tip Use the immutable tip as a target. --out-file FILE Optional output file. Default is to write to stdout. -h,--help Show this help text diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_query_stake-pools.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_query_stake-pools.cli index 19b4c61279..573dab1ef7 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_query_stake-pools.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_query_stake-pools.cli @@ -4,6 +4,7 @@ Usage: cardano-cli conway query stake-pools --socket-path SOCKET_PATH ( --mainnet | --testnet-magic NATURAL ) + [--volatile-tip | --immutable-tip] [--out-file FILE] Get the node's current set of stake pool ids @@ -22,5 +23,8 @@ 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 + --volatile-tip Use the volatile tip as a target. (This is the + default) + --immutable-tip Use the immutable tip as a target. --out-file FILE Optional output file. Default is to write to stdout. -h,--help Show this help text diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_query_stake-snapshot.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_query_stake-snapshot.cli index fc9bf2ee5d..5e57b09145 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_query_stake-snapshot.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_query_stake-snapshot.cli @@ -7,6 +7,9 @@ Usage: cardano-cli conway query stake-snapshot --socket-path SOCKET_PATH ( --all-stake-pools | (--stake-pool-id STAKE_POOL_ID) ) + [ --volatile-tip + | --immutable-tip + ] [--out-file FILE] Obtain the three stake snapshots for a pool, plus the total active stake @@ -30,5 +33,8 @@ Available options: --stake-pool-id STAKE_POOL_ID Stake pool ID/verification key hash (either Bech32-encoded or hex-encoded). + --volatile-tip Use the volatile tip as a target. (This is the + default) + --immutable-tip Use the immutable tip as a target. --out-file FILE Optional output file. Default is to write to stdout. -h,--help Show this help text diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_query_utxo.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_query_utxo.cli index ea3c2b4f3d..7bc2284783 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_query_utxo.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_query_utxo.cli @@ -5,6 +5,7 @@ Usage: cardano-cli conway query utxo --socket-path SOCKET_PATH | (--tx-in TX-IN) ) (--mainnet | --testnet-magic NATURAL) + [--volatile-tip | --immutable-tip] [--out-file FILE] Get a portion of the current UTxO: by tx in, by address or the whole. @@ -27,5 +28,8 @@ 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 + --volatile-tip Use the volatile tip as a target. (This is the + default) + --immutable-tip Use the immutable tip as a target. --out-file FILE Optional output file. Default is to write to stdout. -h,--help Show this help text From 2a2be2fee5354666d2192420ded69987ae5beb42 Mon Sep 17 00:00:00 2001 From: Pablo Lamela Date: Sat, 10 Feb 2024 00:34:15 +0100 Subject: [PATCH 3/5] Add immutable tip parameter to rest of conway queries --- .../Cardano/CLI/EraBased/Commands/Query.hs | 6 ++++ .../Cardano/CLI/EraBased/Options/Common.hs | 35 +++++++++---------- .../src/Cardano/CLI/EraBased/Options/Query.hs | 11 ++++-- .../src/Cardano/CLI/EraBased/Run/Query.hs | 31 ++++++++++------ .../src/Cardano/CLI/Legacy/Run/Query.hs | 2 +- .../cardano-cli-golden/files/golden/help.cli | 12 +++++++ .../help/conway_query_committee-state.cli | 6 ++++ .../golden/help/conway_query_constitution.cli | 6 ++++ .../conway_query_drep-stake-distribution.cli | 6 ++++ .../golden/help/conway_query_drep-state.cli | 4 +++ .../golden/help/conway_query_gov-state.cli | 4 +++ .../golden/help/conway_query_slot-number.cli | 4 +++ 12 files changed, 94 insertions(+), 33 deletions(-) diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Commands/Query.hs b/cardano-cli/src/Cardano/CLI/EraBased/Commands/Query.hs index 98b973a988..52846b0c8c 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Commands/Query.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Commands/Query.hs @@ -83,6 +83,7 @@ data QueryConstitutionHashCmdArgs = QueryConstitutionHashCmdArgs { nodeSocketPath :: !SocketPath , consensusModeParams :: !ConsensusModeParams , networkId :: !NetworkId + , target :: !(Consensus.Target ChainPoint) , mOutFile :: !(Maybe (File () Out)) } deriving (Generic, Show) @@ -183,6 +184,7 @@ data QuerySlotNumberCmdArgs = QuerySlotNumberCmdArgs { nodeSocketPath :: !SocketPath , consensusModeParams :: !ConsensusModeParams , networkId :: !NetworkId + , target :: !(Consensus.Target ChainPoint) , utcTime :: !UTCTime } deriving (Generic, Show) @@ -191,6 +193,7 @@ data QueryNoArgCmdArgs era = QueryNoArgCmdArgs , nodeSocketPath :: !SocketPath , consensusModeParams :: !ConsensusModeParams , networkId :: !NetworkId + , target :: !(Consensus.Target ChainPoint) , mOutFile :: !(Maybe (File () Out)) } deriving Show @@ -200,6 +203,7 @@ data QueryDRepStateCmdArgs era = QueryDRepStateCmdArgs , consensusModeParams :: !ConsensusModeParams , networkId :: !NetworkId , drepKeys :: !(AllOrOnly (VerificationKeyOrHashOrFile DRepKey)) + , target :: !(Consensus.Target ChainPoint) , mOutFile :: !(Maybe (File () Out)) } deriving Show @@ -209,6 +213,7 @@ data QueryDRepStakeDistributionCmdArgs era = QueryDRepStakeDistributionCmdArgs , consensusModeParams :: !ConsensusModeParams , networkId :: !NetworkId , drepKeys :: !(AllOrOnly (VerificationKeyOrHashOrFile DRepKey)) + , target :: !(Consensus.Target ChainPoint) , mOutFile :: !(Maybe (File () Out)) } deriving Show @@ -220,6 +225,7 @@ data QueryCommitteeMembersStateCmdArgs era = QueryCommitteeMembersStateCmdArgs , committeeColdKeys :: ![VerificationKeyOrHashOrFile CommitteeColdKey] , committeeHotKeys :: ![VerificationKeyOrHashOrFile CommitteeHotKey] , memberStatuses :: ![MemberStatus] + , target :: !(Consensus.Target ChainPoint) , mOutFile :: !(Maybe (File () Out)) } deriving Show diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Options/Common.hs b/cardano-cli/src/Cardano/CLI/EraBased/Options/Common.hs index ae1ab22096..aa30275959 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Options/Common.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Options/Common.hs @@ -104,28 +104,27 @@ pNetworkId envCli = asum $ mconcat ] pTarget :: CardanoEra era -> Parser (Consensus.Target ChainPoint) -pTarget = - inEonForEra (pure Consensus.VolatileTip) conwayOnwardsTargetParser - where - conwayOnwardsTargetParser :: ConwayEraOnwards era -> Parser (Consensus.Target ChainPoint) - conwayOnwardsTargetParser ConwayEraOnwardsConway = - asum $ mconcat - [ [ Opt.flag' Consensus.VolatileTip $ mconcat - [ Opt.long "volatile-tip" - , Opt.help $ mconcat - [ "Use the volatile tip as a target. (This is the default)" - ] +pTarget = inEonForEra (pure Consensus.VolatileTip) pTargetFromConway + +pTargetFromConway :: ConwayEraOnwards era -> Parser (Consensus.Target ChainPoint) +pTargetFromConway ConwayEraOnwardsConway = + asum $ mconcat + [ [ Opt.flag' Consensus.VolatileTip $ mconcat + [ Opt.long "volatile-tip" + , Opt.help $ mconcat + [ "Use the volatile tip as a target. (This is the default)" ] - , Opt.flag' Consensus.ImmutableTip $ mconcat - [ Opt.long "immutable-tip" - , Opt.help $ mconcat - [ "Use the immutable tip as a target." - ] + ] + , Opt.flag' Consensus.ImmutableTip $ mconcat + [ Opt.long "immutable-tip" + , Opt.help $ mconcat + [ "Use the immutable tip as a target." ] ] - , -- Default to volatile tip if not specified - [ pure Consensus.VolatileTip ] ] + , -- Default to volatile tip if not specified + [ pure Consensus.VolatileTip ] + ] toUnitIntervalOrErr :: Rational -> L.UnitInterval toUnitIntervalOrErr r = case Ledger.boundRational r of diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Options/Query.hs b/cardano-cli/src/Cardano/CLI/EraBased/Options/Query.hs index 7b5f308109..10d17edebe 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Options/Query.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Options/Query.hs @@ -106,7 +106,7 @@ pQueryCmds era envCli = $ Opt.progDesc "Local Mempool info" , Just $ subParser "slot-number" - $ Opt.info (pQuerySlotNumberCmd envCli) + $ Opt.info (pQuerySlotNumberCmd era envCli) $ Opt.progDesc "Query slot number for UTC timestamp" , pQueryGetConstitutionCmd era envCli , pQueryGetGovStateCmd era envCli @@ -274,13 +274,14 @@ pKesPeriodInfoCmd era envCli = <*> pTarget era <*> pMaybeOutputFile -pQuerySlotNumberCmd :: EnvCli -> Parser (QueryCmds era) -pQuerySlotNumberCmd envCli = +pQuerySlotNumberCmd :: CardanoEra era -> EnvCli -> Parser (QueryCmds era) +pQuerySlotNumberCmd era envCli = fmap QuerySlotNumberCmd $ QuerySlotNumberCmdArgs <$> pSocketPath envCli <*> pConsensusModeParams <*> pNetworkId envCli + <*> pTarget era <*> pUtcTimestamp where pUtcTimestamp = @@ -334,6 +335,7 @@ pQueryDRepStateCmd era envCli = do <*> pConsensusModeParams <*> pNetworkId envCli <*> pAllOrOnlyDRepVerificationKeyOrHashOrFile + <*> pTargetFromConway w <*> optional pOutputFile pQueryDRepStakeDistributionCmd :: () @@ -353,6 +355,7 @@ pQueryDRepStakeDistributionCmd era envCli = do <*> pConsensusModeParams <*> pNetworkId envCli <*> pAllOrOnlyDRepVerificationKeyOrHashOrFile + <*> pTargetFromConway w <*> optional pOutputFile pQueryGetCommitteeStateCmd :: () @@ -374,6 +377,7 @@ pQueryGetCommitteeStateCmd era envCli = do <*> many pCommitteeColdVerificationKeyOrHashOrFile <*> many pCommitteeHotKeyOrHashOrFile <*> many pMemberStatus + <*> pTargetFromConway w <*> optional pOutputFile pMemberStatus :: Parser MemberStatus @@ -402,4 +406,5 @@ pQueryNoArgCmdArgs w envCli = <$> pSocketPath envCli <*> pConsensusModeParams <*> pNetworkId envCli + <*> pTargetFromConway w <*> optional pOutputFile diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Run/Query.hs b/cardano-cli/src/Cardano/CLI/EraBased/Run/Query.hs index e7e59f894f..2072d3b1ca 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Run/Query.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Run/Query.hs @@ -144,11 +144,12 @@ runQueryConstitutionHashCmd { Cmd.nodeSocketPath , Cmd.consensusModeParams , Cmd.networkId + , Cmd.target , Cmd.mOutFile } = do let localNodeConnInfo = LocalNodeConnectInfo consensusModeParams networkId nodeSocketPath - result <- liftIO $ executeLocalStateQueryExpr localNodeConnInfo Consensus.VolatileTip $ runExceptT $ do + result <- liftIO $ executeLocalStateQueryExpr localNodeConnInfo target $ runExceptT $ do AnyCardanoEra era <- lift queryCurrentEra & onLeft (left . QueryCmdUnsupportedNtcVersion) sbe <- requireShelleyBasedEra era @@ -690,8 +691,9 @@ runQuerySlotNumberCmd , Cmd.consensusModeParams , Cmd.networkId , Cmd.utcTime + , Cmd.target } = do - SlotNo slotNo <- utcTimeToSlotNo nodeSocketPath consensusModeParams networkId utcTime + SlotNo slotNo <- utcTimeToSlotNo nodeSocketPath consensusModeParams networkId target utcTime liftIO . putStr $ show slotNo -- | Obtain stake snapshot information for a pool, plus information about the total active stake. @@ -1399,10 +1401,11 @@ runQueryConstitution , Cmd.nodeSocketPath , Cmd.consensusModeParams , Cmd.networkId + , Cmd.target , Cmd.mOutFile } = conwayEraOnwardsConstraints eon $ do let localNodeConnInfo = LocalNodeConnectInfo consensusModeParams networkId nodeSocketPath - constitution <- runQuery localNodeConnInfo $ queryConstitution eon + constitution <- runQuery localNodeConnInfo target $ queryConstitution eon writeOutput mOutFile constitution runQueryGovState @@ -1414,10 +1417,11 @@ runQueryGovState , Cmd.nodeSocketPath , Cmd.consensusModeParams , Cmd.networkId + , Cmd.target , Cmd.mOutFile } = conwayEraOnwardsConstraints eon $ do let localNodeConnInfo = LocalNodeConnectInfo consensusModeParams networkId nodeSocketPath - govState <- runQuery localNodeConnInfo $ queryGovState eon + govState <- runQuery localNodeConnInfo target $ queryGovState eon writeOutput mOutFile govState runQueryDRepState @@ -1430,6 +1434,7 @@ runQueryDRepState , Cmd.consensusModeParams , Cmd.networkId , Cmd.drepKeys = drepKeys' + , Cmd.target , Cmd.mOutFile } = conwayEraOnwardsConstraints eon $ do let localNodeConnInfo = LocalNodeConnectInfo consensusModeParams networkId nodeSocketPath @@ -1439,7 +1444,7 @@ runQueryDRepState Only l -> l drepCreds <- Set.fromList <$> mapM (firstExceptT QueryCmdDRepKeyError . getDRepCredentialFromVerKeyHashOrFile) drepKeys - drepState <- runQuery localNodeConnInfo $ queryDRepState eon drepCreds + drepState <- runQuery localNodeConnInfo target $ queryDRepState eon drepCreds writeOutput mOutFile $ second drepStateToJson <$> Map.assocs drepState where @@ -1459,6 +1464,7 @@ runQueryDRepStakeDistribution , Cmd.consensusModeParams , Cmd.networkId , Cmd.drepKeys = drepKeys' + , Cmd.target , Cmd.mOutFile } = conwayEraOnwardsConstraints eon $ do let localNodeConnInfo = LocalNodeConnectInfo consensusModeParams networkId nodeSocketPath @@ -1471,7 +1477,7 @@ runQueryDRepStakeDistribution Only l -> l dreps <- Set.fromList <$> mapM drepFromVrfKey drepKeys - drepStakeDistribution <- runQuery localNodeConnInfo $ queryDRepStakeDistribution eon dreps + drepStakeDistribution <- runQuery localNodeConnInfo target $ queryDRepStakeDistribution eon dreps writeOutput mOutFile $ Map.assocs drepStakeDistribution @@ -1484,6 +1490,7 @@ runQueryCommitteeMembersState , Cmd.nodeSocketPath , Cmd.consensusModeParams , Cmd.networkId + , Cmd.target , Cmd.mOutFile , Cmd.committeeColdKeys = coldCredKeys , Cmd.committeeHotKeys = hotCredKeys @@ -1499,11 +1506,12 @@ runQueryCommitteeMembersState firstExceptT QueryCmdCommitteeHotKeyError . getCommitteeHotCredentialFromVerKeyHashOrFile hotKeys <- Set.fromList <$> mapM hotKeysFromVerKeyHashOrFile hotCredKeys - committeeState <- runQuery localNodeConnInfo $ + committeeState <- runQuery localNodeConnInfo target $ queryCommitteeMembersState eon coldKeys hotKeys (Set.fromList memberStatuses) writeOutput mOutFile $ A.toJSON committeeState runQuery :: LocalNodeConnectInfo + -> Consensus.Target ChainPoint -> LocalStateQueryExpr BlockInMode ChainPoint @@ -1514,9 +1522,9 @@ runQuery :: LocalNodeConnectInfo UnsupportedNtcVersionError (Either Consensus.EraMismatch a)) -> ExceptT QueryCmdError IO a -runQuery localNodeConnInfo query = +runQuery localNodeConnInfo target query = firstExceptT QueryCmdAcquireFailure - ( newExceptT $ executeLocalStateQueryExpr localNodeConnInfo Consensus.VolatileTip query) + ( newExceptT $ executeLocalStateQueryExpr localNodeConnInfo target query) & onLeft (left . QueryCmdUnsupportedNtcVersion) & onLeft (left . QueryCmdEraMismatch) @@ -1560,13 +1568,14 @@ utcTimeToSlotNo :: SocketPath -> ConsensusModeParams -> NetworkId + -> Consensus.Target ChainPoint -> UTCTime -> ExceptT QueryCmdError IO SlotNo -utcTimeToSlotNo nodeSocketPath consensusModeParams networkId utcTime = do +utcTimeToSlotNo nodeSocketPath consensusModeParams networkId target utcTime = do let localNodeConnInfo = LocalNodeConnectInfo consensusModeParams networkId nodeSocketPath lift - ( executeLocalStateQueryExpr localNodeConnInfo Consensus.VolatileTip $ runExceptT $ do + ( executeLocalStateQueryExpr localNodeConnInfo target $ runExceptT $ do systemStart <- lift querySystemStart & onLeft (left . QueryCmdUnsupportedNtcVersion) diff --git a/cardano-cli/src/Cardano/CLI/Legacy/Run/Query.hs b/cardano-cli/src/Cardano/CLI/Legacy/Run/Query.hs index 2970a874f2..7504915dcd 100644 --- a/cardano-cli/src/Cardano/CLI/Legacy/Run/Query.hs +++ b/cardano-cli/src/Cardano/CLI/Legacy/Run/Query.hs @@ -80,7 +80,7 @@ runLegacyQuerySlotNumberCmd :: () => Cmd.LegacyQuerySlotNumberCmdArgs -> ExceptT QueryCmdError IO () runLegacyQuerySlotNumberCmd Cmd.LegacyQuerySlotNumberCmdArgs {..} = - EraBased.runQuerySlotNumberCmd EraBased.QuerySlotNumberCmdArgs {..} + EraBased.runQuerySlotNumberCmd EraBased.QuerySlotNumberCmdArgs {target = Consensus.VolatileTip, ..} -- | Obtain stake snapshot information for a pool, plus information about the total active stake. -- This information can be used for leader slot calculation, for example, and has been requested by SPOs. diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help.cli index 68f472163b..a971afeb02 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help.cli @@ -6701,6 +6701,7 @@ Usage: cardano-cli conway query slot-number --socket-path SOCKET_PATH ( --mainnet | --testnet-magic NATURAL ) + [--volatile-tip | --immutable-tip] TIMESTAMP Query slot number for UTC timestamp @@ -6711,6 +6712,9 @@ Usage: cardano-cli conway query constitution --socket-path SOCKET_PATH ( --mainnet | --testnet-magic NATURAL ) + [ --volatile-tip + | --immutable-tip + ] [--out-file FILE] Get the constitution @@ -6721,6 +6725,7 @@ Usage: cardano-cli conway query gov-state --socket-path SOCKET_PATH ( --mainnet | --testnet-magic NATURAL ) + [--volatile-tip | --immutable-tip] [--out-file FILE] Get the governance state @@ -6738,6 +6743,7 @@ Usage: cardano-cli conway query drep-state --socket-path SOCKET_PATH | --drep-key-hash HASH ) ) + [--volatile-tip | --immutable-tip] [--out-file FILE] Get the DRep state. @@ -6756,6 +6762,9 @@ Usage: cardano-cli conway query drep-stake-distribution | --drep-key-hash HASH ) ) + [ --volatile-tip + | --immutable-tip + ] [--out-file FILE] Get the DRep stake distribution. @@ -6778,6 +6787,9 @@ Usage: cardano-cli conway query committee-state --socket-path SOCKET_PATH | --expired | --unrecognized ] + [ --volatile-tip + | --immutable-tip + ] [--out-file FILE] Get the committee state diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_query_committee-state.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_query_committee-state.cli index 2b8c89df2c..548dfc5229 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_query_committee-state.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_query_committee-state.cli @@ -16,6 +16,9 @@ Usage: cardano-cli conway query committee-state --socket-path SOCKET_PATH | --expired | --unrecognized ] + [ --volatile-tip + | --immutable-tip + ] [--out-file FILE] Get the committee state @@ -48,5 +51,8 @@ Available options: --expired Expired committee members --unrecognized Unrecognized committe members: a hot credential for an unknown cold credential + --volatile-tip Use the volatile tip as a target. (This is the + default) + --immutable-tip Use the immutable tip as a target. --out-file FILE The output file. -h,--help Show this help text diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_query_constitution.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_query_constitution.cli index b7ff99059a..c908211f3b 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_query_constitution.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_query_constitution.cli @@ -4,6 +4,9 @@ Usage: cardano-cli conway query constitution --socket-path SOCKET_PATH ( --mainnet | --testnet-magic NATURAL ) + [ --volatile-tip + | --immutable-tip + ] [--out-file FILE] Get the constitution @@ -22,5 +25,8 @@ 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 + --volatile-tip Use the volatile tip as a target. (This is the + default) + --immutable-tip Use the immutable tip as a target. --out-file FILE The output file. -h,--help Show this help text diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_query_drep-stake-distribution.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_query_drep-stake-distribution.cli index 15531ac701..24af22bc7a 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_query_drep-stake-distribution.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_query_drep-stake-distribution.cli @@ -12,6 +12,9 @@ Usage: cardano-cli conway query drep-stake-distribution | --drep-key-hash HASH ) ) + [ --volatile-tip + | --immutable-tip + ] [--out-file FILE] Get the DRep stake distribution. @@ -37,5 +40,8 @@ Available options: Filepath of the DRep verification key. --drep-key-hash HASH DRep verification key hash (either Bech32-encoded or hex-encoded). + --volatile-tip Use the volatile tip as a target. (This is the + default) + --immutable-tip Use the immutable tip as a target. --out-file FILE The output file. -h,--help Show this help text diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_query_drep-state.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_query_drep-state.cli index 7ebb59d9a3..62fbb788cd 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_query_drep-state.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_query_drep-state.cli @@ -11,6 +11,7 @@ Usage: cardano-cli conway query drep-state --socket-path SOCKET_PATH | --drep-key-hash HASH ) ) + [--volatile-tip | --immutable-tip] [--out-file FILE] Get the DRep state. @@ -36,5 +37,8 @@ Available options: Filepath of the DRep verification key. --drep-key-hash HASH DRep verification key hash (either Bech32-encoded or hex-encoded). + --volatile-tip Use the volatile tip as a target. (This is the + default) + --immutable-tip Use the immutable tip as a target. --out-file FILE The output file. -h,--help Show this help text diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_query_gov-state.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_query_gov-state.cli index bd2e20ce53..31685e3014 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_query_gov-state.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_query_gov-state.cli @@ -4,6 +4,7 @@ Usage: cardano-cli conway query gov-state --socket-path SOCKET_PATH ( --mainnet | --testnet-magic NATURAL ) + [--volatile-tip | --immutable-tip] [--out-file FILE] Get the governance state @@ -22,5 +23,8 @@ 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 + --volatile-tip Use the volatile tip as a target. (This is the + default) + --immutable-tip Use the immutable tip as a target. --out-file FILE The output file. -h,--help Show this help text diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_query_slot-number.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_query_slot-number.cli index 6d160767e8..0b0e9fbabe 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_query_slot-number.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_query_slot-number.cli @@ -4,6 +4,7 @@ Usage: cardano-cli conway query slot-number --socket-path SOCKET_PATH ( --mainnet | --testnet-magic NATURAL ) + [--volatile-tip | --immutable-tip] TIMESTAMP Query slot number for UTC timestamp @@ -22,5 +23,8 @@ 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 + --volatile-tip Use the volatile tip as a target. (This is the + default) + --immutable-tip Use the immutable tip as a target. TIMESTAMP UTC timestamp in YYYY-MM-DDThh:mm:ssZ format -h,--help Show this help text From 2107c5db5523ab6c9dcbad2d8cae71e9a8232eab Mon Sep 17 00:00:00 2001 From: Pablo Lamela Date: Sat, 10 Feb 2024 00:47:10 +0100 Subject: [PATCH 4/5] Refactor pTarget function --- .../Cardano/CLI/EraBased/Options/Common.hs | 8 ++-- .../src/Cardano/CLI/EraBased/Options/Query.hs | 44 ++++++++++++------- 2 files changed, 31 insertions(+), 21 deletions(-) diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Options/Common.hs b/cardano-cli/src/Cardano/CLI/EraBased/Options/Common.hs index aa30275959..f81917a930 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Options/Common.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Options/Common.hs @@ -103,11 +103,9 @@ pNetworkId envCli = asum $ mconcat pure <$> maybeToList (envCliNetworkId envCli) ] -pTarget :: CardanoEra era -> Parser (Consensus.Target ChainPoint) -pTarget = inEonForEra (pure Consensus.VolatileTip) pTargetFromConway - -pTargetFromConway :: ConwayEraOnwards era -> Parser (Consensus.Target ChainPoint) -pTargetFromConway ConwayEraOnwardsConway = +pTarget :: Maybe (ConwayEraOnwards era) -> Parser (Consensus.Target ChainPoint) +pTarget Nothing = pure Consensus.VolatileTip +pTarget (Just ConwayEraOnwardsConway) = asum $ mconcat [ [ Opt.flag' Consensus.VolatileTip $ mconcat [ Opt.long "volatile-tip" diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Options/Query.hs b/cardano-cli/src/Cardano/CLI/EraBased/Options/Query.hs index 10d17edebe..92852c2748 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Options/Query.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Options/Query.hs @@ -126,74 +126,81 @@ pQueryProtocolParametersCmd envCli = pQueryTipCmd :: CardanoEra era -> EnvCli -> Parser (QueryCmds era) pQueryTipCmd era envCli = + let mw = forEraMaybeEon era in fmap QueryTipCmd $ QueryTipCmdArgs <$> pSocketPath envCli <*> pConsensusModeParams <*> pNetworkId envCli - <*> pTarget era + <*> pTarget mw <*> pMaybeOutputFile pQueryUTxOCmd :: CardanoEra era -> EnvCli -> Parser (QueryCmds era) pQueryUTxOCmd era envCli = + let mw = forEraMaybeEon era in fmap QueryUTxOCmd $ QueryUTxOCmdArgs <$> pSocketPath envCli <*> pConsensusModeParams <*> pQueryUTxOFilter <*> pNetworkId envCli - <*> pTarget era + <*> pTarget mw <*> pMaybeOutputFile pQueryStakePoolsCmd :: CardanoEra era -> EnvCli -> Parser (QueryCmds era) pQueryStakePoolsCmd era envCli = + let mw = forEraMaybeEon era in fmap QueryStakePoolsCmd $ QueryStakePoolsCmdArgs <$> pSocketPath envCli <*> pConsensusModeParams <*> pNetworkId envCli - <*> pTarget era + <*> pTarget mw <*> pMaybeOutputFile pQueryStakeDistributionCmd :: CardanoEra era -> EnvCli -> Parser (QueryCmds era) pQueryStakeDistributionCmd era envCli = + let mw = forEraMaybeEon era in fmap QueryStakeDistributionCmd $ QueryStakeDistributionCmdArgs <$> pSocketPath envCli <*> pConsensusModeParams <*> pNetworkId envCli - <*> pTarget era + <*> pTarget mw <*> pMaybeOutputFile pQueryStakeAddressInfoCmd :: CardanoEra era -> EnvCli -> Parser (QueryCmds era) pQueryStakeAddressInfoCmd era envCli = + let mw = forEraMaybeEon era in fmap QueryStakeAddressInfoCmd $ QueryStakeAddressInfoCmdArgs <$> pSocketPath envCli <*> pConsensusModeParams <*> pFilterByStakeAddress <*> pNetworkId envCli - <*> pTarget era + <*> pTarget mw <*> pMaybeOutputFile pQueryLedgerStateCmd :: CardanoEra era -> EnvCli -> Parser (QueryCmds era) pQueryLedgerStateCmd era envCli = + let mw = forEraMaybeEon era in fmap QueryLedgerStateCmd $ QueryLedgerStateCmdArgs <$> pSocketPath envCli <*> pConsensusModeParams <*> pNetworkId envCli - <*> pTarget era + <*> pTarget mw <*> pMaybeOutputFile pQueryProtocolStateCmd :: CardanoEra era -> EnvCli -> Parser (QueryCmds era) pQueryProtocolStateCmd era envCli = + let mw = forEraMaybeEon era in fmap QueryProtocolStateCmd $ QueryProtocolStateCmdArgs <$> pSocketPath envCli <*> pConsensusModeParams <*> pNetworkId envCli - <*> pTarget era + <*> pTarget mw <*> pMaybeOutputFile pAllStakePoolsOrSome :: Parser (AllOrOnly (Hash StakePoolKey)) @@ -208,24 +215,26 @@ pAllStakePoolsOrSome = pAll <|> pOnly pQueryStakeSnapshotCmd :: CardanoEra era -> EnvCli -> Parser (QueryCmds era) pQueryStakeSnapshotCmd era envCli = + let mw = forEraMaybeEon era in fmap QueryStakeSnapshotCmd $ QueryStakeSnapshotCmdArgs <$> pSocketPath envCli <*> pConsensusModeParams <*> pNetworkId envCli <*> pAllStakePoolsOrSome - <*> pTarget era + <*> pTarget mw <*> pMaybeOutputFile pQueryPoolStateCmd :: CardanoEra era -> EnvCli -> Parser (QueryCmds era) pQueryPoolStateCmd era envCli = + let mw = forEraMaybeEon era in fmap QueryPoolStateCmd $ QueryPoolStateCmdArgs <$> pSocketPath envCli <*> pConsensusModeParams <*> pNetworkId envCli <*> pAllStakePoolsOrSome - <*> pTarget era + <*> pTarget mw pQueryTxMempoolCmd :: EnvCli -> Parser (QueryCmds era) pQueryTxMempoolCmd envCli = @@ -251,6 +260,7 @@ pQueryTxMempoolCmd envCli = ] pLeadershipScheduleCmd :: CardanoEra era -> EnvCli -> Parser (QueryCmds era) pLeadershipScheduleCmd era envCli = + let mw = forEraMaybeEon era in fmap QueryLeadershipScheduleCmd $ QueryLeadershipScheduleCmdArgs <$> pSocketPath envCli @@ -260,28 +270,30 @@ pLeadershipScheduleCmd era envCli = <*> pStakePoolVerificationKeyOrHashOrFile Nothing <*> pVrfSigningKeyFile <*> pWhichLeadershipSchedule - <*> pTarget era + <*> pTarget mw <*> pMaybeOutputFile pKesPeriodInfoCmd :: CardanoEra era -> EnvCli -> Parser (QueryCmds era) pKesPeriodInfoCmd era envCli = + let mw = forEraMaybeEon era in fmap QueryKesPeriodInfoCmd $ QueryKesPeriodInfoCmdArgs <$> pSocketPath envCli <*> pConsensusModeParams <*> pNetworkId envCli <*> pOperationalCertificateFile - <*> pTarget era + <*> pTarget mw <*> pMaybeOutputFile pQuerySlotNumberCmd :: CardanoEra era -> EnvCli -> Parser (QueryCmds era) pQuerySlotNumberCmd era envCli = + let mw = forEraMaybeEon era in fmap QuerySlotNumberCmd $ QuerySlotNumberCmdArgs <$> pSocketPath envCli <*> pConsensusModeParams <*> pNetworkId envCli - <*> pTarget era + <*> pTarget mw <*> pUtcTimestamp where pUtcTimestamp = @@ -335,7 +347,7 @@ pQueryDRepStateCmd era envCli = do <*> pConsensusModeParams <*> pNetworkId envCli <*> pAllOrOnlyDRepVerificationKeyOrHashOrFile - <*> pTargetFromConway w + <*> pTarget (Just w) <*> optional pOutputFile pQueryDRepStakeDistributionCmd :: () @@ -355,7 +367,7 @@ pQueryDRepStakeDistributionCmd era envCli = do <*> pConsensusModeParams <*> pNetworkId envCli <*> pAllOrOnlyDRepVerificationKeyOrHashOrFile - <*> pTargetFromConway w + <*> pTarget (Just w) <*> optional pOutputFile pQueryGetCommitteeStateCmd :: () @@ -377,7 +389,7 @@ pQueryGetCommitteeStateCmd era envCli = do <*> many pCommitteeColdVerificationKeyOrHashOrFile <*> many pCommitteeHotKeyOrHashOrFile <*> many pMemberStatus - <*> pTargetFromConway w + <*> pTarget (Just w) <*> optional pOutputFile pMemberStatus :: Parser MemberStatus @@ -406,5 +418,5 @@ pQueryNoArgCmdArgs w envCli = <$> pSocketPath envCli <*> pConsensusModeParams <*> pNetworkId envCli - <*> pTargetFromConway w + <*> pTarget (Just w) <*> optional pOutputFile From 8f5038474bf3a1d558b064500af117738fc87ab0 Mon Sep 17 00:00:00 2001 From: Pablo Lamela Date: Mon, 12 Feb 2024 15:09:55 +0100 Subject: [PATCH 5/5] Refactor based on review --- .../Cardano/CLI/EraBased/Options/Common.hs | 34 +++++++------ .../src/Cardano/CLI/EraBased/Options/Query.hs | 51 ++++++++----------- 2 files changed, 38 insertions(+), 47 deletions(-) diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Options/Common.hs b/cardano-cli/src/Cardano/CLI/EraBased/Options/Common.hs index f81917a930..a385e41472 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Options/Common.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Options/Common.hs @@ -103,26 +103,28 @@ pNetworkId envCli = asum $ mconcat pure <$> maybeToList (envCliNetworkId envCli) ] -pTarget :: Maybe (ConwayEraOnwards era) -> Parser (Consensus.Target ChainPoint) -pTarget Nothing = pure Consensus.VolatileTip -pTarget (Just ConwayEraOnwardsConway) = - asum $ mconcat - [ [ Opt.flag' Consensus.VolatileTip $ mconcat - [ Opt.long "volatile-tip" - , Opt.help $ mconcat - [ "Use the volatile tip as a target. (This is the default)" +pTarget :: CardanoEra era -> Parser (Consensus.Target ChainPoint) +pTarget = inEonForEra (pure Consensus.VolatileTip) pTargetFromConway + where + pTargetFromConway :: ConwayEraOnwards era -> Parser (Consensus.Target ChainPoint) + pTargetFromConway _ = + asum $ mconcat + [ [ Opt.flag' Consensus.VolatileTip $ mconcat + [ Opt.long "volatile-tip" + , Opt.help $ mconcat + [ "Use the volatile tip as a target. (This is the default)" + ] ] - ] - , Opt.flag' Consensus.ImmutableTip $ mconcat - [ Opt.long "immutable-tip" - , Opt.help $ mconcat - [ "Use the immutable tip as a target." + , Opt.flag' Consensus.ImmutableTip $ mconcat + [ Opt.long "immutable-tip" + , Opt.help $ mconcat + [ "Use the immutable tip as a target." + ] ] ] + , -- Default to volatile tip if not specified + [ pure Consensus.VolatileTip ] ] - , -- Default to volatile tip if not specified - [ pure Consensus.VolatileTip ] - ] toUnitIntervalOrErr :: Rational -> L.UnitInterval toUnitIntervalOrErr r = case Ledger.boundRational r of diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Options/Query.hs b/cardano-cli/src/Cardano/CLI/EraBased/Options/Query.hs index 92852c2748..51a927940a 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Options/Query.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Options/Query.hs @@ -126,81 +126,74 @@ pQueryProtocolParametersCmd envCli = pQueryTipCmd :: CardanoEra era -> EnvCli -> Parser (QueryCmds era) pQueryTipCmd era envCli = - let mw = forEraMaybeEon era in fmap QueryTipCmd $ QueryTipCmdArgs <$> pSocketPath envCli <*> pConsensusModeParams <*> pNetworkId envCli - <*> pTarget mw + <*> pTarget era <*> pMaybeOutputFile pQueryUTxOCmd :: CardanoEra era -> EnvCli -> Parser (QueryCmds era) pQueryUTxOCmd era envCli = - let mw = forEraMaybeEon era in fmap QueryUTxOCmd $ QueryUTxOCmdArgs <$> pSocketPath envCli <*> pConsensusModeParams <*> pQueryUTxOFilter <*> pNetworkId envCli - <*> pTarget mw + <*> pTarget era <*> pMaybeOutputFile pQueryStakePoolsCmd :: CardanoEra era -> EnvCli -> Parser (QueryCmds era) pQueryStakePoolsCmd era envCli = - let mw = forEraMaybeEon era in fmap QueryStakePoolsCmd $ QueryStakePoolsCmdArgs <$> pSocketPath envCli <*> pConsensusModeParams <*> pNetworkId envCli - <*> pTarget mw + <*> pTarget era <*> pMaybeOutputFile pQueryStakeDistributionCmd :: CardanoEra era -> EnvCli -> Parser (QueryCmds era) pQueryStakeDistributionCmd era envCli = - let mw = forEraMaybeEon era in fmap QueryStakeDistributionCmd $ QueryStakeDistributionCmdArgs <$> pSocketPath envCli <*> pConsensusModeParams <*> pNetworkId envCli - <*> pTarget mw + <*> pTarget era <*> pMaybeOutputFile pQueryStakeAddressInfoCmd :: CardanoEra era -> EnvCli -> Parser (QueryCmds era) pQueryStakeAddressInfoCmd era envCli = - let mw = forEraMaybeEon era in fmap QueryStakeAddressInfoCmd $ QueryStakeAddressInfoCmdArgs <$> pSocketPath envCli <*> pConsensusModeParams <*> pFilterByStakeAddress <*> pNetworkId envCli - <*> pTarget mw + <*> pTarget era <*> pMaybeOutputFile pQueryLedgerStateCmd :: CardanoEra era -> EnvCli -> Parser (QueryCmds era) pQueryLedgerStateCmd era envCli = - let mw = forEraMaybeEon era in fmap QueryLedgerStateCmd $ QueryLedgerStateCmdArgs <$> pSocketPath envCli <*> pConsensusModeParams <*> pNetworkId envCli - <*> pTarget mw + <*> pTarget era <*> pMaybeOutputFile pQueryProtocolStateCmd :: CardanoEra era -> EnvCli -> Parser (QueryCmds era) pQueryProtocolStateCmd era envCli = - let mw = forEraMaybeEon era in fmap QueryProtocolStateCmd $ QueryProtocolStateCmdArgs <$> pSocketPath envCli <*> pConsensusModeParams <*> pNetworkId envCli - <*> pTarget mw + <*> pTarget era <*> pMaybeOutputFile pAllStakePoolsOrSome :: Parser (AllOrOnly (Hash StakePoolKey)) @@ -215,26 +208,24 @@ pAllStakePoolsOrSome = pAll <|> pOnly pQueryStakeSnapshotCmd :: CardanoEra era -> EnvCli -> Parser (QueryCmds era) pQueryStakeSnapshotCmd era envCli = - let mw = forEraMaybeEon era in fmap QueryStakeSnapshotCmd $ QueryStakeSnapshotCmdArgs <$> pSocketPath envCli <*> pConsensusModeParams <*> pNetworkId envCli <*> pAllStakePoolsOrSome - <*> pTarget mw + <*> pTarget era <*> pMaybeOutputFile pQueryPoolStateCmd :: CardanoEra era -> EnvCli -> Parser (QueryCmds era) pQueryPoolStateCmd era envCli = - let mw = forEraMaybeEon era in fmap QueryPoolStateCmd $ QueryPoolStateCmdArgs <$> pSocketPath envCli <*> pConsensusModeParams <*> pNetworkId envCli <*> pAllStakePoolsOrSome - <*> pTarget mw + <*> pTarget era pQueryTxMempoolCmd :: EnvCli -> Parser (QueryCmds era) pQueryTxMempoolCmd envCli = @@ -260,7 +251,6 @@ pQueryTxMempoolCmd envCli = ] pLeadershipScheduleCmd :: CardanoEra era -> EnvCli -> Parser (QueryCmds era) pLeadershipScheduleCmd era envCli = - let mw = forEraMaybeEon era in fmap QueryLeadershipScheduleCmd $ QueryLeadershipScheduleCmdArgs <$> pSocketPath envCli @@ -270,30 +260,28 @@ pLeadershipScheduleCmd era envCli = <*> pStakePoolVerificationKeyOrHashOrFile Nothing <*> pVrfSigningKeyFile <*> pWhichLeadershipSchedule - <*> pTarget mw + <*> pTarget era <*> pMaybeOutputFile pKesPeriodInfoCmd :: CardanoEra era -> EnvCli -> Parser (QueryCmds era) pKesPeriodInfoCmd era envCli = - let mw = forEraMaybeEon era in fmap QueryKesPeriodInfoCmd $ QueryKesPeriodInfoCmdArgs <$> pSocketPath envCli <*> pConsensusModeParams <*> pNetworkId envCli <*> pOperationalCertificateFile - <*> pTarget mw + <*> pTarget era <*> pMaybeOutputFile pQuerySlotNumberCmd :: CardanoEra era -> EnvCli -> Parser (QueryCmds era) pQuerySlotNumberCmd era envCli = - let mw = forEraMaybeEon era in fmap QuerySlotNumberCmd $ QuerySlotNumberCmdArgs <$> pSocketPath envCli <*> pConsensusModeParams <*> pNetworkId envCli - <*> pTarget mw + <*> pTarget era <*> pUtcTimestamp where pUtcTimestamp = @@ -310,7 +298,7 @@ pQueryGetConstitutionCmd era envCli = do w <- forEraMaybeEon era pure $ subParser "constitution" - $ Opt.info (QueryConstitutionCmd <$> pQueryNoArgCmdArgs w envCli) + $ Opt.info (QueryConstitutionCmd <$> pQueryNoArgCmdArgs w era envCli) $ Opt.progDesc "Get the constitution" pQueryGetGovStateCmd :: () @@ -321,7 +309,7 @@ pQueryGetGovStateCmd era envCli = do w <- forEraMaybeEon era pure $ subParser "gov-state" - $ Opt.info (QueryGovStateCmd <$> pQueryNoArgCmdArgs w envCli) + $ Opt.info (QueryGovStateCmd <$> pQueryNoArgCmdArgs w era envCli) $ Opt.progDesc "Get the governance state" -- TODO Conway: DRep State and DRep Stake Distribution parsers use DRep keys to obtain DRep credentials. This only @@ -347,7 +335,7 @@ pQueryDRepStateCmd era envCli = do <*> pConsensusModeParams <*> pNetworkId envCli <*> pAllOrOnlyDRepVerificationKeyOrHashOrFile - <*> pTarget (Just w) + <*> pTarget era <*> optional pOutputFile pQueryDRepStakeDistributionCmd :: () @@ -367,7 +355,7 @@ pQueryDRepStakeDistributionCmd era envCli = do <*> pConsensusModeParams <*> pNetworkId envCli <*> pAllOrOnlyDRepVerificationKeyOrHashOrFile - <*> pTarget (Just w) + <*> pTarget era <*> optional pOutputFile pQueryGetCommitteeStateCmd :: () @@ -389,7 +377,7 @@ pQueryGetCommitteeStateCmd era envCli = do <*> many pCommitteeColdVerificationKeyOrHashOrFile <*> many pCommitteeHotKeyOrHashOrFile <*> many pMemberStatus - <*> pTarget (Just w) + <*> pTarget era <*> optional pOutputFile pMemberStatus :: Parser MemberStatus @@ -411,12 +399,13 @@ pQueryGetCommitteeStateCmd era envCli = do pQueryNoArgCmdArgs :: () => ConwayEraOnwards era + -> CardanoEra era -> EnvCli -> Parser (QueryNoArgCmdArgs era) -pQueryNoArgCmdArgs w envCli = +pQueryNoArgCmdArgs w era envCli = QueryNoArgCmdArgs w <$> pSocketPath envCli <*> pConsensusModeParams <*> pNetworkId envCli - <*> pTarget (Just w) + <*> pTarget era <*> optional pOutputFile