Skip to content

Commit

Permalink
Update to cardano-api-8.10.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
newhoggy committed Jul 28, 2023
1 parent 2addf31 commit c7cf08c
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 86 deletions.
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-07-27T22:41:49Z
, cardano-haskell-packages 2023-07-27T06:35:34Z
, cardano-haskell-packages 2023-07-27T18:37:22Z

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 @@ -116,19 +116,19 @@ library
, binary
, bytestring
, canonical-json
, cardano-api ^>= 8.10.1
, cardano-api ^>= 8.10.2
, cardano-binary
, cardano-crypto
, cardano-crypto-class >= 2.1.1
, cardano-crypto-wrapper ^>= 1.5
, cardano-data >= 1.0
, cardano-git-rev
, cardano-ledger-alonzo >= 1.1.1
, cardano-ledger-byron >= 1.0
, cardano-ledger-alonzo >= 1.3.1.1
, cardano-ledger-byron >= 1.0.0.2
, cardano-ledger-binary >= 1.0
, cardano-ledger-core >= 1.2
, cardano-ledger-conway >= 1.1
, cardano-ledger-shelley >= 1.1.1
, cardano-ledger-conway >= 1.5
, cardano-ledger-shelley >=1.4.1.0
, cardano-ping ^>= 0.2.0.5
, cardano-prelude
, cardano-protocol-tpraos >= 1.0
Expand All @@ -150,7 +150,7 @@ library
, optparse-applicative-fork
, ouroboros-consensus >= 0.9
, ouroboros-consensus-cardano >= 0.7
, ouroboros-consensus-protocol >= 0.5
, ouroboros-consensus-protocol >= 0.5.0.4
, ouroboros-network-api
, ouroboros-network-protocols
, parsec
Expand Down Expand Up @@ -203,8 +203,8 @@ test-suite cardano-cli-test
, base16-bytestring
, bech32 >= 1.1.0
, bytestring
, cardano-api ^>= 8.10.1
, cardano-api:internal ^>= 8.10.1
, cardano-api ^>= 8.10.2
, cardano-api:internal ^>= 8.10.2
, cardano-api-gen ^>= 8.1.1.0
, cardano-cli
, cardano-cli:cardano-cli-test-lib
Expand Down Expand Up @@ -247,12 +247,12 @@ test-suite cardano-cli-golden
build-depends: aeson >= 1.5.6.0
, base16-bytestring
, bytestring
, cardano-api ^>= 8.10.1
, cardano-api ^>= 8.10.2
, cardano-cli
, cardano-cli:cardano-cli-test-lib
, cardano-crypto-class ^>= 2.1
, cardano-crypto-wrapper ^>= 1.5.1
, cardano-ledger-byron ^>= 1.0
, cardano-ledger-byron ^>= 1.0.0.2
, cborg
, containers
, filepath
Expand Down
4 changes: 3 additions & 1 deletion cardano-cli/src/Cardano/CLI/EraBased/Run/Governance.hs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ runGovernanceMIRCertificatePayStakeAddrs w mirPot sAddrs rwdAmts oFp = do
$ Map.fromList [ (toShelleyStakeCredential scred, Ledger.toDeltaCoin (toShelleyLovelace rwdAmt))
| (scred, rwdAmt) <- zip sCreds rwdAmts
]
let mirCert = makeMIRCertificate $ MirCertificateRequirements w mirPot $ shelleyToBabbageEraConstraints w mirTarget
let mirCert = makeMIRCertificate
$ MirCertificateRequirements w mirPot
$ shelleyToBabbageEraConstraints w mirTarget

firstExceptT GovernanceCmdTextEnvWriteError
. newExceptT
Expand Down
19 changes: 9 additions & 10 deletions cardano-cli/src/Cardano/CLI/Json/Friendly.hs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ import qualified Cardano.Api.Ledger as Ledger
import Cardano.Api.Shelley (Address (ShelleyAddress), Hash (..),
KeyWitness (ShelleyBootstrapWitness, ShelleyKeyWitness), ShelleyLedgerEra,
StakeAddress (..), fromShelleyPaymentCredential, fromShelleyStakeReference,
obtainCryptoConstraints, obtainEraCryptoConstraints, toShelleyLovelace,
toShelleyStakeCredential)
toShelleyLovelace, toShelleyStakeCredential)

