Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update of cardano-cli to 8.21.0.0 and cardano-api to 8.42.0.0, delete custom cardano-git-rev #5716

Merged
merged 11 commits into from
Mar 28, 2024
2 changes: 1 addition & 1 deletion bench/locli/locli.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ library
, attoparsec
, attoparsec-iso8601
, bytestring
, cardano-git-rev
, cardano-git-rev ^>= 0.2.2
, cardano-ledger-core
, cardano-prelude
, cardano-slotting
Expand Down
3 changes: 2 additions & 1 deletion bench/locli/src/Cardano/Analysis/API/LocliVersion.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE TemplateHaskell #-}
module Cardano.Analysis.API.LocliVersion (module Cardano.Analysis.API.LocliVersion) where

import Cardano.Prelude (NFData, mconcat)
Expand All @@ -22,7 +23,7 @@ data LocliVersion =
getLocliVersion :: LocliVersion
getLocliVersion =
LocliVersion
Cardano.Git.Rev.gitRev
$(Cardano.Git.Rev.gitRev)
(pack (showVersion Paths_locli.version))

renderProgramAndVersion :: LocliVersion -> Text
Expand Down
2 changes: 1 addition & 1 deletion bench/plutus-scripts-bench/plutus-scripts-bench.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ library
-- IOG dependencies
--------------------------
build-depends:
, cardano-api ^>= 8.39.3.0
, cardano-api ^>= 8.42.0.0
, plutus-ledger-api >=1.0.0
, plutus-tx >=1.0.0
, plutus-tx-plugin ^>=1.21
Expand Down
9 changes: 5 additions & 4 deletions bench/tx-generator/src/Cardano/Benchmarking/Compiler.hs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ where
import Cardano.Api

import Cardano.Benchmarking.Script.Types
import qualified Cardano.Ledger.Coin as L
import Cardano.TxGenerator.Setup.NixService
import Cardano.TxGenerator.Setup.SigningKey
import Cardano.TxGenerator.Types
Expand Down Expand Up @@ -159,7 +160,7 @@ splittingPhase srcWallet = do
-- testCompiler (error "opts") $ splitSequenceWalletNames (WalletName "w1") (WalletName "w2") (unfoldSplitSequence 1 1000 10000)

data Split
= SplitWithChange Lovelace Int
= SplitWithChange L.Coin Int
| FullSplits Int
deriving Show

Expand All @@ -171,7 +172,7 @@ splitSequenceWalletNames src dst (split: rest) = do
l <- splitSequenceWalletNames tempWallet dst rest
return $ ( src, tempWallet, split) : l

unfoldSplitSequence :: Lovelace -> Lovelace -> Int -> [ Split ]
unfoldSplitSequence :: L.Coin -> L.Coin -> Int -> [ Split ]
unfoldSplitSequence fee value outputs
= if outputs < maxOutputsPerTx
then [ SplitWithChange value outputs ]
Expand Down Expand Up @@ -208,8 +209,8 @@ benchmarkingPhase wallet collateralWallet = do
return doneWallet

data Fees = Fees {
_safeCollateral :: Lovelace
, _minValuePerInput :: Lovelace
_safeCollateral :: L.Coin
, _minValuePerInput :: L.Coin
}

evilFeeMagic :: Compiler Fees
Expand Down
69 changes: 30 additions & 39 deletions bench/tx-generator/src/Cardano/Benchmarking/Script/Core.hs
Original file line number Diff line number Diff line change
Expand Up @@ -19,62 +19,53 @@ module Cardano.Benchmarking.Script.Core
where

import "contra-tracer" Control.Tracer (Tracer (..))

import Control.Concurrent (threadDelay)
import Control.Monad
import Control.Monad.IO.Class
import Control.Monad.Trans.Except
import Control.Monad.Trans.Except.Extra
import Data.ByteString.Lazy.Char8 as BSL (writeFile)
import Data.Ratio ((%))

import Streaming
import qualified Streaming.Prelude as Streaming

import qualified Data.Text as Text (unpack)
import Prelude

