Skip to content
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

Integrate latest ledger, consensus and api for 8.6.0 #385

Merged
merged 11 commits into from
Oct 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ repository cardano-haskell-packages
-- you need to run if you change them
index-state:
, hackage.haskell.org 2023-08-08T19:56:09Z
, cardano-haskell-packages 2023-10-20T00:31:44Z
, cardano-haskell-packages 2023-10-27T12:25:48Z

packages:
cardano-cli
Expand Down
20 changes: 10 additions & 10 deletions cardano-cli/cardano-cli.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -203,19 +203,19 @@ library
, binary
, bytestring
, canonical-json
, cardano-api ^>= 8.28.0.0
, cardano-api ^>= 8.29.0.0
, cardano-binary
, cardano-crypto
, cardano-crypto-class ^>= 2.1.2
, cardano-crypto-wrapper ^>= 1.5.1
, cardano-data >= 1.0
, cardano-data >= 1.1
, cardano-git-rev
, cardano-ledger-alonzo >= 1.3.1.1
, cardano-ledger-binary >= 1.0
, cardano-ledger-alonzo >= 1.5.0.0
, cardano-ledger-binary >= 1.2
, cardano-ledger-byron >= 1.0.0.2
, cardano-ledger-conway >= 1.5
, cardano-ledger-core >= 1.2
, cardano-ledger-shelley >=1.4.1.0
, cardano-ledger-conway >= 1.10
, cardano-ledger-core >= 1.8
, cardano-ledger-shelley >=1.7.0.0
, cardano-ping ^>= 0.2.0.5
, cardano-prelude
, cardano-slotting ^>= 0.1
Expand All @@ -234,9 +234,9 @@ library
, microlens
, network
, optparse-applicative-fork
, ouroboros-consensus >= 0.12
, ouroboros-consensus-cardano >= 0.10
, ouroboros-consensus-protocol >= 0.5.0.4
, ouroboros-consensus >= 0.13
, ouroboros-consensus-cardano >= 0.11
, ouroboros-consensus-protocol >= 0.6.0.0
, ouroboros-network-api
, ouroboros-network-protocols
, parsec
Expand Down
12 changes: 4 additions & 8 deletions cardano-cli/src/Cardano/CLI/Byron/Tx.hs
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,8 @@ txSpendGenesisUTxOByronPBFT gc nId sk (ByronAddress bAddr) outs = do
, txTotalCollateral = TxTotalCollateralNone
, txReturnCollateral = TxReturnCollateralNone
, txFee = TxFeeImplicit ByronEraOnlyByron
, txValidityRange =
( TxValidityNoLowerBound
, defaultTxValidityUpperBound ByronEra
)
, txValidityLowerBound = TxValidityNoLowerBound
, txValidityUpperBound = defaultTxValidityUpperBound ByronEra
, txMetadata = TxMetadataNone
, txAuxScripts = TxAuxScriptsNone
, txExtraKeyWits = TxExtraKeyWitnessesNone
Expand Down Expand Up @@ -207,10 +205,8 @@ txSpendUTxOByronPBFT nId sk txIns outs = do
, txTotalCollateral = TxTotalCollateralNone
, txReturnCollateral = TxReturnCollateralNone
, txFee = TxFeeImplicit ByronEraOnlyByron
, txValidityRange =
( TxValidityNoLowerBound
, defaultTxValidityUpperBound ByronEra
)
, txValidityLowerBound = TxValidityNoLowerBound
, txValidityUpperBound = defaultTxValidityUpperBound ByronEra
, txMetadata = TxMetadataNone
, txAuxScripts = TxAuxScriptsNone
, txExtraKeyWits = TxExtraKeyWitnessesNone
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ module Cardano.CLI.EraBased.Commands.Governance.Committee
) where

import Cardano.Api
import qualified Cardano.Api.Ledger as Ledger
import Cardano.Api.Shelley