import qualified Cardano.Ledger.Credential as Shelley
import qualified Cardano.Ledger.Shelley.API as Shelley
Expand Down Expand Up @@ -311,17 +310,17 @@ stakeCredJson
:: ShelleyBasedEra era
-> Shelley.StakeCredential (Ledger.EraCrypto (ShelleyLedgerEra era))
-> Aeson.Value
stakeCredJson sbe c = obtainCryptoConstraints sbe $ toJSON c
stakeCredJson sbe c = shelleyBasedEraConstraints sbe $ toJSON c

poolIdJson
:: ShelleyBasedEra era
-> Ledger.KeyHash Ledger.StakePool (Ledger.EraCrypto (ShelleyLedgerEra era))
-> Aeson.Value
poolIdJson sbe pId = obtainCryptoConstraints sbe $ toJSON pId
poolIdJson sbe pId = shelleyBasedEraConstraints sbe $ toJSON pId

poolParamsJson
:: ShelleyBasedEra era -> Shelley.PoolParams (Ledger.EraCrypto (ShelleyLedgerEra era)) -> Aeson.Value
poolParamsJson sbe pp = obtainCryptoConstraints sbe $ toJSON pp
poolParamsJson sbe pp = shelleyBasedEraConstraints sbe $ toJSON pp


friendlyCertificate :: ShelleyBasedEra era -> Certificate era -> Aeson.Value
Expand All @@ -339,18 +338,18 @@ friendlyCertificate sbe =
, "pool" .= poolIdJson sbe poolId
]
ShelleyRelatedCertificate _ (Ledger.ShelleyTxCertPool (Ledger.RetirePool poolId retirementEpoch)) ->
"stake pool retirement" .= object ["pool" .= StakePoolKeyHash (obtainEraCryptoConstraints sbe poolId), "epoch" .= retirementEpoch]
"stake pool retirement" .= object ["pool" .= StakePoolKeyHash (shelleyBasedEraConstraints sbe poolId), "epoch" .= retirementEpoch]

ShelleyRelatedCertificate _ (Ledger.ShelleyTxCertPool (Ledger.RegPool poolParams)) ->
"stake pool registration" .= poolParamsJson sbe poolParams
ShelleyRelatedCertificate _ (Ledger.ShelleyTxCertGenesisDeleg (Ledger.GenesisDelegCert genesisKeyHash delegateKeyHash vrfKeyHash)) ->
"genesis key delegation"
.= object
[ "genesis key hash"
.= serialiseToRawBytesHexText (GenesisKeyHash $ obtainEraCryptoConstraints sbe genesisKeyHash),
.= serialiseToRawBytesHexText (GenesisKeyHash $ shelleyBasedEraConstraints sbe genesisKeyHash),
"delegate key hash"
.= serialiseToRawBytesHexText (GenesisDelegateKeyHash $ obtainEraCryptoConstraints sbe delegateKeyHash),
"VRF key hash" .= serialiseToRawBytesHexText (VrfKeyHash $ obtainEraCryptoConstraints sbe vrfKeyHash)
.= serialiseToRawBytesHexText (GenesisDelegateKeyHash $ shelleyBasedEraConstraints sbe delegateKeyHash),
"VRF key hash" .= serialiseToRawBytesHexText (VrfKeyHash $ shelleyBasedEraConstraints sbe vrfKeyHash)
]
ShelleyRelatedCertificate _ (Ledger.ShelleyTxCertMir (Ledger.MIRCert pot target)) ->
"MIR" .= object ["pot" .= friendlyMirPot pot, friendlyMirTarget sbe target]
Expand Down Expand Up @@ -379,7 +378,7 @@ friendlyMirTarget sbe = \case
[ friendlyStakeCredential credential
, "amount" .= friendlyLovelace (toShelleyLovelace (Lovelace 0) `Ledger.addDeltaCoin` lovelace)
]
| (credential, lovelace) <- Map.toList (obtainEraCryptoConstraints sbe addresses)
| (credential, lovelace) <- Map.toList (shelleyBasedEraConstraints sbe addresses)
]
Ledger.SendToOppositePotMIR amount -> "MIR amount" .= friendlyLovelace amount