import Cardano.Api
import Cardano.Api.Shelley (PlutusScriptOrReferenceInput (..), ProtocolParameters,
ShelleyLedgerEra, convertToLedgerProtocolParameters, protocolParamMaxTxExUnits,
protocolParamPrices)

import Cardano.Logging hiding (LocalSocket)

import qualified Cardano.Ledger.Core as Ledger

import Cardano.TxGenerator.Fund as Fund
import qualified Cardano.TxGenerator.FundQueue as FundQueue
import Cardano.TxGenerator.Setup.Plutus as Plutus
import Cardano.TxGenerator.Tx
import Cardano.TxGenerator.Types
import qualified Cardano.TxGenerator.Utils as Utils
import Cardano.TxGenerator.UTxO

import Cardano.Benchmarking.GeneratorTx as GeneratorTx (AsyncBenchmarkControl)
import qualified Cardano.Benchmarking.GeneratorTx as GeneratorTx (waitBenchmark, walletBenchmark)
import Cardano.Benchmarking.GeneratorTx.NodeToNode (ConnectClient,
benchmarkConnectTxSubmit)
import Cardano.Benchmarking.GeneratorTx.SizedMetadata (mkMetadata)
import qualified Cardano.TxGenerator.Genesis as Genesis
import Cardano.TxGenerator.PlutusContext
import Cardano.TxGenerator.Setup.SigningKey

import Cardano.Benchmarking.OuroborosImports as Core (LocalSubmitTx, SigningKeyFile,
makeLocalConnectInfo, protocolToCodecConfig)

import Cardano.Benchmarking.LogTypes as Core (TraceBenchTxSubmit (..), btConnect_, btN2N_,
btSubmission2_, btTxSubmit_)
import Cardano.Benchmarking.Types as Core (SubmissionErrorPolicy (..))
import Cardano.Benchmarking.Wallet as Wallet

import Cardano.Benchmarking.OuroborosImports as Core (LocalSubmitTx, SigningKeyFile,
makeLocalConnectInfo, protocolToCodecConfig)
import Cardano.Benchmarking.Script.Aeson (prettyPrintOrdered, readProtocolParametersFile)
import Cardano.Benchmarking.Script.Env hiding (Error (TxGenError))
import qualified Cardano.Benchmarking.Script.Env as Env (Error (TxGenError))
import Cardano.Benchmarking.Script.Types
import Cardano.Benchmarking.Types as Core (SubmissionErrorPolicy (..))
import Cardano.Benchmarking.Version as Version
import Cardano.Benchmarking.Wallet as Wallet
import qualified Cardano.Ledger.Coin as L
import qualified Cardano.Ledger.Core as Ledger
import Cardano.Logging hiding (LocalSocket)
import Cardano.TxGenerator.Fund as Fund
import qualified Cardano.TxGenerator.FundQueue as FundQueue
import qualified Cardano.TxGenerator.Genesis as Genesis
import Cardano.TxGenerator.PlutusContext
import Cardano.TxGenerator.Setup.Plutus as Plutus
import Cardano.TxGenerator.Setup.SigningKey
import Cardano.TxGenerator.Tx
import Cardano.TxGenerator.Types
import qualified Cardano.TxGenerator.Utils as Utils
import Cardano.TxGenerator.UTxO
import Ouroboros.Network.Protocol.LocalStateQuery.Type (Target (..))

import Prelude

import Control.Concurrent (threadDelay)
import Control.Monad
import Data.ByteString.Lazy.Char8 as BSL (writeFile)
import Data.Ratio ((%))
import qualified Data.Text as Text (unpack)

import Streaming
import qualified Streaming.Prelude as Streaming

liftCoreWithEra :: AnyCardanoEra -> (forall era. IsShelleyBasedEra era => AsType era -> ExceptT TxGenError IO x) -> ActionM (Either TxGenError x)
liftCoreWithEra era coreCall = withEra era ( liftIO . runExceptT . coreCall)

Expand Down Expand Up @@ -106,7 +97,7 @@ readSigningKey name filePath =
defineSigningKey :: String -> SigningKey PaymentKey -> ActionM ()
defineSigningKey = setEnvKeys

