diff --git a/flake.lock b/flake.lock index b85eaae..b53c9a6 100644 --- a/flake.lock +++ b/flake.lock @@ -3,16 +3,16 @@ "cardano-node": { "flake": false, "locked": { - "lastModified": 1745954148, - "narHash": "sha256-Moth/2BOCWDdgXrOX6fv2rykqe4zR9POjC+g4dlUqqc=", + "lastModified": 1770822424, + "narHash": "sha256-zyrBw3yn69y3n0c6U0MDvezYC3GHbjJ3yJmhM4vMtUk=", "owner": "IntersectMBO", "repo": "cardano-node", - "rev": "420c94fbb075146c6ec7fba78c5b0482fafe72dd", + "rev": "0d697f14ee10a775f08c60e3839becc9131dca75", "type": "github" }, "original": { "owner": "IntersectMBO", - "ref": "10.4.1", + "ref": "10.6.2", "repo": "cardano-node", "type": "github" } diff --git a/flake.nix b/flake.nix index 60d2d4d..23e2471 100644 --- a/flake.nix +++ b/flake.nix @@ -6,7 +6,7 @@ treefmt-nix.inputs.nixpkgs.follows = "nixpkgs"; flake-compat.url = "github:input-output-hk/flake-compat"; flake-compat.flake = false; - cardano-node.url = "github:IntersectMBO/cardano-node/10.4.1"; + cardano-node.url = "github:IntersectMBO/cardano-node/10.6.2"; cardano-node.flake = false; # otherwise, +2k dependencies we don’t really use nix-bundle-exe.url = "github:3noch/nix-bundle-exe"; nix-bundle-exe.flake = false; diff --git a/nix/cardano-api--expose-internal.diff b/nix/cardano-api--expose-internal.diff index 7de276d..ba8cb07 100644 --- a/nix/cardano-api--expose-internal.diff +++ b/nix/cardano-api--expose-internal.diff @@ -1,35 +1,31 @@ diff --git a/cardano-api.cabal b/cardano-api.cabal -index 1e76d5160..3a2944853 100644 +index 6746e30c2..d94794832 100644 --- a/cardano-api.cabal +++ b/cardano-api.cabal -@@ -76,12 +76,14 @@ library - Cardano.Api.Internal.DRepMetadata - Cardano.Api.Internal.Eon.ShelleyBasedEra - Cardano.Api.Internal.Eras -+ Cardano.Api.Internal.Eras.Core - Cardano.Api.Internal.Error - Cardano.Api.Internal.Fees - Cardano.Api.Internal.Genesis - Cardano.Api.Internal.GenesisParameters - Cardano.Api.Internal.Governance.Metadata.Validation - Cardano.Api.Internal.IO -+ Cardano.Api.Internal.InMode - Cardano.Api.Internal.LedgerState - Cardano.Api.Internal.Modes +@@ -205,12 +205,16 @@ library + Cardano.Api.Certificate.Internal.DRepMetadata + Cardano.Api.Certificate.Internal.OperationalCertificate + Cardano.Api.Certificate.Internal.StakePoolMetadata ++ exposed-modules: + Cardano.Api.Consensus.Internal.InMode ++ other-modules: + Cardano.Api.Consensus.Internal.Mode + Cardano.Api.Consensus.Internal.Protocol + Cardano.Api.Consensus.Internal.Reexport + Cardano.Api.Era.Internal.Case ++ exposed-modules: + Cardano.Api.Era.Internal.Core ++ other-modules: + Cardano.Api.Era.Internal.Eon.AllegraEraOnwards + Cardano.Api.Era.Internal.Eon.AlonzoEraOnwards + Cardano.Api.Era.Internal.Eon.BabbageEraOnwards +@@ -252,7 +256,9 @@ library + Cardano.Api.IO.Internal.Compat.Posix + Cardano.Api.IO.Internal.Compat.Wasm + Cardano.Api.IO.Internal.Compat.Win32 ++ exposed-modules: Cardano.Api.Internal.Orphans -@@ -203,7 +205,6 @@ library - Cardano.Api.Internal.Eon.ShelleyToBabbageEra - Cardano.Api.Internal.Eon.ShelleyToMaryEra - Cardano.Api.Internal.Eras.Case -- Cardano.Api.Internal.Eras.Core - Cardano.Api.Internal.Experimental.Eras - Cardano.Api.Internal.Experimental.Plutus.IndexedPlutusScriptWitness - Cardano.Api.Internal.Experimental.Plutus.Script -@@ -229,7 +230,6 @@ library - Cardano.Api.Internal.IPC - Cardano.Api.Internal.IPC.Monad - Cardano.Api.Internal.IPC.Version -- Cardano.Api.Internal.InMode - Cardano.Api.Internal.Json - Cardano.Api.Internal.Keys.Byron - Cardano.Api.Internal.Keys.Class ++ other-modules: + Cardano.Api.Internal.Orphans.Misc + Cardano.Api.Internal.Orphans.Serialisation + Cardano.Api.Internal.Utils diff --git a/nix/cardano-ledger-test--expose-helpers.diff b/nix/cardano-ledger-test--expose-helpers.diff index 6207ae7..57f5b38 100644 --- a/nix/cardano-ledger-test--expose-helpers.diff +++ b/nix/cardano-ledger-test--expose-helpers.diff @@ -1,11 +1,11 @@ diff --git a/src/Test/Cardano/Ledger/Generic/GenState.hs b/src/Test/Cardano/Ledger/Generic/GenState.hs -index 95742c8b7..fa0f514a1 100644 +index a4a0d8f86..4020fd005 100644 --- a/src/Test/Cardano/Ledger/Generic/GenState.hs +++ b/src/Test/Cardano/Ledger/Generic/GenState.hs -@@ -75,6 +75,8 @@ module Test.Cardano.Ledger.Generic.GenState ( +@@ -74,6 +74,8 @@ module Test.Cardano.Ledger.Generic.GenState ( initStableFields, modifyGenStateInitialUtxo, - modifyGenStateInitialRewards, + modifyGenStateInitialAccounts, + modifyGenStateScripts, + modifyPlutusScripts, modifyModelCount, diff --git a/nix/cardano-node--apply-patches.diff b/nix/cardano-node--apply-patches.diff index 6b85e40..fa48c1f 100644 --- a/nix/cardano-node--apply-patches.diff +++ b/nix/cardano-node--apply-patches.diff @@ -1,8 +1,8 @@ diff --git a/nix/haskell.nix b/nix/haskell.nix -index 5db39bc61..039328c7f 100644 +index 52a57b06bb..5e84f31753 100644 --- a/nix/haskell.nix +++ b/nix/haskell.nix -@@ -113,6 +113,18 @@ let +@@ -122,6 +122,18 @@ let # modules = [ @@ -19,5 +19,5 @@ index 5db39bc61..039328c7f 100644 + ]; + }) ({ lib, pkgs, ... }: { - packages.cardano-tracer.package.buildable = with pkgs.stdenv.hostPlatform; lib.mkForce (!isMusl); packages.cardano-node-chairman.components.tests.chairman-tests.buildable = lib.mkForce pkgs.stdenv.hostPlatform.isUnix; + package-keys = ["plutus-tx-plugin"]; diff --git a/nix/cardano-node--export-cardano-submit-api.diff b/nix/cardano-node--export-cardano-submit-api.diff new file mode 100644 index 0000000..024b4ad --- /dev/null +++ b/nix/cardano-node--export-cardano-submit-api.diff @@ -0,0 +1,13 @@ +diff --git a/cardano-submit-api/cardano-submit-api.cabal b/cardano-submit-api/cardano-submit-api.cabal +index dac88bc83a..a28c0b42c2 100644 +--- a/cardano-submit-api/cardano-submit-api.cabal ++++ b/cardano-submit-api/cardano-submit-api.cabal +@@ -66,7 +66,7 @@ library + + exposed-modules: Cardano.TxSubmit + +- other-modules: Cardano.TxSubmit.CLI.Parsers ++ exposed-modules: Cardano.TxSubmit.CLI.Parsers + , Cardano.TxSubmit.CLI.Types + , Cardano.TxSubmit.Metrics + , Cardano.TxSubmit.Orphans diff --git a/nix/cardano-node--expose-cardano-ledger-test.diff b/nix/cardano-node--expose-cardano-ledger-test.diff index bcc9f7d..44e7062 100644 --- a/nix/cardano-node--expose-cardano-ledger-test.diff +++ b/nix/cardano-node--expose-cardano-ledger-test.diff @@ -1,40 +1,45 @@ diff --git a/cabal.project b/cabal.project -index 35af620d1..ef6e74e44 100644 +index 2b1b2e8b5b..1ae15e2941 100644 --- a/cabal.project +++ b/cabal.project -@@ -65,6 +65,15 @@ allow-newer: - -- Do NOT add more source-repository-package stanzas here unless they are strictly - -- temporary! Please read the section in CONTRIBUTING about updating dependencies. +@@ -64,6 +64,20 @@ package plutus-scripts-bench + allow-newer: + , katip:Win32 +source-repository-package + type: git + location: https://github.com/IntersectMBO/cardano-ledger.git -+ tag: a9e78ae63cf8870f0ce6ce76bd7029b82ddb47e1 ++ tag: faa7a9dc347697b11d4da5b7818b1731e11aeeef + subdir: + libs/cardano-ledger-test -+ libs/constrained-generators -+ --sha256: 12a99hc2jqgcjipvsqpgsrjhxyzd2gyn4mgqkir0ld3ksmzvcgd4 ++ --sha256: 0r7aqzx981sxzdqnq2874ddhmc8wzsxf93zv1dp18fpsirhwvya6 ++ ++source-repository-package ++ type: git ++ location: https://github.com/input-output-hk/constrained-generators.git ++ --sha256: sha256-HjRCWK+3uTZBPLkpxr7oDlZe2W5kf/5s32XzXPdi6Go= ++ tag: 45559e07fe1651ddd257f2a1215dfd65e30a963f + if impl (ghc >= 9.12) allow-newer: - -- https://github.com/phadej/vec/issues/118 + -- https://github.com/kapralVV/Unique/issues/11 diff --git a/cardano-node/cardano-node.cabal b/cardano-node/cardano-node.cabal -index 5ff4ea573..2027d3714 100644 +index 2c523934fa..73309acf04 100644 --- a/cardano-node/cardano-node.cabal +++ b/cardano-node/cardano-node.cabal -@@ -160,6 +160,7 @@ library - , cardano-ledger-conway +@@ -152,6 +152,7 @@ library , cardano-ledger-core + , cardano-ledger-dijkstra , cardano-ledger-shelley + , cardano-ledger-test == 9.9.9.9 , cardano-prelude , cardano-protocol-tpraos >= 1.4 , cardano-slotting >= 0.2 diff --git a/nix/haskell.nix b/nix/haskell.nix -index 1bc557d65..9277e580f 100644 +index 5e84f31753..fb3d1e3292 100644 --- a/nix/haskell.nix +++ b/nix/haskell.nix -@@ -113,6 +113,14 @@ let +@@ -122,6 +122,14 @@ let # modules = [ diff --git a/nix/internal.nix b/nix/internal.nix index 80a17fc..a9ab471 100644 --- a/nix/internal.nix +++ b/nix/internal.nix @@ -42,7 +42,9 @@ in rec { x86_64-darwin = cardano-node-flake.packages.x86_64-darwin; aarch64-darwin = cardano-node-flake.packages.aarch64-darwin; } - .${targetSystem}; + .${ + targetSystem + }; inherit (cardano-node-packages) cardano-node cardano-cli; @@ -57,9 +59,8 @@ in rec { name = "cardano-ledger--${dep-tag}"; owner = "IntersectMBO"; repo = "cardano-ledger"; - #rev = "a9e78ae63cf8870f0ce6ce76bd7029b82ddb47e1"; # the one for cardano-node 10.4.1, tag: cardano-ledger-core-1.17.0.0 - rev = dep-tag; # the one for cardano-node 10.4.1 - hash = "sha256-pD22f9VzNApynPhVYv0T7fsOZdbvYr1vlOxhKRhMSYk="; + rev = dep-tag; + hash = "sha256-RvnNYY76OhRuC/uP5Lr+HLEKWyMHCWxx+10HlPrH6mQ="; }; in (import inputs.flake-compat { @@ -74,7 +75,6 @@ in rec { ''} cp -r ${../testgen-hs} ./testgen-hs sed -r '/^packages:/ a\ testgen-hs' -i cabal.project - sed -r 's/other-modules:\s*/ , /g' -i cardano-submit-api/cardano-submit-api.cabal patch -p1 -i ${./cardano-node--apply-patches.diff} cp ${./cardano-ledger-core--Arbitrary-PoolMetadata.diff} nix/cardano-ledger-core--Arbitrary-PoolMetadata.diff @@ -88,6 +88,8 @@ in rec { patch -p1 -i ${./cardano-node--expose-cardano-ledger-test.diff} sed -r 's,CARDANO_LEDGER_SOURCE,${cardano-ledger-src},g' -i nix/haskell.nix + + patch -p1 -i ${./cardano-node--export-cardano-submit-api.diff} ''); inherit (unpatched) rev shortRev lastModified lastModifiedDate; }; @@ -101,7 +103,9 @@ in rec { aarch64-darwin = patched-flake.packages.aarch64-darwin.testgen-hs; x86_64-windows = patched-flake.legacyPackages.x86_64-linux.hydraJobs.windows.testgen-hs; } - .${targetSystem}; + .${ + targetSystem + }; nix-bundle-exe = import inputs.nix-bundle-exe {inherit pkgs;}; @@ -174,5 +178,7 @@ in rec { aarch64-linux = linuxLike {}; x86_64-windows = linuxLike {useZip = true;}; } - .${targetSystem}; + .${ + targetSystem + }; } diff --git a/testgen-hs/Encoder.hs b/testgen-hs/Encoder.hs index afb83a4..c630e98 100644 --- a/testgen-hs/Encoder.hs +++ b/testgen-hs/Encoder.hs @@ -147,6 +147,7 @@ serializeLanguage = \case Ledger.PlutusV1 -> "plutus:v1" Ledger.PlutusV2 -> "plutus:v2" Ledger.PlutusV3 -> "plutus:v3" + Ledger.PlutusV4 -> "plutus:v4" -- | Ogmios "budget" object from 'ExUnits'. serializeExUnits :: Al.ExUnits -> Encoding @@ -258,6 +259,8 @@ serializeContextError err = J.text $ case err of "Reference scripts not supported in plutus:v1. Use plutus:v2 or higher." C.BabbageContextError (Ba.ReferenceInputsNotSupported {}) -> "Reference inputs not supported in plutus:v1. Use plutus:v2 or higher." + C.ReferenceInputsNotDisjointFromInputs {} -> + "Reference inputs overlap with regular inputs. Ensure both sets are disjoint." C.BabbageContextError (Ba.RedeemerPointerPointsToNothing purpose) -> let (title, ptr) = case purpose of diff --git a/testgen-hs/Generators.hs b/testgen-hs/Generators.hs index 612453c..a234fef 100644 --- a/testgen-hs/Generators.hs +++ b/testgen-hs/Generators.hs @@ -3,10 +3,7 @@ module Generators where -import qualified Cardano.Api.Internal.Eon.ShelleyBasedEra as CAPI -import qualified Cardano.Api.Internal.Eras.Core as CAPI -import qualified Cardano.Api.Internal.InMode as CAPI -import qualified Cardano.Api.Internal.Modes as CAPI +import qualified Cardano.Api as CAPI import Cardano.Api.Internal.Orphans () import qualified Cardano.Binary import qualified Cardano.Chain.Slotting as CCS @@ -229,6 +226,7 @@ hfcEnvelopeShowInner = go go (OCCB.ApplyTxErrMary a) = (show . typeOf $ a, show a) go (OCCB.ApplyTxErrAlonzo a) = (show . typeOf $ a, show a) go (OCCB.ApplyTxErrBabbage a) = (show . typeOf $ a, show a) + go (OCCB.ApplyTxErrDijkstra a) = (show . typeOf $ a, show a) go (OCCB.ApplyTxErrConway a) = (show . typeOf $ a, show a) go (OCCB.ApplyTxErrWrongEra a) = (show . typeOf $ a, show a) diff --git a/testgen-hs/Main.hs b/testgen-hs/Main.hs index 7244e04..c966417 100644 --- a/testgen-hs/Main.hs +++ b/testgen-hs/Main.hs @@ -6,11 +6,9 @@ module Main where import CLI (GenSize (..), NumCases (..), Seed (..)) import qualified CLI +import qualified Cardano.Api as CAPI import Cardano.Binary (FromCBOR, decodeFull') import Cardano.Ledger.Api (ConwayEra, PParams) -import qualified Cardano.Ledger.Binary.Decoding as Binary -import qualified Cardano.Ledger.Core -import qualified Cardano.Ledger.Core as Ledger import Cardano.Slotting.EpochInfo (EpochInfo, fixedEpochInfo) import Cardano.Slotting.Slot (EpochSize (..)) import Cardano.Slotting.Time (SystemStart (..), mkSlotLength) @@ -23,12 +21,11 @@ import qualified Data.Aeson as J import qualified Data.Aeson.Encode.Pretty as J import Data.Bifunctor (first) import Data.ByteString (ByteString) -import qualified Data.ByteString as BS import qualified Data.ByteString.Base16 as B16 import qualified Data.ByteString.Char8 as B8 import qualified Data.ByteString.Lazy as BL import qualified Data.ByteString.Lazy.Char8 as BL8 -import Data.Foldable (foldl') +import qualified Data.Foldable as Foldable import Data.Proxy (Proxy (..)) import Data.Text (Text) import qualified Data.Text as T @@ -38,7 +35,6 @@ import Data.Time (NominalDiffTime) import Data.Time.Clock.POSIX (getPOSIXTime) import Data.Word (Word16, Word64) import qualified Deserialize as D -import Encoder (serializeDecoderError) import Evaluation (eval'Conway, writeJson) import GHC.Generics (Generic) import qualified Generators as G @@ -161,7 +157,7 @@ writeRandom _ (Seed seed) (GenSize generatorSize) (NumCases numCases) = do putsLock <- newMVar () let chunks = snd $ - foldl' + Foldable.foldl' ( \(prevRng, acc) chunk -> let (rngL, rngR) = System.Random.split prevRng in (rngL, (chunk, rngR) : acc) @@ -300,12 +296,12 @@ runEvaluateStream = do Right (evalPayload :: EvalPayload) -> do let decodedValues = do txBytes <- first (\e -> PayloadResponse (Just (T.pack e)) Nothing) $ B16.decode (T.encodeUtf8 (tx evalPayload)) - decodedTx <- - decodeCborWith - "Transaction" - (Left . (\e -> PayloadResponse (Just (serializeDecoderError (BS.length txBytes) e)) Nothing)) - (Binary.decCBOR @(Cardano.Ledger.Core.Tx ConwayEra)) - txBytes + decodedTxApi <- + first + (\e -> PayloadResponse (Just (T.pack (show e))) Nothing) + (CAPI.deserialiseFromCBOR (CAPI.AsTx CAPI.AsConwayEra) txBytes) + let decodedTx = case decodedTxApi of + CAPI.ShelleyTx _ ledgerTx -> ledgerTx utxos <- first (\e -> PayloadResponse (Just (T.pack e)) Nothing) $ decodeFromHex (utxos evalPayload) return (decodedTx, utxos) @@ -329,21 +325,3 @@ decodeFromHex hexText = do cborBytes <- first show $ B16.decode (T.encodeUtf8 hexText) -- 2. Decode from CBOR. first show $ decodeFull' cborBytes - --- Run a CBOR decoder for data in Conway era -decodeCborWith :: - -- | Label for error reporting - Text -> - -- | Error handler - (Binary.DecoderError -> Either e a) -> - -- | CBOR decoder - (forall s. Binary.Decoder s a) -> - -- | Input bytes - ByteString -> - Either e a -decodeCborWith lbl handleErr decoder bytes = - case Binary.decodeFullDecoder version lbl decoder (BL.fromStrict bytes) of - Left cborErr -> handleErr cborErr - Right val -> Right val - where - version = Ledger.eraProtVerLow @ConwayEra diff --git a/testgen-hs/SynthEvalTx.hs b/testgen-hs/SynthEvalTx.hs index 17b3e3e..0e6145c 100644 --- a/testgen-hs/SynthEvalTx.hs +++ b/testgen-hs/SynthEvalTx.hs @@ -21,7 +21,7 @@ import qualified Cardano.Ledger.Api.Era import Cardano.Ledger.Api.Tx (BabbageEraTxBody, RedeemerReport, Tx) import Cardano.Ledger.Api.Tx.In (TxIn) import Cardano.Ledger.Api.Tx.Out - ( TxOut (..), + ( TxOut, ) import Cardano.Ledger.Api.UTxO (UTxO (..)) import Cardano.Ledger.BaseTypes (Network (..)) @@ -34,7 +34,7 @@ import Cardano.Ledger.Credential import Cardano.Ledger.Keys (KeyHash (..), KeyRole (..)) import Cardano.Ledger.Val (inject) import Cardano.Slotting.EpochInfo (EpochInfo, fixedEpochInfo) -import Cardano.Slotting.Slot (EpochSize (..), SlotNo (..)) +import Cardano.Slotting.Slot (EpochSize (..)) import Cardano.Slotting.Time (SystemStart (..), mkSlotLength) import Data.Aeson ( eitherDecodeStrict', @@ -42,7 +42,6 @@ import Data.Aeson import qualified Data.Aeson as J import qualified Data.Aeson.Encoding as AesonEncoding import qualified Data.ByteString as BS -import qualified Data.Default import Data.FileEmbed (embedFile) import qualified Data.Map.Strict as Map import qualified Data.Set as Set @@ -53,7 +52,6 @@ import Encoder (ogmiosSuccess) import Lens.Micro ((^.)) import qualified Test.Cardano.Ledger.Generic.GenState import qualified Test.Cardano.Ledger.Generic.Proof as Proof -import qualified Test.Cardano.Ledger.Generic.TxGen import qualified Test.QuickCheck as QC -- | Drops a Plutus script into both lookup maps. @@ -75,12 +73,8 @@ genTxUTxO :: Cardano.Ledger.Api.UTxO.UTxO Cardano.Ledger.Api.Era.ConwayEra ) genTxUTxO = do - slot <- SlotNo <$> QC.choose (0, 10_000) - ((utxo, tx), _) <- Test.Cardano.Ledger.Generic.GenState.runGenRS proof Data.Default.def (Test.Cardano.Ledger.Generic.TxGen.genAlonzoTx proof slot) - pure (tx, utxo) - where - proof :: Proof.Proof Cardano.Ledger.Api.Era.ConwayEra - proof = Proof.Conway + tx <- QC.arbitrary + pure (tx, stubUTxO tx) eval'Conway :: (Cardano.Ledger.Core.Tx (Cardano.Ledger.Api.Era.ConwayEra)) -> @@ -122,7 +116,7 @@ stubUTxO tx = [(i, dummyOut) | i <- Set.toList (allTxIns tx)] where dummyOut :: TxOut era - dummyOut = mkBasicTxOut dummyAddr (inject (Coin 2_000_000)) + dummyOut = Cardano.Ledger.Core.mkBasicTxOut dummyAddr (inject (Coin 2_000_000)) dummyAddr :: Addr dummyAddr = Addr Testnet (KeyHashObj dummyKeyHash) StakeRefNull diff --git a/testgen-hs/testgen-hs.cabal b/testgen-hs/testgen-hs.cabal index 6d281fc..f50cfb9 100644 --- a/testgen-hs/testgen-hs.cabal +++ b/testgen-hs/testgen-hs.cabal @@ -5,7 +5,7 @@ synopsis: CBOR test case generator and deserializer for cross-checking other implementations -- Version tracks cardano-node, adding a patch segment: -version: 10.4.1.2 +version: 10.6.2.0 executable testgen-hs main-is: Main.hs @@ -31,7 +31,6 @@ executable testgen-hs , cardano-submit-api , cborg , containers - , data-default , file-embed , generic-random , microlens