From 1dff40608a4c2e52970fee0e9c0b90ce1328f93b Mon Sep 17 00:00:00 2001 From: Georgy Lukyanov Date: Mon, 8 Dec 2025 17:33:25 +0100 Subject: [PATCH 01/32] [wip] Add s-r-ps on Consensus, Ledger and Network --- cabal.project | 58 ++++++++++++++++++++++++++++++++++- cardano-api/cardano-api.cabal | 30 +++++++++--------- flake.lock | 6 ++-- 3 files changed, 76 insertions(+), 18 deletions(-) diff --git a/cabal.project b/cabal.project index cc71f29c10..4450b71dd6 100644 --- a/cabal.project +++ b/cabal.project @@ -13,7 +13,7 @@ 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 2025-12-02T22:23:29Z + , hackage.haskell.org 2025-12-03T15:53:31Z , cardano-haskell-packages 2026-01-24T11:25:12Z packages: @@ -164,3 +164,59 @@ if arch(wasm32) -- IMPORTANT -- Do NOT add more source-repository-package stanzas here unless they are strictly -- temporary! Please read the section in CONTRIBUTING about updating dependencies. + +source-repository-package + type: git + location: https://github.com/IntersectMBO/cardano-ledger + tag: 71ec2758703b75b5a6187438a08eb3386773850e + --sha256: sha256-elIA+esNslfejQEuoYszrG7MkKJVc1AulUBDSIIEUEo= + subdir: + eras/allegra/impl + eras/alonzo/impl + eras/alonzo/test-suite + eras/babbage/impl + eras/byron/chain/executable-spec + eras/byron/crypto + eras/byron/ledger/executable-spec + eras/byron/ledger/impl + eras/conway/impl + eras/dijkstra/impl + eras/mary/impl + eras/shelley-ma/test-suite + eras/shelley/impl + eras/shelley/test-suite + libs/cardano-data + libs/cardano-ledger-api + libs/cardano-ledger-binary + libs/cardano-ledger-core + libs/cardano-protocol-tpraos + libs/non-integral + libs/plutus-preprocessor + libs/small-steps + libs/vector-map + +source-repository-package + type: git + location: https://github.com/IntersectMBO/ouroboros-consensus + tag: c6c00805ea5b450e16efdfe22a3b3b6f3a360c82 + --sha256: sha256-DtiaTJI5uAt4CZEv/OBsv8SSv9/OwK1wm2mMPn56XJE= + subdir: + ouroboros-consensus + ouroboros-consensus-cardano + ouroboros-consensus-diffusion + ouroboros-consensus-protocol + strict-sop-core + sop-extras + +-- Backported version of https://github.com/IntersectMBO/ouroboros-network/pull/5161 +source-repository-package + type: git + location: https://github.com/IntersectMBO/ouroboros-network + tag: 1385b53cefb81e79553b6b0252537455833ea9c4 + --sha256: sha256-zZ7WsMfRs1fG16bmvI5vIh4fhQ8RGyEvYGLSWlrxpg0= + subdir: + ouroboros-network-api + ouroboros-network + ouroboros-network-framework + ouroboros-network-mock + ouroboros-network-protocols diff --git a/cardano-api/cardano-api.cabal b/cardano-api/cardano-api.cabal index 8b994a8153..184f08e8a3 100644 --- a/cardano-api/cardano-api.cabal +++ b/cardano-api/cardano-api.cabal @@ -127,16 +127,16 @@ library cardano-binary, cardano-crypto, cardano-crypto-class ^>=2.2.3.2, - cardano-crypto-wrapper ^>=1.6, + cardano-crypto-wrapper ^>=1.7, cardano-data >=1.0, cardano-ledger-allegra >=1.7, cardano-ledger-alonzo >=1.13, - cardano-ledger-api ^>=1.12.1, + cardano-ledger-api ^>=1.13, cardano-ledger-babbage >=1.11, cardano-ledger-binary >=1.6, cardano-ledger-byron >=1.2, cardano-ledger-conway >=1.19, - cardano-ledger-core >=1.17 && <1.19, + cardano-ledger-core >=1.17 && <1.20, cardano-ledger-dijkstra >=0.1, cardano-ledger-mary >=1.8, cardano-ledger-shelley >=1.16, @@ -158,7 +158,7 @@ library groups, iproute, memory, - microlens, + microlens <0.5, mono-traversable, mtl, network, @@ -324,14 +324,16 @@ library gen base16-bytestring, bytestring, cardano-api, - cardano-binary >=1.6 && <1.8, - cardano-crypto-class, - cardano-crypto-test ^>=1.6, - cardano-ledger-alonzo:{cardano-ledger-alonzo, testlib} >=1.8.1, - cardano-ledger-byron:testlib, - cardano-ledger-conway:testlib, - cardano-ledger-core:{cardano-ledger-core, testlib} >=1.14, - cardano-ledger-dijkstra:testlib >=0.1, + cardano-binary >=1.6 && <1.9, + cardano-crypto-class ^>=2.2.1, + cardano-crypto-wrapper:{cardano-crypto-wrapper, testlib} ^>=1.7, + cardano-ledger-alonzo >=1.8.1, + cardano-ledger-babbage, + cardano-ledger-byron, + cardano-ledger-conway, + cardano-ledger-core >=1.14, + cardano-ledger-dijkstra >=0.1, + cardano-ledger-mary, cardano-ledger-shelley >=1.13, cardano-strict-containers, containers, @@ -366,7 +368,7 @@ test-suite cardano-api-test cardano-crypto-tests ^>=2.2, cardano-crypto-wrapper:testlib, cardano-ledger-alonzo, - cardano-ledger-api ^>=1.12.1, + cardano-ledger-api ^>=1.13, cardano-ledger-binary, cardano-ledger-conway, cardano-ledger-core >=1.14, @@ -442,7 +444,7 @@ test-suite cardano-api-golden cardano-crypto-class, cardano-data >=1.0, cardano-ledger-alonzo, - cardano-ledger-api ^>=1.12.1, + cardano-ledger-api ^>=1.13, cardano-ledger-binary, cardano-ledger-core >=1.14, cardano-ledger-shelley, diff --git a/flake.lock b/flake.lock index 8f342f2bc4..610528df0e 100644 --- a/flake.lock +++ b/flake.lock @@ -281,11 +281,11 @@ "hackageNix": { "flake": false, "locked": { - "lastModified": 1764721618, - "narHash": "sha256-qayd4uIJ1PU3TWnm4ExC8WmLBUo8/4LL9QEWngiaz24=", + "lastModified": 1765278254, + "narHash": "sha256-qDZRP4OeexvTgYI+rQDxPbRndM0fBh0AgCuJ/D6df4c=", "owner": "input-output-hk", "repo": "hackage.nix", - "rev": "1b943b3cd91ffdaa62da6fe5870b7c7cfca30729", + "rev": "3be6f76c573b49280512d238fc49ca80fb70cfa9", "type": "github" }, "original": { From 876c808e781742f151f1b38f8445bfac61ac180f Mon Sep 17 00:00:00 2001 From: Georgy Lukyanov Date: Tue, 9 Dec 2025 13:47:25 +0100 Subject: [PATCH 02/32] [wip] integrate new Ledger --- cardano-api/src/Cardano/Api/Genesis/Internal.hs | 10 +++++----- .../Cardano/Api/Internal/Orphans/Serialisation.hs | 2 ++ .../src/Cardano/Api/Ledger/Internal/Reexport.hs | 12 ++++-------- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/cardano-api/src/Cardano/Api/Genesis/Internal.hs b/cardano-api/src/Cardano/Api/Genesis/Internal.hs index f8761b32df..773d72e6da 100644 --- a/cardano-api/src/Cardano/Api/Genesis/Internal.hs +++ b/cardano-api/src/Cardano/Api/Genesis/Internal.hs @@ -42,7 +42,7 @@ import Cardano.Api.IO import Cardano.Chain.Genesis qualified import Cardano.Crypto.Hash.Blake2b qualified import Cardano.Crypto.Hash.Class qualified -import Cardano.Ledger.Alonzo.Genesis (AlonzoGenesis (..)) +import Cardano.Ledger.Alonzo.Genesis (AlonzoGenesis (..), AlonzoExtraConfig(..)) import Cardano.Ledger.Alonzo.Scripts (ExUnits (..), Prices (..)) import Cardano.Ledger.Api (CoinPerWord (..)) import Cardano.Ledger.BaseTypes as Ledger @@ -358,9 +358,10 @@ alonzoGenesisDefaults = { exUnitsMem = 62000000 , exUnitsSteps = 20000000000 } - , agCostModels = errorFail apiCostModels + , agPlutusV1CostModel = either (error . show) id (L.mkCostModel PlutusV1 defaultV1CostModel) , agCollateralPercentage = 150 , agCoinsPerUTxOWord = CoinPerWord $ Coin 34482 + , agExtraConfig = Just . AlonzoExtraConfig . Just $ errorFail apiCostModels } where apiCostModels = @@ -369,8 +370,7 @@ alonzoGenesisDefaults = [ (fromIntegral $ fromEnum PlutusV1, defaultV1CostModel) , (fromIntegral $ fromEnum PlutusV2, defaultV2CostModel) ] - where - defaultV1CostModel = + defaultV1CostModel = [ 205665 , 812 , 1 @@ -538,7 +538,7 @@ alonzoGenesisDefaults = , 18975 , 10 ] - defaultV2CostModel = + defaultV2CostModel = [ 205665 , 812 , 1 diff --git a/cardano-api/src/Cardano/Api/Internal/Orphans/Serialisation.hs b/cardano-api/src/Cardano/Api/Internal/Orphans/Serialisation.hs index 6909516e96..de0d2cced8 100644 --- a/cardano-api/src/Cardano/Api/Internal/Orphans/Serialisation.hs +++ b/cardano-api/src/Cardano/Api/Internal/Orphans/Serialisation.hs @@ -198,6 +198,8 @@ deriving anyclass instance ToJSON L.Voting.Error deriving anyclass instance ToJSON L.VotingPeriod +deriving anyclass instance ToJSON L.Withdrawals + deriving anyclass instance ( ToJSON (L.PredicateFailure (L.EraRule "UTXOW" ledgerera)) , ToJSON (L.PredicateFailure (L.EraRule "DELEGS" ledgerera)) diff --git a/cardano-api/src/Cardano/Api/Ledger/Internal/Reexport.hs b/cardano-api/src/Cardano/Api/Ledger/Internal/Reexport.hs index 54ddd9f789..81d6afffa6 100644 --- a/cardano-api/src/Cardano/Api/Ledger/Internal/Reexport.hs +++ b/cardano-api/src/Cardano/Api/Ledger/Internal/Reexport.hs @@ -15,11 +15,10 @@ module Cardano.Api.Ledger.Internal.Reexport , StakeReference (..) , WitVKey (..) , hashKey - , hashVerKeyVRF , hashWithSerialiser , fromVRFVerKeyHash , toVRFVerKeyHash - , PoolParams (..) + , StakePoolParams (..) , HasKeyRole , MIRPot (..) , MIRTarget (..) @@ -131,7 +130,7 @@ module Cardano.Api.Ledger.Internal.Reexport , toPlainDecoder -- Shelley , secondsToNominalDiffTimeMicro - , ChainAccountState (..) + , ChainAccountState -- TODO: this should be ChainAccountState (..), but it does not compile , NewEpochState (..) , ShelleyGenesisStaking (..) -- Allegra @@ -192,7 +191,6 @@ module Cardano.Api.Ledger.Internal.Reexport , strictMaybeToMaybe , maybeToStrictMaybe , AnchorData (..) - , hashAnchorData , UnitInterval , mkVersion , NonNegativeInterval @@ -284,7 +282,6 @@ import Cardano.Ledger.BaseTypes , Version , boundRational , dnsToText - , hashAnchorData , maybeToStrictMaybe , mkVersion , portToWord16 @@ -386,13 +383,12 @@ import Cardano.Ledger.Plutus.Language , toSLanguage ) import Cardano.Ledger.Shelley.API - ( ChainAccountState (..) + ( ChainAccountState -- TODO: this should be ChainAccountState (..), but it does not compile , GenDelegPair (..) , NewEpochState (..) , StakeReference (..) , WitVKey (..) , hashKey - , hashVerKeyVRF ) import Cardano.Ledger.Shelley.Genesis ( ShelleyGenesisStaking (..) @@ -411,7 +407,7 @@ import Cardano.Ledger.Shelley.TxCert ) import Cardano.Ledger.State ( PoolMetadata (..) - , PoolParams (..) + , StakePoolParams (..) , ScriptsNeeded , StakePoolRelay (..) , UTxO (..) From d5ab5f7af0f1f95b80d95da6fbe8a474cbf13e47 Mon Sep 17 00:00:00 2001 From: Georgy Lukyanov Date: Tue, 9 Dec 2025 15:18:40 +0100 Subject: [PATCH 03/32] Add Javier's upgrage to LSM Co-authored-by: Georgy Lukyanov Co-authored-by: Javier Sagredo --- .../src/Cardano/Api/Era/Internal/Eon/AlonzoEraOnwards.hs | 5 +---- cardano-api/src/Cardano/Api/Experimental/Era.hs | 1 - .../Experimental/Plutus/Internal/Shim/LegacyScripts.hs | 8 ++++++-- cardano-api/src/Cardano/Api/LedgerState.hs | 4 +++- cardano-api/src/Cardano/Api/Plutus/Internal/Script.hs | 2 +- 5 files changed, 11 insertions(+), 9 deletions(-) diff --git a/cardano-api/src/Cardano/Api/Era/Internal/Eon/AlonzoEraOnwards.hs b/cardano-api/src/Cardano/Api/Era/Internal/Eon/AlonzoEraOnwards.hs index d48f1fa643..484b1cd4fc 100644 --- a/cardano-api/src/Cardano/Api/Era/Internal/Eon/AlonzoEraOnwards.hs +++ b/cardano-api/src/Cardano/Api/Era/Internal/Eon/AlonzoEraOnwards.hs @@ -29,7 +29,6 @@ import Cardano.Binary import Cardano.Crypto.Hash.Blake2b qualified as Blake2b import Cardano.Crypto.Hash.Class qualified as C import Cardano.Crypto.VRF qualified as C -import Cardano.Ledger.Allegra.Scripts qualified as L import Cardano.Ledger.Alonzo.Plutus.Context qualified as Plutus import Cardano.Ledger.Alonzo.Scripts qualified as L import Cardano.Ledger.Alonzo.Tx qualified as L @@ -107,11 +106,9 @@ type AlonzoEraOnwardsConstraints era = , L.EraUTxO (ShelleyLedgerEra era) , L.HashAnnotated (L.TxBody (ShelleyLedgerEra era)) L.EraIndependentTxBody , L.MaryEraTxBody (ShelleyLedgerEra era) - , L.NativeScript (ShelleyLedgerEra era) ~ L.Timelock (ShelleyLedgerEra era) , Plutus.EraPlutusContext (ShelleyLedgerEra era) , L.Script (ShelleyLedgerEra era) ~ L.AlonzoScript (ShelleyLedgerEra era) , L.ScriptsNeeded (ShelleyLedgerEra era) ~ L.AlonzoScriptsNeeded (ShelleyLedgerEra era) - , L.ShelleyEraTxCert (ShelleyLedgerEra era) , L.Value (ShelleyLedgerEra era) ~ L.MaryValue , FromCBOR (Consensus.ChainDepState (ConsensusProtocol era)) , FromCBOR (DebugLedgerState era) @@ -131,7 +128,7 @@ alonzoEraOnwardsConstraints = \case AlonzoEraOnwardsAlonzo -> id AlonzoEraOnwardsBabbage -> id AlonzoEraOnwardsConway -> id - AlonzoEraOnwardsDijkstra -> const $ error "alonzoEraOnwardsConstraints: Dijkstra era not yet supported" + AlonzoEraOnwardsDijkstra -> id {-# DEPRECATED alonzoEraOnwardsToShelleyBasedEra "Use 'convert' instead." #-} alonzoEraOnwardsToShelleyBasedEra :: AlonzoEraOnwards era -> ShelleyBasedEra era diff --git a/cardano-api/src/Cardano/Api/Experimental/Era.hs b/cardano-api/src/Cardano/Api/Experimental/Era.hs index 3a1777fea8..c2fb3e227d 100644 --- a/cardano-api/src/Cardano/Api/Experimental/Era.hs +++ b/cardano-api/src/Cardano/Api/Experimental/Era.hs @@ -316,7 +316,6 @@ type EraCommonConstraints era = , L.Val (L.Value (LedgerEra era)) , L.Value (LedgerEra era) ~ L.MaryValue , FromCBOR (ChainDepState (ConsensusProtocol era)) - , L.NativeScript (LedgerEra era) ~ L.Timelock (LedgerEra era) , PraosProtocolSupportsNode (ConsensusProtocol era) , ShelleyLedgerEra era ~ LedgerEra era , LedgerEra era ~ ShelleyLedgerEra era diff --git a/cardano-api/src/Cardano/Api/Experimental/Plutus/Internal/Shim/LegacyScripts.hs b/cardano-api/src/Cardano/Api/Experimental/Plutus/Internal/Shim/LegacyScripts.hs index 1a79dcf94d..bac3050367 100644 --- a/cardano-api/src/Cardano/Api/Experimental/Plutus/Internal/Shim/LegacyScripts.hs +++ b/cardano-api/src/Cardano/Api/Experimental/Plutus/Internal/Shim/LegacyScripts.hs @@ -48,7 +48,7 @@ import Cardano.Binary qualified as CBOR import Cardano.Ledger.Alonzo.Scripts qualified as L import Cardano.Ledger.BaseTypes (Version) import Cardano.Ledger.Core qualified as L -import Cardano.Ledger.Mary.Value qualified as L +import Cardano.Ledger.Dijkstra.Scripts qualified as Dijkstra import Cardano.Ledger.Plutus.Language qualified as L import Data.Text qualified as Text @@ -110,7 +110,11 @@ convertToNewScriptWitness eon (Old.SimpleScriptWitness _ scriptOrRefInput) witne convertTotimelock :: AlonzoEraOnwards era -> Old.SimpleScript -> L.NativeScript (ShelleyLedgerEra era) -convertTotimelock eon s = alonzoEraOnwardsConstraints eon $ Old.toAllegraTimelock s +convertTotimelock eon s = alonzoEraOnwardsConstraints eon $ case eon of + AlonzoEraOnwardsAlonzo -> Old.toAllegraTimelock s + AlonzoEraOnwardsBabbage -> Old.toAllegraTimelock s + AlonzoEraOnwardsConway -> Old.toAllegraTimelock s + AlonzoEraOnwardsDijkstra -> Dijkstra.upgradeTimelock (Old.toAllegraTimelock s) createPlutusScriptDatum :: Witnessable thing era diff --git a/cardano-api/src/Cardano/Api/LedgerState.hs b/cardano-api/src/Cardano/Api/LedgerState.hs index f39493acd0..623ab88397 100644 --- a/cardano-api/src/Cardano/Api/LedgerState.hs +++ b/cardano-api/src/Cardano/Api/LedgerState.hs @@ -10,6 +10,7 @@ {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeApplications #-} {-# LANGUAGE TypeOperators #-} +{-# OPTIONS_GHC -Wno-x-ord-preserving-coercions #-} module Cardano.Api.LedgerState ( -- * Initialization / Accumulation @@ -207,6 +208,7 @@ import Ouroboros.Consensus.Shelley.HFEras qualified as Shelley import Ouroboros.Consensus.Shelley.Ledger.Block qualified as Shelley import Ouroboros.Consensus.Shelley.Ledger.Ledger qualified as Shelley import Ouroboros.Consensus.TypeFamilyWrappers (WrapLedgerEvent (WrapLedgerEvent)) +import Ouroboros.Consensus.Util (coerceMapKeys) import Ouroboros.Network.Block (blockNo) import Ouroboros.Network.Block qualified import Ouroboros.Network.Protocol.ChainSync.Client qualified as CS @@ -2285,7 +2287,7 @@ getLedgerTablesUTxOValues sbe tbs = -> Map TxIn (TxOut CtxUTxO era) ejectTables idx = let Consensus.LedgerTables (Ledger.ValuesMK values) = HFC.ejectLedgerTables idx tbs - in Map.mapKeys fromShelleyTxIn $ Map.map (fromShelleyTxOut sbe) values + in Map.mapKeys fromShelleyTxIn $ coerceMapKeys $ Map.map (fromShelleyTxOut sbe) values in case sbe of ShelleyBasedEraShelley -> ejectTables (IS IZ) diff --git a/cardano-api/src/Cardano/Api/Plutus/Internal/Script.hs b/cardano-api/src/Cardano/Api/Plutus/Internal/Script.hs index 9eba37259f..ad36721474 100644 --- a/cardano-api/src/Cardano/Api/Plutus/Internal/Script.hs +++ b/cardano-api/src/Cardano/Api/Plutus/Internal/Script.hs @@ -1243,7 +1243,7 @@ toShelleyScript (ScriptInEra langInEra (SimpleScript script)) = SimpleScriptInAlonzo -> Alonzo.NativeScript (toAllegraTimelock script) SimpleScriptInBabbage -> Alonzo.NativeScript (toAllegraTimelock script) SimpleScriptInConway -> Alonzo.NativeScript (toAllegraTimelock script) - SimpleScriptInDijkstra -> Alonzo.NativeScript (toAllegraTimelock script) + SimpleScriptInDijkstra -> Alonzo.NativeScript (Dijkstra.upgradeTimelock (toAllegraTimelock script)) toShelleyScript ( ScriptInEra langInEra From 8ba2f6cd4f5e49127605b805b8afb26f6b42aeae Mon Sep 17 00:00:00 2001 From: Georgy Lukyanov Date: Tue, 9 Dec 2025 15:38:30 +0100 Subject: [PATCH 04/32] Use `StrictMaybe` in transaction body --- cardano-api/src/Cardano/Api/Tx/Internal/Body.hs | 16 ++++++++-------- .../src/Cardano/Api/Tx/Internal/Body/Lens.hs | 16 ++++++++-------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/cardano-api/src/Cardano/Api/Tx/Internal/Body.hs b/cardano-api/src/Cardano/Api/Tx/Internal/Body.hs index f7ae62f5fe..f7b271d5d1 100644 --- a/cardano-api/src/Cardano/Api/Tx/Internal/Body.hs +++ b/cardano-api/src/Cardano/Api/Tx/Internal/Body.hs @@ -460,7 +460,7 @@ defaultTxFee w = TxFeeExplicit w mempty data TxValidityUpperBound era where TxValidityUpperBound :: ShelleyBasedEra era - -> Maybe SlotNo + -> StrictMaybe SlotNo -> TxValidityUpperBound era deriving instance Eq (TxValidityUpperBound era) @@ -471,7 +471,7 @@ defaultTxValidityUpperBound :: () => ShelleyBasedEra era -> TxValidityUpperBound era -defaultTxValidityUpperBound sbe = TxValidityUpperBound sbe Nothing +defaultTxValidityUpperBound sbe = TxValidityUpperBound sbe SNothing data TxValidityLowerBound era where TxValidityNoLowerBound @@ -1679,8 +1679,8 @@ fromLedgerTxValidityLowerBound sbe body = ( \w -> let mInvalidBefore = body ^. A.invalidBeforeTxBodyL w in case mInvalidBefore of - Nothing -> TxValidityNoLowerBound - Just s -> TxValidityLowerBound w s + SNothing -> TxValidityNoLowerBound + SJust s -> TxValidityLowerBound w s ) sbe @@ -1887,16 +1887,16 @@ convTransactionFee _ (TxFeeExplicit _ fee) = fee convValidityLowerBound :: () => TxValidityLowerBound era - -> Maybe SlotNo + -> StrictMaybe SlotNo convValidityLowerBound = \case - TxValidityNoLowerBound -> Nothing - TxValidityLowerBound _ s -> Just s + TxValidityNoLowerBound -> SNothing + TxValidityLowerBound _ s -> SJust s convValidityUpperBound :: () => ShelleyBasedEra era -> TxValidityUpperBound era - -> Maybe SlotNo + -> StrictMaybe SlotNo convValidityUpperBound _ = \case TxValidityUpperBound _ ms -> ms diff --git a/cardano-api/src/Cardano/Api/Tx/Internal/Body/Lens.hs b/cardano-api/src/Cardano/Api/Tx/Internal/Body/Lens.hs index 0f4ab8ae43..3343173c96 100644 --- a/cardano-api/src/Cardano/Api/Tx/Internal/Body/Lens.hs +++ b/cardano-api/src/Cardano/Api/Tx/Internal/Body/Lens.hs @@ -87,7 +87,7 @@ strictMaybeL = lens g s txBodyL :: Lens' (LedgerTxBody era) (L.TxBody (ShelleyLedgerEra era)) txBodyL = lens unTxBody (\_ x -> LedgerTxBody x) -invalidBeforeTxBodyL :: AllegraEraOnwards era -> Lens' (LedgerTxBody era) (Maybe SlotNo) +invalidBeforeTxBodyL :: AllegraEraOnwards era -> Lens' (LedgerTxBody era) (StrictMaybe SlotNo) invalidBeforeTxBodyL w = allegraEraOnwardsConstraints w $ txBodyL . L.vldtTxBodyL . L.invalidBeforeL -- | Compatibility lens that provides a consistent interface over 'ttlTxBodyL' and @@ -105,27 +105,27 @@ invalidBeforeTxBodyL w = allegraEraOnwardsConstraints w $ txBodyL . L.vldtTxBody -- -- 'invalidHereAfterTxBodyL' lens over both with a 'Maybe SlotNo' type representation. Withing the -- Shelley era, setting Nothing will set the ttl to 'maxBound' in the underlying ledger type. -invalidHereAfterTxBodyL :: ShelleyBasedEra era -> Lens' (LedgerTxBody era) (Maybe SlotNo) +invalidHereAfterTxBodyL :: ShelleyBasedEra era -> Lens' (LedgerTxBody era) (StrictMaybe SlotNo) invalidHereAfterTxBodyL = caseShelleyEraOnlyOrAllegraEraOnwards ttlAsInvalidHereAfterTxBodyL (const $ txBodyL . L.vldtTxBodyL . L.invalidHereAfterL) -- | Compatibility lens over 'ttlTxBodyL' which represents 'maxBound' as Nothing and all other values as 'Just'. -ttlAsInvalidHereAfterTxBodyL :: ShelleyEraOnly era -> Lens' (LedgerTxBody era) (Maybe SlotNo) +ttlAsInvalidHereAfterTxBodyL :: ShelleyEraOnly era -> Lens' (LedgerTxBody era) (StrictMaybe SlotNo) ttlAsInvalidHereAfterTxBodyL w = lens (g w) (s w) where - g :: ShelleyEraOnly era -> LedgerTxBody era -> Maybe SlotNo + g :: ShelleyEraOnly era -> LedgerTxBody era -> StrictMaybe SlotNo g w' txBody = shelleyEraOnlyConstraints w' $ - let ttl = txBody ^. txBodyL . L.ttlTxBodyL in if ttl == maxBound then Nothing else Just ttl + let ttl = txBody ^. txBodyL . L.ttlTxBodyL in if ttl == maxBound then SNothing else SJust ttl - s :: ShelleyEraOnly era -> LedgerTxBody era -> Maybe SlotNo -> LedgerTxBody era + s :: ShelleyEraOnly era -> LedgerTxBody era -> StrictMaybe SlotNo -> LedgerTxBody era s w' txBody mSlotNo = shelleyEraOnlyConstraints w' $ case mSlotNo of - Nothing -> txBody & txBodyL . L.ttlTxBodyL .~ maxBound - Just ttl -> txBody & txBodyL . L.ttlTxBodyL .~ ttl + SNothing -> txBody & txBodyL . L.ttlTxBodyL .~ maxBound + SJust ttl -> txBody & txBodyL . L.ttlTxBodyL .~ ttl -- | Lens to access the 'invalidBefore' field of a 'ValidityInterval' as a 'StrictMaybe SlotNo'. -- Ideally this should be defined in cardano-ledger From 0eaf07176658bec18fe8a238a9a2bf233867a7a0 Mon Sep 17 00:00:00 2001 From: Georgy Lukyanov Date: Tue, 9 Dec 2025 15:51:59 +0100 Subject: [PATCH 05/32] Update key roles --- cardano-api/src/Cardano/Api/Address.hs | 13 +++++++------ cardano-api/src/Cardano/Api/Key/Internal.hs | 4 ++-- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/cardano-api/src/Cardano/Api/Address.hs b/cardano-api/src/Cardano/Api/Address.hs index 86db0828c3..f7bd3ead7d 100644 --- a/cardano-api/src/Cardano/Api/Address.hs +++ b/cardano-api/src/Cardano/Api/Address.hs @@ -104,6 +104,7 @@ import Cardano.Ledger.Address qualified as Shelley import Cardano.Ledger.BaseTypes qualified as Shelley import Cardano.Ledger.Credential qualified as Shelley import Cardano.Ledger.Plutus.TxInfo qualified as Plutus +import Cardano.Ledger.Keys qualified as Shelley import PlutusLedgerApi.V1 qualified as PlutusAPI import Control.Applicative ((<|>)) @@ -183,7 +184,7 @@ data Address addrtype where -- in Shelley era and are thus supported from the Shelley era onwards ShelleyAddress :: Shelley.Network - -> Shelley.PaymentCredential + -> Shelley.Credential Shelley.Payment -> Shelley.StakeReference -> Address ShelleyAddr @@ -527,7 +528,7 @@ makeShelleyAddressInEra sbe nw pc scr = data StakeAddress where StakeAddress :: Shelley.Network - -> Shelley.StakeCredential + -> Shelley.Credential Shelley.Staking -> StakeAddress deriving (Eq, Ord, Show) @@ -652,7 +653,7 @@ toShelleyStakeAddr (StakeAddress nw sc) = toShelleyPaymentCredential :: PaymentCredential - -> Shelley.PaymentCredential + -> Shelley.Credential Shelley.Payment toShelleyPaymentCredential (PaymentCredentialByKey (PaymentKeyHash kh)) = Shelley.KeyHashObj kh toShelleyPaymentCredential (PaymentCredentialByScript sh) = @@ -660,7 +661,7 @@ toShelleyPaymentCredential (PaymentCredentialByScript sh) = toShelleyStakeCredential :: StakeCredential - -> Shelley.StakeCredential + -> Shelley.Credential Shelley.Staking toShelleyStakeCredential (StakeCredentialByKey (StakeKeyHash kh)) = Shelley.KeyHashObj kh toShelleyStakeCredential (StakeCredentialByScript sh) = @@ -704,7 +705,7 @@ fromShelleyStakeAddr :: Shelley.RewardAccount -> StakeAddress fromShelleyStakeAddr (Shelley.RewardAccount nw sc) = StakeAddress nw sc fromShelleyStakeCredential - :: Shelley.StakeCredential + :: Shelley.Credential Shelley.Staking -> StakeCredential fromShelleyStakeCredential (Shelley.KeyHashObj kh) = StakeCredentialByKey (StakeKeyHash kh) @@ -712,7 +713,7 @@ fromShelleyStakeCredential (Shelley.ScriptHashObj sh) = StakeCredentialByScript (fromShelleyScriptHash sh) fromShelleyPaymentCredential - :: Shelley.PaymentCredential + :: Shelley.Credential Shelley.Payment -> PaymentCredential fromShelleyPaymentCredential (Shelley.KeyHashObj kh) = PaymentCredentialByKey (PaymentKeyHash kh) diff --git a/cardano-api/src/Cardano/Api/Key/Internal.hs b/cardano-api/src/Cardano/Api/Key/Internal.hs index a4d7969ba8..0bf6c39885 100644 --- a/cardano-api/src/Cardano/Api/Key/Internal.hs +++ b/cardano-api/src/Cardano/Api/Key/Internal.hs @@ -603,7 +603,7 @@ instance HasTypeProxy GenesisKey where instance Key GenesisKey where newtype VerificationKey GenesisKey - = GenesisVerificationKey (Shelley.VKey Shelley.Genesis) + = GenesisVerificationKey (Shelley.VKey Shelley.GenesisRole) deriving stock Eq deriving (Show, Pretty) via UsingRawBytesHex (VerificationKey GenesisKey) deriving newtype (ToCBOR, FromCBOR) @@ -652,7 +652,7 @@ instance SerialiseAsRawBytes (SigningKey GenesisKey) where GenesisSigningKey <$> Crypto.rawDeserialiseSignKeyDSIGN bs newtype instance Hash GenesisKey - = GenesisKeyHash {unGenesisKeyHash :: Shelley.KeyHash Shelley.Genesis} + = GenesisKeyHash {unGenesisKeyHash :: Shelley.KeyHash Shelley.GenesisRole} deriving stock (Eq, Ord) deriving (Show, Pretty) via UsingRawBytesHex (Hash GenesisKey) deriving (ToCBOR, FromCBOR) via UsingRawBytes (Hash GenesisKey) From 6e4e4526f266adf2cb9c26d140a5a7fdc56ccc1a Mon Sep 17 00:00:00 2001 From: Georgy Lukyanov Date: Tue, 9 Dec 2025 15:52:10 +0100 Subject: [PATCH 06/32] Replace Witness with Guard --- cardano-api/src/Cardano/Api/Tx/Internal/Body/Lens.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cardano-api/src/Cardano/Api/Tx/Internal/Body/Lens.hs b/cardano-api/src/Cardano/Api/Tx/Internal/Body/Lens.hs index 3343173c96..3794460469 100644 --- a/cardano-api/src/Cardano/Api/Tx/Internal/Body/Lens.hs +++ b/cardano-api/src/Cardano/Api/Tx/Internal/Body/Lens.hs @@ -165,7 +165,7 @@ collateralInputsTxBodyL collateralInputsTxBodyL w = alonzoEraOnwardsConstraints w $ txBodyL . L.collateralInputsTxBodyL reqSignerHashesTxBodyL - :: AlonzoEraOnwards era -> Lens' (LedgerTxBody era) (Set (L.KeyHash L.Witness)) + :: AlonzoEraOnwards era -> Lens' (LedgerTxBody era) (Set (L.KeyHash L.Guard)) reqSignerHashesTxBodyL w@AlonzoEraOnwardsAlonzo = alonzoEraOnwardsConstraints w $ txBodyL . L.reqSignerHashesTxBodyL reqSignerHashesTxBodyL w@AlonzoEraOnwardsBabbage = alonzoEraOnwardsConstraints w $ txBodyL . L.reqSignerHashesTxBodyL reqSignerHashesTxBodyL w@AlonzoEraOnwardsConway = alonzoEraOnwardsConstraints w $ txBodyL . L.reqSignerHashesTxBodyL From 3620daee55980499eec6be442743e83a291df3c7 Mon Sep 17 00:00:00 2001 From: Georgy Lukyanov Date: Tue, 9 Dec 2025 16:17:59 +0100 Subject: [PATCH 07/32] PoolParams -> StakePoolParams --- .../src/Cardano/Api/Certificate/Internal.hs | 72 +++++++++---------- .../Experimental/Tx/Internal/Certificate.hs | 6 +- .../Tx/Internal/Certificate/Compatible.hs | 2 +- 3 files changed, 40 insertions(+), 40 deletions(-) diff --git a/cardano-api/src/Cardano/Api/Certificate/Internal.hs b/cardano-api/src/Cardano/Api/Certificate/Internal.hs index 400e9c3549..18da0c9e67 100644 --- a/cardano-api/src/Cardano/Api/Certificate/Internal.hs +++ b/cardano-api/src/Cardano/Api/Certificate/Internal.hs @@ -329,11 +329,11 @@ makeStakeAddressDelegationCertificate = \case data StakePoolRegistrationRequirements era where StakePoolRegistrationRequirementsConwayOnwards :: ConwayEraOnwards era - -> Ledger.PoolParams + -> Ledger.StakePoolParams -> StakePoolRegistrationRequirements era StakePoolRegistrationRequirementsPreConway :: ShelleyToBabbageEra era - -> Ledger.PoolParams + -> Ledger.StakePoolParams -> StakePoolRegistrationRequirements era {-# DEPRECATED @@ -648,7 +648,7 @@ fromShelleyCertificate fromShelleyCertificate = caseShelleyToBabbageOrConwayEraOnwards ShelleyRelatedCertificate ConwayCertificate -toShelleyPoolParams :: StakePoolParameters -> Ledger.PoolParams +toShelleyPoolParams :: StakePoolParameters -> Ledger.StakePoolParams toShelleyPoolParams StakePoolParameters { stakePoolId = StakePoolKeyHash poolkh @@ -663,23 +663,23 @@ toShelleyPoolParams } = -- TODO: validate pool parameters such as the PoolMargin below, but also -- do simple client-side sanity checks, e.g. on the pool metadata url - Ledger.PoolParams - { Ledger.ppId = poolkh - , Ledger.ppVrf = Ledger.toVRFVerKeyHash vrfkh - , Ledger.ppPledge = stakePoolPledge - , Ledger.ppCost = stakePoolCost - , Ledger.ppMargin = + Ledger.StakePoolParams + { Ledger.sppId = poolkh + , Ledger.sppVrf = Ledger.toVRFVerKeyHash vrfkh + , Ledger.sppPledge = stakePoolPledge + , Ledger.sppCost = stakePoolCost + , Ledger.sppMargin = fromMaybe (error "toShelleyPoolParams: invalid PoolMargin") (Ledger.boundRational stakePoolMargin) - , Ledger.ppRewardAccount = toShelleyStakeAddr stakePoolRewardAccount - , Ledger.ppOwners = + , Ledger.sppRewardAccount = toShelleyStakeAddr stakePoolRewardAccount + , Ledger.sppOwners = fromList [kh | StakeKeyHash kh <- stakePoolOwners] - , Ledger.ppRelays = + , Ledger.sppRelays = fromList (map toShelleyStakePoolRelay stakePoolRelays) - , Ledger.ppMetadata = + , Ledger.sppMetadata = toShelleyPoolMetadata <$> Ledger.maybeToStrictMaybe stakePoolMetadata } @@ -721,35 +721,35 @@ toShelleyPoolParams Ledger.textToUrl (Text.length url) url fromShelleyPoolParams - :: Ledger.PoolParams + :: Ledger.StakePoolParams -> StakePoolParameters fromShelleyPoolParams - Ledger.PoolParams - { Ledger.ppId - , Ledger.ppVrf - , Ledger.ppPledge - , Ledger.ppCost - , Ledger.ppMargin - , Ledger.ppRewardAccount - , Ledger.ppOwners - , Ledger.ppRelays - , Ledger.ppMetadata + Ledger.StakePoolParams + { Ledger.sppId + , Ledger.sppVrf + , Ledger.sppPledge + , Ledger.sppCost + , Ledger.sppMargin + , Ledger.sppRewardAccount + , Ledger.sppOwners + , Ledger.sppRelays + , Ledger.sppMetadata } = StakePoolParameters - { stakePoolId = StakePoolKeyHash ppId - , stakePoolVRF = VrfKeyHash (Ledger.fromVRFVerKeyHash ppVrf) - , stakePoolCost = ppCost - , stakePoolMargin = Ledger.unboundRational ppMargin - , stakePoolRewardAccount = fromShelleyStakeAddr ppRewardAccount - , stakePoolPledge = ppPledge - , stakePoolOwners = map StakeKeyHash (toList ppOwners) + { stakePoolId = StakePoolKeyHash sppId + , stakePoolVRF = VrfKeyHash (Ledger.fromVRFVerKeyHash sppVrf) + , stakePoolCost = sppCost + , stakePoolMargin = Ledger.unboundRational sppMargin + , stakePoolRewardAccount = fromShelleyStakeAddr sppRewardAccount + , stakePoolPledge = sppPledge + , stakePoolOwners = map StakeKeyHash (toList sppOwners) , stakePoolRelays = map fromShelleyStakePoolRelay - (toList ppRelays) + (toList sppRelays) , stakePoolMetadata = fromShelleyPoolMetadata - <$> Ledger.strictMaybeToMaybe ppMetadata + <$> Ledger.strictMaybeToMaybe sppMetadata } where fromShelleyStakePoolRelay :: Ledger.StakePoolRelay -> StakePoolRelay @@ -808,7 +808,7 @@ fromShelleyStakePoolState , stakePoolVRF = VrfKeyHash (Ledger.fromVRFVerKeyHash spsVrf) , stakePoolCost = spsCost , stakePoolMargin = Ledger.unboundRational spsMargin - , stakePoolRewardAccount = fromShelleyStakeAddr spsRewardAccount + , stakePoolRewardAccount = StakeAddress undefined spsRewardAccount -- TODO the Network argument was removed in Ledger , stakePoolPledge = spsPledge , stakePoolOwners = map StakeKeyHash (toList spsOwners) , stakePoolRelays = @@ -877,7 +877,7 @@ getAnchorDataFromCertificate c = Ledger.RegTxCert _ -> return Nothing Ledger.UnRegTxCert _ -> return Nothing Ledger.DelegStakeTxCert _ _ -> return Nothing - Ledger.RegPoolTxCert poolParams -> strictMaybe (return Nothing) anchorDataFromPoolMetadata $ Ledger.ppMetadata poolParams + Ledger.RegPoolTxCert poolParams -> strictMaybe (return Nothing) anchorDataFromPoolMetadata $ Ledger.sppMetadata poolParams Ledger.RetirePoolTxCert _ _ -> return Nothing Ledger.GenesisDelegTxCert{} -> return Nothing Ledger.MirTxCert _ -> return Nothing @@ -891,7 +891,7 @@ getAnchorDataFromCertificate c = Ledger.UnRegDepositTxCert _ _ -> return Nothing Ledger.RegDepositDelegTxCert{} -> return Nothing Ledger.DelegTxCert{} -> return Nothing - Ledger.RegPoolTxCert poolParams -> strictMaybe (return Nothing) anchorDataFromPoolMetadata $ Ledger.ppMetadata poolParams + Ledger.RegPoolTxCert poolParams -> strictMaybe (return Nothing) anchorDataFromPoolMetadata $ Ledger.sppMetadata poolParams Ledger.RetirePoolTxCert _ _ -> return Nothing Ledger.RegDRepTxCert _ _ mAnchor -> return $ Ledger.strictMaybeToMaybe mAnchor Ledger.UnRegDRepTxCert _ _ -> return Nothing diff --git a/cardano-api/src/Cardano/Api/Experimental/Tx/Internal/Certificate.hs b/cardano-api/src/Cardano/Api/Experimental/Tx/Internal/Certificate.hs index 43f728eeb0..8dec157474 100644 --- a/cardano-api/src/Cardano/Api/Experimental/Tx/Internal/Certificate.hs +++ b/cardano-api/src/Cardano/Api/Experimental/Tx/Internal/Certificate.hs @@ -92,7 +92,7 @@ makeStakeAddressUnregistrationCertificate scred deposit = makeStakePoolRegistrationCertificate :: forall era . IsEra era - => Ledger.PoolParams + => Ledger.StakePoolParams -> Certificate (LedgerEra era) makeStakePoolRegistrationCertificate poolParams = obtainCommonConstraints (useEra @era) $ @@ -199,7 +199,7 @@ getAnchorDataFromCertificate ConwayEra (Certificate c) = Ledger.UnRegDepositTxCert _ _ -> return Nothing Ledger.RegDepositDelegTxCert{} -> return Nothing Ledger.DelegTxCert{} -> return Nothing - Ledger.RegPoolTxCert poolParams -> strictMaybe (return Nothing) anchorDataFromPoolMetadata $ Ledger.ppMetadata poolParams + Ledger.RegPoolTxCert poolParams -> strictMaybe (return Nothing) anchorDataFromPoolMetadata $ Ledger.sppMetadata poolParams Ledger.RetirePoolTxCert _ _ -> return Nothing Ledger.RegDRepTxCert _ _ mAnchor -> return $ Ledger.strictMaybeToMaybe mAnchor Ledger.UnRegDRepTxCert _ _ -> return Nothing @@ -213,7 +213,7 @@ getAnchorDataFromCertificate DijkstraEra (Certificate c) = Ledger.UnRegDepositTxCert _ _ -> return Nothing Ledger.RegDepositDelegTxCert{} -> return Nothing Ledger.DelegTxCert{} -> return Nothing - Ledger.RegPoolTxCert poolParams -> strictMaybe (return Nothing) anchorDataFromPoolMetadata $ Ledger.ppMetadata poolParams + Ledger.RegPoolTxCert poolParams -> strictMaybe (return Nothing) anchorDataFromPoolMetadata $ Ledger.sppMetadata poolParams Ledger.RetirePoolTxCert _ _ -> return Nothing Ledger.RegDRepTxCert _ _ mAnchor -> return $ Ledger.strictMaybeToMaybe mAnchor Ledger.UnRegDRepTxCert _ _ -> return Nothing diff --git a/cardano-api/src/Cardano/Api/Experimental/Tx/Internal/Certificate/Compatible.hs b/cardano-api/src/Cardano/Api/Experimental/Tx/Internal/Certificate/Compatible.hs index ab1b1b4920..72c5b93327 100644 --- a/cardano-api/src/Cardano/Api/Experimental/Tx/Internal/Certificate/Compatible.hs +++ b/cardano-api/src/Cardano/Api/Experimental/Tx/Internal/Certificate/Compatible.hs @@ -136,7 +136,7 @@ makeStakeAddressUnregistrationCertificate scred = makeStakePoolRegistrationCertificate :: forall era . IsShelleyBasedEra era - => Ledger.PoolParams + => Ledger.StakePoolParams -> Certificate (ShelleyLedgerEra era) makeStakePoolRegistrationCertificate poolParams = shelleyBasedEraConstraints (shelleyBasedEra @era) $ From edb7966753310370b4e707c465bc893db1f341e2 Mon Sep 17 00:00:00 2001 From: Georgy Lukyanov Date: Mon, 22 Dec 2025 14:13:19 +0100 Subject: [PATCH 08/32] [wip] comment-out redundant patterns --- .../src/Cardano/Api/Tx/Internal/Output.hs | 61 ++++++++++--------- 1 file changed, 32 insertions(+), 29 deletions(-) diff --git a/cardano-api/src/Cardano/Api/Tx/Internal/Output.hs b/cardano-api/src/Cardano/Api/Tx/Internal/Output.hs index 6b39116629..ab0dffe14a 100644 --- a/cardano-api/src/Cardano/Api/Tx/Internal/Output.hs +++ b/cardano-api/src/Cardano/Api/Tx/Internal/Output.hs @@ -814,12 +814,13 @@ toShelleyTxOut sbe = shelleyBasedEraConstraints sbe $ \case .~ toBabbageTxOutDatumUTxO txoutdata & L.referenceScriptTxOutL .~ refScriptToShelleyScript sbe refScript - AlonzoEraOnwardsDijkstra -> - L.mkBasicTxOut (toShelleyAddr addr) value - & L.datumTxOutL - .~ toBabbageTxOutDatumUTxO txoutdata - & L.referenceScriptTxOutL - .~ refScriptToShelleyScript sbe refScript + -- TODO: this pattern shows up as redundant + -- AlonzoEraOnwardsDijkstra -> + -- L.mkBasicTxOut (toShelleyAddr addr) value + -- & L.datumTxOutL + -- .~ toBabbageTxOutDatumUTxO txoutdata + -- & L.referenceScriptTxOutL + -- .~ refScriptToShelleyScript sbe refScript ) sbe @@ -854,12 +855,13 @@ toShelleyTxOutAny sbe = shelleyBasedEraConstraints sbe $ \case .~ toBabbageTxOutDatum txoutdata & L.referenceScriptTxOutL .~ refScriptToShelleyScript sbe refScript - AlonzoEraOnwardsDijkstra -> - L.mkBasicTxOut (toShelleyAddr addr) value - & L.datumTxOutL - .~ toBabbageTxOutDatum txoutdata - & L.referenceScriptTxOutL - .~ refScriptToShelleyScript sbe refScript + -- TODO: this pattern shows up as redundant + -- AlonzoEraOnwardsDijkstra -> + -- L.mkBasicTxOut (toShelleyAddr addr) value + -- & L.datumTxOutL + -- .~ toBabbageTxOutDatum txoutdata + -- & L.referenceScriptTxOutL + -- .~ refScriptToShelleyScript sbe refScript ) sbe @@ -922,23 +924,24 @@ fromShelleyTxOut sbe ledgerTxOut = shelleyBasedEraConstraints sbe $ do where datum = ledgerTxOut ^. L.datumTxOutL mRefScript = ledgerTxOut ^. L.referenceScriptTxOutL - ShelleyBasedEraDijkstra -> - TxOut - addressInEra - txOutValue - ( fromBabbageTxOutDatum - AlonzoEraOnwardsDijkstra - BabbageEraOnwardsDijkstra - datum - ) - ( case mRefScript of - SNothing -> ReferenceScriptNone - SJust refScript -> - fromShelleyScriptToReferenceScript ShelleyBasedEraDijkstra refScript - ) - where - datum = ledgerTxOut ^. L.datumTxOutL - mRefScript = ledgerTxOut ^. L.referenceScriptTxOutL + -- TODO: this pattern shows up as redundant + -- ShelleyBasedEraDijkstra -> + -- TxOut + -- addressInEra + -- txOutValue + -- ( fromBabbageTxOutDatum + -- AlonzoEraOnwardsDijkstra + -- BabbageEraOnwardsDijkstra + -- datum + -- ) + -- ( case mRefScript of + -- SNothing -> ReferenceScriptNone + -- SJust refScript -> + -- fromShelleyScriptToReferenceScript ShelleyBasedEraDijkstra refScript + -- ) + -- where + -- datum = ledgerTxOut ^. L.datumTxOutL + -- mRefScript = ledgerTxOut ^. L.referenceScriptTxOutL -- ---------------------------------------------------------------------------- -- Transaction output values (era-dependent) From 91aa8c48bdde9d3c6bec2f5ee44d49adb4791f0c Mon Sep 17 00:00:00 2001 From: Mateusz Galazyn Date: Mon, 5 Jan 2026 18:53:42 +0100 Subject: [PATCH 09/32] Add ledger lenses for `ChainAccountState` to exports from `Cardano.Api.Ledger` --- cardano-api/src/Cardano/Api/Ledger/Internal/Reexport.hs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/cardano-api/src/Cardano/Api/Ledger/Internal/Reexport.hs b/cardano-api/src/Cardano/Api/Ledger/Internal/Reexport.hs index 81d6afffa6..c4e2d9cf8c 100644 --- a/cardano-api/src/Cardano/Api/Ledger/Internal/Reexport.hs +++ b/cardano-api/src/Cardano/Api/Ledger/Internal/Reexport.hs @@ -130,7 +130,9 @@ module Cardano.Api.Ledger.Internal.Reexport , toPlainDecoder -- Shelley , secondsToNominalDiffTimeMicro - , ChainAccountState -- TODO: this should be ChainAccountState (..), but it does not compile + , ChainAccountState + , casTreasuryL + , casReservesL , NewEpochState (..) , ShelleyGenesisStaking (..) -- Allegra @@ -383,7 +385,7 @@ import Cardano.Ledger.Plutus.Language , toSLanguage ) import Cardano.Ledger.Shelley.API - ( ChainAccountState -- TODO: this should be ChainAccountState (..), but it does not compile + ( ChainAccountState , GenDelegPair (..) , NewEpochState (..) , StakeReference (..) @@ -412,6 +414,8 @@ import Cardano.Ledger.State , StakePoolRelay (..) , UTxO (..) , getScriptsNeeded + , casReservesL + , casTreasuryL ) import Cardano.Ledger.TxIn (TxId (..), TxIn (..)) import Cardano.Ledger.Val From 9887e168ffad71de1f5b823a9b1fe7a39977d245 Mon Sep 17 00:00:00 2001 From: Georgy Lukyanov Date: Fri, 30 Jan 2026 10:49:11 +0100 Subject: [PATCH 10/32] [wip] bump Network, Ledger and Consensus s-r-ps --- cabal.project | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/cabal.project b/cabal.project index 4450b71dd6..9fccdd942d 100644 --- a/cabal.project +++ b/cabal.project @@ -168,8 +168,8 @@ if arch(wasm32) source-repository-package type: git location: https://github.com/IntersectMBO/cardano-ledger - tag: 71ec2758703b75b5a6187438a08eb3386773850e - --sha256: sha256-elIA+esNslfejQEuoYszrG7MkKJVc1AulUBDSIIEUEo= + tag: eabc9e0ddf9ad01785d292c775bb90bcf29b46df + --sha256: sha256-CirNK/WNWPSmqnEBR6IyKz8UW5JcAh6YQCg8p31AzBU= subdir: eras/allegra/impl eras/alonzo/impl @@ -198,8 +198,8 @@ source-repository-package source-repository-package type: git location: https://github.com/IntersectMBO/ouroboros-consensus - tag: c6c00805ea5b450e16efdfe22a3b3b6f3a360c82 - --sha256: sha256-DtiaTJI5uAt4CZEv/OBsv8SSv9/OwK1wm2mMPn56XJE= + tag: 678aec0ce019c741a892e519386cb24913cc36dc + --sha256: sha256-F6VHW5O4yWmLLqxH8IVhxlfrjXm4Mb+eECEPbAoZzh8= subdir: ouroboros-consensus ouroboros-consensus-cardano @@ -208,15 +208,12 @@ source-repository-package strict-sop-core sop-extras --- Backported version of https://github.com/IntersectMBO/ouroboros-network/pull/5161 source-repository-package type: git location: https://github.com/IntersectMBO/ouroboros-network - tag: 1385b53cefb81e79553b6b0252537455833ea9c4 - --sha256: sha256-zZ7WsMfRs1fG16bmvI5vIh4fhQ8RGyEvYGLSWlrxpg0= + tag: 228bb2045784a9c180651dedeea9af9396140f47 + --sha256: sha256-q/93M6+TtnqWiguOiwuUSJljA7nrICOsu+5SLl6jiCc= subdir: - ouroboros-network-api ouroboros-network - ouroboros-network-framework - ouroboros-network-mock - ouroboros-network-protocols + cardano-diffusion + network-mux From 57630f4a23226ae290e8c41b154219a35f9f9994 Mon Sep 17 00:00:00 2001 From: Georgy Lukyanov Date: Fri, 30 Jan 2026 12:17:14 +0100 Subject: [PATCH 11/32] Bump index states --- cabal.project | 4 ++-- flake.lock | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/cabal.project b/cabal.project index 9fccdd942d..d3a5cc64e7 100644 --- a/cabal.project +++ b/cabal.project @@ -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 2025-12-03T15:53:31Z - , cardano-haskell-packages 2026-01-24T11:25:12Z + , hackage.haskell.org 2026-01-12T19:29:50Z + , cardano-haskell-packages 2026-01-27T13:37:12Z packages: cardano-api diff --git a/flake.lock b/flake.lock index 610528df0e..b7909d28b4 100644 --- a/flake.lock +++ b/flake.lock @@ -3,11 +3,11 @@ "CHaP": { "flake": false, "locked": { - "lastModified": 1769539092, - "narHash": "sha256-bFd3tzV8FaYUQiZFA1V+2WjXPcnlxN1GbNs+HO6aUR4=", + "lastModified": 1769746903, + "narHash": "sha256-aP97gwy91CpecSSDa/BEsohQ7hv7kuovziuNikzRGTw=", "owner": "intersectmbo", "repo": "cardano-haskell-packages", - "rev": "a175d3efe0e99fe537b822e344c451166f6d0b97", + "rev": "13b004164316511afb0d50be4fd0764da40a7a84", "type": "github" }, "original": { @@ -281,11 +281,11 @@ "hackageNix": { "flake": false, "locked": { - "lastModified": 1765278254, - "narHash": "sha256-qDZRP4OeexvTgYI+rQDxPbRndM0fBh0AgCuJ/D6df4c=", + "lastModified": 1769758141, + "narHash": "sha256-Ny+sNUrVjly5NEe5q2AGvoU0IMWu0dplRY3LbsNLiuU=", "owner": "input-output-hk", "repo": "hackage.nix", - "rev": "3be6f76c573b49280512d238fc49ca80fb70cfa9", + "rev": "a02f96e99c0076becc35f7034c7717f4b455d25f", "type": "github" }, "original": { From 0d7d1b7f2c1ab39373410c9c613dde553aff2e6a Mon Sep 17 00:00:00 2001 From: Georgy Lukyanov Date: Fri, 30 Jan 2026 12:24:23 +0100 Subject: [PATCH 12/32] Bump typed-protocols and Network packages --- cardano-api/cardano-api.cabal | 12 +++++------- cardano-api/src/Cardano/Api/Network/IPC/Internal.hs | 4 ++-- .../Api/Network/IPC/Internal/ChainSync/Client.hs | 2 +- .../src/Cardano/Api/Network/IPC/Internal/Version.hs | 2 +- 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/cardano-api/cardano-api.cabal b/cardano-api/cardano-api.cabal index 184f08e8a3..bc9320f6bb 100644 --- a/cardano-api/cardano-api.cabal +++ b/cardano-api/cardano-api.cabal @@ -38,7 +38,7 @@ common project-config -Wunused-packages common maybe-unix - if !(os(windows)|| arch(wasm32)) + if !(os(windows) || arch(wasm32)) build-depends: unix common maybe-Win32 @@ -46,7 +46,7 @@ common maybe-Win32 build-depends: Win32 common text - if os(osx)&& arch(aarch64) + if os(osx) && arch(aarch64) build-depends: text >=1.2.5.0 else build-depends: text >=2.0 @@ -129,6 +129,7 @@ library cardano-crypto-class ^>=2.2.3.2, cardano-crypto-wrapper ^>=1.7, cardano-data >=1.0, + cardano-diffusion:{api, cardano-diffusion} ^>=0.1, cardano-ledger-allegra >=1.7, cardano-ledger-alonzo >=1.13, cardano-ledger-api ^>=1.13, @@ -169,10 +170,7 @@ library ouroboros-consensus-cardano ^>=0.26, ouroboros-consensus-diffusion ^>=0.25, ouroboros-consensus-protocol ^>=0.13, - ouroboros-network, - ouroboros-network-api >=0.15, - ouroboros-network-framework, - ouroboros-network-protocols >=0.15, + ouroboros-network:{api, framework, ouroboros-network, protocols} ^>=0.24, parsec, plutus-core ^>=1.57, plutus-ledger-api ^>=1.57, @@ -193,7 +191,7 @@ library time, transformers, transformers-except ^>=0.1.3, - typed-protocols ^>=1.0, + typed-protocols ^>=1.1, validation, vector, yaml, diff --git a/cardano-api/src/Cardano/Api/Network/IPC/Internal.hs b/cardano-api/src/Cardano/Api/Network/IPC/Internal.hs index bfd4945148..9c84bb0c9d 100644 --- a/cardano-api/src/Cardano/Api/Network/IPC/Internal.hs +++ b/cardano-api/src/Cardano/Api/Network/IPC/Internal.hs @@ -92,11 +92,11 @@ import Ouroboros.Consensus.Shelley.Ledger.Block qualified as Consensus import Ouroboros.Consensus.Shelley.Ledger.SupportsProtocol () import Ouroboros.Network.Block qualified as Net import Ouroboros.Network.Mux qualified as Net -import Ouroboros.Network.NodeToClient +import Cardano.Network.NodeToClient ( NodeToClientProtocols (..) , NodeToClientVersionData (..) ) -import Ouroboros.Network.NodeToClient qualified as Net +import Cardano.Network.NodeToClient qualified as Net import Ouroboros.Network.Protocol.ChainSync.Client as Net.Sync import Ouroboros.Network.Protocol.ChainSync.ClientPipelined as Net.SyncP import Ouroboros.Network.Protocol.LocalStateQuery.Client (LocalStateQueryClient (..)) diff --git a/cardano-api/src/Cardano/Api/Network/IPC/Internal/ChainSync/Client.hs b/cardano-api/src/Cardano/Api/Network/IPC/Internal/ChainSync/Client.hs index 94a1be3ef7..45e59397de 100644 --- a/cardano-api/src/Cardano/Api/Network/IPC/Internal/ChainSync/Client.hs +++ b/cardano-api/src/Cardano/Api/Network/IPC/Internal/ChainSync/Client.hs @@ -15,5 +15,5 @@ module Cardano.Api.Network.IPC.Internal.ChainSync.Client ) where -import Ouroboros.Network.NodeToClient +import Cardano.Network.NodeToClient import Ouroboros.Network.Protocol.ChainSync.Client diff --git a/cardano-api/src/Cardano/Api/Network/IPC/Internal/Version.hs b/cardano-api/src/Cardano/Api/Network/IPC/Internal/Version.hs index 2938a04e3c..c059a22697 100644 --- a/cardano-api/src/Cardano/Api/Network/IPC/Internal/Version.hs +++ b/cardano-api/src/Cardano/Api/Network/IPC/Internal/Version.hs @@ -15,7 +15,7 @@ import Ouroboros.Consensus.Cardano.Block qualified as Consensus import Ouroboros.Consensus.Cardano.Node () import Ouroboros.Consensus.Ledger.Query qualified as Consensus import Ouroboros.Consensus.Shelley.Ledger.SupportsProtocol () -import Ouroboros.Network.NodeToClient.Version (NodeToClientVersion (..)) +import Cardano.Network.NodeToClient.Version (NodeToClientVersion (..)) import Ouroboros.Network.Protocol.LocalStateQuery.Codec -- | LocalStateQuery uses versioned queries, which means it requires the Node to support a minimum From f2723be0a896736d82d7ae4193db7bebda6c4b52 Mon Sep 17 00:00:00 2001 From: Georgy Lukyanov Date: Fri, 30 Jan 2026 12:25:59 +0100 Subject: [PATCH 13/32] Rename Leger's `PParams` fields --- .../src/Cardano/Api/Genesis/Internal.hs | 4 +-- .../src/Cardano/Api/Internal/Orphans/Misc.hs | 28 +++++++++---------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/cardano-api/src/Cardano/Api/Genesis/Internal.hs b/cardano-api/src/Cardano/Api/Genesis/Internal.hs index 773d72e6da..17df805cc5 100644 --- a/cardano-api/src/Cardano/Api/Genesis/Internal.hs +++ b/cardano-api/src/Cardano/Api/Genesis/Internal.hs @@ -171,8 +171,8 @@ shelleyGenesisDefaults = & ppMaxBBSizeL .~ 64 * 1024 -- max 64kb blocks & ppMaxTxSizeL .~ 16 * 1024 -- max 16kb txs & ppEMaxL .~ EpochInterval 18 - & ppMinFeeAL .~ Coin 1 -- The linear factor for the minimum fee calculation - & ppMinFeeBL .~ Coin 0 -- The constant factor for the minimum fee calculation + & ppTxFeePerByteL .~ CoinPerByte (L.CompactCoin 1) -- The linear factor for the minimum fee calculation + & ppTxFeeFixedL .~ Coin 0 -- The constant factor for the minimum fee calculation -- pot = tx_fees + ρ * remaining_reserves & ppRhoL .~ unsafeBR (1 % 10) -- How much of reserves goes into pot & ppTauL .~ unsafeBR (1 % 10) -- τ * remaining_reserves is sent to treasury every epoch diff --git a/cardano-api/src/Cardano/Api/Internal/Orphans/Misc.hs b/cardano-api/src/Cardano/Api/Internal/Orphans/Misc.hs index dfe75284c1..f005c82369 100644 --- a/cardano-api/src/Cardano/Api/Internal/Orphans/Misc.hs +++ b/cardano-api/src/Cardano/Api/Internal/Orphans/Misc.hs @@ -73,8 +73,8 @@ deriving newtype instance Bits L.Coin -- In this instance we take the last 'Just' value or the only 'Just' value instance Semigroup (Ledger.ShelleyPParams StrictMaybe era) where (<>) pp1 pp2 = - let fsppMinFeeA = lastMappendWith Ledger.sppMinFeeA pp1 pp2 - fsppMinFeeB = lastMappendWith Ledger.sppMinFeeB pp1 pp2 + let fsppTxFeePerByte = lastMappendWith Ledger.sppTxFeePerByte pp1 pp2 + fsppTxFeeFixed = lastMappendWith Ledger.sppTxFeeFixed pp1 pp2 fsppMaxBBSize = lastMappendWith Ledger.sppMaxBBSize pp1 pp2 fsppMaxTxSize = lastMappendWith Ledger.sppMaxTxSize pp1 pp2 fsppMaxBHSize = lastMappendWith Ledger.sppMaxBHSize pp1 pp2 @@ -91,8 +91,8 @@ instance Semigroup (Ledger.ShelleyPParams StrictMaybe era) where fsppMinUTxOValue = lastMappendWith Ledger.sppMinUTxOValue pp1 pp2 fsppMinPoolCost = lastMappendWith Ledger.sppMinPoolCost pp1 pp2 in Ledger.ShelleyPParams - { Ledger.sppMinFeeA = fsppMinFeeA - , Ledger.sppMinFeeB = fsppMinFeeB + { Ledger.sppTxFeePerByte = fsppTxFeePerByte + , Ledger.sppTxFeeFixed = fsppTxFeeFixed , Ledger.sppMaxBBSize = fsppMaxBBSize , Ledger.sppMaxTxSize = fsppMaxTxSize , Ledger.sppMaxBHSize = fsppMaxBHSize @@ -112,8 +112,8 @@ instance Semigroup (Ledger.ShelleyPParams StrictMaybe era) where instance Semigroup (Ledger.AlonzoPParams StrictMaybe era) where (<>) p1 p2 = - let fappMinFeeA = lastMappendWith Ledger.appMinFeeA p1 p2 - fappMinFeeB = lastMappendWith Ledger.appMinFeeB p1 p2 + let fappTxFeePerByte = lastMappendWith Ledger.appTxFeePerByte p1 p2 + fappTxFeeFixed = lastMappendWith Ledger.appTxFeeFixed p1 p2 fappMaxBBSize = lastMappendWith Ledger.appMaxBBSize p1 p2 fappMaxTxSize = lastMappendWith Ledger.appMaxTxSize p1 p2 fappMaxBHSize = lastMappendWith Ledger.appMaxBHSize p1 p2 @@ -137,8 +137,8 @@ instance Semigroup (Ledger.AlonzoPParams StrictMaybe era) where fappCollateralPercentage = lastMappendWith Ledger.appCollateralPercentage p1 p2 fappMaxCollateralInputs = lastMappendWith Ledger.appMaxCollateralInputs p1 p2 in Ledger.AlonzoPParams - { Ledger.appMinFeeA = fappMinFeeA - , Ledger.appMinFeeB = fappMinFeeB + { Ledger.appTxFeePerByte = fappTxFeePerByte + , Ledger.appTxFeeFixed = fappTxFeeFixed , Ledger.appMaxBBSize = fappMaxBBSize , Ledger.appMaxTxSize = fappMaxTxSize , Ledger.appMaxBHSize = fappMaxBHSize @@ -179,8 +179,8 @@ lastMappendWith l = under2 l lastMappend instance Semigroup (Ledger.BabbagePParams StrictMaybe era) where (<>) p1 p2 = - let fbppMinFeeA = lastMappendWith Ledger.bppMinFeeA p1 p2 - fbppMinFeeB = lastMappendWith Ledger.bppMinFeeB p1 p2 + let fbppTxFeePerByte = lastMappendWith Ledger.bppTxFeePerByte p1 p2 + fbppTxFeeFixed = lastMappendWith Ledger.bppTxFeeFixed p1 p2 fbppMaxBBSize = lastMappendWith Ledger.bppMaxBBSize p1 p2 fbppMaxTxSize = lastMappendWith Ledger.bppMaxTxSize p1 p2 fbppMaxBHSize = lastMappendWith Ledger.bppMaxBHSize p1 p2 @@ -202,8 +202,8 @@ instance Semigroup (Ledger.BabbagePParams StrictMaybe era) where fbppCollateralPercentage = lastMappendWith Ledger.bppCollateralPercentage p1 p2 fbppMaxCollateralInputs = lastMappendWith Ledger.bppMaxCollateralInputs p1 p2 in Ledger.BabbagePParams - { Ledger.bppMinFeeA = fbppMinFeeA - , Ledger.bppMinFeeB = fbppMinFeeB + { Ledger.bppTxFeePerByte = fbppTxFeePerByte + , Ledger.bppTxFeeFixed = fbppTxFeeFixed , Ledger.bppMaxBBSize = fbppMaxBBSize , Ledger.bppMaxTxSize = fbppMaxTxSize , Ledger.bppMaxBHSize = fbppMaxBHSize @@ -229,8 +229,8 @@ instance Semigroup (Ledger.BabbagePParams StrictMaybe era) where instance Semigroup (Ledger.ConwayPParams StrictMaybe era) where (<>) p1 p2 = Ledger.ConwayPParams - { Ledger.cppMinFeeA = lastMappendWithTHKD Ledger.cppMinFeeA p1 p2 - , Ledger.cppMinFeeB = lastMappendWithTHKD Ledger.cppMinFeeB p1 p2 + { Ledger.cppTxFeePerByte = lastMappendWithTHKD Ledger.cppTxFeePerByte p1 p2 + , Ledger.cppTxFeeFixed = lastMappendWithTHKD Ledger.cppTxFeeFixed p1 p2 , Ledger.cppMaxBBSize = lastMappendWithTHKD Ledger.cppMaxBBSize p1 p2 , Ledger.cppMaxTxSize = lastMappendWithTHKD Ledger.cppMaxTxSize p1 p2 , Ledger.cppMaxBHSize = lastMappendWithTHKD Ledger.cppMaxBHSize p1 p2 From b56b96747a80ccd3cf52f05c0f673d5ef53b3681 Mon Sep 17 00:00:00 2001 From: Georgy Lukyanov Date: Mon, 2 Feb 2026 12:45:10 +0100 Subject: [PATCH 14/32] Bump Consensus and Ledger srps --- cabal.project | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cabal.project b/cabal.project index d3a5cc64e7..7a179cbc7c 100644 --- a/cabal.project +++ b/cabal.project @@ -168,8 +168,8 @@ if arch(wasm32) source-repository-package type: git location: https://github.com/IntersectMBO/cardano-ledger - tag: eabc9e0ddf9ad01785d292c775bb90bcf29b46df - --sha256: sha256-CirNK/WNWPSmqnEBR6IyKz8UW5JcAh6YQCg8p31AzBU= + tag: 324efe565237061615ec10e7f47e08699cace660 + --sha256: sha256-Tu5TlPwJgVpEfTui+zbaUJIOMoexCwFTQ5M/n2DP2/I= subdir: eras/allegra/impl eras/alonzo/impl @@ -198,8 +198,8 @@ source-repository-package source-repository-package type: git location: https://github.com/IntersectMBO/ouroboros-consensus - tag: 678aec0ce019c741a892e519386cb24913cc36dc - --sha256: sha256-F6VHW5O4yWmLLqxH8IVhxlfrjXm4Mb+eECEPbAoZzh8= + tag: 93709ba7fe1145227e7128e21d535421a74b1920 + --sha256: sha256-vLwuGcjbMhSBVVJ6qT2XstuJJrildXnpst//B23in0Y= subdir: ouroboros-consensus ouroboros-consensus-cardano From 1b548817cdbf4428611ca9816344d2768927a9d0 Mon Sep 17 00:00:00 2001 From: Georgy Lukyanov Date: Mon, 2 Feb 2026 12:49:03 +0100 Subject: [PATCH 15/32] Shelley.RewardAccount -> Shelley.AccountAddress --- cardano-api/src/Cardano/Api/Address.hs | 20 ++++++++--------- .../Internal/Action/ProposalProcedure.hs | 10 +++++---- .../Api/Internal/Orphans/Serialisation.hs | 22 +++++++++++++------ .../Cardano/Api/Ledger/Internal/Reexport.hs | 4 ++-- 4 files changed, 33 insertions(+), 23 deletions(-) diff --git a/cardano-api/src/Cardano/Api/Address.hs b/cardano-api/src/Cardano/Api/Address.hs index f7bd3ead7d..e4711751eb 100644 --- a/cardano-api/src/Cardano/Api/Address.hs +++ b/cardano-api/src/Cardano/Api/Address.hs @@ -103,8 +103,8 @@ import Cardano.Chain.Common qualified as Byron import Cardano.Ledger.Address qualified as Shelley import Cardano.Ledger.BaseTypes qualified as Shelley import Cardano.Ledger.Credential qualified as Shelley -import Cardano.Ledger.Plutus.TxInfo qualified as Plutus import Cardano.Ledger.Keys qualified as Shelley +import Cardano.Ledger.Plutus.TxInfo qualified as Plutus import PlutusLedgerApi.V1 qualified as PlutusAPI import Control.Applicative ((<|>)) @@ -568,12 +568,12 @@ instance HasTypeProxy StakeAddress where instance SerialiseAsRawBytes StakeAddress where serialiseToRawBytes (StakeAddress nw sc) = - Shelley.serialiseRewardAccount (Shelley.RewardAccount nw sc) + Shelley.serialiseAccountAddress (Shelley.AccountAddress nw (Shelley.AccountId sc)) deserialiseFromRawBytes AsStakeAddress bs = - case Shelley.deserialiseRewardAccount bs of + case Shelley.deserialiseAccountAddress bs of Nothing -> Left (SerialiseAsRawBytesError "Unable to deserialise StakeAddress") - Just (Shelley.RewardAccount nw sc) -> Right (StakeAddress nw sc) + Just (Shelley.AccountAddress nw (Shelley.AccountId sc)) -> Right (StakeAddress nw sc) instance SerialiseAsBech32 StakeAddress where bech32PrefixFor (StakeAddress Shelley.Mainnet _) = unsafeHumanReadablePartFromText "stake" @@ -644,11 +644,11 @@ toShelleyAddr ) = Shelley.Addr nw pc scr -toShelleyStakeAddr :: StakeAddress -> Shelley.RewardAccount +toShelleyStakeAddr :: StakeAddress -> Shelley.AccountAddress toShelleyStakeAddr (StakeAddress nw sc) = - Shelley.RewardAccount - { Shelley.raNetwork = nw - , Shelley.raCredential = sc + Shelley.AccountAddress + { Shelley.aaNetworkId = nw + , Shelley.aaAccountId = (Shelley.AccountId sc) } toShelleyPaymentCredential @@ -701,8 +701,8 @@ fromShelleyAddr sbe (Shelley.Addr nw pc scr) = (ShelleyAddressInEra sbe) (ShelleyAddress nw pc scr) -fromShelleyStakeAddr :: Shelley.RewardAccount -> StakeAddress -fromShelleyStakeAddr (Shelley.RewardAccount nw sc) = StakeAddress nw sc +fromShelleyStakeAddr :: Shelley.AccountAddress -> StakeAddress +fromShelleyStakeAddr (Shelley.AccountAddress nw (Shelley.AccountId sc)) = StakeAddress nw sc fromShelleyStakeCredential :: Shelley.Credential Shelley.Staking diff --git a/cardano-api/src/Cardano/Api/Governance/Internal/Action/ProposalProcedure.hs b/cardano-api/src/Cardano/Api/Governance/Internal/Action/ProposalProcedure.hs index 6ca5b03cfb..13408f94c5 100644 --- a/cardano-api/src/Cardano/Api/Governance/Internal/Action/ProposalProcedure.hs +++ b/cardano-api/src/Cardano/Api/Governance/Internal/Action/ProposalProcedure.hs @@ -105,7 +105,9 @@ toGovernanceAction sbe = InfoAct -> Gov.InfoAction TreasuryWithdrawal withdrawals govPol -> - let m = fromList [(L.RewardAccount nw (toShelleyStakeCredential sc), l) | (nw, sc, l) <- withdrawals] + let m = + fromList + [(L.AccountAddress nw (L.AccountId (toShelleyStakeCredential sc)), l) | (nw, sc, l) <- withdrawals] in Gov.TreasuryWithdrawals m govPol InitiateHardfork prevGovId pVer -> Gov.HardForkInitiation prevGovId pVer @@ -129,7 +131,7 @@ fromGovernanceAction = \case InitiateHardfork prevGovId pVer Gov.TreasuryWithdrawals withdrawlMap govPolicy -> let res = - [ (L.raNetwork rwdAcnt, fromShelleyStakeCredential (L.raCredential rwdAcnt), coin) + [ (L.aaNetworkId rwdAcnt, fromShelleyStakeCredential (L.unAccountId $ L.aaAccountId rwdAcnt), coin) | (rwdAcnt, coin) <- toList withdrawlMap ] in TreasuryWithdrawal res govPolicy @@ -202,7 +204,7 @@ createProposalProcedure sbe nw dep cred govAct anchor = Proposal Gov.ProposalProcedure { Gov.pProcDeposit = dep - , Gov.pProcReturnAddr = L.RewardAccount nw $ toShelleyStakeCredential cred + , Gov.pProcReturnAddr = L.AccountAddress nw (L.AccountId $ toShelleyStakeCredential cred) , Gov.pProcGovAction = toGovernanceAction sbe govAct , Gov.pProcAnchor = anchor } @@ -215,7 +217,7 @@ fromProposalProcedure sbe (Proposal pp) = shelleyBasedEraConstraints sbe ( Gov.pProcDeposit pp - , fromShelleyStakeCredential (L.raCredential (Gov.pProcReturnAddr pp)) + , fromShelleyStakeCredential (L.unAccountId $ L.aaAccountId (Gov.pProcReturnAddr pp)) , fromGovernanceAction (Gov.pProcGovAction pp) ) diff --git a/cardano-api/src/Cardano/Api/Internal/Orphans/Serialisation.hs b/cardano-api/src/Cardano/Api/Internal/Orphans/Serialisation.hs index de0d2cced8..9fdd38b706 100644 --- a/cardano-api/src/Cardano/Api/Internal/Orphans/Serialisation.hs +++ b/cardano-api/src/Cardano/Api/Internal/Orphans/Serialisation.hs @@ -99,7 +99,9 @@ import Data.Aeson ( KeyValue ((.=)) , ToJSON (..) , ToJSONKey (..) + , decode , defaultOptions + , encode , genericToJSON , object , pairs @@ -117,8 +119,12 @@ import Data.Data (Data) import Data.Kind (Constraint, Type) import Data.ListMap (ListMap) import Data.ListMap qualified as ListMap +import Data.Map.NonEmpty (NonEmptyMap) +import Data.Map.NonEmpty qualified as NonEmptyMap import Data.Maybe.Strict (StrictMaybe (..)) import Data.Monoid +import Data.Set.NonEmpty (NonEmptySet) +import Data.Set.NonEmpty qualified as NonEmptySet import Data.Text qualified as T import Data.Text qualified as Text import Data.Text.Encoding qualified as Text @@ -134,8 +140,6 @@ import Numeric (showHex) import Prettyprinter (punctuate, viaShow) import Text.Read -deriving instance Generic (L.ApplyTxError era) - deriving instance Generic (L.Registration.TooLarge a) deriving instance Generic L.ApplicationNameError @@ -200,9 +204,16 @@ deriving anyclass instance ToJSON L.VotingPeriod deriving anyclass instance ToJSON L.Withdrawals +instance ToJSON (NonEmptyMap k v) where + toJSON = undefined + +instance ToJSON (NonEmptySet v) where + toJSON = undefined + deriving anyclass instance ( ToJSON (L.PredicateFailure (L.EraRule "UTXOW" ledgerera)) , ToJSON (L.PredicateFailure (L.EraRule "DELEGS" ledgerera)) + , ToJSON (NonEmptyMap L.AccountAddress (Ledger.Mismatch Ledger.RelEQ L.Coin)) ) => ToJSON (L.ShelleyLedgerPredFailure ledgerera) @@ -236,9 +247,8 @@ instance where toJSON = genericToJSON defaultOptions -deriving anyclass instance - ToJSON (L.PredicateFailure (L.EraRule "LEDGER" ledgerera)) - => ToJSON (L.ApplyTxError ledgerera) +instance ToJSON (L.ApplyTxError ledgerera) where + toJSON = undefined deriving via ShowOf (L.Keys.VKey L.Keys.Witness) @@ -366,8 +376,6 @@ instance ToJSON (HeaderHash blk) => ToJSON (Tip blk) where -- Simple newtype wrappers JSON conversion -- -deriving newtype instance ToJSON ShelleyHash - deriving newtype instance ToJSON HashHeader deriving instance ToJSON Ledger.PrtclState diff --git a/cardano-api/src/Cardano/Api/Ledger/Internal/Reexport.hs b/cardano-api/src/Cardano/Api/Ledger/Internal/Reexport.hs index c4e2d9cf8c..751bfeb126 100644 --- a/cardano-api/src/Cardano/Api/Ledger/Internal/Reexport.hs +++ b/cardano-api/src/Cardano/Api/Ledger/Internal/Reexport.hs @@ -210,12 +210,12 @@ module Cardano.Api.Ledger.Internal.Reexport , unsafeMakeSafeHash , extractHash -- Reward - , RewardAccount (..) + , AccountAddress (..) ) where import Cardano.Crypto.Hash.Class (hashFromBytes, hashToBytes) -import Cardano.Ledger.Address (Addr (..), RewardAccount (..)) +import Cardano.Ledger.Address (Addr (..), AccountAddress (..)) import Cardano.Ledger.Allegra.Scripts (AllegraEraScript (..), Timelock (..), showTimelock) import Cardano.Ledger.Alonzo.Core ( AlonzoEraScript (..) From 46d1da597f97a47177882c8ac74e1c453fae7f1a Mon Sep 17 00:00:00 2001 From: Georgy Lukyanov Date: Mon, 2 Feb 2026 13:02:25 +0100 Subject: [PATCH 16/32] Integrate `PoolMetadata` hash type change --- cardano-api/cardano-api.cabal | 1 + .../src/Cardano/Api/Certificate/Internal.hs | 25 +++++++++++++------ .../Experimental/Tx/Internal/Certificate.hs | 10 +++++--- 3 files changed, 25 insertions(+), 11 deletions(-) diff --git a/cardano-api/cardano-api.cabal b/cardano-api/cardano-api.cabal index bc9320f6bb..f0bec5133c 100644 --- a/cardano-api/cardano-api.cabal +++ b/cardano-api/cardano-api.cabal @@ -159,6 +159,7 @@ library groups, iproute, memory, + mempack, microlens <0.5, mono-traversable, mtl, diff --git a/cardano-api/src/Cardano/Api/Certificate/Internal.hs b/cardano-api/src/Cardano/Api/Certificate/Internal.hs index 18da0c9e67..4bae9b4c63 100644 --- a/cardano-api/src/Cardano/Api/Certificate/Internal.hs +++ b/cardano-api/src/Cardano/Api/Certificate/Internal.hs @@ -97,10 +97,13 @@ import Cardano.Ledger.State qualified as Ledger import Control.Monad import Control.Monad.Except (MonadError (..)) +import Data.Array.Byte (ByteArray) import Data.ByteString (ByteString) import Data.ByteString qualified as BS +import Data.ByteString.Short qualified as SBS import Data.IP (IPv4, IPv6) import Data.Maybe +import Data.MemPack.Buffer (byteArrayFromShortByteString, byteArrayToShortByteString) import Data.Text (Text) import Data.Text qualified as Text import Data.Text.Encoding qualified as Text @@ -672,7 +675,7 @@ toShelleyPoolParams fromMaybe (error "toShelleyPoolParams: invalid PoolMargin") (Ledger.boundRational stakePoolMargin) - , Ledger.sppRewardAccount = toShelleyStakeAddr stakePoolRewardAccount + , Ledger.sppAccountAddress = toShelleyStakeAddr stakePoolRewardAccount , Ledger.sppOwners = fromList [kh | StakeKeyHash kh <- stakePoolOwners] @@ -706,7 +709,7 @@ toShelleyPoolParams } = Ledger.PoolMetadata { Ledger.pmUrl = toShelleyUrl stakePoolMetadataURL - , Ledger.pmHash = Ledger.hashToBytes mdh + , Ledger.pmHash = byteArrayFromShortByteString . SBS.toShort $ Ledger.hashToBytes mdh } toShelleyDnsName :: ByteString -> Ledger.DnsName @@ -730,7 +733,7 @@ fromShelleyPoolParams , Ledger.sppPledge , Ledger.sppCost , Ledger.sppMargin - , Ledger.sppRewardAccount + , Ledger.sppAccountAddress , Ledger.sppOwners , Ledger.sppRelays , Ledger.sppMetadata @@ -740,7 +743,7 @@ fromShelleyPoolParams , stakePoolVRF = VrfKeyHash (Ledger.fromVRFVerKeyHash sppVrf) , stakePoolCost = sppCost , stakePoolMargin = Ledger.unboundRational sppMargin - , stakePoolRewardAccount = fromShelleyStakeAddr sppRewardAccount + , stakePoolRewardAccount = fromShelleyStakeAddr sppAccountAddress , stakePoolPledge = sppPledge , stakePoolOwners = map StakeKeyHash (toList sppOwners) , stakePoolRelays = @@ -778,6 +781,8 @@ fromShelleyPoolParams StakePoolMetadataHash . fromMaybe (error "fromShelleyPoolMetadata: invalid hash. TODO: proper validation") . Ledger.hashFromBytes + . SBS.fromShort + . byteArrayToShortByteString $ pmHash } @@ -798,7 +803,7 @@ fromShelleyStakePoolState , Ledger.spsPledge , Ledger.spsCost , Ledger.spsMargin - , Ledger.spsRewardAccount + , Ledger.spsAccountAddress , Ledger.spsOwners , Ledger.spsRelays , Ledger.spsMetadata @@ -808,7 +813,7 @@ fromShelleyStakePoolState , stakePoolVRF = VrfKeyHash (Ledger.fromVRFVerKeyHash spsVrf) , stakePoolCost = spsCost , stakePoolMargin = Ledger.unboundRational spsMargin - , stakePoolRewardAccount = StakeAddress undefined spsRewardAccount -- TODO the Network argument was removed in Ledger + , stakePoolRewardAccount = StakeAddress undefined spsAccountAddress -- TODO the Network argument was removed in Ledger , stakePoolPledge = spsPledge , stakePoolOwners = map StakeKeyHash (toList spsOwners) , stakePoolRelays = @@ -846,6 +851,8 @@ fromShelleyStakePoolState StakePoolMetadataHash . fromMaybe (error "fromShelleyPoolMetadata: invalid hash. TODO: proper validation") . Ledger.hashFromBytes + . SBS.fromShort + . byteArrayToShortByteString $ pmHash } @@ -856,7 +863,7 @@ fromShelleyStakePoolState . Ledger.dnsToText data AnchorDataFromCertificateError - = InvalidPoolMetadataHashError Ledger.Url ByteString + = InvalidPoolMetadataHashError Ledger.Url ByteArray deriving (Eq, Show) instance Error AnchorDataFromCertificateError where @@ -907,7 +914,9 @@ getAnchorDataFromCertificate c = anchorDataFromPoolMetadata (Ledger.PoolMetadata{Ledger.pmUrl = url, Ledger.pmHash = hashBytes}) = do hash <- maybe (throwError $ InvalidPoolMetadataHashError url hashBytes) return $ - Ledger.hashFromBytes hashBytes + Ledger.hashFromBytes $ + SBS.fromShort $ + byteArrayToShortByteString hashBytes return $ Just ( Ledger.Anchor diff --git a/cardano-api/src/Cardano/Api/Experimental/Tx/Internal/Certificate.hs b/cardano-api/src/Cardano/Api/Experimental/Tx/Internal/Certificate.hs index 8dec157474..a8383200db 100644 --- a/cardano-api/src/Cardano/Api/Experimental/Tx/Internal/Certificate.hs +++ b/cardano-api/src/Cardano/Api/Experimental/Tx/Internal/Certificate.hs @@ -55,7 +55,9 @@ import Cardano.Api.Serialise.TextEnvelope.Internal import Cardano.Ledger.BaseTypes (strictMaybe) import Control.Monad.Except (MonadError (..)) -import Data.ByteString (ByteString) +import Data.Array.Byte (ByteArray) +import Data.ByteString.Short qualified as SBS +import Data.MemPack.Buffer (byteArrayToShortByteString) import Data.String (IsString (fromString)) makeStakeAddressDelegationCertificate @@ -229,7 +231,9 @@ anchorDataFromPoolMetadata anchorDataFromPoolMetadata (Ledger.PoolMetadata{Ledger.pmUrl = url, Ledger.pmHash = hashBytes}) = do hash <- maybe (throwError $ InvalidPoolMetadataHashError url hashBytes) return $ - Ledger.hashFromBytes hashBytes + Ledger.hashFromBytes $ + SBS.fromShort $ + byteArrayToShortByteString hashBytes return $ Just ( Ledger.Anchor @@ -239,7 +243,7 @@ anchorDataFromPoolMetadata (Ledger.PoolMetadata{Ledger.pmUrl = url, Ledger.pmHas ) data AnchorDataFromCertificateError - = InvalidPoolMetadataHashError Ledger.Url ByteString + = InvalidPoolMetadataHashError Ledger.Url ByteArray deriving (Eq, Show) instance Error AnchorDataFromCertificateError where From 09adff6111bc124c1609fa87fd2441345d8621b5 Mon Sep 17 00:00:00 2001 From: Georgy Lukyanov Date: Mon, 2 Feb 2026 13:41:57 +0100 Subject: [PATCH 17/32] [wip] Coin -> CompactCoin Coin --- .../src/Cardano/Api/ProtocolParameters.hs | 33 ++++++++++++------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/cardano-api/src/Cardano/Api/ProtocolParameters.hs b/cardano-api/src/Cardano/Api/ProtocolParameters.hs index 12b794f845..04cc9526ab 100644 --- a/cardano-api/src/Cardano/Api/ProtocolParameters.hs +++ b/cardano-api/src/Cardano/Api/ProtocolParameters.hs @@ -118,6 +118,7 @@ import Cardano.Ledger.Babbage.Core qualified as Ledger import Cardano.Ledger.BaseTypes (strictMaybeToMaybe) import Cardano.Ledger.BaseTypes qualified as Ledger import Cardano.Ledger.Coin qualified as L +import Cardano.Ledger.Compactible qualified as Ledger import Cardano.Ledger.Conway.PParams qualified as Ledger import Cardano.Ledger.Hashes (HASH) import Cardano.Ledger.Plutus.CostModels qualified as Plutus @@ -301,8 +302,8 @@ createEraBasedProtocolParamUpdate sbe eraPParamsUpdate = -- if parameters are deprecated. data CommonProtocolParametersUpdate = CommonProtocolParametersUpdate - { cppMinFeeA :: StrictMaybe Ledger.Coin - , cppMinFeeB :: StrictMaybe Ledger.Coin + { cppTxFeePerByteL :: StrictMaybe Ledger.CoinPerByte + , cppTxFeeFixedL :: StrictMaybe Ledger.Coin , cppMaxBlockBodySize :: StrictMaybe Word32 , cppMaxTxSize :: StrictMaybe Word32 , cppMaxBlockHeaderSize :: StrictMaybe Word16 @@ -322,8 +323,8 @@ createCommonPParamsUpdate :: EraPParams ledgerera => CommonProtocolParametersUpdate -> Ledger.PParamsUpdate ledgerera createCommonPParamsUpdate CommonProtocolParametersUpdate{..} = emptyPParamsUpdate - & Ledger.ppuMinFeeAL .~ cppMinFeeA - & Ledger.ppuMinFeeBL .~ cppMinFeeB + & Ledger.ppuTxFeePerByteL .~ cppTxFeePerByteL + & Ledger.ppuTxFeeFixedL .~ cppTxFeeFixedL & Ledger.ppuMaxBBSizeL .~ cppMaxBlockBodySize & Ledger.ppuMaxTxSizeL .~ cppMaxTxSize & Ledger.ppuMaxBHSizeL .~ cppMaxBlockHeaderSize @@ -678,7 +679,8 @@ data ProtocolParametersUpdate -- algorithm. , protocolUpdateTxFeeFixed :: Maybe L.Coin -- ^ The constant factor for the minimum fee calculation. - , protocolUpdateTxFeePerByte :: Maybe L.Coin + , protocolUpdateTxFeePerByte :: Maybe L.Coin -- TODO: consider using Ledger.CoinPerByte + -- ^ The linear factor for the minimum fee calculation. , protocolUpdateMinUTxOValue :: Maybe L.Coin -- ^ The minimum permitted value for new UTxO entries, ie for @@ -1137,8 +1139,8 @@ toShelleyCommonPParamsUpdate tau <- mapM (boundRationalEither "Tau") protocolUpdateTreasuryCut let ppuCommon = emptyPParamsUpdate - & ppuMinFeeAL .~ noInlineMaybeToStrictMaybe protocolUpdateTxFeePerByte - & ppuMinFeeBL .~ noInlineMaybeToStrictMaybe protocolUpdateTxFeeFixed + & ppuTxFeePerByteL .~ noInlineMaybeToStrictMaybe (unsafeToCoinPerByte <$> protocolUpdateTxFeePerByte) + & ppuTxFeeFixedL .~ noInlineMaybeToStrictMaybe protocolUpdateTxFeeFixed & ppuMaxBBSizeL .~ noInlineMaybeToStrictMaybe protocolUpdateMaxBlockBodySize & ppuMaxTxSizeL .~ noInlineMaybeToStrictMaybe protocolUpdateMaxTxSize & ppuMaxBHSizeL .~ noInlineMaybeToStrictMaybe protocolUpdateMaxBlockHeaderSize @@ -1151,6 +1153,9 @@ toShelleyCommonPParamsUpdate & ppuTauL .~ noInlineMaybeToStrictMaybe tau & ppuMinPoolCostL .~ noInlineMaybeToStrictMaybe protocolUpdateMinPoolCost pure ppuCommon + where + -- TODO: instead, use 'CoinPerByte' in 'ProtocolParametersUpdate' + unsafeToCoinPerByte = Ledger.CoinPerByte . Ledger.toCompactPartial toShelleyPParamsUpdate :: ( EraPParams ledgerera @@ -1240,8 +1245,12 @@ toBabbageCommonPParamsUpdate ppuAlonzoCommon <- toAlonzoCommonPParamsUpdate protocolParametersUpdate let ppuBabbage = ppuAlonzoCommon - & ppuCoinsPerUTxOByteL .~ fmap CoinPerByte (noInlineMaybeToStrictMaybe protocolUpdateUTxOCostPerByte) + & ppuCoinsPerUTxOByteL + .~ fmap (CoinPerByte . unsafeToCompact) (noInlineMaybeToStrictMaybe protocolUpdateUTxOCostPerByte) pure ppuBabbage + where + -- TODO: instead, use CompactCoin in ProtocolParametersUpdate + unsafeToCompact = Ledger.toCompactPartial toBabbagePParamsUpdate :: ProtocolParametersUpdate @@ -1322,8 +1331,9 @@ fromShelleyCommonPParamsUpdate ppu = , protocolUpdateMaxBlockHeaderSize = strictMaybeToMaybe (ppu ^. ppuMaxBHSizeL) , protocolUpdateMaxBlockBodySize = strictMaybeToMaybe (ppu ^. ppuMaxBBSizeL) , protocolUpdateMaxTxSize = strictMaybeToMaybe (ppu ^. ppuMaxTxSizeL) - , protocolUpdateTxFeeFixed = strictMaybeToMaybe (ppu ^. ppuMinFeeBL) - , protocolUpdateTxFeePerByte = strictMaybeToMaybe (ppu ^. ppuMinFeeAL) + , protocolUpdateTxFeeFixed = strictMaybeToMaybe (ppu ^. ppuTxFeeFixedL) + , protocolUpdateTxFeePerByte = + Ledger.fromCompact . unCoinPerByte <$> strictMaybeToMaybe (ppu ^. ppuTxFeePerByteL) , protocolUpdateStakeAddressDeposit = strictMaybeToMaybe (ppu ^. ppuKeyDepositL) , protocolUpdateStakePoolDeposit = strictMaybeToMaybe (ppu ^. ppuPoolDepositL) , protocolUpdateMinPoolCost = strictMaybeToMaybe (ppu ^. ppuMinPoolCostL) @@ -1409,7 +1419,8 @@ fromBabbageCommonPParamsUpdate -> ProtocolParametersUpdate fromBabbageCommonPParamsUpdate ppu = (fromAlonzoCommonPParamsUpdate ppu) - { protocolUpdateUTxOCostPerByte = unCoinPerByte <$> strictMaybeToMaybe (ppu ^. ppuCoinsPerUTxOByteL) + { protocolUpdateUTxOCostPerByte = + Ledger.fromCompact . unCoinPerByte <$> strictMaybeToMaybe (ppu ^. ppuCoinsPerUTxOByteL) } fromBabbagePParamsUpdate From 4138f0b9202ab143a916a7bad672deb2d1d336b3 Mon Sep 17 00:00:00 2001 From: Georgy Lukyanov Date: Mon, 2 Feb 2026 14:06:00 +0100 Subject: [PATCH 18/32] Use new name of the Constitution script hash --- .../Api/Governance/Internal/Action/ProposalProcedure.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cardano-api/src/Cardano/Api/Governance/Internal/Action/ProposalProcedure.hs b/cardano-api/src/Cardano/Api/Governance/Internal/Action/ProposalProcedure.hs index 13408f94c5..67fe257b41 100644 --- a/cardano-api/src/Cardano/Api/Governance/Internal/Action/ProposalProcedure.hs +++ b/cardano-api/src/Cardano/Api/Governance/Internal/Action/ProposalProcedure.hs @@ -85,7 +85,7 @@ toGovernanceAction sbe = prevGovAction Gov.Constitution { Gov.constitutionAnchor = anchor - , Gov.constitutionScript = mConstitutionScriptHash + , Gov.constitutionGuardrailsScriptHash = mConstitutionScriptHash } ProposeNewCommittee prevGovId oldCommitteeMembers newCommitteeMembers quor -> Gov.UpdateCommittee @@ -124,7 +124,7 @@ fromGovernanceAction = \case ProposeNewConstitution prevGovId (Gov.constitutionAnchor constitution) - (Gov.constitutionScript constitution) + (Gov.constitutionGuardrailsScriptHash constitution) Gov.ParameterChange prevGovId pparams govPolicy -> UpdatePParams prevGovId pparams govPolicy Gov.HardForkInitiation prevGovId pVer -> From cc4905c1a2e5b17dbc5737d953cffcad5e02eb91 Mon Sep 17 00:00:00 2001 From: Georgy Lukyanov Date: Mon, 2 Feb 2026 15:25:02 +0100 Subject: [PATCH 19/32] [wip] integrate GetLedgerPeerSnapshot query --- .../Api/Query/Internal/Type/QueryInMode.hs | 27 ++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/cardano-api/src/Cardano/Api/Query/Internal/Type/QueryInMode.hs b/cardano-api/src/Cardano/Api/Query/Internal/Type/QueryInMode.hs index 39a5c537d1..451234d67c 100644 --- a/cardano-api/src/Cardano/Api/Query/Internal/Type/QueryInMode.hs +++ b/cardano-api/src/Cardano/Api/Query/Internal/Type/QueryInMode.hs @@ -427,14 +427,15 @@ decodeStakeSnapshot (SerialisedStakeSnapshots (Serialised ls)) = StakeSnapshot < decodeBigLedgerPeerSnapshot :: Consensus.ShelleyNodeToClientVersion -> Serialised LedgerPeerSnapshot - -> Either (LBS.ByteString, DecoderError) LedgerPeerSnapshot + -> Either (LBS.ByteString, DecoderError) (LedgerPeerSnapshot BigLedgerPeers) decodeBigLedgerPeerSnapshot ntcV (Serialised lps) = - first - (lps,) - $ Plain.decodeFullDecoder - "LedgerPeerSnapshot" - (decodeLedgerPeerSnapshot $ Consensus.ledgerPeerSnapshotSupportsSRV ntcV) - lps + -- first + -- (lps,) + -- $ Plain.decodeFullDecoder + -- "LedgerPeerSnapshot" + -- (decodeLedgerPeerSnapshot $ Consensus.ledgerPeerSnapshotSupportsSRV ntcV) + -- lps + undefined -- TODO(10.7) toShelleyAddrSet :: CardanoEra era @@ -693,8 +694,9 @@ toConsensusQueryShelleyBased sbe = \case (consensusQueryInEraInMode era (Consensus.GetProposals govActs)) ) sbe + -- TODO(10.7): support full GetLedgerPeerSnapshot query QueryLedgerPeerSnapshot -> - Some (consensusQueryInEraInMode era (Consensus.GetCBOR Consensus.GetBigLedgerPeerSnapshot)) + Some (consensusQueryInEraInMode era (Consensus.GetCBOR (Consensus.GetLedgerPeerSnapshot BigLedgerPeers))) QueryStakePoolDefaultVote govActs -> caseShelleyToBabbageOrConwayEraOnwards ( const $ @@ -1015,10 +1017,11 @@ fromConsensusQueryResultShelleyBased sbe sbeQuery q' r' = r' _ -> fromConsensusQueryResultMismatch QueryLedgerPeerSnapshot{} -> - case q' of - Consensus.GetCBOR Consensus.GetBigLedgerPeerSnapshot -> - r' - _ -> fromConsensusQueryResultMismatch + undefined -- TODO(10.7) + -- case q' of + -- Consensus.GetCBOR Consensus.GetLedgerPeerSnapshot{} -> + -- r' + -- _ -> fromConsensusQueryResultMismatch QueryStakePoolDefaultVote{} -> case q' of Consensus.QueryStakePoolDefaultVote{} -> From d3c83ff1236d10fa434e21a736d1088d64de7c70 Mon Sep 17 00:00:00 2001 From: Georgy Lukyanov Date: Mon, 2 Feb 2026 15:49:48 +0100 Subject: [PATCH 20/32] [wip] downgrade Consensus to make it build with the srp --- cardano-api/cardano-api.cabal | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cardano-api/cardano-api.cabal b/cardano-api/cardano-api.cabal index f0bec5133c..5c9bd206f6 100644 --- a/cardano-api/cardano-api.cabal +++ b/cardano-api/cardano-api.cabal @@ -167,9 +167,9 @@ library network-mux, nothunks, ordered-containers, - ouroboros-consensus ^>=0.29, + ouroboros-consensus ^>=0.28, ouroboros-consensus-cardano ^>=0.26, - ouroboros-consensus-diffusion ^>=0.25, + ouroboros-consensus-diffusion ^>=0.24, ouroboros-consensus-protocol ^>=0.13, ouroboros-network:{api, framework, ouroboros-network, protocols} ^>=0.24, parsec, From 35f61186b603515adf816a429e6b0ce320243493 Mon Sep 17 00:00:00 2001 From: Georgy Lukyanov Date: Mon, 2 Feb 2026 16:59:18 +0100 Subject: [PATCH 21/32] [wip] assorted integration work --- .../Experimental/Plutus/Internal/Shim/LegacyScripts.hs | 1 + .../src/Cardano/Api/Experimental/Simple/Script.hs | 2 +- .../Api/Experimental/Tx/Internal/BodyContent/New.hs | 10 +++++----- .../src/Cardano/Api/Experimental/Tx/Internal/Fee.hs | 8 ++++---- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/cardano-api/src/Cardano/Api/Experimental/Plutus/Internal/Shim/LegacyScripts.hs b/cardano-api/src/Cardano/Api/Experimental/Plutus/Internal/Shim/LegacyScripts.hs index bac3050367..c1cccbb33c 100644 --- a/cardano-api/src/Cardano/Api/Experimental/Plutus/Internal/Shim/LegacyScripts.hs +++ b/cardano-api/src/Cardano/Api/Experimental/Plutus/Internal/Shim/LegacyScripts.hs @@ -50,6 +50,7 @@ import Cardano.Ledger.BaseTypes (Version) import Cardano.Ledger.Core qualified as L import Cardano.Ledger.Dijkstra.Scripts qualified as Dijkstra import Cardano.Ledger.Plutus.Language qualified as L +import Cardano.Ledger.Mary.Value qualified as L import Data.Text qualified as Text import Data.Typeable diff --git a/cardano-api/src/Cardano/Api/Experimental/Simple/Script.hs b/cardano-api/src/Cardano/Api/Experimental/Simple/Script.hs index 977583eeaf..18167d42d2 100644 --- a/cardano-api/src/Cardano/Api/Experimental/Simple/Script.hs +++ b/cardano-api/src/Cardano/Api/Experimental/Simple/Script.hs @@ -49,7 +49,7 @@ instance r <- CBOR.runAnnotator <$> CBOR.decodeFull' (L.eraProtVerHigh @era) bs - return $ SimpleScript $ r $ CBOR.Full $ BS.fromStrict bs + SimpleScript <$> (r $ CBOR.Full $ BS.fromStrict bs) -- TODO: We should also deserialize the JSON representation of simple scripts. deserialiseSimpleScript diff --git a/cardano-api/src/Cardano/Api/Experimental/Tx/Internal/BodyContent/New.hs b/cardano-api/src/Cardano/Api/Experimental/Tx/Internal/BodyContent/New.hs index 088636192b..777b6dde06 100644 --- a/cardano-api/src/Cardano/Api/Experimental/Tx/Internal/BodyContent/New.hs +++ b/cardano-api/src/Cardano/Api/Experimental/Tx/Internal/BodyContent/New.hs @@ -173,9 +173,9 @@ makeUnsignedTx era@ConwayEra bc = obtainCommonConstraints era $ do & L.totalCollateralTxBodyL .~ L.maybeToStrictMaybe totCollateral & L.collateralReturnTxBodyL .~ L.maybeToStrictMaybe retCollateral & L.feeTxBodyL .~ fee - & L.vldtTxBodyL . L.invalidBeforeL .~ txValidityLowerBound bc - & L.vldtTxBodyL . L.invalidHereAfterL .~ txValidityUpperBound bc - & L.reqSignerHashesTxBodyL .~ setReqSignerHashes + & L.vldtTxBodyL . L.invalidBeforeL .~ (L.maybeToStrictMaybe $ txValidityLowerBound bc) + & L.vldtTxBodyL . L.invalidHereAfterL .~ (L.maybeToStrictMaybe $ txValidityUpperBound bc) + & L.reqSignerHashesTxBodyL .~ undefined --TODO(10.7): setReqSignerHashes & L.scriptIntegrityHashTxBodyL .~ scriptIntegrityHash & L.withdrawalsTxBodyL .~ withdrawals & L.certsTxBodyL .~ certs @@ -288,9 +288,9 @@ toAuxiliaryData txMData ss' = eraSpecificLedgerTxBody :: Era era - -> L.TxBody (LedgerEra era) + -> L.TxBody L.TopTx (LedgerEra era) -> TxBodyContent (LedgerEra era) - -> L.TxBody (LedgerEra era) + -> L.TxBody L.TopTx (LedgerEra era) eraSpecificLedgerTxBody era ledgerbody bc = body era where diff --git a/cardano-api/src/Cardano/Api/Experimental/Tx/Internal/Fee.hs b/cardano-api/src/Cardano/Api/Experimental/Tx/Internal/Fee.hs index 663a4beaf2..ed41ef92c1 100644 --- a/cardano-api/src/Cardano/Api/Experimental/Tx/Internal/Fee.hs +++ b/cardano-api/src/Cardano/Api/Experimental/Tx/Internal/Fee.hs @@ -551,12 +551,12 @@ evaluateTransactionBalance pp poolids stakeDelegDeposits drepDelegDeposits utxo isRegPool kh = Api.StakePoolKeyHash kh `Set.member` poolids lookupDelegDeposit - :: Ledger.Credential 'Ledger.Staking -> Maybe L.Coin + :: Ledger.Credential Ledger.Staking -> Maybe L.Coin lookupDelegDeposit stakeCred = Map.lookup (fromShelleyStakeCredential stakeCred) stakeDelegDeposits lookupDRepDeposit - :: Ledger.Credential 'Ledger.DRepRole -> Maybe L.Coin + :: Ledger.Credential Ledger.DRepRole -> Maybe L.Coin lookupDRepDeposit drepCred = Map.lookup drepCred drepDelegDeposits @@ -1059,7 +1059,7 @@ indexWitnessedTxProposalProcedures (TxProposalProcedures proposals) = do | (ix, (proposal, anyWitness)) <- allProposalsList ] -toUnsigned :: forall era. Era era -> L.Tx (LedgerEra era) -> UnsignedTx era +toUnsigned :: forall era. Era era -> L.Tx L.TopTx (LedgerEra era) -> UnsignedTx era toUnsigned e tx = obtainCommonConstraints e $ UnsignedTx tx @@ -1075,7 +1075,7 @@ evaluateTransactionExecutionUnits -> LedgerEpochInfo -> L.PParams (LedgerEra era) -> L.UTxO (LedgerEra era) - -> L.Tx (LedgerEra era) + -> L.Tx L.TopTx (LedgerEra era) -> Map ScriptWitnessIndex (Either ScriptExecutionError (EvalTxExecutionUnitsLog, ExecutionUnits)) evaluateTransactionExecutionUnits systemstart epochInfo pp utxo tx = obtainCommonConstraints (useEra @era) $ From cc234b6683f3d21887bb7c1adf360d83efb0e682 Mon Sep 17 00:00:00 2001 From: Jordan Millar Date: Tue, 3 Feb 2026 11:10:53 -0400 Subject: [PATCH 22/32] Introduce transaction levels --- cardano-api/cardano-api.cabal | 22 ++++----- cardano-api/src/Cardano/Api/Block.hs | 3 +- cardano-api/src/Cardano/Api/Compatible/Tx.hs | 17 ++++--- .../Api/Era/Internal/Eon/AllegraEraOnwards.hs | 2 +- .../Api/Era/Internal/Eon/AlonzoEraOnwards.hs | 2 +- .../Api/Era/Internal/Eon/BabbageEraOnwards.hs | 2 +- .../Api/Era/Internal/Eon/ConwayEraOnwards.hs | 2 +- .../Api/Era/Internal/Eon/MaryEraOnwards.hs | 2 +- .../Api/Era/Internal/Eon/ShelleyBasedEra.hs | 2 +- .../Api/Era/Internal/Eon/ShelleyEraOnly.hs | 2 +- .../Era/Internal/Eon/ShelleyToAllegraEra.hs | 2 +- .../Era/Internal/Eon/ShelleyToAlonzoEra.hs | 2 +- .../Era/Internal/Eon/ShelleyToBabbageEra.hs | 2 +- .../Api/Era/Internal/Eon/ShelleyToMaryEra.hs | 2 +- .../src/Cardano/Api/Experimental/Era.hs | 2 +- .../src/Cardano/Api/Experimental/Tx.hs | 6 +-- .../Tx/Internal/BodyContent/New.hs | 9 ++-- .../Api/Experimental/Tx/Internal/Fee.hs | 1 + .../Api/Experimental/Tx/Internal/Type.hs | 2 +- cardano-api/src/Cardano/Api/LedgerState.hs | 9 ++-- .../Api/LedgerState/Internal/LedgerEvent.hs | 4 +- .../src/Cardano/Api/Query/Internal/Expr.hs | 6 +-- .../Api/Query/Internal/Type/QueryInMode.hs | 13 ++--- .../src/Cardano/Api/Tx/Internal/Body.hs | 49 +++++++++++-------- .../src/Cardano/Api/Tx/Internal/Body/Lens.hs | 4 +- .../src/Cardano/Api/Tx/Internal/Fee.hs | 7 +-- .../src/Cardano/Api/Tx/Internal/Output.hs | 2 +- .../src/Cardano/Api/Tx/Internal/Sign.hs | 20 ++++---- 28 files changed, 106 insertions(+), 92 deletions(-) diff --git a/cardano-api/cardano-api.cabal b/cardano-api/cardano-api.cabal index 5c9bd206f6..58b2abc577 100644 --- a/cardano-api/cardano-api.cabal +++ b/cardano-api/cardano-api.cabal @@ -38,7 +38,7 @@ common project-config -Wunused-packages common maybe-unix - if !(os(windows) || arch(wasm32)) + if !(os(windows)|| arch(wasm32)) build-depends: unix common maybe-Win32 @@ -46,7 +46,7 @@ common maybe-Win32 build-depends: Win32 common text - if os(osx) && arch(aarch64) + if os(osx)&& arch(aarch64) build-depends: text >=1.2.5.0 else build-depends: text >=2.0 @@ -129,7 +129,7 @@ library cardano-crypto-class ^>=2.2.3.2, cardano-crypto-wrapper ^>=1.7, cardano-data >=1.0, - cardano-diffusion:{api, cardano-diffusion} ^>=0.1, + cardano-diffusion:{cardano-diffusion, api} ^>=0.1, cardano-ledger-allegra >=1.7, cardano-ledger-alonzo >=1.13, cardano-ledger-api ^>=1.13, @@ -171,7 +171,7 @@ library ouroboros-consensus-cardano ^>=0.26, ouroboros-consensus-diffusion ^>=0.24, ouroboros-consensus-protocol ^>=0.13, - ouroboros-network:{api, framework, ouroboros-network, protocols} ^>=0.24, + ouroboros-network:{ouroboros-network, api, framework, protocols} ^>=0.24, parsec, plutus-core ^>=1.57, plutus-ledger-api ^>=1.57, @@ -325,14 +325,12 @@ library gen cardano-api, cardano-binary >=1.6 && <1.9, cardano-crypto-class ^>=2.2.1, - cardano-crypto-wrapper:{cardano-crypto-wrapper, testlib} ^>=1.7, - cardano-ledger-alonzo >=1.8.1, - cardano-ledger-babbage, - cardano-ledger-byron, - cardano-ledger-conway, - cardano-ledger-core >=1.14, - cardano-ledger-dijkstra >=0.1, - cardano-ledger-mary, + cardano-crypto-wrapper:testlib ^>=1.7, + cardano-ledger-alonzo:{cardano-ledger-alonzo, testlib} >=1.8.1, + cardano-ledger-byron:testlib, + cardano-ledger-conway:testlib, + cardano-ledger-core:{cardano-ledger-core, testlib} >=1.17, + cardano-ledger-dijkstra:testlib >=0.1, cardano-ledger-shelley >=1.13, cardano-strict-containers, containers, diff --git a/cardano-api/src/Cardano/Api/Block.hs b/cardano-api/src/Cardano/Api/Block.hs index 88dbae3ca2..d2da48d91b 100644 --- a/cardano-api/src/Cardano/Api/Block.hs +++ b/cardano-api/src/Cardano/Api/Block.hs @@ -80,6 +80,7 @@ import Data.ByteString qualified as BS import Data.ByteString.Short qualified as SBS import Data.Foldable (Foldable (toList)) import Data.Text (Text) +import Lens.Micro -- ---------------------------------------------------------------------------- -- Blocks in an era @@ -174,7 +175,7 @@ getShelleyBlockTxs -> [Tx era] getShelleyBlockTxs era (Ledger.Block _header txs) = [ ShelleyTx era txinblock - | txinblock <- toList (Ledger.fromTxSeq txs) + | txinblock <- toList (txs ^. Ledger.txSeqBlockBodyL) ] -- ---------------------------------------------------------------------------- diff --git a/cardano-api/src/Cardano/Api/Compatible/Tx.hs b/cardano-api/src/Cardano/Api/Compatible/Tx.hs index 1439d5fc39..093fa05cb8 100644 --- a/cardano-api/src/Cardano/Api/Compatible/Tx.hs +++ b/cardano-api/src/Cardano/Api/Compatible/Tx.hs @@ -35,6 +35,7 @@ import Cardano.Api.Value.Internal import Cardano.Ledger.Alonzo.Tx qualified as L import Cardano.Ledger.Alonzo.TxWits qualified as Alonzo import Cardano.Ledger.Api qualified as L +import Cardano.Ledger.Core qualified as L import Data.Map.Strict qualified as Map import Data.Maybe @@ -84,7 +85,7 @@ createCompatibleTx sbe ins outs txFee' anyProtocolUpdate anyVote txCertificates' case anyProtocolUpdate of ProtocolUpdate shelleyToBabbageEra updateProposal -> do ledgerPParamsUpdate <- toLedgerUpdate sbe updateProposal - let updateTxBody :: Endo (L.TxBody (ShelleyLedgerEra era)) = + let updateTxBody :: Endo (L.TxBody L.TopTx (ShelleyLedgerEra era)) = shelleyToBabbageEraConstraints shelleyToBabbageEra $ Endo $ \txb -> txb & L.updateTxBodyL .~ SJust ledgerPParamsUpdate @@ -107,7 +108,7 @@ createCompatibleTx sbe ins outs txFee' anyProtocolUpdate anyVote txCertificates' , txIn <- maybeToList $ getAnyWitnessReferenceInput wit ] -- append proposal reference inputs & set proposal procedures - updateTxBody :: Endo (L.TxBody (ShelleyLedgerEra era)) = + updateTxBody :: Endo (L.TxBody L.TopTx (ShelleyLedgerEra era)) = conwayEraOnwardsConstraints conwayOnwards $ Endo $ (L.referenceInputsTxBodyL %~ (<> fromList referenceInputs)) @@ -140,13 +141,13 @@ createCompatibleTx sbe ins outs txFee' anyProtocolUpdate anyVote txCertificates' era = toCardanoEra sbe appEndos = appEndo . mconcat - setCerts :: Endo (L.TxBody (ShelleyLedgerEra era)) + setCerts :: Endo (L.TxBody L.TopTx (ShelleyLedgerEra era)) setCerts = shelleyBasedEraConstraints sbe $ Endo $ L.certsTxBodyL .~ convCertificates txCertificates' - setRefInputs :: Endo (L.TxBody (ShelleyLedgerEra era)) + setRefInputs :: Endo (L.TxBody L.TopTx (ShelleyLedgerEra era)) setRefInputs = do let refInputs = [ toShelleyTxIn refInput @@ -162,8 +163,8 @@ createCompatibleTx sbe ins outs txFee' anyProtocolUpdate anyVote txCertificates' overwriteVotingProcedures :: ConwayEraOnwards era -> L.VotingProcedures (ShelleyLedgerEra era) - -> L.Tx (ShelleyLedgerEra era) - -> L.Tx (ShelleyLedgerEra era) + -> L.Tx L.TopTx (ShelleyLedgerEra era) + -> L.Tx L.TopTx (ShelleyLedgerEra era) overwriteVotingProcedures conwayOnwards votingProcedures = conwayEraOnwardsConstraints conwayOnwards $ (L.bodyTxL . L.votingProceduresTxBodyL) .~ votingProcedures @@ -273,7 +274,7 @@ createCommonTxBody -> [TxIn] -> [TxOut ctx era] -> Lovelace - -> L.TxBody (ShelleyLedgerEra era) + -> L.TxBody L.TopTx (ShelleyLedgerEra era) createCommonTxBody era ins outs txFee' = let txIns' = map toShelleyTxIn ins txOuts' = map (toShelleyTxOutAny era) outs @@ -301,7 +302,7 @@ addWitnesses witnesses (ShelleyTx sbe tx) = :: forall ledgerera . ShelleyLedgerEra era ~ ledgerera => L.EraTx ledgerera - => L.Tx ledgerera + => L.Tx L.TopTx ledgerera txCommon = tx & L.witsTxL diff --git a/cardano-api/src/Cardano/Api/Era/Internal/Eon/AllegraEraOnwards.hs b/cardano-api/src/Cardano/Api/Era/Internal/Eon/AllegraEraOnwards.hs index 4f05537032..66665356dd 100644 --- a/cardano-api/src/Cardano/Api/Era/Internal/Eon/AllegraEraOnwards.hs +++ b/cardano-api/src/Cardano/Api/Era/Internal/Eon/AllegraEraOnwards.hs @@ -96,7 +96,7 @@ type AllegraEraOnwardsConstraints era = , L.EraTx (ShelleyLedgerEra era) , L.EraTxBody (ShelleyLedgerEra era) , L.EraTxOut (ShelleyLedgerEra era) - , L.HashAnnotated (L.TxBody (ShelleyLedgerEra era)) L.EraIndependentTxBody + , L.HashAnnotated (L.TxBody L.TopTx (ShelleyLedgerEra era)) L.EraIndependentTxBody , L.AllegraEraTxBody (ShelleyLedgerEra era) , L.ShelleyEraTxCert (ShelleyLedgerEra era) , FromCBOR (Consensus.ChainDepState (ConsensusProtocol era)) diff --git a/cardano-api/src/Cardano/Api/Era/Internal/Eon/AlonzoEraOnwards.hs b/cardano-api/src/Cardano/Api/Era/Internal/Eon/AlonzoEraOnwards.hs index 484b1cd4fc..9fd0e10030 100644 --- a/cardano-api/src/Cardano/Api/Era/Internal/Eon/AlonzoEraOnwards.hs +++ b/cardano-api/src/Cardano/Api/Era/Internal/Eon/AlonzoEraOnwards.hs @@ -104,7 +104,7 @@ type AlonzoEraOnwardsConstraints era = , L.EraTxBody (ShelleyLedgerEra era) , L.EraTxOut (ShelleyLedgerEra era) , L.EraUTxO (ShelleyLedgerEra era) - , L.HashAnnotated (L.TxBody (ShelleyLedgerEra era)) L.EraIndependentTxBody + , L.HashAnnotated (L.TxBody L.TopTx (ShelleyLedgerEra era)) L.EraIndependentTxBody , L.MaryEraTxBody (ShelleyLedgerEra era) , Plutus.EraPlutusContext (ShelleyLedgerEra era) , L.Script (ShelleyLedgerEra era) ~ L.AlonzoScript (ShelleyLedgerEra era) diff --git a/cardano-api/src/Cardano/Api/Era/Internal/Eon/BabbageEraOnwards.hs b/cardano-api/src/Cardano/Api/Era/Internal/Eon/BabbageEraOnwards.hs index 09c7ca6e60..39e670b8cc 100644 --- a/cardano-api/src/Cardano/Api/Era/Internal/Eon/BabbageEraOnwards.hs +++ b/cardano-api/src/Cardano/Api/Era/Internal/Eon/BabbageEraOnwards.hs @@ -112,7 +112,7 @@ type BabbageEraOnwardsConstraints era = , L.EraTxBody (ShelleyLedgerEra era) , L.EraTxOut (ShelleyLedgerEra era) , L.EraUTxO (ShelleyLedgerEra era) - , L.HashAnnotated (L.TxBody (ShelleyLedgerEra era)) L.EraIndependentTxBody + , L.HashAnnotated (L.TxBody L.TopTx (ShelleyLedgerEra era)) L.EraIndependentTxBody , L.MaryEraTxBody (ShelleyLedgerEra era) , L.Script (ShelleyLedgerEra era) ~ L.AlonzoScript (ShelleyLedgerEra era) , L.ScriptsNeeded (ShelleyLedgerEra era) ~ L.AlonzoScriptsNeeded (ShelleyLedgerEra era) diff --git a/cardano-api/src/Cardano/Api/Era/Internal/Eon/ConwayEraOnwards.hs b/cardano-api/src/Cardano/Api/Era/Internal/Eon/ConwayEraOnwards.hs index a759d36a2f..8759ac69bc 100644 --- a/cardano-api/src/Cardano/Api/Era/Internal/Eon/ConwayEraOnwards.hs +++ b/cardano-api/src/Cardano/Api/Era/Internal/Eon/ConwayEraOnwards.hs @@ -121,7 +121,7 @@ type ConwayEraOnwardsConstraints era = , L.EraTxOut (ShelleyLedgerEra era) , L.EraUTxO (ShelleyLedgerEra era) , L.GovState (ShelleyLedgerEra era) ~ L.ConwayGovState (ShelleyLedgerEra era) - , L.HashAnnotated (L.TxBody (ShelleyLedgerEra era)) L.EraIndependentTxBody + , L.HashAnnotated (L.TxBody L.TopTx (ShelleyLedgerEra era)) L.EraIndependentTxBody , L.MaryEraTxBody (ShelleyLedgerEra era) , L.Script (ShelleyLedgerEra era) ~ L.AlonzoScript (ShelleyLedgerEra era) , L.ScriptsNeeded (ShelleyLedgerEra era) ~ L.AlonzoScriptsNeeded (ShelleyLedgerEra era) diff --git a/cardano-api/src/Cardano/Api/Era/Internal/Eon/MaryEraOnwards.hs b/cardano-api/src/Cardano/Api/Era/Internal/Eon/MaryEraOnwards.hs index 076f6b7b78..9e991abef9 100644 --- a/cardano-api/src/Cardano/Api/Era/Internal/Eon/MaryEraOnwards.hs +++ b/cardano-api/src/Cardano/Api/Era/Internal/Eon/MaryEraOnwards.hs @@ -97,7 +97,7 @@ type MaryEraOnwardsConstraints era = , L.EraTxBody (ShelleyLedgerEra era) , L.EraTxOut (ShelleyLedgerEra era) , L.EraUTxO (ShelleyLedgerEra era) - , L.HashAnnotated (L.TxBody (ShelleyLedgerEra era)) L.EraIndependentTxBody + , L.HashAnnotated (L.TxBody L.TopTx (ShelleyLedgerEra era)) L.EraIndependentTxBody , L.MaryEraTxBody (ShelleyLedgerEra era) , L.ShelleyEraTxCert (ShelleyLedgerEra era) , L.Value (ShelleyLedgerEra era) ~ L.MaryValue diff --git a/cardano-api/src/Cardano/Api/Era/Internal/Eon/ShelleyBasedEra.hs b/cardano-api/src/Cardano/Api/Era/Internal/Eon/ShelleyBasedEra.hs index 5f83a8301b..f0320b6a8b 100644 --- a/cardano-api/src/Cardano/Api/Era/Internal/Eon/ShelleyBasedEra.hs +++ b/cardano-api/src/Cardano/Api/Era/Internal/Eon/ShelleyBasedEra.hs @@ -232,7 +232,7 @@ type ShelleyBasedEraConstraints era = , L.EraTxOut (ShelleyLedgerEra era) , L.EraUTxO (ShelleyLedgerEra era) , L.EraTxWits (ShelleyLedgerEra era) - , L.HashAnnotated (L.TxBody (ShelleyLedgerEra era)) L.EraIndependentTxBody + , L.HashAnnotated (L.TxBody L.TopTx (ShelleyLedgerEra era)) L.EraIndependentTxBody , L.EraCertState (ShelleyLedgerEra era) , L.EraAccounts (ShelleyLedgerEra era) , L.ShelleyEraTxCert (ShelleyLedgerEra era) diff --git a/cardano-api/src/Cardano/Api/Era/Internal/Eon/ShelleyEraOnly.hs b/cardano-api/src/Cardano/Api/Era/Internal/Eon/ShelleyEraOnly.hs index 8e5d76de09..e65cde6e27 100644 --- a/cardano-api/src/Cardano/Api/Era/Internal/Eon/ShelleyEraOnly.hs +++ b/cardano-api/src/Cardano/Api/Era/Internal/Eon/ShelleyEraOnly.hs @@ -84,7 +84,7 @@ type ShelleyEraOnlyConstraints era = , L.EraTxOut (ShelleyLedgerEra era) , L.ExactEra L.ShelleyEra (ShelleyLedgerEra era) , L.ExactEra L.ShelleyEra (ShelleyLedgerEra era) - , L.HashAnnotated (L.TxBody (ShelleyLedgerEra era)) L.EraIndependentTxBody + , L.HashAnnotated (L.TxBody L.TopTx (ShelleyLedgerEra era)) L.EraIndependentTxBody , L.ProtVerAtMost (ShelleyLedgerEra era) 2 , L.ProtVerAtMost (ShelleyLedgerEra era) 6 , L.ProtVerAtMost (ShelleyLedgerEra era) 8 diff --git a/cardano-api/src/Cardano/Api/Era/Internal/Eon/ShelleyToAllegraEra.hs b/cardano-api/src/Cardano/Api/Era/Internal/Eon/ShelleyToAllegraEra.hs index 529487624c..f4b62fe135 100644 --- a/cardano-api/src/Cardano/Api/Era/Internal/Eon/ShelleyToAllegraEra.hs +++ b/cardano-api/src/Cardano/Api/Era/Internal/Eon/ShelleyToAllegraEra.hs @@ -87,7 +87,7 @@ type ShelleyToAllegraEraConstraints era = , L.EraTxBody (ShelleyLedgerEra era) , L.EraTxOut (ShelleyLedgerEra era) , L.EraUTxO (ShelleyLedgerEra era) - , L.HashAnnotated (L.TxBody (ShelleyLedgerEra era)) L.EraIndependentTxBody + , L.HashAnnotated (L.TxBody L.TopTx (ShelleyLedgerEra era)) L.EraIndependentTxBody , L.ProtVerAtMost (ShelleyLedgerEra era) 4 , L.ProtVerAtMost (ShelleyLedgerEra era) 6 , L.ProtVerAtMost (ShelleyLedgerEra era) 8 diff --git a/cardano-api/src/Cardano/Api/Era/Internal/Eon/ShelleyToAlonzoEra.hs b/cardano-api/src/Cardano/Api/Era/Internal/Eon/ShelleyToAlonzoEra.hs index 8c38e43e91..df9f1eba90 100644 --- a/cardano-api/src/Cardano/Api/Era/Internal/Eon/ShelleyToAlonzoEra.hs +++ b/cardano-api/src/Cardano/Api/Era/Internal/Eon/ShelleyToAlonzoEra.hs @@ -90,7 +90,7 @@ type ShelleyToAlonzoEraConstraints era = , L.EraTx (ShelleyLedgerEra era) , L.EraTxBody (ShelleyLedgerEra era) , L.EraTxOut (ShelleyLedgerEra era) - , L.HashAnnotated (L.TxBody (ShelleyLedgerEra era)) L.EraIndependentTxBody + , L.HashAnnotated (L.TxBody L.TopTx (ShelleyLedgerEra era)) L.EraIndependentTxBody , L.ProtVerAtMost (ShelleyLedgerEra era) 6 , L.ProtVerAtMost (ShelleyLedgerEra era) 8 , L.ShelleyEraTxBody (ShelleyLedgerEra era) diff --git a/cardano-api/src/Cardano/Api/Era/Internal/Eon/ShelleyToBabbageEra.hs b/cardano-api/src/Cardano/Api/Era/Internal/Eon/ShelleyToBabbageEra.hs index 0eede2a88d..4767b14ed0 100644 --- a/cardano-api/src/Cardano/Api/Era/Internal/Eon/ShelleyToBabbageEra.hs +++ b/cardano-api/src/Cardano/Api/Era/Internal/Eon/ShelleyToBabbageEra.hs @@ -95,7 +95,7 @@ type ShelleyToBabbageEraConstraints era = , L.EraTx (ShelleyLedgerEra era) , L.EraTxBody (ShelleyLedgerEra era) , L.EraTxOut (ShelleyLedgerEra era) - , L.HashAnnotated (L.TxBody (ShelleyLedgerEra era)) L.EraIndependentTxBody + , L.HashAnnotated (L.TxBody L.TopTx (ShelleyLedgerEra era)) L.EraIndependentTxBody , L.ProtVerAtMost (ShelleyLedgerEra era) 8 , L.ShelleyEraTxBody (ShelleyLedgerEra era) , L.ShelleyEraTxCert (ShelleyLedgerEra era) diff --git a/cardano-api/src/Cardano/Api/Era/Internal/Eon/ShelleyToMaryEra.hs b/cardano-api/src/Cardano/Api/Era/Internal/Eon/ShelleyToMaryEra.hs index c8219bdd5a..dbc9379a22 100644 --- a/cardano-api/src/Cardano/Api/Era/Internal/Eon/ShelleyToMaryEra.hs +++ b/cardano-api/src/Cardano/Api/Era/Internal/Eon/ShelleyToMaryEra.hs @@ -88,7 +88,7 @@ type ShelleyToMaryEraConstraints era = , L.EraTx (ShelleyLedgerEra era) , L.EraTxBody (ShelleyLedgerEra era) , L.EraTxOut (ShelleyLedgerEra era) - , L.HashAnnotated (L.TxBody (ShelleyLedgerEra era)) L.EraIndependentTxBody + , L.HashAnnotated (L.TxBody L.TopTx (ShelleyLedgerEra era)) L.EraIndependentTxBody , L.ProtVerAtMost (ShelleyLedgerEra era) 4 , L.ProtVerAtMost (ShelleyLedgerEra era) 6 , L.ProtVerAtMost (ShelleyLedgerEra era) 8 diff --git a/cardano-api/src/Cardano/Api/Experimental/Era.hs b/cardano-api/src/Cardano/Api/Experimental/Era.hs index c2fb3e227d..26478c847f 100644 --- a/cardano-api/src/Cardano/Api/Experimental/Era.hs +++ b/cardano-api/src/Cardano/Api/Experimental/Era.hs @@ -320,7 +320,7 @@ type EraCommonConstraints era = , ShelleyLedgerEra era ~ LedgerEra era , LedgerEra era ~ ShelleyLedgerEra era , ToJSON (ChainDepState (ConsensusProtocol era)) - , L.HashAnnotated (Ledger.TxBody (LedgerEra era)) L.EraIndependentTxBody + , L.HashAnnotated (Ledger.TxBody Ledger.TopTx (LedgerEra era)) L.EraIndependentTxBody , Api.IsCardanoEra era , Api.IsShelleyBasedEra era , IsEra era diff --git a/cardano-api/src/Cardano/Api/Experimental/Tx.hs b/cardano-api/src/Cardano/Api/Experimental/Tx.hs index 5d69a0afd7..24008df664 100644 --- a/cardano-api/src/Cardano/Api/Experimental/Tx.hs +++ b/cardano-api/src/Cardano/Api/Experimental/Tx.hs @@ -241,8 +241,8 @@ getUnsignedTxFee (UnsignedTx unsignedTx) = in txbody ^. L.feeTxBodyL hashTxBody - :: L.HashAnnotated (Ledger.TxBody era) L.EraIndependentTxBody - => L.TxBody era -> Hash.Hash L.HASH L.EraIndependentTxBody + :: L.HashAnnotated (Ledger.TxBody Ledger.TopTx era) L.EraIndependentTxBody + => L.TxBody Ledger.TopTx era -> Hash.Hash L.HASH L.EraIndependentTxBody hashTxBody = L.extractHash . L.hashAnnotated makeKeyWitness @@ -262,7 +262,7 @@ makeKeyWitness era (UnsignedTx unsignedTx) wsk = -- | A transaction that has been witnesssed data SignedTx era - = L.EraTx (LedgerEra era) => SignedTx (Ledger.Tx (LedgerEra era)) + = L.EraTx (LedgerEra era) => SignedTx (Ledger.Tx Ledger.TopTx (LedgerEra era)) deriving instance Eq (SignedTx era) diff --git a/cardano-api/src/Cardano/Api/Experimental/Tx/Internal/BodyContent/New.hs b/cardano-api/src/Cardano/Api/Experimental/Tx/Internal/BodyContent/New.hs index 777b6dde06..de5adfd46a 100644 --- a/cardano-api/src/Cardano/Api/Experimental/Tx/Internal/BodyContent/New.hs +++ b/cardano-api/src/Cardano/Api/Experimental/Tx/Internal/BodyContent/New.hs @@ -94,6 +94,7 @@ import Cardano.Api.Plutus.Internal.ScriptData qualified as Api import Cardano.Api.Tx.Internal.Body ( CtxTx , TxIn + , asGuard , toShelleyTxIn , toShelleyWithdrawal ) @@ -108,8 +109,8 @@ import Cardano.Ledger.Alonzo.Tx qualified as L import Cardano.Ledger.Alonzo.TxBody qualified as L import Cardano.Ledger.Alonzo.TxWits qualified as L import Cardano.Ledger.Api qualified as L +import Cardano.Ledger.Core qualified as L import Cardano.Ledger.Core qualified as Ledger -import Cardano.Ledger.Keys qualified as L import Cardano.Ledger.Plutus.Language qualified as Plutus import Control.Monad @@ -175,7 +176,7 @@ makeUnsignedTx era@ConwayEra bc = obtainCommonConstraints era $ do & L.feeTxBodyL .~ fee & L.vldtTxBodyL . L.invalidBeforeL .~ (L.maybeToStrictMaybe $ txValidityLowerBound bc) & L.vldtTxBodyL . L.invalidHereAfterL .~ (L.maybeToStrictMaybe $ txValidityUpperBound bc) - & L.reqSignerHashesTxBodyL .~ undefined --TODO(10.7): setReqSignerHashes + & L.reqSignerHashesTxBodyL .~ setReqSignerHashes & L.scriptIntegrityHashTxBodyL .~ scriptIntegrityHash & L.withdrawalsTxBodyL .~ withdrawals & L.certsTxBodyL .~ certs @@ -221,10 +222,10 @@ convMintValue v = do multiAsset convExtraKeyWitnesses - :: TxExtraKeyWitnesses -> Set (L.KeyHash L.Witness) + :: TxExtraKeyWitnesses -> Set (L.KeyHash L.Guard) convExtraKeyWitnesses (TxExtraKeyWitnesses khs) = fromList - [ L.asWitness kh + [ asGuard kh | PaymentKeyHash kh <- khs ] diff --git a/cardano-api/src/Cardano/Api/Experimental/Tx/Internal/Fee.hs b/cardano-api/src/Cardano/Api/Experimental/Tx/Internal/Fee.hs index ed41ef92c1..278328d02d 100644 --- a/cardano-api/src/Cardano/Api/Experimental/Tx/Internal/Fee.hs +++ b/cardano-api/src/Cardano/Api/Experimental/Tx/Internal/Fee.hs @@ -67,6 +67,7 @@ import Cardano.Ledger.Alonzo.Core qualified as Ledger import Cardano.Ledger.Api qualified as L import Cardano.Ledger.Coin qualified as L import Cardano.Ledger.Conway.Governance qualified as L +import Cardano.Ledger.Core qualified as L import Cardano.Ledger.Credential as Ledger (Credential) import Cardano.Ledger.Val qualified as L diff --git a/cardano-api/src/Cardano/Api/Experimental/Tx/Internal/Type.hs b/cardano-api/src/Cardano/Api/Experimental/Tx/Internal/Type.hs index da74dc00ed..ee30be3ad7 100644 --- a/cardano-api/src/Cardano/Api/Experimental/Tx/Internal/Type.hs +++ b/cardano-api/src/Cardano/Api/Experimental/Tx/Internal/Type.hs @@ -35,7 +35,7 @@ import Data.ByteString.Lazy (fromStrict) -- | A transaction that can contain everything -- except key witnesses. data UnsignedTx era - = L.EraTx (LedgerEra era) => UnsignedTx (Ledger.Tx (LedgerEra era)) + = L.EraTx (LedgerEra era) => UnsignedTx (Ledger.Tx Ledger.TopTx (LedgerEra era)) instance HasTypeProxy era => HasTypeProxy (UnsignedTx era) where data AsType (UnsignedTx era) = AsUnsignedTx (AsType era) diff --git a/cardano-api/src/Cardano/Api/LedgerState.hs b/cardano-api/src/Cardano/Api/LedgerState.hs index 623ab88397..77bad9c11e 100644 --- a/cardano-api/src/Cardano/Api/LedgerState.hs +++ b/cardano-api/src/Cardano/Api/LedgerState.hs @@ -166,6 +166,7 @@ import Cardano.Ledger.BaseTypes qualified as Ledger import Cardano.Ledger.Binary (DecoderError) import Cardano.Ledger.Conway.Genesis (ConwayGenesis (..)) import Cardano.Ledger.Dijkstra.PParams qualified as Ledger +import Cardano.Ledger.Keys qualified as L import Cardano.Ledger.Keys qualified as SL import Cardano.Ledger.Shelley.API qualified as ShelleyAPI import Cardano.Ledger.Shelley.Core qualified as Core @@ -1792,7 +1793,7 @@ renderHash :: Cardano.Crypto.Hash.Class.Hash Cardano.Crypto.Hash.Blake2b.Blake2b_256 ByteString -> Text renderHash h = Text.decodeUtf8 $ Base16.encode (Cardano.Crypto.Hash.Class.hashToBytes h) -newtype StakeCred = StakeCred {_unStakeCred :: Ledger.Credential 'Ledger.Staking} +newtype StakeCred = StakeCred {_unStakeCred :: Ledger.Credential L.Staking} deriving (Eq, Ord) data Env = Env @@ -2096,7 +2097,7 @@ nextEpochEligibleLeadershipSlots sbe sGen serCurrEpochState ptclState poolid (Vr snapshot = ShelleyAPI.ssStakeMark $ ShelleyAPI.esSnapshots cEstate markSnapshotPoolDistr :: Map - (SL.KeyHash 'SL.StakePool) + (SL.KeyHash SL.StakePool) SL.IndividualPoolStake markSnapshotPoolDistr = ShelleyAPI.unPoolDistr . ShelleyAPI.calculatePoolDistr $ snapshot @@ -2133,7 +2134,7 @@ isLeadingSlotsTPraos => Set SlotNo -> PoolId -> Map - (SL.KeyHash 'SL.StakePool) + (SL.KeyHash SL.StakePool) SL.IndividualPoolStake -> Consensus.Nonce -> Crypto.SignKeyVRF v @@ -2158,7 +2159,7 @@ isLeadingSlotsPraos => Set SlotNo -> PoolId -> Map - (SL.KeyHash 'SL.StakePool) + (SL.KeyHash SL.StakePool) SL.IndividualPoolStake -> Consensus.Nonce -> Crypto.SignKeyVRF (Crypto.VRF Consensus.StandardCrypto) diff --git a/cardano-api/src/Cardano/Api/LedgerState/Internal/LedgerEvent.hs b/cardano-api/src/Cardano/Api/LedgerState/Internal/LedgerEvent.hs index 4affa9eb2b..a9fa2a5ea2 100644 --- a/cardano-api/src/Cardano/Api/LedgerState/Internal/LedgerEvent.hs +++ b/cardano-api/src/Cardano/Api/LedgerState/Internal/LedgerEvent.hs @@ -72,7 +72,7 @@ data LedgerEvent Ledger.TxId (Set (Ledger.Voter, Ledger.GovActionId)) -- ^ Votes that were replaced in this tx. - (Set (Ledger.Credential 'Ledger.DRepRole)) + (Set (Ledger.Credential Ledger.DRepRole)) -- ^ 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. @@ -110,7 +110,7 @@ data PoolReapDetails = PoolReapDetails convertRetiredPoolsMap :: Map - Ledger.StakeCredential + (Ledger.Credential Ledger.Staking) (Map (Ledger.KeyHash Ledger.StakePool) (Ledger.CompactForm Ledger.Coin)) -> Map StakeCredential (Map (Hash StakePoolKey) L.Coin) convertRetiredPoolsMap = diff --git a/cardano-api/src/Cardano/Api/Query/Internal/Expr.hs b/cardano-api/src/Cardano/Api/Query/Internal/Expr.hs index 3d366702e4..232278378f 100644 --- a/cardano-api/src/Cardano/Api/Query/Internal/Expr.hs +++ b/cardano-api/src/Cardano/Api/Query/Internal/Expr.hs @@ -429,7 +429,7 @@ queryDRepStakeDistribution eon = querySbe eon . QueryDRepStakeDistr querySPOStakeDistribution :: ConwayEraOnwards era - -> Set (L.KeyHash 'L.StakePool) + -> Set (L.KeyHash L.StakePool) -- ^ An empty SPO key hash set means that distributions for all SPOs will be returned -> LocalStateQueryExpr block @@ -439,7 +439,7 @@ querySPOStakeDistribution IO ( Either UnsupportedNtcVersionError - (Either EraMismatch (Map (L.KeyHash 'L.StakePool) L.Coin)) + (Either EraMismatch (Map (L.KeyHash L.StakePool) L.Coin)) ) querySPOStakeDistribution eon = querySbe eon . QuerySPOStakeDistr @@ -507,7 +507,7 @@ queryProposals eon = querySbe eon . QueryProposals queryStakePoolDefaultVote :: forall era block point r . ConwayEraOnwards era - -> L.KeyHash 'L.StakePool + -> L.KeyHash L.StakePool -> LocalStateQueryExpr block point diff --git a/cardano-api/src/Cardano/Api/Query/Internal/Type/QueryInMode.hs b/cardano-api/src/Cardano/Api/Query/Internal/Type/QueryInMode.hs index 451234d67c..f46a042a3f 100644 --- a/cardano-api/src/Cardano/Api/Query/Internal/Type/QueryInMode.hs +++ b/cardano-api/src/Cardano/Api/Query/Internal/Type/QueryInMode.hs @@ -301,8 +301,8 @@ data QueryInShelleyBasedEra era result where :: Set Ledger.DRep -> QueryInShelleyBasedEra era (Map Ledger.DRep L.Coin) QuerySPOStakeDistr - :: Set (Ledger.KeyHash 'Ledger.StakePool) - -> QueryInShelleyBasedEra era (Map (Ledger.KeyHash 'Ledger.StakePool) L.Coin) + :: Set (Ledger.KeyHash Ledger.StakePool) + -> QueryInShelleyBasedEra era (Map (Ledger.KeyHash Ledger.StakePool) L.Coin) QueryCommitteeMembersState :: Set (Shelley.Credential Shelley.ColdCommitteeRole) -> Set (Shelley.Credential Shelley.HotCommitteeRole) @@ -317,7 +317,7 @@ data QueryInShelleyBasedEra era result where QueryLedgerPeerSnapshot :: QueryInShelleyBasedEra era (Serialised LedgerPeerSnapshot) QueryStakePoolDefaultVote - :: Ledger.KeyHash 'Ledger.StakePool + :: Ledger.KeyHash Ledger.StakePool -> QueryInShelleyBasedEra era L.DefaultVote deriving instance Show (QueryInShelleyBasedEra era result) @@ -428,7 +428,7 @@ decodeBigLedgerPeerSnapshot :: Consensus.ShelleyNodeToClientVersion -> Serialised LedgerPeerSnapshot -> Either (LBS.ByteString, DecoderError) (LedgerPeerSnapshot BigLedgerPeers) -decodeBigLedgerPeerSnapshot ntcV (Serialised lps) = +decodeBigLedgerPeerSnapshot _ntcV (Serialised _lps) = -- first -- (lps,) -- $ Plain.decodeFullDecoder @@ -502,7 +502,7 @@ fromShelleyDelegations = . toList fromShelleyRewardAccounts - :: Map (Shelley.Credential 'Core.Staking) L.Coin + :: Map (Shelley.Credential Core.Staking) L.Coin -> Map StakeCredential L.Coin fromShelleyRewardAccounts = -- TODO: write an appropriate property to show it is safe to use @@ -696,7 +696,8 @@ toConsensusQueryShelleyBased sbe = \case sbe -- TODO(10.7): support full GetLedgerPeerSnapshot query QueryLedgerPeerSnapshot -> - Some (consensusQueryInEraInMode era (Consensus.GetCBOR (Consensus.GetLedgerPeerSnapshot BigLedgerPeers))) + Some + (consensusQueryInEraInMode era (Consensus.GetCBOR (Consensus.GetLedgerPeerSnapshot BigLedgerPeers))) QueryStakePoolDefaultVote govActs -> caseShelleyToBabbageOrConwayEraOnwards ( const $ diff --git a/cardano-api/src/Cardano/Api/Tx/Internal/Body.hs b/cardano-api/src/Cardano/Api/Tx/Internal/Body.hs index f7b271d5d1..a1bad6b746 100644 --- a/cardano-api/src/Cardano/Api/Tx/Internal/Body.hs +++ b/cardano-api/src/Cardano/Api/Tx/Internal/Body.hs @@ -175,6 +175,7 @@ module Cardano.Api.Tx.Internal.Body , scriptDataToInlineDatum -- ** Internal conversion functions & types + , asGuard , convCertificates , convCollateralTxIns , convExtraKeyWitnesses @@ -1185,7 +1186,7 @@ getTxId (ShelleyTxBody sbe tx _ _ _ _) = getTxIdShelley :: Ledger.EraTxBody (ShelleyLedgerEra era) => ShelleyBasedEra era - -> Ledger.TxBody (ShelleyLedgerEra era) + -> Ledger.TxBody Ledger.TopTx (ShelleyLedgerEra era) -> TxId getTxIdShelley _ tx = TxId @@ -1517,7 +1518,7 @@ getTxBodyContent = \case fromLedgerTxBody :: ShelleyBasedEra era -> TxScriptValidity era - -> Ledger.TxBody (ShelleyLedgerEra era) + -> Ledger.TxBody Ledger.TopTx (ShelleyLedgerEra era) -> TxBodyScriptData era -> Maybe (L.TxAuxData (ShelleyLedgerEra era)) -> TxBodyContent ViewTx era @@ -1551,7 +1552,7 @@ fromLedgerTxBody sbe scriptValidity body scriptdata mAux = fromLedgerProposalProcedures :: ShelleyBasedEra era - -> Ledger.TxBody (ShelleyLedgerEra era) + -> Ledger.TxBody Ledger.TopTx (ShelleyLedgerEra era) -> Maybe (Featured ConwayEraOnwards era (TxProposalProcedures ViewTx era)) fromLedgerProposalProcedures sbe body = forShelleyBasedEraInEonMaybe sbe $ \w -> @@ -1563,7 +1564,7 @@ fromLedgerProposalProcedures sbe body = fromLedgerVotingProcedures :: () => ShelleyBasedEra era - -> Ledger.TxBody (ShelleyLedgerEra era) + -> Ledger.TxBody Ledger.TopTx (ShelleyLedgerEra era) -> Maybe (Featured ConwayEraOnwards era (TxVotingProcedures ViewTx era)) fromLedgerVotingProcedures sbe body = forShelleyBasedEraInEonMaybe sbe $ \w -> @@ -1576,7 +1577,7 @@ fromLedgerVotingProcedures sbe body = fromLedgerCurrentTreasuryValue :: () => ShelleyBasedEra era - -> Ledger.TxBody (ShelleyLedgerEra era) + -> Ledger.TxBody Ledger.TopTx (ShelleyLedgerEra era) -> Maybe (Featured ConwayEraOnwards era (Maybe Coin)) fromLedgerCurrentTreasuryValue sbe body = forEraInEonMaybe (toCardanoEra sbe) $ \ceo -> conwayEraOnwardsConstraints ceo $ @@ -1586,7 +1587,7 @@ fromLedgerCurrentTreasuryValue sbe body = forEraInEonMaybe (toCardanoEra sbe) $ fromLedgerTreasuryDonation :: () => ShelleyBasedEra era - -> L.TxBody (ShelleyLedgerEra era) + -> L.TxBody L.TopTx (ShelleyLedgerEra era) -> Maybe (Featured ConwayEraOnwards era Coin) fromLedgerTreasuryDonation sbe body = forShelleyBasedEraInEonMaybe sbe $ \w -> @@ -1596,7 +1597,7 @@ fromLedgerTreasuryDonation sbe body = fromLedgerTxIns :: forall era . ShelleyBasedEra era - -> Ledger.TxBody (ShelleyLedgerEra era) + -> Ledger.TxBody Ledger.TopTx (ShelleyLedgerEra era) -> [(TxIn, BuildTxWith ViewTx (Witness WitCtxTxIn era))] fromLedgerTxIns sbe body = [ (fromShelleyTxIn input, ViewTx) @@ -1605,7 +1606,7 @@ fromLedgerTxIns sbe body = where inputs_ :: ShelleyBasedEra era - -> Ledger.TxBody (ShelleyLedgerEra era) + -> Ledger.TxBody Ledger.TopTx (ShelleyLedgerEra era) -> Set Ledger.TxIn inputs_ ShelleyBasedEraShelley = view L.inputsTxBodyL inputs_ ShelleyBasedEraAllegra = view L.inputsTxBodyL @@ -1618,7 +1619,7 @@ fromLedgerTxIns sbe body = fromLedgerTxInsCollateral :: forall era . ShelleyBasedEra era - -> Ledger.TxBody (ShelleyLedgerEra era) + -> Ledger.TxBody Ledger.TopTx (ShelleyLedgerEra era) -> TxInsCollateral era fromLedgerTxInsCollateral sbe body = caseShelleyToMaryOrAlonzoEraOnwards @@ -1627,7 +1628,9 @@ fromLedgerTxInsCollateral sbe body = sbe fromLedgerTxInsReference - :: ShelleyBasedEra era -> Ledger.TxBody (ShelleyLedgerEra era) -> TxInsReference ViewTx era + :: ShelleyBasedEra era + -> Ledger.TxBody Ledger.TopTx (ShelleyLedgerEra era) + -> TxInsReference ViewTx era fromLedgerTxInsReference sbe txBody = caseShelleyToAlonzoOrBabbageEraOnwards (const TxInsReferenceNone) @@ -1636,7 +1639,7 @@ fromLedgerTxInsReference sbe txBody = fromLedgerTxTotalCollateral :: ShelleyBasedEra era - -> Ledger.TxBody (ShelleyLedgerEra era) + -> Ledger.TxBody Ledger.TopTx (ShelleyLedgerEra era) -> TxTotalCollateral era fromLedgerTxTotalCollateral sbe txbody = caseShelleyToAlonzoOrBabbageEraOnwards @@ -1650,7 +1653,7 @@ fromLedgerTxTotalCollateral sbe txbody = fromLedgerTxReturnCollateral :: ShelleyBasedEra era - -> Ledger.TxBody (ShelleyLedgerEra era) + -> Ledger.TxBody Ledger.TopTx (ShelleyLedgerEra era) -> TxReturnCollateral CtxTx era fromLedgerTxReturnCollateral sbe txbody = caseShelleyToAlonzoOrBabbageEraOnwards @@ -1663,7 +1666,7 @@ fromLedgerTxReturnCollateral sbe txbody = sbe fromLedgerTxFee - :: ShelleyBasedEra era -> Ledger.TxBody (ShelleyLedgerEra era) -> TxFee era + :: ShelleyBasedEra era -> Ledger.TxBody Ledger.TopTx (ShelleyLedgerEra era) -> TxFee era fromLedgerTxFee sbe body = shelleyBasedEraConstraints sbe $ TxFeeExplicit sbe $ @@ -1750,7 +1753,7 @@ fromLedgerTxAuxiliaryData sbe (Just auxData) = fromLedgerTxExtraKeyWitnesses :: ShelleyBasedEra era - -> Ledger.TxBody (ShelleyLedgerEra era) + -> Ledger.TxBody Ledger.TopTx (ShelleyLedgerEra era) -> TxExtraKeyWitnesses era fromLedgerTxExtraKeyWitnesses sbe body = caseShelleyToMaryOrAlonzoEraOnwards @@ -1770,7 +1773,7 @@ fromLedgerTxExtraKeyWitnesses sbe body = fromLedgerTxWithdrawals :: ShelleyBasedEra era - -> Ledger.TxBody (ShelleyLedgerEra era) + -> Ledger.TxBody Ledger.TopTx (ShelleyLedgerEra era) -> TxWithdrawals ViewTx era fromLedgerTxWithdrawals sbe body = shelleyBasedEraConstraints sbe $ @@ -1781,7 +1784,7 @@ fromLedgerTxWithdrawals sbe body = fromLedgerTxCertificates :: ShelleyBasedEra era - -> Ledger.TxBody (ShelleyLedgerEra era) + -> Ledger.TxBody Ledger.TopTx (ShelleyLedgerEra era) -> TxCertificates ViewTx era fromLedgerTxCertificates sbe body = shelleyBasedEraConstraints sbe $ @@ -1794,7 +1797,7 @@ fromLedgerTxCertificates sbe body = maybeFromLedgerTxUpdateProposal :: () => ShelleyBasedEra era - -> Ledger.TxBody (ShelleyLedgerEra era) + -> Ledger.TxBody Ledger.TopTx (ShelleyLedgerEra era) -> TxUpdateProposal era maybeFromLedgerTxUpdateProposal sbe body = caseShelleyToBabbageOrConwayEraOnwards @@ -1808,7 +1811,7 @@ maybeFromLedgerTxUpdateProposal sbe body = fromLedgerTxMintValue :: ShelleyBasedEra era - -> Ledger.TxBody (ShelleyLedgerEra era) + -> Ledger.TxBody Ledger.TopTx (ShelleyLedgerEra era) -> TxMintValue ViewTx era fromLedgerTxMintValue sbe body = forEraInEon (toCardanoEra sbe) TxMintNone $ \w -> maryEraOnwardsConstraints w $ do @@ -1918,16 +1921,22 @@ convMintValue txMintValue = do multiAsset convExtraKeyWitnesses - :: TxExtraKeyWitnesses era -> Set (Shelley.KeyHash Shelley.Witness) + :: TxExtraKeyWitnesses era -> Set (Shelley.KeyHash Shelley.Guard) convExtraKeyWitnesses txExtraKeyWits = case txExtraKeyWits of TxExtraKeyWitnessesNone -> Set.empty TxExtraKeyWitnesses _ khs -> fromList - [ Shelley.asWitness kh + [ asGuard kh | PaymentKeyHash kh <- khs ] +asGuard + :: Ledger.HasKeyRole a + => a r + -> a L.Guard +asGuard = Ledger.coerceKeyRole + convScripts :: ShelleyLedgerEra era ~ ledgerera => [(ScriptWitnessIndex, AnyScriptWitness era)] diff --git a/cardano-api/src/Cardano/Api/Tx/Internal/Body/Lens.hs b/cardano-api/src/Cardano/Api/Tx/Internal/Body/Lens.hs index 3794460469..31fc3cfe1a 100644 --- a/cardano-api/src/Cardano/Api/Tx/Internal/Body/Lens.hs +++ b/cardano-api/src/Cardano/Api/Tx/Internal/Body/Lens.hs @@ -71,7 +71,7 @@ import Data.Set (Set) import Lens.Micro newtype LedgerTxBody era = LedgerTxBody - { unTxBody :: L.TxBody (ShelleyLedgerEra era) + { unTxBody :: L.TxBody L.TopTx (ShelleyLedgerEra era) } strictMaybeL :: Lens' (StrictMaybe a) (Maybe a) @@ -84,7 +84,7 @@ strictMaybeL = lens g s s :: StrictMaybe a -> Maybe a -> StrictMaybe a s _ = maybe SNothing SJust -txBodyL :: Lens' (LedgerTxBody era) (L.TxBody (ShelleyLedgerEra era)) +txBodyL :: Lens' (LedgerTxBody era) (L.TxBody L.TopTx (ShelleyLedgerEra era)) txBodyL = lens unTxBody (\_ x -> LedgerTxBody x) invalidBeforeTxBodyL :: AllegraEraOnwards era -> Lens' (LedgerTxBody era) (StrictMaybe SlotNo) diff --git a/cardano-api/src/Cardano/Api/Tx/Internal/Fee.hs b/cardano-api/src/Cardano/Api/Tx/Internal/Fee.hs index e1f1be05a7..c40f2e0ded 100644 --- a/cardano-api/src/Cardano/Api/Tx/Internal/Fee.hs +++ b/cardano-api/src/Cardano/Api/Tx/Internal/Fee.hs @@ -85,6 +85,7 @@ import Cardano.Ledger.Alonzo.Scripts qualified as Alonzo import Cardano.Ledger.Api qualified as L import Cardano.Ledger.Coin qualified as L import Cardano.Ledger.Conway.Governance qualified as L +import Cardano.Ledger.Core qualified as L import Cardano.Ledger.Credential as Ledger (Credential) import Cardano.Ledger.Plutus.Language qualified as Plutus import Ouroboros.Consensus.HardFork.History qualified as Consensus @@ -717,7 +718,7 @@ evaluateTransactionExecutionUnitsShelley -> LedgerEpochInfo -> LedgerProtocolParameters era -> UTxO era - -> L.Tx (ShelleyLedgerEra era) + -> L.Tx L.TopTx (ShelleyLedgerEra era) -> Map ScriptWitnessIndex (Either ScriptExecutionError (EvalTxExecutionUnitsLog, ExecutionUnits)) evaluateTransactionExecutionUnitsShelley sbe systemstart epochInfo (LedgerProtocolParameters pp) utxo tx = caseShelleyToMaryOrAlonzoEraOnwards @@ -836,12 +837,12 @@ evaluateTransactionBalance sbe pp poolids stakeDelegDeposits drepDelegDeposits u isRegPool kh = StakePoolKeyHash kh `Set.member` poolids lookupDelegDeposit - :: Ledger.Credential 'Ledger.Staking -> Maybe L.Coin + :: Ledger.Credential Ledger.Staking -> Maybe L.Coin lookupDelegDeposit stakeCred = Map.lookup (fromShelleyStakeCredential stakeCred) stakeDelegDeposits lookupDRepDeposit - :: Ledger.Credential 'Ledger.DRepRole -> Maybe L.Coin + :: Ledger.Credential Ledger.DRepRole -> Maybe L.Coin lookupDRepDeposit drepCred = Map.lookup drepCred drepDelegDeposits diff --git a/cardano-api/src/Cardano/Api/Tx/Internal/Output.hs b/cardano-api/src/Cardano/Api/Tx/Internal/Output.hs index ab0dffe14a..5d2a7ec655 100644 --- a/cardano-api/src/Cardano/Api/Tx/Internal/Output.hs +++ b/cardano-api/src/Cardano/Api/Tx/Internal/Output.hs @@ -192,7 +192,7 @@ convTxOuts sbe txOuts = fromList $ map (toShelleyTxOutAny sbe) txOuts fromLedgerTxOuts :: forall era . ShelleyBasedEra era - -> Ledger.TxBody (ShelleyLedgerEra era) + -> Ledger.TxBody Ledger.TopTx (ShelleyLedgerEra era) -> TxBodyScriptData era -> [TxOut CtxTx era] fromLedgerTxOuts sbe body scriptdata = diff --git a/cardano-api/src/Cardano/Api/Tx/Internal/Sign.hs b/cardano-api/src/Cardano/Api/Tx/Internal/Sign.hs index 32bd9bcdfd..ee658b4a2e 100644 --- a/cardano-api/src/Cardano/Api/Tx/Internal/Sign.hs +++ b/cardano-api/src/Cardano/Api/Tx/Internal/Sign.hs @@ -124,7 +124,7 @@ import Lens.Micro data Tx era where ShelleyTx :: ShelleyBasedEra era - -> L.Tx (ShelleyLedgerEra era) + -> L.Tx L.TopTx (ShelleyLedgerEra era) -> Tx era -- | This pattern will be deprecated in the future. We advise against introducing new usage of it. @@ -224,14 +224,14 @@ instance IsShelleyBasedEra era => SerialiseAsCBOR (Tx era) where serialiseShelleyBasedTx :: forall ledgerera . L.EraTx ledgerera - => L.Tx ledgerera + => L.Tx L.TopTx ledgerera -> ByteString serialiseShelleyBasedTx = Plain.serialize' deserialiseShelleyBasedTx :: forall ledgerera tx' . L.EraTx ledgerera - => (L.Tx ledgerera -> tx') + => (L.Tx L.TopTx ledgerera -> tx') -> ByteString -> Either CBOR.DecoderError tx' deserialiseShelleyBasedTx mkTx bs = @@ -296,7 +296,7 @@ instance IsShelleyBasedEra era => HasTextEnvelope (Tx era) where data TxBody era where ShelleyTxBody :: ShelleyBasedEra era - -> Ledger.TxBody (ShelleyLedgerEra era) + -> Ledger.TxBody Ledger.TopTx (ShelleyLedgerEra era) -- We include the scripts along with the tx body, rather than the -- witnesses set, since they need to be known when building the body. -> [Ledger.Script (ShelleyLedgerEra era)] @@ -319,7 +319,7 @@ data TxBody era where -- The 'ShelleyBasedEra' GADT tells us what era we are in. -- The 'ShelleyLedgerEra' type family maps that to the era type from the --- ledger lib. The 'Ledger.TxBody' type family maps that to a specific +-- ledger lib. The 'Ledger.TxBody Ledger.TopTx' type family maps that to a specific -- tx body type, which is different for each Shelley-based era. -- The GADT in the ShelleyTxBody case requires a custom instance @@ -952,7 +952,7 @@ getTxWitnesses (ShelleyTx sbe tx') = getShelleyTxWitnesses :: forall ledgerera . L.EraTx ledgerera - => L.Tx ledgerera + => L.Tx L.TopTx ledgerera -> [KeyWitness era] getShelleyTxWitnesses tx = map (ShelleyBootstrapWitness sbe) (Set.elems (tx ^. L.witsTxL . L.bootAddrTxWitsL)) @@ -961,7 +961,7 @@ getTxWitnesses (ShelleyTx sbe tx') = getAlonzoTxWitnesses :: forall ledgerera . L.EraTx ledgerera - => L.Tx ledgerera + => L.Tx L.TopTx ledgerera -> [KeyWitness era] getAlonzoTxWitnesses = getShelleyTxWitnesses @@ -993,7 +993,7 @@ makeSignedTransaction :: forall ledgerera . ShelleyLedgerEra era ~ ledgerera => L.EraTx ledgerera - => L.Tx ledgerera + => L.Tx L.TopTx ledgerera txCommon = L.mkBasicTx txbody & L.witsTxL @@ -1100,7 +1100,7 @@ makeShelleyBasedBootstrapWitness . () => ShelleyBasedEra era -> WitnessNetworkIdOrByronAddress - -> Ledger.TxBody (ShelleyLedgerEra era) + -> Ledger.TxBody Ledger.TopTx (ShelleyLedgerEra era) -> SigningKey ByronKey -> KeyWitness era makeShelleyBasedBootstrapWitness sbe nwOrAddr txbody (ByronSigningKey sk) = @@ -1192,7 +1192,7 @@ makeShelleyKeyWitness' :: forall era . () => ShelleyBasedEra era - -> L.TxBody (ShelleyLedgerEra era) + -> L.TxBody L.TopTx (ShelleyLedgerEra era) -> ShelleyWitnessSigningKey -> KeyWitness era makeShelleyKeyWitness' sbe txBody wsk = From 58dc248a0bbaab0f5f577be4a2114b154218ad6a Mon Sep 17 00:00:00 2001 From: Jordan Millar Date: Tue, 3 Feb 2026 14:46:02 -0400 Subject: [PATCH 23/32] Update CostModel JSON format --- cardano-api/cardano-api.cabal | 4 +- cardano-api/gen/Test/Gen/Cardano/Api.hs | 38 +- cardano-api/gen/Test/Gen/Cardano/Api/Typed.hs | 4 +- cardano-api/src/Cardano/Api/Genesis.hs | 1 + .../src/Cardano/Api/Genesis/Internal.hs | 703 +++++++++-------- .../Test/Golden/Cardano/Api/Genesis.hs | 9 +- .../Test/Cardano/Api/EpochLeadership.hs | 9 +- .../Test/Cardano/Api/Experimental.hs | 10 +- .../Test/Cardano/Api/Genesis.hs | 33 +- .../Cardano/Api/Transaction/Autobalance.hs | 7 +- .../spec.alonzo-v2-cost-model-array-175.json | 733 ++++++++--------- .../spec.alonzo-v2-cost-model-map-175.json | 740 +++++++++--------- 12 files changed, 1176 insertions(+), 1115 deletions(-) diff --git a/cardano-api/cardano-api.cabal b/cardano-api/cardano-api.cabal index 58b2abc577..c670f49857 100644 --- a/cardano-api/cardano-api.cabal +++ b/cardano-api/cardano-api.cabal @@ -368,7 +368,7 @@ test-suite cardano-api-test cardano-ledger-api ^>=1.13, cardano-ledger-binary, cardano-ledger-conway, - cardano-ledger-core >=1.14, + cardano-ledger-core, cardano-ledger-mary, cardano-ledger-shelley, cardano-protocol-tpraos, @@ -443,7 +443,7 @@ test-suite cardano-api-golden cardano-ledger-alonzo, cardano-ledger-api ^>=1.13, cardano-ledger-binary, - cardano-ledger-core >=1.14, + cardano-ledger-core, cardano-ledger-shelley, cardano-protocol-tpraos, containers, diff --git a/cardano-api/gen/Test/Gen/Cardano/Api.hs b/cardano-api/gen/Test/Gen/Cardano/Api.hs index e123fdfe4b..4841e4c1ee 100644 --- a/cardano-api/gen/Test/Gen/Cardano/Api.hs +++ b/cardano-api/gen/Test/Gen/Cardano/Api.hs @@ -9,9 +9,12 @@ module Test.Gen.Cardano.Api ) where +import Cardano.Api.Genesis (defaultV1CostModel) + import Cardano.Ledger.Alonzo.Core qualified as Ledger import Cardano.Ledger.Alonzo.Genesis qualified as Alonzo import Cardano.Ledger.Alonzo.Scripts qualified as Alonzo +import Cardano.Ledger.Alonzo.Scripts qualified as L import Cardano.Ledger.BaseTypes qualified as Ledger import Cardano.Ledger.Coin qualified as Ledger import Cardano.Ledger.Plutus.CostModels qualified as Plutus @@ -97,7 +100,20 @@ genAlonzoGenesis :: Gen Alonzo.AlonzoGenesis genAlonzoGenesis = do coinsPerUTxOWord <- genCoin (Range.linear 0 5) -- TODO: Babbage: Figure out how to deal with the asymmetric cost model JSON - _costmdls' <- genCostModels + costmdls' <- genCostModels + v1CostModel <- case Map.lookup Alonzo.PlutusV1 $ L.costModelsValid costmdls' of + Just cm -> return cm + Nothing -> return defaultV1CostModel + + let v2OnwardsCostModels = + mconcat $ + map + ( \l -> case l `Map.lookup` L.costModelsValid costmdls' of + Just cm -> Map.singleton l cm + Nothing -> Map.empty + ) + [Alonzo.PlutusV2 .. maxBound] + extraConfig = Just $ Alonzo.AlonzoExtraConfig $ Just $ L.mkCostModels v2OnwardsCostModels prices' <- genPrices maxTxExUnits' <- genExUnits maxBlockExUnits' <- genExUnits @@ -105,14 +121,14 @@ genAlonzoGenesis = do collateralPercentage' <- Gen.integral (Range.linear 0 10) maxCollateralInputs' <- Gen.integral (Range.linear 0 10) - return + return $ Alonzo.AlonzoGenesis - { Alonzo.agCoinsPerUTxOWord = Ledger.CoinPerWord coinsPerUTxOWord - , Alonzo.agCostModels = mempty - , Alonzo.agPrices = prices' - , Alonzo.agMaxTxExUnits = maxTxExUnits' - , Alonzo.agMaxBlockExUnits = maxBlockExUnits' - , Alonzo.agMaxValSize = maxValSize' - , Alonzo.agCollateralPercentage = collateralPercentage' - , Alonzo.agMaxCollateralInputs = maxCollateralInputs' - } + (Ledger.CoinPerWord coinsPerUTxOWord) + v1CostModel + prices' + maxTxExUnits' + maxBlockExUnits' + maxValSize' + collateralPercentage' + maxCollateralInputs' + extraConfig diff --git a/cardano-api/gen/Test/Gen/Cardano/Api/Typed.hs b/cardano-api/gen/Test/Gen/Cardano/Api/Typed.hs index 16ab7ef359..ffa9e483e2 100644 --- a/cardano-api/gen/Test/Gen/Cardano/Api/Typed.hs +++ b/cardano-api/gen/Test/Gen/Cardano/Api/Typed.hs @@ -172,8 +172,8 @@ import Cardano.Crypto.Seed qualified as Crypto import Cardano.Ledger.Alonzo.Scripts qualified as Alonzo import Cardano.Ledger.BaseTypes qualified as Ledger import Cardano.Ledger.Core qualified as Ledger +import Cardano.Ledger.Hashes (unsafeMakeSafeHash) import Cardano.Ledger.Plutus.Language qualified as L -import Cardano.Ledger.SafeHash (unsafeMakeSafeHash) import Control.Applicative (Alternative (..), optional) import Control.Monad @@ -736,7 +736,7 @@ genTxValidityLowerBound = -- TODO: Accept a range for generating ttl. genTxValidityUpperBound :: ShelleyBasedEra era -> Gen (TxValidityUpperBound era) genTxValidityUpperBound sbe = - TxValidityUpperBound sbe <$> Gen.maybe genTtl + TxValidityUpperBound sbe . Ledger.maybeToStrictMaybe <$> Gen.maybe genTtl genTxMetadataInEra :: CardanoEra era -> Gen (TxMetadataInEra era) genTxMetadataInEra = diff --git a/cardano-api/src/Cardano/Api/Genesis.hs b/cardano-api/src/Cardano/Api/Genesis.hs index 3efb52633a..5fd4f98e19 100644 --- a/cardano-api/src/Cardano/Api/Genesis.hs +++ b/cardano-api/src/Cardano/Api/Genesis.hs @@ -4,6 +4,7 @@ module Cardano.Api.Genesis , alonzoGenesisDefaults , conwayGenesisDefaults , dijkstraGenesisDefaults + , defaultV1CostModel -- ** Configuration , ByronGenesisConfig diff --git a/cardano-api/src/Cardano/Api/Genesis/Internal.hs b/cardano-api/src/Cardano/Api/Genesis/Internal.hs index 17df805cc5..d70751c0b0 100644 --- a/cardano-api/src/Cardano/Api/Genesis/Internal.hs +++ b/cardano-api/src/Cardano/Api/Genesis/Internal.hs @@ -32,6 +32,9 @@ module Cardano.Api.Genesis.Internal , AlonzoGenesisFile , ConwayGenesisFile + -- ** Defaults + , defaultV1CostModel + -- * Utilities , unsafeBoundedRational ) @@ -42,7 +45,7 @@ import Cardano.Api.IO import Cardano.Chain.Genesis qualified import Cardano.Crypto.Hash.Blake2b qualified import Cardano.Crypto.Hash.Class qualified -import Cardano.Ledger.Alonzo.Genesis (AlonzoGenesis (..), AlonzoExtraConfig(..)) +import Cardano.Ledger.Alonzo.Genesis (AlonzoExtraConfig (..), AlonzoGenesis (..)) import Cardano.Ledger.Alonzo.Scripts (ExUnits (..), Prices (..)) import Cardano.Ledger.Api (CoinPerWord (..)) import Cardano.Ledger.BaseTypes as Ledger @@ -358,7 +361,7 @@ alonzoGenesisDefaults = { exUnitsMem = 62000000 , exUnitsSteps = 20000000000 } - , agPlutusV1CostModel = either (error . show) id (L.mkCostModel PlutusV1 defaultV1CostModel) + , agPlutusV1CostModel = either (error . show) id (L.mkCostModel PlutusV1 defaultV1CostModelValues) , agCollateralPercentage = 150 , agCoinsPerUTxOWord = CoinPerWord $ Coin 34482 , agExtraConfig = Just . AlonzoExtraConfig . Just $ errorFail apiCostModels @@ -367,354 +370,360 @@ alonzoGenesisDefaults = apiCostModels = mkCostModelsLenient $ fromList - [ (fromIntegral $ fromEnum PlutusV1, defaultV1CostModel) + [ (fromIntegral $ fromEnum PlutusV1, defaultV1CostModelValues) , (fromIntegral $ fromEnum PlutusV2, defaultV2CostModel) ] - defaultV1CostModel = - [ 205665 - , 812 - , 1 - , 1 - , 1000 - , 571 - , 0 - , 1 - , 1000 - , 24177 - , 4 - , 1 - , 1000 - , 32 - , 117366 - , 10475 - , 4 - , 23000 - , 100 - , 23000 - , 100 - , 23000 - , 100 - , 23000 - , 100 - , 23000 - , 100 - , 23000 - , 100 - , 100 - , 100 - , 23000 - , 100 - , 19537 - , 32 - , 175354 - , 32 - , 46417 - , 4 - , 221973 - , 511 - , 0 - , 1 - , 89141 - , 32 - , 497525 - , 14068 - , 4 - , 2 - , 196500 - , 453240 - , 220 - , 0 - , 1 - , 1 - , 1000 - , 28662 - , 4 - , 2 - , 245000 - , 216773 - , 62 - , 1 - , 1060367 - , 12586 - , 1 - , 208512 - , 421 - , 1 - , 187000 - , 1000 - , 52998 - , 1 - , 80436 - , 32 - , 43249 - , 32 - , 1000 - , 32 - , 80556 - , 1 - , 57667 - , 4 - , 1000 - , 10 - , 197145 - , 156 - , 1 - , 197145 - , 156 - , 1 - , 204924 - , 473 - , 1 - , 208896 - , 511 - , 1 - , 52467 - , 32 - , 64832 - , 32 - , 65493 - , 32 - , 22558 - , 32 - , 16563 - , 32 - , 76511 - , 32 - , 196500 - , 453240 - , 220 - , 0 - , 1 - , 1 - , 69522 - , 11687 - , 0 - , 1 - , 60091 - , 32 - , 196500 - , 453240 - , 220 - , 0 - , 1 - , 1 - , 196500 - , 453240 - , 220 - , 0 - , 1 - , 1 - , 806990 - , 30482 - , 4 - , 1927926 - , 82523 - , 4 - , 265318 - , 0 - , 4 - , 0 - , 85931 - , 32 - , 205665 - , 812 - , 1 - , 1 - , 41182 - , 32 - , 212342 - , 32 - , 31220 - , 32 - , 32696 - , 32 - , 43357 - , 32 - , 32247 - , 32 - , 38314 - , 32 - , 57996947 - , 18975 - , 10 - ] defaultV2CostModel = - [ 205665 - , 812 - , 1 - , 1 - , 1000 - , 571 - , 0 - , 1 - , 1000 - , 24177 - , 4 - , 1 - , 1000 - , 32 - , 117366 - , 10475 - , 4 - , 23000 - , 100 - , 23000 - , 100 - , 23000 - , 100 - , 23000 - , 100 - , 23000 - , 100 - , 23000 - , 100 - , 100 - , 100 - , 23000 - , 100 - , 19537 - , 32 - , 175354 - , 32 - , 46417 - , 4 - , 221973 - , 511 - , 0 - , 1 - , 89141 - , 32 - , 497525 - , 14068 - , 4 - , 2 - , 196500 - , 453240 - , 220 - , 0 - , 1 - , 1 - , 1000 - , 28662 - , 4 - , 2 - , 245000 - , 216773 - , 62 - , 1 - , 1060367 - , 12586 - , 1 - , 208512 - , 421 - , 1 - , 187000 - , 1000 - , 52998 - , 1 - , 80436 - , 32 - , 43249 - , 32 - , 1000 - , 32 - , 80556 - , 1 - , 57667 - , 4 - , 1000 - , 10 - , 197145 - , 156 - , 1 - , 197145 - , 156 - , 1 - , 204924 - , 473 - , 1 - , 208896 - , 511 - , 1 - , 52467 - , 32 - , 64832 - , 32 - , 65493 - , 32 - , 22558 - , 32 - , 16563 - , 32 - , 76511 - , 32 - , 196500 - , 453240 - , 220 - , 0 - , 1 - , 1 - , 69522 - , 11687 - , 0 - , 1 - , 60091 - , 32 - , 196500 - , 453240 - , 220 - , 0 - , 1 - , 1 - , 196500 - , 453240 - , 220 - , 0 - , 1 - , 1 - , 1159724 - , 392670 - , 0 - , 2 - , 806990 - , 30482 - , 4 - , 1927926 - , 82523 - , 4 - , 265318 - , 0 - , 4 - , 0 - , 85931 - , 32 - , 205665 - , 812 - , 1 - , 1 - , 41182 - , 32 - , 212342 - , 32 - , 31220 - , 32 - , 32696 - , 32 - , 43357 - , 32 - , 32247 - , 32 - , 38314 - , 32 - , 35892428 - , 10 - , 9462713 - , 1021 - , 10 - , 38887044 - , 32947 - , 10 - ] + [ 205665 + , 812 + , 1 + , 1 + , 1000 + , 571 + , 0 + , 1 + , 1000 + , 24177 + , 4 + , 1 + , 1000 + , 32 + , 117366 + , 10475 + , 4 + , 23000 + , 100 + , 23000 + , 100 + , 23000 + , 100 + , 23000 + , 100 + , 23000 + , 100 + , 23000 + , 100 + , 100 + , 100 + , 23000 + , 100 + , 19537 + , 32 + , 175354 + , 32 + , 46417 + , 4 + , 221973 + , 511 + , 0 + , 1 + , 89141 + , 32 + , 497525 + , 14068 + , 4 + , 2 + , 196500 + , 453240 + , 220 + , 0 + , 1 + , 1 + , 1000 + , 28662 + , 4 + , 2 + , 245000 + , 216773 + , 62 + , 1 + , 1060367 + , 12586 + , 1 + , 208512 + , 421 + , 1 + , 187000 + , 1000 + , 52998 + , 1 + , 80436 + , 32 + , 43249 + , 32 + , 1000 + , 32 + , 80556 + , 1 + , 57667 + , 4 + , 1000 + , 10 + , 197145 + , 156 + , 1 + , 197145 + , 156 + , 1 + , 204924 + , 473 + , 1 + , 208896 + , 511 + , 1 + , 52467 + , 32 + , 64832 + , 32 + , 65493 + , 32 + , 22558 + , 32 + , 16563 + , 32 + , 76511 + , 32 + , 196500 + , 453240 + , 220 + , 0 + , 1 + , 1 + , 69522 + , 11687 + , 0 + , 1 + , 60091 + , 32 + , 196500 + , 453240 + , 220 + , 0 + , 1 + , 1 + , 196500 + , 453240 + , 220 + , 0 + , 1 + , 1 + , 1159724 + , 392670 + , 0 + , 2 + , 806990 + , 30482 + , 4 + , 1927926 + , 82523 + , 4 + , 265318 + , 0 + , 4 + , 0 + , 85931 + , 32 + , 205665 + , 812 + , 1 + , 1 + , 41182 + , 32 + , 212342 + , 32 + , 31220 + , 32 + , 32696 + , 32 + , 43357 + , 32 + , 32247 + , 32 + , 38314 + , 32 + , 35892428 + , 10 + , 9462713 + , 1021 + , 10 + , 38887044 + , 32947 + , 10 + ] + +defaultV1CostModel :: L.CostModel +defaultV1CostModel = + either (error . show) id (L.mkCostModel PlutusV1 defaultV1CostModelValues) + +defaultV1CostModelValues :: [Int64] +defaultV1CostModelValues = + [ 205665 + , 812 + , 1 + , 1 + , 1000 + , 571 + , 0 + , 1 + , 1000 + , 24177 + , 4 + , 1 + , 1000 + , 32 + , 117366 + , 10475 + , 4 + , 23000 + , 100 + , 23000 + , 100 + , 23000 + , 100 + , 23000 + , 100 + , 23000 + , 100 + , 23000 + , 100 + , 100 + , 100 + , 23000 + , 100 + , 19537 + , 32 + , 175354 + , 32 + , 46417 + , 4 + , 221973 + , 511 + , 0 + , 1 + , 89141 + , 32 + , 497525 + , 14068 + , 4 + , 2 + , 196500 + , 453240 + , 220 + , 0 + , 1 + , 1 + , 1000 + , 28662 + , 4 + , 2 + , 245000 + , 216773 + , 62 + , 1 + , 1060367 + , 12586 + , 1 + , 208512 + , 421 + , 1 + , 187000 + , 1000 + , 52998 + , 1 + , 80436 + , 32 + , 43249 + , 32 + , 1000 + , 32 + , 80556 + , 1 + , 57667 + , 4 + , 1000 + , 10 + , 197145 + , 156 + , 1 + , 197145 + , 156 + , 1 + , 204924 + , 473 + , 1 + , 208896 + , 511 + , 1 + , 52467 + , 32 + , 64832 + , 32 + , 65493 + , 32 + , 22558 + , 32 + , 16563 + , 32 + , 76511 + , 32 + , 196500 + , 453240 + , 220 + , 0 + , 1 + , 1 + , 69522 + , 11687 + , 0 + , 1 + , 60091 + , 32 + , 196500 + , 453240 + , 220 + , 0 + , 1 + , 1 + , 196500 + , 453240 + , 220 + , 0 + , 1 + , 1 + , 806990 + , 30482 + , 4 + , 1927926 + , 82523 + , 4 + , 265318 + , 0 + , 4 + , 0 + , 85931 + , 32 + , 205665 + , 812 + , 1 + , 1 + , 41182 + , 32 + , 212342 + , 32 + , 31220 + , 32 + , 32696 + , 32 + , 43357 + , 32 + , 32247 + , 32 + , 38314 + , 32 + , 57996947 + , 18975 + , 10 + ] -- | Convert Rational to a bounded rational. Throw an exception when the rational is out of bounds. unsafeBoundedRational diff --git a/cardano-api/test/cardano-api-golden/Test/Golden/Cardano/Api/Genesis.hs b/cardano-api/test/cardano-api-golden/Test/Golden/Cardano/Api/Genesis.hs index 5b4b6a234f..586d595b20 100644 --- a/cardano-api/test/cardano-api-golden/Test/Golden/Cardano/Api/Genesis.hs +++ b/cardano-api/test/cardano-api-golden/Test/Golden/Cardano/Api/Genesis.hs @@ -11,14 +11,11 @@ where import Cardano.Api.Genesis import Cardano.Crypto.VRF (VerKeyVRF) -import Cardano.Ledger.Address (Addr (..)) import Cardano.Ledger.BaseTypes (Network (..), knownNonZeroBounded) import Cardano.Ledger.Coin (Coin (..)) import Cardano.Ledger.Core import Cardano.Ledger.Credential ( Credential (..) - , PaymentCredential - , StakeCredential , StakeReference (..) ) import Cardano.Ledger.Keys (GenDelegPair (..)) @@ -61,7 +58,7 @@ exampleShelleyGenesis = } where -- hash of the genesis verification key - genesisVerKeyHash :: KeyHash Genesis + genesisVerKeyHash :: KeyHash GenesisRole genesisVerKeyHash = KeyHash "23d51e91ae5adc7ae801e9de4cd54175fb7464ec2680b25686bbb194" -- hash of the delegators verification key delegVerKeyHash :: KeyHash GenesisDelegate @@ -71,13 +68,13 @@ exampleShelleyGenesis = initialFundedAddress :: Addr initialFundedAddress = Addr Testnet paymentCredential (StakeRefBase stakingCredential) where - paymentCredential :: PaymentCredential + paymentCredential :: Credential Payment paymentCredential = KeyHashObj $ KeyHash "1c14ee8e58fbcbd48dc7367c95a63fd1d937ba989820015db16ac7e5" - stakingCredential :: StakeCredential + stakingCredential :: Credential Staking stakingCredential = KeyHashObj $ KeyHash diff --git a/cardano-api/test/cardano-api-test/Test/Cardano/Api/EpochLeadership.hs b/cardano-api/test/cardano-api-test/Test/Cardano/Api/EpochLeadership.hs index 0a84aa71b0..2c0a66120a 100644 --- a/cardano-api/test/cardano-api-test/Test/Cardano/Api/EpochLeadership.hs +++ b/cardano-api/test/cardano-api-test/Test/Cardano/Api/EpochLeadership.hs @@ -2,6 +2,7 @@ {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE OverloadedLists #-} {-# LANGUAGE ScopedTypeVariables #-} +{-# LANGUAGE TypeApplications #-} {-# LANGUAGE TypeFamilies #-} module Test.Cardano.Api.EpochLeadership @@ -15,8 +16,9 @@ import Cardano.Api.Ledger (KeyHash (..), toCompactPartial) import Cardano.Binary (serialize) import Cardano.Crypto.Seed (mkSeedFromBytes) import Cardano.Ledger.Api.PParams (emptyPParams) -import Cardano.Ledger.BaseTypes (Nonce (..), WithOrigin (..)) +import Cardano.Ledger.BaseTypes (NonZero (..), Nonce (..), WithOrigin (..), knownNonZero) import Cardano.Ledger.Binary.Encoding (toByronCBOR) +import Cardano.Ledger.Coin (toCoinNonZero) import Cardano.Ledger.Hashes qualified as L import Cardano.Ledger.Shelley.API qualified as L import Cardano.Ledger.State qualified as L @@ -110,7 +112,7 @@ test_currentEpochEligibleLeadershipSlots = } ) ] - , L.pdTotalActiveStake = toCompactPartial 0 + , L.pdTotalActiveStake = nonZeroCoin } serPoolDistr = Serialised (serialize (toByronCBOR poolDistr)) currentEpoch = EpochNo 4 @@ -136,3 +138,6 @@ test_currentEpochEligibleLeadershipSlots = encodeProtocolState cds = ProtocolState (Serialised pbs) where pbs = serialize (toCBOR cds) + +nonZeroCoin :: NonZero Coin +nonZeroCoin = toCoinNonZero $ knownNonZero @1 diff --git a/cardano-api/test/cardano-api-test/Test/Cardano/Api/Experimental.hs b/cardano-api/test/cardano-api-test/Test/Cardano/Api/Experimental.hs index 304f3c6745..1ac0b20099 100644 --- a/cardano-api/test/cardano-api-test/Test/Cardano/Api/Experimental.hs +++ b/cardano-api/test/cardano-api-test/Test/Cardano/Api/Experimental.hs @@ -19,8 +19,8 @@ import Cardano.Api.Ledger qualified as Ledger import Cardano.Api.Plutus qualified as Script import Cardano.Api.Tx (Tx (ShelleyTx)) -import Cardano.Ledger.Alonzo.Scripts qualified as UnexportedLedger import Cardano.Ledger.Api qualified as UnexportedLedger +import Cardano.Ledger.Core qualified as L import Cardano.Slotting.EpochInfo qualified as Slotting import Cardano.Slotting.Slot qualified as Slotting import Cardano.Slotting.Time qualified as Slotting @@ -98,7 +98,7 @@ prop_created_transaction_with_both_apis_are_the_same = H.propertyOnce $ do exampleTransactionExperimentalWay :: H.MonadTest m => Exp.Era Exp.ConwayEra - -> m (Ledger.Tx (Exp.LedgerEra Exp.ConwayEra)) + -> m (Ledger.Tx L.TopTx (Exp.LedgerEra Exp.ConwayEra)) exampleTransactionExperimentalWay era = do txBodyContent <- exampleTxBodyContentExperimental era signingKey <- exampleSigningKey @@ -109,7 +109,7 @@ prop_created_transaction_with_both_apis_are_the_same = H.propertyOnce $ do let bootstrapWitnesses = [] keyWitnesses = [witness] - let Exp.SignedTx (signedTx :: Ledger.Tx (Exp.LedgerEra Exp.ConwayEra)) = Exp.signTx era bootstrapWitnesses keyWitnesses unsignedTx + let Exp.SignedTx (signedTx :: Ledger.Tx L.TopTx (Exp.LedgerEra Exp.ConwayEra)) = Exp.signTx era bootstrapWitnesses keyWitnesses unsignedTx return signedTx prop_balance_transaction_two_ways :: Property @@ -240,7 +240,7 @@ exampleProtocolParams = alonzoUpgrade = UnexportedLedger.UpgradeAlonzoPParams { UnexportedLedger.uappCoinsPerUTxOWord = Ledger.CoinPerWord $ Ledger.Coin 34_482 - , UnexportedLedger.uappCostModels = UnexportedLedger.emptyCostModels -- We are not using scripts for this tests, so this is fine for now + , UnexportedLedger.uappPlutusV1CostModel = Genesis.defaultV1CostModel -- We are not using scripts for this tests, so this is fine for now , UnexportedLedger.uappPrices = Ledger.Prices { Ledger.prSteps = fromMaybe maxBound $ Ledger.boundRational $ 721 % 10_000_000 @@ -411,7 +411,7 @@ expEraGen = let eras :: [Exp.Some Exp.Era] = [minBound .. maxBound] in Gen.element eras -expTxForEraGen :: Exp.Era era -> Gen (Ledger.Tx (Exp.LedgerEra era)) +expTxForEraGen :: Exp.Era era -> Gen (Ledger.Tx L.TopTx (Exp.LedgerEra era)) expTxForEraGen era = do Exp.obtainCommonConstraints era $ do ShelleyTx _ tx <- genTx (convert era) diff --git a/cardano-api/test/cardano-api-test/Test/Cardano/Api/Genesis.hs b/cardano-api/test/cardano-api-test/Test/Cardano/Api/Genesis.hs index ff3424a5a4..edb1c2ec46 100644 --- a/cardano-api/test/cardano-api-test/Test/Cardano/Api/Genesis.hs +++ b/cardano-api/test/cardano-api-test/Test/Cardano/Api/Genesis.hs @@ -83,7 +83,7 @@ prop_check_default_alonzo_genesis_roundtrips = H.propertyOnce $ do ] forM_ eras $ \(Some aeo) -> do - let defaultCostModels = L.agCostModels alonzoGenesisDefaults + let defaultCostModels = fromJust . L.aecCostModels $ fromJust $ L.agExtraConfig alonzoGenesisDefaults defaultCostModelsBs = encodeCborInEraCostModels aeo defaultCostModels H.note_ $ "Decode alonzo genesis for era " <> show aeo defaultCostModels' <- H.leftFail $ decodeCborInEraCostModels aeo defaultCostModelsBs @@ -115,13 +115,36 @@ loadPlutusV2CostModelFromGenesis => FilePath -> m (Either String (L.CostModels, [Int64])) loadPlutusV2CostModelFromGenesis filePath = withFrozenCallStack . runExceptT $ do - genesis <- H.readJsonFileOk filePath - let costModels = L.agCostModels genesis + aGen <- H.readJsonFileOk filePath + extraConfig <- + liftEither + $ maybe + ( Left $ + unlines + [ "No V2 costmodels present in Alonzo genesis: " <> filePath + , "AlonzoGenesis: " <> show aGen + ] + ) + Right + $ L.agExtraConfig aGen + + costModels <- + liftEither + $ maybe + ( Left $ + unlines + [ "No cost models present in Alonzo genesis: " <> filePath + , "ExtraConfig: " <> show extraConfig + , "AlonzoGenesis: " <> show aGen + ] + ) + Right + $ L.aecCostModels extraConfig + let m = L.costModelsValid costModels liftEither . fmap ((costModels,) . L.getCostModelParams) . maybe (Left "No PlutusV2 model found") Right - . M.lookup L.PlutusV2 - $ L.costModelsValid costModels + $ M.lookup L.PlutusV2 m decodeCborInEraCostModels :: forall era diff --git a/cardano-api/test/cardano-api-test/Test/Cardano/Api/Transaction/Autobalance.hs b/cardano-api/test/cardano-api-test/Test/Cardano/Api/Transaction/Autobalance.hs index 39df8660e0..199fb7b9d7 100644 --- a/cardano-api/test/cardano-api-test/Test/Cardano/Api/Transaction/Autobalance.hs +++ b/cardano-api/test/cardano-api-test/Test/Cardano/Api/Transaction/Autobalance.hs @@ -574,9 +574,10 @@ prop_ensure_gov_actions_are_preserved_by_autobalance = H.propertyOnce $ do L.ProposalProcedure { L.pProcDeposit = 100_000_000 , L.pProcReturnAddr = - L.RewardAccount - { L.raNetwork = L.Testnet - , L.raCredential = mkCredential "keyHash-0b1b872f7953bccfc4245f3282b3363f3d19e9e001a5c41e307363d7" + L.AccountAddress + { L.aaNetworkId = L.Testnet + , L.aaAccountId = + L.AccountId $ mkCredential "keyHash-0b1b872f7953bccfc4245f3282b3363f3d19e9e001a5c41e307363d7" } , L.pProcGovAction = L.InfoAction , L.pProcAnchor = anchor diff --git a/cardano-api/test/cardano-api-test/files/input/genesis/spec.alonzo-v2-cost-model-array-175.json b/cardano-api/test/cardano-api-test/files/input/genesis/spec.alonzo-v2-cost-model-array-175.json index abcaab932f..d23389905e 100644 --- a/cardano-api/test/cardano-api-test/files/input/genesis/spec.alonzo-v2-cost-model-array-175.json +++ b/cardano-api/test/cardano-api-test/files/input/genesis/spec.alonzo-v2-cost-model-array-175.json @@ -1,365 +1,370 @@ { - "collateralPercentage": 150, - "costModels": { - "PlutusV1": [ - 205665, - 812, - 1, - 1, - 1000, - 571, - 0, - 1, - 1000, - 24177, - 4, - 1, - 1000, - 32, - 117366, - 10475, - 4, - 23000, - 100, - 23000, - 100, - 23000, - 100, - 23000, - 100, - 23000, - 100, - 23000, - 100, - 100, - 100, - 23000, - 100, - 19537, - 32, - 175354, - 32, - 46417, - 4, - 221973, - 511, - 0, - 1, - 89141, - 32, - 497525, - 14068, - 4, - 2, - 196500, - 453240, - 220, - 0, - 1, - 1, - 1000, - 28662, - 4, - 2, - 245000, - 216773, - 62, - 1, - 1060367, - 12586, - 1, - 208512, - 421, - 1, - 187000, - 1000, - 52998, - 1, - 80436, - 32, - 43249, - 32, - 1000, - 32, - 80556, - 1, - 57667, - 4, - 1000, - 10, - 197145, - 156, - 1, - 197145, - 156, - 1, - 204924, - 473, - 1, - 208896, - 511, - 1, - 52467, - 32, - 64832, - 32, - 65493, - 32, - 22558, - 32, - 16563, - 32, - 76511, - 32, - 196500, - 453240, - 220, - 0, - 1, - 1, - 69522, - 11687, - 0, - 1, - 60091, - 32, - 196500, - 453240, - 220, - 0, - 1, - 1, - 196500, - 453240, - 220, - 0, - 1, - 1, - 806990, - 30482, - 4, - 1927926, - 82523, - 4, - 265318, - 0, - 4, - 0, - 85931, - 32, - 205665, - 812, - 1, - 1, - 41182, - 32, - 212342, - 32, - 31220, - 32, - 32696, - 32, - 43357, - 32, - 32247, - 32, - 38314, - 32, - 9462713, - 1021, - 10 - ], - "PlutusV2": [ - 205665, - 812, - 1, - 1, - 1000, - 571, - 0, - 1, - 1000, - 24177, - 4, - 1, - 1000, - 32, - 117366, - 10475, - 4, - 23000, - 100, - 23000, - 100, - 23000, - 100, - 23000, - 100, - 23000, - 100, - 23000, - 100, - 100, - 100, - 23000, - 100, - 19537, - 32, - 175354, - 32, - 46417, - 4, - 221973, - 511, - 0, - 1, - 89141, - 32, - 497525, - 14068, - 4, - 2, - 196500, - 453240, - 220, - 0, - 1, - 1, - 1000, - 28662, - 4, - 2, - 245000, - 216773, - 62, - 1, - 1060367, - 12586, - 1, - 208512, - 421, - 1, - 187000, - 1000, - 52998, - 1, - 80436, - 32, - 43249, - 32, - 1000, - 32, - 80556, - 1, - 57667, - 4, - 1000, - 10, - 197145, - 156, - 1, - 197145, - 156, - 1, - 204924, - 473, - 1, - 208896, - 511, - 1, - 52467, - 32, - 64832, - 32, - 65493, - 32, - 22558, - 32, - 16563, - 32, - 76511, - 32, - 196500, - 453240, - 220, - 0, - 1, - 1, - 69522, - 11687, - 0, - 1, - 60091, - 32, - 196500, - 453240, - 220, - 0, - 1, - 1, - 196500, - 453240, - 220, - 0, - 1, - 1, - 1159724, - 392670, - 0, - 2, - 806990, - 30482, - 4, - 1927926, - 82523, - 4, - 265318, - 0, - 4, - 0, - 85931, - 32, - 205665, - 812, - 1, - 1, - 41182, - 32, - 212342, - 32, - 31220, - 32, - 32696, - 32, - 43357, - 32, - 32247, - 32, - 38314, - 32, - 35892428, - 10, - 9462713, - 1021, - 10, - 38887044, - 32947, - 10 - ] - }, - "executionPrices": { - "prMem": 0.0577, - "prSteps": 7.21e-05 - }, - "lovelacePerUTxOWord": 34482, - "maxBlockExUnits": { - "exUnitsMem": 62000000, - "exUnitsSteps": 40000000000 - }, - "maxCollateralInputs": 3, - "maxTxExUnits": { - "exUnitsMem": 14000000, - "exUnitsSteps": 10000000000 - }, - "maxValueSize": 5000 -} + "collateralPercentage": 150, + "costModels": { + "PlutusV1": [ + 205665, + 812, + 1, + 1, + 1000, + 571, + 0, + 1, + 1000, + 24177, + 4, + 1, + 1000, + 32, + 117366, + 10475, + 4, + 23000, + 100, + 23000, + 100, + 23000, + 100, + 23000, + 100, + 23000, + 100, + 23000, + 100, + 100, + 100, + 23000, + 100, + 19537, + 32, + 175354, + 32, + 46417, + 4, + 221973, + 511, + 0, + 1, + 89141, + 32, + 497525, + 14068, + 4, + 2, + 196500, + 453240, + 220, + 0, + 1, + 1, + 1000, + 28662, + 4, + 2, + 245000, + 216773, + 62, + 1, + 1060367, + 12586, + 1, + 208512, + 421, + 1, + 187000, + 1000, + 52998, + 1, + 80436, + 32, + 43249, + 32, + 1000, + 32, + 80556, + 1, + 57667, + 4, + 1000, + 10, + 197145, + 156, + 1, + 197145, + 156, + 1, + 204924, + 473, + 1, + 208896, + 511, + 1, + 52467, + 32, + 64832, + 32, + 65493, + 32, + 22558, + 32, + 16563, + 32, + 76511, + 32, + 196500, + 453240, + 220, + 0, + 1, + 1, + 69522, + 11687, + 0, + 1, + 60091, + 32, + 196500, + 453240, + 220, + 0, + 1, + 1, + 196500, + 453240, + 220, + 0, + 1, + 1, + 806990, + 30482, + 4, + 1927926, + 82523, + 4, + 265318, + 0, + 4, + 0, + 85931, + 32, + 205665, + 812, + 1, + 1, + 41182, + 32, + 212342, + 32, + 31220, + 32, + 32696, + 32, + 43357, + 32, + 32247, + 32, + 38314, + 32, + 9462713, + 1021, + 10 + ] + + }, + "executionPrices": { + "prMem": 0.0577, + "prSteps": 7.21e-05 + }, + "lovelacePerUTxOWord": 34482, + "maxBlockExUnits": { + "exUnitsMem": 62000000, + "exUnitsSteps": 40000000000 + }, + "maxCollateralInputs": 3, + "maxTxExUnits": { + "exUnitsMem": 14000000, + "exUnitsSteps": 10000000000 + }, + "maxValueSize": 5000, + "extraConfig": { + "costModels": { + "PlutusV2": [ + 205665, + 812, + 1, + 1, + 1000, + 571, + 0, + 1, + 1000, + 24177, + 4, + 1, + 1000, + 32, + 117366, + 10475, + 4, + 23000, + 100, + 23000, + 100, + 23000, + 100, + 23000, + 100, + 23000, + 100, + 23000, + 100, + 100, + 100, + 23000, + 100, + 19537, + 32, + 175354, + 32, + 46417, + 4, + 221973, + 511, + 0, + 1, + 89141, + 32, + 497525, + 14068, + 4, + 2, + 196500, + 453240, + 220, + 0, + 1, + 1, + 1000, + 28662, + 4, + 2, + 245000, + 216773, + 62, + 1, + 1060367, + 12586, + 1, + 208512, + 421, + 1, + 187000, + 1000, + 52998, + 1, + 80436, + 32, + 43249, + 32, + 1000, + 32, + 80556, + 1, + 57667, + 4, + 1000, + 10, + 197145, + 156, + 1, + 197145, + 156, + 1, + 204924, + 473, + 1, + 208896, + 511, + 1, + 52467, + 32, + 64832, + 32, + 65493, + 32, + 22558, + 32, + 16563, + 32, + 76511, + 32, + 196500, + 453240, + 220, + 0, + 1, + 1, + 69522, + 11687, + 0, + 1, + 60091, + 32, + 196500, + 453240, + 220, + 0, + 1, + 1, + 196500, + 453240, + 220, + 0, + 1, + 1, + 1159724, + 392670, + 0, + 2, + 806990, + 30482, + 4, + 1927926, + 82523, + 4, + 265318, + 0, + 4, + 0, + 85931, + 32, + 205665, + 812, + 1, + 1, + 41182, + 32, + 212342, + 32, + 31220, + 32, + 32696, + 32, + 43357, + 32, + 32247, + 32, + 38314, + 32, + 35892428, + 10, + 9462713, + 1021, + 10, + 38887044, + 32947, + 10 + ] + } + } +} \ No newline at end of file diff --git a/cardano-api/test/cardano-api-test/files/input/genesis/spec.alonzo-v2-cost-model-map-175.json b/cardano-api/test/cardano-api-test/files/input/genesis/spec.alonzo-v2-cost-model-map-175.json index 3d0d6ba16d..24c86e7f56 100644 --- a/cardano-api/test/cardano-api-test/files/input/genesis/spec.alonzo-v2-cost-model-map-175.json +++ b/cardano-api/test/cardano-api-test/files/input/genesis/spec.alonzo-v2-cost-model-map-175.json @@ -1,372 +1,376 @@ { - "coinsPerUTxOByte": 4310, - "collateralPercentage": 150, - "costModels": { - "PlutusV1": { - "addInteger-cpu-arguments-intercept": 205665, - "addInteger-cpu-arguments-slope": 812, - "addInteger-memory-arguments-intercept": 1, - "addInteger-memory-arguments-slope": 1, - "appendByteString-cpu-arguments-intercept": 1000, - "appendByteString-cpu-arguments-slope": 571, - "appendByteString-memory-arguments-intercept": 0, - "appendByteString-memory-arguments-slope": 1, - "appendString-cpu-arguments-intercept": 1000, - "appendString-cpu-arguments-slope": 24177, - "appendString-memory-arguments-intercept": 4, - "appendString-memory-arguments-slope": 1, - "bData-cpu-arguments": 1000, - "bData-memory-arguments": 32, - "blake2b-cpu-arguments-intercept": 117366, - "blake2b-cpu-arguments-slope": 10475, - "blake2b-memory-arguments": 4, - "cekApplyCost-exBudgetCPU": 23000, - "cekApplyCost-exBudgetMemory": 100, - "cekBuiltinCost-exBudgetCPU": 23000, - "cekBuiltinCost-exBudgetMemory": 100, - "cekConstCost-exBudgetCPU": 23000, - "cekConstCost-exBudgetMemory": 100, - "cekDelayCost-exBudgetCPU": 23000, - "cekDelayCost-exBudgetMemory": 100, - "cekForceCost-exBudgetCPU": 23000, - "cekForceCost-exBudgetMemory": 100, - "cekLamCost-exBudgetCPU": 23000, - "cekLamCost-exBudgetMemory": 100, - "cekStartupCost-exBudgetCPU": 100, - "cekStartupCost-exBudgetMemory": 100, - "cekVarCost-exBudgetCPU": 23000, - "cekVarCost-exBudgetMemory": 100, - "chooseData-cpu-arguments": 19537, - "chooseData-memory-arguments": 32, - "chooseList-cpu-arguments": 175354, - "chooseList-memory-arguments": 32, - "chooseUnit-cpu-arguments": 46417, - "chooseUnit-memory-arguments": 4, - "consByteString-cpu-arguments-intercept": 221973, - "consByteString-cpu-arguments-slope": 511, - "consByteString-memory-arguments-intercept": 0, - "consByteString-memory-arguments-slope": 1, - "constrData-cpu-arguments": 89141, - "constrData-memory-arguments": 32, - "decodeUtf8-cpu-arguments-intercept": 497525, - "decodeUtf8-cpu-arguments-slope": 14068, - "decodeUtf8-memory-arguments-intercept": 4, - "decodeUtf8-memory-arguments-slope": 2, - "divideInteger-cpu-arguments-constant": 196500, - "divideInteger-cpu-arguments-model-arguments-intercept": 453240, - "divideInteger-cpu-arguments-model-arguments-slope": 220, - "divideInteger-memory-arguments-intercept": 0, - "divideInteger-memory-arguments-minimum": 1, - "divideInteger-memory-arguments-slope": 1, - "encodeUtf8-cpu-arguments-intercept": 1000, - "encodeUtf8-cpu-arguments-slope": 28662, - "encodeUtf8-memory-arguments-intercept": 4, - "encodeUtf8-memory-arguments-slope": 2, - "equalsByteString-cpu-arguments-constant": 245000, - "equalsByteString-cpu-arguments-intercept": 216773, - "equalsByteString-cpu-arguments-slope": 62, - "equalsByteString-memory-arguments": 1, - "equalsData-cpu-arguments-intercept": 1060367, - "equalsData-cpu-arguments-slope": 12586, - "equalsData-memory-arguments": 1, - "equalsInteger-cpu-arguments-intercept": 208512, - "equalsInteger-cpu-arguments-slope": 421, - "equalsInteger-memory-arguments": 1, - "equalsString-cpu-arguments-constant": 187000, - "equalsString-cpu-arguments-intercept": 1000, - "equalsString-cpu-arguments-slope": 52998, - "equalsString-memory-arguments": 1, - "fstPair-cpu-arguments": 80436, - "fstPair-memory-arguments": 32, - "headList-cpu-arguments": 43249, - "headList-memory-arguments": 32, - "iData-cpu-arguments": 1000, - "iData-memory-arguments": 32, - "ifThenElse-cpu-arguments": 80556, - "ifThenElse-memory-arguments": 1, - "indexByteString-cpu-arguments": 57667, - "indexByteString-memory-arguments": 4, - "lengthOfByteString-cpu-arguments": 1000, - "lengthOfByteString-memory-arguments": 10, - "lessThanByteString-cpu-arguments-intercept": 197145, - "lessThanByteString-cpu-arguments-slope": 156, - "lessThanByteString-memory-arguments": 1, - "lessThanEqualsByteString-cpu-arguments-intercept": 197145, - "lessThanEqualsByteString-cpu-arguments-slope": 156, - "lessThanEqualsByteString-memory-arguments": 1, - "lessThanEqualsInteger-cpu-arguments-intercept": 204924, - "lessThanEqualsInteger-cpu-arguments-slope": 473, - "lessThanEqualsInteger-memory-arguments": 1, - "lessThanInteger-cpu-arguments-intercept": 208896, - "lessThanInteger-cpu-arguments-slope": 511, - "lessThanInteger-memory-arguments": 1, - "listData-cpu-arguments": 52467, - "listData-memory-arguments": 32, - "mapData-cpu-arguments": 64832, - "mapData-memory-arguments": 32, - "mkCons-cpu-arguments": 65493, - "mkCons-memory-arguments": 32, - "mkNilData-cpu-arguments": 22558, - "mkNilData-memory-arguments": 32, - "mkNilPairData-cpu-arguments": 16563, - "mkNilPairData-memory-arguments": 32, - "mkPairData-cpu-arguments": 76511, - "mkPairData-memory-arguments": 32, - "modInteger-cpu-arguments-constant": 196500, - "modInteger-cpu-arguments-model-arguments-intercept": 453240, - "modInteger-cpu-arguments-model-arguments-slope": 220, - "modInteger-memory-arguments-intercept": 0, - "modInteger-memory-arguments-minimum": 1, - "modInteger-memory-arguments-slope": 1, - "multiplyInteger-cpu-arguments-intercept": 69522, - "multiplyInteger-cpu-arguments-slope": 11687, - "multiplyInteger-memory-arguments-intercept": 0, - "multiplyInteger-memory-arguments-slope": 1, - "nullList-cpu-arguments": 60091, - "nullList-memory-arguments": 32, - "quotientInteger-cpu-arguments-constant": 196500, - "quotientInteger-cpu-arguments-model-arguments-intercept": 453240, - "quotientInteger-cpu-arguments-model-arguments-slope": 220, - "quotientInteger-memory-arguments-intercept": 0, - "quotientInteger-memory-arguments-minimum": 1, - "quotientInteger-memory-arguments-slope": 1, - "remainderInteger-cpu-arguments-constant": 196500, - "remainderInteger-cpu-arguments-model-arguments-intercept": 453240, - "remainderInteger-cpu-arguments-model-arguments-slope": 220, - "remainderInteger-memory-arguments-intercept": 0, - "remainderInteger-memory-arguments-minimum": 1, - "remainderInteger-memory-arguments-slope": 1, - "sha2_256-cpu-arguments-intercept": 806990, - "sha2_256-cpu-arguments-slope": 30482, - "sha2_256-memory-arguments": 4, - "sha3_256-cpu-arguments-intercept": 1927926, - "sha3_256-cpu-arguments-slope": 82523, - "sha3_256-memory-arguments": 4, - "sliceByteString-cpu-arguments-intercept": 265318, - "sliceByteString-cpu-arguments-slope": 0, - "sliceByteString-memory-arguments-intercept": 4, - "sliceByteString-memory-arguments-slope": 0, - "sndPair-cpu-arguments": 85931, - "sndPair-memory-arguments": 32, - "subtractInteger-cpu-arguments-intercept": 205665, - "subtractInteger-cpu-arguments-slope": 812, - "subtractInteger-memory-arguments-intercept": 1, - "subtractInteger-memory-arguments-slope": 1, - "tailList-cpu-arguments": 41182, - "tailList-memory-arguments": 32, - "trace-cpu-arguments": 212342, - "trace-memory-arguments": 32, - "unBData-cpu-arguments": 31220, - "unBData-memory-arguments": 32, - "unConstrData-cpu-arguments": 32696, - "unConstrData-memory-arguments": 32, - "unIData-cpu-arguments": 43357, - "unIData-memory-arguments": 32, - "unListData-cpu-arguments": 32247, - "unListData-memory-arguments": 32, - "unMapData-cpu-arguments": 38314, - "unMapData-memory-arguments": 32, - "verifySignature-cpu-arguments-intercept": 3345831, - "verifySignature-cpu-arguments-slope": 1, - "verifySignature-memory-arguments": 1 + "coinsPerUTxOByte": 4310, + "collateralPercentage": 150, + "costModels": { + "PlutusV1": { + "addInteger-cpu-arguments-intercept": 205665, + "addInteger-cpu-arguments-slope": 812, + "addInteger-memory-arguments-intercept": 1, + "addInteger-memory-arguments-slope": 1, + "appendByteString-cpu-arguments-intercept": 1000, + "appendByteString-cpu-arguments-slope": 571, + "appendByteString-memory-arguments-intercept": 0, + "appendByteString-memory-arguments-slope": 1, + "appendString-cpu-arguments-intercept": 1000, + "appendString-cpu-arguments-slope": 24177, + "appendString-memory-arguments-intercept": 4, + "appendString-memory-arguments-slope": 1, + "bData-cpu-arguments": 1000, + "bData-memory-arguments": 32, + "blake2b-cpu-arguments-intercept": 117366, + "blake2b-cpu-arguments-slope": 10475, + "blake2b-memory-arguments": 4, + "cekApplyCost-exBudgetCPU": 23000, + "cekApplyCost-exBudgetMemory": 100, + "cekBuiltinCost-exBudgetCPU": 23000, + "cekBuiltinCost-exBudgetMemory": 100, + "cekConstCost-exBudgetCPU": 23000, + "cekConstCost-exBudgetMemory": 100, + "cekDelayCost-exBudgetCPU": 23000, + "cekDelayCost-exBudgetMemory": 100, + "cekForceCost-exBudgetCPU": 23000, + "cekForceCost-exBudgetMemory": 100, + "cekLamCost-exBudgetCPU": 23000, + "cekLamCost-exBudgetMemory": 100, + "cekStartupCost-exBudgetCPU": 100, + "cekStartupCost-exBudgetMemory": 100, + "cekVarCost-exBudgetCPU": 23000, + "cekVarCost-exBudgetMemory": 100, + "chooseData-cpu-arguments": 19537, + "chooseData-memory-arguments": 32, + "chooseList-cpu-arguments": 175354, + "chooseList-memory-arguments": 32, + "chooseUnit-cpu-arguments": 46417, + "chooseUnit-memory-arguments": 4, + "consByteString-cpu-arguments-intercept": 221973, + "consByteString-cpu-arguments-slope": 511, + "consByteString-memory-arguments-intercept": 0, + "consByteString-memory-arguments-slope": 1, + "constrData-cpu-arguments": 89141, + "constrData-memory-arguments": 32, + "decodeUtf8-cpu-arguments-intercept": 497525, + "decodeUtf8-cpu-arguments-slope": 14068, + "decodeUtf8-memory-arguments-intercept": 4, + "decodeUtf8-memory-arguments-slope": 2, + "divideInteger-cpu-arguments-constant": 196500, + "divideInteger-cpu-arguments-model-arguments-intercept": 453240, + "divideInteger-cpu-arguments-model-arguments-slope": 220, + "divideInteger-memory-arguments-intercept": 0, + "divideInteger-memory-arguments-minimum": 1, + "divideInteger-memory-arguments-slope": 1, + "encodeUtf8-cpu-arguments-intercept": 1000, + "encodeUtf8-cpu-arguments-slope": 28662, + "encodeUtf8-memory-arguments-intercept": 4, + "encodeUtf8-memory-arguments-slope": 2, + "equalsByteString-cpu-arguments-constant": 245000, + "equalsByteString-cpu-arguments-intercept": 216773, + "equalsByteString-cpu-arguments-slope": 62, + "equalsByteString-memory-arguments": 1, + "equalsData-cpu-arguments-intercept": 1060367, + "equalsData-cpu-arguments-slope": 12586, + "equalsData-memory-arguments": 1, + "equalsInteger-cpu-arguments-intercept": 208512, + "equalsInteger-cpu-arguments-slope": 421, + "equalsInteger-memory-arguments": 1, + "equalsString-cpu-arguments-constant": 187000, + "equalsString-cpu-arguments-intercept": 1000, + "equalsString-cpu-arguments-slope": 52998, + "equalsString-memory-arguments": 1, + "fstPair-cpu-arguments": 80436, + "fstPair-memory-arguments": 32, + "headList-cpu-arguments": 43249, + "headList-memory-arguments": 32, + "iData-cpu-arguments": 1000, + "iData-memory-arguments": 32, + "ifThenElse-cpu-arguments": 80556, + "ifThenElse-memory-arguments": 1, + "indexByteString-cpu-arguments": 57667, + "indexByteString-memory-arguments": 4, + "lengthOfByteString-cpu-arguments": 1000, + "lengthOfByteString-memory-arguments": 10, + "lessThanByteString-cpu-arguments-intercept": 197145, + "lessThanByteString-cpu-arguments-slope": 156, + "lessThanByteString-memory-arguments": 1, + "lessThanEqualsByteString-cpu-arguments-intercept": 197145, + "lessThanEqualsByteString-cpu-arguments-slope": 156, + "lessThanEqualsByteString-memory-arguments": 1, + "lessThanEqualsInteger-cpu-arguments-intercept": 204924, + "lessThanEqualsInteger-cpu-arguments-slope": 473, + "lessThanEqualsInteger-memory-arguments": 1, + "lessThanInteger-cpu-arguments-intercept": 208896, + "lessThanInteger-cpu-arguments-slope": 511, + "lessThanInteger-memory-arguments": 1, + "listData-cpu-arguments": 52467, + "listData-memory-arguments": 32, + "mapData-cpu-arguments": 64832, + "mapData-memory-arguments": 32, + "mkCons-cpu-arguments": 65493, + "mkCons-memory-arguments": 32, + "mkNilData-cpu-arguments": 22558, + "mkNilData-memory-arguments": 32, + "mkNilPairData-cpu-arguments": 16563, + "mkNilPairData-memory-arguments": 32, + "mkPairData-cpu-arguments": 76511, + "mkPairData-memory-arguments": 32, + "modInteger-cpu-arguments-constant": 196500, + "modInteger-cpu-arguments-model-arguments-intercept": 453240, + "modInteger-cpu-arguments-model-arguments-slope": 220, + "modInteger-memory-arguments-intercept": 0, + "modInteger-memory-arguments-minimum": 1, + "modInteger-memory-arguments-slope": 1, + "multiplyInteger-cpu-arguments-intercept": 69522, + "multiplyInteger-cpu-arguments-slope": 11687, + "multiplyInteger-memory-arguments-intercept": 0, + "multiplyInteger-memory-arguments-slope": 1, + "nullList-cpu-arguments": 60091, + "nullList-memory-arguments": 32, + "quotientInteger-cpu-arguments-constant": 196500, + "quotientInteger-cpu-arguments-model-arguments-intercept": 453240, + "quotientInteger-cpu-arguments-model-arguments-slope": 220, + "quotientInteger-memory-arguments-intercept": 0, + "quotientInteger-memory-arguments-minimum": 1, + "quotientInteger-memory-arguments-slope": 1, + "remainderInteger-cpu-arguments-constant": 196500, + "remainderInteger-cpu-arguments-model-arguments-intercept": 453240, + "remainderInteger-cpu-arguments-model-arguments-slope": 220, + "remainderInteger-memory-arguments-intercept": 0, + "remainderInteger-memory-arguments-minimum": 1, + "remainderInteger-memory-arguments-slope": 1, + "sha2_256-cpu-arguments-intercept": 806990, + "sha2_256-cpu-arguments-slope": 30482, + "sha2_256-memory-arguments": 4, + "sha3_256-cpu-arguments-intercept": 1927926, + "sha3_256-cpu-arguments-slope": 82523, + "sha3_256-memory-arguments": 4, + "sliceByteString-cpu-arguments-intercept": 265318, + "sliceByteString-cpu-arguments-slope": 0, + "sliceByteString-memory-arguments-intercept": 4, + "sliceByteString-memory-arguments-slope": 0, + "sndPair-cpu-arguments": 85931, + "sndPair-memory-arguments": 32, + "subtractInteger-cpu-arguments-intercept": 205665, + "subtractInteger-cpu-arguments-slope": 812, + "subtractInteger-memory-arguments-intercept": 1, + "subtractInteger-memory-arguments-slope": 1, + "tailList-cpu-arguments": 41182, + "tailList-memory-arguments": 32, + "trace-cpu-arguments": 212342, + "trace-memory-arguments": 32, + "unBData-cpu-arguments": 31220, + "unBData-memory-arguments": 32, + "unConstrData-cpu-arguments": 32696, + "unConstrData-memory-arguments": 32, + "unIData-cpu-arguments": 43357, + "unIData-memory-arguments": 32, + "unListData-cpu-arguments": 32247, + "unListData-memory-arguments": 32, + "unMapData-cpu-arguments": 38314, + "unMapData-memory-arguments": 32, + "verifySignature-cpu-arguments-intercept": 3345831, + "verifySignature-cpu-arguments-slope": 1, + "verifySignature-memory-arguments": 1 + } }, - "PlutusV2": { - "addInteger-cpu-arguments-intercept": 205665, - "addInteger-cpu-arguments-slope": 812, - "addInteger-memory-arguments-intercept": 1, - "addInteger-memory-arguments-slope": 1, - "appendByteString-cpu-arguments-intercept": 1000, - "appendByteString-cpu-arguments-slope": 571, - "appendByteString-memory-arguments-intercept": 0, - "appendByteString-memory-arguments-slope": 1, - "appendString-cpu-arguments-intercept": 1000, - "appendString-cpu-arguments-slope": 24177, - "appendString-memory-arguments-intercept": 4, - "appendString-memory-arguments-slope": 1, - "bData-cpu-arguments": 1000, - "bData-memory-arguments": 32, - "blake2b_256-cpu-arguments-intercept": 117366, - "blake2b_256-cpu-arguments-slope": 10475, - "blake2b_256-memory-arguments": 4, - "cekApplyCost-exBudgetCPU": 23000, - "cekApplyCost-exBudgetMemory": 100, - "cekBuiltinCost-exBudgetCPU": 23000, - "cekBuiltinCost-exBudgetMemory": 100, - "cekConstCost-exBudgetCPU": 23000, - "cekConstCost-exBudgetMemory": 100, - "cekDelayCost-exBudgetCPU": 23000, - "cekDelayCost-exBudgetMemory": 100, - "cekForceCost-exBudgetCPU": 23000, - "cekForceCost-exBudgetMemory": 100, - "cekLamCost-exBudgetCPU": 23000, - "cekLamCost-exBudgetMemory": 100, - "cekStartupCost-exBudgetCPU": 100, - "cekStartupCost-exBudgetMemory": 100, - "cekVarCost-exBudgetCPU": 23000, - "cekVarCost-exBudgetMemory": 100, - "chooseData-cpu-arguments": 19537, - "chooseData-memory-arguments": 32, - "chooseList-cpu-arguments": 175354, - "chooseList-memory-arguments": 32, - "chooseUnit-cpu-arguments": 46417, - "chooseUnit-memory-arguments": 4, - "consByteString-cpu-arguments-intercept": 221973, - "consByteString-cpu-arguments-slope": 511, - "consByteString-memory-arguments-intercept": 0, - "consByteString-memory-arguments-slope": 1, - "constrData-cpu-arguments": 89141, - "constrData-memory-arguments": 32, - "decodeUtf8-cpu-arguments-intercept": 497525, - "decodeUtf8-cpu-arguments-slope": 14068, - "decodeUtf8-memory-arguments-intercept": 4, - "decodeUtf8-memory-arguments-slope": 2, - "divideInteger-cpu-arguments-constant": 196500, - "divideInteger-cpu-arguments-model-arguments-intercept": 453240, - "divideInteger-cpu-arguments-model-arguments-slope": 220, - "divideInteger-memory-arguments-intercept": 0, - "divideInteger-memory-arguments-minimum": 1, - "divideInteger-memory-arguments-slope": 1, - "encodeUtf8-cpu-arguments-intercept": 1000, - "encodeUtf8-cpu-arguments-slope": 28662, - "encodeUtf8-memory-arguments-intercept": 4, - "encodeUtf8-memory-arguments-slope": 2, - "equalsByteString-cpu-arguments-constant": 245000, - "equalsByteString-cpu-arguments-intercept": 216773, - "equalsByteString-cpu-arguments-slope": 62, - "equalsByteString-memory-arguments": 1, - "equalsData-cpu-arguments-intercept": 1060367, - "equalsData-cpu-arguments-slope": 12586, - "equalsData-memory-arguments": 1, - "equalsInteger-cpu-arguments-intercept": 208512, - "equalsInteger-cpu-arguments-slope": 421, - "equalsInteger-memory-arguments": 1, - "equalsString-cpu-arguments-constant": 187000, - "equalsString-cpu-arguments-intercept": 1000, - "equalsString-cpu-arguments-slope": 52998, - "equalsString-memory-arguments": 1, - "fstPair-cpu-arguments": 80436, - "fstPair-memory-arguments": 32, - "headList-cpu-arguments": 43249, - "headList-memory-arguments": 32, - "iData-cpu-arguments": 1000, - "iData-memory-arguments": 32, - "ifThenElse-cpu-arguments": 80556, - "ifThenElse-memory-arguments": 1, - "indexByteString-cpu-arguments": 57667, - "indexByteString-memory-arguments": 4, - "lengthOfByteString-cpu-arguments": 1000, - "lengthOfByteString-memory-arguments": 10, - "lessThanByteString-cpu-arguments-intercept": 197145, - "lessThanByteString-cpu-arguments-slope": 156, - "lessThanByteString-memory-arguments": 1, - "lessThanEqualsByteString-cpu-arguments-intercept": 197145, - "lessThanEqualsByteString-cpu-arguments-slope": 156, - "lessThanEqualsByteString-memory-arguments": 1, - "lessThanEqualsInteger-cpu-arguments-intercept": 204924, - "lessThanEqualsInteger-cpu-arguments-slope": 473, - "lessThanEqualsInteger-memory-arguments": 1, - "lessThanInteger-cpu-arguments-intercept": 208896, - "lessThanInteger-cpu-arguments-slope": 511, - "lessThanInteger-memory-arguments": 1, - "listData-cpu-arguments": 52467, - "listData-memory-arguments": 32, - "mapData-cpu-arguments": 64832, - "mapData-memory-arguments": 32, - "mkCons-cpu-arguments": 65493, - "mkCons-memory-arguments": 32, - "mkNilData-cpu-arguments": 22558, - "mkNilData-memory-arguments": 32, - "mkNilPairData-cpu-arguments": 16563, - "mkNilPairData-memory-arguments": 32, - "mkPairData-cpu-arguments": 76511, - "mkPairData-memory-arguments": 32, - "modInteger-cpu-arguments-constant": 196500, - "modInteger-cpu-arguments-model-arguments-intercept": 453240, - "modInteger-cpu-arguments-model-arguments-slope": 220, - "modInteger-memory-arguments-intercept": 0, - "modInteger-memory-arguments-minimum": 1, - "modInteger-memory-arguments-slope": 1, - "multiplyInteger-cpu-arguments-intercept": 69522, - "multiplyInteger-cpu-arguments-slope": 11687, - "multiplyInteger-memory-arguments-intercept": 0, - "multiplyInteger-memory-arguments-slope": 1, - "nullList-cpu-arguments": 60091, - "nullList-memory-arguments": 32, - "quotientInteger-cpu-arguments-constant": 196500, - "quotientInteger-cpu-arguments-model-arguments-intercept": 453240, - "quotientInteger-cpu-arguments-model-arguments-slope": 220, - "quotientInteger-memory-arguments-intercept": 0, - "quotientInteger-memory-arguments-minimum": 1, - "quotientInteger-memory-arguments-slope": 1, - "remainderInteger-cpu-arguments-constant": 196500, - "remainderInteger-cpu-arguments-model-arguments-intercept": 453240, - "remainderInteger-cpu-arguments-model-arguments-slope": 220, - "remainderInteger-memory-arguments-intercept": 0, - "remainderInteger-memory-arguments-minimum": 1, - "remainderInteger-memory-arguments-slope": 1, - "serialiseData-cpu-arguments-intercept": 1159724, - "serialiseData-cpu-arguments-slope": 392670, - "serialiseData-memory-arguments-intercept": 0, - "serialiseData-memory-arguments-slope": 2, - "sha2_256-cpu-arguments-intercept": 806990, - "sha2_256-cpu-arguments-slope": 30482, - "sha2_256-memory-arguments": 4, - "sha3_256-cpu-arguments-intercept": 1927926, - "sha3_256-cpu-arguments-slope": 82523, - "sha3_256-memory-arguments": 4, - "sliceByteString-cpu-arguments-intercept": 265318, - "sliceByteString-cpu-arguments-slope": 0, - "sliceByteString-memory-arguments-intercept": 4, - "sliceByteString-memory-arguments-slope": 0, - "sndPair-cpu-arguments": 85931, - "sndPair-memory-arguments": 32, - "subtractInteger-cpu-arguments-intercept": 205665, - "subtractInteger-cpu-arguments-slope": 812, - "subtractInteger-memory-arguments-intercept": 1, - "subtractInteger-memory-arguments-slope": 1, - "tailList-cpu-arguments": 41182, - "tailList-memory-arguments": 32, - "trace-cpu-arguments": 212342, - "trace-memory-arguments": 32, - "unBData-cpu-arguments": 31220, - "unBData-memory-arguments": 32, - "unConstrData-cpu-arguments": 32696, - "unConstrData-memory-arguments": 32, - "unIData-cpu-arguments": 43357, - "unIData-memory-arguments": 32, - "unListData-cpu-arguments": 32247, - "unListData-memory-arguments": 32, - "unMapData-cpu-arguments": 38314, - "unMapData-memory-arguments": 32, - "verifyEcdsaSecp256k1Signature-cpu-arguments": 35892428, - "verifyEcdsaSecp256k1Signature-memory-arguments": 10, - "verifyEd25519Signature-cpu-arguments-intercept": 57996947, - "verifyEd25519Signature-cpu-arguments-slope": 18975, - "verifyEd25519Signature-memory-arguments": 10, - "verifySchnorrSecp256k1Signature-cpu-arguments-intercept": 38887044, - "verifySchnorrSecp256k1Signature-cpu-arguments-slope": 32947, - "verifySchnorrSecp256k1Signature-memory-arguments": 10 - } - }, - "executionPrices": { - "prMem": { - "denominator": 10000, - "numerator": 577 + "executionPrices": { + "prMem": { + "denominator": 10000, + "numerator": 577 + }, + "prSteps": { + "denominator": 10000000, + "numerator": 721 + } + }, + "lovelacePerUTxOWord": 4310, + "maxBlockExUnits": { + "exUnitsMem": 62000000, + "exUnitsSteps": 40000000000 + }, + "maxCollateralInputs": 3, + "maxTxExUnits": { + "exUnitsMem": 14000000, + "exUnitsSteps": 10000000000 }, - "prSteps": { - "denominator": 10000000, - "numerator": 721 + "maxValueSize": 5000, + "extraConfig": { + "costModels": { + "PlutusV2": { + "addInteger-cpu-arguments-intercept": 205665, + "addInteger-cpu-arguments-slope": 812, + "addInteger-memory-arguments-intercept": 1, + "addInteger-memory-arguments-slope": 1, + "appendByteString-cpu-arguments-intercept": 1000, + "appendByteString-cpu-arguments-slope": 571, + "appendByteString-memory-arguments-intercept": 0, + "appendByteString-memory-arguments-slope": 1, + "appendString-cpu-arguments-intercept": 1000, + "appendString-cpu-arguments-slope": 24177, + "appendString-memory-arguments-intercept": 4, + "appendString-memory-arguments-slope": 1, + "bData-cpu-arguments": 1000, + "bData-memory-arguments": 32, + "blake2b_256-cpu-arguments-intercept": 117366, + "blake2b_256-cpu-arguments-slope": 10475, + "blake2b_256-memory-arguments": 4, + "cekApplyCost-exBudgetCPU": 23000, + "cekApplyCost-exBudgetMemory": 100, + "cekBuiltinCost-exBudgetCPU": 23000, + "cekBuiltinCost-exBudgetMemory": 100, + "cekConstCost-exBudgetCPU": 23000, + "cekConstCost-exBudgetMemory": 100, + "cekDelayCost-exBudgetCPU": 23000, + "cekDelayCost-exBudgetMemory": 100, + "cekForceCost-exBudgetCPU": 23000, + "cekForceCost-exBudgetMemory": 100, + "cekLamCost-exBudgetCPU": 23000, + "cekLamCost-exBudgetMemory": 100, + "cekStartupCost-exBudgetCPU": 100, + "cekStartupCost-exBudgetMemory": 100, + "cekVarCost-exBudgetCPU": 23000, + "cekVarCost-exBudgetMemory": 100, + "chooseData-cpu-arguments": 19537, + "chooseData-memory-arguments": 32, + "chooseList-cpu-arguments": 175354, + "chooseList-memory-arguments": 32, + "chooseUnit-cpu-arguments": 46417, + "chooseUnit-memory-arguments": 4, + "consByteString-cpu-arguments-intercept": 221973, + "consByteString-cpu-arguments-slope": 511, + "consByteString-memory-arguments-intercept": 0, + "consByteString-memory-arguments-slope": 1, + "constrData-cpu-arguments": 89141, + "constrData-memory-arguments": 32, + "decodeUtf8-cpu-arguments-intercept": 497525, + "decodeUtf8-cpu-arguments-slope": 14068, + "decodeUtf8-memory-arguments-intercept": 4, + "decodeUtf8-memory-arguments-slope": 2, + "divideInteger-cpu-arguments-constant": 196500, + "divideInteger-cpu-arguments-model-arguments-intercept": 453240, + "divideInteger-cpu-arguments-model-arguments-slope": 220, + "divideInteger-memory-arguments-intercept": 0, + "divideInteger-memory-arguments-minimum": 1, + "divideInteger-memory-arguments-slope": 1, + "encodeUtf8-cpu-arguments-intercept": 1000, + "encodeUtf8-cpu-arguments-slope": 28662, + "encodeUtf8-memory-arguments-intercept": 4, + "encodeUtf8-memory-arguments-slope": 2, + "equalsByteString-cpu-arguments-constant": 245000, + "equalsByteString-cpu-arguments-intercept": 216773, + "equalsByteString-cpu-arguments-slope": 62, + "equalsByteString-memory-arguments": 1, + "equalsData-cpu-arguments-intercept": 1060367, + "equalsData-cpu-arguments-slope": 12586, + "equalsData-memory-arguments": 1, + "equalsInteger-cpu-arguments-intercept": 208512, + "equalsInteger-cpu-arguments-slope": 421, + "equalsInteger-memory-arguments": 1, + "equalsString-cpu-arguments-constant": 187000, + "equalsString-cpu-arguments-intercept": 1000, + "equalsString-cpu-arguments-slope": 52998, + "equalsString-memory-arguments": 1, + "fstPair-cpu-arguments": 80436, + "fstPair-memory-arguments": 32, + "headList-cpu-arguments": 43249, + "headList-memory-arguments": 32, + "iData-cpu-arguments": 1000, + "iData-memory-arguments": 32, + "ifThenElse-cpu-arguments": 80556, + "ifThenElse-memory-arguments": 1, + "indexByteString-cpu-arguments": 57667, + "indexByteString-memory-arguments": 4, + "lengthOfByteString-cpu-arguments": 1000, + "lengthOfByteString-memory-arguments": 10, + "lessThanByteString-cpu-arguments-intercept": 197145, + "lessThanByteString-cpu-arguments-slope": 156, + "lessThanByteString-memory-arguments": 1, + "lessThanEqualsByteString-cpu-arguments-intercept": 197145, + "lessThanEqualsByteString-cpu-arguments-slope": 156, + "lessThanEqualsByteString-memory-arguments": 1, + "lessThanEqualsInteger-cpu-arguments-intercept": 204924, + "lessThanEqualsInteger-cpu-arguments-slope": 473, + "lessThanEqualsInteger-memory-arguments": 1, + "lessThanInteger-cpu-arguments-intercept": 208896, + "lessThanInteger-cpu-arguments-slope": 511, + "lessThanInteger-memory-arguments": 1, + "listData-cpu-arguments": 52467, + "listData-memory-arguments": 32, + "mapData-cpu-arguments": 64832, + "mapData-memory-arguments": 32, + "mkCons-cpu-arguments": 65493, + "mkCons-memory-arguments": 32, + "mkNilData-cpu-arguments": 22558, + "mkNilData-memory-arguments": 32, + "mkNilPairData-cpu-arguments": 16563, + "mkNilPairData-memory-arguments": 32, + "mkPairData-cpu-arguments": 76511, + "mkPairData-memory-arguments": 32, + "modInteger-cpu-arguments-constant": 196500, + "modInteger-cpu-arguments-model-arguments-intercept": 453240, + "modInteger-cpu-arguments-model-arguments-slope": 220, + "modInteger-memory-arguments-intercept": 0, + "modInteger-memory-arguments-minimum": 1, + "modInteger-memory-arguments-slope": 1, + "multiplyInteger-cpu-arguments-intercept": 69522, + "multiplyInteger-cpu-arguments-slope": 11687, + "multiplyInteger-memory-arguments-intercept": 0, + "multiplyInteger-memory-arguments-slope": 1, + "nullList-cpu-arguments": 60091, + "nullList-memory-arguments": 32, + "quotientInteger-cpu-arguments-constant": 196500, + "quotientInteger-cpu-arguments-model-arguments-intercept": 453240, + "quotientInteger-cpu-arguments-model-arguments-slope": 220, + "quotientInteger-memory-arguments-intercept": 0, + "quotientInteger-memory-arguments-minimum": 1, + "quotientInteger-memory-arguments-slope": 1, + "remainderInteger-cpu-arguments-constant": 196500, + "remainderInteger-cpu-arguments-model-arguments-intercept": 453240, + "remainderInteger-cpu-arguments-model-arguments-slope": 220, + "remainderInteger-memory-arguments-intercept": 0, + "remainderInteger-memory-arguments-minimum": 1, + "remainderInteger-memory-arguments-slope": 1, + "serialiseData-cpu-arguments-intercept": 1159724, + "serialiseData-cpu-arguments-slope": 392670, + "serialiseData-memory-arguments-intercept": 0, + "serialiseData-memory-arguments-slope": 2, + "sha2_256-cpu-arguments-intercept": 806990, + "sha2_256-cpu-arguments-slope": 30482, + "sha2_256-memory-arguments": 4, + "sha3_256-cpu-arguments-intercept": 1927926, + "sha3_256-cpu-arguments-slope": 82523, + "sha3_256-memory-arguments": 4, + "sliceByteString-cpu-arguments-intercept": 265318, + "sliceByteString-cpu-arguments-slope": 0, + "sliceByteString-memory-arguments-intercept": 4, + "sliceByteString-memory-arguments-slope": 0, + "sndPair-cpu-arguments": 85931, + "sndPair-memory-arguments": 32, + "subtractInteger-cpu-arguments-intercept": 205665, + "subtractInteger-cpu-arguments-slope": 812, + "subtractInteger-memory-arguments-intercept": 1, + "subtractInteger-memory-arguments-slope": 1, + "tailList-cpu-arguments": 41182, + "tailList-memory-arguments": 32, + "trace-cpu-arguments": 212342, + "trace-memory-arguments": 32, + "unBData-cpu-arguments": 31220, + "unBData-memory-arguments": 32, + "unConstrData-cpu-arguments": 32696, + "unConstrData-memory-arguments": 32, + "unIData-cpu-arguments": 43357, + "unIData-memory-arguments": 32, + "unListData-cpu-arguments": 32247, + "unListData-memory-arguments": 32, + "unMapData-cpu-arguments": 38314, + "unMapData-memory-arguments": 32, + "verifyEcdsaSecp256k1Signature-cpu-arguments": 35892428, + "verifyEcdsaSecp256k1Signature-memory-arguments": 10, + "verifyEd25519Signature-cpu-arguments-intercept": 57996947, + "verifyEd25519Signature-cpu-arguments-slope": 18975, + "verifyEd25519Signature-memory-arguments": 10, + "verifySchnorrSecp256k1Signature-cpu-arguments-intercept": 38887044, + "verifySchnorrSecp256k1Signature-cpu-arguments-slope": 32947, + "verifySchnorrSecp256k1Signature-memory-arguments": 10 + } + } } - }, - "lovelacePerUTxOWord": 4310, - "maxBlockExUnits": { - "exUnitsMem": 62000000, - "exUnitsSteps": 40000000000 - }, - "maxCollateralInputs": 3, - "maxTxExUnits": { - "exUnitsMem": 14000000, - "exUnitsSteps": 10000000000 - }, - "maxValueSize": 5000 -} +} \ No newline at end of file From d7d8d4824e532b6d5b917d053e18ed8667f075a1 Mon Sep 17 00:00:00 2001 From: Jordan Millar Date: Wed, 4 Feb 2026 15:57:46 -0400 Subject: [PATCH 24/32] Address undefineds and review comments --- .../src/Cardano/Api/Certificate/Internal.hs | 72 ------------------- .../Cardano/Api/Consensus/Internal/InMode.hs | 17 ++++- .../src/Cardano/Api/Era/Internal/Case.hs | 2 +- .../Api/Internal/Orphans/Serialisation.hs | 41 +++++++++-- .../src/Cardano/Api/Tx/Internal/Output.hs | 36 +--------- 5 files changed, 53 insertions(+), 115 deletions(-) diff --git a/cardano-api/src/Cardano/Api/Certificate/Internal.hs b/cardano-api/src/Cardano/Api/Certificate/Internal.hs index 4bae9b4c63..110415b1de 100644 --- a/cardano-api/src/Cardano/Api/Certificate/Internal.hs +++ b/cardano-api/src/Cardano/Api/Certificate/Internal.hs @@ -63,7 +63,6 @@ module Cardano.Api.Certificate.Internal , fromShelleyCertificate , toShelleyPoolParams , fromShelleyPoolParams - , fromShelleyStakePoolState -- * Data family instances , AsType (AsCertificate, AsTxId) @@ -93,7 +92,6 @@ import Cardano.Api.Serialise.TextEnvelope.Internal import Cardano.Ledger.BaseTypes (strictMaybe) import Cardano.Ledger.Coin qualified as L -import Cardano.Ledger.State qualified as Ledger import Control.Monad import Control.Monad.Except (MonadError (..)) @@ -792,76 +790,6 @@ fromShelleyPoolParams Text.encodeUtf8 . Ledger.dnsToText -fromShelleyStakePoolState - :: Ledger.KeyHash Ledger.StakePool - -> Ledger.StakePoolState - -> StakePoolParameters -fromShelleyStakePoolState - poolId - Ledger.StakePoolState - { Ledger.spsVrf - , Ledger.spsPledge - , Ledger.spsCost - , Ledger.spsMargin - , Ledger.spsAccountAddress - , Ledger.spsOwners - , Ledger.spsRelays - , Ledger.spsMetadata - } = - StakePoolParameters - { stakePoolId = StakePoolKeyHash poolId - , stakePoolVRF = VrfKeyHash (Ledger.fromVRFVerKeyHash spsVrf) - , stakePoolCost = spsCost - , stakePoolMargin = Ledger.unboundRational spsMargin - , stakePoolRewardAccount = StakeAddress undefined spsAccountAddress -- TODO the Network argument was removed in Ledger - , stakePoolPledge = spsPledge - , stakePoolOwners = map StakeKeyHash (toList spsOwners) - , stakePoolRelays = - map - fromShelleyStakePoolRelay - (toList spsRelays) - , stakePoolMetadata = - fromShelleyPoolMetadata - <$> Ledger.strictMaybeToMaybe spsMetadata - } - where - fromShelleyStakePoolRelay :: Ledger.StakePoolRelay -> StakePoolRelay - fromShelleyStakePoolRelay (Ledger.SingleHostAddr mport mipv4 mipv6) = - StakePoolRelayIp - (Ledger.strictMaybeToMaybe mipv4) - (Ledger.strictMaybeToMaybe mipv6) - (fromIntegral . Ledger.portToWord16 <$> Ledger.strictMaybeToMaybe mport) - fromShelleyStakePoolRelay (Ledger.SingleHostName mport dnsname) = - StakePoolRelayDnsARecord - (fromShelleyDnsName dnsname) - (fromIntegral . Ledger.portToWord16 <$> Ledger.strictMaybeToMaybe mport) - fromShelleyStakePoolRelay (Ledger.MultiHostName dnsname) = - StakePoolRelayDnsSrvRecord - (fromShelleyDnsName dnsname) - - fromShelleyPoolMetadata :: Ledger.PoolMetadata -> StakePoolMetadataReference - fromShelleyPoolMetadata - Ledger.PoolMetadata - { Ledger.pmUrl - , Ledger.pmHash - } = - StakePoolMetadataReference - { stakePoolMetadataURL = Ledger.urlToText pmUrl - , stakePoolMetadataHash = - StakePoolMetadataHash - . fromMaybe (error "fromShelleyPoolMetadata: invalid hash. TODO: proper validation") - . Ledger.hashFromBytes - . SBS.fromShort - . byteArrayToShortByteString - $ pmHash - } - - -- TODO: change the ledger rep of the DNS name to use ShortByteString - fromShelleyDnsName :: Ledger.DnsName -> ByteString - fromShelleyDnsName = - Text.encodeUtf8 - . Ledger.dnsToText - data AnchorDataFromCertificateError = InvalidPoolMetadataHashError Ledger.Url ByteArray deriving (Eq, Show) diff --git a/cardano-api/src/Cardano/Api/Consensus/Internal/InMode.hs b/cardano-api/src/Cardano/Api/Consensus/Internal/InMode.hs index 8fea91d371..f0246db60a 100644 --- a/cardano-api/src/Cardano/Api/Consensus/Internal/InMode.hs +++ b/cardano-api/src/Cardano/Api/Consensus/Internal/InMode.hs @@ -262,7 +262,22 @@ appTxErrToJson => ShelleyBasedEra era -> Consensus.ApplyTxErr (Consensus.ShelleyBlock (ConsensusProtocol era) (ShelleyLedgerEra era)) -> Aeson.Value -appTxErrToJson w e = shelleyBasedEraConstraints w $ toJSON e +appTxErrToJson w e = + case w of + ShelleyBasedEraShelley -> toJSON e + ShelleyBasedEraAllegra -> toJSON e + ShelleyBasedEraMary -> toJSON e + ShelleyBasedEraAlonzo -> toJSON e + ShelleyBasedEraBabbage -> toJSON e + ShelleyBasedEraConway -> toJSON e + -- TODO: Ledger needs to expose DijkstraLedgerPredFailure in order + -- to define the necessary JSON instances for Dijkstra era. + ShelleyBasedEraDijkstra -> + Aeson.String . Text.pack $ + unlines + [ "This is not JSON serializable yet. Ledger must expose DijkstraLedgerPredFailure to implement the necessary instances." + , show e + ] -- | A 'TxValidationError' in one of the eras supported by a given protocol -- mode. diff --git a/cardano-api/src/Cardano/Api/Era/Internal/Case.hs b/cardano-api/src/Cardano/Api/Era/Internal/Case.hs index 996bac75b1..cf9202cc75 100644 --- a/cardano-api/src/Cardano/Api/Era/Internal/Case.hs +++ b/cardano-api/src/Cardano/Api/Era/Internal/Case.hs @@ -121,7 +121,7 @@ caseShelleyToMaryOrAlonzoEraOnwards l r = \case ShelleyBasedEraAlonzo -> r AlonzoEraOnwardsAlonzo ShelleyBasedEraBabbage -> r AlonzoEraOnwardsBabbage ShelleyBasedEraConway -> r AlonzoEraOnwardsConway - ShelleyBasedEraDijkstra -> error "caseShelleyToMaryOrAlonzoEraOnwards: DijkstraEra is not supported" + ShelleyBasedEraDijkstra -> r AlonzoEraOnwardsDijkstra -- | @caseShelleyToAlonzoOrBabbageEraOnwards f g era@ applies @f@ to shelley, allegra, mary, and alonzo; -- and applies @g@ to babbage and later eras. diff --git a/cardano-api/src/Cardano/Api/Internal/Orphans/Serialisation.hs b/cardano-api/src/Cardano/Api/Internal/Orphans/Serialisation.hs index 9fdd38b706..99f6ffba03 100644 --- a/cardano-api/src/Cardano/Api/Internal/Orphans/Serialisation.hs +++ b/cardano-api/src/Cardano/Api/Internal/Orphans/Serialisation.hs @@ -45,6 +45,7 @@ import Cardano.Chain.Update.Validation.Registration qualified as L.Registration import Cardano.Chain.Update.Validation.Voting qualified as L.Voting import Cardano.Crypto.Hash qualified as Crypto import Cardano.Ledger.Allegra.Rules qualified as L +import Cardano.Ledger.Alonzo qualified as L import Cardano.Ledger.Alonzo.PParams qualified as Ledger import Cardano.Ledger.Alonzo.Rules qualified as Alonzo import Cardano.Ledger.Alonzo.Rules qualified as L @@ -63,6 +64,8 @@ import Cardano.Ledger.Conway.PParams qualified as Ledger import Cardano.Ledger.Conway.Rules qualified as L import Cardano.Ledger.Conway.TxCert qualified as L import Cardano.Ledger.Core qualified as L hiding (KeyHash) +import Cardano.Ledger.Dijkstra qualified as L +import Cardano.Ledger.Dijkstra.Rules qualified as L import Cardano.Ledger.HKD (NoUpdate (..)) import Cardano.Ledger.Hashes qualified as L hiding (KeyHash) import Cardano.Ledger.Keys qualified as L.Keys @@ -108,6 +111,7 @@ import Data.Aeson ) import Data.Aeson qualified as A import Data.Aeson qualified as Aeson +import Data.Aeson.Types (toJSONKeyText) import Data.Bifunctor import Data.ByteString qualified as BS import Data.ByteString.Base16 qualified as B16 @@ -119,7 +123,7 @@ import Data.Data (Data) import Data.Kind (Constraint, Type) import Data.ListMap (ListMap) import Data.ListMap qualified as ListMap -import Data.Map.NonEmpty (NonEmptyMap) +import Data.Map.NonEmpty (NonEmptyMap, toMap) import Data.Map.NonEmpty qualified as NonEmptyMap import Data.Maybe.Strict (StrictMaybe (..)) import Data.Monoid @@ -204,11 +208,11 @@ deriving anyclass instance ToJSON L.VotingPeriod deriving anyclass instance ToJSON L.Withdrawals -instance ToJSON (NonEmptyMap k v) where - toJSON = undefined +instance (ToJSONKey k, ToJSON v) => ToJSON (NonEmptyMap k v) where + toJSON = toJSON . toMap -instance ToJSON (NonEmptySet v) where - toJSON = undefined +instance ToJSON v => ToJSON (NonEmptySet v) where + toJSON = toJSON . NonEmptySet.toSet deriving anyclass instance ( ToJSON (L.PredicateFailure (L.EraRule "UTXOW" ledgerera)) @@ -247,8 +251,31 @@ instance where toJSON = genericToJSON defaultOptions -instance ToJSON (L.ApplyTxError ledgerera) where - toJSON = undefined +instance ToJSON (L.ApplyTxError L.ShelleyEra) where + toJSON = Aeson.genericToJSON Aeson.defaultOptions + +instance ToJSON (L.ApplyTxError L.AllegraEra) where + toJSON = Aeson.genericToJSON Aeson.defaultOptions + +instance ToJSON (L.ApplyTxError L.MaryEra) where + toJSON = Aeson.genericToJSON Aeson.defaultOptions + +instance ToJSON (L.ApplyTxError L.AlonzoEra) where + toJSON = Aeson.genericToJSON Aeson.defaultOptions + +instance ToJSON (L.ApplyTxError L.BabbageEra) where + toJSON = Aeson.genericToJSON Aeson.defaultOptions + +instance ToJSON (L.ApplyTxError L.ConwayEra) where + toJSON = Aeson.genericToJSON Aeson.defaultOptions + +-- TODO: Ledger must expose DijkstraLedgerPredFailure in order to write the +-- instances below. +-- instance ToJSON (L.ApplyTxError L.DijkstraEra) where +-- toJSON = Aeson.genericToJSON Aeson.defaultOptions + +-- instance ToJSON (L.DijkstraMempoolPredFailure L.DijkstraEra) where +-- toJSON = Aeson.genericToJSON Aeson.defaultOptions deriving via ShowOf (L.Keys.VKey L.Keys.Witness) diff --git a/cardano-api/src/Cardano/Api/Tx/Internal/Output.hs b/cardano-api/src/Cardano/Api/Tx/Internal/Output.hs index 5d2a7ec655..5bf8cf5e1c 100644 --- a/cardano-api/src/Cardano/Api/Tx/Internal/Output.hs +++ b/cardano-api/src/Cardano/Api/Tx/Internal/Output.hs @@ -793,8 +793,8 @@ toShelleyTxOut => ShelleyBasedEra era -> TxOut CtxUTxO era -> Ledger.TxOut ledgerera -toShelleyTxOut sbe = shelleyBasedEraConstraints sbe $ \case - TxOut addr (TxOutValueShelleyBased _ value) txoutdata refScript -> +toShelleyTxOut sbe' = shelleyBasedEraConstraints sbe' $ \case + TxOut addr (TxOutValueShelleyBased sbe value) txoutdata refScript -> caseShelleyToMaryOrAlonzoEraOnwards (const $ L.mkBasicTxOut (toShelleyAddr addr) value) ( \case @@ -814,13 +814,6 @@ toShelleyTxOut sbe = shelleyBasedEraConstraints sbe $ \case .~ toBabbageTxOutDatumUTxO txoutdata & L.referenceScriptTxOutL .~ refScriptToShelleyScript sbe refScript - -- TODO: this pattern shows up as redundant - -- AlonzoEraOnwardsDijkstra -> - -- L.mkBasicTxOut (toShelleyAddr addr) value - -- & L.datumTxOutL - -- .~ toBabbageTxOutDatumUTxO txoutdata - -- & L.referenceScriptTxOutL - -- .~ refScriptToShelleyScript sbe refScript ) sbe @@ -855,13 +848,6 @@ toShelleyTxOutAny sbe = shelleyBasedEraConstraints sbe $ \case .~ toBabbageTxOutDatum txoutdata & L.referenceScriptTxOutL .~ refScriptToShelleyScript sbe refScript - -- TODO: this pattern shows up as redundant - -- AlonzoEraOnwardsDijkstra -> - -- L.mkBasicTxOut (toShelleyAddr addr) value - -- & L.datumTxOutL - -- .~ toBabbageTxOutDatum txoutdata - -- & L.referenceScriptTxOutL - -- .~ refScriptToShelleyScript sbe refScript ) sbe @@ -924,24 +910,6 @@ fromShelleyTxOut sbe ledgerTxOut = shelleyBasedEraConstraints sbe $ do where datum = ledgerTxOut ^. L.datumTxOutL mRefScript = ledgerTxOut ^. L.referenceScriptTxOutL - -- TODO: this pattern shows up as redundant - -- ShelleyBasedEraDijkstra -> - -- TxOut - -- addressInEra - -- txOutValue - -- ( fromBabbageTxOutDatum - -- AlonzoEraOnwardsDijkstra - -- BabbageEraOnwardsDijkstra - -- datum - -- ) - -- ( case mRefScript of - -- SNothing -> ReferenceScriptNone - -- SJust refScript -> - -- fromShelleyScriptToReferenceScript ShelleyBasedEraDijkstra refScript - -- ) - -- where - -- datum = ledgerTxOut ^. L.datumTxOutL - -- mRefScript = ledgerTxOut ^. L.referenceScriptTxOutL -- ---------------------------------------------------------------------------- -- Transaction output values (era-dependent) From eee03a91018f1c58e57da1adfdbbf0fbe40a6166 Mon Sep 17 00:00:00 2001 From: Pablo Lamela Date: Tue, 3 Feb 2026 22:16:00 +0100 Subject: [PATCH 25/32] Fix CI errors --- cabal.project | 13 ++--------- cardano-api/src/Cardano/Api/Address.hs | 2 +- .../Cardano/Api/Experimental/Simple/Script.hs | 2 +- .../Tx/Internal/BodyContent/New.hs | 4 ++-- cardano-rpc/cardano-rpc.cabal | 1 + .../Rpc/Server/Internal/UtxoRpc/Type.hs | 23 +++++++++++++------ .../Test/Cardano/Rpc/ProtocolParameters.hs | 6 ++--- 7 files changed, 26 insertions(+), 25 deletions(-) diff --git a/cabal.project b/cabal.project index 7a179cbc7c..0471eb7235 100644 --- a/cabal.project +++ b/cabal.project @@ -79,15 +79,6 @@ if arch(wasm32) tag: a198a76c584dc2cfdcde6b431968de92a5fed65e --sha256: sha256-LRC3L+J921+/moZS7F17vCfM/4usYy/eMR+w/mXsjeA= - source-repository-package - type: git - location: https://github.com/palas/ouroboros-network.git - tag: 2fddbdb8ed23b63a43852bb98bd6ddc1a6d96d98 - subdir: - ouroboros-network - ouroboros-network-framework - --sha256: sha256-OAPsul8TaOpNwd2BlTE0jwqWiRk83rNVSxtIA5Se9Kg= - source-repository-package type: git location: https://github.com/palas/criterion.git @@ -127,8 +118,8 @@ if arch(wasm32) source-repository-package type: git location: https://github.com/palas/mempack.git - tag: 0211addbbbf51011e5348d3696566eb12ccbef07 - --sha256: sha256-iLc+foF2AM3vG6deuZ51+faI6buMkubMP75md51hMe8= + tag: 3514811b33741c4ac37d6f78b01f5d33088f6303 + --sha256: sha256-fATs5q/l+gs5qJnzqxW0pe/EqjdwxKYcBcGKrbU4L+Y= source-repository-package type: git diff --git a/cardano-api/src/Cardano/Api/Address.hs b/cardano-api/src/Cardano/Api/Address.hs index e4711751eb..ebe5913dc1 100644 --- a/cardano-api/src/Cardano/Api/Address.hs +++ b/cardano-api/src/Cardano/Api/Address.hs @@ -648,7 +648,7 @@ toShelleyStakeAddr :: StakeAddress -> Shelley.AccountAddress toShelleyStakeAddr (StakeAddress nw sc) = Shelley.AccountAddress { Shelley.aaNetworkId = nw - , Shelley.aaAccountId = (Shelley.AccountId sc) + , Shelley.aaAccountId = Shelley.AccountId sc } toShelleyPaymentCredential diff --git a/cardano-api/src/Cardano/Api/Experimental/Simple/Script.hs b/cardano-api/src/Cardano/Api/Experimental/Simple/Script.hs index 18167d42d2..d60cb0ce85 100644 --- a/cardano-api/src/Cardano/Api/Experimental/Simple/Script.hs +++ b/cardano-api/src/Cardano/Api/Experimental/Simple/Script.hs @@ -49,7 +49,7 @@ instance r <- CBOR.runAnnotator <$> CBOR.decodeFull' (L.eraProtVerHigh @era) bs - SimpleScript <$> (r $ CBOR.Full $ BS.fromStrict bs) + SimpleScript <$> r (CBOR.Full $ BS.fromStrict bs) -- TODO: We should also deserialize the JSON representation of simple scripts. deserialiseSimpleScript diff --git a/cardano-api/src/Cardano/Api/Experimental/Tx/Internal/BodyContent/New.hs b/cardano-api/src/Cardano/Api/Experimental/Tx/Internal/BodyContent/New.hs index de5adfd46a..417fdbeb7f 100644 --- a/cardano-api/src/Cardano/Api/Experimental/Tx/Internal/BodyContent/New.hs +++ b/cardano-api/src/Cardano/Api/Experimental/Tx/Internal/BodyContent/New.hs @@ -174,8 +174,8 @@ makeUnsignedTx era@ConwayEra bc = obtainCommonConstraints era $ do & L.totalCollateralTxBodyL .~ L.maybeToStrictMaybe totCollateral & L.collateralReturnTxBodyL .~ L.maybeToStrictMaybe retCollateral & L.feeTxBodyL .~ fee - & L.vldtTxBodyL . L.invalidBeforeL .~ (L.maybeToStrictMaybe $ txValidityLowerBound bc) - & L.vldtTxBodyL . L.invalidHereAfterL .~ (L.maybeToStrictMaybe $ txValidityUpperBound bc) + & L.vldtTxBodyL . L.invalidBeforeL .~ L.maybeToStrictMaybe (txValidityLowerBound bc) + & L.vldtTxBodyL . L.invalidHereAfterL .~ L.maybeToStrictMaybe (txValidityUpperBound bc) & L.reqSignerHashesTxBodyL .~ setReqSignerHashes & L.scriptIntegrityHashTxBodyL .~ scriptIntegrityHash & L.withdrawalsTxBodyL .~ withdrawals diff --git a/cardano-rpc/cardano-rpc.cabal b/cardano-rpc/cardano-rpc.cabal index 93780b22a9..925ffe333f 100644 --- a/cardano-rpc/cardano-rpc.cabal +++ b/cardano-rpc/cardano-rpc.cabal @@ -77,6 +77,7 @@ library containers, contra-tracer, data-default, + errors, filepath, generic-data, grapesy, diff --git a/cardano-rpc/src/Cardano/Rpc/Server/Internal/UtxoRpc/Type.hs b/cardano-rpc/src/Cardano/Rpc/Server/Internal/UtxoRpc/Type.hs index d55b1cabf1..30be7cbcb2 100644 --- a/cardano-rpc/src/Cardano/Rpc/Server/Internal/UtxoRpc/Type.hs +++ b/cardano-rpc/src/Cardano/Rpc/Server/Internal/UtxoRpc/Type.hs @@ -49,6 +49,7 @@ import Cardano.Ledger.Plutus qualified as L import RIO hiding (toList) +import Control.Error.Util (note) import Data.ByteString.Short qualified as SBS import Data.Default import Data.Map.Strict qualified as M @@ -71,10 +72,11 @@ protocolParamsToUtxoRpcPParams era pparams = obtainCommonConstraints era $ do drepVotingThresholds :: L.DRepVotingThresholds = pparams ^. L.ppDRepVotingThresholdsL def - & #coinsPerUtxoByte .~ pparams ^. L.ppCoinsPerUTxOByteL . to L.unCoinPerByte . to inject + & #coinsPerUtxoByte + .~ pparams ^. L.ppCoinsPerUTxOByteL . to L.unCoinPerByte . to L.fromCompact . to inject & #maxTxSize .~ pparams ^. L.ppMaxTxSizeL . to fromIntegral - & #minFeeCoefficient .~ pparams ^. L.ppMinFeeBL . to inject - & #minFeeConstant .~ pparams ^. L.ppMinFeeAL . to inject + & #minFeeCoefficient .~ pparams ^. L.ppTxFeeFixedL . to inject + & #minFeeConstant .~ pparams ^. L.ppTxFeePerByteL . to L.unCoinPerByte . to L.fromCompact . to inject & #maxBlockBodySize .~ pparams ^. L.ppMaxBBSizeL . to fromIntegral & #maxBlockHeaderSize .~ pparams ^. L.ppMaxBHSizeL . to fromIntegral & #stakeKeyDeposit .~ pparams ^. L.ppKeyDepositL . to inject @@ -144,14 +146,18 @@ utxoRpcPParamsToProtocolParams era pp = conwayEraOnwardsConstraints (convert era [ \r -> do coinsPerUtxoByte <- pp ^. #coinsPerUtxoByte . to utxoRpcBigIntToInteger ?! "Invalid coinsPerUtxoByte" - pure $ set L.ppCoinsPerUTxOByteL (L.CoinPerByte $ L.Coin coinsPerUtxoByte) r + compactCoinsPerUtxO <- + note "Could not convert coinsPerUtxoByte to compact form." $ L.toCompact (L.Coin coinsPerUtxoByte) + pure $ set L.ppCoinsPerUTxOByteL (L.CoinPerByte compactCoinsPerUtxO) r , pure . (L.ppMaxTxSizeL .~ pp ^. #maxTxSize . to fromIntegral) , \r -> do minFeeCoeff <- pp ^. #minFeeCoefficient . to utxoRpcBigIntToInteger ?! "Invalid minFeeCoefficient" - pure $ set L.ppMinFeeBL (L.Coin minFeeCoeff) r + pure $ set L.ppTxFeeFixedL (L.Coin minFeeCoeff) r , \r -> do minFeeConst <- pp ^. #minFeeConstant . to utxoRpcBigIntToInteger ?! "Invalid minFeeConstant" - pure $ set L.ppMinFeeAL (L.Coin minFeeConst) r + minFeeConstCompact <- + note "Could not convert minFeeConstant to compact form." $ L.toCompact (L.Coin minFeeConst) + pure $ set L.ppTxFeePerByteL (L.CoinPerByte minFeeConstCompact) r , pure . (L.ppMaxBBSizeL .~ pp ^. #maxBlockBodySize . to fromIntegral) , pure . (L.ppMaxBHSizeL .~ pp ^. #maxBlockHeaderSize . to fromIntegral) , \r -> do @@ -208,7 +214,10 @@ utxoRpcPParamsToProtocolParams era pp = conwayEraOnwardsConstraints (convert era , \r -> do minFeeScriptRefCostPerByte <- pp - ^. #minFeeScriptRefCostPerByte . to inject . to L.boundRational ?! "Invalid minFeeScriptRefCostPerByte" + ^. #minFeeScriptRefCostPerByte + . to inject + . to L.boundRational + ?! "Invalid minFeeScriptRefCostPerByte" pure $ set L.ppMinFeeRefScriptCostPerByteL minFeeScriptRefCostPerByte r , \r -> do let thresholds = pp ^. #poolVotingThresholds . #thresholds diff --git a/cardano-rpc/test/cardano-rpc-test/Test/Cardano/Rpc/ProtocolParameters.hs b/cardano-rpc/test/cardano-rpc-test/Test/Cardano/Rpc/ProtocolParameters.hs index cc645ee99b..283d470447 100644 --- a/cardano-rpc/test/cardano-rpc-test/Test/Cardano/Rpc/ProtocolParameters.hs +++ b/cardano-rpc/test/cardano-rpc-test/Test/Cardano/Rpc/ProtocolParameters.hs @@ -47,9 +47,9 @@ hprop_roundtrip_protocol_parameters = H.property $ do pp' = obtainCommonConstraints era $ pp - & L.ppCoinsPerUTxOByteL %~ L.CoinPerByte . clipI 64 . L.unCoinPerByte - & L.ppMinFeeBL %~ clipI 64 - & L.ppMinFeeAL %~ clipI 64 + & L.ppCoinsPerUTxOByteL %~ id -- This is already Word64 so no clipping needed (https://github.com/IntersectMBO/cardano-ledger/blob/master/libs/cardano-ledger-core/src/Cardano/Ledger/Coin.hs#L143) + & L.ppTxFeeFixedL %~ clipI 64 + & L.ppTxFeePerByteL %~ id -- This is already Word64 so no clipping needed (https://github.com/IntersectMBO/cardano-ledger/blob/master/libs/cardano-ledger-core/src/Cardano/Ledger/Coin.hs#L143) & L.ppA0L %~ clipIBr & L.ppRhoL %~ clipIBr & L.ppTauL %~ clipIBr From 9ed9c439115862b77d9cd27f40dfa5b5cd703b72 Mon Sep 17 00:00:00 2001 From: Pablo Lamela Date: Tue, 3 Feb 2026 23:54:33 +0100 Subject: [PATCH 26/32] Make pragma conditional for 9.10 --- cardano-api/src/Cardano/Api/LedgerState.hs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cardano-api/src/Cardano/Api/LedgerState.hs b/cardano-api/src/Cardano/Api/LedgerState.hs index 77bad9c11e..a96f55ce9f 100644 --- a/cardano-api/src/Cardano/Api/LedgerState.hs +++ b/cardano-api/src/Cardano/Api/LedgerState.hs @@ -1,4 +1,5 @@ {-# LANGUAGE BangPatterns #-} +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE DerivingStrategies #-} {-# LANGUAGE FlexibleContexts #-} @@ -10,7 +11,10 @@ {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeApplications #-} {-# LANGUAGE TypeOperators #-} + +#if __GLASGOW_HASKELL__ >= 910 {-# OPTIONS_GHC -Wno-x-ord-preserving-coercions #-} +#endif module Cardano.Api.LedgerState ( -- * Initialization / Accumulation From 5390491754155ff15e124581dba73943f6ecfa99 Mon Sep 17 00:00:00 2001 From: Pablo Lamela Date: Wed, 4 Feb 2026 00:54:31 +0100 Subject: [PATCH 27/32] Update WASM cache --- .github/workflows/haskell-wasm.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/haskell-wasm.yml b/.github/workflows/haskell-wasm.yml index 804a690cc0..86fc62d359 100644 --- a/.github/workflows/haskell-wasm.yml +++ b/.github/workflows/haskell-wasm.yml @@ -114,9 +114,9 @@ jobs: - name: Restore cached deps run: | - wget "https://agrius.feralhosting.com/palas/wasm-cache/96feb8056220c74aa6b5af41ca64ad982f207fc4f99a22e0393a4de12169bf04.tar.xz" - tar -xf 96feb8056220c74aa6b5af41ca64ad982f207fc4f99a22e0393a4de12169bf04.tar.xz - rm 96feb8056220c74aa6b5af41ca64ad982f207fc4f99a22e0393a4de12169bf04.tar.xz + wget "https://agrius.feralhosting.com/palas/wasm-cache/12419d337f57e7ea7b01c6499af0a70402bd2f2f055951c84693deb21b182a6f.tar.xz" + tar -xf 12419d337f57e7ea7b01c6499af0a70402bd2f2f055951c84693deb21b182a6f.tar.xz + rm 12419d337f57e7ea7b01c6499af0a70402bd2f2f055951c84693deb21b182a6f.tar.xz rm -fr ~/.ghc-wasm/.cabal/store/ mv store ~/.ghc-wasm/.cabal/ From 7e03660c6ec525624e311f68423f94807ef62e23 Mon Sep 17 00:00:00 2001 From: Pablo Lamela Date: Wed, 4 Feb 2026 00:59:33 +0100 Subject: [PATCH 28/32] Run formatter on everything --- .../Experimental/Plutus/Internal/Shim/LegacyScripts.hs | 2 +- .../src/Cardano/Api/Ledger/Internal/Reexport.hs | 6 +++--- cardano-api/src/Cardano/Api/Network/IPC/Internal.hs | 10 +++++----- .../src/Cardano/Api/Network/IPC/Internal/Version.hs | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/cardano-api/src/Cardano/Api/Experimental/Plutus/Internal/Shim/LegacyScripts.hs b/cardano-api/src/Cardano/Api/Experimental/Plutus/Internal/Shim/LegacyScripts.hs index c1cccbb33c..f81dfd1029 100644 --- a/cardano-api/src/Cardano/Api/Experimental/Plutus/Internal/Shim/LegacyScripts.hs +++ b/cardano-api/src/Cardano/Api/Experimental/Plutus/Internal/Shim/LegacyScripts.hs @@ -49,8 +49,8 @@ import Cardano.Ledger.Alonzo.Scripts qualified as L import Cardano.Ledger.BaseTypes (Version) import Cardano.Ledger.Core qualified as L import Cardano.Ledger.Dijkstra.Scripts qualified as Dijkstra -import Cardano.Ledger.Plutus.Language qualified as L import Cardano.Ledger.Mary.Value qualified as L +import Cardano.Ledger.Plutus.Language qualified as L import Data.Text qualified as Text import Data.Typeable diff --git a/cardano-api/src/Cardano/Api/Ledger/Internal/Reexport.hs b/cardano-api/src/Cardano/Api/Ledger/Internal/Reexport.hs index 751bfeb126..71fcd67173 100644 --- a/cardano-api/src/Cardano/Api/Ledger/Internal/Reexport.hs +++ b/cardano-api/src/Cardano/Api/Ledger/Internal/Reexport.hs @@ -215,7 +215,7 @@ module Cardano.Api.Ledger.Internal.Reexport where import Cardano.Crypto.Hash.Class (hashFromBytes, hashToBytes) -import Cardano.Ledger.Address (Addr (..), AccountAddress (..)) +import Cardano.Ledger.Address (AccountAddress (..), Addr (..)) import Cardano.Ledger.Allegra.Scripts (AllegraEraScript (..), Timelock (..), showTimelock) import Cardano.Ledger.Alonzo.Core ( AlonzoEraScript (..) @@ -409,13 +409,13 @@ import Cardano.Ledger.Shelley.TxCert ) import Cardano.Ledger.State ( PoolMetadata (..) - , StakePoolParams (..) , ScriptsNeeded + , StakePoolParams (..) , StakePoolRelay (..) , UTxO (..) - , getScriptsNeeded , casReservesL , casTreasuryL + , getScriptsNeeded ) import Cardano.Ledger.TxIn (TxId (..), TxIn (..)) import Cardano.Ledger.Val diff --git a/cardano-api/src/Cardano/Api/Network/IPC/Internal.hs b/cardano-api/src/Cardano/Api/Network/IPC/Internal.hs index 9c84bb0c9d..21ca0f6c33 100644 --- a/cardano-api/src/Cardano/Api/Network/IPC/Internal.hs +++ b/cardano-api/src/Cardano/Api/Network/IPC/Internal.hs @@ -77,6 +77,11 @@ import Cardano.Api.Query.Internal.Type.QueryInMode import Cardano.Api.Tx.Internal.Body import Cardano.Api.Tx.Internal.Sign +import Cardano.Network.NodeToClient + ( NodeToClientProtocols (..) + , NodeToClientVersionData (..) + ) +import Cardano.Network.NodeToClient qualified as Net import Cardano.Protocol.Crypto (StandardCrypto) import Ouroboros.Consensus.Block qualified as Consensus import Ouroboros.Consensus.Cardano.Block qualified as Consensus @@ -92,11 +97,6 @@ import Ouroboros.Consensus.Shelley.Ledger.Block qualified as Consensus import Ouroboros.Consensus.Shelley.Ledger.SupportsProtocol () import Ouroboros.Network.Block qualified as Net import Ouroboros.Network.Mux qualified as Net -import Cardano.Network.NodeToClient - ( NodeToClientProtocols (..) - , NodeToClientVersionData (..) - ) -import Cardano.Network.NodeToClient qualified as Net import Ouroboros.Network.Protocol.ChainSync.Client as Net.Sync import Ouroboros.Network.Protocol.ChainSync.ClientPipelined as Net.SyncP import Ouroboros.Network.Protocol.LocalStateQuery.Client (LocalStateQueryClient (..)) diff --git a/cardano-api/src/Cardano/Api/Network/IPC/Internal/Version.hs b/cardano-api/src/Cardano/Api/Network/IPC/Internal/Version.hs index c059a22697..c9778c228f 100644 --- a/cardano-api/src/Cardano/Api/Network/IPC/Internal/Version.hs +++ b/cardano-api/src/Cardano/Api/Network/IPC/Internal/Version.hs @@ -10,12 +10,12 @@ where import Cardano.Api.Error import Cardano.Api.Pretty +import Cardano.Network.NodeToClient.Version (NodeToClientVersion (..)) import Cardano.Protocol.Crypto import Ouroboros.Consensus.Cardano.Block qualified as Consensus import Ouroboros.Consensus.Cardano.Node () import Ouroboros.Consensus.Ledger.Query qualified as Consensus import Ouroboros.Consensus.Shelley.Ledger.SupportsProtocol () -import Cardano.Network.NodeToClient.Version (NodeToClientVersion (..)) import Ouroboros.Network.Protocol.LocalStateQuery.Codec -- | LocalStateQuery uses versioned queries, which means it requires the Node to support a minimum From 4510c458ea82be37d6190c63abc5eccc4c6ec535 Mon Sep 17 00:00:00 2001 From: Pablo Lamela Date: Thu, 5 Feb 2026 02:12:28 +0100 Subject: [PATCH 29/32] Remove unnecessary stanza --- cabal.project | 8 -------- 1 file changed, 8 deletions(-) diff --git a/cabal.project b/cabal.project index 0471eb7235..86d9fe6e2f 100644 --- a/cabal.project +++ b/cabal.project @@ -127,14 +127,6 @@ if arch(wasm32) tag: ab92e48e9fdf3abe214f85fdbe5301c1280e14e9 --sha256: sha256-U+ln/gbXoQZpNjZHydNa0FG/9GdJFgL1+T3+7KTzDWo= - source-repository-package - type: git - location: https://github.com/palas/fs-sim - tag: c39efe618cf63df909e8e0acab31684b10223550 - --sha256: sha256-zHJfVFEzdeq9WhInEIRCJ1OQTYM06k++9gzfUaG//S8= - subdir: - fs-sim - package cardano-crypto-praos flags: -external-libsodium-vrf From 24a0e7bfa49eeec3ebfadd034086c0885311253c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20W=C3=B3jtowicz?= Date: Wed, 4 Feb 2026 14:05:14 +0100 Subject: [PATCH 30/32] Integrate ledger peer snapshot query --- cardano-api/src/Cardano/Api/Network.hs | 2 +- .../Cardano/Api/Network/Internal/Reexport.hs | 4 +- cardano-api/src/Cardano/Api/Query.hs | 2 +- .../src/Cardano/Api/Query/Internal/Expr.hs | 3 +- .../Api/Query/Internal/Type/QueryInMode.hs | 45 +++++++++---------- 5 files changed, 28 insertions(+), 28 deletions(-) diff --git a/cardano-api/src/Cardano/Api/Network.hs b/cardano-api/src/Cardano/Api/Network.hs index 4c5ff3d6ba..7ad4ace187 100644 --- a/cardano-api/src/Cardano/Api/Network.hs +++ b/cardano-api/src/Cardano/Api/Network.hs @@ -7,7 +7,7 @@ module Cardano.Api.Network , mainnetNetworkMagic -- * @network@ reexports - , LedgerPeerSnapshot (..) + , SomeLedgerPeerSnapshot (..) , Target (..) , Serialised (..) , SubmitResult (..) diff --git a/cardano-api/src/Cardano/Api/Network/Internal/Reexport.hs b/cardano-api/src/Cardano/Api/Network/Internal/Reexport.hs index 28cc4705ea..c2b900f6af 100644 --- a/cardano-api/src/Cardano/Api/Network/Internal/Reexport.hs +++ b/cardano-api/src/Cardano/Api/Network/Internal/Reexport.hs @@ -1,5 +1,5 @@ module Cardano.Api.Network.Internal.Reexport - ( LedgerPeerSnapshot (..) + ( SomeLedgerPeerSnapshot (..) , Target (..) , Serialised (..) , SubmitResult (..) @@ -7,6 +7,6 @@ module Cardano.Api.Network.Internal.Reexport where import Ouroboros.Network.Block (Serialised (..)) -import Ouroboros.Network.PeerSelection.LedgerPeers.Type (LedgerPeerSnapshot (..)) +import Ouroboros.Network.PeerSelection.LedgerPeers.Type (SomeLedgerPeerSnapshot (..)) import Ouroboros.Network.Protocol.LocalStateQuery.Type (Target (..)) import Ouroboros.Network.Protocol.LocalTxSubmission.Type (SubmitResult (..)) diff --git a/cardano-api/src/Cardano/Api/Query.hs b/cardano-api/src/Cardano/Api/Query.hs index 97aa1355a5..9639e757ba 100644 --- a/cardano-api/src/Cardano/Api/Query.hs +++ b/cardano-api/src/Cardano/Api/Query.hs @@ -37,7 +37,7 @@ module Cardano.Api.Query , LedgerState (..) , getProgress , getSlotForRelativeTime - , decodeBigLedgerPeerSnapshot + , decodeLedgerPeerSnapshot -- * Convenience functions , QueryConvenienceError (..) diff --git a/cardano-api/src/Cardano/Api/Query/Internal/Expr.hs b/cardano-api/src/Cardano/Api/Query/Internal/Expr.hs index 232278378f..574261c0fa 100644 --- a/cardano-api/src/Cardano/Api/Query/Internal/Expr.hs +++ b/cardano-api/src/Cardano/Api/Query/Internal/Expr.hs @@ -153,6 +153,7 @@ queryDebugLedgerState eon = querySbe eon QueryDebugLedgerState queryLedgerPeerSnapshot :: () => ShelleyBasedEra era + -> LedgerPeersKind -> LocalStateQueryExpr block point @@ -160,7 +161,7 @@ queryLedgerPeerSnapshot r IO (Either UnsupportedNtcVersionError (Either EraMismatch (Serialised LedgerPeerSnapshot))) -queryLedgerPeerSnapshot eon = querySbe eon QueryLedgerPeerSnapshot +queryLedgerPeerSnapshot eon = querySbe eon . QueryLedgerPeerSnapshot queryEraHistory :: () diff --git a/cardano-api/src/Cardano/Api/Query/Internal/Type/QueryInMode.hs b/cardano-api/src/Cardano/Api/Query/Internal/Type/QueryInMode.hs index f46a042a3f..e4c8d61937 100644 --- a/cardano-api/src/Cardano/Api/Query/Internal/Type/QueryInMode.hs +++ b/cardano-api/src/Cardano/Api/Query/Internal/Type/QueryInMode.hs @@ -57,7 +57,7 @@ module Cardano.Api.Query.Internal.Type.QueryInMode , LedgerState (..) , getProgress , getSlotForRelativeTime - , decodeBigLedgerPeerSnapshot + , decodeLedgerPeerSnapshot -- * Internal conversion functions , toLedgerUTxO @@ -115,7 +115,7 @@ import Ouroboros.Consensus.Ledger.Query qualified as Consensus import Ouroboros.Consensus.Protocol.Abstract qualified as Consensus import Ouroboros.Consensus.Shelley.Ledger qualified as Consensus import Ouroboros.Network.Block (Serialised (..)) -import Ouroboros.Network.PeerSelection.LedgerPeers.Type +import Ouroboros.Network.PeerSelection.LedgerPeers.Type as Diffusion import Ouroboros.Network.Protocol.LocalStateQuery.Client (Some (..)) import Codec.Serialise qualified as CBOR @@ -127,6 +127,7 @@ import Data.Either.Combinators (rightToMaybe) import Data.Map.Strict (Map) import Data.Map.Strict qualified as Map import Data.Maybe (mapMaybe) +import Data.Proxy import Data.SOP.Constraint (SListI) import Data.Sequence (Seq) import Data.Set (Set) @@ -315,7 +316,8 @@ data QueryInShelleyBasedEra era result where :: Set L.GovActionId -> QueryInShelleyBasedEra era (Seq (L.GovActionState (ShelleyLedgerEra era))) QueryLedgerPeerSnapshot - :: QueryInShelleyBasedEra era (Serialised LedgerPeerSnapshot) + :: LedgerPeersKind + -> QueryInShelleyBasedEra era (Serialised SomeLedgerPeerSnapshot) QueryStakePoolDefaultVote :: Ledger.KeyHash Ledger.StakePool -> QueryInShelleyBasedEra era L.DefaultVote @@ -424,18 +426,17 @@ decodeStakeSnapshot -> Either DecoderError (StakeSnapshot era) decodeStakeSnapshot (SerialisedStakeSnapshots (Serialised ls)) = StakeSnapshot <$> Plain.decodeFull ls -decodeBigLedgerPeerSnapshot +decodeLedgerPeerSnapshot :: Consensus.ShelleyNodeToClientVersion - -> Serialised LedgerPeerSnapshot - -> Either (LBS.ByteString, DecoderError) (LedgerPeerSnapshot BigLedgerPeers) -decodeBigLedgerPeerSnapshot _ntcV (Serialised _lps) = - -- first - -- (lps,) - -- $ Plain.decodeFullDecoder - -- "LedgerPeerSnapshot" - -- (decodeLedgerPeerSnapshot $ Consensus.ledgerPeerSnapshotSupportsSRV ntcV) - -- lps - undefined -- TODO(10.7) + -> Serialised SomeLedgerPeerSnapshot + -> Either (LBS.ByteString, DecoderError) SomeLedgerPeerSnapshot +decodeLedgerPeerSnapshot _ntcV (Serialised lps) = + first + (lps,) + $ Plain.decodeFullDecoder + "LedgerPeerSnapshot" + (Diffusion.decodeLedgerPeerSnapshot (Proxy :: Proxy (Consensus.CardanoBlock StandardCrypto))) + lps toShelleyAddrSet :: CardanoEra era @@ -694,10 +695,9 @@ toConsensusQueryShelleyBased sbe = \case (consensusQueryInEraInMode era (Consensus.GetProposals govActs)) ) sbe - -- TODO(10.7): support full GetLedgerPeerSnapshot query - QueryLedgerPeerSnapshot -> + QueryLedgerPeerSnapshot peerKind -> Some - (consensusQueryInEraInMode era (Consensus.GetCBOR (Consensus.GetLedgerPeerSnapshot BigLedgerPeers))) + (consensusQueryInEraInMode era (Consensus.GetCBOR (Consensus.GetLedgerPeerSnapshot peerKind))) QueryStakePoolDefaultVote govActs -> caseShelleyToBabbageOrConwayEraOnwards ( const $ @@ -1017,12 +1017,11 @@ fromConsensusQueryResultShelleyBased sbe sbeQuery q' r' = Consensus.GetProposals{} -> r' _ -> fromConsensusQueryResultMismatch - QueryLedgerPeerSnapshot{} -> - undefined -- TODO(10.7) - -- case q' of - -- Consensus.GetCBOR Consensus.GetLedgerPeerSnapshot{} -> - -- r' - -- _ -> fromConsensusQueryResultMismatch + QueryLedgerPeerSnapshot {} -> + case q' of + Consensus.GetCBOR (Consensus.GetLedgerPeerSnapshot {}) -> + r' + _ -> fromConsensusQueryResultMismatch QueryStakePoolDefaultVote{} -> case q' of Consensus.QueryStakePoolDefaultVote{} -> From 7020645f979f81c760a86305d32be6eb73fe1845 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20W=C3=B3jtowicz?= Date: Thu, 5 Feb 2026 13:18:21 +0100 Subject: [PATCH 31/32] consensus srp --- cabal.project | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cabal.project b/cabal.project index 86d9fe6e2f..2fcd41bc43 100644 --- a/cabal.project +++ b/cabal.project @@ -181,8 +181,8 @@ source-repository-package source-repository-package type: git location: https://github.com/IntersectMBO/ouroboros-consensus - tag: 93709ba7fe1145227e7128e21d535421a74b1920 - --sha256: sha256-vLwuGcjbMhSBVVJ6qT2XstuJJrildXnpst//B23in0Y= + tag: c7587e868ab2ea3802d6c880668a5d7689ab27d2 + --sha256: sha256-TfU1QCQ5wOpGzjLojKl8dhXLrI0k6RuzZ5lCgELlX3U= subdir: ouroboros-consensus ouroboros-consensus-cardano From aaf83b9ebc97698b8cb16a47f4ac2b7d7b1a6b10 Mon Sep 17 00:00:00 2001 From: Jordan Millar Date: Thu, 5 Feb 2026 09:57:18 -0400 Subject: [PATCH 32/32] Fill in ApplyTx JSON rendering fro Dijkstra --- .../Cardano/Api/Consensus/Internal/InMode.hs | 9 +- .../Api/Internal/Orphans/Serialisation.hs | 83 +++++++++++++++++-- 2 files changed, 78 insertions(+), 14 deletions(-) diff --git a/cardano-api/src/Cardano/Api/Consensus/Internal/InMode.hs b/cardano-api/src/Cardano/Api/Consensus/Internal/InMode.hs index f0246db60a..1eb8654d10 100644 --- a/cardano-api/src/Cardano/Api/Consensus/Internal/InMode.hs +++ b/cardano-api/src/Cardano/Api/Consensus/Internal/InMode.hs @@ -270,14 +270,7 @@ appTxErrToJson w e = ShelleyBasedEraAlonzo -> toJSON e ShelleyBasedEraBabbage -> toJSON e ShelleyBasedEraConway -> toJSON e - -- TODO: Ledger needs to expose DijkstraLedgerPredFailure in order - -- to define the necessary JSON instances for Dijkstra era. - ShelleyBasedEraDijkstra -> - Aeson.String . Text.pack $ - unlines - [ "This is not JSON serializable yet. Ledger must expose DijkstraLedgerPredFailure to implement the necessary instances." - , show e - ] + ShelleyBasedEraDijkstra -> toJSON e -- | A 'TxValidationError' in one of the eras supported by a given protocol -- mode. diff --git a/cardano-api/src/Cardano/Api/Internal/Orphans/Serialisation.hs b/cardano-api/src/Cardano/Api/Internal/Orphans/Serialisation.hs index 99f6ffba03..d2d8e90223 100644 --- a/cardano-api/src/Cardano/Api/Internal/Orphans/Serialisation.hs +++ b/cardano-api/src/Cardano/Api/Internal/Orphans/Serialisation.hs @@ -43,6 +43,7 @@ import Cardano.Chain.Update.Validation.Endorsement qualified as L.Endorsement import Cardano.Chain.Update.Validation.Interface qualified as L.Interface import Cardano.Chain.Update.Validation.Registration qualified as L.Registration import Cardano.Chain.Update.Validation.Voting qualified as L.Voting +import Cardano.Crypto.Hash (hashToTextAsHex) import Cardano.Crypto.Hash qualified as Crypto import Cardano.Ledger.Allegra.Rules qualified as L import Cardano.Ledger.Alonzo qualified as L @@ -269,13 +270,83 @@ instance ToJSON (L.ApplyTxError L.BabbageEra) where instance ToJSON (L.ApplyTxError L.ConwayEra) where toJSON = Aeson.genericToJSON Aeson.defaultOptions --- TODO: Ledger must expose DijkstraLedgerPredFailure in order to write the --- instances below. --- instance ToJSON (L.ApplyTxError L.DijkstraEra) where --- toJSON = Aeson.genericToJSON Aeson.defaultOptions +instance ToJSON (L.ApplyTxError L.DijkstraEra) where + toJSON = Aeson.genericToJSON Aeson.defaultOptions + +instance ToJSON (L.DijkstraMempoolPredFailure L.DijkstraEra) where + toJSON = Aeson.genericToJSON Aeson.defaultOptions + +instance ToJSON (L.DijkstraLedgerPredFailure L.DijkstraEra) where + toJSON = Aeson.genericToJSON Aeson.defaultOptions + +instance ToJSON (L.DijkstraSubLedgersPredFailure L.DijkstraEra) where + toJSON = Aeson.genericToJSON Aeson.defaultOptions + +instance ToJSON (L.DijkstraSubLedgerPredFailure L.DijkstraEra) where + toJSON = Aeson.genericToJSON Aeson.defaultOptions + +instance ToJSON (L.DijkstraSubGovPredFailure L.DijkstraEra) where + toJSON = Aeson.genericToJSON Aeson.defaultOptions + +instance ToJSON (L.DijkstraSubCertsPredFailure L.DijkstraEra) where + toJSON = Aeson.genericToJSON Aeson.defaultOptions + +instance ToJSON (L.DijkstraSubCertPredFailure L.DijkstraEra) where + toJSON = Aeson.genericToJSON Aeson.defaultOptions + +instance ToJSON (L.DijkstraSubGovCertPredFailure L.DijkstraEra) where + toJSON = Aeson.genericToJSON Aeson.defaultOptions + +instance ToJSON (L.DijkstraGovPredFailure L.DijkstraEra) where + toJSON = Aeson.genericToJSON Aeson.defaultOptions + +instance ToJSON (L.DijkstraGovCertPredFailure L.DijkstraEra) where + toJSON = Aeson.genericToJSON Aeson.defaultOptions + +instance ToJSON (L.DijkstraSubPoolPredFailure L.DijkstraEra) where + toJSON = Aeson.genericToJSON Aeson.defaultOptions + +instance ToJSON (L.DijkstraSubUtxowPredFailure L.DijkstraEra) where + toJSON = Aeson.genericToJSON Aeson.defaultOptions + +instance ToJSON (L.DijkstraUtxowPredFailure L.DijkstraEra) where + toJSON = Aeson.genericToJSON Aeson.defaultOptions + +instance ToJSON (L.DijkstraSubDelegPredFailure L.DijkstraEra) where + toJSON = Aeson.genericToJSON Aeson.defaultOptions + +instance ToJSON (L.ShelleyPoolPredFailure L.DijkstraEra) where + toJSON = Aeson.genericToJSON Aeson.defaultOptions + +instance ToJSON (L.DijkstraSubUtxoPredFailure L.DijkstraEra) where + toJSON = Aeson.genericToJSON Aeson.defaultOptions + +instance ToJSON (L.DijkstraUtxoPredFailure L.DijkstraEra) where + toJSON = Aeson.genericToJSON Aeson.defaultOptions + +instance ToJSON (L.ConwayDelegPredFailure L.DijkstraEra) where + toJSON = Aeson.genericToJSON Aeson.defaultOptions + +instance ToJSON (L.DijkstraSubUtxosPredFailure L.DijkstraEra) where + toJSON = Aeson.genericToJSON Aeson.defaultOptions + +instance ToJSON (L.ConwayCertPredFailure L.DijkstraEra) where + toJSON = Aeson.genericToJSON Aeson.defaultOptions + +instance ToJSON (L.ConwayUtxosPredFailure L.DijkstraEra) where + toJSON = Aeson.genericToJSON Aeson.defaultOptions + +instance + ToJSON + (L.ConwayCertsPredFailure L.DijkstraEra) + where + toJSON = Aeson.genericToJSON Aeson.defaultOptions + +instance ToJSONKey Ledger.TxId where + toJSONKey = toJSONKeyText ledgerTxIdToText --- instance ToJSON (L.DijkstraMempoolPredFailure L.DijkstraEra) where --- toJSON = Aeson.genericToJSON Aeson.defaultOptions +ledgerTxIdToText :: Ledger.TxId -> T.Text +ledgerTxIdToText (Ledger.TxId txidHash) = hashToTextAsHex (L.extractHash txidHash) deriving via ShowOf (L.Keys.VKey L.Keys.Witness)