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 cardano-ledger and plutus versions already on CHaP #711

Closed
wants to merge 13 commits into from
Closed
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
15 changes: 12 additions & 3 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ repository cardano-haskell-packages
-- See CONTRIBUTING for information about these, including some Nix commands
-- you need to run if you change them
index-state:
, hackage.haskell.org 2024-10-10T08:11:33Z
, cardano-haskell-packages 2024-10-14T23:19:53Z
, hackage.haskell.org 2024-12-10T16:20:07Z
, cardano-haskell-packages 2024-12-18T14:29:04Z

packages:
cardano-api
Expand Down Expand Up @@ -51,4 +51,13 @@ write-ghc-environment-files: always

constraints:
Cabal < 3.14,
cardano-ledger-shelley ^>= 1.14.1

source-repository-package
type: git
location: https://github.com/IntersectMBO/ouroboros-consensus
tag: e47f737f1447a33f6c2bbbd35cc47272cdf03526
--sha256: sha256-8FHWs//Thm14o+COMoyY7eq4fe53JNywDdE+N3UKQmA=
subdir: ouroboros-consensus
ouroboros-consensus-cardano
ouroboros-consensus-diffusion
ouroboros-consensus-protocol
2 changes: 1 addition & 1 deletion cardano-api-gen/cardano-api-gen.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ license-files:
NOTICE

build-type: Simple
extra-source-files:
extra-doc-files:
CHANGELOG.md
README.md

Expand Down
16 changes: 8 additions & 8 deletions cardano-api/cardano-api.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ library internal
cardano-data >=1.0,
cardano-ledger-allegra >=1.6,
cardano-ledger-alonzo >=1.10.2,
cardano-ledger-api ^>=1.9.3,
cardano-ledger-api >=1.9.3,
cardano-ledger-babbage >=1.9,
cardano-ledger-binary >=1.3,
cardano-ledger-byron >=1.0.1,
Expand Down Expand Up @@ -207,11 +207,11 @@ library internal
ouroboros-consensus-diffusion ^>=0.18,
ouroboros-consensus-protocol ^>=0.9.0.2,
ouroboros-network,
ouroboros-network-api ^>=0.10,
ouroboros-network-api ^>=0.11,
ouroboros-network-framework,
ouroboros-network-protocols,
parsec,
plutus-ledger-api:{plutus-ledger-api, plutus-ledger-api-testlib} ^>=1.36,
plutus-ledger-api:{plutus-ledger-api, plutus-ledger-api-testlib} ^>=1.37,
prettyprinter,
prettyprinter-ansi-terminal,
prettyprinter-configurable ^>=1.36,
Expand All @@ -226,7 +226,7 @@ library internal
time,
transformers,
transformers-except ^>=0.1.3,
typed-protocols ^>=0.1.1,
typed-protocols ^>=0.3,
vector,
yaml,

Expand Down Expand Up @@ -262,7 +262,7 @@ library
memory,
nothunks,
ouroboros-network-protocols,
typed-protocols ^>=0.1.1,
typed-protocols,

