Skip to content
Draft
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 bench/plutus-scripts-bench/plutus-scripts-bench.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@ library
-- IOG dependencies
--------------------------
build-depends:
, cardano-api ^>=10.19
, plutus-ledger-api ^>=1.53
, plutus-tx ^>=1.53
, plutus-tx-plugin ^>=1.53
, cardano-api ^>=10.21
, plutus-ledger-api ^>=1.56
, plutus-tx ^>=1.56
, plutus-tx-plugin ^>=1.56

------------------------
-- Non-IOG dependencies
Expand Down
4 changes: 2 additions & 2 deletions bench/tx-generator/tx-generator.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,9 @@ library
, attoparsec-aeson
, base16-bytestring
, bytestring
, cardano-api ^>= 10.19
, cardano-api ^>= 10.21
, cardano-binary
, cardano-cli ^>= 10.13
, cardano-cli ^>= 10.14
, cardano-crypto-class
, cardano-crypto-wrapper
, cardano-data
Expand Down
26 changes: 22 additions & 4 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -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-10-17T00:26:22Z
, cardano-haskell-packages 2025-11-20T19:55:27Z
, hackage.haskell.org 2025-12-02T22:23:29Z
, cardano-haskell-packages 2025-12-16T19:04:42Z

packages:
cardano-node
Expand All @@ -35,8 +35,8 @@ packages:
-- Needed when cross compiling
extra-packages: alex

program-options
ghc-options: -Werror
-- program-options
-- ghc-options: -Werror

test-show-details: direct

Expand Down Expand Up @@ -72,3 +72,21 @@ if impl (ghc >= 9.12)
-- 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-api.git
tag: 61e4cdd85f35e9088c4e1a869ff0d2b33473f5ff
--sha256: sha256-Xmni6Kal8fE77ul7HjFB0bvJRZHr07bjiJ4zrkrcMVU=
subdir: cardano-api



source-repository-package
type: git
location: https://github.com/IntersectMBO/cardano-cli.git
tag: f7daf209b31b57564ed79086c08a7cd5e2326fff
--sha256: sha256-+uS6wo+lfYkfZLAz6A7QIFZCiLezMOkRqTEdTrUGMdM=
subdir: cardano-cli
2 changes: 1 addition & 1 deletion cardano-node-chairman/cardano-node-chairman.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -88,5 +88,5 @@ test-suite chairman-tests
ghc-options: -threaded -rtsopts "-with-rtsopts=-N -T"

build-tool-depends: cardano-node:cardano-node
, cardano-cli:cardano-cli ^>= 10.13
, cardano-cli:cardano-cli ^>= 10.14
, cardano-node-chairman:cardano-node-chairman
2 changes: 1 addition & 1 deletion cardano-node/cardano-node.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ library
, async
, base16-bytestring
, bytestring
, cardano-api ^>= 10.19
, cardano-api ^>= 10.21
, cardano-crypto-class ^>=2.2.3.2
, cardano-crypto-wrapper
, cardano-git-rev ^>=0.2.2
Expand Down
4 changes: 2 additions & 2 deletions cardano-submit-api/cardano-submit-api.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ library
, aeson
, async
, bytestring
, cardano-api ^>= 10.19
, cardano-api ^>= 10.21
, cardano-binary
, cardano-cli ^>= 10.13
, cardano-cli ^>= 10.14
, cardano-crypto-class ^>=2.2.3.2
, http-media
, iohk-monitoring
Expand Down
8 changes: 6 additions & 2 deletions cardano-testnet/cardano-testnet.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ library
, annotated-exception
, ansi-terminal
, bytestring
, cardano-api ^>= 10.19
, cardano-cli:{cardano-cli, cardano-cli-test-lib} ^>= 10.13
, cardano-api ^>= 10.21
, cardano-cli:{cardano-cli, cardano-cli-test-lib} ^>= 10.14
, cardano-crypto-class ^>=2.2.3.2
, cardano-crypto-wrapper
, cardano-git-rev ^>= 0.2.2
Expand Down Expand Up @@ -209,8 +209,12 @@ test-suite cardano-testnet-test
Cardano.Testnet.Test.Cli.QuerySlotNumber
Cardano.Testnet.Test.Cli.Plutus.Scripts
Cardano.Testnet.Test.Cli.Plutus.CostCalculation
Cardano.Testnet.Test.Cli.Plutus.MultiAssetReturnCollateral
Cardano.Testnet.Test.Cli.Scripts.Simple.CostCalculation
Cardano.Testnet.Test.Cli.Scripts.Simple.Mint
Cardano.Testnet.Test.Cli.StakeSnapshot
Cardano.Testnet.Test.Cli.Transaction
Cardano.Testnet.Test.Cli.Transaction.BuildEstimate
Cardano.Testnet.Test.Cli.Transaction.RegisterDeregisterStakeAddress
Cardano.Testnet.Test.DumpConfig
Cardano.Testnet.Test.FoldEpochState
Expand Down
22 changes: 22 additions & 0 deletions cardano-testnet/src/Testnet/Components/Query.hs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ module Testnet.Components.Query
, findAllUtxos
, findUtxosWithAddress
, findLargestUtxoWithAddress
, findLargestMultiAssetUtxoWithAddress
, findLargestUtxoForPaymentKey

