From a213b6efe3b6a494957e1ea466bba10ce591e727 Mon Sep 17 00:00:00 2001 From: Jordan Millar Date: Fri, 6 Sep 2024 16:08:57 -0400 Subject: [PATCH 01/15] Bump dependencies for 9.2 release --- bench/cardano-profile/cardano-profile.cabal | 1 - bench/locli/locli.cabal | 2 +- .../plutus-scripts-bench.cabal | 8 ++++---- bench/tx-generator/tx-generator.cabal | 4 ++-- cabal.project | 7 ++++--- cardano-node-chairman/cardano-node-chairman.cabal | 2 +- cardano-node/cardano-node.cabal | 10 +++++----- cardano-submit-api/cardano-submit-api.cabal | 6 +++--- cardano-testnet/cardano-testnet.cabal | 14 +++++++------- cardano-tracer/cardano-tracer.cabal | 2 +- flake.lock | 6 +++--- trace-dispatcher/trace-dispatcher.cabal | 2 +- trace-forward/trace-forward.cabal | 2 +- 13 files changed, 33 insertions(+), 33 deletions(-) diff --git a/bench/cardano-profile/cardano-profile.cabal b/bench/cardano-profile/cardano-profile.cabal index bedf3e0799f..22f906381d4 100644 --- a/bench/cardano-profile/cardano-profile.cabal +++ b/bench/cardano-profile/cardano-profile.cabal @@ -13,7 +13,6 @@ license: Apache-2.0 license-files: LICENSE NOTICE build-type: Simple -extra-source-files: README.md data-files: data/all-profiles.json data/ci-test-bage.json data/genesis/epoch-timeline.json diff --git a/bench/locli/locli.cabal b/bench/locli/locli.cabal index fbdf3952519..e5f1bd3b52d 100644 --- a/bench/locli/locli.cabal +++ b/bench/locli/locli.cabal @@ -120,7 +120,7 @@ library , optparse-generic , ouroboros-consensus -- for Data.SOP.Strict: - , ouroboros-network ^>= 0.16.1 + , ouroboros-network ^>= 0.17 , 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 1adb404e90e..0ed523a1e8a 100644 --- a/bench/plutus-scripts-bench/plutus-scripts-bench.cabal +++ b/bench/plutus-scripts-bench/plutus-scripts-bench.cabal @@ -80,10 +80,10 @@ library -- IOG dependencies -------------------------- build-depends: - , cardano-api ^>=9.2 - , plutus-ledger-api ^>=1.31 - , plutus-tx ^>=1.31 - , plutus-tx-plugin ^>=1.31 + , cardano-api ^>=9.3 + , plutus-ledger-api ^>=1.32 + , plutus-tx ^>=1.32 + , plutus-tx-plugin ^>=1.32 ------------------------ -- Non-IOG dependencies diff --git a/bench/tx-generator/tx-generator.cabal b/bench/tx-generator/tx-generator.cabal index 0fa2a7bf2eb..c1fbc0cd1ed 100644 --- a/bench/tx-generator/tx-generator.cabal +++ b/bench/tx-generator/tx-generator.cabal @@ -106,9 +106,9 @@ library , attoparsec-aeson , base16-bytestring , bytestring - , cardano-api ^>= 9.2 + , cardano-api ^>= 9.3 , cardano-binary - , cardano-cli ^>= 9.3 + , cardano-cli ^>= 9.4 , cardano-crypto-class , cardano-crypto-wrapper , cardano-data diff --git a/cabal.project b/cabal.project index e64c096993b..d56680584e1 100644 --- a/cabal.project +++ b/cabal.project @@ -14,7 +14,7 @@ repository cardano-haskell-packages -- you need to run if you change them index-state: , hackage.haskell.org 2024-08-20T21:35:22Z - , cardano-haskell-packages 2024-08-18T22:35:14Z + , cardano-haskell-packages 2024-09-06T15:28:20Z packages: cardano-node @@ -34,8 +34,8 @@ packages: extra-packages: Cabal -program-options - ghc-options: -Werror +-- program-options +-- ghc-options: -Werror test-show-details: direct @@ -72,3 +72,4 @@ allow-newer: -- IMPORTANT -- Do NOT add more source-repository-package stanzas here unless they are strictly -- temporary! Please read the section in CONTRIBUTING about updating dependencies. + diff --git a/cardano-node-chairman/cardano-node-chairman.cabal b/cardano-node-chairman/cardano-node-chairman.cabal index 4150ad6e125..77b6251661a 100644 --- a/cardano-node-chairman/cardano-node-chairman.cabal +++ b/cardano-node-chairman/cardano-node-chairman.cabal @@ -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 ^>= 9.3 + , cardano-cli:cardano-cli ^>= 9.4 , cardano-node-chairman:cardano-node-chairman diff --git a/cardano-node/cardano-node.cabal b/cardano-node/cardano-node.cabal index 3b538359bf6..d8ec0334dc5 100644 --- a/cardano-node/cardano-node.cabal +++ b/cardano-node/cardano-node.cabal @@ -145,7 +145,7 @@ library , async , base16-bytestring , bytestring - , cardano-api ^>= 9.2 + , cardano-api ^>= 9.3 , cardano-crypto-class , cardano-crypto-wrapper , cardano-git-rev ^>=0.2.2 @@ -187,13 +187,13 @@ library , nothunks , optparse-applicative-fork >= 0.18.1 , ouroboros-consensus ^>= 0.20 - , ouroboros-consensus-cardano ^>= 0.18 + , ouroboros-consensus-cardano ^>= 0.19 , ouroboros-consensus-diffusion ^>= 0.17 , ouroboros-consensus-protocol - , ouroboros-network-api ^>= 0.7.3 - , ouroboros-network ^>= 0.16.1 + , ouroboros-network-api ^>= 0.9 + , ouroboros-network ^>= 0.17 , ouroboros-network-framework - , ouroboros-network-protocols ^>= 0.9 + , ouroboros-network-protocols ^>= 0.10 , prettyprinter , prettyprinter-ansi-terminal , psqueues diff --git a/cardano-submit-api/cardano-submit-api.cabal b/cardano-submit-api/cardano-submit-api.cabal index 8d35969d7fd..0e5f6834e8d 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 ^>= 9.2 + , cardano-api ^>= 9.3 , cardano-binary - , cardano-cli ^>= 9.3 + , cardano-cli ^>= 9.4 , cardano-crypto-class ^>= 2.1.2 , http-media , iohk-monitoring @@ -49,7 +49,7 @@ library , network , optparse-applicative-fork , ouroboros-consensus-cardano - , ouroboros-network ^>= 0.16.1 + , ouroboros-network ^>= 0.17 , ouroboros-network-protocols , prometheus >= 2.2.4 , servant diff --git a/cardano-testnet/cardano-testnet.cabal b/cardano-testnet/cardano-testnet.cabal index e410642c547..4c2815afb0a 100644 --- a/cardano-testnet/cardano-testnet.cabal +++ b/cardano-testnet/cardano-testnet.cabal @@ -35,8 +35,8 @@ library , aeson-pretty , ansi-terminal , bytestring - , cardano-api ^>= 9.2 - , cardano-cli ^>= 9.3 + , cardano-api ^>= 9.3 + , cardano-cli ^>= 9.4 , cardano-crypto-class , cardano-crypto-wrapper , cardano-git-rev ^>= 0.2.2 @@ -69,7 +69,7 @@ library , network , network-mux , optparse-applicative-fork - , ouroboros-network ^>= 0.16.1 + , ouroboros-network ^>= 0.17 , ouroboros-network-api , prettyprinter , process @@ -182,9 +182,9 @@ test-suite cardano-testnet-test main-is: cardano-testnet-test.hs - other-modules: Cardano.Testnet.Test.Cli.Babbage.LeadershipSchedule - Cardano.Testnet.Test.Cli.Babbage.StakeSnapshot - Cardano.Testnet.Test.Cli.Babbage.Transaction + other-modules: Cardano.Testnet.Test.Cli.LeadershipSchedule + Cardano.Testnet.Test.Cli.StakeSnapshot + Cardano.Testnet.Test.Cli.Transaction Cardano.Testnet.Test.Cli.Conway.Plutus Cardano.Testnet.Test.Cli.Conway.StakeSnapshot Cardano.Testnet.Test.Cli.KesPeriodInfo @@ -208,7 +208,7 @@ test-suite cardano-testnet-test Cardano.Testnet.Test.Gov.PredefinedAbstainDRep Cardano.Testnet.Test.Node.Shutdown Cardano.Testnet.Test.SanityCheck - Cardano.Testnet.Test.SubmitApi.Babbage.Transaction + Cardano.Testnet.Test.SubmitApi.Transaction type: exitcode-stdio-1.0 diff --git a/cardano-tracer/cardano-tracer.cabal b/cardano-tracer/cardano-tracer.cabal index c8b450d8115..7dac8e1e41e 100644 --- a/cardano-tracer/cardano-tracer.cabal +++ b/cardano-tracer/cardano-tracer.cabal @@ -175,7 +175,7 @@ library , filepath , mime-mail , optparse-applicative - , ouroboros-network ^>= 0.16.1 + , ouroboros-network ^>= 0.17 , ouroboros-network-api , ouroboros-network-framework , signal diff --git a/flake.lock b/flake.lock index 4e5ddec370e..fe9cc8dbf06 100644 --- a/flake.lock +++ b/flake.lock @@ -3,11 +3,11 @@ "CHaP": { "flake": false, "locked": { - "lastModified": 1724197463, - "narHash": "sha256-/ZHOKRX84tXckstr6rTYyjytF2yfrIpvGujRLyjZfUE=", + "lastModified": 1725556271, + "narHash": "sha256-+cwhAlF4zGfWC3UTSppYOwZ8SRcAfWU3WweenyvYgLA=", "owner": "intersectmbo", "repo": "cardano-haskell-packages", - "rev": "610a202920ffe1d371035d35053152e9a0c77fce", + "rev": "c9c0d9f9c76ea1e18d8fb8b744c52bfc39b058c8", "type": "github" }, "original": { diff --git a/trace-dispatcher/trace-dispatcher.cabal b/trace-dispatcher/trace-dispatcher.cabal index bcee3acd626..a83ddfe4207 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.16.1 + , ouroboros-network ^>= 0.17 , ouroboros-network-api , ouroboros-network-framework , serialise diff --git a/trace-forward/trace-forward.cabal b/trace-forward/trace-forward.cabal index 6a9c67a7972..a6a9d8411a3 100644 --- a/trace-forward/trace-forward.cabal +++ b/trace-forward/trace-forward.cabal @@ -64,7 +64,7 @@ library , deepseq , extra , io-classes - , ouroboros-network-api ^>= 0.7.3 + , ouroboros-network-api ^>= 0.9 , ouroboros-network-framework , serialise , stm From ec115c3c1a12e45c911b3ebfb89e6af81d8f2a97 Mon Sep 17 00:00:00 2001 From: Jordan Millar Date: Fri, 6 Sep 2024 17:19:59 -0400 Subject: [PATCH 02/15] Add parse options for single or multiple database paths in cardano-node executable --- .../src/Cardano/Node/Configuration/POM.hs | 7 +-- cardano-node/src/Cardano/Node/Orphans.hs | 5 ++ cardano-node/src/Cardano/Node/Parsers.hs | 50 +++++++++++++++---- 3 files changed, 48 insertions(+), 14 deletions(-) diff --git a/cardano-node/src/Cardano/Node/Configuration/POM.hs b/cardano-node/src/Cardano/Node/Configuration/POM.hs index d9ff4255aad..ad87f1f4d44 100644 --- a/cardano-node/src/Cardano/Node/Configuration/POM.hs +++ b/cardano-node/src/Cardano/Node/Configuration/POM.hs @@ -33,6 +33,7 @@ import Cardano.Tracing.Config import Cardano.Tracing.OrphanInstances.Network () import Ouroboros.Consensus.Mempool (MempoolCapacityBytes (..), MempoolCapacityBytesOverride (..)) +import Ouroboros.Consensus.Node (NodeDatabasePaths (..)) import qualified Ouroboros.Consensus.Node as Consensus (NetworkP2PMode (..)) import Ouroboros.Consensus.Storage.LedgerDB.DiskPolicy (NumOfDiskSnapshots (..), SnapshotInterval (..)) @@ -91,7 +92,7 @@ data NodeConfiguration -- (logging, tracing, protocol, slot length etc) , ncConfigFile :: !ConfigYamlFilePath , ncTopologyFile :: !TopologyFile - , ncDatabaseFile :: !DbFile + , ncDatabaseFile :: !NodeDatabasePaths , ncProtocolFiles :: !ProtocolFilepaths , ncValidateDB :: !Bool , ncShutdownConfig :: !ShutdownConfig @@ -173,7 +174,7 @@ data PartialNodeConfiguration -- (logging, tracing, protocol, slot length etc) , pncConfigFile :: !(Last ConfigYamlFilePath) , pncTopologyFile :: !(Last TopologyFile) - , pncDatabaseFile :: !(Last DbFile) + , pncDatabaseFile :: !(Last NodeDatabasePaths) , pncProtocolFiles :: !(Last ProtocolFilepaths) , pncValidateDB :: !(Last Bool) , pncShutdownConfig :: !(Last ShutdownConfig) @@ -492,7 +493,7 @@ defaultPartialNodeConfiguration :: PartialNodeConfiguration defaultPartialNodeConfiguration = PartialNodeConfiguration { pncConfigFile = Last . Just $ ConfigYamlFilePath "configuration/cardano/mainnet-config.json" - , pncDatabaseFile = Last . Just $ DbFile "mainnet/db/" + , pncDatabaseFile = Last . Just $ OnePathForAllDbs "mainnet/db/" , pncLoggingSwitch = Last $ Just True , pncSocketConfig = Last . Just $ SocketConfig mempty mempty mempty mempty , pncDiffusionMode = Last $ Just InitiatorAndResponderDiffusionMode diff --git a/cardano-node/src/Cardano/Node/Orphans.hs b/cardano-node/src/Cardano/Node/Orphans.hs index 9435d87f890..a5189bcfb38 100644 --- a/cardano-node/src/Cardano/Node/Orphans.hs +++ b/cardano-node/src/Cardano/Node/Orphans.hs @@ -1,5 +1,6 @@ {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE NamedFieldPuns #-} +{-# LANGUAGE StandaloneDeriving #-} {-# OPTIONS_GHC -Wno-orphans #-} @@ -7,12 +8,16 @@ module Cardano.Node.Orphans () where import Cardano.Api () +import Ouroboros.Consensus.Node import Ouroboros.Network.NodeToNode (AcceptedConnectionsLimit (..)) import Ouroboros.Network.SizeInBytes (SizeInBytes (..)) import Data.Aeson.Types import Text.Printf (PrintfArg (..)) +deriving instance Eq NodeDatabasePaths +deriving instance Show NodeDatabasePaths + instance PrintfArg SizeInBytes where formatArg (SizeInBytes s) = formatArg s diff --git a/cardano-node/src/Cardano/Node/Parsers.hs b/cardano-node/src/Cardano/Node/Parsers.hs index ba82f9f96db..1a5f1fa47e3 100644 --- a/cardano-node/src/Cardano/Node/Parsers.hs +++ b/cardano-node/src/Cardano/Node/Parsers.hs @@ -20,8 +20,8 @@ import Cardano.Node.Configuration.Socket import Cardano.Node.Handlers.Shutdown import Cardano.Node.Types import Cardano.Prelude (ConvertText (..)) -import Ouroboros.Consensus.Mempool (MempoolCapacityBytes (..), - MempoolCapacityBytesOverride (..)) +import Ouroboros.Consensus.Mempool (MempoolCapacityBytes (..)) +import Ouroboros.Consensus.Node import Ouroboros.Consensus.Storage.LedgerDB.DiskPolicy (NumOfDiskSnapshots (..), SnapshotInterval (..)) @@ -50,7 +50,7 @@ nodeRunParser :: Parser PartialNodeConfiguration nodeRunParser = do -- Filepaths topFp <- lastOption parseTopologyFile - dbFp <- lastOption parseDbPath + dbFp <- lastOption parseNodeDatabasePaths validate <- lastOption parseValidateDB socketFp <- lastOption $ parseSocketPath "Path to a cardano-node socket" traceForwardSocket <- lastOption parseTracerSocketMode @@ -88,7 +88,7 @@ nodeRunParser = do socketFp , pncConfigFile = ConfigYamlFilePath <$> nodeConfigFp , pncTopologyFile = TopologyFile <$> topFp - , pncDatabaseFile = DbFile <$> dbFp + , pncDatabaseFile = dbFp , pncDiffusionMode = mempty , pncNumOfDiskSnapshots = numOfDiskSnapshots , pncSnapshotInterval = snapshotInterval @@ -224,14 +224,42 @@ parseMempoolCapacityOverride = parseOverride <|> parseNoOverride <> help "[DEPRECATED: Set it in config file] Don't override mempool capacity" ) -parseDbPath :: Parser FilePath + +parseNodeDatabasePaths :: Parser NodeDatabasePaths +parseNodeDatabasePaths = parseDbPath <|> parseMultipleDbPaths + +parseDbPath :: Parser NodeDatabasePaths parseDbPath = - strOption - ( long "database-path" - <> metavar "FILEPATH" - <> help "Directory where the state is stored." - <> completer (bashCompleter "file") - ) + fmap OnePathForAllDbs $ + strOption $ + mconcat + [ long "database-path" + , metavar "FILEPATH" + , help "Directory where the state is stored." + , completer (bashCompleter "file") + ] + +parseMultipleDbPaths :: Parser NodeDatabasePaths +parseMultipleDbPaths = MultipleDbPaths <$> parseImmutableDbPath <*> parseVolatileDbPath + +parseVolatileDbPath :: Parser FilePath +parseVolatileDbPath = strOption $ + mconcat + [ long "volatile-database-path" + , metavar "FILEPATH" + , help "Directory where the state is stored." + , completer (bashCompleter "file") + ] + +parseImmutableDbPath :: Parser FilePath +parseImmutableDbPath = strOption $ + mconcat + [ long "immutable-database-path" + , metavar "FILEPATH" + , help "Directory where the state is stored." + , completer (bashCompleter "file") + ] + parseValidateDB :: Parser Bool parseValidateDB = From 4166ee47b5272d60f5d8cf7f9acd5525c2ae04e2 Mon Sep 17 00:00:00 2001 From: Jordan Millar Date: Fri, 6 Sep 2024 17:21:35 -0400 Subject: [PATCH 03/15] Propagate consensus changes --- .../src/Cardano/Node/Protocol/Byron.hs | 5 +- .../src/Cardano/Node/Protocol/Cardano.hs | 90 +++---------------- .../src/Cardano/Node/Protocol/Shelley.hs | 13 +-- 3 files changed, 15 insertions(+), 93 deletions(-) diff --git a/cardano-node/src/Cardano/Node/Protocol/Byron.hs b/cardano-node/src/Cardano/Node/Protocol/Byron.hs index 6350d16ba16..57465668589 100644 --- a/cardano-node/src/Cardano/Node/Protocol/Byron.hs +++ b/cardano-node/src/Cardano/Node/Protocol/Byron.hs @@ -31,7 +31,6 @@ import Cardano.Tracing.OrphanInstances.HardFork () import Cardano.Tracing.OrphanInstances.Shelley () import Ouroboros.Consensus.Cardano import qualified Ouroboros.Consensus.Cardano as Consensus -import qualified Ouroboros.Consensus.Mempool.Capacity as TxLimits import qualified Data.ByteString.Lazy as LB import Data.Maybe (fromMaybe) @@ -80,9 +79,7 @@ mkSomeConsensusProtocolByron NodeByronProtocolConfiguration { npcByronSupportedProtocolVersionAlt, byronSoftwareVersion = softwareVersion, byronLeaderCredentials = - optionalLeaderCredentials, - byronMaxTxCapacityOverrides = - TxLimits.mkOverrides TxLimits.noOverridesMeasure + optionalLeaderCredentials } readGenesis :: GenesisFile diff --git a/cardano-node/src/Cardano/Node/Protocol/Cardano.hs b/cardano-node/src/Cardano/Node/Protocol/Cardano.hs index c36e9c844d4..573c6a86d6c 100644 --- a/cardano-node/src/Cardano/Node/Protocol/Cardano.hs +++ b/cardano-node/src/Cardano/Node/Protocol/Cardano.hs @@ -33,10 +33,9 @@ import Ouroboros.Consensus.Cardano import qualified Ouroboros.Consensus.Cardano as Consensus import qualified Ouroboros.Consensus.Cardano.CanHardFork as Consensus import Ouroboros.Consensus.Cardano.Condense () +import qualified Ouroboros.Consensus.Cardano.Node as Consensus import Ouroboros.Consensus.Config (emptyCheckpointsMap) import Ouroboros.Consensus.HardFork.Combinator.Condense () -import qualified Ouroboros.Consensus.Mempool.Capacity as TxLimits -import qualified Ouroboros.Consensus.Shelley.Node.Praos as Praos import Prelude @@ -145,8 +144,8 @@ mkSomeConsensusProtocolCardano NodeByronProtocolConfiguration { --TODO: all these protocol versions below are confusing and unnecessary. -- It could and should all be automated and these config entries eliminated. return $! - SomeConsensusProtocol CardanoBlockType $ ProtocolInfoArgsCardano $ CardanoProtocolParams { - paramsByron = + SomeConsensusProtocol CardanoBlockType $ ProtocolInfoArgsCardano $ Consensus.CardanoProtocolParams { + Consensus.byronProtocolParams = Consensus.ProtocolParamsByron { byronGenesis = byronGenesis, byronPbftSignatureThreshold = @@ -167,94 +166,25 @@ mkSomeConsensusProtocolCardano NodeByronProtocolConfiguration { npcByronSupportedProtocolVersionAlt, byronSoftwareVersion = Byron.softwareVersion, byronLeaderCredentials = - byronLeaderCredentials, - byronMaxTxCapacityOverrides = - TxLimits.mkOverrides TxLimits.noOverridesMeasure + byronLeaderCredentials } - , paramsShelleyBased = + , Consensus.shelleyBasedProtocolParams = Consensus.ProtocolParamsShelleyBased { shelleyBasedInitialNonce = Shelley.genesisHashToPraosNonce shelleyGenesisHash, shelleyBasedLeaderCredentials = shelleyLeaderCredentials } - , paramsShelley = - Consensus.ProtocolParamsShelley { - -- This is /not/ the Shelley protocol version. It is the protocol - -- version that this node will declare that it understands, when it - -- is in the Shelley era. That is, it is the version of protocol - -- /after/ Shelley, i.e. Allegra. - shelleyProtVer = - ProtVer (natVersion @3) 0, - shelleyMaxTxCapacityOverrides = - TxLimits.mkOverrides TxLimits.noOverridesMeasure - } - , paramsAllegra = - Consensus.ProtocolParamsAllegra { - -- This is /not/ the Allegra protocol version. It is the protocol - -- version that this node will declare that it understands, when it - -- is in the Allegra era. That is, it is the version of protocol - -- /after/ Allegra, i.e. Mary. - allegraProtVer = - ProtVer (natVersion @4) 0, - allegraMaxTxCapacityOverrides = - TxLimits.mkOverrides TxLimits.noOverridesMeasure - } - , paramsMary = - Consensus.ProtocolParamsMary { - -- This is /not/ the Mary protocol version. It is the protocol - -- version that this node will declare that it understands, when it - -- is in the Mary era. That is, it is the version of protocol - -- /after/ Mary, i.e. Alonzo. - maryProtVer = ProtVer (natVersion @5) 0, - maryMaxTxCapacityOverrides = - TxLimits.mkOverrides TxLimits.noOverridesMeasure - } - , paramsAlonzo = - Consensus.ProtocolParamsAlonzo { - -- This is /not/ the Alonzo protocol version. It is the protocol - -- version that this node will declare that it understands, when it - -- is in the Alonzo era. That is, it is the version of protocol - -- /after/ Alonzo, i.e. Babbage. - -- NOTE: - -- We are not actually transitioning to version 7.2, - -- this is a HACK so that we can distinguish between others - -- versions of the node that are broadcasting major version 7. - -- We intentionally broadcast 7.0 starting in Babbage. - alonzoProtVer = ProtVer (natVersion @7) 2, - alonzoMaxTxCapacityOverrides = - TxLimits.mkOverrides TxLimits.noOverridesMeasure - } - , paramsBabbage = - Praos.ProtocolParamsBabbage { - -- If Conway is not enabled, this is the Babbage protocol version, - -- since that's the last one node understands. - -- - -- If Conway is enabled, then this is /not/ the Babbage protocol - -- version. It is the protocol version that this node will declare - -- that it understands during the Babbage era. That is, it is the - -- version of protocol /after/ Babbage, i.e. Conway. - Praos.babbageProtVer = ProtVer (natVersion @9) 1, - Praos.babbageMaxTxCapacityOverrides = - TxLimits.mkOverrides TxLimits.noOverridesMeasure - } - , paramsConway = - Praos.ProtocolParamsConway { - -- ProtVer 9 corresponds to the Conway bootstrap era. - -- ProtVer 10 corresponds to the Conway post bootstrap era. - Praos.conwayProtVer = + , Consensus.cardanoProtocolVersion = if npcExperimentalHardForksEnabled then ProtVer (natVersion @10) 0 - else ProtVer (natVersion @9) 1, - Praos.conwayMaxTxCapacityOverrides = - TxLimits.mkOverrides TxLimits.noOverridesMeasure - } + else ProtVer (natVersion @9) 1 -- The remaining arguments specify the parameters needed to transition between two eras - , ledgerTransitionConfig = + , Consensus.cardanoLedgerTransitionConfig = Ledger.mkLatestTransitionConfig shelleyGenesis alonzoGenesis conwayGenesis - , hardForkTriggers = + , Consensus.cardanoHardForkTriggers = Consensus.CardanoHardForkTriggers' { triggerHardForkShelley = -- What will trigger the Byron -> Shelley hard fork? @@ -310,7 +240,7 @@ mkSomeConsensusProtocolCardano NodeByronProtocolConfiguration { Just epochNo -> Consensus.TriggerHardForkAtEpoch epochNo } -- TODO: once https://github.com/IntersectMBO/cardano-node/issues/5730 is implemented 'emptyCheckpointsMap' needs to be replaced with the checkpoints map read from a configuration file. - , checkpoints = emptyCheckpointsMap + , Consensus.cardanoCheckpoints = emptyCheckpointsMap } ---------------------------------------------------------------------- diff --git a/cardano-node/src/Cardano/Node/Protocol/Shelley.hs b/cardano-node/src/Cardano/Node/Protocol/Shelley.hs index 058cc4d5ea5..4073c8d5191 100644 --- a/cardano-node/src/Cardano/Node/Protocol/Shelley.hs +++ b/cardano-node/src/Cardano/Node/Protocol/Shelley.hs @@ -39,10 +39,9 @@ import Cardano.Node.Types import Cardano.Tracing.OrphanInstances.HardFork () import Cardano.Tracing.OrphanInstances.Shelley () import qualified Ouroboros.Consensus.Cardano as Consensus -import qualified Ouroboros.Consensus.Mempool.Capacity as TxLimits import Ouroboros.Consensus.Protocol.Praos.Common (PraosCanBeLeader (..)) -import Ouroboros.Consensus.Shelley.Node (Nonce (..), ProtocolParams (..), - ProtocolParamsShelleyBased (..), ShelleyLeaderCredentials (..)) +import Ouroboros.Consensus.Shelley.Node (Nonce (..), ProtocolParamsShelleyBased (..), + ShelleyLeaderCredentials (..)) import Control.Exception (IOException) import Control.Monad @@ -83,12 +82,8 @@ mkSomeConsensusProtocolShelley NodeShelleyProtocolConfiguration { shelleyBasedLeaderCredentials = leaderCredentials } - Consensus.ProtocolParamsShelley { - shelleyProtVer = - ProtVer (natVersion @2) 0, - shelleyMaxTxCapacityOverrides = - TxLimits.mkOverrides TxLimits.noOverridesMeasure - } + (ProtVer (natVersion @2) 0) + genesisHashToPraosNonce :: GenesisHash -> Nonce genesisHashToPraosNonce (GenesisHash h) = Nonce (Crypto.castHash h) From 40f5dc23fa6fafc4c1067015c0fa59c322a7bdcf Mon Sep 17 00:00:00 2001 From: Jordan Millar Date: Fri, 6 Sep 2024 17:21:54 -0400 Subject: [PATCH 04/15] Belongs with the NodeDatabasePaths commit --- cardano-node/src/Cardano/Node/Run.hs | 154 ++++++++++----------- cardano-node/test/Test/Cardano/Node/POM.hs | 3 +- 2 files changed, 78 insertions(+), 79 deletions(-) diff --git a/cardano-node/src/Cardano/Node/Run.hs b/cardano-node/src/Cardano/Node/Run.hs index 08b0feed168..3d944d96278 100644 --- a/cardano-node/src/Cardano/Node/Run.hs +++ b/cardano-node/src/Cardano/Node/Run.hs @@ -27,75 +27,46 @@ module Cardano.Node.Run import Cardano.Api (File (..), FileDirection (..)) import qualified Cardano.Api as Api -import Cardano.Prelude (FatalError (..), bool, (:~:) (..)) - -import Data.Bits -import Data.IP (toSockAddr) - -import Control.Concurrent (killThread, mkWeakThreadId, myThreadId) -import Control.Concurrent.Class.MonadSTM.Strict -import Control.Exception (try) -import qualified Control.Exception as Exception -import Control.Monad (forM_, unless, void, when) -import Control.Monad.Class.MonadThrow (MonadThrow (..)) -import Control.Monad.IO.Class (MonadIO (..)) -import Control.Monad.Trans.Except (ExceptT, runExceptT) -import Control.Monad.Trans.Except.Extra (left) -import "contra-tracer" Control.Tracer -import Data.Either (partitionEithers) -import Data.Map.Strict (Map) -import qualified Data.Map.Strict as Map -import Data.Maybe (catMaybes, fromMaybe, mapMaybe) -import Data.Monoid (Last (..)) -import Data.Proxy (Proxy (..)) -import Data.Text (Text, breakOn, pack) -import qualified Data.Text as Text -import qualified Data.Text.Encoding as Text -import qualified Data.Text.IO as Text -import Data.Time.Clock (getCurrentTime) -import Data.Time.Clock.POSIX (utcTimeToPOSIXSeconds) -import Data.Version (showVersion) -import Network.HostName (getHostName) -import Network.Socket (Socket) -import System.Directory (canonicalizePath, createDirectoryIfMissing, makeAbsolute) -import System.Environment (lookupEnv) -#ifdef UNIX -import GHC.Weak (deRefWeak) -import System.Posix.Files -import qualified System.Posix.Signals as Signals -import System.Posix.Types (FileMode) -#else -import System.Win32.File -#endif - import Cardano.BM.Data.LogItem (LogObject (..)) import Cardano.BM.Data.Tracer (ToLogObject (..), TracingVerbosity (..)) import Cardano.BM.Data.Transformers (setHostname) import Cardano.BM.Trace -import Paths_cardano_node (version) - import qualified Cardano.Crypto.Init as Crypto - -import Cardano.Node.Tracing.Tracers.NodeVersion (getNodeVersion) - import Cardano.Node.Configuration.Logging (LoggingLayer (..), createLoggingLayer, nodeBasicInfo, shutdownLoggingLayer) import Cardano.Node.Configuration.NodeAddress import Cardano.Node.Configuration.POM (NodeConfiguration (..), PartialNodeConfiguration (..), SomeNetworkP2PMode (..), TimeoutOverride (..), defaultPartialNodeConfiguration, makeNodeConfiguration, parseNodeConfigurationFP) +import Cardano.Node.Configuration.Socket (SocketOrSocketInfo (..), + gatherConfiguredSockets, getSocketOrSocketInfoAddr) +import qualified Cardano.Node.Configuration.Topology as TopologyNonP2P +import Cardano.Node.Configuration.TopologyP2P +import qualified Cardano.Node.Configuration.TopologyP2P as TopologyP2P +import Cardano.Node.Handlers.Shutdown +import Cardano.Node.Protocol (ProtocolInstantiationError (..), mkConsensusProtocol) +import Cardano.Node.Protocol.Byron (ByronProtocolInstantiationError (CredentialsError)) +import Cardano.Node.Protocol.Cardano (CardanoProtocolInstantiationError (..)) +import Cardano.Node.Protocol.Shelley (PraosLeaderCredentialsError (..), + ShelleyProtocolInstantiationError (PraosLeaderCredentialsError)) +import Cardano.Node.Protocol.Types +import Cardano.Node.Queries import Cardano.Node.Startup +import Cardano.Node.TraceConstraints (TraceConstraints) import Cardano.Node.Tracing.API import Cardano.Node.Tracing.StateRep (NodeState (NodeKernelOnline)) +import Cardano.Node.Tracing.Tracers.NodeVersion (getNodeVersion) import Cardano.Node.Tracing.Tracers.Startup (getStartupInfo) import Cardano.Node.Types +import Cardano.Prelude (FatalError (..), bool, (:~:) (..)) import Cardano.Tracing.Config (TraceOptions (..), TraceSelection (..)) - +import Cardano.Tracing.Tracers import qualified Ouroboros.Consensus.Config as Consensus import Ouroboros.Consensus.Config.SupportsNode (ConfigSupportsNode (..)) import Ouroboros.Consensus.Node (DiskPolicyArgs (..), NetworkP2PMode (..), - RunNodeArgs (..), StdRunNodeArgs (..)) -import qualified Ouroboros.Consensus.Node as Node (getChainDB, run) + NodeDatabasePaths (..), RunNodeArgs (..), StdRunNodeArgs (..)) +import qualified Ouroboros.Consensus.Node as Node (NodeDatabasePaths (..), getChainDB, run) +import Ouroboros.Consensus.Node.Genesis import Ouroboros.Consensus.Node.NetworkProtocolVersion import Ouroboros.Consensus.Node.ProtocolInfo import Ouroboros.Consensus.Util.Orphans () @@ -107,34 +78,50 @@ import Ouroboros.Network.NodeToClient (LocalAddress (..), LocalSocket import Ouroboros.Network.NodeToNode (AcceptedConnectionsLimit (..), ConnectionId, PeerSelectionTargets (..), RemoteAddress) import Ouroboros.Network.PeerSelection.Bootstrap (UseBootstrapPeers (..)) - +import Ouroboros.Network.PeerSelection.LedgerPeers.Type (UseLedgerPeers) +import Ouroboros.Network.PeerSelection.PeerSharing (PeerSharing (..)) +import Ouroboros.Network.PeerSelection.PeerTrustable (PeerTrustable) import Ouroboros.Network.PeerSelection.RelayAccessPoint (RelayAccessPoint (..)) +import Ouroboros.Network.PeerSelection.State.LocalRootPeers (HotValency, WarmValency) import Ouroboros.Network.Protocol.ChainSync.Codec import Ouroboros.Network.Subscription (DnsSubscriptionTarget (..), IPSubscriptionTarget (..)) -import Cardano.Node.Configuration.Socket (SocketOrSocketInfo (..), - gatherConfiguredSockets, getSocketOrSocketInfoAddr) -import qualified Cardano.Node.Configuration.Topology as TopologyNonP2P -import Cardano.Node.Configuration.TopologyP2P -import qualified Cardano.Node.Configuration.TopologyP2P as TopologyP2P -import Cardano.Node.Handlers.Shutdown -import Cardano.Node.Protocol (ProtocolInstantiationError (..), mkConsensusProtocol) -import Cardano.Node.Protocol.Byron (ByronProtocolInstantiationError (CredentialsError)) -import Cardano.Node.Protocol.Cardano (CardanoProtocolInstantiationError (..)) -import Cardano.Node.Protocol.Shelley (PraosLeaderCredentialsError (..), - ShelleyProtocolInstantiationError (PraosLeaderCredentialsError)) -import Cardano.Node.Protocol.Types -import Cardano.Node.Queries -import Cardano.Node.TraceConstraints (TraceConstraints) -import Cardano.Tracing.Tracers -import Ouroboros.Network.PeerSelection.Bootstrap (UseBootstrapPeers) -import Ouroboros.Network.PeerSelection.LedgerPeers.Type (UseLedgerPeers) - -import Ouroboros.Network.PeerSelection.PeerSharing (PeerSharing (..)) -import Ouroboros.Network.PeerSelection.PeerTrustable (PeerTrustable) +import Control.Concurrent (killThread, mkWeakThreadId, myThreadId) +import Control.Concurrent.Class.MonadSTM.Strict +import Control.Exception (try) +import qualified Control.Exception as Exception +import Control.Monad (forM_, unless, void, when) +import Control.Monad.Class.MonadThrow (MonadThrow (..)) +import Control.Monad.IO.Class (MonadIO (..)) +import Control.Monad.Trans.Except (ExceptT, runExceptT) +import Control.Monad.Trans.Except.Extra (left) +import "contra-tracer" Control.Tracer +import Data.Bits +import Data.Either (partitionEithers) +import Data.IP (toSockAddr) +import Data.Map.Strict (Map) +import qualified Data.Map.Strict as Map +import Data.Maybe (catMaybes, fromMaybe, mapMaybe) +import Data.Monoid (Last (..)) +import Data.Proxy (Proxy (..)) +import Data.Text (Text, breakOn, pack) +import qualified Data.Text as Text +import qualified Data.Text.Encoding as Text +import qualified Data.Text.IO as Text +import Data.Time.Clock (getCurrentTime) +import Data.Time.Clock.POSIX (utcTimeToPOSIXSeconds) +import Data.Version (showVersion) +import GHC.Weak (deRefWeak) +import Network.HostName (getHostName) +import Network.Socket (Socket) +import System.Directory (canonicalizePath, createDirectoryIfMissing, makeAbsolute) +import System.Environment (lookupEnv) +import System.Posix.Files +import qualified System.Posix.Signals as Signals +import System.Posix.Types (FileMode) -import Ouroboros.Network.PeerSelection.State.LocalRootPeers (HotValency, WarmValency) +import Paths_cardano_node (version) {- HLINT ignore "Fuse concatMap/map" -} @@ -456,7 +443,8 @@ handleSimpleNode blockType runP p2pMode tracers nc onKernel = do useLedgerVar <- newTVarIO ntUseLedgerPeers useBootstrapVar <- newTVarIO ntUseBootstrapPeers let nodeArgs = RunNodeArgs - { rnTraceConsensus = consensusTracers tracers + { rnGenesisConfig = disableGenesisConfig + , rnTraceConsensus = consensusTracers tracers , rnTraceNTN = nodeToNodeTracers tracers , rnTraceNTC = nodeToClientTracers tracers , rnProtocolInfo = pInfo @@ -539,7 +527,8 @@ handleSimpleNode blockType runP p2pMode tracers nc onKernel = do (length ipProducerAddrs) nodeArgs = RunNodeArgs - { rnTraceConsensus = consensusTracers tracers + { rnGenesisConfig = disableGenesisConfig + , rnTraceConsensus = consensusTracers tracers , rnTraceNTN = nodeToNodeTracers tracers , rnTraceNTC = nodeToClientTracers tracers , rnProtocolInfo = pInfo @@ -795,11 +784,20 @@ updateTopologyConfiguration startupTracer nc localRootsVar publicRootsVar useLed -- Helper functions -------------------------------------------------------------------------------- -canonDbPath :: NodeConfiguration -> IO FilePath -canonDbPath NodeConfiguration{ncDatabaseFile = DbFile dbFp} = do - fp <- canonicalizePath =<< makeAbsolute dbFp - createDirectoryIfMissing True fp - return fp +canonDbPath :: NodeConfiguration -> IO NodeDatabasePaths +canonDbPath NodeConfiguration{ncDatabaseFile = nodeDatabaseFps} = + case nodeDatabaseFps of + OnePathForAllDbs dbFp -> do + fp <- canonicalizePath =<< makeAbsolute dbFp + createDirectoryIfMissing True fp + return $ OnePathForAllDbs fp + + MultipleDbPaths immutable volatile -> do + canonImmutable <- canonicalizePath =<< makeAbsolute immutable + canonVolatile <- canonicalizePath =<< makeAbsolute volatile + createDirectoryIfMissing True canonImmutable + createDirectoryIfMissing True canonVolatile + return $ MultipleDbPaths canonImmutable canonVolatile -- | Make sure the VRF private key file is readable only diff --git a/cardano-node/test/Test/Cardano/Node/POM.hs b/cardano-node/test/Test/Cardano/Node/POM.hs index 20d8c99119f..2b2c416d704 100644 --- a/cardano-node/test/Test/Cardano/Node/POM.hs +++ b/cardano-node/test/Test/Cardano/Node/POM.hs @@ -12,6 +12,7 @@ import Cardano.Node.Handlers.Shutdown import Cardano.Node.Types import Cardano.Tracing.Config (PartialTraceOptions (..), defaultPartialTraceConfiguration, partialTraceSelectionToEither) +import Ouroboros.Consensus.Node (NodeDatabasePaths (..)) import qualified Ouroboros.Consensus.Node as Consensus (NetworkP2PMode (..)) import Ouroboros.Consensus.Storage.LedgerDB.DiskPolicy (NumOfDiskSnapshots (..), SnapshotInterval (..)) @@ -197,7 +198,7 @@ eExpectedConfig = do , ncStartAsNonProducingNode = False , ncConfigFile = ConfigYamlFilePath "configuration/cardano/mainnet-config.json" , ncTopologyFile = TopologyFile "configuration/cardano/mainnet-topology.json" - , ncDatabaseFile = DbFile "mainnet/db/" + , ncDatabaseFile = OnePathForAllDbs "mainnet/db/" , ncProtocolFiles = ProtocolFilepaths Nothing Nothing Nothing Nothing Nothing Nothing , ncValidateDB = True , ncProtocolConfig = testNodeProtocolConfiguration From 3f1c103e2258ad23f755977c72bcf17c69b52159 Mon Sep 17 00:00:00 2001 From: Jordan Millar Date: Fri, 6 Sep 2024 17:22:50 -0400 Subject: [PATCH 05/15] Propagate tracers --- .../src/Cardano/Node/Tracing/Tracers.hs | 14 ++ .../Cardano/Node/Tracing/Tracers/ChainDB.hs | 16 +- .../Cardano/Node/Tracing/Tracers/Consensus.hs | 156 +++++++++++++++++- .../Cardano/Node/Tracing/Tracers/Startup.hs | 5 +- .../Tracing/OrphanInstances/Consensus.hs | 15 +- .../Tracing/OrphanInstances/Network.hs | 7 +- .../Tracing/OrphanInstances/Shelley.hs | 1 + cardano-node/src/Cardano/Tracing/Tracers.hs | 5 +- 8 files changed, 199 insertions(+), 20 deletions(-) diff --git a/cardano-node/src/Cardano/Node/Tracing/Tracers.hs b/cardano-node/src/Cardano/Node/Tracing/Tracers.hs index dc12e1b5947..2372bf21e78 100644 --- a/cardano-node/src/Cardano/Node/Tracing/Tracers.hs +++ b/cardano-node/src/Cardano/Node/Tracing/Tracers.hs @@ -242,6 +242,16 @@ mkConsensusTracers configReflection trBase trForward mbTrEKG _trDataPoint trConf ["ChainSync", "ServerBlock"] configureTracers configReflection trConfig [chainSyncServerBlockTr] + !consensusSanityCheckTr <- mkCardanoTracer + trBase trForward mbTrEKG + ["Consensus", "SanityCheck"] + configureTracers configReflection trConfig [consensusSanityCheckTr] + + !gddTr <- mkCardanoTracer + trBase trForward mbTrEKG + ["Consensus", "GDD"] + configureTracers configReflection trConfig [gddTr] + !blockFetchDecisionTr <- mkCardanoTracer trBase trForward mbTrEKG ["BlockFetch", "Decision"] @@ -332,6 +342,8 @@ mkConsensusTracers configReflection trBase trForward mbTrEKG _trDataPoint trConf <> traceWith chainSyncServerHeaderMetricsTr , Consensus.chainSyncServerBlockTracer = Tracer $ traceWith chainSyncServerBlockTr + , Consensus.consensusSanityCheckTracer = Tracer $ + traceWith consensusSanityCheckTr , Consensus.blockFetchDecisionTracer = Tracer $ traceWith blockFetchDecisionTr , Consensus.blockFetchClientTracer = Tracer $ @@ -341,6 +353,8 @@ mkConsensusTracers configReflection trBase trForward mbTrEKG _trDataPoint trConf traceWith blockFetchServerTr , Consensus.forgeStateInfoTracer = Tracer $ traceWith (traceAsKESInfo (Proxy @blk) forgeKESInfoTr) + , Consensus.gddTracer = Tracer $ + traceWith gddTr , Consensus.txInboundTracer = Tracer $ traceWith txInboundTr , Consensus.txOutboundTracer = Tracer $ diff --git a/cardano-node/src/Cardano/Node/Tracing/Tracers/ChainDB.hs b/cardano-node/src/Cardano/Node/Tracing/Tracers/ChainDB.hs index b5dc5a5f129..81be9e4a625 100644 --- a/cardano-node/src/Cardano/Node/Tracing/Tracers/ChainDB.hs +++ b/cardano-node/src/Cardano/Node/Tracing/Tracers/ChainDB.hs @@ -79,6 +79,7 @@ instance ( LogFormatting (Header blk) , LedgerSupportsProtocol blk , InspectLedger blk ) => LogFormatting (ChainDB.TraceEvent blk) where + forHuman v@ChainDB.TraceLastShutdownUnclean = forHumanOrMachine v forHuman (ChainDB.TraceAddBlockEvent v) = forHumanOrMachine v forHuman (ChainDB.TraceFollowerEvent v) = forHumanOrMachine v forHuman (ChainDB.TraceCopyToImmutableDBEvent v) = forHumanOrMachine v @@ -91,6 +92,8 @@ instance ( LogFormatting (Header blk) forHuman (ChainDB.TraceImmutableDBEvent v) = forHumanOrMachine v forHuman (ChainDB.TraceVolatileDBEvent v) = forHumanOrMachine v + forMachine details v@ChainDB.TraceLastShutdownUnclean = + forMachine details v forMachine details (ChainDB.TraceAddBlockEvent v) = forMachine details v forMachine details (ChainDB.TraceFollowerEvent v) = @@ -114,6 +117,7 @@ instance ( LogFormatting (Header blk) forMachine details (ChainDB.TraceVolatileDBEvent v) = forMachine details v + asMetrics v@ChainDB.TraceLastShutdownUnclean = asMetrics v asMetrics (ChainDB.TraceAddBlockEvent v) = asMetrics v asMetrics (ChainDB.TraceFollowerEvent v) = asMetrics v asMetrics (ChainDB.TraceCopyToImmutableDBEvent v) = asMetrics v @@ -128,6 +132,8 @@ instance ( LogFormatting (Header blk) instance MetaTrace (ChainDB.TraceEvent blk) where + namespaceFor ev@ChainDB.TraceLastShutdownUnclean = + nsPrependInner "LastShutdownUnclean" (namespaceFor ev) namespaceFor (ChainDB.TraceAddBlockEvent ev) = nsPrependInner "AddBlockEvent" (namespaceFor ev) namespaceFor (ChainDB.TraceFollowerEvent ev) = @@ -1488,18 +1494,20 @@ instance MetaTrace (ChainDB.UnknownRange blk) where instance ( StandardHash blk , ConvertRawHash blk) => LogFormatting (LedgerDB.TraceSnapshotEvent blk) where - forHuman (LedgerDB.TookSnapshot snap pt) = + forHuman (LedgerDB.TookSnapshot snap pt enclosedTiming) = "Took ledger snapshot " <> showT snap <> - " at " <> renderRealPointAsPhrase pt + " at " <> renderRealPointAsPhrase pt <> " at " <> + showT enclosedTiming forHuman (LedgerDB.DeletedSnapshot snap) = "Deleted old snapshot " <> showT snap forHuman (LedgerDB.InvalidSnapshot snap failure) = "Invalid snapshot " <> showT snap <> showT failure - forMachine dtals (LedgerDB.TookSnapshot snap pt) = + forMachine dtals (LedgerDB.TookSnapshot snap pt enclosedTiming) = mconcat [ "kind" .= String "TookSnapshot" , "snapshot" .= forMachine dtals snap - , "tip" .= show pt ] + , "tip" .= show pt + , "enclosedTiming" .= enclosedTiming] forMachine dtals (LedgerDB.DeletedSnapshot snap) = mconcat [ "kind" .= String "DeletedSnapshot" , "snapshot" .= forMachine dtals snap ] diff --git a/cardano-node/src/Cardano/Node/Tracing/Tracers/Consensus.hs b/cardano-node/src/Cardano/Node/Tracing/Tracers/Consensus.hs index 27ca806f916..70e6813967b 100644 --- a/cardano-node/src/Cardano/Node/Tracing/Tracers/Consensus.hs +++ b/cardano-node/src/Cardano/Node/Tracing/Tracers/Consensus.hs @@ -10,6 +10,7 @@ {-# LANGUAGE UndecidableInstances #-} {-# OPTIONS_GHC -Wno-orphans #-} +{-# LANGUAGE InstanceSigs #-} module Cardano.Node.Tracing.Tracers.Consensus ( @@ -44,6 +45,7 @@ import Ouroboros.Consensus.Mempool (MempoolSize (..), TraceEventMempoo import Ouroboros.Consensus.MiniProtocol.BlockFetch.Server (TraceBlockFetchServerEvent (..)) import Ouroboros.Consensus.MiniProtocol.ChainSync.Client +import Ouroboros.Consensus.Genesis.Governor import Ouroboros.Consensus.MiniProtocol.ChainSync.Client.Jumping (Instruction (..), JumpInstruction (..), JumpResult (..)) import Ouroboros.Consensus.MiniProtocol.ChainSync.Client.State (JumpInfo (..)) @@ -150,6 +152,37 @@ instance (LogFormatting (LedgerUpdate blk), LogFormatting (LedgerWarning blk)) LedgerUpdate update -> forMachine dtal update LedgerWarning warning -> forMachine dtal warning +-------------------------------------------------------------------------------- +-- AnchoredFragment tracer +-------------------------------------------------------------------------------- + +instance (HasHeader blk, ConvertRawHash (Header blk)) => + LogFormatting (AF.AnchoredFragment blk) where + forMachine _dtal frag = mconcat + [ "kind" .= String "AnchoredFragment" + , "anchorPoint" .= ( Aeson.Object $ mconcat + [ "kind" .= String "AnchoredFragmentAnchorPoint" + , "hash" .= String (renderChainHash + (renderHeaderHash (Proxy @(Header blk))) + (AF.anchorToHash $ AF.anchor frag)) + , "slotNo" .= String (showT $ AF.anchorToSlotNo $ AF.anchor frag) + , "blockNo" .= String (showT $ AF.anchorToBlockNo $ AF.anchor frag) + ] + ) + , "headPoint" .= ( Aeson.Object $ mconcat + [ "kind" .= String "AnchoredFragmentHeadPoint" + , "hash" .= String (renderChainHash + (renderHeaderHash (Proxy @(Header blk))) + (AF.headHash frag)) + , "slotNo" .= String (showT $ AF.headSlot frag) + , "blockNo" .= String (showT $ AF.headBlockNo frag) + ] + ) + , "length" .= toJSON (fragmentLength frag) + ] + + forHuman = forHumanOrMachine + -------------------------------------------------------------------------------- -- ChainSyncClient Tracer @@ -735,13 +768,13 @@ instance (HasHeader header, ConvertRawHash header) => , "head" .= String (renderChainHash (renderHeaderHash (Proxy @header)) (AF.headHash af)) - , "length" .= toJSON (fragmentLength af)] + , "length" .= toJSON (fragmentLength' af)] where -- NOTE: this ignores the Byron era with its EBB complication: -- the length would be underestimated by 1, if the AF is anchored -- at the epoch boundary. - fragmentLength :: AF.AnchoredFragment header -> Int - fragmentLength f = fromIntegral . unBlockNo $ + fragmentLength' :: AF.AnchoredFragment header -> Int + fragmentLength' f = fromIntegral . unBlockNo $ case (f, f) of (AS.Empty{}, AS.Empty{}) -> 0 (firstHdr AS.:< _, _ AS.:> lastHdr) -> @@ -869,6 +902,108 @@ instance MetaTrace (TraceBlockFetchServerEvent blk) where allNamespaces = [Namespace [] ["SendBlock"]] +-------------------------------------------------------------------------------- +-- Gdd Tracer +-------------------------------------------------------------------------------- + +instance ( Show peer + , HasHeader blk + , HasHeader (Header blk) + , ConvertRawHash (Header blk) + ) => LogFormatting (TraceGDDEvent peer blk) where + forMachine dtal TraceGDDEvent {..} = mconcat + [ "kind" .= String "TraceGDDEvent" + , "bounds" .= toJSON ( + map + ( \(peer, density) -> Aeson.Object $ mconcat + [ "kind" .= String "PeerDensityBound" + , "peer" .= (String $ showT peer) + , "densityBounds" .= forMachine dtal density + ] + ) + bounds + ) + , "curChain" .= forMachine dtal curChain + , "candidates" .= toJSON ( + map + ( \(peer, frag) -> Aeson.Object $ mconcat + [ "kind" .= String "PeerCandidateFragment" + , "peer" .= (String $ showT peer) + , "candidateFragment" .= forMachine dtal frag + ] + ) + candidates + ) + , "candidateSuffixes" .= toJSON ( + map + ( \(peer, frag) -> Aeson.Object $ mconcat + [ "kind" .= String "PeerCandidateSuffix" + , "peer" .= (String $ showT peer) + , "candidateSuffix" .= forMachine dtal frag + ] + ) + candidateSuffixes + ) + , "losingPeers".= (toJSON $ map (String . showT) losingPeers) + , "loeHead" .= (String $ showT loeHead) + , "sgen" .= (String $ showT $ unGenesisWindow sgen) + ] + + forHuman = forHumanOrMachine + +instance MetaTrace (TraceGDDEvent peer blk) where + namespaceFor _ = Namespace [] ["TraceGDDEvent"] + + severityFor _ _ = Just Debug + + documentFor _ = Just "The Genesis Density Disconnection governor has updated its state" + + allNamespaces = [Namespace [] ["TraceGDDEvent"]] + + +instance ( HasHeader blk + , HasHeader (Header blk) + , ConvertRawHash (Header blk) + ) => LogFormatting (DensityBounds blk) where + forMachine dtal DensityBounds {..} = mconcat + [ "kind" .= String "DensityBounds" + , "clippedFragment" .= forMachine dtal clippedFragment + , "offersMoreThanK" .= toJSON offersMoreThanK + , "lowerBound" .= toJSON lowerBound + , "upperBound" .= toJSON upperBound + , "hasBlockAfter" .= toJSON hasBlockAfter + , "latestSlot" .= String (showT latestSlot) + , "idling" .= toJSON idling + ] + + forHuman = forHumanOrMachine + + +-------------------------------------------------------------------------------- +-- SanityCheckIssue Tracer +-------------------------------------------------------------------------------- + +instance MetaTrace SanityCheckIssue where + + namespaceFor InconsistentSecurityParam {} = Namespace [] ["SanityCheckIssue"] + + severityFor (Namespace _ ["SanityCheckIssue"]) _ = Just Error + severityFor _ _ = Nothing + + documentFor (Namespace _ ["SanityCheckIssue"]) = Nothing + documentFor _ = Nothing + + allNamespaces = [Namespace [] ["SanityCheckIssue"]] + +instance LogFormatting SanityCheckIssue where + forMachine _dtal (InconsistentSecurityParam e) = + mconcat [ "kind" .= String "InconsistentSecurityParam" + , "error" .= String (Text.pack $ show e) + ] + forHuman (InconsistentSecurityParam e) = + "Configuration contains multiple security parameters: " <> Text.pack (show e) + + -------------------------------------------------------------------------------- -- TxInbound Tracer -------------------------------------------------------------------------------- @@ -2025,3 +2160,18 @@ instance ( StandardHash blk ] forHuman = showT + + +-------------------------------------------------------------------------------- +-- Utils +-------------------------------------------------------------------------------- + +-- NOTE: this ignores the Byron era with its EBB complication: +-- the length would be underestimated by 1, if the AF is anchored +-- at the epoch boundary. +fragmentLength :: HasHeader header => AF.AnchoredFragment header -> Int +fragmentLength f = fromIntegral . unBlockNo $ + case (f, f) of + (AS.Empty{}, AS.Empty{}) -> 0 + (firstHdr AS.:< _, _ AS.:> lastHdr) -> + blockNo lastHdr - blockNo firstHdr + 1 \ No newline at end of file diff --git a/cardano-node/src/Cardano/Node/Tracing/Tracers/Startup.hs b/cardano-node/src/Cardano/Node/Tracing/Tracers/Startup.hs index 6854cab8dee..0d27397ef89 100644 --- a/cardano-node/src/Cardano/Node/Tracing/Tracers/Startup.hs +++ b/cardano-node/src/Cardano/Node/Tracing/Tracers/Startup.hs @@ -25,9 +25,7 @@ import Cardano.Logging import Cardano.Node.Configuration.POM (NodeConfiguration, ncProtocol) import Cardano.Node.Configuration.Socket import Cardano.Node.Protocol (SomeConsensusProtocol (..)) - import Cardano.Node.Startup - import Cardano.Slotting.Slot (EpochSize (..)) import qualified Ouroboros.Consensus.BlockchainTime.WallClock.Types as WCT import Ouroboros.Consensus.Byron.Ledger.Conversions (fromByronEpochSlots, @@ -56,7 +54,6 @@ import Data.Text (Text, pack) import Data.Time (getCurrentTime) import Data.Time.Clock.POSIX (POSIXTime, utcTimeToPOSIXSeconds) import Data.Version (showVersion) - import Network.Socket (SockAddr) import Paths_cardano_node (version) @@ -440,7 +437,6 @@ instance MetaTrace (StartupTrace blk) where , Namespace [] ["Network"] ] - nodeToClientVersionToInt :: NodeToClientVersion -> Int nodeToClientVersionToInt = \case NodeToClientV_9 -> 9 @@ -451,6 +447,7 @@ nodeToClientVersionToInt = \case NodeToClientV_14 -> 14 NodeToClientV_15 -> 15 NodeToClientV_16 -> 16 + NodeToClientV_17 -> 17 nodeToNodeVersionToInt :: NodeToNodeVersion -> Int nodeToNodeVersionToInt = \case diff --git a/cardano-node/src/Cardano/Tracing/OrphanInstances/Consensus.hs b/cardano-node/src/Cardano/Tracing/OrphanInstances/Consensus.hs index a051411c5fc..144ec205328 100644 --- a/cardano-node/src/Cardano/Tracing/OrphanInstances/Consensus.hs +++ b/cardano-node/src/Cardano/Tracing/OrphanInstances/Consensus.hs @@ -220,6 +220,7 @@ instance HasSeverityAnnotation (ChainDB.TraceEvent blk) where VolDb.Truncate{} -> Error VolDb.InvalidFileNames{} -> Warning VolDb.DBClosed{} -> Info + getSeverityAnnotation ChainDB.TraceLastShutdownUnclean = Debug instance HasSeverityAnnotation (LedgerEvent blk) where getSeverityAnnotation (LedgerUpdate _) = Notice @@ -489,6 +490,7 @@ instance ( ConvertRawHash blk , InspectLedger blk) => HasTextFormatter (ChainDB.TraceEvent blk) where formatText tev _obj = case tev of + ChainDB.TraceLastShutdownUnclean -> "TraceLastShutdownUnclean" ChainDB.TraceAddBlockEvent ev -> case ev of ChainDB.IgnoreBlockOlderThanK pt -> "Ignoring block older than K: " <> renderRealPointAsPhrase pt @@ -588,9 +590,10 @@ instance ( ConvertRawHash blk ChainDB.TraceSnapshotEvent ev -> case ev of LedgerDB.InvalidSnapshot snap failure -> "Invalid snapshot " <> showT snap <> showT failure - LedgerDB.TookSnapshot snap pt -> + LedgerDB.TookSnapshot snap pt enclosedTiming -> "Took ledger snapshot " <> showT snap <> - " at " <> renderRealPointAsPhrase pt + " at " <> renderRealPointAsPhrase pt <> " at" <> + showT enclosedTiming LedgerDB.DeletedSnapshot snap -> "Deleted old snapshot " <> showT snap ChainDB.TraceCopyToImmutableDBEvent ev -> case ev of @@ -892,6 +895,8 @@ instance ( ConvertRawHash blk , ToObject (LedgerEvent blk) , ToObject (SelectView (BlockProtocol blk))) => ToObject (ChainDB.TraceEvent blk) where + toObject _verb ChainDB.TraceLastShutdownUnclean = + mconcat [ "kind" .= String "TraceLastShutdownUnclean" ] toObject verb (ChainDB.TraceAddBlockEvent ev) = case ev of ChainDB.IgnoreBlockOlderThanK pt -> mconcat [ "kind" .= String "TraceAddBlockEvent.IgnoreBlockOlderThanK" @@ -1054,10 +1059,12 @@ instance ( ConvertRawHash blk toObject MinimalVerbosity (ChainDB.TraceSnapshotEvent _ev) = mempty -- no output toObject verb (ChainDB.TraceSnapshotEvent ev) = case ev of - LedgerDB.TookSnapshot snap pt -> + LedgerDB.TookSnapshot snap pt enclosedTiming -> mconcat [ "kind" .= String "TraceSnapshotEvent.TookSnapshot" , "snapshot" .= toObject verb snap - , "tip" .= show pt ] + , "tip" .= show pt + , "enclosedTiming" .= enclosedTiming + ] LedgerDB.DeletedSnapshot snap -> mconcat [ "kind" .= String "TraceSnapshotEvent.DeletedSnapshot" , "snapshot" .= toObject verb snap ] diff --git a/cardano-node/src/Cardano/Tracing/OrphanInstances/Network.hs b/cardano-node/src/Cardano/Tracing/OrphanInstances/Network.hs index 1b89661c375..7592da20c67 100644 --- a/cardano-node/src/Cardano/Tracing/OrphanInstances/Network.hs +++ b/cardano-node/src/Cardano/Tracing/OrphanInstances/Network.hs @@ -61,9 +61,8 @@ import Ouroboros.Network.NodeToNode (ErrorPolicyTrace (..), NodeToNode import qualified Ouroboros.Network.NodeToNode as NtN import Ouroboros.Network.PeerSelection.Bootstrap import Ouroboros.Network.PeerSelection.Governor (DebugPeerSelection (..), - DebugPeerSelectionState (..), PeerSelectionCounters, - PeerSelectionView (..), PeerSelectionState (..), - PeerSelectionTargets (..), TracePeerSelection (..), + DebugPeerSelectionState (..), PeerSelectionCounters, PeerSelectionState (..), + PeerSelectionTargets (..), PeerSelectionView (..), TracePeerSelection (..), peerSelectionStateToCounters) import Ouroboros.Network.PeerSelection.LedgerPeers import Ouroboros.Network.PeerSelection.PeerSharing (PeerSharing (..)) @@ -98,7 +97,6 @@ import Ouroboros.Network.Protocol.TxSubmission2.Type as TxSubmission2 import Ouroboros.Network.RethrowPolicy (ErrorCommand (..)) import Ouroboros.Network.Server2 (ServerTrace (..)) import qualified Ouroboros.Network.Server2 as Server -import Ouroboros.Network.SizeInBytes (SizeInBytes (..)) import Ouroboros.Network.Snocket (LocalAddress (..)) import Ouroboros.Network.Subscription (ConnectResult (..), DnsTrace (..), SubscriberError (..), SubscriptionTrace (..), WithDomainName (..), @@ -2179,6 +2177,7 @@ instance ToJSON NodeToClientVersion where toJSON NodeToClientV_14 = Number 14 toJSON NodeToClientV_15 = Number 15 toJSON NodeToClientV_16 = Number 16 + toJSON NodeToClientV_17 = Number 17 instance FromJSON NodeToClientVersion where parseJSON (Number 9) = return NodeToClientV_9 diff --git a/cardano-node/src/Cardano/Tracing/OrphanInstances/Shelley.hs b/cardano-node/src/Cardano/Tracing/OrphanInstances/Shelley.hs index 2fc41ecfe63..a8b7f0c578e 100644 --- a/cardano-node/src/Cardano/Tracing/OrphanInstances/Shelley.hs +++ b/cardano-node/src/Cardano/Tracing/OrphanInstances/Shelley.hs @@ -1309,6 +1309,7 @@ instance ToJSON ShelleyNodeToClientVersion where toJSON ShelleyNodeToClientVersion6 = String "ShelleyNodeToClientVersion6" toJSON ShelleyNodeToClientVersion7 = String "ShelleyNodeToClientVersion7" toJSON ShelleyNodeToClientVersion8 = String "ShelleyNodeToClientVersion8" + toJSON ShelleyNodeToClientVersion9 = String "ShelleyNodeToClientVersion9" instance Ledger.Crypto c => ToObject (PraosChainSelectView c) where toObject _ PraosChainSelectView { diff --git a/cardano-node/src/Cardano/Tracing/Tracers.hs b/cardano-node/src/Cardano/Tracing/Tracers.hs index 934a5091612..91e507c5471 100644 --- a/cardano-node/src/Cardano/Tracing/Tracers.hs +++ b/cardano-node/src/Cardano/Tracing/Tracers.hs @@ -496,11 +496,13 @@ mkTracers _ _ _ _ _ enableP2P = { Consensus.chainSyncClientTracer = nullTracer , Consensus.chainSyncServerHeaderTracer = nullTracer , Consensus.chainSyncServerBlockTracer = nullTracer + , Consensus.consensusSanityCheckTracer = nullTracer , Consensus.blockFetchDecisionTracer = nullTracer , Consensus.blockFetchClientTracer = nullTracer , Consensus.blockFetchServerTracer = nullTracer , Consensus.keepAliveClientTracer = nullTracer , Consensus.forgeStateInfoTracer = nullTracer + , Consensus.gddTracer = nullTracer , Consensus.txInboundTracer = nullTracer , Consensus.txOutboundTracer = nullTracer , Consensus.localTxSubmissionServerTracer = nullTracer @@ -757,7 +759,6 @@ mkConsensusTracers mbEKGDirect trSel verb tr nodeKern fStats = do tBlockDelayCDF1s <- STM.newTVarIO $ CdfCounter 0 tBlockDelayCDF3s <- STM.newTVarIO $ CdfCounter 0 tBlockDelayCDF5s <- STM.newTVarIO $ CdfCounter 0 - pure Consensus.Tracers { Consensus.chainSyncClientTracer = tracerOnOff (traceChainSyncClient trSel) verb "ChainSyncClient" tr , Consensus.chainSyncServerHeaderTracer = @@ -765,6 +766,7 @@ mkConsensusTracers mbEKGDirect trSel verb tr nodeKern fStats = do (annotateSeverity . toLogObject' verb $ appendName "ChainSyncHeaderServer" tr) <> (\(TraceLabelPeer _ ev) -> ev) `contramap` Tracer (traceServedCount mbEKGDirect) , Consensus.chainSyncServerBlockTracer = tracerOnOff (traceChainSyncBlockServer trSel) verb "ChainSyncBlockServer" tr + , Consensus.consensusSanityCheckTracer = nullTracer -- error "TODO" , Consensus.blockFetchDecisionTracer = tracerOnOff' (traceBlockFetchDecisions trSel) $ annotateSeverity $ teeTraceBlockFetchDecision verb elidedFetchDecision tr , Consensus.blockFetchClientTracer = traceBlockFetchClientMetrics mbEKGDirect tBlockDelayM @@ -772,6 +774,7 @@ mkConsensusTracers mbEKGDirect trSel verb tr nodeKern fStats = do tracerOnOff (traceBlockFetchClient trSel) verb "BlockFetchClient" tr , Consensus.blockFetchServerTracer = traceBlockFetchServerMetrics trmet meta tBlocksServed tLocalUp tMaxSlotNo $ tracerOnOff (traceBlockFetchServer trSel) verb "BlockFetchServer" tr + , Consensus.gddTracer = nullTracer -- error "TODO" , Consensus.keepAliveClientTracer = tracerOnOff (traceKeepAliveClient trSel) verb "KeepAliveClient" tr , Consensus.forgeStateInfoTracer = tracerOnOff' (traceForgeStateInfo trSel) $ forgeStateInfoTracer (Proxy @blk) trSel tr From 27ffa6830b938de4ddbc85fe851a2a332f72323f Mon Sep 17 00:00:00 2001 From: Jordan Millar Date: Fri, 6 Sep 2024 17:11:35 -0400 Subject: [PATCH 06/15] cardano-testnet changes --- .../src/Testnet/Components/Query.hs | 2 +- .../src/Testnet/Process/Cli/SPO.hs | 2 +- cardano-testnet/src/Testnet/Runtime.hs | 10 +++++---- .../files/golden/help/cardano.cli | 15 ++++++++----- .../Cardano/Testnet/Test/Cli/Conway/Plutus.hs | 4 +++- .../Cardano/Testnet/Test/Cli/KesPeriodInfo.hs | 13 ++++++++--- .../Cli/{Babbage => }/LeadershipSchedule.hs | 14 ++++++------ .../Cardano/Testnet/Test/Cli/Query.hs | 9 ++------ .../Test/Cli/{Babbage => }/StakeSnapshot.hs | 4 ++-- .../Test/Cli/{Babbage => }/Transaction.hs | 15 ++++++++----- .../Testnet/Test/Gov/CommitteeAddNew.hs | 4 +++- .../Cardano/Testnet/Test/Gov/NoConfidence.hs | 2 +- .../Test/Gov/ProposeNewConstitution.hs | 2 +- .../SubmitApi/{Babbage => }/Transaction.hs | 16 ++++++++------ .../cardano-testnet-test.hs | 22 +++++++++---------- .../golden/tx.failed.response.json.golden | 18 +++------------ 16 files changed, 79 insertions(+), 73 deletions(-) rename cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/{Babbage => }/LeadershipSchedule.hs (97%) rename cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/{Babbage => }/StakeSnapshot.hs (91%) rename cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/{Babbage => }/Transaction.hs (90%) rename cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/SubmitApi/{Babbage => }/Transaction.hs (93%) diff --git a/cardano-testnet/src/Testnet/Components/Query.hs b/cardano-testnet/src/Testnet/Components/Query.hs index 226bc232f7e..5fc41dd6e2f 100644 --- a/cardano-testnet/src/Testnet/Components/Query.hs +++ b/cardano-testnet/src/Testnet/Components/Query.hs @@ -414,7 +414,7 @@ checkDRepState -> m a checkDRepState epochStateView@EpochStateView{nodeConfigPath, socketPath} sbe f = withFrozenCallStack $ do currentEpoch <- getCurrentEpochNo epochStateView - let terminationEpoch = succ . succ $ currentEpoch + let terminationEpoch = succ . succ . succ $ currentEpoch result <- H.evalIO . runExceptT $ foldEpochState nodeConfigPath socketPath QuickValidation terminationEpoch Nothing $ \(AnyNewEpochState actualEra newEpochState) _slotNumber _blockNumber -> do Refl <- either error pure $ assertErasEqual sbe actualEra diff --git a/cardano-testnet/src/Testnet/Process/Cli/SPO.hs b/cardano-testnet/src/Testnet/Process/Cli/SPO.hs index 4161bb25f0e..0a49b4c2b73 100644 --- a/cardano-testnet/src/Testnet/Process/Cli/SPO.hs +++ b/cardano-testnet/src/Testnet/Process/Cli/SPO.hs @@ -346,7 +346,7 @@ registerSingleSpo identifier tap@(TmpAbsolutePath tempAbsPath') nodeConfigFile s createStakeKeyRegistrationCertificate tap asbe poolOwnerstakeVkeyFp - 2_000_000 + 0 (workDir "pledger.regcert") void $ execCli' execConfig diff --git a/cardano-testnet/src/Testnet/Runtime.hs b/cardano-testnet/src/Testnet/Runtime.hs index e05ed778961..df528690f80 100644 --- a/cardano-testnet/src/Testnet/Runtime.hs +++ b/cardano-testnet/src/Testnet/Runtime.hs @@ -5,6 +5,7 @@ {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE GADTs #-} {-# LANGUAGE LambdaCase #-} +{-# LANGUAGE NumericUnderscores #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE ScopedTypeVariables #-} @@ -116,7 +117,7 @@ startNode -> [String] -- ^ The command --socket-path will be added automatically. -> ExceptT NodeStartFailure m NodeRuntime -startNode tp node ipv4 port testnetMagic nodeCmd = GHC.withFrozenCallStack $ do +startNode tp node ipv4 port _testnetMagic nodeCmd = GHC.withFrozenCallStack $ do let tempBaseAbsPath = makeTmpBaseAbsPath tp socketDir = makeSocketDir tp logDir = makeLogDir tp @@ -190,10 +191,11 @@ startNode tp node ipv4 port testnetMagic nodeCmd = GHC.withFrozenCallStack $ do NodeExecutableError . hsep $ ["Socket", pretty socketAbsPath, "was not created after 30 seconds. There was no output on stderr. Exception:", prettyException ioex]) $ hoistEither eSprocketError - + H.threadDelay 5_000_000 -- Ping node and fail on error - Ping.pingNode (fromIntegral testnetMagic) sprocket - >>= (firstExceptT (NodeExecutableError . ("Ping error:" <+>) . prettyError) . hoistEither) + -- TODO: Need to update cardano-ping with N2C version 17 + -- Ping.pingNode (fromIntegral testnetMagic) sprocket + -- >>= (firstExceptT (NodeExecutableError . ("Ping error:" <+>) . prettyError) . hoistEither) pure $ NodeRuntime node ipv4 port sprocket stdIn nodeStdoutFile nodeStderrFile hProcess where diff --git a/cardano-testnet/test/cardano-testnet-golden/files/golden/help/cardano.cli b/cardano-testnet/test/cardano-testnet-golden/files/golden/help/cardano.cli index 98eb490d148..c84a57ba17c 100644 --- a/cardano-testnet/test/cardano-testnet-golden/files/golden/help/cardano.cli +++ b/cardano-testnet/test/cardano-testnet-golden/files/golden/help/cardano.cli @@ -22,11 +22,16 @@ Available options: --num-pool-nodes COUNT Number of pool nodes. Note this uses a default node configuration for all nodes. (default: [SpoTestnetNodeOptions Nothing [],SpoTestnetNodeOptions Nothing [],SpoTestnetNodeOptions Nothing []]) - --shelley-era Specify the Shelley era - --allegra-era Specify the Allegra era - --mary-era Specify the Mary era - --alonzo-era Specify the Alonzo era - --babbage-era Specify the Babbage era (default) + --shelley-era Specify the Shelley era - DEPRECATED - will be + removed in the future + --allegra-era Specify the Allegra era - DEPRECATED - will be + removed in the future + --mary-era Specify the Mary era - DEPRECATED - will be removed + in the future + --alonzo-era Specify the Alonzo era - DEPRECATED - will be removed + in the future + --babbage-era Specify the Babbage era (default) - DEPRECATED - will + be removed in the future --conway-era Specify the Conway era --epoch-length SLOTS Epoch length, in number of slots (default: 500) --slot-length SECONDS Slot length (default: 0.1) diff --git a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Conway/Plutus.hs b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Conway/Plutus.hs index 1d055d361c9..2975e7976f4 100644 --- a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Conway/Plutus.hs +++ b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Conway/Plutus.hs @@ -41,6 +41,8 @@ import qualified Hedgehog.Extras as H -- Certifying YES -- Voting NO -- Proposing NO +-- Execute me with: +-- @DISABLE_RETRIES=1 cabal test cardano-testnet-test --test-options '-p "/PlutusV3/"'@ hprop_plutus_v3 :: Property hprop_plutus_v3 = integrationWorkspace "all-plutus-script-purposes" $ \tempAbsBasePath' -> H.runWithDefaultWatchdog_ $ do H.note_ SYS.os @@ -139,7 +141,7 @@ hprop_plutus_v3 = integrationWorkspace "all-plutus-script-purposes" $ \tempAbsBa -- 2. Successfully spend conway spending script txinCollateral <- findLargestUtxoForPaymentKey epochStateView sbe wallet1 - plutusScriptTxIn <- fmap fst . retryUntilJustM epochStateView (WaitForBlocks 3) $ + plutusScriptTxIn <- fmap fst . retryUntilJustM epochStateView (WaitForBlocks 10) $ findLargestUtxoWithAddress epochStateView sbe $ Text.pack plutusSpendingScriptAddr let spendScriptUTxOTxBody = work "spend-script-utxo-tx-body" 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 00b32ee2837..8a664111275 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 @@ -48,6 +48,9 @@ import qualified Hedgehog.Extras.Test.Base as H import qualified Hedgehog.Extras.Test.File as H import qualified Hedgehog.Extras.Test.TestWatchdog as H + +-- | Execute me with: +-- @DISABLE_RETRIES=1 cabal test cardano-testnet-test --test-options '-p "/kes-period-info/"'@ hprop_kes_period_info :: Property hprop_kes_period_info = integrationRetryWorkspace 2 "kes-period-info" $ \tempAbsBasePath' -> H.runWithDefaultWatchdog_ $ do H.note_ SYS.os @@ -56,7 +59,7 @@ hprop_kes_period_info = integrationRetryWorkspace 2 "kes-period-info" $ \tempAbs <- mkConf tempAbsBasePath' let tempBaseAbsPath = makeTmpBaseAbsPath tempAbsPath - sbe = ShelleyBasedEraBabbage + sbe = ShelleyBasedEraConway eraString = eraToString sbe cTestnetOptions = cardanoDefaultTestnetOptions { cardanoNodeEra = AnyShelleyBasedEra sbe -- TODO: We should only support the latest era and the upcoming era @@ -95,7 +98,9 @@ hprop_kes_period_info = integrationRetryWorkspace 2 "kes-period-info" $ \tempAbs cTestnetOptions execConfig (txin1, utxoSKeyFile, utxoAddr) - + + H.noteShow_ $ "Test SPO stake pool id: " <> stakePoolId + -- Create test stake address to delegate to the new stake pool -- NB: We need to fund the payment credential of the overall address -------------------------------------------------------------- @@ -135,7 +140,7 @@ hprop_kes_period_info = integrationRetryWorkspace 2 "kes-period-info" $ \tempAbs tempAbsPath (cardanoNodeEra cTestnetOptions) testDelegatorVkeyFp - 2_000_000 + 0 testDelegatorRegCertFp -- Test stake address deleg cert @@ -340,6 +345,8 @@ hprop_kes_period_info = integrationRetryWorkspace 2 "kes-period-info" $ \tempAbs [ "query", "stake-snapshot" , "--all-stake-pools" ] + + -- TODO: Create a check here that confirms there are four stake pools and each has stake! H.writeFile (work "stake-snapshot-2.json") stakeSnapshot2 ledgerStateJson2 <- execCli' execConfig 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/LeadershipSchedule.hs similarity index 97% rename from cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Babbage/LeadershipSchedule.hs rename to cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/LeadershipSchedule.hs index cd3e8b6209c..7d505c86880 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/LeadershipSchedule.hs @@ -9,7 +9,7 @@ {-# OPTIONS_GHC -Wno-unrecognised-pragmas #-} {- HLINT ignore "Redundant id" -} -module Cardano.Testnet.Test.Cli.Babbage.LeadershipSchedule +module Cardano.Testnet.Test.Cli.LeadershipSchedule ( hprop_leadershipSchedule ) where @@ -55,11 +55,12 @@ import qualified Hedgehog.Extras.Test.TestWatchdog as H -- | Execute me with: -- @DISABLE_RETRIES=1 cabal test cardano-testnet-test --test-options '-p "/leadership-schedule/"'@ hprop_leadershipSchedule :: Property -hprop_leadershipSchedule = integrationRetryWorkspace 2 "babbage-leadership-schedule" $ \tempAbsBasePath' -> H.runWithDefaultWatchdog_ $ do +hprop_leadershipSchedule = integrationRetryWorkspace 2 "leadership-schedule" $ \tempAbsBasePath' -> H.runWithDefaultWatchdog_ $ do H.note_ SYS.os conf@Conf { tempAbsPath=tempAbsPath@(TmpAbsolutePath work) } <- mkConf tempAbsBasePath' let tempBaseAbsPath = makeTmpBaseAbsPath tempAbsPath - sbe = shelleyBasedEra @BabbageEra + sbe = shelleyBasedEra @ConwayEra + eraString = eraToString sbe cTestnetOptions = cardanoDefaultTestnetOptions { cardanoNodeEra = AnyShelleyBasedEra sbe -- TODO: We should only support the latest era and the upcoming era } @@ -78,7 +79,7 @@ hprop_leadershipSchedule = integrationRetryWorkspace 2 "babbage-leadership-sched let utxoAddr = Text.unpack $ paymentKeyInfoAddr wallet0 utxoSKeyFile = signingKeyFp $ paymentKeyInfoPair wallet0 void $ execCli' execConfig - [ "conway", "query", "utxo" + [ eraString, "query", "utxo" , "--address", utxoAddr , "--cardano-mode" , "--out-file", work "utxo-1.json" @@ -137,7 +138,7 @@ hprop_leadershipSchedule = integrationRetryWorkspace 2 "babbage-leadership-sched tempAbsPath (cardanoNodeEra cTestnetOptions) testDelegatorVkeyFp - 2_000_000 + 0 testDelegatorRegCertFp -- Test stake address deleg cert @@ -164,8 +165,7 @@ hprop_leadershipSchedule = integrationRetryWorkspace 2 "babbage-leadership-sched UTxO utxo2 <- H.noteShowM $ decodeEraUTxO sbe utxo2Json txin2 <- H.noteShow =<< H.headM (Map.keys utxo2) - let eraString = eraToString sbe - delegRegTestDelegatorTxBodyFp = work "deleg-register-test-delegator.txbody" + let delegRegTestDelegatorTxBodyFp = work "deleg-register-test-delegator.txbody" void $ execCli' execConfig [ eraString diff --git a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Query.hs b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Query.hs index 1ad6d8e4a11..a5a0e01a109 100644 --- a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Query.hs +++ b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Query.hs @@ -159,11 +159,6 @@ hprop_cli_queries = integrationWorkspace "cli-queries" $ \tempAbsBasePath' -> H. protocolParametersOutFile "test/cardano-testnet-test/files/golden/queries/protocolParametersFileOut.json" - TestQueryConstitutionHashCmd -> - -- constitution-hash - -- Currently disabled (not accessible from the command line) - pure () - TestQueryTipCmd -> -- tip do @@ -346,7 +341,7 @@ hprop_cli_queries = integrationWorkspace "cli-queries" $ \tempAbsBasePath' -> H. submitTx execConfig cEra signedTx -- Wait until transaction is on chain and obtain transaction identifier txId <- retrieveTransactionId execConfig signedTx - txIx <- H.evalMaybeM $ watchEpochStateUpdate epochStateView (EpochInterval 2) (getTxIx sbe txId transferAmount) + txIx <- H.evalMaybeM $ watchEpochStateUpdate epochStateView (EpochInterval 3) (getTxIx sbe txId transferAmount) -- Query the reference script size let protocolParametersOutFile = refScriptSizeWork "ref-script-size-out.json" H.noteM_ $ execCli' execConfig [ eraName, "query", "ref-script-size" @@ -517,4 +512,4 @@ redactJsonFields changes v = Aeson.Array $ Vector.map recurse vector _ -> v where - recurse = redactJsonFields changes \ No newline at end of file + recurse = redactJsonFields changes diff --git a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Babbage/StakeSnapshot.hs b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/StakeSnapshot.hs similarity index 91% rename from cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Babbage/StakeSnapshot.hs rename to cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/StakeSnapshot.hs index 7dfd0273842..997f9723658 100644 --- a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Babbage/StakeSnapshot.hs +++ b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/StakeSnapshot.hs @@ -3,7 +3,7 @@ {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE ScopedTypeVariables #-} -module Cardano.Testnet.Test.Cli.Babbage.StakeSnapshot +module Cardano.Testnet.Test.Cli.StakeSnapshot ( hprop_stakeSnapshot ) where @@ -30,7 +30,7 @@ import qualified Hedgehog.Extras.Test.Base as H import qualified Hedgehog.Extras.Test.TestWatchdog as H hprop_stakeSnapshot :: Property -hprop_stakeSnapshot = integrationRetryWorkspace 2 "babbage-stake-snapshot" $ \tempAbsBasePath' -> H.runWithDefaultWatchdog_ $ do +hprop_stakeSnapshot = integrationRetryWorkspace 2 "stake-snapshot" $ \tempAbsBasePath' -> H.runWithDefaultWatchdog_ $ do H.note_ SYS.os conf@Conf { tempAbsPath } <- mkConf tempAbsBasePath' let tempAbsPath' = unTmpAbsPath tempAbsPath diff --git a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Babbage/Transaction.hs b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Transaction.hs similarity index 90% rename from cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Babbage/Transaction.hs rename to cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Transaction.hs index 667af8c7995..1df5fda221c 100644 --- a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Babbage/Transaction.hs +++ b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Transaction.hs @@ -6,7 +6,7 @@ {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeApplications #-} -module Cardano.Testnet.Test.Cli.Babbage.Transaction +module Cardano.Testnet.Test.Cli.Transaction ( hprop_transaction ) where @@ -39,15 +39,19 @@ import qualified Hedgehog.Extras.Test.Base as H import qualified Hedgehog.Extras.Test.File as H import qualified Hedgehog.Extras.Test.TestWatchdog as H + +-- | Execute me with: +-- @DISABLE_RETRIES=1 cabal test cardano-testnet-test --test-options '-p "/simple transaction build/"'@ hprop_transaction :: Property -hprop_transaction = integrationRetryWorkspace 0 "babbage-transaction" $ \tempAbsBasePath' -> H.runWithDefaultWatchdog_ $ do +hprop_transaction = integrationRetryWorkspace 0 "simple transaction build" $ \tempAbsBasePath' -> H.runWithDefaultWatchdog_ $ do H.note_ SYS.os conf@Conf { tempAbsPath } <- mkConf tempAbsBasePath' let tempAbsPath' = unTmpAbsPath tempAbsPath work <- H.createDirectoryIfMissing $ tempAbsPath' "work" let - sbe = ShelleyBasedEraBabbage + sbe = ShelleyBasedEraConway + txEra = AsConwayEra era = toCardanoEra sbe cEra = AnyCardanoEra era tempBaseAbsPath = makeTmpBaseAbsPath $ TmpAbsolutePath tempAbsPath' @@ -95,14 +99,15 @@ hprop_transaction = integrationRetryWorkspace 0 "babbage-transaction" $ \tempAbs , "--out-file", txbodyFp ] cddlUnwitnessedTx <- H.readJsonFileOk txbodyFp - apiTx <- H.evalEither $ deserialiseFromTextEnvelope (AsTx AsBabbageEra) cddlUnwitnessedTx + apiTx <- H.evalEither $ deserialiseFromTextEnvelope (AsTx txEra) cddlUnwitnessedTx let txFee = L.unCoin $ extractTxFee apiTx -- This is the current calculated fee. -- It's a sanity check to see if anything has -- changed regarding fee calculation. -- 8.10 changed fee from 228 -> 330 - 330 H.=== txFee + -- 9.2 changed fee from 330 -> 336 + 336 H.=== txFee void $ execCli' execConfig [ anyEraToString cEra, "transaction", "sign" diff --git a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/CommitteeAddNew.hs b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/CommitteeAddNew.hs index 2875b5e6415..595aa18d460 100644 --- a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/CommitteeAddNew.hs +++ b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/CommitteeAddNew.hs @@ -48,6 +48,8 @@ import Testnet.Types import Hedgehog import qualified Hedgehog.Extras as H +-- | Execute me with: +-- @DISABLE_RETRIES=1 cabal test cardano-testnet-test --test-options '-p "/Committee Add New/"'@ hprop_constitutional_committee_add_new :: Property hprop_constitutional_committee_add_new = integrationWorkspace "constitutional-committee-add-new" $ \tempAbsBasePath' -> H.runWithDefaultWatchdog_ $ do conf@Conf { tempAbsPath } <- mkConf tempAbsBasePath' @@ -176,7 +178,7 @@ hprop_constitutional_committee_add_new = integrationWorkspace "constitutional-co governanceActionTxId <- H.noteM $ retrieveTransactionId execConfig signedProposalTx governanceActionIx <- - H.nothingFailM . watchEpochStateUpdate epochStateView (L.EpochInterval 1) $ \(anyNewEpochState, _, _) -> + H.nothingFailM . watchEpochStateUpdate epochStateView (L.EpochInterval 2) $ \(anyNewEpochState, _, _) -> pure $ maybeExtractGovernanceActionIndex (fromString governanceActionTxId) anyNewEpochState dRepVoteFiles <- diff --git a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/NoConfidence.hs b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/NoConfidence.hs index 295bff66dee..1df67a39a5d 100644 --- a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/NoConfidence.hs +++ b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/NoConfidence.hs @@ -221,7 +221,7 @@ hprop_gov_no_confidence = integrationWorkspace "no-confidence" $ \tempAbsBasePat submitTx execConfig cEra voteTxFp -- Tally votes - waitForGovActionVotes epochStateView (EpochInterval 1) + waitForGovActionVotes epochStateView (EpochInterval 2) govState <- getGovState epochStateView ceo govActionState <- H.headM $ govState ^. L.cgsProposalsL . L.pPropsL . to toList diff --git a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/ProposeNewConstitution.hs b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/ProposeNewConstitution.hs index 93aff8bb7fe..1b53c4f3185 100644 --- a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/ProposeNewConstitution.hs +++ b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/ProposeNewConstitution.hs @@ -182,7 +182,7 @@ hprop_ledger_events_propose_new_constitution = integrationWorkspace "propose-new submitTx execConfig cEra voteTxFp - waitForGovActionVotes epochStateView (EpochInterval 1) + waitForGovActionVotes epochStateView (EpochInterval 2) -- Count votes before checking for ratification. It may happen that the proposal gets removed after -- ratification because of a long waiting time, so we won't be able to access votes. diff --git a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/SubmitApi/Babbage/Transaction.hs b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/SubmitApi/Transaction.hs similarity index 93% rename from cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/SubmitApi/Babbage/Transaction.hs rename to cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/SubmitApi/Transaction.hs index fc6c6c93788..14a4e60e58c 100644 --- a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/SubmitApi/Babbage/Transaction.hs +++ b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/SubmitApi/Transaction.hs @@ -6,7 +6,7 @@ {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeApplications #-} -module Cardano.Testnet.Test.SubmitApi.Babbage.Transaction +module Cardano.Testnet.Test.SubmitApi.Transaction ( hprop_transaction ) where @@ -35,6 +35,7 @@ import System.FilePath (()) import qualified System.Info as SYS import Text.Regex (mkRegex, subRegex) +import Testnet.Components.Configuration import Testnet.Process.Run (execCli', mkExecConfig, procSubmitApi) import Testnet.Property.Util (decodeEraUTxO, integrationRetryWorkspace) import Testnet.SubmitApi @@ -48,11 +49,12 @@ import qualified Hedgehog.Extras.Test.Golden as H import qualified Hedgehog.Extras.Test.TestWatchdog as H hprop_transaction :: Property -hprop_transaction = integrationRetryWorkspace 0 "submit-api-babbage-transaction" $ \tempAbsBasePath' -> H.runWithDefaultWatchdog_ $ do +hprop_transaction = integrationRetryWorkspace 0 "submit-api-transaction" $ \tempAbsBasePath' -> H.runWithDefaultWatchdog_ $ do H.note_ SYS.os conf@Conf { tempAbsPath } <- mkConf tempAbsBasePath' let tempAbsPath' = unTmpAbsPath tempAbsPath - sbe = ShelleyBasedEraBabbage + sbe = ShelleyBasedEraConway + eraString = eraToString sbe tempBaseAbsPath = makeTmpBaseAbsPath $ TmpAbsolutePath tempAbsPath' options = cardanoDefaultTestnetOptions { cardanoNodeEra = AnyShelleyBasedEra sbe -- TODO: We should only support the latest era and the upcoming era @@ -87,7 +89,7 @@ hprop_transaction = integrationRetryWorkspace 0 "submit-api-babbage-transaction" txFailedResponseYamlGoldenFp <- H.note "test/cardano-testnet-test/files/golden/tx.failed.response.json.golden" void $ execCli' execConfig - [ "babbage", "query", "utxo" + [ eraString, "query", "utxo" , "--address", Text.unpack $ paymentKeyInfoAddr wallet0 , "--cardano-mode" , "--out-file", work "utxo-1.json" @@ -98,7 +100,7 @@ hprop_transaction = integrationRetryWorkspace 0 "submit-api-babbage-transaction" txin1 <- H.noteShow =<< H.headM (Map.keys utxo1) void $ execCli' execConfig - [ "babbage", "transaction", "build" + [ eraString, "transaction", "build" , "--change-address", Text.unpack $ paymentKeyInfoAddr wallet0 , "--tx-in", Text.unpack $ renderTxIn txin1 , "--tx-out", Text.unpack (paymentKeyInfoAddr wallet0) <> "+" <> show @Int 5_000_001 @@ -106,7 +108,7 @@ hprop_transaction = integrationRetryWorkspace 0 "submit-api-babbage-transaction" ] void $ execCli' execConfig - [ "babbage", "transaction", "sign" + [ eraString, "transaction", "sign" , "--tx-body-file", txbodyFp , "--signing-key-file", signingKeyFp $ paymentKeyInfoPair wallet0 , "--out-file", txbodySignedFp @@ -143,7 +145,7 @@ hprop_transaction = integrationRetryWorkspace 0 "submit-api-babbage-transaction" H.byDurationM 5 45 "Expected UTxO found" $ do void $ execCli' execConfig - [ "babbage", "query", "utxo" + [ eraString, "query", "utxo" , "--address", Text.unpack $ paymentKeyInfoAddr wallet0 , "--cardano-mode" , "--out-file", work "utxo-2.json" diff --git a/cardano-testnet/test/cardano-testnet-test/cardano-testnet-test.hs b/cardano-testnet/test/cardano-testnet-test/cardano-testnet-test.hs index 636d0c717f0..a0c2bb23658 100644 --- a/cardano-testnet/test/cardano-testnet-test/cardano-testnet-test.hs +++ b/cardano-testnet/test/cardano-testnet-test/cardano-testnet-test.hs @@ -5,9 +5,9 @@ module Main ) where import qualified Cardano.Crypto.Init as Crypto -import qualified Cardano.Testnet.Test.Cli.Babbage.LeadershipSchedule -import qualified Cardano.Testnet.Test.Cli.Babbage.StakeSnapshot -import qualified Cardano.Testnet.Test.Cli.Babbage.Transaction +import qualified Cardano.Testnet.Test.Cli.LeadershipSchedule +import qualified Cardano.Testnet.Test.Cli.StakeSnapshot +import qualified Cardano.Testnet.Test.Cli.Transaction import qualified Cardano.Testnet.Test.Cli.Conway.Plutus import qualified Cardano.Testnet.Test.Cli.KesPeriodInfo import qualified Cardano.Testnet.Test.Cli.Query @@ -26,7 +26,7 @@ import qualified Cardano.Testnet.Test.Gov.TreasuryGrowth as Gov import qualified Cardano.Testnet.Test.Gov.TreasuryWithdrawal as Gov import qualified Cardano.Testnet.Test.Node.Shutdown import qualified Cardano.Testnet.Test.SanityCheck as LedgerEvents -import qualified Cardano.Testnet.Test.SubmitApi.Babbage.Transaction +import qualified Cardano.Testnet.Test.SubmitApi.Transaction import Prelude @@ -78,11 +78,10 @@ tests = do , ignoreOnMacAndWindows "Shutdown On Sigint" Cardano.Testnet.Test.Node.Shutdown.hprop_shutdownOnSigint -- ShutdownOnSlotSynced FAILS Still. The node times out and it seems the "shutdown-on-slot-synced" flag does nothing -- , ignoreOnWindows "ShutdownOnSlotSynced" Cardano.Testnet.Test.Node.Shutdown.hprop_shutdownOnSlotSynced - , T.testGroup "Babbage" - [ ignoreOnMacAndWindows "leadership-schedule" Cardano.Testnet.Test.Cli.Babbage.LeadershipSchedule.hprop_leadershipSchedule -- FAILS - , ignoreOnWindows "stake-snapshot" Cardano.Testnet.Test.Cli.Babbage.StakeSnapshot.hprop_stakeSnapshot - , ignoreOnWindows "transaction" Cardano.Testnet.Test.Cli.Babbage.Transaction.hprop_transaction - ] + , ignoreOnWindows "stake-snapshot" Cardano.Testnet.Test.Cli.StakeSnapshot.hprop_stakeSnapshot + , ignoreOnWindows "simple transaction build" Cardano.Testnet.Test.Cli.Transaction.hprop_transaction + , ignoreOnMacAndWindows "leadership-schedule" Cardano.Testnet.Test.Cli.LeadershipSchedule.hprop_leadershipSchedule + -- TODO: Conway - Re-enable when create-staked is working in conway again --, T.testGroup "Conway" -- [ ignoreOnWindows "stake-snapshot" Cardano.Testnet.Test.Cli.Conway.StakeSnapshot.hprop_stakeSnapshot @@ -96,10 +95,9 @@ tests = do ] ] , T.testGroup "SubmitApi" - [ T.testGroup "Babbage" - [ ignoreOnWindows "transaction" Cardano.Testnet.Test.SubmitApi.Babbage.Transaction.hprop_transaction + [ ignoreOnWindows "transaction" Cardano.Testnet.Test.SubmitApi.Transaction.hprop_transaction ] - ] + ] defaultMainWithIngredientsAndOptions :: [T.Ingredient] -> T.OptionSet -> T.TestTree -> IO () diff --git a/cardano-testnet/test/cardano-testnet-test/files/golden/tx.failed.response.json.golden b/cardano-testnet/test/cardano-testnet-test/files/golden/tx.failed.response.json.golden index c9291f5b15f..fa3deeabecf 100644 --- a/cardano-testnet/test/cardano-testnet-test/files/golden/tx.failed.response.json.golden +++ b/cardano-testnet/test/cardano-testnet-test/files/golden/tx.failed.response.json.golden @@ -2,22 +2,10 @@ "contents": { "contents": { "contents": { - "era": "ShelleyBasedEraBabbage", + "era": "ShelleyBasedEraConway", "error": [ - { - "contents": { - "contents": "AlonzoInBabbageUtxoPredFailure (ValueNotConservedUTxO (MaryValue (Coin 0) (MultiAsset (fromList []))) (MaryValue (Coin 15000003000000) (MultiAsset (fromList []))))", - "tag": "UtxoFailure" - }, - "tag": "UtxowFailure" - }, - { - "contents": { - "contents": "AlonzoInBabbageUtxoPredFailure (BadInputsUTxO (fromList [TxIn (TxId {unTxId = SafeHash \"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\"}) (TxIx {unTxIx = 0})]))", - "tag": "UtxoFailure" - }, - "tag": "UtxowFailure" - } + "ConwayUtxowFailure (UtxoFailure (ValueNotConservedUTxO (MaryValue (Coin 0) (MultiAsset (fromList []))) (MaryValue (Coin 15000003000000) (MultiAsset (fromList [])))))", + "ConwayUtxowFailure (UtxoFailure (BadInputsUTxO (fromList [TxIn (TxId {unTxId = SafeHash \"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\"}) (TxIx {unTxIx = 0})])))" ], "kind": "ShelleyTxValidationError" }, From ec0c8c2b6965f34b6ec5794a7ba45996b32b080a Mon Sep 17 00:00:00 2001 From: Jordan Millar Date: Fri, 6 Sep 2024 17:11:54 -0400 Subject: [PATCH 07/15] tx-generator changes --- .../GeneratorTx/SubmissionClient.hs | 47 +++++++++---------- .../Cardano/TxGenerator/Setup/NodeConfig.hs | 16 +++---- 2 files changed, 29 insertions(+), 34 deletions(-) diff --git a/bench/tx-generator/src/Cardano/Benchmarking/GeneratorTx/SubmissionClient.hs b/bench/tx-generator/src/Cardano/Benchmarking/GeneratorTx/SubmissionClient.hs index e227292c8af..08a21618e74 100644 --- a/bench/tx-generator/src/Cardano/Benchmarking/GeneratorTx/SubmissionClient.hs +++ b/bench/tx-generator/src/Cardano/Benchmarking/GeneratorTx/SubmissionClient.hs @@ -25,43 +25,38 @@ module Cardano.Benchmarking.GeneratorTx.SubmissionClient , txSubmissionClient ) where -import Cardano.Prelude hiding (ByteString, atomically, retry, state, threadDelay) -import Prelude (error, fail) - -import Control.Arrow ((&&&)) - -import qualified Data.List as L -import qualified Data.List.Extra as L -import qualified Data.List.NonEmpty as NE -import qualified Data.Text as T +import Cardano.Api hiding (Active) +import Cardano.Api.Shelley (fromShelleyTxId, toConsensusGenTx) +import Cardano.Benchmarking.LogTypes +import Cardano.Benchmarking.Types +import Cardano.Logging +import Cardano.Prelude hiding (ByteString, atomically, retry, state, threadDelay) import Cardano.Tracing.OrphanInstances.Byron () import Cardano.Tracing.OrphanInstances.Common () import Cardano.Tracing.OrphanInstances.Consensus () import Cardano.Tracing.OrphanInstances.Network () import Cardano.Tracing.OrphanInstances.Shelley () - import qualified Ouroboros.Consensus.Cardano as Consensus (CardanoBlock) +import qualified Ouroboros.Consensus.Cardano.Block as Block + (TxId (GenTxIdAllegra, GenTxIdAlonzo, GenTxIdBabbage, GenTxIdConway, GenTxIdMary, GenTxIdShelley)) import Ouroboros.Consensus.Ledger.SupportsMempool (GenTx, GenTxId, txInBlockSize) import qualified Ouroboros.Consensus.Ledger.SupportsMempool as Mempool import Ouroboros.Consensus.Shelley.Eras (StandardCrypto) import qualified Ouroboros.Consensus.Shelley.Ledger.Mempool as Mempool (TxId (ShelleyTxId)) - -import qualified Ouroboros.Consensus.Cardano.Block as Block - (TxId (GenTxIdAllegra, GenTxIdAlonzo, GenTxIdBabbage, GenTxIdConway, GenTxIdMary, GenTxIdShelley)) - import Ouroboros.Network.Protocol.TxSubmission2.Client (ClientStIdle (..), ClientStTxIds (..), ClientStTxs (..), TxSubmissionClient (..)) import Ouroboros.Network.Protocol.TxSubmission2.Type (BlockingReplyList (..), - TokBlockingStyle (..), TxSizeInBytes) + NumTxIdsToAck (..), NumTxIdsToReq (..), TokBlockingStyle (..)) +import Ouroboros.Network.SizeInBytes -import Cardano.Api hiding (Active) -import Cardano.Api.Shelley (fromShelleyTxId, toConsensusGenTx) - -import Cardano.Logging +import Prelude (error, fail) -import Cardano.Benchmarking.LogTypes -import Cardano.Benchmarking.Types +import Control.Arrow ((&&&)) +import qualified Data.List as L +import qualified Data.List.Extra as L +import qualified Data.List.NonEmpty as NE +import qualified Data.Text as T type CardanoBlock = Consensus.CardanoBlock StandardCrypto data SubmissionThreadStats @@ -129,10 +124,10 @@ txSubmissionClient tr bmtr initialTxSource endOfProtocolCallback = requestTxIds :: forall blocking. LocalState era -> TokBlockingStyle blocking - -> Word16 - -> Word16 + -> NumTxIdsToAck + -> NumTxIdsToReq -> m (ClientStTxIds blocking (GenTxId CardanoBlock) (GenTx CardanoBlock) m ()) - requestTxIds state blocking ackNum reqNum = do + requestTxIds state blocking (NumTxIdsToAck ackNum) (NumTxIdsToReq reqNum) = do let ack = Ack $ fromIntegral ackNum req = Req $ fromIntegral reqNum traceWith tr $ reqIdsTrace ack req blocking @@ -182,8 +177,8 @@ txSubmissionClient tr bmtr initialTxSource endOfProtocolCallback = , stsUnavailable = stsUnavailable stats + Unav (length missIds)})) - txToIdSize :: tx -> (GenTxId CardanoBlock, TxSizeInBytes) - txToIdSize = (Mempool.txId &&& txInBlockSize) . toGenTx + txToIdSize :: tx -> (GenTxId CardanoBlock, SizeInBytes) + txToIdSize = (Mempool.txId &&& (SizeInBytes . txInBlockSize)) . toGenTx toGenTx :: tx -> GenTx CardanoBlock toGenTx tx = toConsensusGenTx $ TxInMode (shelleyBasedEra @era) tx diff --git a/bench/tx-generator/src/Cardano/TxGenerator/Setup/NodeConfig.hs b/bench/tx-generator/src/Cardano/TxGenerator/Setup/NodeConfig.hs index 6dba910fcd0..6e6e97c37e3 100644 --- a/bench/tx-generator/src/Cardano/TxGenerator/Setup/NodeConfig.hs +++ b/bench/tx-generator/src/Cardano/TxGenerator/Setup/NodeConfig.hs @@ -8,14 +8,8 @@ module Cardano.TxGenerator.Setup.NodeConfig (module Cardano.TxGenerator.Setup.NodeConfig) where -import Control.Applicative (Const (Const), getConst) -import Control.Monad.Trans.Except (runExceptT) -import Data.Bifunctor (first) -import Data.Monoid - -import qualified Ouroboros.Consensus.Cardano as Consensus - import Cardano.Api (BlockType (..), ProtocolInfoArgs (..)) + import qualified Cardano.Ledger.Api.Transition as Ledger (tcShelleyGenesisL) import Cardano.Node.Configuration.POM import Cardano.Node.Handlers.Shutdown (ShutdownConfig (..)) @@ -25,6 +19,12 @@ import Cardano.Node.Types (ConfigYamlFilePath (..), GenesisFile, NodeProtocolConfiguration (..), NodeShelleyProtocolConfiguration (..), ProtocolFilepaths (..)) import Cardano.TxGenerator.Types +import qualified Ouroboros.Consensus.Cardano.Node as Consensus + +import Control.Applicative (Const (Const), getConst) +import Control.Monad.Trans.Except (runExceptT) +import Data.Bifunctor (first) +import Data.Monoid -- | extract genesis from a Cardano protocol @@ -35,7 +35,7 @@ getGenesis (SomeConsensusProtocol CardanoBlockType proto) = getConst $ Ledger.tcShelleyGenesisL Const transCfg where ProtocolInfoArgsCardano Consensus.CardanoProtocolParams - { Consensus.ledgerTransitionConfig = transCfg + { Consensus.cardanoLedgerTransitionConfig = transCfg } = proto -- | extract the path to genesis file from a NodeConfiguration for Cardano protocol From 979f9817c69e8e4b0c3ba3ed8d250ee8e07f1a96 Mon Sep 17 00:00:00 2001 From: Jordan Millar Date: Fri, 6 Sep 2024 17:44:38 -0400 Subject: [PATCH 08/15] Remove Win32 --- cardano-node/cardano-node.cabal | 4 ---- 1 file changed, 4 deletions(-) diff --git a/cardano-node/cardano-node.cabal b/cardano-node/cardano-node.cabal index d8ec0334dc5..463395f1954 100644 --- a/cardano-node/cardano-node.cabal +++ b/cardano-node/cardano-node.cabal @@ -38,9 +38,6 @@ common project-config -Wpartial-fields -Wredundant-constraints -Wunused-packages -common maybe-Win32 - if os(windows) - build-depends: Win32 common maybe-unix if !os(windows) @@ -55,7 +52,6 @@ common text library import: project-config , maybe-unix - , maybe-Win32 , text if flag(unexpected_thunks) cpp-options: -DUNEXPECTED_THUNKS From 9b7ee2175a771e1d5d5d4ce254f24f03d81ccdf7 Mon Sep 17 00:00:00 2001 From: Jordan Millar Date: Fri, 6 Sep 2024 18:03:11 -0400 Subject: [PATCH 09/15] Restore windows build --- cardano-node/cardano-node.cabal | 4 ++++ cardano-node/src/Cardano/Node/Run.hs | 7 +++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/cardano-node/cardano-node.cabal b/cardano-node/cardano-node.cabal index 463395f1954..b305b0f0610 100644 --- a/cardano-node/cardano-node.cabal +++ b/cardano-node/cardano-node.cabal @@ -38,6 +38,9 @@ common project-config -Wpartial-fields -Wredundant-constraints -Wunused-packages +common maybe-Win32 + if os(windows) + build-depends: Win32 common maybe-unix if !os(windows) @@ -52,6 +55,7 @@ common text library import: project-config , maybe-unix + , maybe-Win32 , text if flag(unexpected_thunks) cpp-options: -DUNEXPECTED_THUNKS diff --git a/cardano-node/src/Cardano/Node/Run.hs b/cardano-node/src/Cardano/Node/Run.hs index 3d944d96278..a44c07226d1 100644 --- a/cardano-node/src/Cardano/Node/Run.hs +++ b/cardano-node/src/Cardano/Node/Run.hs @@ -112,15 +112,18 @@ import qualified Data.Text.IO as Text import Data.Time.Clock (getCurrentTime) import Data.Time.Clock.POSIX (utcTimeToPOSIXSeconds) import Data.Version (showVersion) -import GHC.Weak (deRefWeak) import Network.HostName (getHostName) import Network.Socket (Socket) import System.Directory (canonicalizePath, createDirectoryIfMissing, makeAbsolute) import System.Environment (lookupEnv) +#ifdef UNIX +import GHC.Weak (deRefWeak) import System.Posix.Files import qualified System.Posix.Signals as Signals import System.Posix.Types (FileMode) - +#else +import System.Win32.File +#endif import Paths_cardano_node (version) From 51196e7402d99f6d4017c2b963a7203eb123a4c7 Mon Sep 17 00:00:00 2001 From: Jordan Millar Date: Fri, 6 Sep 2024 18:03:19 -0400 Subject: [PATCH 10/15] Remove unnecessary cardano-testnet changes --- cardano-testnet/src/Testnet/Components/Query.hs | 2 +- cardano-testnet/src/Testnet/Runtime.hs | 2 +- .../Cardano/Testnet/Test/Cli/Conway/Plutus.hs | 2 +- .../test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Query.hs | 2 +- .../Cardano/Testnet/Test/Gov/CommitteeAddNew.hs | 2 +- .../Cardano/Testnet/Test/Gov/NoConfidence.hs | 2 +- .../Cardano/Testnet/Test/Gov/ProposeNewConstitution.hs | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/cardano-testnet/src/Testnet/Components/Query.hs b/cardano-testnet/src/Testnet/Components/Query.hs index 5fc41dd6e2f..226bc232f7e 100644 --- a/cardano-testnet/src/Testnet/Components/Query.hs +++ b/cardano-testnet/src/Testnet/Components/Query.hs @@ -414,7 +414,7 @@ checkDRepState -> m a checkDRepState epochStateView@EpochStateView{nodeConfigPath, socketPath} sbe f = withFrozenCallStack $ do currentEpoch <- getCurrentEpochNo epochStateView - let terminationEpoch = succ . succ . succ $ currentEpoch + let terminationEpoch = succ . succ $ currentEpoch result <- H.evalIO . runExceptT $ foldEpochState nodeConfigPath socketPath QuickValidation terminationEpoch Nothing $ \(AnyNewEpochState actualEra newEpochState) _slotNumber _blockNumber -> do Refl <- either error pure $ assertErasEqual sbe actualEra diff --git a/cardano-testnet/src/Testnet/Runtime.hs b/cardano-testnet/src/Testnet/Runtime.hs index df528690f80..3671fee2a7c 100644 --- a/cardano-testnet/src/Testnet/Runtime.hs +++ b/cardano-testnet/src/Testnet/Runtime.hs @@ -191,9 +191,9 @@ startNode tp node ipv4 port _testnetMagic nodeCmd = GHC.withFrozenCallStack $ do NodeExecutableError . hsep $ ["Socket", pretty socketAbsPath, "was not created after 30 seconds. There was no output on stderr. Exception:", prettyException ioex]) $ hoistEither eSprocketError - H.threadDelay 5_000_000 -- Ping node and fail on error -- TODO: Need to update cardano-ping with N2C version 17 + H.threadDelay 5_000_000 -- Uncomment below and remove me once cardano-ping has been updated with N2C version 17 -- Ping.pingNode (fromIntegral testnetMagic) sprocket -- >>= (firstExceptT (NodeExecutableError . ("Ping error:" <+>) . prettyError) . hoistEither) diff --git a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Conway/Plutus.hs b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Conway/Plutus.hs index 2975e7976f4..1b755f0f2eb 100644 --- a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Conway/Plutus.hs +++ b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Conway/Plutus.hs @@ -141,7 +141,7 @@ hprop_plutus_v3 = integrationWorkspace "all-plutus-script-purposes" $ \tempAbsBa -- 2. Successfully spend conway spending script txinCollateral <- findLargestUtxoForPaymentKey epochStateView sbe wallet1 - plutusScriptTxIn <- fmap fst . retryUntilJustM epochStateView (WaitForBlocks 10) $ + plutusScriptTxIn <- fmap fst . retryUntilJustM epochStateView (WaitForBlocks 3) $ findLargestUtxoWithAddress epochStateView sbe $ Text.pack plutusSpendingScriptAddr let spendScriptUTxOTxBody = work "spend-script-utxo-tx-body" diff --git a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Query.hs b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Query.hs index a5a0e01a109..71042be20ac 100644 --- a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Query.hs +++ b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Query.hs @@ -341,7 +341,7 @@ hprop_cli_queries = integrationWorkspace "cli-queries" $ \tempAbsBasePath' -> H. submitTx execConfig cEra signedTx -- Wait until transaction is on chain and obtain transaction identifier txId <- retrieveTransactionId execConfig signedTx - txIx <- H.evalMaybeM $ watchEpochStateUpdate epochStateView (EpochInterval 3) (getTxIx sbe txId transferAmount) + txIx <- H.evalMaybeM $ watchEpochStateUpdate epochStateView (EpochInterval 2) (getTxIx sbe txId transferAmount) -- Query the reference script size let protocolParametersOutFile = refScriptSizeWork "ref-script-size-out.json" H.noteM_ $ execCli' execConfig [ eraName, "query", "ref-script-size" diff --git a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/CommitteeAddNew.hs b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/CommitteeAddNew.hs index 595aa18d460..1c8a5f3dd72 100644 --- a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/CommitteeAddNew.hs +++ b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/CommitteeAddNew.hs @@ -178,7 +178,7 @@ hprop_constitutional_committee_add_new = integrationWorkspace "constitutional-co governanceActionTxId <- H.noteM $ retrieveTransactionId execConfig signedProposalTx governanceActionIx <- - H.nothingFailM . watchEpochStateUpdate epochStateView (L.EpochInterval 2) $ \(anyNewEpochState, _, _) -> + H.nothingFailM . watchEpochStateUpdate epochStateView (L.EpochInterval 1) $ \(anyNewEpochState, _, _) -> pure $ maybeExtractGovernanceActionIndex (fromString governanceActionTxId) anyNewEpochState dRepVoteFiles <- diff --git a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/NoConfidence.hs b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/NoConfidence.hs index 1df67a39a5d..295bff66dee 100644 --- a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/NoConfidence.hs +++ b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/NoConfidence.hs @@ -221,7 +221,7 @@ hprop_gov_no_confidence = integrationWorkspace "no-confidence" $ \tempAbsBasePat submitTx execConfig cEra voteTxFp -- Tally votes - waitForGovActionVotes epochStateView (EpochInterval 2) + waitForGovActionVotes epochStateView (EpochInterval 1) govState <- getGovState epochStateView ceo govActionState <- H.headM $ govState ^. L.cgsProposalsL . L.pPropsL . to toList diff --git a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/ProposeNewConstitution.hs b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/ProposeNewConstitution.hs index 1b53c4f3185..93aff8bb7fe 100644 --- a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/ProposeNewConstitution.hs +++ b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/ProposeNewConstitution.hs @@ -182,7 +182,7 @@ hprop_ledger_events_propose_new_constitution = integrationWorkspace "propose-new submitTx execConfig cEra voteTxFp - waitForGovActionVotes epochStateView (EpochInterval 2) + waitForGovActionVotes epochStateView (EpochInterval 1) -- Count votes before checking for ratification. It may happen that the proposal gets removed after -- ratification because of a long waiting time, so we won't be able to access votes. From fec2cc5b23ce9dffb5f8a9f8455d51e0d949006f Mon Sep 17 00:00:00 2001 From: Jordan Millar Date: Fri, 6 Sep 2024 18:09:37 -0400 Subject: [PATCH 11/15] Bump flake --- flake.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/flake.lock b/flake.lock index fe9cc8dbf06..64df81ac7a9 100644 --- a/flake.lock +++ b/flake.lock @@ -3,11 +3,11 @@ "CHaP": { "flake": false, "locked": { - "lastModified": 1725556271, - "narHash": "sha256-+cwhAlF4zGfWC3UTSppYOwZ8SRcAfWU3WweenyvYgLA=", + "lastModified": 1725637923, + "narHash": "sha256-S8Q+s1YulD6MGf5VX7L6U83bEKtv+xZp0y3XlVKl59I=", "owner": "intersectmbo", "repo": "cardano-haskell-packages", - "rev": "c9c0d9f9c76ea1e18d8fb8b744c52bfc39b058c8", + "rev": "8088581d2499d233aa6ba2ac9f5af77f9cb88784", "type": "github" }, "original": { From c6de055c6543d5c584a8d41ca052cdb5221315c7 Mon Sep 17 00:00:00 2001 From: Jordan Millar Date: Fri, 6 Sep 2024 22:59:51 -0400 Subject: [PATCH 12/15] Fix transaction test --- .../Cardano/Testnet/Test/Cli/Transaction.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Transaction.hs b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Transaction.hs index 1df5fda221c..95824fa02b0 100644 --- a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Transaction.hs +++ b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Transaction.hs @@ -133,7 +133,7 @@ hprop_transaction = integrationRetryWorkspace 0 "simple transaction build" $ \te utxo2Json <- H.leftFailM . H.readJsonFile $ work "utxo-2.json" UTxO utxo2 <- H.noteShowM $ decodeEraUTxO sbe utxo2Json txouts2 <- H.noteShow $ L.unCoin . txOutValueLovelace . txOutValue . snd <$> Map.toList utxo2 - H.assert $ 5_000_001 `List.elem` txouts2 + H.assert $ 15_000_003_000_000 `List.elem` txouts2 txOutValue :: TxOut ctx era -> TxOutValue era txOutValue (TxOut _ v _ _) = v From 9757139f4be0a34ae5aa5fe22a5b41e899ce7a15 Mon Sep 17 00:00:00 2001 From: Jordan Millar Date: Mon, 9 Sep 2024 10:01:45 -0400 Subject: [PATCH 13/15] Remove me: SRP cardano-cli --- cabal.project | 9 ++++++++- cardano-testnet/cardano-testnet.cabal | 2 +- cardano-testnet/src/Testnet/Runtime.hs | 10 ++++------ flake.lock | 6 +++--- 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/cabal.project b/cabal.project index d56680584e1..f802fc4f6e2 100644 --- a/cabal.project +++ b/cabal.project @@ -14,7 +14,7 @@ repository cardano-haskell-packages -- you need to run if you change them index-state: , hackage.haskell.org 2024-08-20T21:35:22Z - , cardano-haskell-packages 2024-09-06T15:28:20Z + , cardano-haskell-packages 2024-09-09T11:32:44Z packages: cardano-node @@ -73,3 +73,10 @@ allow-newer: -- Do NOT add more source-repository-package stanzas here unless they are strictly -- temporary! Please read the section in CONTRIBUTING about updating dependencies. +source-repository-package + type: git + location: https://github.com/IntersectMBO/cardano-cli.git + tag: d1d4ddef07614ddbed61b42626e73ae30504382c + --sha256: sha256-sghDLRheKc8I4BAJCggJfH+xotGASg7vkR245EMctrY= + subdir: cardano-cli + diff --git a/cardano-testnet/cardano-testnet.cabal b/cardano-testnet/cardano-testnet.cabal index 4c2815afb0a..61fb091d27f 100644 --- a/cardano-testnet/cardano-testnet.cabal +++ b/cardano-testnet/cardano-testnet.cabal @@ -49,7 +49,7 @@ library , cardano-ledger-core:{cardano-ledger-core, testlib} , cardano-ledger-shelley , cardano-node - , cardano-ping ^>= 0.2.0.13 + , cardano-ping ^>= 0.4 , contra-tracer , containers , data-default-class diff --git a/cardano-testnet/src/Testnet/Runtime.hs b/cardano-testnet/src/Testnet/Runtime.hs index 3671fee2a7c..de9e91e09b5 100644 --- a/cardano-testnet/src/Testnet/Runtime.hs +++ b/cardano-testnet/src/Testnet/Runtime.hs @@ -5,7 +5,6 @@ {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE GADTs #-} {-# LANGUAGE LambdaCase #-} -{-# LANGUAGE NumericUnderscores #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE ScopedTypeVariables #-} @@ -117,7 +116,7 @@ startNode -> [String] -- ^ The command --socket-path will be added automatically. -> ExceptT NodeStartFailure m NodeRuntime -startNode tp node ipv4 port _testnetMagic nodeCmd = GHC.withFrozenCallStack $ do +startNode tp node ipv4 port testnetMagic nodeCmd = GHC.withFrozenCallStack $ do let tempBaseAbsPath = makeTmpBaseAbsPath tp socketDir = makeSocketDir tp logDir = makeLogDir tp @@ -191,11 +190,10 @@ startNode tp node ipv4 port _testnetMagic nodeCmd = GHC.withFrozenCallStack $ do NodeExecutableError . hsep $ ["Socket", pretty socketAbsPath, "was not created after 30 seconds. There was no output on stderr. Exception:", prettyException ioex]) $ hoistEither eSprocketError + -- Ping node and fail on error - -- TODO: Need to update cardano-ping with N2C version 17 - H.threadDelay 5_000_000 -- Uncomment below and remove me once cardano-ping has been updated with N2C version 17 - -- Ping.pingNode (fromIntegral testnetMagic) sprocket - -- >>= (firstExceptT (NodeExecutableError . ("Ping error:" <+>) . prettyError) . hoistEither) + Ping.pingNode (fromIntegral testnetMagic) sprocket + >>= (firstExceptT (NodeExecutableError . ("Ping error:" <+>) . prettyError) . hoistEither) pure $ NodeRuntime node ipv4 port sprocket stdIn nodeStdoutFile nodeStderrFile hProcess where diff --git a/flake.lock b/flake.lock index 64df81ac7a9..d1b6a94ba98 100644 --- a/flake.lock +++ b/flake.lock @@ -3,11 +3,11 @@ "CHaP": { "flake": false, "locked": { - "lastModified": 1725637923, - "narHash": "sha256-S8Q+s1YulD6MGf5VX7L6U83bEKtv+xZp0y3XlVKl59I=", + "lastModified": 1725882485, + "narHash": "sha256-lL70EjKqXpTazTu7VkoGzQOEvEmdpa9/yD3W9x4t+KU=", "owner": "intersectmbo", "repo": "cardano-haskell-packages", - "rev": "8088581d2499d233aa6ba2ac9f5af77f9cb88784", + "rev": "dd0b250a0c215e0e617739e3928deb7e7c8a2f79", "type": "github" }, "original": { From 348576e79ead0b46c47b0588a2f091816251ceed Mon Sep 17 00:00:00 2001 From: Jordan Millar Date: Mon, 9 Sep 2024 14:29:51 -0400 Subject: [PATCH 14/15] Increase waitForGovActionVotes interval from 1 to 2 epochs --- .../Cardano/Testnet/Test/Gov/CommitteeAddNew.hs | 2 +- .../Cardano/Testnet/Test/Gov/NoConfidence.hs | 2 +- .../Cardano/Testnet/Test/Gov/ProposeNewConstitution.hs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/CommitteeAddNew.hs b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/CommitteeAddNew.hs index 1c8a5f3dd72..9f78b57992a 100644 --- a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/CommitteeAddNew.hs +++ b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/CommitteeAddNew.hs @@ -209,7 +209,7 @@ hprop_constitutional_committee_add_new = integrationWorkspace "constitutional-co submitTx execConfig cEra voteTxFp - waitForGovActionVotes epochStateView (L.EpochInterval 1) + waitForGovActionVotes epochStateView (L.EpochInterval 2) govState <- getGovState epochStateView ceo govActionState <- H.headM $ govState ^. L.cgsProposalsL . L.pPropsL . to toList diff --git a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/NoConfidence.hs b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/NoConfidence.hs index 295bff66dee..1df67a39a5d 100644 --- a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/NoConfidence.hs +++ b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/NoConfidence.hs @@ -221,7 +221,7 @@ hprop_gov_no_confidence = integrationWorkspace "no-confidence" $ \tempAbsBasePat submitTx execConfig cEra voteTxFp -- Tally votes - waitForGovActionVotes epochStateView (EpochInterval 1) + waitForGovActionVotes epochStateView (EpochInterval 2) govState <- getGovState epochStateView ceo govActionState <- H.headM $ govState ^. L.cgsProposalsL . L.pPropsL . to toList diff --git a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/ProposeNewConstitution.hs b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/ProposeNewConstitution.hs index 93aff8bb7fe..1b53c4f3185 100644 --- a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/ProposeNewConstitution.hs +++ b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/ProposeNewConstitution.hs @@ -182,7 +182,7 @@ hprop_ledger_events_propose_new_constitution = integrationWorkspace "propose-new submitTx execConfig cEra voteTxFp - waitForGovActionVotes epochStateView (EpochInterval 1) + waitForGovActionVotes epochStateView (EpochInterval 2) -- Count votes before checking for ratification. It may happen that the proposal gets removed after -- ratification because of a long waiting time, so we won't be able to access votes. From ffa12a4e5319f5e93995ea9c1078838cd39ff2c8 Mon Sep 17 00:00:00 2001 From: Mateusz Galazyn Date: Mon, 9 Sep 2024 20:46:37 +0200 Subject: [PATCH 15/15] Add collateral balancing test. --- .../Cardano/Testnet/Test/Cli/Conway/Plutus.hs | 65 +++++++++++++++++-- 1 file changed, 60 insertions(+), 5 deletions(-) diff --git a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Conway/Plutus.hs b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Conway/Plutus.hs index 1b755f0f2eb..170c048ade9 100644 --- a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Conway/Plutus.hs +++ b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Conway/Plutus.hs @@ -16,8 +16,11 @@ import Cardano.Testnet import Prelude -import Control.Monad (void) +import Control.Monad +import Data.List (sortOn) +import Data.Maybe import qualified Data.Text as Text +import GHC.Exts (IsList (..)) import System.FilePath (()) import qualified System.Info as SYS @@ -121,7 +124,7 @@ hprop_plutus_v3 = integrationWorkspace "all-plutus-script-purposes" $ \tempAbsBa [ anyEraToString anyEra, "transaction", "build" , "--change-address", Text.unpack $ paymentKeyInfoAddr wallet0 , "--tx-in", Text.unpack $ renderTxIn txin1 - , "--tx-out", plutusSpendingScriptAddr <> "+" <> show @Int 5_000_000 + , "--tx-out", plutusSpendingScriptAddr <> "+" <> show @Int 50_000_000 , "--tx-out-datum-hash", scriptdatumhash , "--out-file", sendAdaToScriptAddressTxBody ] @@ -141,13 +144,13 @@ hprop_plutus_v3 = integrationWorkspace "all-plutus-script-purposes" $ \tempAbsBa -- 2. Successfully spend conway spending script txinCollateral <- findLargestUtxoForPaymentKey epochStateView sbe wallet1 - plutusScriptTxIn <- fmap fst . retryUntilJustM epochStateView (WaitForBlocks 3) $ + plutusScriptTxIn <- fmap fst . retryUntilJustM epochStateView (WaitForBlocks 20) $ findLargestUtxoWithAddress epochStateView sbe $ Text.pack plutusSpendingScriptAddr let spendScriptUTxOTxBody = work "spend-script-utxo-tx-body" spendScriptUTxOTx = work "spend-script-utxo-tx" mintValue = mconcat ["5 ", mintingPolicyId, ".", assetName] - txout = mconcat [ utxoAddr, "+", show @Int 2_000_000 + txout = mconcat [ utxoAddr, "+", show @Int 20_000_000 , "+", mintValue ] @@ -180,5 +183,57 @@ hprop_plutus_v3 = integrationWorkspace "all-plutus-script-purposes" $ \tempAbsBa [ "transaction", "submit" , "--tx-file", spendScriptUTxOTx ] - H.success + + _ <- waitForBlocks epochStateView 5 + utxos <- sortOn fst . toList <$> findUtxosWithAddress epochStateView sbe (paymentKeyInfoAddr wallet0) + utxoWithAsset <- H.headM $ flip mapMaybe utxos $ \(txin, TxOut _ txoutv _ _) -> + case txoutv of + TxOutValueByron{} -> Nothing + txov@TxOutValueShelleyBased{} -> do + let assets = [ a | a@(AssetId _ _, _)<- toList $ txOutValueToValue txov ] + if null assets + then Nothing + else Just txin + + txin2 <- findLargestUtxoForPaymentKey epochStateView sbe wallet1 + + H.noteM_ $ execCli' execConfig + [ "query", "utxo", "--whole-utxo" ] + + void $ execCli' execConfig + [ anyEraToString anyEra, "transaction", "build" + , "--change-address", Text.unpack $ paymentKeyInfoAddr wallet1 + , "--tx-in-collateral", Text.unpack $ renderTxIn utxoWithAsset + , "--tx-out-return-collateral", utxoAddr <> "+" <> show @Int 2_000_000 <> "+" <> "5 " <> mintingPolicyId <> "." <> assetName + , "--tx-in", Text.unpack $ renderTxIn txin2 + -- , "--tx-in-script-file", plutusScript + -- , "--tx-in-datum-value", "0" + -- , "--tx-in-redeemer-value", "0" + , "--mint", mintValue + , "--mint-script-file", plutusScript + , "--mint-redeemer-value", "0" + -- , "--certificate-file", scriptStakeRegistrationCertificate + -- , "--certificate-script-file", plutusScript + -- , "--certificate-redeemer-value", "0" + , "--tx-out", utxoAddr <> "+1000000" + , "--out-file", spendScriptUTxOTxBody + ] + + H.noteM_ $ execCli' execConfig + [ "debug", "transaction", "view", "--tx-file", spendScriptUTxOTxBody ] + + void $ execCli' execConfig + [ "transaction", "sign" + , "--tx-body-file", spendScriptUTxOTxBody + , "--signing-key-file", utxoSKeyFile + , "--signing-key-file", utxoSKeyFile2 + , "--out-file", spendScriptUTxOTx + ] + + void $ execCli' execConfig + [ "transaction", "submit" + , "--tx-file", spendScriptUTxOTx + ] + + H.failure