From 1f567e97154d78a2bb33cac9905c8fcf1525ea1c Mon Sep 17 00:00:00 2001 From: Javier Sagredo Date: Fri, 10 Nov 2023 13:30:31 +0100 Subject: [PATCH] Integration work for node 8.7.0 --- bench/locli/locli.cabal | 2 +- .../plutus-scripts-bench.cabal | 2 +- .../Benchmarking/GeneratorTx/NodeToNode.hs | 5 +- .../GeneratorTx/SubmissionClient.hs | 12 +- .../Cardano/Benchmarking/OuroborosImports.hs | 7 +- .../src/Cardano/Benchmarking/Script/Aeson.hs | 1 + .../src/Cardano/Benchmarking/Script/Core.hs | 29 +++-- .../src/Cardano/TxGenerator/Fund.hs | 4 +- .../src/Cardano/TxGenerator/Genesis.hs | 2 +- .../src/Cardano/TxGenerator/Setup/Plutus.hs | 2 +- .../src/Cardano/TxGenerator/Utils.hs | 13 +-- bench/tx-generator/test/Main.hs | 1 + bench/tx-generator/tx-generator.cabal | 5 +- cabal.project | 21 +++- cardano-node-chairman/app/Cardano/Chairman.hs | 108 +++++++----------- .../app/Cardano/Chairman/Commands/Run.hs | 2 +- .../cardano-node-chairman.cabal | 3 +- cardano-node/cardano-node.cabal | 10 +- .../src/Cardano/Node/Configuration/POM.hs | 5 +- cardano-node/src/Cardano/Node/Run.hs | 1 + .../src/Cardano/Node/Tracing/Era/Shelley.hs | 4 + .../Cardano/Node/Tracing/Tracers/Startup.hs | 1 + .../Tracing/OrphanInstances/Network.hs | 8 +- .../Tracing/OrphanInstances/Shelley.hs | 6 +- cardano-node/test/Test/Cardano/Node/POM.hs | 6 +- cardano-submit-api/cardano-submit-api.cabal | 6 +- .../src/Cardano/TxSubmit/CLI/Types.hs | 4 +- .../src/Cardano/TxSubmit/Types.hs | 4 +- .../src/Cardano/TxSubmit/Web.hs | 28 ++--- cardano-testnet/cardano-testnet.cabal | 6 +- .../Test/Cli/Babbage/LeadershipSchedule.hs | 3 +- .../Cardano/Testnet/Test/Cli/KesPeriodInfo.hs | 3 +- .../Cardano/Testnet/Test/FoldBlocks.hs | 4 +- cardano-tracer/cardano-tracer.cabal | 2 +- trace-dispatcher/trace-dispatcher.cabal | 2 +- trace-forward/trace-forward.cabal | 4 +- 36 files changed, 156 insertions(+), 170 deletions(-) diff --git a/bench/locli/locli.cabal b/bench/locli/locli.cabal index 41078b85409..20e37185c52 100644 --- a/bench/locli/locli.cabal +++ b/bench/locli/locli.cabal @@ -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 diff --git a/bench/plutus-scripts-bench/plutus-scripts-bench.cabal b/bench/plutus-scripts-bench/plutus-scripts-bench.cabal index 98b8bcda927..70815683b24 100644 --- a/bench/plutus-scripts-bench/plutus-scripts-bench.cabal +++ b/bench/plutus-scripts-bench/plutus-scripts-bench.cabal @@ -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 diff --git a/bench/tx-generator/src/Cardano/Benchmarking/GeneratorTx/NodeToNode.hs b/bench/tx-generator/src/Cardano/Benchmarking/GeneratorTx/NodeToNode.hs index 29af0567d50..5e50d2e56c5 100644 --- a/bench/tx-generator/src/Cardano/Benchmarking/GeneratorTx/NodeToNode.hs +++ b/bench/tx-generator/src/Cardano/Benchmarking/GeneratorTx/NodeToNode.hs @@ -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) @@ -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 = diff --git a/bench/tx-generator/src/Cardano/Benchmarking/GeneratorTx/SubmissionClient.hs b/bench/tx-generator/src/Cardano/Benchmarking/GeneratorTx/SubmissionClient.hs index bc357be6498..94329294c08 100644 --- a/bench/tx-generator/src/Cardano/Benchmarking/GeneratorTx/SubmissionClient.hs +++ b/bench/tx-generator/src/Cardano/Benchmarking/GeneratorTx/SubmissionClient.hs @@ -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 diff --git a/bench/tx-generator/src/Cardano/Benchmarking/OuroborosImports.hs b/bench/tx-generator/src/Cardano/Benchmarking/OuroborosImports.hs index 46d077d3018..6843b2a3d21 100644 --- a/bench/tx-generator/src/Cardano/Benchmarking/OuroborosImports.hs +++ b/bench/tx-generator/src/Cardano/Benchmarking/OuroborosImports.hs @@ -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 @@ -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)) diff --git a/bench/tx-generator/src/Cardano/Benchmarking/Script/Aeson.hs b/bench/tx-generator/src/Cardano/Benchmarking/Script/Aeson.hs index a9da0f5743c..353c2f5c2c1 100644 --- a/bench/tx-generator/src/Cardano/Benchmarking/Script/Aeson.hs +++ b/bench/tx-generator/src/Cardano/Benchmarking/Script/Aeson.hs @@ -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) diff --git a/bench/tx-generator/src/Cardano/Benchmarking/Script/Core.hs b/bench/tx-generator/src/Cardano/Benchmarking/Script/Core.hs index 5e1ea423383..84055bb4364 100644 --- a/bench/tx-generator/src/Cardano/Benchmarking/Script/Core.hs +++ b/bench/tx-generator/src/Cardano/Benchmarking/Script/Core.hs @@ -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 case ret of Right era -> return era Left err -> liftTxGenError $ TxGenError $ show err @@ -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 @@ -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 @@ -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 @@ -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 () diff --git a/bench/tx-generator/src/Cardano/TxGenerator/Fund.hs b/bench/tx-generator/src/Cardano/TxGenerator/Fund.hs index 8819531e7d6..e4ce61a0e80 100644 --- a/bench/tx-generator/src/Cardano/TxGenerator/Fund.hs +++ b/bench/tx-generator/src/Cardano/TxGenerator/Fund.hs @@ -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 diff --git a/bench/tx-generator/src/Cardano/TxGenerator/Genesis.hs b/bench/tx-generator/src/Cardano/TxGenerator/Genesis.hs index a1e0cece136..249a2ee83a0 100644 --- a/bench/tx-generator/src/Cardano/TxGenerator/Genesis.hs +++ b/bench/tx-generator/src/Cardano/TxGenerator/Genesis.hs @@ -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 diff --git a/bench/tx-generator/src/Cardano/TxGenerator/Setup/Plutus.hs b/bench/tx-generator/src/Cardano/TxGenerator/Setup/Plutus.hs index 1ced74cbee2..c9a7ccc41cc 100644 --- a/bench/tx-generator/src/Cardano/TxGenerator/Setup/Plutus.hs +++ b/bench/tx-generator/src/Cardano/TxGenerator/Setup/Plutus.hs @@ -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 diff --git a/bench/tx-generator/src/Cardano/TxGenerator/Utils.hs b/bench/tx-generator/src/Cardano/TxGenerator/Utils.hs index 1bf6560f114..b45013b8534 100644 --- a/bench/tx-generator/src/Cardano/TxGenerator/Utils.hs +++ b/bench/tx-generator/src/Cardano/TxGenerator/Utils.hs @@ -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 diff --git a/bench/tx-generator/test/Main.hs b/bench/tx-generator/test/Main.hs index 25575148f31..2d117778730 100644 --- a/bench/tx-generator/test/Main.hs +++ b/bench/tx-generator/test/Main.hs @@ -1,4 +1,5 @@ {-# LANGUAGE Trustworthy #-} +{-# OPTIONS_GHC -Wno-all-missed-specialisations #-} module Main (main) where diff --git a/bench/tx-generator/tx-generator.cabal b/bench/tx-generator/tx-generator.cabal index 6d9980c4541..cfdf3b6dc6f 100644 --- a/bench/tx-generator/tx-generator.cabal +++ b/bench/tx-generator/tx-generator.cabal @@ -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 diff --git a/cabal.project b/cabal.project index f28fa84116c..ece06661c6d 100644 --- a/cabal.project +++ b/cabal.project @@ -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 @@ -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 diff --git a/cardano-node-chairman/app/Cardano/Chairman.hs b/cardano-node-chairman/app/Cardano/Chairman.hs index 20786c1f2b0..7e9855969db 100644 --- a/cardano-node-chairman/app/Cardano/Chairman.hs +++ b/cardano-node-chairman/app/Cardano/Chairman.hs @@ -18,7 +18,6 @@ import Control.Monad.Class.MonadAsync import Control.Monad.Class.MonadThrow import Control.Monad.Class.MonadTimer.SI import Control.Tracer -import Data.Coerce (coerce) import qualified Data.List as List import Data.Map.Strict (Map) import qualified Data.Map.Strict as Map @@ -27,6 +26,7 @@ import Data.Proxy (Proxy (..)) import Data.Word (Word64) import Ouroboros.Consensus.Block.Abstract +import Ouroboros.Consensus.Cardano.Block import Ouroboros.Consensus.Config.SecurityParam import Ouroboros.Network.AnchoredFragment (Anchor, AnchoredFragment) @@ -56,7 +56,7 @@ chairmanTest :: () -> DiffTime -> BlockNo -> [SocketPath] - -> ConsensusModeParams CardanoMode + -> ConsensusModeParams -> SecurityParam -> IO () chairmanTest tracer nw runningTime progressThreshold socketPaths cModeParams secParam = do @@ -65,8 +65,7 @@ chairmanTest tracer nw runningTime progressThreshold socketPaths cModeParams sec -- Run the chairman and get the final snapshot of the chain from each node. chainsSnapshot <- - obtainGetHeader (consensusModeOnly cModeParams) $ - runChairman + runChairman tracer nw runningTime @@ -78,8 +77,7 @@ chairmanTest tracer nw runningTime progressThreshold socketPaths cModeParams sec -- Test if we achieved consensus consensusSuccess <- either throwIO return $ - obtainHasHeader (consensusModeOnly cModeParams) $ - consensusCondition (consensusModeOnly cModeParams) chainsSnapshot secParam + consensusCondition chainsSnapshot secParam traceWith tracer (show consensusSuccess) @@ -109,14 +107,10 @@ instance Exception ConsensusFailure where -- the intersection of each pair is within K blocks of each tip. consensusCondition :: () - => ConsensusBlockForMode CardanoMode ~ blk - => HasHeader (Header blk) - => ConvertRawHash blk - => ConsensusMode CardanoMode - -> Map PeerId (AnchoredFragment (Header blk)) + => Map PeerId (AnchoredFragment (Header (CardanoBlock StandardCrypto))) -> SecurityParam -> Either ConsensusFailure ConsensusSuccess -consensusCondition cMode chains securityParam = +consensusCondition chains securityParam = -- The (forkTooLong . chainForkPoints) predicate is not transitive. -- As a consequence, we need to check it between all the pairs of chains: let forks = @@ -126,14 +120,14 @@ consensusCondition cMode chains securityParam = ] in case List.find (forkTooLong . snd) forks of Just ((peerid1, peerid2), (intersection, tip1, tip2)) ->do - let apiTip1 = fromConsensusTip cMode $ AF.anchorToTip tip1 - apiTip2 = fromConsensusTip cMode $ AF.anchorToTip tip2 + let apiTip1 = AF.anchorToTip tip1 + apiTip2 = AF.anchorToTip tip2 intersectChainPt = fromAnchor intersection Left $ ConsensusFailure - (peerid1, apiTip1) - (peerid2, apiTip2) + (peerid1, fromConsensusTip apiTip1) + (peerid2, fromConsensusTip apiTip2) intersectChainPt securityParam Nothing -> @@ -144,7 +138,7 @@ consensusCondition cMode chains securityParam = $ List.minimumBy (comparing AF.anchorToBlockNo) [ intersection | (_,(intersection,_,_)) <- forks ]) -- all the chain tips: - [ (peerid, fromConsensusTip cMode $ AF.anchorToTip (AF.headAnchor chain)) + [ (peerid, fromConsensusTip $ AF.anchorToTip (AF.headAnchor chain)) | (peerid, chain) <- Map.toList chains ] where chainForkPoints @@ -244,10 +238,8 @@ progressCondition minBlockNo (ConsensusSuccess _ tips) = do getBlockNo (ChainTip _ _ bNum) = bNum getBlockNo ChainTipAtGenesis = 0 -runChairman :: forall blk. () - => ConsensusBlockForMode CardanoMode ~ blk - => GetHeader (ConsensusBlockForMode CardanoMode) - => Tracer IO String +runChairman :: + Tracer IO String -> NetworkId -- ^ Security parameter, if a fork is deeper than it 'runChairman' -- will throw an exception. @@ -255,15 +247,15 @@ runChairman :: forall blk. () -- ^ Run for this much time. -> [SocketPath] -- ^ Local socket directory - -> ConsensusModeParams CardanoMode + -> ConsensusModeParams -> SecurityParam -> IO (Map SocketPath (AF.AnchoredSeq (WithOrigin SlotNo) - (Anchor (Header blk)) - (Header blk))) + (Anchor (Header (CardanoBlock StandardCrypto))) + (Header (CardanoBlock StandardCrypto)))) runChairman tracer networkId runningTime socketPaths cModeParams secParam = do - let initialChains :: Map SocketPath (AF.AnchoredSeq (WithOrigin SlotNo) (Anchor (Header blk)) (Header blk)) + let initialChains :: Map SocketPath (AF.AnchoredSeq (WithOrigin SlotNo) (Anchor (Header (CardanoBlock StandardCrypto))) (Header (CardanoBlock StandardCrypto))) initialChains = Map.fromList [ (socketPath, AF.Empty AF.AnchorGenesis) | socketPath <- socketPaths] @@ -278,7 +270,7 @@ runChairman tracer networkId runningTime socketPaths cModeParams secParam = do , localNodeSocketPath = socketPath } chairmanChainSyncClient = LocalChainSyncClient $ - chainSyncClient (showTracing tracer) socketPath chainsVar cModeParams secParam + chainSyncClient (showTracing tracer) socketPath chainsVar secParam protocolsInMode = LocalNodeClientProtocols { localChainSyncClient = chairmanChainSyncClient , localTxSubmissionClient = Nothing @@ -310,22 +302,19 @@ addBlock sockPath chainsVar blk = -- | Rollback a single block. If the rollback point is not found, we simply -- error. It should never happen if the security parameter is set up correctly. -rollback :: forall blk. () - => ConsensusBlockForMode CardanoMode ~ blk - => HasHeader (Header blk) - => SocketPath - -> StrictTVar IO (Map SocketPath (AnchoredFragment (Header (ConsensusBlockForMode CardanoMode)))) - -> ConsensusMode CardanoMode +rollback :: + SocketPath + -> StrictTVar IO (Map SocketPath (AnchoredFragment (Header (CardanoBlock StandardCrypto)))) -> ChainPoint -> STM IO () -rollback sockPath chainsVar cMode p = +rollback sockPath chainsVar p = modifyTVar chainsVar (Map.adjust fn sockPath) where - p' :: Point (Header (ConsensusBlockForMode CardanoMode)) - p' = coerce $ toConsensusPointInMode cMode p + p' :: Point (Header (CardanoBlock StandardCrypto)) + p' = toConsensusPointHF p - fn :: AnchoredFragment (Header (ConsensusBlockForMode CardanoMode)) - -> AnchoredFragment (Header (ConsensusBlockForMode CardanoMode)) + fn :: AnchoredFragment (Header (CardanoBlock StandardCrypto)) + -> AnchoredFragment (Header (CardanoBlock StandardCrypto)) fn cf = case AF.rollback p' cf of Nothing -> error "rollback error: rollback beyond chain fragment" Just cf' -> cf' @@ -333,76 +322,57 @@ rollback sockPath chainsVar cMode p = -- Chain-Sync client type ChairmanTrace' = ConsensusSuccess -type ChainVar = StrictTVar IO (Map SocketPath (AnchoredFragment (Header (ConsensusBlockForMode CardanoMode)))) +type ChainVar = StrictTVar IO (Map SocketPath (AnchoredFragment (Header (CardanoBlock StandardCrypto)))) -- | 'chainSyncClient which build chain fragment; on every roll forward it will -- check if there is consensus on immutable chain. chainSyncClient - :: GetHeader (ConsensusBlockForMode CardanoMode) - => Tracer IO ChairmanTrace' + :: Tracer IO ChairmanTrace' -> SocketPath -> ChainVar - -> ConsensusModeParams CardanoMode -> SecurityParam - -> ChainSyncClient (BlockInMode CardanoMode) ChainPoint ChainTip IO () -chainSyncClient tracer sockPath chainsVar cModeP secParam = ChainSyncClient $ pure $ + -> ChainSyncClient BlockInMode ChainPoint ChainTip IO () +chainSyncClient tracer sockPath chainsVar secParam = ChainSyncClient $ pure $ -- Notify the core node about the our latest points at which we are -- synchronised. This client is not persistent and thus it just -- synchronises from the genesis block. A real implementation should send -- a list of points up to a point which is k blocks deep. SendMsgFindIntersect - [fromConsensusPointInMode (consensusModeOnly cModeP) Block.genesisPoint] + [ChainPointAtGenesis] ClientStIntersect { recvMsgIntersectFound = \_ _ -> ChainSyncClient $ pure clientStIdle , recvMsgIntersectNotFound = \ _ -> ChainSyncClient $ pure clientStIdle } where - clientStIdle :: ClientStIdle (BlockInMode CardanoMode) ChainPoint ChainTip IO () + clientStIdle :: ClientStIdle BlockInMode ChainPoint ChainTip IO () clientStIdle = SendMsgRequestNext clientStNext (pure clientStNext) - clientStNext :: ClientStNext (BlockInMode CardanoMode) ChainPoint ChainTip IO () + clientStNext :: ClientStNext BlockInMode ChainPoint ChainTip IO () clientStNext = ClientStNext { recvMsgRollForward = \blk _tip -> ChainSyncClient $ do -- add block & check if there is consensus on immutable chain -- trace the decision or error res <- atomically $ do addBlock sockPath chainsVar $ toConsensusBlock blk - obtainHasHeader (consensusModeOnly cModeP) $ checkConsensus (consensusModeOnly cModeP) chainsVar secParam + checkConsensus chainsVar secParam traceWith tracer res pure clientStIdle , recvMsgRollBackward = \point _tip -> ChainSyncClient $ do -- rollback & check res <- atomically $ do - rollback sockPath chainsVar (consensusModeOnly cModeP) point - obtainHasHeader (consensusModeOnly cModeP) $ checkConsensus (consensusModeOnly cModeP) chainsVar secParam + rollback sockPath chainsVar point + checkConsensus chainsVar secParam traceWith tracer res pure clientStIdle } -- Helpers -obtainHasHeader - :: ConsensusBlockForMode CardanoMode ~ blk - => ConsensusMode CardanoMode - -> ((HasHeader (Header blk), ConvertRawHash (ConsensusBlockForMode CardanoMode)) => a) - -> a -obtainHasHeader CardanoMode f = f - -obtainGetHeader - :: ConsensusMode CardanoMode - -> ( (GetHeader (ConsensusBlockForMode CardanoMode) - ) => a) - -> a -obtainGetHeader CardanoMode f = f - -- | Check that all nodes agree with each other, within the security parameter. checkConsensus - :: HasHeader (Header (ConsensusBlockForMode CardanoMode)) - => ConvertRawHash (ConsensusBlockForMode CardanoMode) - => ConsensusMode CardanoMode - -> ChainVar + :: ChainVar -> SecurityParam -> STM IO ConsensusSuccess -checkConsensus cMode chainsVar secParam = do +checkConsensus chainsVar secParam = do chainsSnapshot <- readTVar chainsVar - either throwIO return $ consensusCondition cMode chainsSnapshot secParam + either throwIO return $ consensusCondition chainsSnapshot secParam diff --git a/cardano-node-chairman/app/Cardano/Chairman/Commands/Run.hs b/cardano-node-chairman/app/Cardano/Chairman/Commands/Run.hs index 786276a3796..1157e47d380 100644 --- a/cardano-node-chairman/app/Cardano/Chairman/Commands/Run.hs +++ b/cardano-node-chairman/app/Cardano/Chairman/Commands/Run.hs @@ -139,7 +139,7 @@ run RunOpts return () where - getConsensusMode :: SecurityParam -> NodeProtocolConfiguration -> ConsensusModeParams CardanoMode + getConsensusMode :: SecurityParam -> NodeProtocolConfiguration -> ConsensusModeParams getConsensusMode (SecurityParam k) ncProtocolConfig = case ncProtocolConfig of NodeProtocolConfigurationCardano{} -> diff --git a/cardano-node-chairman/cardano-node-chairman.cabal b/cardano-node-chairman/cardano-node-chairman.cabal index 3b784154049..3266bc0b13c 100644 --- a/cardano-node-chairman/cardano-node-chairman.cabal +++ b/cardano-node-chairman/cardano-node-chairman.cabal @@ -51,6 +51,7 @@ executable cardano-node-chairman , io-classes , optparse-applicative-fork , ouroboros-consensus + , ouroboros-consensus-cardano , ouroboros-network-api , ouroboros-network-protocols , strict-stm @@ -88,5 +89,5 @@ test-suite chairman-tests ghc-options: -threaded -rtsopts -with-rtsopts=-N -with-rtsopts=-T build-tool-depends: cardano-node:cardano-node - , cardano-cli:cardano-cli ^>= 8.13 + , cardano-cli:cardano-cli ^>= 8.15 , cardano-node-chairman:cardano-node-chairman diff --git a/cardano-node/cardano-node.cabal b/cardano-node/cardano-node.cabal index 9ed6baa88a8..359bb284dde 100644 --- a/cardano-node/cardano-node.cabal +++ b/cardano-node/cardano-node.cabal @@ -137,7 +137,7 @@ library , async , base16-bytestring , bytestring - , cardano-api ^>= 8.29 + , cardano-api ^>= 8.31 , cardano-crypto-class , cardano-crypto-wrapper , cardano-git-rev @@ -177,13 +177,13 @@ library , nothunks , optparse-applicative-fork >= 0.18.1 , ouroboros-consensus ^>= 0.13 - , ouroboros-consensus-cardano ^>= 0.11 - , ouroboros-consensus-diffusion ^>= 0.8 + , ouroboros-consensus-cardano ^>= 0.12 + , ouroboros-consensus-diffusion ^>= 0.9 , ouroboros-consensus-protocol , ouroboros-network-api - , ouroboros-network ^>= 0.9.1 + , ouroboros-network ^>= 0.10 , ouroboros-network-framework - , ouroboros-network-protocols < 0.5.3.0 + , ouroboros-network-protocols ^>= 0.6 , prettyprinter , prettyprinter-ansi-terminal , psqueues diff --git a/cardano-node/src/Cardano/Node/Configuration/POM.hs b/cardano-node/src/Cardano/Node/Configuration/POM.hs index fac39fac8db..72e329f3fc4 100644 --- a/cardano-node/src/Cardano/Node/Configuration/POM.hs +++ b/cardano-node/src/Cardano/Node/Configuration/POM.hs @@ -45,6 +45,7 @@ import Cardano.Node.Handlers.Shutdown import Cardano.Node.Protocol.Types (Protocol (..)) import Cardano.Node.Types import Cardano.Tracing.Config +import Cardano.Tracing.OrphanInstances.Network () import Ouroboros.Consensus.Mempool (MempoolCapacityBytes (..), MempoolCapacityBytesOverride (..)) import qualified Ouroboros.Consensus.Node as Consensus (NetworkP2PMode (..)) @@ -298,7 +299,7 @@ instance FromJSON PartialNodeConfiguration where -- Peer Sharing -- DISABLED BY DEFAULT - pncPeerSharing <- Last <$> v .:? "PeerSharing" .!= Just NoPeerSharing + pncPeerSharing <- Last <$> v .:? "PeerSharing" .!= Just PeerSharingDisabled pure PartialNodeConfiguration { pncProtocolConfig @@ -505,7 +506,7 @@ defaultPartialNodeConfiguration = , pncTargetNumberOfEstablishedBigLedgerPeers = Last (Just 10) , pncTargetNumberOfActiveBigLedgerPeers = Last (Just 5) , pncEnableP2P = Last (Just DisabledP2PMode) - , pncPeerSharing = Last (Just NoPeerSharing) + , pncPeerSharing = Last (Just PeerSharingDisabled) } lastOption :: Parser a -> Parser (Last a) diff --git a/cardano-node/src/Cardano/Node/Run.hs b/cardano-node/src/Cardano/Node/Run.hs index f71ac5c73d8..cdc1e7b1673 100644 --- a/cardano-node/src/Cardano/Node/Run.hs +++ b/cardano-node/src/Cardano/Node/Run.hs @@ -480,6 +480,7 @@ handleSimpleNode blockType runP p2pMode tracers nc onKernel = do , srnEnableInDevelopmentVersions = ncExperimentalProtocolsEnabled nc , srnTraceChainDB = chainDBTracer tracers , srnMaybeMempoolCapacityOverride = ncMaybeMempoolCapacityOverride nc + , srnChainSyncTimeout = Nothing } DisabledP2PMode -> do nt <- TopologyNonP2P.readTopologyFileOrError nc diff --git a/cardano-node/src/Cardano/Node/Tracing/Era/Shelley.hs b/cardano-node/src/Cardano/Node/Tracing/Era/Shelley.hs index 0876fd65df5..2b3638e88c1 100644 --- a/cardano-node/src/Cardano/Node/Tracing/Era/Shelley.hs +++ b/cardano-node/src/Cardano/Node/Tracing/Era/Shelley.hs @@ -1139,6 +1139,10 @@ instance mconcat [ "kind" .= String "InvalidPrevGovActionIdsInProposals" , "proposals" .= proposals ] + forMachine _ (Conway.VotingOnExpiredGovAction actions) = + mconcat [ "kind" .= String "VotingOnExpiredGovAction" + , "action" .= actions + ] instance ( Consensus.ShelleyBasedEra era diff --git a/cardano-node/src/Cardano/Node/Tracing/Tracers/Startup.hs b/cardano-node/src/Cardano/Node/Tracing/Tracers/Startup.hs index 6f697cdff69..0c6481ecea9 100644 --- a/cardano-node/src/Cardano/Node/Tracing/Tracers/Startup.hs +++ b/cardano-node/src/Cardano/Node/Tracing/Tracers/Startup.hs @@ -446,6 +446,7 @@ nodeToNodeVersionToInt = \case NodeToNodeV_10 -> 10 NodeToNodeV_11 -> 11 NodeToNodeV_12 -> 12 + NodeToNodeV_13 -> 13 -- | Pretty print 'StartupInfoTrace' -- diff --git a/cardano-node/src/Cardano/Tracing/OrphanInstances/Network.hs b/cardano-node/src/Cardano/Tracing/OrphanInstances/Network.hs index dcaf75bd6fb..ea67db7e618 100644 --- a/cardano-node/src/Cardano/Tracing/OrphanInstances/Network.hs +++ b/cardano-node/src/Cardano/Tracing/OrphanInstances/Network.hs @@ -32,6 +32,7 @@ import qualified Data.Set as Set import Data.Text (Text, pack) import qualified Data.Text as Text import qualified Data.Text.Encoding as Text +import qualified Text.Read as Text import Network.TypedProtocol.Codec (AnyMessageAndAgency (..)) import Network.TypedProtocol.Core (PeerHasAgency (..)) @@ -2001,6 +2002,7 @@ instance ToJSON NodeToNodeVersion where toJSON NodeToNodeV_10 = Number 10 toJSON NodeToNodeV_11 = Number 11 toJSON NodeToNodeV_12 = Number 12 + toJSON NodeToNodeV_13 = Number 13 instance FromJSON NodeToNodeVersion where parseJSON (Number 7) = return NodeToNodeV_7 @@ -2008,6 +2010,8 @@ instance FromJSON NodeToNodeVersion where parseJSON (Number 9) = return NodeToNodeV_9 parseJSON (Number 10) = return NodeToNodeV_10 parseJSON (Number 11) = return NodeToNodeV_11 + parseJSON (Number 12) = return NodeToNodeV_12 + parseJSON (Number 13) = return NodeToNodeV_13 parseJSON (Number x) = fail ("FromJSON.NodeToNodeVersion: unsupported node-to-node protocol version " ++ show x) parseJSON x = fail ("FromJSON.NodeToNodeVersion: error parsing NodeToNodeVersion: " ++ show x) @@ -2415,8 +2419,8 @@ instance ToJSON addr ] instance FromJSON PeerSharing where - parseJSON = withText "PeerSharing" $ \t -> - case readMaybe (Text.unpack t) of + parseJSON = Aeson.withText "PeerSharing" $ \t -> + case Text.readMaybe (Text.unpack t) of Nothing -> fail ("PeerSharing.parseJSON: could not parse value: " ++ Text.unpack t) Just ps -> return ps diff --git a/cardano-node/src/Cardano/Tracing/OrphanInstances/Shelley.hs b/cardano-node/src/Cardano/Tracing/OrphanInstances/Shelley.hs index 8b182a16f91..d359c75ff88 100644 --- a/cardano-node/src/Cardano/Tracing/OrphanInstances/Shelley.hs +++ b/cardano-node/src/Cardano/Tracing/OrphanInstances/Shelley.hs @@ -33,7 +33,7 @@ import Cardano.Ledger.Alonzo.Rules (AlonzoBbodyPredFailure (..), Alonz AlonzoUtxosPredFailure, AlonzoUtxowPredFailure (..)) import qualified Cardano.Ledger.Alonzo.Rules as Alonzo import qualified Cardano.Ledger.Alonzo.Tx as Alonzo -import qualified Cardano.Ledger.Alonzo.TxInfo as Alonzo +import qualified Cardano.Ledger.Alonzo.Plutus.TxInfo as Alonzo import qualified Cardano.Ledger.Api as Ledger import Cardano.Ledger.Babbage.Rules (BabbageUtxoPredFailure, BabbageUtxowPredFailure) import qualified Cardano.Ledger.Babbage.Rules as Babbage @@ -380,6 +380,10 @@ instance Ledger.EraPParams era => ToObject (Conway.ConwayGovPredFailure era) whe mconcat [ "kind" .= String "InvalidPrevGovActionIdsInProposals" , "proposals" .= proposals ] + toObject _ (Conway.VotingOnExpiredGovAction actions) = + mconcat [ "kind" .= String "VotingOnExpiredGovAction" + , "action" .= actions + ] instance ( Core.Crypto (Consensus.EraCrypto era) diff --git a/cardano-node/test/Test/Cardano/Node/POM.hs b/cardano-node/test/Test/Cardano/Node/POM.hs index dd1d92a6c9c..2e9fb03de0e 100644 --- a/cardano-node/test/Test/Cardano/Node/POM.hs +++ b/cardano-node/test/Test/Cardano/Node/POM.hs @@ -140,7 +140,7 @@ testPartialYamlConfig = , pncTargetNumberOfEstablishedBigLedgerPeers = mempty , pncTargetNumberOfActiveBigLedgerPeers = mempty , pncEnableP2P = Last (Just DisabledP2PMode) - , pncPeerSharing = Last (Just NoPeerSharing) + , pncPeerSharing = Last (Just PeerSharingDisabled) } -- | Example partial configuration theoretically created @@ -178,7 +178,7 @@ testPartialCliConfig = , pncTargetNumberOfEstablishedBigLedgerPeers = mempty , pncTargetNumberOfActiveBigLedgerPeers = mempty , pncEnableP2P = Last (Just DisabledP2PMode) - , pncPeerSharing = Last (Just NoPeerSharing) + , pncPeerSharing = Last (Just PeerSharingDisabled) } -- | Expected final NodeConfiguration @@ -222,7 +222,7 @@ eExpectedConfig = do , ncTargetNumberOfEstablishedBigLedgerPeers = 10 , ncTargetNumberOfActiveBigLedgerPeers = 5 , ncEnableP2P = SomeNetworkP2PMode Consensus.DisabledP2PMode - , ncPeerSharing = NoPeerSharing + , ncPeerSharing = PeerSharingDisabled } -- ----------------------------------------------------------------------------- diff --git a/cardano-submit-api/cardano-submit-api.cabal b/cardano-submit-api/cardano-submit-api.cabal index 071f9de240a..2163fc2d435 100644 --- a/cardano-submit-api/cardano-submit-api.cabal +++ b/cardano-submit-api/cardano-submit-api.cabal @@ -39,9 +39,9 @@ library , aeson , async , bytestring - , cardano-api ^>= 8.29 + , cardano-api ^>= 8.31 , cardano-binary - , cardano-cli ^>= 8.13 + , cardano-cli ^>= 8.15 , cardano-crypto-class ^>= 2.1.2 , cardano-ledger-byron ^>= 1.0 , formatting @@ -51,7 +51,7 @@ library , network , optparse-applicative-fork , ouroboros-consensus-cardano - , ouroboros-network ^>= 0.9.1 + , ouroboros-network ^>= 0.10 , ouroboros-network-protocols , prometheus >= 2.2.4 , servant diff --git a/cardano-submit-api/src/Cardano/TxSubmit/CLI/Types.hs b/cardano-submit-api/src/Cardano/TxSubmit/CLI/Types.hs index cf1f58cec29..c6579a301f8 100644 --- a/cardano-submit-api/src/Cardano/TxSubmit/CLI/Types.hs +++ b/cardano-submit-api/src/Cardano/TxSubmit/CLI/Types.hs @@ -4,13 +4,13 @@ module Cardano.TxSubmit.CLI.Types , TxSubmitNodeParams (..) ) where -import Cardano.Api (AnyConsensusModeParams, NetworkId (..), SocketPath) +import Cardano.Api (ConsensusModeParams, NetworkId (..), SocketPath) import Cardano.TxSubmit.Rest.Types (WebserverConfig) -- | The product type of all command line arguments data TxSubmitNodeParams = TxSubmitNodeParams { tspConfigFile :: !ConfigFile - , tspProtocol :: !AnyConsensusModeParams + , tspProtocol :: !ConsensusModeParams , tspNetworkId :: !NetworkId , tspSocketPath :: !SocketPath , tspWebserverConfig :: !WebserverConfig diff --git a/cardano-submit-api/src/Cardano/TxSubmit/Types.hs b/cardano-submit-api/src/Cardano/TxSubmit/Types.hs index 14f9ed9349f..9b3d20222fb 100644 --- a/cardano-submit-api/src/Cardano/TxSubmit/Types.hs +++ b/cardano-submit-api/src/Cardano/TxSubmit/Types.hs @@ -16,7 +16,7 @@ module Cardano.TxSubmit.Types , renderTxCmdError ) where -import Cardano.Api (AnyCardanoEra, AnyConsensusMode (..), Error (..), TxId, textShow) +import Cardano.Api (Error (..), TxId, textShow) import Cardano.Binary (DecoderError) import Data.Aeson (ToJSON (..), Value (..)) import Data.ByteString.Char8 (ByteString) @@ -54,7 +54,6 @@ newtype EnvSocketError = CliEnvVarLookup Text deriving (Eq, Show) data TxCmdError = TxCmdSocketEnvError EnvSocketError - | TxCmdEraConsensusModeMismatch !AnyConsensusMode !AnyCardanoEra | TxCmdTxReadError !RawCborDecodeError | TxCmdTxSubmitError !Text | TxCmdTxSubmitErrorEraMismatch !EraMismatch @@ -67,7 +66,6 @@ convertJson = String . renderTxSubmitWebApiError renderTxCmdError :: TxCmdError -> Text renderTxCmdError (TxCmdSocketEnvError socketError) = "socket env error " <> textShow socketError -renderTxCmdError (TxCmdEraConsensusModeMismatch mode era) = "era consensus mode mismatch" <> textShow mode <> " " <> textShow era renderTxCmdError (TxCmdTxReadError envelopeError) = "transaction read error " <> textShow envelopeError renderTxCmdError (TxCmdTxSubmitError msg) = "transaction submit error " <> msg renderTxCmdError (TxCmdTxSubmitErrorEraMismatch eraMismatch) = "transaction submit era mismatch" <> textShow eraMismatch diff --git a/cardano-submit-api/src/Cardano/TxSubmit/Web.hs b/cardano-submit-api/src/Cardano/TxSubmit/Web.hs index 9b7c2e59797..59c39325ef5 100644 --- a/cardano-submit-api/src/Cardano/TxSubmit/Web.hs +++ b/cardano-submit-api/src/Cardano/TxSubmit/Web.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE GADTs #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE RankNTypes #-} @@ -11,14 +12,13 @@ module Cardano.TxSubmit.Web ) where import Cardano.Api (AllegraEra, AnyCardanoEra (AnyCardanoEra), - AnyConsensusMode (AnyConsensusMode), AnyConsensusModeParams (..), AsType (..), + AsType (..), ConsensusModeParams (..), CardanoEra (..), Error (..), FromSomeType (..), HasTypeProxy (AsType), InAnyCardanoEra (..), LocalNodeConnectInfo (LocalNodeConnectInfo, localConsensusModeParams, localNodeNetworkId, localNodeSocketPath), NetworkId, SerialiseAsCBOR (..), ShelleyEra, SocketPath, ToJSON, Tx, TxId (..), - TxInMode (TxInMode), - TxValidationErrorInMode (TxValidationEraMismatch, TxValidationErrorInMode), - consensusModeOnly, getTxBody, getTxId, submitTxToNodeLocal, toEraInMode) + TxInMode (TxInMode), TxValidationErrorInCardanoMode (..), + getTxBody, getTxId, submitTxToNodeLocal, IsCardanoEra (..)) import Cardano.Binary (DecoderError (..)) import Cardano.BM.Trace (Trace, logInfo) @@ -27,7 +27,7 @@ import Cardano.TxSubmit.Metrics (TxSubmitMetrics (..)) import Cardano.TxSubmit.Rest.Types (WebserverConfig (..), toWarpSettings) import qualified Cardano.TxSubmit.Rest.Web as Web import Cardano.TxSubmit.Types (EnvSocketError (..), RawCborDecodeError (..), - TxCmdError (TxCmdEraConsensusModeMismatch, TxCmdTxReadError, TxCmdTxSubmitError, TxCmdTxSubmitErrorEraMismatch), + TxCmdError (TxCmdTxReadError, TxCmdTxSubmitError, TxCmdTxSubmitErrorEraMismatch), TxSubmitApi, TxSubmitApiRecord (..), TxSubmitWebApiError (TxSubmitFail), renderTxCmdError) import Cardano.TxSubmit.Util (logException) @@ -74,7 +74,7 @@ runTxSubmitServer :: Trace IO Text -> TxSubmitMetrics -> WebserverConfig - -> AnyConsensusModeParams + -> ConsensusModeParams -> NetworkId -> SocketPath -> IO () @@ -86,7 +86,7 @@ runTxSubmitServer trace metrics webserverConfig protocol networkId socketPath = txSubmitApp :: Trace IO Text -> TxSubmitMetrics - -> AnyConsensusModeParams + -> ConsensusModeParams -> NetworkId -> SocketPath -> Application @@ -128,21 +128,17 @@ readByteStringTx = firstExceptT TxCmdTxReadError . hoistEither . deserialiseAnyO txSubmitPost :: Trace IO Text -> TxSubmitMetrics - -> AnyConsensusModeParams + -> ConsensusModeParams -> NetworkId -> SocketPath -> ByteString -> Handler TxId -txSubmitPost trace metrics (AnyConsensusModeParams cModeParams) networkId socketPath txBytes = +txSubmitPost trace metrics p@(CardanoModeParams cModeParams) networkId socketPath txBytes = handle $ do InAnyCardanoEra era tx <- readByteStringTx txBytes - let cMode = AnyConsensusMode $ consensusModeOnly cModeParams - eraInMode <- hoistMaybe - (TxCmdEraConsensusModeMismatch cMode (AnyCardanoEra era)) - (toEraInMode era $ consensusModeOnly cModeParams) - let txInMode = TxInMode tx eraInMode + let txInMode = TxInMode era tx localNodeConnInfo = LocalNodeConnectInfo - { localConsensusModeParams = cModeParams + { localConsensusModeParams = p , localNodeNetworkId = networkId , localNodeSocketPath = socketPath } @@ -154,7 +150,7 @@ txSubmitPost trace metrics (AnyConsensusModeParams cModeParams) networkId socket return $ getTxId (getTxBody tx) Net.Tx.SubmitFail reason -> case reason of - TxValidationErrorInMode err _eraInMode -> left . TxCmdTxSubmitError . T.pack $ show err + TxValidationErrorInCardanoMode err -> left . TxCmdTxSubmitError . T.pack $ show err TxValidationEraMismatch mismatchErr -> left $ TxCmdTxSubmitErrorEraMismatch mismatchErr where handle :: ExceptT TxCmdError IO TxId -> Handler TxId diff --git a/cardano-testnet/cardano-testnet.cabal b/cardano-testnet/cardano-testnet.cabal index f2462db9285..292ce3fea95 100644 --- a/cardano-testnet/cardano-testnet.cabal +++ b/cardano-testnet/cardano-testnet.cabal @@ -34,8 +34,8 @@ library build-depends: aeson , ansi-terminal , bytestring - , cardano-api ^>= 8.29 - , cardano-cli ^>= 8.13 + , cardano-api ^>= 8.31 + , cardano-cli ^>= 8.15 , cardano-crypto-class , cardano-crypto-wrapper , cardano-ledger-alonzo @@ -55,7 +55,7 @@ library , hedgehog-extras ^>= 0.4.7.0 , mtl , optparse-applicative-fork - , ouroboros-network ^>= 0.9.1 + , ouroboros-network ^>= 0.10 , process , resourcet , safe-exceptions diff --git a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Babbage/LeadershipSchedule.hs b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Babbage/LeadershipSchedule.hs index 7c6f311dac5..e4c8d66a43f 100644 --- a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Babbage/LeadershipSchedule.hs +++ b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Babbage/LeadershipSchedule.hs @@ -83,8 +83,7 @@ hprop_leadershipSchedule = H.integrationRetryWorkspace 2 "babbage-leadership-sch execConfig <- H.headM (poolSprockets tr) >>= H.mkExecConfig tempBaseAbsPath - sbe <- case cardanoEraStyle era of - ShelleyBasedEra era' -> return era' + let sbe = shelleyBasedEra @BabbageEra work <- H.note tempAbsPath' ----------------Need to register an SPO------------------ diff --git a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/KesPeriodInfo.hs b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/KesPeriodInfo.hs index 39afde93556..bdc679b912d 100644 --- a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/KesPeriodInfo.hs +++ b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/KesPeriodInfo.hs @@ -66,8 +66,7 @@ hprop_kes_period_info = H.integrationRetryWorkspace 2 "kes-period-info" $ \tempA , cardanoNodeEra = AnyCardanoEra era -- TODO: We should only support the latest era and the upcoming era } - sbe <- case cardanoEraStyle era of - ShelleyBasedEra era' -> return era' + let sbe = shelleyBasedEra @BabbageEra runTime@TestnetRuntime { testnetMagic } <- cardanoTestnet cTestnetOptions conf diff --git a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/FoldBlocks.hs b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/FoldBlocks.hs index cf4839bf446..2103a039e57 100644 --- a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/FoldBlocks.hs +++ b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/FoldBlocks.hs @@ -1,4 +1,5 @@ {-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE TupleSections #-} module Cardano.Testnet.Test.FoldBlocks where @@ -67,7 +68,8 @@ prop_foldBlocks = H.integrationRetryWorkspace 2 "foldblocks" $ \tempAbsBasePath' -- permanent (= older than the k parameter) blocks created. In -- that case we simply restart `foldBlocks` again. forever $ do - let handler _env _ledgerState _ledgerEvents _blockInCardanoMode _ = IO.putMVar lock () + let handler :: Env -> LedgerState -> [LedgerEvent] -> BlockInMode CardanoMode -> () -> IO ((), FoldStatus) + handler _env _ledgerState _ledgerEvents _blockInCardanoMode _ = (, ContinueFold) <$> IO.putMVar lock () e <- runExceptT (C.foldBlocks (File configFile) (C.File socketPathAbs) C.QuickValidation () handler) either (throw . FoldBlocksException) (\_ -> pure ()) e link a -- Throw async thread's exceptions in main thread diff --git a/cardano-tracer/cardano-tracer.cabal b/cardano-tracer/cardano-tracer.cabal index 7e75618dc43..81a18d97958 100644 --- a/cardano-tracer/cardano-tracer.cabal +++ b/cardano-tracer/cardano-tracer.cabal @@ -146,7 +146,7 @@ library , filepath , mime-mail , optparse-applicative - , ouroboros-network ^>= 0.9.1 + , ouroboros-network ^>= 0.10 , ouroboros-network-api , ouroboros-network-framework , signal diff --git a/trace-dispatcher/trace-dispatcher.cabal b/trace-dispatcher/trace-dispatcher.cabal index 882e21eedba..9ad79d75a87 100644 --- a/trace-dispatcher/trace-dispatcher.cabal +++ b/trace-dispatcher/trace-dispatcher.cabal @@ -60,7 +60,7 @@ library , hostname , network , optparse-applicative-fork - , ouroboros-network ^>= 0.9.1 + , ouroboros-network ^>= 0.10 , ouroboros-network-api , ouroboros-network-framework , serialise diff --git a/trace-forward/trace-forward.cabal b/trace-forward/trace-forward.cabal index 4a590f193e4..b7ef51915ae 100644 --- a/trace-forward/trace-forward.cabal +++ b/trace-forward/trace-forward.cabal @@ -64,8 +64,8 @@ library , deepseq , extra , io-classes - , ouroboros-network-api ^>= 0.5.1 - , ouroboros-network-framework ^>= 0.9 + , ouroboros-network-api ^>= 0.6 + , ouroboros-network-framework >= 0.9 && < 0.11 , serialise , stm , text