From d1c93c9e8a669f43dab41ad99e290b1c9336888c Mon Sep 17 00:00:00 2001 From: Neil Mayhew Date: Wed, 20 Nov 2024 14:18:58 -0700 Subject: [PATCH 1/8] Fix typo in documentation --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 46efafa548..23a77559d9 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -115,7 +115,7 @@ cabal run db-analyser To test all the packages in this repository run: ```sh -cabal build all +cabal test all ``` in the command line, either inside `nix-shell` if you use `nix`, or in a From 9d2b660b6c9515f4bd5f803cab8b00ffec2587d4 Mon Sep 17 00:00:00 2001 From: Neil Mayhew Date: Thu, 7 Nov 2024 21:35:45 -0700 Subject: [PATCH 2/8] Bump Hackage and CHaP indexes --- cabal.project | 4 ++-- flake.lock | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/cabal.project b/cabal.project index 5bc613b1a8..76af3b5684 100644 --- a/cabal.project +++ b/cabal.project @@ -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-10-22T14:26:27Z + , hackage.haskell.org 2024-12-10T16:20:07Z -- Bump this if you need newer packages from CHaP - , cardano-haskell-packages 2024-10-30T11:23:17Z + , cardano-haskell-packages 2024-12-18T14:29:04Z packages: ouroboros-consensus diff --git a/flake.lock b/flake.lock index e058c7b99c..8163ad1e65 100644 --- a/flake.lock +++ b/flake.lock @@ -3,11 +3,11 @@ "CHaP": { "flake": false, "locked": { - "lastModified": 1730295876, - "narHash": "sha256-ijnHTQ6eKIQ9FpEqDKt6c7vuFYN8aOBDhonp67utx2s=", + "lastModified": 1734535858, + "narHash": "sha256-9DzduMA63FdftXjZi5j2JKqxVnU8tC246w8N77MM1fs=", "owner": "intersectmbo", "repo": "cardano-haskell-packages", - "rev": "25591f43ab943d5a070db5e8a2b9ff3a499d4d92", + "rev": "9cc1161fab9bafb3d6b7ee28395a732519caf540", "type": "github" }, "original": { @@ -237,11 +237,11 @@ "hackageNix": { "flake": false, "locked": { - "lastModified": 1729643285, - "narHash": "sha256-2ukEfnphbVMpa6qJQ/h0O12e6wS9j+/w2mwE1YZQskI=", + "lastModified": 1733877006, + "narHash": "sha256-rNpSFS/ziUQBPgo6iAbKgU00yRpeCngv215TW0D+kCo=", "owner": "input-output-hk", "repo": "hackage.nix", - "rev": "e07df92046b89b0359d426c02848d96196ad60ec", + "rev": "583f569545854160b6bc5606374bf5006a9f6929", "type": "github" }, "original": { From 11cdea1e76b963d85794d406c7d6c0b266c466ca Mon Sep 17 00:00:00 2001 From: Neil Mayhew Date: Thu, 7 Nov 2024 22:49:51 -0700 Subject: [PATCH 3/8] cardano-ledger upgrade: bump ledger dependency bounds --- .../ouroboros-consensus-cardano.cabal | 18 +++++++++--------- .../ouroboros-consensus-protocol.cabal | 2 +- .../20241218_154808_neilmayhew_HEAD.md | 3 +++ ouroboros-consensus/ouroboros-consensus.cabal | 2 +- 4 files changed, 14 insertions(+), 11 deletions(-) create mode 100644 ouroboros-consensus/changelog.d/20241218_154808_neilmayhew_HEAD.md diff --git a/ouroboros-consensus-cardano/ouroboros-consensus-cardano.cabal b/ouroboros-consensus-cardano/ouroboros-consensus-cardano.cabal index df32ce0c7f..541bdd3179 100644 --- a/ouroboros-consensus-cardano/ouroboros-consensus-cardano.cabal +++ b/ouroboros-consensus-cardano/ouroboros-consensus-cardano.cabal @@ -135,17 +135,17 @@ library cardano-crypto-class, cardano-crypto-wrapper, cardano-ledger-allegra ^>=1.6, - cardano-ledger-alonzo ^>=1.11, - cardano-ledger-api ^>=1.9.3, + cardano-ledger-alonzo ^>=1.12, + cardano-ledger-api ^>=1.10, cardano-ledger-babbage ^>=1.10, - cardano-ledger-binary ^>=1.4, + cardano-ledger-binary ^>=1.5, cardano-ledger-byron ^>=1.0.1, - cardano-ledger-conway ^>=1.17.2, - cardano-ledger-core ^>=1.15, + cardano-ledger-conway ^>=1.18, + cardano-ledger-core ^>=1.16, cardano-ledger-mary ^>=1.7, - cardano-ledger-shelley ^>=1.14, + cardano-ledger-shelley ^>=1.15, cardano-prelude, - cardano-protocol-tpraos ^>=1.2, + cardano-protocol-tpraos ^>=1.3, cardano-slotting, cardano-strict-containers, cborg ^>=0.2.2, @@ -390,7 +390,7 @@ library unstable-cardano-testlib cardano-ledger-api, cardano-ledger-byron, cardano-ledger-conway:testlib, - cardano-ledger-conway-test >=1.2.1, + cardano-ledger-conway-test ^>=1.3, cardano-ledger-core:{cardano-ledger-core, testlib}, cardano-ledger-shelley, cardano-protocol-tpraos, @@ -535,7 +535,7 @@ library unstable-cardano-tools cardano-ledger-mary, cardano-ledger-shelley, cardano-prelude, - cardano-protocol-tpraos ^>=1.2, + cardano-protocol-tpraos ^>=1.3, cardano-slotting, cardano-strict-containers, cborg ^>=0.2.2, diff --git a/ouroboros-consensus-protocol/ouroboros-consensus-protocol.cabal b/ouroboros-consensus-protocol/ouroboros-consensus-protocol.cabal index 8e04317c92..b14f45cf0e 100644 --- a/ouroboros-consensus-protocol/ouroboros-consensus-protocol.cabal +++ b/ouroboros-consensus-protocol/ouroboros-consensus-protocol.cabal @@ -119,7 +119,7 @@ test-suite protocol-test base, cardano-crypto-class, cardano-ledger-binary:testlib, - cardano-ledger-core, + cardano-ledger-core ^>=1.16, containers, ouroboros-consensus:{ouroboros-consensus, unstable-consensus-testlib}, ouroboros-consensus-protocol, diff --git a/ouroboros-consensus/changelog.d/20241218_154808_neilmayhew_HEAD.md b/ouroboros-consensus/changelog.d/20241218_154808_neilmayhew_HEAD.md new file mode 100644 index 0000000000..803ab3d940 --- /dev/null +++ b/ouroboros-consensus/changelog.d/20241218_154808_neilmayhew_HEAD.md @@ -0,0 +1,3 @@ +### Patch + +* Remove upper bound on `cardano-ledger-core` diff --git a/ouroboros-consensus/ouroboros-consensus.cabal b/ouroboros-consensus/ouroboros-consensus.cabal index 774a787b19..2a5d2e6cda 100644 --- a/ouroboros-consensus/ouroboros-consensus.cabal +++ b/ouroboros-consensus/ouroboros-consensus.cabal @@ -278,7 +278,7 @@ library bytestring >=0.10 && <0.13, cardano-binary, cardano-crypto-class, - cardano-ledger-core ^>=1.15, + cardano-ledger-core ^>=1.16, cardano-prelude, cardano-slotting, cardano-strict-containers, From 8c2e36622b3cc389fe41eac151b703c118ffbffb Mon Sep 17 00:00:00 2001 From: Neil Mayhew Date: Tue, 19 Nov 2024 18:07:01 -0700 Subject: [PATCH 4/8] cardano-ledger upgrade: use modified ledger serialization API --- .../Consensus/Byron/Ledger/Serialisation.hs | 12 ++++++------ .../Ouroboros/Consensus/Shelley/Ledger/Block.hs | 12 ++++++------ .../Ouroboros/Consensus/Shelley/Ledger/Mempool.hs | 6 +++--- .../Shelley/Ledger/Query/PParamsLegacyEncoder.hs | 4 ++-- .../unstable-cardano-tools/Cardano/Api/KeysByron.hs | 2 +- .../Cardano/Api/OperationalCertificate.hs | 4 ++-- 6 files changed, 20 insertions(+), 20 deletions(-) diff --git a/ouroboros-consensus-cardano/src/byron/Ouroboros/Consensus/Byron/Ledger/Serialisation.hs b/ouroboros-consensus-cardano/src/byron/Ouroboros/Consensus/Byron/Ledger/Serialisation.hs index cbf986e979..43a9a42dfc 100644 --- a/ouroboros-consensus-cardano/src/byron/Ouroboros/Consensus/Byron/Ledger/Serialisation.hs +++ b/ouroboros-consensus-cardano/src/byron/Ouroboros/Consensus/Byron/Ledger/Serialisation.hs @@ -178,7 +178,7 @@ encodeByronBlock blk = mconcat [ -- | Inverse of 'encodeByronBlock' decodeByronBlock :: CC.EpochSlots -> Decoder s (Lazy.ByteString -> ByronBlock) decodeByronBlock epochSlots = - toPlainDecoder byronProtVer $ + toPlainDecoder Nothing byronProtVer $ flip (\bs -> mkByronBlock epochSlots . annotationBytes bs) <$> CC.decCBORABlockOrBoundary epochSlots @@ -195,7 +195,7 @@ decodeByronBlock epochSlots = decodeByronRegularBlock :: CC.EpochSlots -> Decoder s (Lazy.ByteString -> ByronBlock) decodeByronRegularBlock epochSlots = - toPlainDecoder byronProtVer $ + toPlainDecoder Nothing byronProtVer $ flip (\bs -> mkByronBlock epochSlots . annotationBytes bs . CC.ABOBBlock) @@ -213,7 +213,7 @@ decodeByronRegularBlock epochSlots = decodeByronBoundaryBlock :: CC.EpochSlots -> Decoder s (Lazy.ByteString -> ByronBlock) decodeByronBoundaryBlock epochSlots = - toPlainDecoder byronProtVer $ + toPlainDecoder Nothing byronProtVer $ flip (\bs -> mkByronBlock epochSlots . annotationBytes bs . CC.ABOBBoundary) @@ -231,7 +231,7 @@ decodeByronRegularHeader :: CC.EpochSlots -> Decoder s (Lazy.ByteString -> RawHeader) decodeByronRegularHeader epochSlots = - toPlainDecoder byronProtVer $ + toPlainDecoder Nothing byronProtVer $ flip annotationBytes <$> CC.decCBORAHeader epochSlots -- | Encodes a raw Byron EBB header /without/ a tag indicating whether it's a @@ -244,7 +244,7 @@ encodeByronBoundaryHeader = toByronCBOR . CBOR.encodePreEncoded . CC.boundaryHea -- | Inverse of 'encodeByronBoundaryHeader' decodeByronBoundaryHeader :: Decoder s (Lazy.ByteString -> RawBoundaryHeader) decodeByronBoundaryHeader = - toPlainDecoder byronProtVer $ + toPlainDecoder Nothing byronProtVer $ flip annotationBytes <$> CC.decCBORABoundaryHeader -- | The 'BinaryBlockInfo' of the given 'ByronBlock'. @@ -325,7 +325,7 @@ encodeUnsizedHeader (UnsizedHeader raw _ _) = toByronCBOR $ CC.encCBORABlockOrBo decodeUnsizedHeader :: CC.EpochSlots -> Decoder s (Lazy.ByteString -> UnsizedHeader) decodeUnsizedHeader epochSlots = - toPlainDecoder byronProtVer $ + toPlainDecoder Nothing byronProtVer $ fillInByteString <$> CC.decCBORABlockOrBoundaryHdr epochSlots where fillInByteString :: CC.ABlockOrBoundaryHdr ByteSpan diff --git a/ouroboros-consensus-cardano/src/shelley/Ouroboros/Consensus/Shelley/Ledger/Block.hs b/ouroboros-consensus-cardano/src/shelley/Ouroboros/Consensus/Shelley/Ledger/Block.hs index 9e5d96e50d..ba02b3e2d5 100644 --- a/ouroboros-consensus-cardano/src/shelley/Ouroboros/Consensus/Shelley/Ledger/Block.hs +++ b/ouroboros-consensus-cardano/src/shelley/Ouroboros/Consensus/Shelley/Ledger/Block.hs @@ -40,12 +40,12 @@ module Ouroboros.Consensus.Shelley.Ledger.Block ( import qualified Cardano.Crypto.Hash as Crypto import Cardano.Ledger.Binary (Annotator (..), DecCBOR (..), - EncCBOR (..), FullByteString (..), serialize, - toPlainDecoder) + EncCBOR (..), FullByteString (..), serialize) import qualified Cardano.Ledger.Binary.Plain as Plain -import Cardano.Ledger.Core as SL (eraProtVerLow, toEraCBOR) +import Cardano.Ledger.Core as SL (eraDecoder, eraProtVerLow, + toEraCBOR) +import qualified Cardano.Ledger.Core as SL (hashTxSeq) import Cardano.Ledger.Crypto (HASH) -import qualified Cardano.Ledger.Era as SL (hashTxSeq) import qualified Cardano.Ledger.Shelley.API as SL import qualified Cardano.Protocol.TPraos.BHeader as SL import qualified Data.ByteString.Lazy as Lazy @@ -274,7 +274,7 @@ encodeShelleyBlock = toEraCBOR @era decodeShelleyBlock :: forall proto era. ShelleyCompatible proto era => forall s. Plain.Decoder s (Lazy.ByteString -> ShelleyBlock proto era) -decodeShelleyBlock = toPlainDecoder (eraProtVerLow @era) $ (. Full) . runAnnotator <$> decCBOR +decodeShelleyBlock = eraDecoder @era $ (. Full) . runAnnotator <$> decCBOR shelleyBinaryBlockInfo :: forall proto era. ShelleyCompatible proto era => ShelleyBlock proto era -> BinaryBlockInfo shelleyBinaryBlockInfo blk = BinaryBlockInfo { @@ -293,7 +293,7 @@ encodeShelleyHeader = toEraCBOR @era decodeShelleyHeader :: forall proto era. ShelleyCompatible proto era => forall s. Plain.Decoder s (Lazy.ByteString -> Header (ShelleyBlock proto era)) -decodeShelleyHeader = toPlainDecoder (eraProtVerLow @era) $ (. Full) . runAnnotator <$> decCBOR +decodeShelleyHeader = eraDecoder @era $ (. Full) . runAnnotator <$> decCBOR {------------------------------------------------------------------------------- Condense diff --git a/ouroboros-consensus-cardano/src/shelley/Ouroboros/Consensus/Shelley/Ledger/Mempool.hs b/ouroboros-consensus-cardano/src/shelley/Ouroboros/Consensus/Shelley/Ledger/Mempool.hs index 9c4ff4cac8..db05ee8aa1 100644 --- a/ouroboros-consensus-cardano/src/shelley/Ouroboros/Consensus/Shelley/Ledger/Mempool.hs +++ b/ouroboros-consensus-cardano/src/shelley/Ouroboros/Consensus/Shelley/Ledger/Mempool.hs @@ -38,7 +38,7 @@ module Ouroboros.Consensus.Shelley.Ledger.Mempool ( import qualified Cardano.Crypto.Hash as Hash import qualified Cardano.Ledger.Allegra.Rules as AllegraEra -import Cardano.Ledger.Alonzo.Core (Tx, TxSeq, bodyTxL, eraProtVerLow, +import Cardano.Ledger.Alonzo.Core (Tx, TxSeq, bodyTxL, eraDecoder, fromTxSeq, ppMaxBBSizeL, ppMaxBlockExUnitsL, sizeTxF) import qualified Cardano.Ledger.Alonzo.Rules as AlonzoEra import Cardano.Ledger.Alonzo.Scripts (ExUnits, ExUnits', @@ -49,7 +49,7 @@ import qualified Cardano.Ledger.Babbage.Rules as BabbageEra import qualified Cardano.Ledger.BaseTypes as L import Cardano.Ledger.Binary (Annotator (..), DecCBOR (..), EncCBOR (..), FromCBOR (..), FullByteString (..), - ToCBOR (..), toPlainDecoder) + ToCBOR (..)) import qualified Cardano.Ledger.Conway.Rules as ConwayEra import qualified Cardano.Ledger.Conway.Rules as SL import qualified Cardano.Ledger.Conway.UTxO as SL @@ -199,7 +199,7 @@ instance ShelleyCompatible proto era => ToCBOR (GenTx (ShelleyBlock proto era)) instance ShelleyCompatible proto era => FromCBOR (GenTx (ShelleyBlock proto era)) where fromCBOR = fmap mkShelleyTx $ unwrapCBORinCBOR - $ toPlainDecoder (eraProtVerLow @era) $ (. Full) . runAnnotator <$> decCBOR + $ eraDecoder @era $ (. Full) . runAnnotator <$> decCBOR {------------------------------------------------------------------------------- Pretty-printing diff --git a/ouroboros-consensus-cardano/src/shelley/Ouroboros/Consensus/Shelley/Ledger/Query/PParamsLegacyEncoder.hs b/ouroboros-consensus-cardano/src/shelley/Ouroboros/Consensus/Shelley/Ledger/Query/PParamsLegacyEncoder.hs index 6194cc8b32..8914b8f251 100644 --- a/ouroboros-consensus-cardano/src/shelley/Ouroboros/Consensus/Shelley/Ledger/Query/PParamsLegacyEncoder.hs +++ b/ouroboros-consensus-cardano/src/shelley/Ouroboros/Consensus/Shelley/Ledger/Query/PParamsLegacyEncoder.hs @@ -103,7 +103,7 @@ instance Crypto c => ToCBOR (LegacyPParams (AlonzoEra c)) where instance Crypto c => FromCBOR (LegacyPParams (AlonzoEra c)) where fromCBOR = - toPlainDecoder (eraProtVerLow @(AlonzoEra c)) $ + eraDecoder @(AlonzoEra c) $ decode $ RecD mkLegacyAlonzoPParams ToCBOR (LegacyPParams (BabbageEra c)) where instance Crypto c => FromCBOR (LegacyPParams (BabbageEra c)) where fromCBOR = - toPlainDecoder (eraProtVerLow @(BabbageEra c)) $ + eraDecoder @(BabbageEra c) $ decode $ RecD mkLegacyBabbagePParams CBOR.deserialiseFromBytes decCBORXPrv (LB.fromStrict bs)) where - decCBORXPrv = toPlainDecoder byronProtVer Byron.decCBORXPrv + decCBORXPrv = toPlainDecoder Nothing byronProtVer Byron.decCBORXPrv newtype instance Hash ByronKey = ByronKeyHash Byron.KeyHash diff --git a/ouroboros-consensus-cardano/src/unstable-cardano-tools/Cardano/Api/OperationalCertificate.hs b/ouroboros-consensus-cardano/src/unstable-cardano-tools/Cardano/Api/OperationalCertificate.hs index f66cf4488b..9570a3175b 100644 --- a/ouroboros-consensus-cardano/src/unstable-cardano-tools/Cardano/Api/OperationalCertificate.hs +++ b/ouroboros-consensus-cardano/src/unstable-cardano-tools/Cardano/Api/OperationalCertificate.hs @@ -57,13 +57,13 @@ instance ToCBOR OperationalCertificate where toCBOR = CBOR.toPlainEncoding CBOR.shelleyProtVer . encCBOR instance FromCBOR OperationalCertificate where - fromCBOR = CBOR.toPlainDecoder CBOR.shelleyProtVer decCBOR + fromCBOR = CBOR.toPlainDecoder Nothing CBOR.shelleyProtVer decCBOR instance ToCBOR OperationalCertificateIssueCounter where toCBOR = CBOR.toPlainEncoding CBOR.shelleyProtVer . encCBOR instance FromCBOR OperationalCertificateIssueCounter where - fromCBOR = CBOR.toPlainDecoder CBOR.shelleyProtVer decCBOR + fromCBOR = CBOR.toPlainDecoder Nothing CBOR.shelleyProtVer decCBOR instance EncCBOR OperationalCertificate where encCBOR (OperationalCertificate ocert vkey) = From ea81b54d120a443105588d34536d811baf475c0d Mon Sep 17 00:00:00 2001 From: Neil Mayhew Date: Tue, 19 Nov 2024 18:08:25 -0700 Subject: [PATCH 5/8] cardano-ledger upgrade: use Cardano.Ledger.Core instead of Cardano.Ledger.Era --- .../Ouroboros/Consensus/Cardano/CanHardFork.hs | 2 +- .../src/shelley/Ouroboros/Consensus/Shelley/Ledger/Forge.hs | 2 +- .../Test/ThreadNet/Infra/ShelleyBasedHardFork.hs | 2 +- .../Test/Consensus/Shelley/Generators.hs | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ouroboros-consensus-cardano/src/ouroboros-consensus-cardano/Ouroboros/Consensus/Cardano/CanHardFork.hs b/ouroboros-consensus-cardano/src/ouroboros-consensus-cardano/Ouroboros/Consensus/Cardano/CanHardFork.hs index 8fb6bf08ec..d654335520 100644 --- a/ouroboros-consensus-cardano/src/ouroboros-consensus-cardano/Ouroboros/Consensus/Cardano/CanHardFork.hs +++ b/ouroboros-consensus-cardano/src/ouroboros-consensus-cardano/Ouroboros/Consensus/Cardano/CanHardFork.hs @@ -33,8 +33,8 @@ import qualified Cardano.Chain.Genesis as CC.Genesis import qualified Cardano.Chain.Update as CC.Update import Cardano.Crypto.DSIGN (Ed25519DSIGN) import Cardano.Crypto.Hash.Blake2b (Blake2b_224, Blake2b_256) +import qualified Cardano.Ledger.Core as SL import Cardano.Ledger.Crypto (ADDRHASH, Crypto, DSIGN, HASH) -import qualified Cardano.Ledger.Era as SL import qualified Cardano.Ledger.Genesis as SL import Cardano.Ledger.Hashes (EraIndependentTxBody) import Cardano.Ledger.Keys (DSignable, Hash) diff --git a/ouroboros-consensus-cardano/src/shelley/Ouroboros/Consensus/Shelley/Ledger/Forge.hs b/ouroboros-consensus-cardano/src/shelley/Ouroboros/Consensus/Shelley/Ledger/Forge.hs index bfcf43ee94..465ce54514 100644 --- a/ouroboros-consensus-cardano/src/shelley/Ouroboros/Consensus/Shelley/Ledger/Forge.hs +++ b/ouroboros-consensus-cardano/src/shelley/Ouroboros/Consensus/Shelley/Ledger/Forge.hs @@ -7,7 +7,7 @@ module Ouroboros.Consensus.Shelley.Ledger.Forge (forgeShelleyBlock) where import qualified Cardano.Ledger.Core as Core (Tx) -import qualified Cardano.Ledger.Era as SL (hashTxSeq, toTxSeq) +import qualified Cardano.Ledger.Core as SL (hashTxSeq, toTxSeq) import qualified Cardano.Ledger.Shelley.API as SL (Block (..), extractTx) import qualified Cardano.Ledger.Shelley.BlockChain as SL (bBodySize) import qualified Cardano.Protocol.TPraos.BHeader as SL diff --git a/ouroboros-consensus-cardano/src/unstable-cardano-testlib/Test/ThreadNet/Infra/ShelleyBasedHardFork.hs b/ouroboros-consensus-cardano/src/unstable-cardano-testlib/Test/ThreadNet/Infra/ShelleyBasedHardFork.hs index d4961835e0..924653fe61 100644 --- a/ouroboros-consensus-cardano/src/unstable-cardano-testlib/Test/ThreadNet/Infra/ShelleyBasedHardFork.hs +++ b/ouroboros-consensus-cardano/src/unstable-cardano-testlib/Test/ThreadNet/Infra/ShelleyBasedHardFork.hs @@ -28,7 +28,7 @@ module Test.ThreadNet.Infra.ShelleyBasedHardFork ( ) where import qualified Cardano.Ledger.Api.Transition as L -import qualified Cardano.Ledger.Era as SL +import qualified Cardano.Ledger.Core as SL import qualified Cardano.Ledger.Shelley.API as SL import Control.Monad.Except (runExcept) import qualified Data.Map.Strict as Map diff --git a/ouroboros-consensus-cardano/src/unstable-shelley-testlib/Test/Consensus/Shelley/Generators.hs b/ouroboros-consensus-cardano/src/unstable-shelley-testlib/Test/Consensus/Shelley/Generators.hs index d71bf21450..26fb068c45 100644 --- a/ouroboros-consensus-cardano/src/unstable-shelley-testlib/Test/Consensus/Shelley/Generators.hs +++ b/ouroboros-consensus-cardano/src/unstable-shelley-testlib/Test/Consensus/Shelley/Generators.hs @@ -11,8 +11,8 @@ module Test.Consensus.Shelley.Generators (SomeResult (..)) where +import Cardano.Ledger.Core (toTxSeq) import Cardano.Ledger.Crypto (Crypto) -import Cardano.Ledger.Era (toTxSeq) import qualified Cardano.Ledger.Shelley.API as SL import qualified Cardano.Protocol.TPraos.API as SL import qualified Cardano.Protocol.TPraos.BHeader as SL From a36a72f0ed7bf03b1cd89519a00140cfe399b52c Mon Sep 17 00:00:00 2001 From: Neil Mayhew Date: Tue, 19 Nov 2024 18:10:30 -0700 Subject: [PATCH 6/8] cardano-ledger upgrade: use new predicate failure API with Mismatch --- .../Consensus/Shelley/Ledger/Mempool.hs | 58 ++++++++++++------- 1 file changed, 38 insertions(+), 20 deletions(-) diff --git a/ouroboros-consensus-cardano/src/shelley/Ouroboros/Consensus/Shelley/Ledger/Mempool.hs b/ouroboros-consensus-cardano/src/shelley/Ouroboros/Consensus/Shelley/Ledger/Mempool.hs index db05ee8aa1..ad6f439ad0 100644 --- a/ouroboros-consensus-cardano/src/shelley/Ouroboros/Consensus/Shelley/Ledger/Mempool.hs +++ b/ouroboros-consensus-cardano/src/shelley/Ouroboros/Consensus/Shelley/Ledger/Mempool.hs @@ -353,41 +353,51 @@ instance MaxTxSizeUTxO (ShelleyEra c) where , mismatchExpected = txSizeLimit } instance MaxTxSizeUTxO (AllegraEra c) where - maxTxSizeUTxO x y = + maxTxSizeUTxO txSize txSizeLimit = SL.ApplyTxError . pure $ ShelleyEra.UtxowFailure $ ShelleyEra.UtxoFailure - $ AllegraEra.MaxTxSizeUTxO x y + $ AllegraEra.MaxTxSizeUTxO + $ L.Mismatch { mismatchSupplied = txSize + , mismatchExpected = txSizeLimit } instance MaxTxSizeUTxO (MaryEra c) where - maxTxSizeUTxO x y = + maxTxSizeUTxO txSize txSizeLimit = SL.ApplyTxError . pure $ ShelleyEra.UtxowFailure $ ShelleyEra.UtxoFailure - $ AllegraEra.MaxTxSizeUTxO x y + $ AllegraEra.MaxTxSizeUTxO + $ L.Mismatch { mismatchSupplied = txSize + , mismatchExpected = txSizeLimit } instance MaxTxSizeUTxO (AlonzoEra c) where - maxTxSizeUTxO x y = + maxTxSizeUTxO txSize txSizeLimit = SL.ApplyTxError . pure $ ShelleyEra.UtxowFailure $ AlonzoEra.ShelleyInAlonzoUtxowPredFailure $ ShelleyEra.UtxoFailure - $ AlonzoEra.MaxTxSizeUTxO x y + $ AlonzoEra.MaxTxSizeUTxO + $ L.Mismatch { mismatchSupplied = txSize + , mismatchExpected = txSizeLimit } instance MaxTxSizeUTxO (BabbageEra c) where - maxTxSizeUTxO x y = + maxTxSizeUTxO txSize txSizeLimit = SL.ApplyTxError . pure $ ShelleyEra.UtxowFailure $ BabbageEra.UtxoFailure $ BabbageEra.AlonzoInBabbageUtxoPredFailure - $ AlonzoEra.MaxTxSizeUTxO x y + $ AlonzoEra.MaxTxSizeUTxO + $ L.Mismatch { mismatchSupplied = txSize + , mismatchExpected = txSizeLimit } instance MaxTxSizeUTxO (ConwayEra c) where - maxTxSizeUTxO x y = + maxTxSizeUTxO txSize txSizeLimit = SL.ApplyTxError . pure $ ConwayEra.ConwayUtxowFailure $ ConwayEra.UtxoFailure - $ ConwayEra.MaxTxSizeUTxO x y + $ ConwayEra.MaxTxSizeUTxO + $ L.Mismatch { mismatchSupplied = txSize + , mismatchExpected = txSizeLimit } ----- @@ -455,7 +465,7 @@ txMeasureAlonzo st tx@(ShelleyTx _txid tx') = limit = pparams ^. L.ppMaxTxExUnitsL exunits = - validateMaybe (exUnitsTooBigUTxO limit txsz) $ do + validateMaybe (exUnitsTooBigUTxO txsz limit) $ do guard $ pointWiseExUnits (<=) txsz limit Just $ fromExUnits txsz @@ -463,29 +473,35 @@ class ExUnitsTooBigUTxO era where exUnitsTooBigUTxO :: ExUnits -> ExUnits -> SL.ApplyTxError era instance Crypto c => ExUnitsTooBigUTxO (AlonzoEra c) where - exUnitsTooBigUTxO x y = + exUnitsTooBigUTxO txsz limit = SL.ApplyTxError . pure $ ShelleyEra.UtxowFailure $ AlonzoEra.ShelleyInAlonzoUtxowPredFailure $ ShelleyEra.UtxoFailure - $ AlonzoEra.ExUnitsTooBigUTxO x y + $ AlonzoEra.ExUnitsTooBigUTxO + $ L.Mismatch { mismatchSupplied = txsz + , mismatchExpected = limit } instance Crypto c => ExUnitsTooBigUTxO (BabbageEra c) where - exUnitsTooBigUTxO x y = + exUnitsTooBigUTxO txsz limit = SL.ApplyTxError . pure $ ShelleyEra.UtxowFailure $ BabbageEra.AlonzoInBabbageUtxowPredFailure $ AlonzoEra.ShelleyInAlonzoUtxowPredFailure $ ShelleyEra.UtxoFailure $ BabbageEra.AlonzoInBabbageUtxoPredFailure - $ AlonzoEra.ExUnitsTooBigUTxO x y + $ AlonzoEra.ExUnitsTooBigUTxO + $ L.Mismatch { mismatchSupplied = txsz + , mismatchExpected = limit } instance Crypto c => ExUnitsTooBigUTxO (ConwayEra c) where - exUnitsTooBigUTxO x y = + exUnitsTooBigUTxO txsz limit = SL.ApplyTxError . pure $ ConwayEra.ConwayUtxowFailure $ ConwayEra.UtxoFailure - $ ConwayEra.ExUnitsTooBigUTxO x y + $ ConwayEra.ExUnitsTooBigUTxO + $ L.Mismatch { mismatchSupplied = txsz + , mismatchExpected = limit } ----- @@ -546,7 +562,7 @@ txMeasureConway st tx@(ShelleyTx _txid tx') = limit = SL.maxRefScriptSizePerTx refScriptBytes = - validateMaybe (txRefScriptsSizeTooBig limit txsz) $ do + validateMaybe (txRefScriptsSizeTooBig txsz limit) $ do guard $ txsz <= limit Just $ IgnoringOverflow $ ByteSize32 $ fromIntegral txsz @@ -554,9 +570,11 @@ class TxRefScriptsSizeTooBig era where txRefScriptsSizeTooBig :: Int -> Int -> SL.ApplyTxError era instance Crypto c => TxRefScriptsSizeTooBig (ConwayEra c) where - txRefScriptsSizeTooBig x y = + txRefScriptsSizeTooBig txsz limit = SL.ApplyTxError . pure - $ ConwayEra.ConwayTxRefScriptsSizeTooBig x y + $ ConwayEra.ConwayTxRefScriptsSizeTooBig + $ L.Mismatch { mismatchSupplied = txsz + , mismatchExpected = limit } ----- From 66f181200284b21f578485eb456264577d2f6ec8 Mon Sep 17 00:00:00 2001 From: Neil Mayhew Date: Thu, 28 Nov 2024 18:19:06 -0700 Subject: [PATCH 7/8] cardano-ledger upgrade: accommodate new ledgerSlotNo field in LedgerEnv --- .../unstable-shelley-testlib/Test/ThreadNet/TxGen/Shelley.hs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ouroboros-consensus-cardano/src/unstable-shelley-testlib/Test/ThreadNet/TxGen/Shelley.hs b/ouroboros-consensus-cardano/src/unstable-shelley-testlib/Test/ThreadNet/TxGen/Shelley.hs index 732c8726dc..90d8dd5dad 100644 --- a/ouroboros-consensus-cardano/src/unstable-shelley-testlib/Test/ThreadNet/TxGen/Shelley.hs +++ b/ouroboros-consensus-cardano/src/unstable-shelley-testlib/Test/ThreadNet/TxGen/Shelley.hs @@ -103,8 +103,9 @@ genTx _cfg slotNo TickedShelleyLedgerState { tickedShelleyLedgerState } genEnv = epochState = SL.nesEs tickedShelleyLedgerState ledgerEnv :: SL.LedgerEnv (MockShelley h) - ledgerEnv = SL.LedgerEnv { - ledgerSlotNo = slotNo + ledgerEnv = SL.LedgerEnv + { ledgerEpochNo = Nothing + , ledgerSlotNo = slotNo , ledgerIx = minBound , ledgerPp = getPParams tickedShelleyLedgerState , ledgerAccount = SL.esAccountState epochState From 0d65a19d64eaa8ae44b1819b39d5e0a43497f6b1 Mon Sep 17 00:00:00 2001 From: Neil Mayhew Date: Thu, 28 Nov 2024 17:36:27 -0700 Subject: [PATCH 8/8] cardano-ledger upgrade: accommodate the new VRFVerKeyHash type --- .../20241128_174448_neilmayhew_release_srp.md | 3 +++ .../Consensus/Shelley/Ledger/Query/Types.hs | 4 ++-- .../Ouroboros/Consensus/Shelley/Node/TPraos.hs | 2 +- .../Cardano/Api/KeysPraos.hs | 2 +- .../Cardano/Tools/Headers.hs | 5 ++--- .../Test/ThreadNet/Infra/Shelley.hs | 16 ++++++++-------- ...0241218_141944_neilmayhew_integrate_ledger.md | 3 +++ .../Ouroboros/Consensus/Protocol/Praos.hs | 7 ++++--- .../Ouroboros/Consensus/Protocol/TPraos.hs | 2 +- 9 files changed, 25 insertions(+), 19 deletions(-) create mode 100644 ouroboros-consensus-cardano/changelog.d/20241128_174448_neilmayhew_release_srp.md create mode 100644 ouroboros-consensus-protocol/changelog.d/20241218_141944_neilmayhew_integrate_ledger.md diff --git a/ouroboros-consensus-cardano/changelog.d/20241128_174448_neilmayhew_release_srp.md b/ouroboros-consensus-cardano/changelog.d/20241128_174448_neilmayhew_release_srp.md new file mode 100644 index 0000000000..460c2a2c40 --- /dev/null +++ b/ouroboros-consensus-cardano/changelog.d/20241128_174448_neilmayhew_release_srp.md @@ -0,0 +1,3 @@ +### Breaking + +- Change the type of the `mkKeyHashVrf` function to use the new `VRFVerKeyHash` ledger type. diff --git a/ouroboros-consensus-cardano/src/shelley/Ouroboros/Consensus/Shelley/Ledger/Query/Types.hs b/ouroboros-consensus-cardano/src/shelley/Ouroboros/Consensus/Shelley/Ledger/Query/Types.hs index e1c754e519..c996af7dc2 100644 --- a/ouroboros-consensus-cardano/src/shelley/Ouroboros/Consensus/Shelley/Ledger/Query/Types.hs +++ b/ouroboros-consensus-cardano/src/shelley/Ouroboros/Consensus/Shelley/Ledger/Query/Types.hs @@ -20,8 +20,8 @@ import Cardano.Ledger.Binary (DecCBOR (..), EncCBOR (..), decodeRecordNamed, encodeListLen) import Cardano.Ledger.Crypto (Crypto) import Cardano.Ledger.Keys (Hash) +import qualified Cardano.Ledger.Keys as SL 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) @@ -39,7 +39,7 @@ data IndividualPoolStake c = IndividualPoolStake { fromLedgerIndividualPoolStake :: SL.IndividualPoolStake c -> IndividualPoolStake c fromLedgerIndividualPoolStake ips = IndividualPoolStake { individualPoolStake = SL.individualPoolStake ips - , individualPoolStakeVrf = SL.individualPoolStakeVrf ips + , individualPoolStakeVrf = SL.fromVRFVerKeyHash $ SL.individualPoolStakeVrf ips } instance Crypto c => EncCBOR (IndividualPoolStake c) where diff --git a/ouroboros-consensus-cardano/src/shelley/Ouroboros/Consensus/Shelley/Node/TPraos.hs b/ouroboros-consensus-cardano/src/shelley/Ouroboros/Consensus/Shelley/Node/TPraos.hs index 44d13dee75..82e5698885 100644 --- a/ouroboros-consensus-cardano/src/shelley/Ouroboros/Consensus/Shelley/Node/TPraos.hs +++ b/ouroboros-consensus-cardano/src/shelley/Ouroboros/Consensus/Shelley/Node/TPraos.hs @@ -148,7 +148,7 @@ shelleySharedBlockForging hotKey slotToPeriod credentials = forgingVRFHash :: SL.Hash c (SL.VerKeyVRF c) forgingVRFHash = - SL.hashVerKeyVRF + VRF.hashVerKeyVRF . VRF.deriveVerKeyVRF . praosCanBeLeaderSignKeyVRF $ canBeLeader diff --git a/ouroboros-consensus-cardano/src/unstable-cardano-tools/Cardano/Api/KeysPraos.hs b/ouroboros-consensus-cardano/src/unstable-cardano-tools/Cardano/Api/KeysPraos.hs index 5dd33d6dff..153f0a3cd5 100644 --- a/ouroboros-consensus-cardano/src/unstable-cardano-tools/Cardano/Api/KeysPraos.hs +++ b/ouroboros-consensus-cardano/src/unstable-cardano-tools/Cardano/Api/KeysPraos.hs @@ -178,7 +178,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) = diff --git a/ouroboros-consensus-cardano/src/unstable-cardano-tools/Cardano/Tools/Headers.hs b/ouroboros-consensus-cardano/src/unstable-cardano-tools/Cardano/Tools/Headers.hs index f98b8b60c5..3376c36563 100644 --- a/ouroboros-consensus-cardano/src/unstable-cardano-tools/Cardano/Tools/Headers.hs +++ b/ouroboros-consensus-cardano/src/unstable-cardano-tools/Cardano/Tools/Headers.hs @@ -12,12 +12,11 @@ module Cardano.Tools.Headers ( ) where import Cardano.Crypto.DSIGN (deriveVerKeyDSIGN) -import Cardano.Crypto.VRF - (VRFAlgorithm (deriveVerKeyVRF, hashVerKeyVRF)) +import Cardano.Crypto.VRF (VRFAlgorithm (deriveVerKeyVRF)) import Cardano.Ledger.Api (ConwayEra, StandardCrypto) import Cardano.Ledger.Coin (Coin (..)) import Cardano.Ledger.Compactible (toCompact) -import Cardano.Ledger.Keys (VKey (..), hashKey) +import Cardano.Ledger.Keys (VKey (..), hashKey, hashVerKeyVRF) import Cardano.Ledger.PoolDistr (IndividualPoolStake (..)) import Cardano.Prelude (ExitCode (..), exitWith, forM_, hPutStrLn, stderr) diff --git a/ouroboros-consensus-cardano/src/unstable-shelley-testlib/Test/ThreadNet/Infra/Shelley.hs b/ouroboros-consensus-cardano/src/unstable-shelley-testlib/Test/ThreadNet/Infra/Shelley.hs index 2ca053c7a8..b67594b964 100644 --- a/ouroboros-consensus-cardano/src/unstable-shelley-testlib/Test/ThreadNet/Infra/Shelley.hs +++ b/ouroboros-consensus-cardano/src/unstable-shelley-testlib/Test/ThreadNet/Infra/Shelley.hs @@ -36,18 +36,18 @@ module Test.ThreadNet.Infra.Shelley ( ) where import Cardano.Crypto.DSIGN (DSIGNAlgorithm (..), seedSizeDSIGN) -import Cardano.Crypto.Hash (Hash, HashAlgorithm) +import Cardano.Crypto.Hash (HashAlgorithm) import Cardano.Crypto.KES (KESAlgorithm (..)) import Cardano.Crypto.Seed (mkSeedFromBytes) import qualified Cardano.Crypto.Seed as Cardano.Crypto -import Cardano.Crypto.VRF (SignKeyVRF, VRFAlgorithm, VerKeyVRF, - deriveVerKeyVRF, genKeyVRF, seedSizeVRF) +import Cardano.Crypto.VRF (SignKeyVRF, deriveVerKeyVRF, genKeyVRF, + seedSizeVRF) import qualified Cardano.Ledger.Allegra.Scripts as SL import Cardano.Ledger.Alonzo (AlonzoEra) import Cardano.Ledger.BaseTypes (boundRational) import Cardano.Ledger.Crypto (Crypto, DSIGN, HASH, KES, VRF) import Cardano.Ledger.Hashes (EraIndependentTxBody) -import qualified Cardano.Ledger.Keys +import qualified Cardano.Ledger.Keys as LK import qualified Cardano.Ledger.Mary.Core as SL import Cardano.Ledger.SafeHash (HashAnnotated (..), SafeHash, hashAnnotated) @@ -182,7 +182,7 @@ genCoreNode startKESPeriod = do vrfKey <- genKeyVRF <$> genSeed (seedSizeVRF (Proxy @(VRF c))) kesKey <- genKeyKES <$> genSeed (seedSizeKES (Proxy @(KES c))) let kesPub = deriveVerKeyKES kesKey - sigma = Cardano.Ledger.Keys.signedDSIGN + sigma = LK.signedDSIGN @c delKey (SL.OCertSignable kesPub certificateIssueNumber startKESPeriod) @@ -522,9 +522,9 @@ mkVerKey = SL.VKey . deriveVerKeyDSIGN mkKeyPair :: Crypto c => SL.SignKeyDSIGN c -> TL.KeyPair r c mkKeyPair sk = TL.KeyPair { vKey = mkVerKey sk, sKey = sk } -mkKeyHashVrf :: (HashAlgorithm h, VRFAlgorithm vrf) - => SignKeyVRF vrf - -> Hash h (VerKeyVRF vrf) +mkKeyHashVrf :: Crypto c + => SignKeyVRF (VRF c) + -> LK.VRFVerKeyHash (r :: LK.KeyRoleVRF) c mkKeyHashVrf = SL.hashVerKeyVRF . deriveVerKeyVRF networkId :: SL.Network diff --git a/ouroboros-consensus-protocol/changelog.d/20241218_141944_neilmayhew_integrate_ledger.md b/ouroboros-consensus-protocol/changelog.d/20241218_141944_neilmayhew_integrate_ledger.md new file mode 100644 index 0000000000..bdaf678e9f --- /dev/null +++ b/ouroboros-consensus-protocol/changelog.d/20241218_141944_neilmayhew_integrate_ledger.md @@ -0,0 +1,3 @@ +### Patch + +* Use the `VRFVerKeyHash` type from `cardano-ledger-core-1.16` diff --git a/ouroboros-consensus-protocol/src/ouroboros-consensus-protocol/Ouroboros/Consensus/Protocol/Praos.hs b/ouroboros-consensus-protocol/src/ouroboros-consensus-protocol/Ouroboros/Consensus/Protocol/Praos.hs index 3ddbcf200b..ce8bcdb08e 100644 --- a/ouroboros-consensus-protocol/src/ouroboros-consensus-protocol/Ouroboros/Consensus/Protocol/Praos.hs +++ b/ouroboros-consensus-protocol/src/ouroboros-consensus-protocol/Ouroboros/Consensus/Protocol/Praos.hs @@ -37,7 +37,6 @@ module Ouroboros.Consensus.Protocol.Praos ( import Cardano.Binary (FromCBOR (..), ToCBOR (..), enforceSize) import qualified Cardano.Crypto.DSIGN as DSIGN import qualified Cardano.Crypto.KES as KES -import Cardano.Crypto.VRF (hashVerKeyVRF) import qualified Cardano.Crypto.VRF as VRF import Cardano.Ledger.BaseTypes (ActiveSlotCoeff, Nonce, (⭒)) import qualified Cardano.Ledger.BaseTypes as SL @@ -548,8 +547,10 @@ doValidateVRFSignature eta0 pd f b = do case Map.lookup hk pd of Nothing -> throwError $ VRFKeyUnknown hk Just (IndividualPoolStake sigma _totalPoolStake vrfHK) -> do - vrfHK == hashVerKeyVRF vrfK - ?! VRFKeyWrongVRFKey hk vrfHK (hashVerKeyVRF vrfK) + let vrfHKStake = SL.fromVRFVerKeyHash vrfHK + vrfHKBlock = VRF.hashVerKeyVRF vrfK + vrfHKStake == vrfHKBlock + ?! VRFKeyWrongVRFKey hk vrfHKStake vrfHKBlock VRF.verifyCertified () vrfK diff --git a/ouroboros-consensus-protocol/src/ouroboros-consensus-protocol/Ouroboros/Consensus/Protocol/TPraos.hs b/ouroboros-consensus-protocol/src/ouroboros-consensus-protocol/Ouroboros/Consensus/Protocol/TPraos.hs index 37a9475a8b..43529217bc 100644 --- a/ouroboros-consensus-protocol/src/ouroboros-consensus-protocol/Ouroboros/Consensus/Protocol/TPraos.hs +++ b/ouroboros-consensus-protocol/src/ouroboros-consensus-protocol/Ouroboros/Consensus/Protocol/TPraos.hs @@ -324,7 +324,7 @@ instance SL.PraosCrypto c => ConsensusProtocol (TPraos c) where -- the overlay schedule, so we could set it to whatever we -- want. We evaluate it as normal for simplicity's sake. , tpraosIsLeaderProof = coerce y - , tpraosIsLeaderGenVRFHash = Just genDlgVRFHash + , tpraosIsLeaderGenVRFHash = Just $ SL.fromVRFVerKeyHash genDlgVRFHash } | otherwise -> Nothing