Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions flake.lock

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

2 changes: 1 addition & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
58 changes: 27 additions & 31 deletions nix/cardano-api--expose-internal.diff
Original file line number Diff line number Diff line change
@@ -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
6 changes: 3 additions & 3 deletions nix/cardano-ledger-test--expose-helpers.diff
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
6 changes: 3 additions & 3 deletions nix/cardano-node--apply-patches.diff
Original file line number Diff line number Diff line change
@@ -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 =
[
Expand All @@ -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"];
13 changes: 13 additions & 0 deletions nix/cardano-node--export-cardano-submit-api.diff
Original file line number Diff line number Diff line change
@@ -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
31 changes: 18 additions & 13 deletions nix/cardano-node--expose-cardano-ledger-test.diff
Original file line number Diff line number Diff line change
@@ -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 =
[
Expand Down
20 changes: 13 additions & 7 deletions nix/internal.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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 {
Expand All @@ -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
Expand All @@ -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;
};
Expand All @@ -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;};

Expand Down Expand Up @@ -174,5 +178,7 @@ in rec {
aarch64-linux = linuxLike {};
x86_64-windows = linuxLike {useZip = true;};
}
.${targetSystem};
.${
targetSystem
};
}
3 changes: 3 additions & 0 deletions testgen-hs/Encoder.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
6 changes: 2 additions & 4 deletions testgen-hs/Generators.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand Down
40 changes: 9 additions & 31 deletions testgen-hs/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)

Expand All @@ -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
Loading