library gen
import: project-config
Expand Down Expand Up @@ -324,7 +324,7 @@ test-suite cardano-api-test
cardano-crypto-test ^>=1.5,
cardano-crypto-tests ^>=2.1,
cardano-ledger-alonzo,
cardano-ledger-api ^>=1.9,
cardano-ledger-api >=1.9,
cardano-ledger-binary,
cardano-ledger-core:{cardano-ledger-core, testlib} >=1.14,
cardano-ledger-mary,
Expand Down Expand Up @@ -395,7 +395,7 @@ test-suite cardano-api-golden
cardano-crypto-class ^>=2.1.2,
cardano-data >=1.0,
cardano-ledger-alonzo,
cardano-ledger-api ^>=1.9,
cardano-ledger-api >=1.9,
cardano-ledger-babbage >=1.9,
cardano-ledger-binary,
cardano-ledger-core:{cardano-ledger-core, testlib} >=1.14,
Expand All @@ -409,7 +409,7 @@ test-suite cardano-api-golden
hedgehog-extras ^>=0.6.1.0,
microlens,
parsec,
plutus-core ^>=1.36,
plutus-core ^>=1.37,
plutus-ledger-api,
tasty,
tasty-hedgehog,
Expand Down
4 changes: 2 additions & 2 deletions cardano-api/gen/Test/Gen/Cardano/Api/Typed.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1005,7 +1005,7 @@ genProtocolParameters era = do
protocolParamStakePoolDeposit <- genLovelace
protocolParamMinPoolCost <- genLovelace
protocolParamPoolRetireMaxEpoch <- genEpochInterval
protocolParamStakePoolTargetNum <- genNat
protocolParamStakePoolTargetNum <- genWord16
protocolParamPoolPledgeInfluence <- genRationalInt64
protocolParamMonetaryExpansion <- genRational
protocolParamTreasuryCut <- genRational
Expand Down Expand Up @@ -1042,7 +1042,7 @@ genProtocolParametersUpdate era = do
protocolUpdateStakePoolDeposit <- Gen.maybe genLovelace
protocolUpdateMinPoolCost <- Gen.maybe genLovelace
protocolUpdatePoolRetireMaxEpoch <- Gen.maybe genEpochInterval
protocolUpdateStakePoolTargetNum <- Gen.maybe genNat
protocolUpdateStakePoolTargetNum <- Gen.maybe genWord16
protocolUpdatePoolPledgeInfluence <- Gen.maybe genRationalInt64
protocolUpdateMonetaryExpansion <- Gen.maybe genRational
protocolUpdateTreasuryCut <- Gen.maybe genRational
Expand Down
2 changes: 1 addition & 1 deletion cardano-api/internal/Cardano/Api/Block.hs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ import qualified Cardano.Crypto.Hash.Class as Crypto
import qualified Cardano.Crypto.Hashing
import qualified Cardano.Ledger.Api as L
import qualified Cardano.Ledger.Block as Ledger
import qualified Cardano.Ledger.Era as Ledger
import qualified Cardano.Ledger.Core as Ledger
import Cardano.Slotting.Block (BlockNo)
import Cardano.Slotting.Slot (EpochNo, SlotNo, WithOrigin (..))
import qualified Ouroboros.Consensus.Block as Consensus
Expand Down
8 changes: 4 additions & 4 deletions cardano-api/internal/Cardano/Api/Certificate.hs
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ makeStakePoolRetirementCertificate req =
ConwayCertificate atMostBab $
Ledger.mkRetirePoolTxCert (unStakePoolKeyHash poolId) retirementEpoch

data GenesisKeyDelegationRequirements ere where
data GenesisKeyDelegationRequirements era where
GenesisKeyDelegationRequirements
:: ShelleyToBabbageEra era
-> Hash GenesisKey
Expand All @@ -381,7 +381,7 @@ makeGenesisKeyDelegationCertificate
ShelleyRelatedCertificate atMostEra $
shelleyToBabbageEraConstraints atMostEra $
Ledger.ShelleyTxCertGenesisDeleg $
Ledger.GenesisDelegCert hGenKey hGenDelegKey hVrfKey
Ledger.GenesisDelegCert hGenKey hGenDelegKey (Ledger.toVRFVerKeyHash hVrfKey)

