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

Bump CHaP to cardano-ledger-conway-1.7.0.0 #179

Merged
merged 11 commits into from
Aug 21, 2023
2 changes: 1 addition & 1 deletion .github/workflows/haskell.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:

env:
# Modify this value to "invalidate" the cabal cache.
CABAL_CACHE_VERSION: "2023-07-12"
CABAL_CACHE_VERSION: "2023-07-13"

concurrency:
group: >
Expand Down
3 changes: 2 additions & 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-06T23:58:58Z
, cardano-haskell-packages 2023-08-04T17:03:07Z
, cardano-haskell-packages 2023-08-21T16:55:07Z

packages:
cardano-api
Expand All @@ -41,3 +41,4 @@ write-ghc-environment-files: always
-- IMPORTANT
-- Do NOT add more source-repository-package stanzas here unless they are strictly
-- temporary! Please read the section in CONTRIBUTING about updating dependencies.

20 changes: 10 additions & 10 deletions cardano-api/cardano-api.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ library internal
, bytestring
, cardano-binary
, cardano-crypto
, cardano-crypto-class >= 2.1.1
, cardano-crypto-class ^>= 2.1.2
, cardano-crypto-wrapper ^>= 1.5
, cardano-data >= 1.0
, cardano-ledger-alonzo >= 1.3.1.1
Expand Down Expand Up @@ -161,17 +161,17 @@ library internal
, network
, optparse-applicative-fork
, ouroboros-consensus >= 0.9
, ouroboros-consensus-cardano >= 0.7
, ouroboros-consensus-cardano >= 0.8
, ouroboros-consensus-diffusion >= 0.7
, ouroboros-consensus-protocol >= 0.5.0.4
, ouroboros-network
, ouroboros-network-api
, ouroboros-network-framework
, ouroboros-network-protocols
, parsec
, plutus-ledger-api:{plutus-ledger-api, plutus-ledger-api-testlib} ^>= 1.7
, plutus-ledger-api:{plutus-ledger-api, plutus-ledger-api-testlib} ^>= 1.9
, prettyprinter
, prettyprinter-configurable ^>= 1.7
, prettyprinter-configurable ^>= 1.9
, random
, scientific
, serialise
Expand Down Expand Up @@ -210,7 +210,7 @@ library
, cardano-api:internal
, cardano-binary
, cardano-crypto
, cardano-crypto-class >= 2.1.1
, cardano-crypto-class ^>= 2.1.2
, cryptonite
, deepseq
, memory
Expand Down Expand Up @@ -239,7 +239,7 @@ library gen
, cardano-api
, cardano-api:internal
, cardano-binary >= 1.6 && < 1.8
, cardano-crypto-class ^>= 2.1
, cardano-crypto-class ^>= 2.1.2
, cardano-crypto-test ^>= 1.5
, cardano-ledger-alonzo >= 1.3.1.1
, cardano-ledger-alonzo-test
Expand Down Expand Up @@ -268,7 +268,7 @@ test-suite cardano-api-test
, cardano-api:gen
, cardano-api:internal
, cardano-crypto
, cardano-crypto-class ^>= 2.1
, cardano-crypto-class ^>= 2.1.2
, cardano-crypto-test ^>= 1.5
, cardano-crypto-tests ^>= 2.1
, cardano-ledger-api >= 1.3
Expand Down Expand Up @@ -317,7 +317,7 @@ test-suite cardano-api-golden
, cardano-api
, cardano-api:gen
, cardano-binary
, cardano-crypto-class
, cardano-crypto-class ^>= 2.1.2
, cardano-data >= 1.0
, cardano-ledger-alonzo
, cardano-ledger-api >= 1.3
Expand All @@ -331,8 +331,8 @@ test-suite cardano-api-golden
, hedgehog >= 1.1
, hedgehog-extras ^>= 0.4.7.0
, microlens
, plutus-core ^>= 1.7
, plutus-ledger-api ^>= 1.7
, plutus-core ^>= 1.9
, plutus-ledger-api ^>= 1.9
, tasty
, tasty-hedgehog
, time
Expand Down
19 changes: 16 additions & 3 deletions cardano-api/gen/Test/Gen/Cardano/Api/Typed.hs
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ import Cardano.Api hiding (txIns)
import qualified Cardano.Api as Api
import Cardano.Api.Byron (KeyWitness (ByronKeyWitness),
WitnessNetworkIdOrByronAddress (..))
import Cardano.Api.Governance.Actions.VotingProcedure
import Cardano.Api.Script (scriptInEraToRefScript)
import Cardano.Api.Shelley