addFund :: AnyCardanoEra -> String -> TxIn -> Lovelace -> String -> ActionM ()
addFund :: AnyCardanoEra -> String -> TxIn -> L.Coin -> String -> ActionM ()
addFund era wallet txIn lovelace keyName = do
fundKey <- getEnvKeys keyName
let
Expand Down Expand Up @@ -428,7 +419,7 @@ interpretPayMode payMode = do

makePlutusContext :: forall era. IsShelleyBasedEra era
=> ScriptSpec
-> ActionM (Witness WitCtxTxIn era, ScriptInAnyLang, ScriptData, Lovelace)
-> ActionM (Witness WitCtxTxIn era, ScriptInAnyLang, ScriptData, L.Coin)
makePlutusContext ScriptSpec{..} = do
protocolParameters <- getProtocolParameters
script <- liftIOSafe $ Plutus.readPlutusScript scriptSpecFile
Expand Down
21 changes: 10 additions & 11 deletions bench/tx-generator/src/Cardano/Benchmarking/Script/Selftest.hs
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,24 @@ It actually does use a protocol file taken in from IO.
module Cardano.Benchmarking.Script.Selftest
where

import Prelude

import Control.Monad
import qualified Data.ByteString.Lazy.Char8 as BSL

import Data.Either (fromRight)
import Data.String

import Cardano.Api
import Ouroboros.Network.NodeToClient (IOManager)

import Cardano.Benchmarking.Script.Action
import Cardano.Benchmarking.Script.Aeson (prettyPrint)
import Cardano.Benchmarking.Script.Env as Script
import Cardano.Benchmarking.Script.Types
import Cardano.Benchmarking.Tracer (initNullTracers)

import qualified Cardano.Ledger.Coin as L
import Cardano.TxGenerator.Setup.SigningKey
import Cardano.TxGenerator.Types
import Ouroboros.Network.NodeToClient (IOManager)

import Prelude

import Control.Monad
import qualified Data.ByteString.Lazy.Char8 as BSL
import Data.Either (fromRight)
import Data.String

import Paths_tx_generator

Expand Down Expand Up @@ -70,7 +69,7 @@ testScript protocolFile submitMode =
, DefineSigningKey key skey
, AddFund era genesisWallet
(TxIn "900fc5da77a0747da53f7675cbb7d149d46779346dea2f879ab811ccc72a2162" (TxIx 0))
(Lovelace 90000000000000) key
(L.Coin 90000000000000) key
, createChange genesisWallet splitWallet1 1 10
, createChange splitWallet1 splitWallet2 10 30 -- 10 TXs with 30 outputs -> in total 300 outputs
, createChange splitWallet2 splitWallet3 300 30
Expand Down
20 changes: 10 additions & 10 deletions bench/tx-generator/src/Cardano/Benchmarking/Script/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -38,21 +38,21 @@ module Cardano.Benchmarking.Script.Types (
, TxList(..)
) where

import GHC.Generics
import Prelude

import Data.Function (on)
import Data.List.NonEmpty
import Data.Text (Text)

import Cardano.Api
import qualified Cardano.Api.Ledger as L
import Cardano.Api.Shelley

import Cardano.Benchmarking.OuroborosImports (SigningKeyFile)
import Cardano.Node.Configuration.NodeAddress (NodeIPv4Address)

import Cardano.TxGenerator.Types

import Prelude

import Data.Function (on)
import Data.List.NonEmpty
import Data.Text (Text)
import GHC.Generics