import Cardano.CLI.Types.Key
import Cardano.CLI.Types.Key.VerificationKey
Expand Down Expand Up @@ -59,6 +61,7 @@ data GovernanceCommitteeCreateColdKeyResignationCertificateCmdArgs era =
GovernanceCommitteeCreateColdKeyResignationCertificateCmdArgs
{ eon :: !(ConwayEraOnwards era)
, vkeyColdKeySource :: !(VerificationKeyOrHashOrFile CommitteeColdKey)
, anchor :: !(Maybe (Ledger.Anchor (Ledger.EraCrypto (ShelleyLedgerEra era))))
Copy link
Contributor

@Jimbo4350 Jimbo4350 Oct 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have a look at how the governance action parsers handle anchors. E.g

data GovernanceActionCreateNoConfidenceCmdArgs era
  = GovernanceActionCreateNoConfidenceCmdArgs
      { eon                   :: !(ConwayEraOnwards era)
      , networkId             :: !Ledger.Network
      , deposit               :: !Lovelace
      , returnStakeAddress    :: !AnyStakeIdentifier
      , proposalUrl           :: !ProposalUrl
      , proposalHashSource    :: !ProposalHashSource
      , governanceActionId    :: !TxId
      , governanceActionIndex :: !Word32
      , outFile               :: !(File () Out)
      } deriving Show

In particular the proposalUrl and proposalHashSource fields.

Copy link
Contributor Author

@teodanciu teodanciu Oct 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Jimbo4350 So you prefer to flatten these two fields , url and hash.
But what to do about ProposalUrl and ProposalHashSource which are not accurately describing this Anchor, no - since it's not related to proposal, but to resignation.. Create new types for them?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, I don't understand exactly what the suggestion is (probably because I'm not familiar with the codebase).
Would you like me to represent Anchor in GovernanceCommitteeCreateColdKeyResignationCertificateCmdArgs as two different fields, similar to the example you gave above, so as :

   ,    resignationlUrl           :: !ProposalUrl
      , resignationHashSource    :: !ProposalHashSource

instead of the field that I have added:

, anchor            :: !(Maybe (Ledger.Anchor (Ledger.EraCrypto (ShelleyLedgerEra era))))

?

Did i understand correctly?

Copy link
Contributor

@Jimbo4350 Jimbo4350 Oct 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes exactly 👍 I see what you're saying now.

Copy link
Contributor Author

@teodanciu teodanciu Oct 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both of them will have to be Maybe I suppose, since the field is optional. I hope it won't be too messy, if say one is there and the other one not 🤔

, outFile :: !(File () Out)
} deriving Show

Expand Down
16 changes: 14 additions & 2 deletions 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 (..)
, QueryCommitteeMembersStateCmdArgs(..)
, 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)
| QueryCommitteeMembersStateCmd !(QueryCommitteeMembersStateCmdArgs era)
deriving (Generic, Show)

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

data QueryCommitteeMembersStateCmdArgs era = QueryCommitteeMembersStateCmdArgs
{ eon :: !(ConwayEraOnwards era)
, nodeSocketPath :: !SocketPath
, consensusModeParams :: !AnyConsensusModeParams
, networkId :: !NetworkId
, committeeColdKeys :: ![VerificationKeyOrHashOrFile CommitteeColdKey]
, committeeHotKeys :: ![VerificationKeyOrHashOrFile CommitteeHotKey]
, memberStatuses :: ![MemberStatus]
, mOutFile :: !(Maybe (File () Out))
} deriving Show

renderQueryCmds :: QueryCmds era -> Text
renderQueryCmds = \case
QueryLeadershipScheduleCmd {} ->
Expand Down Expand Up @@ -239,7 +251,7 @@ renderQueryCmds = \case
"drep-state"
QueryDRepStakeDistributionCmd {} ->
"drep-stake-distribution"
QueryCommitteeStateCmd {} ->
QueryCommitteeMembersStateCmd {} ->
"committee-state"

renderTxMempoolQuery :: TxMempoolQuery -> Text
Expand Down
4 changes: 2 additions & 2 deletions cardano-cli/src/Cardano/CLI/EraBased/Commands/Transaction.hs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ data TransactionBuildRawCmdArgs era = TransactionBuildRawCmdArgs
-- ^ Multi-Asset value with script witness
, mValidityLowerBound :: !(Maybe SlotNo)
-- ^ Transaction validity lower bound
, mValidityUpperBound :: !(Maybe SlotNo)
, mValidityUpperBound :: !(TxValidityUpperBound era)
-- ^ Transaction validity upper bound
, fee :: !(Maybe Lovelace)
-- ^ Transaction fee
Expand Down Expand Up @@ -110,7 +110,7 @@ data TransactionBuildCmdArgs era = TransactionBuildCmdArgs
-- ^ Multi-Asset value with script witness
, mValidityLowerBound :: !(Maybe SlotNo)
-- ^ Transaction validity lower bound
, mValidityUpperBound :: !(Maybe SlotNo)
, mValidityUpperBound :: !(TxValidityUpperBound era)
-- ^ Transaction validity upper bound
, certificates :: ![(CertificateFile, Maybe (ScriptWitnessFiles WitCtxStake))]
-- ^ Certificates with potential script witness
Expand Down
75 changes: 53 additions & 22 deletions cardano-cli/src/Cardano/CLI/EraBased/Options/Common.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2077,30 +2077,62 @@ pInvalidBefore = fmap SlotNo $ asum
]
]

pInvalidHereafter :: Parser SlotNo
pInvalidHereafter =
pLegacyInvalidHereafter :: Parser SlotNo
Copy link
Contributor