Expand All @@ -147,6 +148,7 @@ import qualified Data.ByteString.Short as SBS
import Data.Coerce
import Data.Int (Int64)
import Data.Map.Strict (Map)
import qualified Data.Map.Strict as Map
import Data.Maybe
import Data.Ratio (Ratio, (%))
import Data.String
Expand Down Expand Up @@ -1125,7 +1127,18 @@ genTxVotes :: CardanoEra era -> Gen (TxVotes era)
genTxVotes era = fromMaybe (pure TxVotesNone) $ do
w <- featureInEra Nothing Just era
let votes = Gen.list (Range.constant 0 10) $ genVote w
pure $ TxVotes w <$> votes
pure $ TxVotes w . Map.fromList <$> votes
where
genVote :: ConwayEraOnwards era -> Gen (VotingProcedure era)
genVote w = conwayEraOnwardsConstraints w $ VotingProcedure <$> Q.arbitrary
genVote
:: ConwayEraOnwards era
-> Gen ( (Voter era, GovernanceActionId era)
, VotingProcedure era
)
genVote w =
conwayEraOnwardsConstraints w $
(,)
<$> ((,)
<$> (fromVoterRole (conwayEraOnwardsToShelleyBasedEra w) <$> Q.arbitrary)
<*> (GovernanceActionId <$> Q.arbitrary)
)
<*> (VotingProcedure <$> Q.arbitrary)
43 changes: 24 additions & 19 deletions cardano-api/internal/Cardano/Api/Certificate.hs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE EmptyCase #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE ImpredicativeTypes #-}
Expand Down Expand Up @@ -165,10 +164,11 @@ instance

-- Conway and onwards related
-- Constitutional Committee related
ConwayCertificate _ (Ledger.ConwayTxCertCommittee Ledger.ConwayRegDRep{}) -> "Constitution committee member key registration"
ConwayCertificate _ (Ledger.ConwayTxCertCommittee Ledger.ConwayUnRegDRep{}) -> "Constitution committee member key unregistration"
ConwayCertificate _ (Ledger.ConwayTxCertCommittee Ledger.ConwayAuthCommitteeHotKey{}) -> "Constitution committee member hot key registration"
ConwayCertificate _ (Ledger.ConwayTxCertCommittee Ledger.ConwayResignCommitteeColdKey{}) -> "Constitution committee member hot key resignation"
ConwayCertificate _ (Ledger.ConwayTxCertGov Ledger.ConwayRegDRep{}) -> "Constitution committee member key registration"
ConwayCertificate _ (Ledger.ConwayTxCertGov Ledger.ConwayUnRegDRep{}) -> "Constitution committee member key unregistration"
ConwayCertificate _ (Ledger.ConwayTxCertGov Ledger.ConwayUpdateDRep{}) -> "Constitution committee member key registration update"
ConwayCertificate _ (Ledger.ConwayTxCertGov Ledger.ConwayAuthCommitteeHotKey{}) -> "Constitution committee member hot key registration"
ConwayCertificate _ (Ledger.ConwayTxCertGov Ledger.ConwayResignCommitteeColdKey{}) -> "Constitution committee member hot key resignation"

ConwayCertificate _ (Ledger.ConwayTxCertDeleg Ledger.ConwayRegCert{}) -> "Stake address registration"
ConwayCertificate _ (Ledger.ConwayTxCertDeleg Ledger.ConwayUnRegCert{}) -> "Stake address deregistration"
Expand Down Expand Up @@ -202,8 +202,8 @@ castConwayTxCert = \case
Ledger.ConwayTxCertDeleg c
Ledger.ConwayTxCertPool c ->
Ledger.ConwayTxCertPool c
Ledger.ConwayTxCertCommittee c ->
Ledger.ConwayTxCertCommittee c
Ledger.ConwayTxCertGov c ->
Ledger.ConwayTxCertGov c

castShelleyToConwayTxCert :: ()
=> EraCrypto srcLedgerEra ~ StandardCrypto
Expand Down Expand Up @@ -260,7 +260,7 @@ castConwayToShelleyTxCert = \case
Nothing
Ledger.ConwayTxCertPool poolCert ->
Just $ Ledger.ShelleyTxCertPool poolCert
Ledger.ConwayTxCertCommittee {} ->
Ledger.ConwayTxCertGov {} ->
Nothing

instance EraCast Certificate where
Expand Down Expand Up @@ -614,38 +614,43 @@ makeDrepRegistrationCertificate :: ()
-> Certificate era
makeDrepRegistrationCertificate (DRepRegistrationRequirements conwayOnwards (VotingCredential vcred) deposit) =
ConwayCertificate conwayOnwards
. Ledger.ConwayTxCertCommittee
. Ledger.ConwayRegDRep vcred
$ toShelleyLovelace deposit
. Ledger.ConwayTxCertGov
$ Ledger.ConwayRegDRep
vcred
(toShelleyLovelace deposit)
Ledger.SNothing -- TODO: Conway era

data CommitteeHotKeyAuthorizationRequirements era where
CommitteeHotKeyAuthorizationRequirements
:: ConwayEraOnwards era
-> Ledger.KeyHash Ledger.CommitteeColdKey (EraCrypto (ShelleyLedgerEra era))
-> Ledger.KeyHash Ledger.CommitteeHotKey (EraCrypto (ShelleyLedgerEra era))
-> Ledger.KeyHash Ledger.ColdCommitteeRole (EraCrypto (ShelleyLedgerEra era))
-> Ledger.KeyHash Ledger.HotCommitteeRole (EraCrypto (ShelleyLedgerEra era))
-> CommitteeHotKeyAuthorizationRequirements era