-- FIXME: temporary workaround instance until Action ADT is refactored
instance Eq (SigningKey PaymentKey) where
Expand Down Expand Up @@ -95,7 +95,7 @@ data Action where
-- 'Cardano.Benchmarking.Wallet.walletRefInsertFund' which in turn
-- is just 'Control.Concurrent.modifyMVar' around
-- 'Cardano.TxGenerator.FundQueue.insert'.
AddFund :: !AnyCardanoEra -> !String -> !TxIn -> !Lovelace -> !String -> Action
AddFund :: !AnyCardanoEra -> !String -> !TxIn -> !L.Coin -> !String -> Action
-- | 'WaitBenchmark' signifies a 'Control.Concurrent.Async.waitCatch'
-- on the 'Cardano.Benchmarking.GeneratorTx.AsyncBenchmarkControl'
-- associated with the ID and also folds tracers into the completion.
Expand Down Expand Up @@ -138,7 +138,7 @@ data Generator where
-- | 'Split' makes payments with change depending on the pay mode.
-- The splitting is from potentially sending the change to a
-- different place.
Split :: !String -> !PayMode -> !PayMode -> [ Lovelace ] -> Generator
Split :: !String -> !PayMode -> !PayMode -> [ L.Coin ] -> Generator
-- | 'SplitN' divides the funds by N and divides them up into that
-- many transactions in a finite sequence. The handling starts from
-- a case in 'Cardano.Benchmarking.Script.Core.evalGenerator' and
Expand Down
9 changes: 6 additions & 3 deletions bench/tx-generator/src/Cardano/Benchmarking/Version.hs
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
{-# LANGUAGE TemplateHaskell #-}

module Cardano.Benchmarking.Version
where

import Cardano.Git.Rev (gitRev)

import Data.Aeson as A
import Data.Text as Text
import Data.Version (showVersion)
import Paths_tx_generator (version)
import System.Info (arch, compilerName, compilerVersion, os)

import Cardano.Git.Rev (gitRev)
import Paths_tx_generator (version)

data Version = Version
{ _package :: !Text
Expand All @@ -26,7 +29,7 @@ txGeneratorVersion = Version
, _arch = Text.pack arch
, _compilerName = Text.pack compilerName
, _compilerVersion = renderVersion compilerVersion
, _gitRev = gitRev
, _gitRev = $(gitRev)
}
where
renderVersion = Text.pack . showVersion
Expand Down
14 changes: 8 additions & 6 deletions bench/tx-generator/src/Cardano/Benchmarking/Wallet.hs
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,20 @@ effect, like 'createAndStore' and 'mangle'.
-}
module Cardano.Benchmarking.Wallet
where
import Prelude

import Control.Concurrent.MVar
import Streaming

import Cardano.Api

import qualified Cardano.Ledger.Coin as L
import Cardano.TxGenerator.FundQueue as FundQueue
import Cardano.TxGenerator.Tx
import Cardano.TxGenerator.Types
import Cardano.TxGenerator.UTxO

import Prelude

import Control.Concurrent.MVar

import Streaming

-- | All the actual functionality of Wallet / WalletRef has been removed
-- and WalletRef has been stripped down to MVar FundQueue.
-- The implementation of Wallet has become trivial.
Expand Down Expand Up @@ -121,7 +123,7 @@ mangleWithChange mkChange mkPayment outs = case outs of
-- The only caller not passing a constant list built with 'repeat'
-- as the first @fkts@ argument is 'mangleWithChange' above. This
-- is likely worth refactoring for the sake of maintainability.
mangle :: Monad m => [ CreateAndStore m era ] -> CreateAndStoreList m era [ Lovelace ]
mangle :: Monad m => [ CreateAndStore m era ] -> CreateAndStoreList m era [ L.Coin ]
mangle fkts values
= (outs, \txId -> mapM_ (\f -> f txId) fs)
where
Expand Down
8 changes: 5 additions & 3 deletions bench/tx-generator/src/Cardano/TxGenerator/Fund.hs
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@ module Cardano.TxGenerator.Fund
)
where

import Data.Function (on)

import Cardano.Api as Api

import qualified Cardano.Ledger.Coin as L

import Data.Function (on)


-- $Types
--
Expand Down Expand Up @@ -67,7 +69,7 @@ getFundKey :: Fund -> Maybe (SigningKey PaymentKey)
getFundKey (Fund (InAnyCardanoEra _ a)) = _fundSigningKey a

-- | Converting a `TxOutValue` to `Lovelace` requires case analysis.
getFundLovelace :: Fund -> Lovelace
getFundLovelace :: Fund -> L.Coin
getFundLovelace (Fund (InAnyCardanoEra _ a)) = case _fundVal a of
TxOutValueByron l -> l
TxOutValueShelleyBased era v -> selectLovelace $ Api.fromLedgerValue era v
Expand Down
Loading
Loading