Skip to content

Commit

Permalink
Integration work for node 8.7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jasagredo committed Nov 15, 2023
1 parent 12ff967 commit 1f567e9
Show file tree
Hide file tree
Showing 36 changed files with 156 additions and 170 deletions.
2 changes: 1 addition & 1 deletion bench/locli/locli.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ library
, optparse-generic
, ouroboros-consensus
-- for Data.SOP.Strict:
, ouroboros-network ^>= 0.9.1
, ouroboros-network ^>= 0.10
, ouroboros-network-api
, process
, quiet
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 @@ -72,7 +72,7 @@ library
-- IOG dependencies
--------------------------
build-depends:
, cardano-api ^>= 8.29
, cardano-api ^>= 8.31
, plutus-ledger-api >=1.0.0
, plutus-tx >=1.0.0
, plutus-tx-plugin >=1.0.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,8 @@ import Ouroboros.Network.Protocol.KeepAlive.Client hiding (SendMsgDone
import Ouroboros.Network.Protocol.KeepAlive.Codec
import Ouroboros.Network.Protocol.TxSubmission2.Client (TxSubmissionClient,
txSubmissionClientPeer)
import Ouroboros.Network.PeerSelection.PeerSharing (PeerSharing (..), encodeRemoteAddress, decodeRemoteAddress)
import Ouroboros.Network.Protocol.PeerSharing.Client (PeerSharingClient (..),
peerSharingClientPeer)
import Ouroboros.Network.Protocol.TxSubmission2.Client (TxSubmissionClient,
txSubmissionClientPeer)

import Ouroboros.Network.Snocket (socketSnocket)

Expand Down Expand Up @@ -96,7 +93,7 @@ benchmarkConnectTxSubmit ioManager handshakeTracer submissionTracer codecConfig
(addrAddress <$> Nothing)
(addrAddress remoteAddr)
where
ownPeerSharing = NoPeerSharing
ownPeerSharing = PeerSharingDisabled
mkApp :: OuroborosBundle mode initiatorCtx responderCtx bs m a b
-> OuroborosApplication mode initiatorCtx responderCtx bs m a b
mkApp bundle =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,12 +191,12 @@ txSubmissionClient tr bmtr initialTxSource endOfProtocolCallback =

toGenTx :: tx -> GenTx CardanoBlock
toGenTx tx = case shelleyBasedEra @era of
ShelleyBasedEraShelley -> toConsensusGenTx $ TxInMode tx ShelleyEraInCardanoMode
ShelleyBasedEraAllegra -> toConsensusGenTx $ TxInMode tx AllegraEraInCardanoMode
ShelleyBasedEraMary -> toConsensusGenTx $ TxInMode tx MaryEraInCardanoMode
ShelleyBasedEraAlonzo -> toConsensusGenTx $ TxInMode tx AlonzoEraInCardanoMode
ShelleyBasedEraBabbage -> toConsensusGenTx $ TxInMode tx BabbageEraInCardanoMode
ShelleyBasedEraConway -> toConsensusGenTx $ TxInMode tx ConwayEraInCardanoMode
ShelleyBasedEraShelley -> toConsensusGenTx $ TxInMode ShelleyEra tx
ShelleyBasedEraAllegra -> toConsensusGenTx $ TxInMode AllegraEra tx
ShelleyBasedEraMary -> toConsensusGenTx $ TxInMode MaryEra tx
ShelleyBasedEraAlonzo -> toConsensusGenTx $ TxInMode AlonzoEra tx
ShelleyBasedEraBabbage -> toConsensusGenTx $ TxInMode BabbageEra tx
ShelleyBasedEraConway -> toConsensusGenTx $ TxInMode ConwayEra tx

fromGenTxId :: GenTxId CardanoBlock -> TxId
fromGenTxId (Block.GenTxIdShelley (Mempool.ShelleyTxId i)) = fromShelleyTxId i
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,11 @@ import Ouroboros.Network.Protocol.LocalTxSubmission.Type (SubmitResult
import Cardano.Node.Configuration.Logging (LoggingLayer)
import Cardano.Node.Protocol.Types (SomeConsensusProtocol (..))

import Cardano.Api.Shelley (CardanoMode)
import Cardano.CLI.Types.Common (SigningKeyFile)

import Cardano.Api (BlockType (..), ConsensusModeParams (..), EpochSlots (..),
LocalNodeConnectInfo (..), NetworkId (..), PaymentKey, SigningKey, SocketPath,
TxInMode, TxValidationErrorInMode, protocolInfo, submitTxToNodeLocal)
TxInMode, TxValidationErrorInCardanoMode, protocolInfo, submitTxToNodeLocal)
import Cardano.Ledger.Shelley.Genesis (ShelleyGenesis)

type CardanoBlock = Consensus.CardanoBlock StandardCrypto
Expand All @@ -61,8 +60,8 @@ protocolToNetworkId :: SomeConsensusProtocol -> NetworkId
protocolToNetworkId ptcl
= Testnet $ getNetworkMagic $ configBlock $ protocolToTopLevelConfig ptcl

makeLocalConnectInfo :: NetworkId -> SocketPath -> LocalNodeConnectInfo CardanoMode
makeLocalConnectInfo :: NetworkId -> SocketPath -> LocalNodeConnectInfo
makeLocalConnectInfo networkId socketPath
= LocalNodeConnectInfo (CardanoModeParams (EpochSlots 21600)) networkId socketPath

type LocalSubmitTx = (TxInMode CardanoMode -> IO (SubmitResult (TxValidationErrorInMode CardanoMode)))
type LocalSubmitTx = (TxInMode -> IO (SubmitResult TxValidationErrorInCardanoMode))
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import System.Exit

import Data.Aeson as Aeson
import Data.Aeson.Encode.Pretty
import Data.Aeson.Parser as Aeson (json)
import qualified Data.Attoparsec.ByteString as Atto
import qualified Data.Yaml as Yaml (encode)

Expand Down
29 changes: 14 additions & 15 deletions bench/tx-generator/src/Cardano/Benchmarking/Script/Core.hs
Original file line number Diff line number Diff line change
Expand Up @@ -161,14 +161,14 @@ cancelBenchmark n = do
liftIO shutdownAction
waitBenchmarkCore ctl

getLocalConnectInfo :: ActionM (LocalNodeConnectInfo CardanoMode)
getLocalConnectInfo :: ActionM LocalNodeConnectInfo
getLocalConnectInfo = makeLocalConnectInfo <$> getEnvNetworkId <*> getEnvSocketPath

queryEra :: ActionM AnyCardanoEra
queryEra = do
localNodeConnectInfo <- getLocalConnectInfo
chainTip <- liftIO $ getLocalChainTip localNodeConnectInfo
ret <- liftIO $ queryNodeLocalState localNodeConnectInfo (Just $ chainTipToChainPoint chainTip) $ QueryCurrentEra CardanoModeIsMultiEra
ret <- liftIO $ queryNodeLocalState localNodeConnectInfo (Just $ chainTipToChainPoint chainTip) $ QueryCurrentEra

Check warning on line 171 in bench/tx-generator/src/Cardano/Benchmarking/Script/Core.hs

View workflow job for this annotation

GitHub Actions / build

Suggestion in queryEra in module Cardano.Benchmarking.Script.Core: Redundant $ ▫︎ Found: "queryNodeLocalState\n localNodeConnectInfo (Just $ chainTipToChainPoint chainTip)\n $ QueryCurrentEra" ▫︎ Perhaps: "queryNodeLocalState\n localNodeConnectInfo (Just $ chainTipToChainPoint chainTip)\n QueryCurrentEra"
case ret of
Right era -> return era
Left err -> liftTxGenError $ TxGenError $ show err
Expand All @@ -180,11 +180,10 @@ queryRemoteProtocolParameters = do
era <- queryEra
let
callQuery :: forall era.
EraInMode era CardanoMode
-> QueryInEra era (Ledger.PParams (ShelleyLedgerEra era))
QueryInEra era (Ledger.PParams (ShelleyLedgerEra era))
-> ActionM ProtocolParameters
callQuery eraInMode query@(QueryInShelleyBasedEra shelleyEra _) = do
res <- liftIO $ queryNodeLocalState localNodeConnectInfo (Just $ chainTipToChainPoint chainTip) (QueryInEra eraInMode query)
callQuery query@(QueryInShelleyBasedEra shelleyEra _) = do
res <- liftIO $ queryNodeLocalState localNodeConnectInfo (Just $ chainTipToChainPoint chainTip) (QueryInEra query)
case res of
Right (Right pp) -> do
let pp' = fromLedgerPParams shelleyEra pp
Expand All @@ -196,12 +195,12 @@ queryRemoteProtocolParameters = do
Left err -> liftTxGenError $ TxGenError $ show err
case era of
AnyCardanoEra ByronEra -> liftTxGenError $ TxGenError "queryRemoteProtocolParameters Byron not supported"
AnyCardanoEra ShelleyEra -> callQuery ShelleyEraInCardanoMode $ QueryInShelleyBasedEra ShelleyBasedEraShelley QueryProtocolParameters
AnyCardanoEra AllegraEra -> callQuery AllegraEraInCardanoMode $ QueryInShelleyBasedEra ShelleyBasedEraAllegra QueryProtocolParameters
AnyCardanoEra MaryEra -> callQuery MaryEraInCardanoMode $ QueryInShelleyBasedEra ShelleyBasedEraMary QueryProtocolParameters
AnyCardanoEra AlonzoEra -> callQuery AlonzoEraInCardanoMode $ QueryInShelleyBasedEra ShelleyBasedEraAlonzo QueryProtocolParameters
AnyCardanoEra BabbageEra -> callQuery BabbageEraInCardanoMode $ QueryInShelleyBasedEra ShelleyBasedEraBabbage QueryProtocolParameters
AnyCardanoEra ConwayEra -> callQuery ConwayEraInCardanoMode $ QueryInShelleyBasedEra ShelleyBasedEraConway QueryProtocolParameters
AnyCardanoEra ShelleyEra -> callQuery $ QueryInShelleyBasedEra ShelleyBasedEraShelley QueryProtocolParameters
AnyCardanoEra AllegraEra -> callQuery $ QueryInShelleyBasedEra ShelleyBasedEraAllegra QueryProtocolParameters
AnyCardanoEra MaryEra -> callQuery $ QueryInShelleyBasedEra ShelleyBasedEraMary QueryProtocolParameters
AnyCardanoEra AlonzoEra -> callQuery $ QueryInShelleyBasedEra ShelleyBasedEraAlonzo QueryProtocolParameters
AnyCardanoEra BabbageEra -> callQuery $ QueryInShelleyBasedEra ShelleyBasedEraBabbage QueryProtocolParameters
AnyCardanoEra ConwayEra -> callQuery $ QueryInShelleyBasedEra ShelleyBasedEraConway QueryProtocolParameters

getProtocolParameters :: ActionM ProtocolParameters
getProtocolParameters = do
Expand All @@ -219,7 +218,7 @@ waitForEra era = do
liftIO $ threadDelay 1_000_000
waitForEra era

localSubmitTx :: TxInMode CardanoMode -> ActionM (SubmitResult (TxValidationErrorInMode CardanoMode))
localSubmitTx :: TxInMode -> ActionM (SubmitResult TxValidationErrorInCardanoMode)
localSubmitTx tx = do
submit <- getLocalSubmitTx
ret <- liftIO $ submit tx
Expand Down Expand Up @@ -401,10 +400,10 @@ selectCollateralFunds (Just walletName) = do
Nothing -> throwE $ WalletError $ "selectCollateralFunds: collateral: era not supported :" ++ show (cardanoEra @era)
Just p -> return (TxInsCollateral p $ map getFundTxIn collateralFunds, collateralFunds)

dumpToFile :: FilePath -> TxInMode CardanoMode -> ActionM ()
dumpToFile :: FilePath -> TxInMode -> ActionM ()
dumpToFile filePath tx = liftIO $ dumpToFileIO filePath tx

dumpToFileIO :: FilePath -> TxInMode CardanoMode -> IO ()
dumpToFileIO :: FilePath -> TxInMode -> IO ()
dumpToFileIO filePath tx = appendFile filePath ('\n' : show tx)

initWallet :: String -> ActionM ()
Expand Down
4 changes: 2 additions & 2 deletions bench/tx-generator/src/Cardano/TxGenerator/Fund.hs
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ getFundKey (Fund (InAnyCardanoEra _ a)) = _fundSigningKey a
-- | Converting a `TxOutValue` to `Lovelace` requires case analysis.
getFundLovelace :: Fund -> Lovelace
getFundLovelace (Fund (InAnyCardanoEra _ a)) = case _fundVal a of
TxOutAdaOnly _era l -> l
TxOutValue _era v -> selectLovelace v
TxOutValueByron _era l -> l
TxOutValueShelleyBased era v -> selectLovelace $ Api.fromLedgerValue era v

-- TODO: facilitate casting KeyWitnesses between eras -- Note [Era transitions]
-- | The `Fund` alternative is checked against `cardanoEra`, but
Expand Down
2 changes: 1 addition & 1 deletion bench/tx-generator/src/Cardano/TxGenerator/Genesis.hs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ genesisSecureInitialFund networkId genesis srcKey destKey TxGenTxParams{txParamF
Just (_, lovelace) ->
let
txOutValue :: TxOutValue era
txOutValue = mkTxOutValueAdaOnly $ lovelace - txParamFee
txOutValue = lovelaceToTxOutValue (cardanoEra @era) $ lovelace - txParamFee
in genesisExpenditure networkId srcKey destAddr txOutValue txParamFee txParamTTL destKey
where
destAddr = keyAddress @era networkId destKey
Expand Down
2 changes: 1 addition & 1 deletion bench/tx-generator/src/Cardano/TxGenerator/Setup/Plutus.hs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import Cardano.CLI.Read (readFileScriptInAnyLang)
import Cardano.Api
import Cardano.Api.Shelley (PlutusScript (..), ProtocolParameters (..), fromAlonzoExUnits,
protocolParamCostModels, toPlutusData)
import Cardano.Ledger.Alonzo.TxInfo (exBudgetToExUnits)
import Cardano.Ledger.Alonzo.Plutus.TxInfo (exBudgetToExUnits)

import qualified PlutusLedgerApi.V1 as PlutusV1
import qualified PlutusLedgerApi.V2 as PlutusV2
Expand Down
13 changes: 2 additions & 11 deletions bench/tx-generator/src/Cardano/TxGenerator/Utils.hs
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,7 @@ mkTxValidityUpperBound :: forall era. IsShelleyBasedEra era => SlotNo -> TxValid
mkTxValidityUpperBound slotNo =
TxValidityUpperBound (fromJust $ forEraMaybeEon (cardanoEra @era)) (Just slotNo)

-- | `mkTxOutValueAdaOnly` reinterprets the `Either` returned by
-- `multiAssetSupportedInEra` with `TxOutValue` constructors.
mkTxOutValueAdaOnly :: forall era . IsShelleyBasedEra era => Lovelace -> TxOutValue era
mkTxOutValueAdaOnly l = caseByronToAllegraOrMaryEraOnwards
(`TxOutAdaOnly` l)
(\p -> TxOutValue p $ lovelaceToValue l)
(cardanoEra @era)

-- | `mkTxInModeCardano` never uses the `TxInByronSpecial` constructor
-- because its type enforces it being a Shelley-based era.
mkTxInModeCardano :: forall era . IsShelleyBasedEra era => Tx era -> TxInMode CardanoMode
mkTxInModeCardano tx =
TxInMode tx (fromJust $ toEraInMode (cardanoEra @era) CardanoMode)
mkTxInModeCardano :: forall era . IsCardanoEra era => Tx era -> TxInMode
mkTxInModeCardano = TxInMode cardanoEra
1 change: 1 addition & 0 deletions bench/tx-generator/test/Main.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{-# LANGUAGE Trustworthy #-}
{-# OPTIONS_GHC -Wno-all-missed-specialisations #-}

module Main (main) where

Expand Down
5 changes: 3 additions & 2 deletions bench/tx-generator/tx-generator.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,12 @@ library
, aeson-pretty
, async
, attoparsec
, attoparsec-aeson
, base16-bytestring
, bytestring
, cardano-api ^>= 8.29
, cardano-api ^>= 8.31
, cardano-binary
, cardano-cli ^>= 8.13
, cardano-cli ^>= 8.15
, cardano-crypto-class
, cardano-crypto-wrapper
, cardano-data
Expand Down
21 changes: 19 additions & 2 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 2023-09-01T22:19:16Z
, cardano-haskell-packages 2023-10-31T17:10:09Z
, hackage.haskell.org 2023-11-09T23:50:15Z
, cardano-haskell-packages 2023-11-15T14:43:10Z

packages:
cardano-git-rev
Expand Down Expand Up @@ -56,3 +56,20 @@ package bitvec
-- temporary! Please read the section in CONTRIBUTING about updating dependencies.

-- `smtp-mail` should depend on `crypton-connection` rather than `connection`!

source-repository-package
type: git
location: https://github.com/input-output-hk/cardano-api
tag: fa8cf407cbce04d55b88feb91ee98b313932aa92
--sha256: 1ycczk06z84xxfbrg8faln8m6cny1bxbx19lvj6fdx01lyswibyg
subdir:
cardano-api
cardano-api-gen

source-repository-package
type: git
location: https://github.com/input-output-hk/cardano-cli
tag: 29374f199fd80cc13a951e8cef4d0b17bbe0cea2
--sha256: 0wzgw3sr9zi809sq1p3x1kghcw217qyfw8m8b2v77jcn29yimkb7
subdir:
cardano-cli
Loading

0 comments on commit 1f567e9

Please sign in to comment.