Expand Down
3 changes: 1 addition & 2 deletions cardano-cli/src/Cardano/CLI/Run/EraBased.hs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ module Cardano.CLI.Run.EraBased
) where

import Cardano.Api
import Cardano.Api.Shelley

import Cardano.CLI.Commands.EraBased
import Cardano.CLI.EraBased.Certificate
Expand All @@ -34,7 +33,7 @@ runAnyEraCommand :: ()
-> ExceptT AnyEraCmdError IO ()
runAnyEraCommand = \case
AnyEraCommandOf sbe cmd ->
firstExceptT AnyEraCmdGenericError $ obtainEraCryptoConstraints sbe $ runEraBasedCommand cmd
firstExceptT AnyEraCmdGenericError $ shelleyBasedEraConstraints sbe $ runEraBasedCommand cmd

runEraBasedCommand :: ()
=> EraBasedCommand era -> ExceptT () IO ()
Expand Down
3 changes: 2 additions & 1 deletion cardano-cli/src/Cardano/CLI/Run/Legacy/Pool.hs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,8 @@ runStakePoolRegistrationCert
}

let ledgerStakePoolParams = toShelleyPoolParams stakePoolParams
req = createStakePoolRegistrationRequirements sbe $ obtainEraCryptoConstraints sbe ledgerStakePoolParams
req = createStakePoolRegistrationRequirements sbe
$ shelleyBasedEraConstraints sbe ledgerStakePoolParams
registrationCert = makeStakePoolRegistrationCertificate req

firstExceptT ShelleyPoolCmdWriteFileError
Expand Down
74 changes: 15 additions & 59 deletions cardano-cli/src/Cardano/CLI/Run/Legacy/Query.hs
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,10 @@ import Cardano.CLI.Types.Legacy
import qualified Cardano.CLI.Types.Output as O
import Cardano.Crypto.Hash (hashToBytesAsHex)
import qualified Cardano.Crypto.Hash.Blake2b as Blake2b
import qualified Cardano.Crypto.VRF as Crypto
import Cardano.Ledger.BaseTypes (Seed)
import qualified Cardano.Ledger.Core as Core
import qualified Cardano.Ledger.Crypto as Crypto
import Cardano.Ledger.Keys (KeyHash (..), KeyRole (..))
import Cardano.Ledger.SafeHash (HashAnnotated, SafeHash)
import Cardano.Ledger.SafeHash (SafeHash)
import Cardano.Ledger.Shelley.LedgerState
(PState (psFutureStakePoolParams, psRetiring, psStakePoolParams))
import qualified Cardano.Ledger.Shelley.LedgerState as SL
Expand Down Expand Up @@ -219,7 +217,7 @@ runQueryConstitutionHash socketPath (AnyConsensusModeParams cModeParams) network
eInMode <- toEraInMode era cMode
& hoistMaybe (ShelleyQueryCmdEraConsensusModeMismatch (AnyConsensusMode cMode) anyE)

lift (Api.withShelleyBasedEraConstraintsForLedger sbe (queryConstitutionHash eInMode sbe))
lift (shelleyBasedEraConstraints sbe (queryConstitutionHash eInMode sbe))
& onLeft (left . ShelleyQueryCmdUnsupportedNtcVersion)
& onLeft (left . ShelleyQueryCmdEraMismatch)

Expand Down Expand Up @@ -485,7 +483,7 @@ runQueryKesPeriodInfo socketPath (AnyConsensusModeParams cModeParams) network no
& onLeft (left . ShelleyQueryCmdUnsupportedNtcVersion)
& onLeft (left . ShelleyQueryCmdLocalStateQueryError . EraMismatchError)