data MirCertificateRequirements era where
MirCertificateRequirements
Expand Down Expand Up @@ -613,7 +613,7 @@ toShelleyPoolParams
-- do simple client-side sanity checks, e.g. on the pool metadata url
Ledger.PoolParams
{ Ledger.ppId = poolkh
, Ledger.ppVrf = vrfkh
, Ledger.ppVrf = Ledger.toVRFVerKeyHash vrfkh
, Ledger.ppPledge = stakePoolPledge
, Ledger.ppCost = stakePoolCost
, Ledger.ppMargin =
Expand Down Expand Up @@ -685,7 +685,7 @@ fromShelleyPoolParams
} =
StakePoolParameters
{ stakePoolId = StakePoolKeyHash ppId
, stakePoolVRF = VrfKeyHash ppVrf
, stakePoolVRF = VrfKeyHash (Ledger.fromVRFVerKeyHash ppVrf)
, stakePoolCost = ppCost
, stakePoolMargin = Ledger.unboundRational ppMargin
, stakePoolRewardAccount = fromShelleyStakeAddr ppRewardAccount
Expand Down
26 changes: 16 additions & 10 deletions cardano-api/internal/Cardano/Api/IPC.hs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ import qualified Ouroboros.Network.Protocol.LocalTxSubmission.Client as Net.Tx

import Control.Concurrent.STM (TMVar, atomically, newEmptyTMVarIO, putTMVar, takeTMVar,
tryPutTMVar)
import Control.Exception (throwIO)
import Control.Monad (void)
import Control.Monad.IO.Class
import Control.Tracer (nullTracer)
Expand Down Expand Up @@ -202,15 +203,19 @@ connectToLocalNodeWithVersion
, localConsensusModeParams
}
clients =
liftIO $ Net.withIOManager $ \iomgr ->
Net.connectTo
(Net.localSnocket iomgr)
Net.NetworkConnectTracers
{ Net.nctMuxTracer = nullTracer
, Net.nctHandshakeTracer = nullTracer
}
versionedProtocls
(unFile localNodeSocketPath)
liftIO $ Net.withIOManager $ \iomgr -> do
r <-
Net.connectTo
(Net.localSnocket iomgr)
Net.NetworkConnectTracers
{ Net.nctMuxTracer = nullTracer
, Net.nctHandshakeTracer = nullTracer
}
versionedProtocls
(unFile localNodeSocketPath)
case r of
Left e -> throwIO e
Right _ -> pure ()
where
versionedProtocls =
-- First convert from the mode-parametrised view of things to the
Expand Down Expand Up @@ -302,10 +307,11 @@ mkVersionedProtocols networkid ptcl unversionedClients =
)
, localStateQueryProtocol =
Net.InitiatorProtocolOnly $
Net.mkMiniProtocolCbFromPeer $
Net.mkMiniProtocolCbFromPeerSt $
const
( nullTracer
, cStateQueryCodec
, Net.Query.StateIdle
, maybe
Net.localStateQueryPeerNull
Net.Query.localStateQueryClientPeer
Expand Down
2 changes: 1 addition & 1 deletion cardano-api/internal/Cardano/Api/Keys/Praos.hs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ instance Key VrfKey where

verificationKeyHash :: VerificationKey VrfKey -> Hash VrfKey
verificationKeyHash (VrfVerificationKey vkey) =
VrfKeyHash (Shelley.hashVerKeyVRF vkey)
VrfKeyHash (Crypto.hashVerKeyVRF vkey)

instance SerialiseAsRawBytes (VerificationKey VrfKey) where
serialiseToRawBytes (VrfVerificationKey vk) =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,8 @@ toLedgerEventConway evt =
case govEvent of
Conway.GovNewProposals txid props ->
Just $ NewGovernanceProposals txid (AnyProposals props)
Conway.GovRemovedVotes txid replacedVotes unregisteredDReps ->
Just $ RemovedGovernanceVotes txid replacedVotes unregisteredDReps

instance ConvertLedgerEvent (HardForkBlock (Consensus.CardanoEras StandardCrypto)) where
toLedgerEvent wrappedLedgerEvent =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@ data LedgerEvent

-- | Newly submittted governance proposals in a single transaction.
NewGovernanceProposals (Ledger.TxId StandardCrypto) AnyProposals
| -- | Governance votes that were invalidated.
RemovedGovernanceVotes
(Ledger.TxId StandardCrypto)
(Set (Ledger.Voter StandardCrypto, Ledger.GovActionId StandardCrypto))
-- ^ Votes that were replaced in this tx.
(Set (Ledger.Credential 'Ledger.DRepRole StandardCrypto))
-- ^ Any votes from these DReps in this or in previous txs are removed
| -- | The current state of governance matters at the epoch boundary.
-- I.E the current constitution, committee, protocol parameters, etc.
EpochBoundaryRatificationState AnyRatificationState
Expand Down
40 changes: 20 additions & 20 deletions cardano-api/internal/Cardano/Api/LedgerState.hs
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ import qualified Data.Yaml as Yaml
import Formatting.Buildable (build)
import GHC.Exts (IsList (..))
import Lens.Micro
import Network.TypedProtocol.Pipelined (Nat (..))
import Network.TypedProtocol.Core (Nat (..))
import System.FilePath

data InitialLedgerStateError
Expand Down Expand Up @@ -1097,45 +1097,45 @@ instance FromJSON NodeConfig where
<*> parseBabbageHardForkEpoch o
<*> parseConwayHardForkEpoch o

parseShelleyHardForkEpoch :: Object -> Parser Consensus.TriggerHardFork
parseShelleyHardForkEpoch :: Object -> Parser (Consensus.CardanoHardForkTrigger blk)
parseShelleyHardForkEpoch o =
asum
[ Consensus.TriggerHardForkAtEpoch <$> o .: "TestShelleyHardForkAtEpoch"
, pure $ Consensus.TriggerHardForkAtVersion 2 -- Mainnet default
[ Consensus.CardanoTriggerHardForkAtEpoch <$> o .: "TestShelleyHardForkAtEpoch"
, pure Consensus.CardanoTriggerHardForkAtDefaultVersion
]

parseAllegraHardForkEpoch :: Object -> Parser Consensus.TriggerHardFork
parseAllegraHardForkEpoch :: Object -> Parser (Consensus.CardanoHardForkTrigger blk)
parseAllegraHardForkEpoch o =
asum
[ Consensus.TriggerHardForkAtEpoch <$> o .: "TestAllegraHardForkAtEpoch"
, pure $ Consensus.TriggerHardForkAtVersion 3 -- Mainnet default
[ Consensus.CardanoTriggerHardForkAtEpoch <$> o .: "TestAllegraHardForkAtEpoch"
, pure Consensus.CardanoTriggerHardForkAtDefaultVersion
]

parseMaryHardForkEpoch :: Object -> Parser Consensus.TriggerHardFork
parseMaryHardForkEpoch :: Object -> Parser (Consensus.CardanoHardForkTrigger blk)
parseMaryHardForkEpoch o =
asum
[ Consensus.TriggerHardForkAtEpoch <$> o .: "TestMaryHardForkAtEpoch"
, pure $ Consensus.TriggerHardForkAtVersion 4 -- Mainnet default
[ Consensus.CardanoTriggerHardForkAtEpoch <$> o .: "TestMaryHardForkAtEpoch"
, pure Consensus.CardanoTriggerHardForkAtDefaultVersion
]

parseAlonzoHardForkEpoch :: Object -> Parser Consensus.TriggerHardFork
parseAlonzoHardForkEpoch :: Object -> Parser (Consensus.CardanoHardForkTrigger blk)
parseAlonzoHardForkEpoch o =
asum
[ Consensus.TriggerHardForkAtEpoch <$> o .: "TestAlonzoHardForkAtEpoch"
, pure $ Consensus.TriggerHardForkAtVersion 5 -- Mainnet default
[ Consensus.CardanoTriggerHardForkAtEpoch <$> o .: "TestAlonzoHardForkAtEpoch"
, pure Consensus.CardanoTriggerHardForkAtDefaultVersion
]
parseBabbageHardForkEpoch :: Object -> Parser Consensus.TriggerHardFork
parseBabbageHardForkEpoch :: Object -> Parser (Consensus.CardanoHardForkTrigger blk)
parseBabbageHardForkEpoch o =
asum
[ Consensus.TriggerHardForkAtEpoch <$> o .: "TestBabbageHardForkAtEpoch"
, pure $ Consensus.TriggerHardForkAtVersion 7 -- Mainnet default
[ Consensus.CardanoTriggerHardForkAtEpoch <$> o .: "TestBabbageHardForkAtEpoch"
, pure Consensus.CardanoTriggerHardForkAtDefaultVersion
]

parseConwayHardForkEpoch :: Object -> Parser Consensus.TriggerHardFork
parseConwayHardForkEpoch :: Object -> Parser (Consensus.CardanoHardForkTrigger blk)
parseConwayHardForkEpoch o =
asum
[ Consensus.TriggerHardForkAtEpoch <$> o .: "TestConwayHardForkAtEpoch"
, pure $ Consensus.TriggerHardForkAtVersion 9 -- Mainnet default
[ Consensus.CardanoTriggerHardForkAtEpoch <$> o .: "TestConwayHardForkAtEpoch"
, pure Consensus.CardanoTriggerHardForkAtDefaultVersion
]

----------------------------------------------------------------------
Expand Down Expand Up @@ -2291,6 +2291,6 @@ toLedgerIndividualPoolStake :: Consensus.IndividualPoolStake c -> SL.IndividualP
toLedgerIndividualPoolStake ips =
SL.IndividualPoolStake
{ SL.individualPoolStake = Consensus.individualPoolStake ips
, SL.individualPoolStakeVrf = Consensus.individualPoolStakeVrf ips
, SL.individualPoolStakeVrf = SL.toVRFVerKeyHash $ Consensus.individualPoolStakeVrf ips
, SL.individualTotalPoolStake = SL.CompactCoin 0
}
6 changes: 3 additions & 3 deletions cardano-api/internal/Cardano/Api/ProtocolParameters.hs
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ data CommonProtocolParametersUpdate
, cppKeyDeposit :: StrictMaybe Ledger.Coin
, cppPoolDeposit :: StrictMaybe Ledger.Coin
, cppPoolRetireMaxEpoch :: StrictMaybe Ledger.EpochInterval
, cppStakePoolTargetNum :: StrictMaybe Natural
, cppStakePoolTargetNum :: StrictMaybe Word16
, cppPoolPledgeInfluence :: StrictMaybe Ledger.NonNegativeInterval
, cppTreasuryExpansion :: StrictMaybe Ledger.UnitInterval
, cppMonetaryExpansion :: StrictMaybe Ledger.UnitInterval
Expand Down Expand Up @@ -526,7 +526,7 @@ data ProtocolParameters
, protocolParamPoolRetireMaxEpoch :: Ledger.EpochInterval
-- ^ The maximum number of epochs into the future that stake pools
-- are permitted to schedule a retirement.
, protocolParamStakePoolTargetNum :: Natural
, protocolParamStakePoolTargetNum :: Word16
-- ^ The equilibrium target number of stake pools.
--
-- This is the \"k\" incentives parameter from the design document.
Expand Down Expand Up @@ -710,7 +710,7 @@ data ProtocolParametersUpdate
, protocolUpdatePoolRetireMaxEpoch :: Maybe Ledger.EpochInterval
-- ^ The maximum number of epochs into the future that stake pools
-- are permitted to schedule a retirement.
, protocolUpdateStakePoolTargetNum :: Maybe Natural
, protocolUpdateStakePoolTargetNum :: Maybe Word16
-- ^ The equilibrium target number of stake pools.
--
-- This is the \"k\" incentives parameter from the design document.
Expand Down
4 changes: 3 additions & 1 deletion cardano-api/internal/Cardano/Api/ReexposeLedger.hs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ module Cardano.Api.ReexposeLedger
, hashKey
, hashVerKeyVRF
, hashWithSerialiser
, fromVRFVerKeyHash
, toVRFVerKeyHash
, PoolParams (..)
, HasKeyRole
, MIRPot (..)
Expand Down Expand Up @@ -225,7 +227,7 @@ import Cardano.Ledger.Credential (Credential (..), credToText)
import Cardano.Ledger.Crypto (ADDRHASH, Crypto, StandardCrypto)
import Cardano.Ledger.DRep (DRep (..), drepAnchorL, drepDepositL, drepExpiryL)
import Cardano.Ledger.Keys (HasKeyRole, KeyHash (..), KeyRole (..), VKey (..),
hashWithSerialiser)
fromVRFVerKeyHash, hashWithSerialiser, toVRFVerKeyHash)
import Cardano.Ledger.Plutus.Data (Data (..), unData)
import Cardano.Ledger.Plutus.Language (Language, Plutus, languageToText, plutusBinary)
import Cardano.Ledger.PoolParams (PoolMetadata (..), PoolParams (..), StakePoolRelay (..))
Expand Down
2 changes: 1 addition & 1 deletion cardano-api/src/Cardano/Api/ChainSync/ClientPipelined.hs
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ where
import Ouroboros.Network.Protocol.ChainSync.ClientPipelined
import Ouroboros.Network.Protocol.ChainSync.PipelineDecision

import Network.TypedProtocol.Pipelined (N (..), Nat (..), natToInt)
import Network.TypedProtocol.Core (N (..), Nat (..), natToInt)
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import Cardano.Ledger.Credential (Credential (..), PaymentCredential,
StakeReference (..))
import Cardano.Ledger.Crypto (StandardCrypto)
import Cardano.Ledger.Keys (GenDelegPair (..), Hash, KeyHash (..), KeyRole (..),
VerKeyVRF)
VerKeyVRF, toVRFVerKeyHash)
import Cardano.Ledger.Shelley.Genesis (emptyGenesisStaking)
import Cardano.Slotting.Slot (EpochSize (..))

Expand Down Expand Up @@ -51,7 +51,7 @@ exampleShelleyGenesis =
fromList
[
( genesisVerKeyHash
, GenDelegPair delegVerKeyHash delegVrfKeyHash
, GenDelegPair delegVerKeyHash (toVRFVerKeyHash delegVrfKeyHash)
)
]
, sgInitialFunds = ListMap [(initialFundedAddress, initialFunds)]
Expand Down
Loading
Loading