makeCommitteeHotKeyAuthorizationCertificate :: ()
=> CommitteeHotKeyAuthorizationRequirements era
-> Certificate era
makeCommitteeHotKeyAuthorizationCertificate (CommitteeHotKeyAuthorizationRequirements cOnwards coldKeyHash hotKeyHash) =
ConwayCertificate cOnwards
. Ledger.ConwayTxCertCommittee
$ Ledger.ConwayAuthCommitteeHotKey coldKeyHash hotKeyHash
. Ledger.ConwayTxCertGov
$ Ledger.ConwayAuthCommitteeHotKey
(Ledger.KeyHashObj coldKeyHash)
(Ledger.KeyHashObj hotKeyHash)

data CommitteeColdkeyResignationRequirements era where
CommitteeColdkeyResignationRequirements
:: ConwayEraOnwards era
-> Ledger.KeyHash Ledger.CommitteeColdKey (EraCrypto (ShelleyLedgerEra era))
-> Ledger.KeyHash Ledger.ColdCommitteeRole (EraCrypto (ShelleyLedgerEra era))
-> CommitteeColdkeyResignationRequirements era

makeCommitteeColdkeyResignationCertificate :: ()
=> CommitteeColdkeyResignationRequirements era
-> Certificate era
makeCommitteeColdkeyResignationCertificate (CommitteeColdkeyResignationRequirements cOnwards coldKeyHash) =
ConwayCertificate cOnwards
. Ledger.ConwayTxCertCommittee
$ Ledger.ConwayResignCommitteeColdKey coldKeyHash
. Ledger.ConwayTxCertGov
$ Ledger.ConwayResignCommitteeColdKey
(Ledger.KeyHashObj coldKeyHash)

data DRepUnregistrationRequirements era where
DRepUnregistrationRequirements
Expand All @@ -659,7 +664,7 @@ makeDrepUnregistrationCertificate :: ()
-> Certificate era
makeDrepUnregistrationCertificate (DRepUnregistrationRequirements conwayOnwards (VotingCredential vcred) deposit) =
ConwayCertificate conwayOnwards
. Ledger.ConwayTxCertCommittee
. Ledger.ConwayTxCertGov
. Ledger.ConwayUnRegDRep vcred
$ toShelleyLovelace deposit

Expand Down
14 changes: 10 additions & 4 deletions cardano-api/internal/Cardano/Api/Fees.hs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ import qualified Cardano.Ledger.Crypto as Ledger
import qualified Cardano.Ledger.Keys as Ledger
import Cardano.Ledger.Mary.Value (MaryValue)
import qualified Cardano.Ledger.Shelley.API.Wallet as Ledger (evaluateTransactionFee)
import Cardano.Ledger.Shelley.TxBody (ShelleyEraTxBody)
import Cardano.Ledger.UTxO as Ledger (EraUTxO)
import qualified Ouroboros.Consensus.HardFork.History as Consensus
import qualified PlutusLedgerApi.V1 as Plutus
Expand Down Expand Up @@ -611,7 +610,16 @@ evaluateTransactionExecutionUnitsShelley sbe systemstart epochInfo pp utxo tx' =
-- This should not occur while using cardano-cli because we zip together
-- the Plutus script and the use site (txin, certificate etc). Therefore
-- the redeemer pointer will always point to a Plutus script.
L.MissingScript rdmrPtr resolveable -> ScriptErrorMissingScript rdmrPtr (ResolvablePointers sbe resolveable)
L.MissingScript rdmrPtr resolveable ->
let cnv1 Alonzo.Plutus
{ Alonzo.plutusLanguage = lang
, Alonzo.plutusScript = Alonzo.BinaryPlutus bytes
} = (bytes, lang)
cnv2 (purpose, mbScript, scriptHash) = (purpose, fmap cnv1 mbScript, scriptHash)
in
ScriptErrorMissingScript rdmrPtr
$ ResolvablePointers sbe
$ Map.map cnv2 resolveable

L.NoCostModelInLedgerState l -> ScriptErrorMissingCostModel l

Expand Down Expand Up @@ -664,7 +672,6 @@ evaluateTransactionBalance pp poolids stakeDelegDeposits utxo

evalMultiAsset :: forall ledgerera.
ShelleyLedgerEra era ~ ledgerera
=> ShelleyEraTxBody ledgerera
nfrisby marked this conversation as resolved.
Show resolved Hide resolved
=> LedgerEraConstraints ledgerera
=> LedgerMultiAssetConstraints ledgerera
=> MultiAssetSupportedInEra era
Expand All @@ -680,7 +687,6 @@ evaluateTransactionBalance pp poolids stakeDelegDeposits utxo

evalAdaOnly :: forall ledgerera.
ShelleyLedgerEra era ~ ledgerera
=> ShelleyEraTxBody ledgerera
=> LedgerEraConstraints ledgerera
=> LedgerAdaOnlyConstraints ledgerera
=> OnlyAdaSupportedInEra era
Expand Down
Loading