(onDiskC, stateC) <- eligibleLeaderSlotsConstaints sbe $ opCertOnDiskAndStateCounters ptclState opCert
(onDiskC, stateC) <- shelleyBasedEraConstraints sbe $ opCertOnDiskAndStateCounters ptclState opCert
let counterInformation = opCertNodeAndOnDiskCounters onDiskC stateC

-- Always render diagnostic information
Expand Down Expand Up @@ -733,7 +731,7 @@ runQueryPoolState socketPath (AnyConsensusModeParams cModeParams) network poolId
& onLeft (left . ShelleyQueryCmdUnsupportedNtcVersion)
& onLeft (left . ShelleyQueryCmdLocalStateQueryError . EraMismatchError)

obtainLedgerEraClassConstraints sbe writePoolState result
shelleyBasedEraConstraints sbe $ writePoolState result

-- | Query the local mempool state
runQueryTxMempool
Expand Down Expand Up @@ -813,7 +811,7 @@ runQueryStakeSnapshot socketPath (AnyConsensusModeParams cModeParams) network al
& onLeft (left . ShelleyQueryCmdUnsupportedNtcVersion)
& onLeft (left . ShelleyQueryCmdLocalStateQueryError . EraMismatchError)

obtainLedgerEraClassConstraints sbe (writeStakeSnapshots mOutFile) result
shelleyBasedEraConstraints sbe $ writeStakeSnapshots mOutFile result


runQueryLedgerState
Expand Down Expand Up @@ -846,7 +844,7 @@ runQueryLedgerState socketPath (AnyConsensusModeParams cModeParams) network mOut
& onLeft (left . ShelleyQueryCmdUnsupportedNtcVersion)
& onLeft (left . ShelleyQueryCmdLocalStateQueryError . EraMismatchError)

obtainLedgerEraClassConstraints sbe (writeLedgerState mOutFile) result
shelleyBasedEraConstraints sbe $ writeLedgerState mOutFile result

runQueryProtocolState
:: SocketPath
Expand Down Expand Up @@ -1372,7 +1370,7 @@ runQueryLeadershipSchedule
& onLeft (left . ShelleyQueryCmdLocalStateQueryError . EraMismatchError)

firstExceptT ShelleyQueryCmdLeaderShipError $ hoistEither
$ eligibleLeaderSlotsConstaints sbe
$ shelleyBasedEraConstraints sbe
$ currentEpochEligibleLeadershipSlots
sbe
shelleyGenesis
Expand All @@ -1393,7 +1391,7 @@ runQueryLeadershipSchedule
& onLeft (left . ShelleyQueryCmdLocalStateQueryError . EraMismatchError)

firstExceptT ShelleyQueryCmdLeaderShipError $ hoistEither
$ eligibleLeaderSlotsConstaints sbe
$ shelleyBasedEraConstraints sbe
$ nextEpochEligibleLeadershipSlots sbe shelleyGenesis
serCurrentEpochState ptclState poolid vrkSkey bpp
eInfo (tip, curentEpoch)
Expand Down Expand Up @@ -1531,59 +1529,17 @@ utcTimeToSlotNo socketPath (AnyConsensusModeParams cModeParams) network utcTime

mode -> left . ShelleyQueryCmdUnsupportedMode $ AnyConsensusMode mode

obtainLedgerEraClassConstraints
:: ShelleyLedgerEra era ~ ledgerera
=> Api.ShelleyBasedEra era
-> (( ToJSON (DebugLedgerState era)
, FromCBOR (DebugLedgerState era)
, Core.EraCrypto ledgerera ~ StandardCrypto
, Core.Era (ShelleyLedgerEra era)
) => a) -> a
obtainLedgerEraClassConstraints ShelleyBasedEraShelley f = f
obtainLedgerEraClassConstraints ShelleyBasedEraAllegra f = f
obtainLedgerEraClassConstraints ShelleyBasedEraMary f = f
obtainLedgerEraClassConstraints ShelleyBasedEraAlonzo f = f
obtainLedgerEraClassConstraints ShelleyBasedEraBabbage f = f
obtainLedgerEraClassConstraints ShelleyBasedEraConway f = f