@newhoggy newhoggy Oct 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But we also have legacy commands that don't understand eras the same way. In the legacy era, options are always there regardless of era and these need validation. This is why these parse plain types, not era sensitive types.

This means we may receive values from the CLI parser that are invalid for our era and hence we need validation.

See 85f657b#r1374853935

pLegacyInvalidHereafter =
fmap SlotNo $ asum
[ Opt.option (bounded "SLOT") $ mconcat
[ Opt.long "invalid-hereafter"
, Opt.metavar "SLOT"
, Opt.help "Time that transaction is valid until (in slots)."
]
, Opt.option (bounded "SLOT") $ mconcat
[ Opt.long "upper-bound"
, Opt.metavar "SLOT"
, Opt.help $ mconcat
[ "Time that transaction is valid until (in slots) "
, "(deprecated; use --invalid-hereafter instead)."
[ Opt.option (bounded "SLOT") $ mconcat
[ Opt.long "invalid-hereafter"
, Opt.metavar "SLOT"
, Opt.help "Time that transaction is valid until (in slots)."
]
, Opt.option (bounded "SLOT") $ mconcat
[ Opt.long "upper-bound"
, Opt.metavar "SLOT"
, Opt.help $ mconcat
[ "Time that transaction is valid until (in slots) "
, "(deprecated; use --invalid-hereafter instead)."
]
, Opt.internal
]
, Opt.option (bounded "SLOT") $ mconcat
[ Opt.long "ttl"
, Opt.metavar "SLOT"
, Opt.help "Time to live (in slots) (deprecated; use --invalid-hereafter instead)."
, Opt.internal
]
, Opt.internal
]
, Opt.option (bounded "SLOT") $ mconcat
[ Opt.long "ttl"
, Opt.metavar "SLOT"
, Opt.help "Time to live (in slots) (deprecated; use --invalid-hereafter instead)."
, Opt.internal
]
]

pInvalidHereafter :: ()
=> CardanoEra era
-> Parser (TxValidityUpperBound era)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In era-based commands we want to bring the era-sensitive types closer to the CLI.

This means we parse TxValidityUpperBound era instead of Maybe SlotNo.

This allows the parser to determine if the options are valid for the given era.

For example pInvalidHereafter will add these options only in a Shelley based eras and will be absent for the Byron era.

In the Byron era, TxValidityNoUpperBound always returned and there are no options for it.

pInvalidHereafter =
caseByronOrShelleyBasedEra
(pure . TxValidityNoUpperBound)
(\eon ->
fmap (TxValidityUpperBound eon) $ asum
[ fmap (Just . SlotNo) $ Opt.option (bounded "SLOT") $ mconcat
[ Opt.long "invalid-hereafter"
, Opt.metavar "SLOT"
, Opt.help "Time that transaction is valid until (in slots)."
]
, fmap (Just . SlotNo) $ Opt.option (bounded "SLOT") $ mconcat
[ Opt.long "upper-bound"
, Opt.metavar "SLOT"
, Opt.help $ mconcat
[ "Time that transaction is valid until (in slots) "
, "(deprecated; use --invalid-hereafter instead)."
]
, Opt.internal
]
, fmap (Just . SlotNo) $ Opt.option (bounded "SLOT") $ mconcat
[ Opt.long "ttl"
, Opt.metavar "SLOT"
, Opt.help "Time to live (in slots) (deprecated; use --invalid-hereafter instead)."
, Opt.internal
]
, pure Nothing
]
)

pTxFee :: Parser Lovelace
pTxFee =
Expand Down Expand Up @@ -2560,7 +2592,6 @@ pProtocolParametersUpdate =
<*> optional pPoolInfluence
<*> optional pMonetaryExpansion
<*> optional pTreasuryExpansion
<*> pure Nothing
<*> pure mempty
<*> optional pExecutionUnitPrices
<*> optional pMaxTxExecutionUnits
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,9 +256,9 @@ pDeprecatedAfterMaryPParams =
DeprecatedAfterMaryPParams
<$> convertToLedger toShelleyLovelace (optional pMinUTxOValue)

pShelleyToAlonzoPParams :: Parser (ShelleyToAlonzoPParams' ledgerera)
pShelleyToAlonzoPParams :: Parser (ShelleyToAlonzoPParams ledgerera)
pShelleyToAlonzoPParams =
ShelleyToAlonzoPParams'
ShelleyToAlonzoPParams
<$> convertToLedger id (optional $ toLedgerNonce <$> pExtraEntropy)
<*> convertToLedger toUnitIntervalOrErr (optional pDecentralParam)

Expand Down Expand Up @@ -318,7 +318,6 @@ dpGovActionProtocolParametersUpdate = \case
<$> pCommonProtocolParameters
<*> pShelleyToAlonzoPParams
<*> pAlonzoOnwardsPParams
<*> pure (ShelleyToAlonzoPParams SNothing)
ShelleyBasedEraBabbage ->
BabbageEraBasedProtocolParametersUpdate
<$> pCommonProtocolParameters
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeFamilies #-}

module Cardano.CLI.EraBased.Options.Governance.Committee
( pGovernanceCommitteeCmds
Expand All @@ -8,6 +9,10 @@ import Cardano.Api

import Cardano.CLI.EraBased.Commands.Governance.Committee
import Cardano.CLI.EraBased.Options.Common
import Cardano.CLI.Read
import qualified Cardano.Ledger.BaseTypes as L
import qualified Cardano.Ledger.Crypto as Crypto
import qualified Cardano.Ledger.SafeHash as L

import Options.Applicative (Parser)
import qualified Options.Applicative as Opt
Expand Down Expand Up @@ -116,13 +121,36 @@ pGovernanceCommitteeCreateColdKeyResignationCertificateCmd era = do
w <- forEraMaybeEon era
pure
$ subParser "create-cold-key-resignation-certificate"
$ Opt.info
( fmap GovernanceCommitteeCreateColdKeyResignationCertificateCmd $
GovernanceCommitteeCreateColdKeyResignationCertificateCmdArgs w
<$> pCommitteeColdVerificationKeyOrHashOrFile
<*> pOutputFile
)
$ Opt.info (conwayEraOnwardsConstraints w $ mkParser w)
$ Opt.progDesc
$ mconcat
[ "Create cold key resignation certificate for a Constitutional Committee Member"
]
where
mkParser w = GovernanceCommitteeCreateColdKeyResignationCertificateCmd <$>
(
GovernanceCommitteeCreateColdKeyResignationCertificateCmdArgs w <$>
pCommitteeColdVerificationKeyOrHashOrFile <*>
pAnchor <*>
pOutputFile
)

pAnchor :: Parser (Maybe (L.Anchor Crypto.StandardCrypto))
pAnchor =
Opt.optional $
L.Anchor
<$> fmap unAnchorUrl pAnchorUrl
<*> pSafeHash

pAnchorUrl :: Parser AnchorUrl
pAnchorUrl =
AnchorUrl
<$> pUrl "resignation-metadata-url" "Constitutional Committee cold key resignation certificate URL"

pSafeHash :: Parser (L.SafeHash Crypto.StandardCrypto L.AnchorData)
pSafeHash =
Opt.option readSafeHash $ mconcat
[ Opt.long "resignation-metadata-hash"
, Opt.metavar "HASH"
, Opt.help "Constitutional Committee cold key resignation certificate metadata hash"
]
30 changes: 29 additions & 1 deletion cardano-cli/src/Cardano/CLI/EraBased/Options/Query.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ module Cardano.CLI.EraBased.Options.Query
) where

import Cardano.Api hiding (QueryInShelleyBasedEra (..))
import qualified Cardano.Api as MemberStatus (MemberStatus (..))
import Cardano.Api.Shelley hiding (QueryInShelleyBasedEra (..))

import Cardano.CLI.Environment (EnvCli (..))
Expand Down Expand Up @@ -351,8 +352,35 @@ pQueryGetCommitteeStateCmd era envCli = do
w <- forEraMaybeEon era
pure
$ subParser "committee-state"
$ Opt.info (QueryCommitteeStateCmd <$> pQueryNoArgCmdArgs w envCli)
$ Opt.info (QueryCommitteeMembersStateCmd <$> pQueryCommitteeMembersStateArgs w)
$ Opt.progDesc "Get the committee state"
where
pQueryCommitteeMembersStateArgs :: ConwayEraOnwards era -> Parser (QueryCommitteeMembersStateCmdArgs era)
pQueryCommitteeMembersStateArgs w = QueryCommitteeMembersStateCmdArgs w
<$> pSocketPath envCli
<*> pConsensusModeParams
<*> pNetworkId envCli
<*> many pCommitteeColdVerificationKeyOrHashOrFile
<*> many pCommitteeHotKeyOrHashOrFile
<*> many pMemberStatus
<*> optional pOutputFile

pMemberStatus :: Parser MemberStatus
pMemberStatus =
asum
[ Opt.flag' MemberStatus.Active $ mconcat
[ Opt.long "active"
, Opt.help "Active committee members (members whose vote will count during ratification)"
]
, Opt.flag' MemberStatus.Expired $ mconcat
[ Opt.long "expired"
, Opt.help "Expired committee members"
]
, Opt.flag' MemberStatus.Unrecognized $ mconcat
[ Opt.long "unrecognized"
, Opt.help "Unrecognized committe members: a hot credential for an unknown cold credential"
]
]

pQueryNoArgCmdArgs :: ()
=> ConwayEraOnwards era
Expand Down
Loading