, checkDRepsNumber
Expand Down Expand Up @@ -350,6 +351,27 @@ findLargestUtxoWithAddress epochStateView sbe address = withFrozenCallStack $ do
. listToMaybe
$ sortOn (\(_, TxOut _ txOutValue _ _) -> Down $ txOutValueToLovelace txOutValue) utxos

-- | Retrieve the largest utxo with a multi-asset
findLargestMultiAssetUtxoWithAddress
:: HasCallStack
=> MonadAssertion m
=> MonadIO m
=> MonadTest m
=> EpochStateView
-> ShelleyBasedEra era
-> Text -- ^ Address
-> m (Maybe (TxIn, TxOut CtxUTxO era))
findLargestMultiAssetUtxoWithAddress epochStateView sbe address = withFrozenCallStack $ do
utxos <- toList <$> findUtxosWithAddress epochStateView sbe address
let sortedUTxOs = sortOn (\(_, TxOut _ txOutValue _ _) -> Down $ txOutValueToLovelace txOutValue) utxos
utxosWithMas = filter (\(_,TxOut _ txOutValue _ _) -> isMultiAssetPresent txOutValue) sortedUTxOs
pure $ listToMaybe utxosWithMas

isMultiAssetPresent :: TxOutValue era -> Bool
isMultiAssetPresent v =
Map.size (valueToPolicyAssets $ txOutValueToValue v) > 0


-- | Retrieve a largest UTxO for a payment key info - a convenience wrapper for
-- 'findLargestUtxoWithAddress'.
findLargestUtxoForPaymentKey
Expand Down
7 changes: 7 additions & 0 deletions cardano-testnet/src/Testnet/Defaults.hs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ module Testnet.Defaults
, plutusV3Script
, plutusV3SupplementalDatumScript
, plutusV2StakeScript
, simpleScript
) where

import Cardano.Api (AnyShelleyBasedEra (..), CardanoEra (..), File (..),
Expand Down Expand Up @@ -592,6 +593,12 @@ defaultUtxoKeys n =
, signingKey = File $ "utxo-keys" </> "utxo" <> show n </> "utxo.skey"
}


simpleScript :: Text -> Text
simpleScript signerRequired =
"{ \"scripts\": [ { \"keyHash\": \"" <> signerRequired <> "\", \"type\": \"sig\" } ], \"type\": \"all\" }"


