Skip to content

Commit

Permalink
Update Ledger and Plutus dependencies for the Cardano Node 8.12 relea…
Browse files Browse the repository at this point in the history
…se. (#1142)

As a part of the [Cardano Node 8.12
release](IntersectMBO/cardano-node#5868) this
PR contains
- [x] updated Ledger dependencies.
- [x] updated Plutus dependencies
- [x] updated `ouroboros-network` dependencies,
... and the code changes needed to make them work.
  • Loading branch information
amesgen authored Jun 19, 2024
2 parents 577ce94 + 6eb84a8 commit b128a6e
Show file tree
Hide file tree
Showing 33 changed files with 217 additions and 74 deletions.
18 changes: 8 additions & 10 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ repository cardano-haskell-packages
-- update either of these.
index-state:
-- Bump this if you need newer packages from Hackage
, hackage.haskell.org 2024-06-02T23:45:05Z
, hackage.haskell.org 2024-06-13T08:49:27Z
-- Bump this if you need newer packages from CHaP
, cardano-haskell-packages 2024-05-29T10:00:00Z
, cardano-haskell-packages 2024-06-18T14:00:00Z

packages:
ouroboros-consensus
Expand All @@ -37,11 +37,9 @@ if(os(windows))
constraints:
bitvec -simd

source-repository-package
type: git
location: https://github.com/IntersectMBO/ouroboros-network
tag: 431bb599940d2947b2cb99d3ae29b7f2c4cdd36d
--sha256: 1a62hqddpnc0j5r7nl54q79nrxyw77dphpsgp68hxij210dkpvca
subdir:
ouroboros-network-api
ouroboros-network-protocols
-- Workaround for a haskell.nix bug around pre-installed libraries. Might be
-- fixed by https://github.com/input-output-hk/haskell.nix/pull/2218.
extra-packages: Cabal
if os(windows)
constraints: time ^>=1.14
allow-newer: *:time
19 changes: 9 additions & 10 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@
nixpkgs.follows = "haskellNix/nixpkgs-unstable";
flake-utils.url = "github:numtide/flake-utils";
haskellNix = {
# temporarily use the static-nix-tools branch until it's merged to work
# aroundt he Cabal build issues.
url = "github:input-output-hk/haskell.nix/static-nix-tools";
url = "github:input-output-hk/haskell.nix";
inputs.hackage.follows = "hackageNix";
};
hackageNix = {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
### Breaking

- Changed `GetStakeDistribution` and `GetPoolDistr` queries to return a
Consensus-vendored version of `PoolDistr` (instead of using the one from
Ledger, as it changed in a backwards-incompatible manner).
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified ouroboros-consensus-cardano/golden/cardano/disk/LedgerState_Mary
Binary file not shown.
Binary file not shown.
Binary file modified ouroboros-consensus-cardano/golden/shelley/disk/ExtLedgerState
Binary file not shown.
Binary file modified ouroboros-consensus-cardano/golden/shelley/disk/LedgerState
Binary file not shown.
27 changes: 14 additions & 13 deletions ouroboros-consensus-cardano/ouroboros-consensus-cardano.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ library
Ouroboros.Consensus.Shelley.Ledger.PeerSelection
Ouroboros.Consensus.Shelley.Ledger.Protocol
Ouroboros.Consensus.Shelley.Ledger.Query
Ouroboros.Consensus.Shelley.Ledger.Query.Types
Ouroboros.Consensus.Shelley.Ledger.SupportsProtocol
Ouroboros.Consensus.Shelley.Node
Ouroboros.Consensus.Shelley.Node.Common
Expand All @@ -133,16 +134,16 @@ library
cardano-crypto,
cardano-crypto-class,
cardano-crypto-wrapper,
cardano-ledger-allegra ^>=1.4,
cardano-ledger-alonzo ^>=1.8,
cardano-ledger-api ^>=1.9,
cardano-ledger-babbage ^>=1.8,
cardano-ledger-binary ^>=1.3,
cardano-ledger-byron ^>=1.0,
cardano-ledger-conway ^>=1.14,
cardano-ledger-core ^>=1.12,
cardano-ledger-mary ^>=1.6,
cardano-ledger-shelley ^>=1.11,
cardano-ledger-allegra ^>=1.5,
cardano-ledger-alonzo ^>=1.9,
cardano-ledger-api ^>=1.9.2,
cardano-ledger-babbage ^>=1.8.1,
cardano-ledger-binary ^>=1.3.3,
cardano-ledger-byron ^>=1.0.1,
cardano-ledger-conway ^>=1.15,
cardano-ledger-core ^>=1.13,
cardano-ledger-mary ^>=1.6.1,
cardano-ledger-shelley ^>=1.12,
cardano-prelude,
cardano-protocol-tpraos ^>=1.2,
cardano-slotting,
Expand All @@ -158,7 +159,7 @@ library
nothunks,
ouroboros-consensus ^>=0.18,
ouroboros-consensus-protocol ^>=0.9,
ouroboros-network-api ^>=0.7,
ouroboros-network-api ^>=0.7.3,
serialise ^>=0.2,
small-steps,
sop-core ^>=0.5,
Expand Down Expand Up @@ -539,7 +540,7 @@ library unstable-cardano-tools
contra-tracer,
directory,
filepath,
fs-api ^>=0.2,
fs-api ^>=0.2.0.1,
githash,
microlens,
mtl,
Expand All @@ -551,7 +552,7 @@ library unstable-cardano-tools
ouroboros-consensus-protocol ^>=0.9,
ouroboros-network,
ouroboros-network-api,
ouroboros-network-framework,
ouroboros-network-framework ^>=0.13.2,
ouroboros-network-protocols,
serialise ^>=0.2,
singletons,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ import Ouroboros.Consensus.Shelley.Ledger.Ledger
import Ouroboros.Consensus.Shelley.Ledger.NetworkProtocolVersion
(ShelleyNodeToClientVersion (..))
import Ouroboros.Consensus.Shelley.Ledger.Query.PParamsLegacyEncoder
import Ouroboros.Consensus.Shelley.Ledger.Query.Types
import Ouroboros.Consensus.Shelley.Protocol.Abstract (ProtoCrypto)
import Ouroboros.Consensus.Util (ShowProxy (..))
import Ouroboros.Network.Block (Serialised (..), decodePoint,
Expand Down Expand Up @@ -127,7 +128,7 @@ data instance BlockQuery (ShelleyBlock proto era) :: Type -> Type where
-- an endpoint that provides all the information that the wallet wants about
-- pools, in an extensible fashion.
GetStakeDistribution
:: BlockQuery (ShelleyBlock proto era) (SL.PoolDistr (EraCrypto era))
:: BlockQuery (ShelleyBlock proto era) (PoolDistr (EraCrypto era))

-- | Get a subset of the UTxO, filtered by address. Although this will
-- typically return a lot less data than 'GetUTxOWhole', it requires a linear
Expand Down Expand Up @@ -224,7 +225,7 @@ data instance BlockQuery (ShelleyBlock proto era) :: Type -> Type where
GetPoolDistr
:: Maybe (Set (SL.KeyHash 'SL.StakePool (EraCrypto era)))
-> BlockQuery (ShelleyBlock proto era)
(SL.PoolDistr (EraCrypto era))
(PoolDistr (EraCrypto era))

GetStakeDelegDeposits
:: Set (StakeCredential (EraCrypto era))
Expand Down Expand Up @@ -319,7 +320,7 @@ instance (ShelleyCompatible proto era, ProtoCrypto proto ~ crypto)
GetProposedPParamsUpdates ->
getProposedPPUpdates st
GetStakeDistribution ->
SL.poolsByTotalStakeFraction globals st
fromLedgerPoolDistr $ SL.poolsByTotalStakeFraction globals st
GetUTxOByAddress addrs ->
SL.getFilteredUTxO st addrs
GetUTxOWhole ->
Expand Down Expand Up @@ -416,7 +417,8 @@ instance (ShelleyCompatible proto era, ProtoCrypto proto ~ crypto)

GetPoolDistr mPoolIds ->
let stakeSet = SL.ssStakeSet . SL.esSnapshots $ getEpochState st in
SL.calculatePoolDistr' (maybe (const True) (flip Set.member) mPoolIds) stakeSet
fromLedgerPoolDistr $
SL.calculatePoolDistr' (maybe (const True) (flip Set.member) mPoolIds) stakeSet
GetStakeDelegDeposits stakeCreds ->
let lookupDeposit =
lookupDepositDState (SL.certDState $ SL.lsCertState $ SL.esLState $ SL.nesEs st)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE OverloadedStrings #-}

-- | This module contains copies of older versions of types from Ledger in order
-- to retain backwards-compatibility. Eventually, types likes this should be
-- defined in Ledger instead of here, see
-- <https://github.com/IntersectMBO/cardano-ledger/issues/4415>.
module Ouroboros.Consensus.Shelley.Ledger.Query.Types (
IndividualPoolStake (..)
, PoolDistr (..)
, fromLedgerIndividualPoolStake
, fromLedgerPoolDistr
) where

import Cardano.Ledger.Binary (DecCBOR (..), EncCBOR (..),
decodeRecordNamed, encodeListLen)
import Cardano.Ledger.Crypto (Crypto)
import Cardano.Ledger.Keys (Hash)
import qualified Cardano.Ledger.PoolDistr as SL
import qualified Cardano.Ledger.Shelley.API as SL
import Data.Map.Strict (Map)
import qualified Data.Map.Strict as Map
import GHC.Generics (Generic)
import NoThunks.Class

-- | Copy of 'SL.IndividualPoolStake' before
-- <https://github.com/IntersectMBO/cardano-ledger/pull/4324>.
data IndividualPoolStake c = IndividualPoolStake {
individualPoolStake :: !Rational
, individualPoolStakeVrf :: !(Hash c (SL.VerKeyVRF c))
}
deriving stock (Show, Eq, Generic)
deriving anyclass (NoThunks)

fromLedgerIndividualPoolStake :: SL.IndividualPoolStake c -> IndividualPoolStake c
fromLedgerIndividualPoolStake ips = IndividualPoolStake {
individualPoolStake = SL.individualPoolStake ips
, individualPoolStakeVrf = SL.individualPoolStakeVrf ips
}

instance Crypto c => EncCBOR (IndividualPoolStake c) where
encCBOR (IndividualPoolStake stake vrf) =
mconcat
[ encodeListLen 2
, encCBOR stake
, encCBOR vrf
]

instance Crypto c => DecCBOR (IndividualPoolStake c) where
decCBOR =
decodeRecordNamed "IndividualPoolStake" (const 2) $
IndividualPoolStake
<$> decCBOR
<*> decCBOR

-- | Copy of 'SL.PoolDistr' before
-- <https://github.com/IntersectMBO/cardano-ledger/pull/4324>.
newtype PoolDistr c = PoolDistr {
unPoolDistr :: Map (SL.KeyHash SL.StakePool c) (IndividualPoolStake c)
}
deriving stock (Show, Eq, Generic)
deriving newtype (EncCBOR, DecCBOR)

fromLedgerPoolDistr :: SL.PoolDistr c -> PoolDistr c
fromLedgerPoolDistr pd = PoolDistr {
unPoolDistr = Map.map fromLedgerIndividualPoolStake $ SL.unPoolDistr pd
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import Ouroboros.Consensus.Protocol.TPraos (TPraos,
import Ouroboros.Consensus.Shelley.Eras
import Ouroboros.Consensus.Shelley.HFEras
import Ouroboros.Consensus.Shelley.Ledger
import Ouroboros.Consensus.Shelley.Ledger.Query.Types
import Ouroboros.Consensus.Shelley.Protocol.TPraos ()
import Ouroboros.Consensus.Storage.Serialisation
import Ouroboros.Network.Block (Serialised (..))
Expand Down Expand Up @@ -114,7 +115,7 @@ fromShelleyLedgerExamples ShelleyLedgerExamples {
, ("EpochNo", SomeResult GetEpochNo 10)
, ("EmptyPParams", SomeResult GetCurrentPParams srePParams)
, ("ProposedPParamsUpdates", SomeResult GetProposedPParamsUpdates sreProposedPPUpdates)
, ("StakeDistribution", SomeResult GetStakeDistribution srePoolDistr)
, ("StakeDistribution", SomeResult GetStakeDistribution $ fromLedgerPoolDistr srePoolDistr)
, ("NonMyopicMemberRewards", SomeResult (GetNonMyopicMemberRewards Set.empty)
(NonMyopicMemberRewards $ sreNonMyopicRewards))
, ("GenesisConfig", SomeResult GetGenesisConfig (compactGenesis sreShelleyGenesis))
Expand Down Expand Up @@ -207,7 +208,7 @@ fromShelleyLedgerExamplesPraos ShelleyLedgerExamples {
, ("EpochNo", SomeResult GetEpochNo 10)
, ("EmptyPParams", SomeResult GetCurrentPParams srePParams)
, ("ProposedPParamsUpdates", SomeResult GetProposedPParamsUpdates sreProposedPPUpdates)
, ("StakeDistribution", SomeResult GetStakeDistribution srePoolDistr)
, ("StakeDistribution", SomeResult GetStakeDistribution $ fromLedgerPoolDistr srePoolDistr)
, ("NonMyopicMemberRewards", SomeResult (GetNonMyopicMemberRewards Set.empty)
(NonMyopicMemberRewards $ sreNonMyopicRewards))
, ("GenesisConfig", SomeResult GetGenesisConfig (compactGenesis sreShelleyGenesis))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import Ouroboros.Consensus.Protocol.TPraos (PraosCrypto, TPraos,
TPraosState (..))
import Ouroboros.Consensus.Shelley.Eras
import Ouroboros.Consensus.Shelley.Ledger
import Ouroboros.Consensus.Shelley.Ledger.Query.Types
import Ouroboros.Consensus.Shelley.Protocol.Praos ()
import Ouroboros.Consensus.Shelley.Protocol.TPraos ()
import Ouroboros.Network.Block (mkSerialised)
Expand Down Expand Up @@ -152,7 +153,7 @@ instance CanMock proto era => Arbitrary (SomeResult (ShelleyBlock proto era)) wh
, SomeResult <$> (GetNonMyopicMemberRewards <$> arbitrary) <*> arbitrary
, SomeResult GetCurrentPParams <$> arbitrary
, SomeResult GetProposedPParamsUpdates <$> arbitrary
, SomeResult GetStakeDistribution <$> arbitrary
, SomeResult GetStakeDistribution . fromLedgerPoolDistr <$> arbitrary
, SomeResult DebugEpochState <$> arbitrary
, (\(SomeResult q r) ->
SomeResult (GetCBOR q) (mkSerialised (encodeShelleyResult maxBound q) r)) <$>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!--
A new scriv changelog fragment.
Uncomment the section that is right (remove the HTML comment wrapper).
-->

### Patch

- Updated dependencies; no local changes required.

<!--
### Non-Breaking
- A bullet item for the Non-Breaking category.
-->
<!--
### Breaking
- A bullet item for the Breaking category.
-->
20 changes: 10 additions & 10 deletions ouroboros-consensus-diffusion/ouroboros-consensus-diffusion.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -84,20 +84,20 @@ library
contra-tracer,
deepseq,
filepath,
fs-api ^>=0.2,
fs-api ^>=0.2.0.1,
hashable,
io-classes ^>=1.4.1,
io-classes ^>=1.5,
mtl,
ouroboros-consensus ^>=0.18,
ouroboros-network ^>=0.16,
ouroboros-network-api ^>=0.7.2,
ouroboros-network-framework ^>=0.13,
ouroboros-network-protocols ^>=0.8.1,
ouroboros-network-api ^>=0.7.3,
ouroboros-network-framework ^>=0.13.2,
ouroboros-network-protocols ^>=0.9,
random,
safe-wild-cards ^>=1.0,
serialise ^>=0.2,
si-timers ^>=1.4,
strict-stm ^>=1.4,
si-timers ^>=1.5,
strict-stm ^>=1.5,
text,
time,
transformers,
Expand Down Expand Up @@ -133,7 +133,7 @@ library unstable-diffusion-testlib
containers,
contra-tracer,
fgl,
fs-sim ^>=0.2,
fs-sim ^>=0.2.1.1,
graphviz >=2999.20.1.0,
io-classes,
io-sim,
Expand Down Expand Up @@ -278,8 +278,8 @@ test-suite consensus-test
containers,
contra-tracer,
directory,
fs-api ^>=0.2,
fs-sim ^>=0.2,
fs-api ^>=0.2.0.1,
fs-sim ^>=0.2.1.1,
hashable,
io-classes,
io-sim,
Expand Down
Loading

0 comments on commit b128a6e

Please sign in to comment.