eligibleLeaderSlotsConstaints
:: ShelleyLedgerEra era ~ ledgerera
=> ShelleyBasedEra era
-> (( ShelleyLedgerEra era ~ ledgerera
, Core.EraCrypto ledgerera ~ StandardCrypto
, Consensus.PraosProtocolSupportsNode (ConsensusProtocol era)
, FromCBOR (Consensus.ChainDepState (ConsensusProtocol era))
, Core.Era ledgerera
, Crypto.Signable (Crypto.VRF (Core.EraCrypto ledgerera)) Seed
, Crypto.ADDRHASH (Consensus.PraosProtocolSupportsNodeCrypto (ConsensusProtocol era)) ~ Blake2b.Blake2b_224
, HashAnnotated
(Core.TxBody (ShelleyLedgerEra era))
Core.EraIndependentTxBody
StandardCrypto
) => a
)
-> a
eligibleLeaderSlotsConstaints ShelleyBasedEraShelley f = f
eligibleLeaderSlotsConstaints ShelleyBasedEraAllegra f = f
eligibleLeaderSlotsConstaints ShelleyBasedEraMary f = f
eligibleLeaderSlotsConstaints ShelleyBasedEraAlonzo f = f
eligibleLeaderSlotsConstaints ShelleyBasedEraBabbage f = f
eligibleLeaderSlotsConstaints ShelleyBasedEraConway f = f

eligibleWriteProtocolStateConstaints
:: ShelleyBasedEra era
-> (( FromCBOR (Consensus.ChainDepState (ConsensusProtocol era))
, ToJSON (Consensus.ChainDepState (ConsensusProtocol era))
) => a
)
-> a
eligibleWriteProtocolStateConstaints ShelleyBasedEraShelley f = f
eligibleWriteProtocolStateConstaints ShelleyBasedEraAllegra f = f
eligibleWriteProtocolStateConstaints ShelleyBasedEraMary f = f
eligibleWriteProtocolStateConstaints ShelleyBasedEraAlonzo f = f
eligibleWriteProtocolStateConstaints ShelleyBasedEraBabbage f = f
eligibleWriteProtocolStateConstaints ShelleyBasedEraConway f = f

-- Required instances
-- instance FromCBOR (TPraosState StandardCrypto) where
-- instance FromCBOR (Praos.PraosState StandardCrypto) where
eligibleWriteProtocolStateConstaints = \case
ShelleyBasedEraShelley -> id
ShelleyBasedEraAllegra -> id
ShelleyBasedEraMary -> id
ShelleyBasedEraAlonzo -> id
ShelleyBasedEraBabbage -> id
ShelleyBasedEraConway -> id
4 changes: 2 additions & 2 deletions cardano-cli/src/Cardano/CLI/Run/Legacy/Read.hs
Original file line number Diff line number Diff line change
Expand Up @@ -765,7 +765,7 @@ readVoteFile
-> VoteFile In
-> IO (Either VoteError (VotingProcedure era))
readVoteFile sbe fp =
first VoteErrorFile <$> obtainEraConstraints sbe (readFileTextEnvelope AsVote fp)
first VoteErrorFile <$> shelleyBasedEraConstraints sbe (readFileTextEnvelope AsVote fp)


data ConstitutionError
Expand Down Expand Up @@ -794,7 +794,7 @@ readConstitution
readConstitution sbe fp =
fmap (first ConstitutionErrorFile)
$ obtainEraPParamsConstraint sbe
$ obtainEraConstraints sbe (readFileTextEnvelope AsProposal fp)
$ shelleyBasedEraConstraints sbe (readFileTextEnvelope AsProposal fp)

-- Misc

Expand Down

0 comments on commit c7cf08c

Please sign in to comment.