Skip to content

Commit

Permalink
wip - Replace queryCommitteState with new queryCommitteeMembersState
Browse files Browse the repository at this point in the history
  • Loading branch information
teodanciu committed Oct 19, 2023
1 parent beb07ad commit 5749dfd
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 9 deletions.
13 changes: 12 additions & 1 deletion cardano-cli/src/Cardano/CLI/EraBased/Commands/Query.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

module Cardano.CLI.EraBased.Commands.Query
( QueryCmds (..)
, QueryCommitteeStateCmdArgs(..)
, QueryLeadershipScheduleCmdArgs(..)
, QueryProtocolParametersCmdArgs(..)
, QueryConstitutionHashCmdArgs(..)
Expand Down Expand Up @@ -55,7 +56,7 @@ data QueryCmds era
| QueryGovStateCmd !(QueryNoArgCmdArgs era)
| QueryDRepStateCmd !(QueryDRepStateCmdArgs era)
| QueryDRepStakeDistributionCmd !(QueryDRepStakeDistributionCmdArgs era)
| QueryCommitteeStateCmd !(QueryNoArgCmdArgs era)
| QueryCommitteeStateCmd !(QueryCommitteeStateCmdArgs era)
deriving (Generic, Show)

data QueryLeadershipScheduleCmdArgs = QueryLeadershipScheduleCmdArgs
Expand Down Expand Up @@ -199,6 +200,16 @@ data QueryDRepStakeDistributionCmdArgs era = QueryDRepStakeDistributionCmdArgs
, mOutFile :: !(Maybe (File () Out))
} deriving Show

data QueryCommitteeStateCmdArgs era = QueryCommitteeStateCmdArgs
{ eon :: !(ConwayEraOnwards era)
, nodeSocketPath :: !SocketPath
, consensusModeParams :: !AnyConsensusModeParams
, networkId :: !NetworkId
, committeeColdVerKeyFile :: ![VerificationKeyOrHashOrFile CommitteeColdKey]
, committeeHotVerKeyFile :: ![VerificationKeyOrHashOrFile CommitteeHotKey]
, mOutFile :: !(Maybe (File () Out))
} deriving Show

renderQueryCmds :: QueryCmds era -> Text
renderQueryCmds = \case
QueryLeadershipScheduleCmd {} ->
Expand Down
12 changes: 11 additions & 1 deletion cardano-cli/src/Cardano/CLI/EraBased/Options/Query.hs
Original file line number Diff line number Diff line change
Expand Up @@ -351,8 +351,18 @@ pQueryGetCommitteeStateCmd era envCli = do
w <- forEraMaybeEon era
pure
$ subParser "committee-state"
$ Opt.info (QueryCommitteeStateCmd <$> pQueryNoArgCmdArgs w envCli)
$ Opt.info (QueryCommitteeStateCmd <$> pQueryCommitteeStateArgs w)
$ Opt.progDesc "Get the committee state"
where
pQueryCommitteeStateArgs :: ConwayEraOnwards era -> Parser (QueryCommitteeStateCmdArgs era)
pQueryCommitteeStateArgs w = QueryCommitteeStateCmdArgs w
<$> pSocketPath envCli
<*> pConsensusModeParams
<*> pNetworkId envCli
<*> many pCommitteeColdVerificationKeyOrHashOrFile
<*> many pCommitteeHotKeyOrHashOrFile
<*> optional pOutputFile


pQueryNoArgCmdArgs :: ()
=> ConwayEraOnwards era
Expand Down
14 changes: 7 additions & 7 deletions cardano-cli/src/Cardano/CLI/EraBased/Run/Query.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1541,17 +1541,18 @@ runQueryDRepStakeDistribution
Map.assocs drepStakeDistribution

runQueryCommitteeState
:: Cmd.QueryNoArgCmdArgs era
:: Cmd.QueryCommitteeStateCmdArgs era
-> ExceptT QueryCmdError IO ()
runQueryCommitteeState
Cmd.QueryNoArgCmdArgs
Cmd.QueryCommitteeStateCmdArgs
{ Cmd.eon
, Cmd.nodeSocketPath
, Cmd.consensusModeParams = AnyConsensusModeParams cModeParams
, Cmd.networkId
, Cmd.mOutFile
}
= conwayEraOnwardsConstraints eon $ do
-- , Cmd.committeeColdVerKeyFile -- = coldCredKeys
-- , Cmd.committeeHotVerKeyFile
} = conwayEraOnwardsConstraints eon $ do
let localNodeConnInfo = LocalNodeConnectInfo cModeParams networkId nodeSocketPath
sbe = conwayEraOnwardsToShelleyBasedEra eon
cEra = conwayEraOnwardsToCardanoEra eon
Expand All @@ -1560,9 +1561,8 @@ runQueryCommitteeState
eraInMode <- toEraInMode cEra cMode
& hoistMaybe (QueryCmdEraConsensusModeMismatch (AnyConsensusMode cMode) (AnyCardanoEra cEra))

committeeState <- runQuery localNodeConnInfo $ queryCommitteeState eraInMode sbe
writeOutput mOutFile $
Map.assocs $ committeeState ^. Ledger.csCommitteeCredsL
committeeState <- runQuery localNodeConnInfo $ queryCommitteeMembersState eraInMode sbe Set.empty Set.empty Set.empty
writeOutput mOutFile committeeState

runQuery :: LocalNodeConnectInfo mode
-> LocalStateQueryExpr
Expand Down
14 changes: 14 additions & 0 deletions cardano-cli/src/Cardano/CLI/Read.hs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ module Cardano.CLI.Read
-- * DRep credentials
, getDRepCredentialFromVerKeyHashOrFile

-- * Committee credentials
, getCommitteeColdCredentialFromVerKeyHashOrFile
, getCommitteeHotCredentialFromVerKeyHashOrFile

, ReadSafeHashError(..)
, readHexAsSafeHash
, readSafeHash
Expand Down Expand Up @@ -1020,6 +1024,16 @@ getDRepCredentialFromVerKeyHashOrFile = \case
pure . Ledger.KeyHashObj . unDRepKeyHash $ verificationKeyHash drepVerKey
VerificationKeyHash kh -> pure . Ledger.KeyHashObj $ unDRepKeyHash kh

getCommitteeColdCredentialFromVerKeyHashOrFile :: ()
=> VerificationKeyOrHashOrFile CommitteeColdKey
-> ExceptT (FileError InputDecodeError) IO (Ledger.Credential Ledger.ColdCommitteeRole Ledger.StandardCrypto)
getCommitteeColdCredentialFromVerKeyHashOrFile = undefined

getCommitteeHotCredentialFromVerKeyHashOrFile :: ()
=> VerificationKeyOrHashOrFile CommitteeHotKey
-> ExceptT (FileError InputDecodeError) IO (Ledger.Credential Ledger.HotCommitteeRole Ledger.StandardCrypto)
getCommitteeHotCredentialFromVerKeyHashOrFile = undefined

data ReadSafeHashError
= ReadSafeHashErrorNotHex ByteString String
| ReadSafeHashErrorInvalidHash Text
Expand Down

0 comments on commit 5749dfd

Please sign in to comment.