-- | Default plutus script that always succeeds
plutusV3Script :: Text
plutusV3Script =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ module Cardano.Testnet.Test.Cli.Plutus.CostCalculation
, hprop_included_plutus_cost_calculation
, hprop_included_simple_script_cost_calculation
-- | Execute tests in this module with:
-- @DISABLE_RETRIES=1 cabal run cardano-testnet-test -- -p "/Spec.hs.Spec.Ledger Events.Plutus.Cost Calc/"@
-- @DISABLE_RETRIES=1 cabal test cardano-testnet-test -- -p "/Spec.hs.Spec.Ledger Events.Plutus.Cost Calc/"@
)
where

import Cardano.Api hiding (Value)
import Cardano.Api.Experimental (Some (Some))
import Cardano.Api.Ledger (EpochInterval (..))

import Cardano.Testnet

import Prelude
import Testnet.Types

import Control.Monad (void)
import Data.Aeson (Value, encodeFile)
Expand All @@ -37,14 +37,13 @@ import qualified System.Info as SYS

import Testnet.Components.Query (findLargestUtxoForPaymentKey, getEpochStateView, getTxIx,
watchEpochStateUpdate)
import qualified Testnet.Defaults as Defaults
import Testnet.Process.Cli.Transaction (TxOutAddress (..), mkSpendOutputsOnlyTx,
retrieveTransactionId, signTx, submitTx)
import Testnet.Process.Run (execCli', mkExecConfig)
import Testnet.Process.RunIO (liftIOAnnotated)
import Testnet.Property.Util (integrationRetryWorkspace)
import Testnet.Start.Types (eraToString)
import Testnet.Types (PaymentKeyInfo (paymentKeyInfoAddr), paymentKeyInfoPair,
verificationKey)

import Hedgehog (Property)
import qualified Hedgehog as H
Expand All @@ -53,7 +52,7 @@ import qualified Hedgehog.Extras.Test.File as H
import qualified Hedgehog.Extras.Test.Golden as H
import qualified Hedgehog.Extras.Test.TestWatchdog as H

-- @DISABLE_RETRIES=1 cabal run cardano-testnet-test -- -p "/Spec.hs.Spec.Ledger Events.Plutus.Cost Calc.Ref Script/"@
-- @DISABLE_RETRIES=1 cabal test cardano-testnet-test --test-options '-p "/Ref Script/"'@
hprop_ref_plutus_cost_calculation :: Property
hprop_ref_plutus_cost_calculation = integrationRetryWorkspace 2 "ref-plutus-script" $ \tempAbsBasePath' -> H.runWithDefaultWatchdog_ $ do
H.note_ SYS.os
Expand Down Expand Up @@ -145,7 +144,16 @@ hprop_ref_plutus_cost_calculation = integrationRetryWorkspace 2 "ref-plutus-scri
refScriptUnlock <- H.createDirectoryIfMissing $ work </> "ref-script-unlock"
let unsignedUnlockTx = File $ refScriptUnlock </> "unsigned-tx.tx"
largestUTxO <- findLargestUtxoForPaymentKey epochStateView sbe wallet1

refScriptHash <- execCli' execConfig [ eraName, "transaction", "policyid", "--script-file", unFile plutusV3Script]
H.note_ $ "Reference script hash: " <> refScriptHash

void $ execCli' execConfig
[ eraName, "query", "utxo"
, "--whole-utxo"
, "--cardano-mode"
, "--out-file", work </> "utxo-1.json"
]
H.cat $ work </> "utxo-1.json"
void $
execCli'
execConfig
Expand Down Expand Up @@ -201,7 +209,7 @@ hprop_ref_plutus_cost_calculation = integrationRetryWorkspace 2 "ref-plutus-scri

H.diffVsGoldenFile output "test/cardano-testnet-test/files/calculatePlutusScriptCost.json"

-- @DISABLE_RETRIES=1 cabal run cardano-testnet-test -- -p "/Spec.hs.Spec.Ledger Events.Plutus.Cost Calc.Normal Script/"@
-- @DISABLE_RETRIES=1 cabal test cardano-testnet-test --test-options '-p "/Spec.hs.Spec.Ledger Events.Plutus.Cost Calc.Normal Script/"'@
hprop_included_plutus_cost_calculation :: Property
hprop_included_plutus_cost_calculation = integrationRetryWorkspace 2 "included-plutus-script" $ \tempAbsBasePath' -> H.runWithDefaultWatchdog_ $ do
H.note_ SYS.os
Expand Down Expand Up @@ -231,8 +239,12 @@ hprop_included_plutus_cost_calculation = integrationRetryWorkspace 2 "included-p
epochStateView <- getEpochStateView configurationFile (nodeSocketPath poolNode1)

includedScriptLockWork <- H.createDirectoryIfMissing $ work </> "included-script-lock"
plutusV3Script <-
File <$> liftIOAnnotated (makeAbsolute "test/cardano-testnet-test/files/plutus/v3/always-succeeds.plutus")

plutusScriptFp <- H.note $ work </> "always-succeeds-script.plutusV3"
H.writeFile plutusScriptFp $ Text.unpack Defaults.plutusV3Script

--_plutusV3Script <-
-- File <$> liftIOAnnotated (makeAbsolute "test/cardano-testnet-test/files/plutus/v3/always-succeeds.plutus")

let includedScriptLockAmount = 10_000_000
enoughAmountForFees = 2_000_000 -- Needs to be more than min ada
Expand All @@ -246,7 +258,7 @@ hprop_included_plutus_cost_calculation = integrationRetryWorkspace 2 "included-p
includedScriptLockWork
"tx-body"
wallet0
[(ScriptAddress plutusV3Script, includedScriptLockAmount, Nothing)]
[(ScriptAddress $ File plutusScriptFp, includedScriptLockAmount, Nothing)]
signedTxIncludedScriptLock <-
signTx
execConfig
Expand All @@ -270,15 +282,16 @@ hprop_included_plutus_cost_calculation = integrationRetryWorkspace 2 "included-p
includedScriptUnlock <- H.createDirectoryIfMissing $ work </> "included-script-unlock"
let unsignedIncludedScript = File $ includedScriptUnlock </> "unsigned-tx.tx"
newLargestUTxO <- findLargestUtxoForPaymentKey epochStateView sbe wallet1

scriptHash <- execCli' execConfig [ eraName, "transaction", "policyid", "--script-file", plutusScriptFp]
H.note_ $ "Script hash: " <> scriptHash
void $
execCli'
execConfig
[ eraName
, "transaction", "build"
, "--change-address", Text.unpack $ paymentKeyInfoAddr wallet1
, "--tx-in", prettyShow (TxIn txIdIncludedScriptLock txIxIncludedScriptLock)
, "--tx-in-script-file", unFile plutusV3Script
, "--tx-in-script-file", plutusScriptFp
, "--tx-in-redeemer-value", "42"
, "--tx-in-collateral", prettyShow newLargestUTxO
, "--tx-out", Text.unpack (paymentKeyInfoAddr wallet1) <> "+" <> show (unCoin (includedScriptLockAmount - enoughAmountForFees))
Expand Down Expand Up @@ -311,7 +324,7 @@ hprop_included_plutus_cost_calculation = integrationRetryWorkspace 2 "included-p
(unFile includedScriptCostOutput)
"test/cardano-testnet-test/files/calculatePlutusScriptCost.json"

-- @DISABLE_RETRIES=1 cabal run cardano-testnet-test -- -p "/Spec.hs.Spec.Ledger Events.Plutus.Cost Calc.Simple Script/"@
-- @DISABLE_RETRIES=1 cabal test cardano-testnet-test --test-options '-p "/Spec.hs.Spec.Ledger Events.Plutus.Cost Calc.Simple Script/"'@
hprop_included_simple_script_cost_calculation :: Property
hprop_included_simple_script_cost_calculation = integrationRetryWorkspace 2 "included-simple-script" $ \tempAbsBasePath' -> H.runWithDefaultWatchdog_ $ do
H.note_ SYS.os
Expand Down
Loading
Loading