From fc66bdbc300bed930495deca4561839bb07a5d14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Hurlin?= Date: Thu, 29 Aug 2024 12:04:42 +0200 Subject: [PATCH 01/10] cardano-testnet: use Default class for testnet options --- cardano-testnet/src/Cardano/Testnet.hs | 1 - cardano-testnet/src/Parsers/Cardano.hs | 13 +++++---- cardano-testnet/src/Testnet/Start/Cardano.hs | 4 +-- cardano-testnet/src/Testnet/Start/Types.hs | 30 ++++++++++---------- 4 files changed, 24 insertions(+), 24 deletions(-) diff --git a/cardano-testnet/src/Cardano/Testnet.hs b/cardano-testnet/src/Cardano/Testnet.hs index c506c054bf3..33ed84e2f23 100644 --- a/cardano-testnet/src/Cardano/Testnet.hs +++ b/cardano-testnet/src/Cardano/Testnet.hs @@ -11,7 +11,6 @@ module Cardano.Testnet ( -- ** Testnet options CardanoTestnetOptions(..), TestnetNodeOptions(..), - cardanoDefaultTestnetOptions, cardanoDefaultTestnetNodeOptions, getDefaultAlonzoGenesis, getDefaultShelleyGenesis, diff --git a/cardano-testnet/src/Parsers/Cardano.hs b/cardano-testnet/src/Parsers/Cardano.hs index a042521a1c2..89d963d72fb 100644 --- a/cardano-testnet/src/Parsers/Cardano.hs +++ b/cardano-testnet/src/Parsers/Cardano.hs @@ -9,6 +9,7 @@ import Cardano.CLI.EraBased.Options.Common hiding (pNetworkId) import Prelude +import Data.Default.Class import Data.Functor import qualified Data.List as L import Data.Word (Word64) @@ -29,14 +30,14 @@ optsTestnet envCli = CardanoTestnetOptions <> OA.help "Epoch length, in number of slots" <> OA.metavar "SLOTS" <> OA.showDefault - <> OA.value (cardanoEpochLength cardanoDefaultTestnetOptions) + <> OA.value (cardanoEpochLength def) ) <*> OA.option auto ( OA.long "slot-length" <> OA.help "Slot length" <> OA.metavar "SECONDS" <> OA.showDefault - <> OA.value (cardanoSlotLength cardanoDefaultTestnetOptions) + <> OA.value (cardanoSlotLength def) ) <*> pNetworkId <*> OA.option auto @@ -44,7 +45,7 @@ optsTestnet envCli = CardanoTestnetOptions <> OA.help "Active slots co-efficient" <> OA.metavar "DOUBLE" <> OA.showDefault - <> OA.value (cardanoActiveSlotsCoeff cardanoDefaultTestnetOptions) + <> OA.value (cardanoActiveSlotsCoeff def) ) <*> pMaxLovelaceSupply <*> OA.option auto @@ -59,7 +60,7 @@ optsTestnet envCli = CardanoTestnetOptions <> OA.help "Node logging format (json|text)" <> OA.metavar "LOGGING_FORMAT" <> OA.showDefault - <> OA.value (cardanoNodeLoggingFormat cardanoDefaultTestnetOptions) + <> OA.value (cardanoNodeLoggingFormat def) ) <*> OA.option auto ( OA.long "num-dreps" @@ -86,7 +87,7 @@ pNumSpoNodes = <> OA.help "Number of pool nodes. Note this uses a default node configuration for all nodes." <> OA.metavar "COUNT" <> OA.showDefault - <> OA.value (cardanoNodes cardanoDefaultTestnetOptions) + <> OA.value (cardanoNodes def) ) @@ -132,6 +133,6 @@ pMaxLovelaceSupply = <> help "Max lovelace supply that your testnet starts with." <> metavar "WORD64" <> showDefault - <> value (cardanoMaxSupply cardanoDefaultTestnetOptions) + <> value (cardanoMaxSupply def) ) diff --git a/cardano-testnet/src/Testnet/Start/Cardano.hs b/cardano-testnet/src/Testnet/Start/Cardano.hs index 80ec4b5ca70..034ba35c33e 100644 --- a/cardano-testnet/src/Testnet/Start/Cardano.hs +++ b/cardano-testnet/src/Testnet/Start/Cardano.hs @@ -11,7 +11,6 @@ module Testnet.Start.Cardano , CardanoTestnetOptions(..) , extraSpoNodeCliArgs , TestnetNodeOptions(..) - , cardanoDefaultTestnetOptions , cardanoDefaultTestnetNodeOptions , TestnetRuntime (..) @@ -39,6 +38,7 @@ import Data.Aeson import qualified Data.Aeson as Aeson import Data.Bifunctor (first) import qualified Data.ByteString.Lazy as LBS +import Data.Default.Class import Data.Either import qualified Data.List as L import Data.Maybe @@ -99,7 +99,7 @@ cardanoTestnetDefault -> Conf -> H.Integration TestnetRuntime cardanoTestnetDefault opts conf = do - AnyShelleyBasedEra sbe <- pure $ cardanoNodeEra cardanoDefaultTestnetOptions + AnyShelleyBasedEra sbe <- pure $ cardanoNodeEra def alonzoGenesis <- getDefaultAlonzoGenesis sbe (startTime, shelleyGenesis) <- getDefaultShelleyGenesis opts cardanoTestnet opts conf startTime shelleyGenesis alonzoGenesis Defaults.defaultConwayGenesis diff --git a/cardano-testnet/src/Testnet/Start/Types.hs b/cardano-testnet/src/Testnet/Start/Types.hs index 173a69ee02b..da7158b65bf 100644 --- a/cardano-testnet/src/Testnet/Start/Types.hs +++ b/cardano-testnet/src/Testnet/Start/Types.hs @@ -4,7 +4,6 @@ module Testnet.Start.Types ( CardanoTestnetOptions(..) - , cardanoDefaultTestnetOptions , anyEraToString , anyShelleyBasedEraToString @@ -25,6 +24,7 @@ import Cardano.Api hiding (cardanoEra) import Prelude import Data.Char (toLower) +import Data.Default.Class import Data.Word import GHC.Stack import System.FilePath (addTrailingPathSeparator) @@ -51,20 +51,20 @@ data CardanoTestnetOptions = CardanoTestnetOptions , cardanoEnableNewEpochStateLogging :: Bool -- ^ if epoch state logging is enabled } deriving (Eq, Show) -cardanoDefaultTestnetOptions :: CardanoTestnetOptions -cardanoDefaultTestnetOptions = CardanoTestnetOptions - { cardanoNodes = cardanoDefaultTestnetNodeOptions - , cardanoNodeEra = AnyShelleyBasedEra ShelleyBasedEraBabbage - , cardanoEpochLength = 500 - , cardanoSlotLength = 0.1 - , cardanoTestnetMagic = 42 - , cardanoActiveSlotsCoeff = 0.05 - , cardanoMaxSupply = 100_000_020_000_000 -- 100 000 billions Lovelace, so 100 millions ADA. This amount should be bigger than the 'byronTotalBalance' in Testnet.Start.Byron - , cardanoEnableP2P = False - , cardanoNodeLoggingFormat = NodeLoggingFormatAsJson - , cardanoNumDReps = 3 - , cardanoEnableNewEpochStateLogging = True - } +instance Default CardanoTestnetOptions where + def = CardanoTestnetOptions + { cardanoNodes = cardanoDefaultTestnetNodeOptions + , cardanoNodeEra = AnyShelleyBasedEra ShelleyBasedEraBabbage + , cardanoEpochLength = 500 + , cardanoSlotLength = 0.1 + , cardanoTestnetMagic = 42 + , cardanoActiveSlotsCoeff = 0.05 + , cardanoMaxSupply = 100_000_020_000_000 -- 100 000 billions Lovelace, so 100 millions ADA. This amount should be bigger than the 'byronTotalBalance' in Testnet.Start.Byron + , cardanoEnableP2P = False + , cardanoNodeLoggingFormat = NodeLoggingFormatAsJson + , cardanoNumDReps = 3 + , cardanoEnableNewEpochStateLogging = True + } -- | Specify a BFT node (Pre-Babbage era only) or an SPO (Shelley era onwards only) data TestnetNodeOptions From 3c087841ad37762cc723d60b5f6bbeb1d7e86781 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Hurlin?= Date: Thu, 29 Aug 2024 14:33:47 +0200 Subject: [PATCH 02/10] cardano-tesnet-test: adapt to use of Default class for CardanoTestnetOptions --- cardano-testnet/cardano-testnet.cabal | 1 + .../Cardano/Testnet/Test/Cli/Babbage/LeadershipSchedule.hs | 3 ++- .../Cardano/Testnet/Test/Cli/Babbage/StakeSnapshot.hs | 3 ++- .../Cardano/Testnet/Test/Cli/Babbage/Transaction.hs | 3 ++- .../Cardano/Testnet/Test/Cli/Conway/Plutus.hs | 3 ++- .../Cardano/Testnet/Test/Cli/Conway/StakeSnapshot.hs | 3 ++- .../Cardano/Testnet/Test/Cli/KesPeriodInfo.hs | 3 ++- .../cardano-testnet-test/Cardano/Testnet/Test/Cli/Query.hs | 3 ++- .../Cardano/Testnet/Test/Cli/QuerySlotNumber.hs | 3 ++- .../Cardano/Testnet/Test/FoldEpochState.hs | 3 ++- .../Cardano/Testnet/Test/Gov/CommitteeAddNew.hs | 3 ++- .../Cardano/Testnet/Test/Gov/DRepActivity.hs | 3 ++- .../Cardano/Testnet/Test/Gov/DRepDeposit.hs | 3 ++- .../Cardano/Testnet/Test/Gov/DRepRetirement.hs | 3 ++- .../Cardano/Testnet/Test/Gov/GovActionTimeout.hs | 3 ++- .../Cardano/Testnet/Test/Gov/InfoAction.hs | 3 ++- .../Cardano/Testnet/Test/Gov/NoConfidence.hs | 3 ++- .../Cardano/Testnet/Test/Gov/PParamChangeFailsSPO.hs | 3 ++- .../Cardano/Testnet/Test/Gov/PredefinedAbstainDRep.hs | 3 ++- .../Cardano/Testnet/Test/Gov/ProposeNewConstitution.hs | 3 ++- .../Cardano/Testnet/Test/Gov/ProposeNewConstitutionSPO.hs | 3 ++- .../Cardano/Testnet/Test/Gov/TreasuryDonation.hs | 3 ++- .../Cardano/Testnet/Test/Gov/TreasuryGrowth.hs | 3 ++- .../Cardano/Testnet/Test/Gov/TreasuryWithdrawal.hs | 3 ++- .../Cardano/Testnet/Test/Node/Shutdown.hs | 5 +++-- .../cardano-testnet-test/Cardano/Testnet/Test/SanityCheck.hs | 3 ++- .../Cardano/Testnet/Test/SubmitApi/Babbage/Transaction.hs | 3 ++- 27 files changed, 54 insertions(+), 27 deletions(-) diff --git a/cardano-testnet/cardano-testnet.cabal b/cardano-testnet/cardano-testnet.cabal index e410642c547..57736f5197b 100644 --- a/cardano-testnet/cardano-testnet.cabal +++ b/cardano-testnet/cardano-testnet.cabal @@ -228,6 +228,7 @@ test-suite cardano-testnet-test , cardano-strict-containers ^>= 0.1 , cardano-testnet , containers + , data-default-class , directory , exceptions , filepath diff --git a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Babbage/LeadershipSchedule.hs b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Babbage/LeadershipSchedule.hs index cd3e8b6209c..8dc36d5bb49 100644 --- a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Babbage/LeadershipSchedule.hs +++ b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Babbage/LeadershipSchedule.hs @@ -25,6 +25,7 @@ import Control.Monad (void) import qualified Data.Aeson as Aeson import qualified Data.Aeson as J import qualified Data.Aeson.Types as J +import Data.Default.Class import Data.List ((\\)) import qualified Data.List as L import qualified Data.Map.Strict as Map @@ -60,7 +61,7 @@ hprop_leadershipSchedule = integrationRetryWorkspace 2 "babbage-leadership-sched conf@Conf { tempAbsPath=tempAbsPath@(TmpAbsolutePath work) } <- mkConf tempAbsBasePath' let tempBaseAbsPath = makeTmpBaseAbsPath tempAbsPath sbe = shelleyBasedEra @BabbageEra - cTestnetOptions = cardanoDefaultTestnetOptions + cTestnetOptions = def { cardanoNodeEra = AnyShelleyBasedEra sbe -- TODO: We should only support the latest era and the upcoming era } 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/Babbage/StakeSnapshot.hs index 7dfd0273842..6d9314951d9 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/Babbage/StakeSnapshot.hs @@ -17,6 +17,7 @@ import Prelude import Control.Monad import qualified Data.Aeson as Aeson import qualified Data.Aeson.KeyMap as KM +import Data.Default.Class import qualified System.Info as SYS import Testnet.Process.Run (execCliStdoutToJson, mkExecConfig) @@ -40,7 +41,7 @@ hprop_stakeSnapshot = integrationRetryWorkspace 2 "babbage-stake-snapshot" $ \te { testnetMagic , poolNodes , configurationFile - } <- cardanoTestnetDefault cardanoDefaultTestnetOptions conf + } <- cardanoTestnetDefault def conf poolNode1 <- H.headM poolNodes poolSprocket1 <- H.noteShow $ nodeSprocket $ poolRuntime poolNode1 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/Babbage/Transaction.hs index 667af8c7995..dc03548712e 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/Babbage/Transaction.hs @@ -22,6 +22,7 @@ import Prelude import Control.Monad (void) import qualified Data.List as List +import Data.Default.Class import qualified Data.Map as Map import qualified Data.Text as Text import Lens.Micro @@ -51,7 +52,7 @@ hprop_transaction = integrationRetryWorkspace 0 "babbage-transaction" $ \tempAbs era = toCardanoEra sbe cEra = AnyCardanoEra era tempBaseAbsPath = makeTmpBaseAbsPath $ TmpAbsolutePath tempAbsPath' - options = cardanoDefaultTestnetOptions + options = def { cardanoNodeEra = AnyShelleyBasedEra sbe -- TODO: We should only support the latest era and the upcoming era } 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..012b8ba39d3 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 @@ -17,6 +17,7 @@ import Cardano.Testnet import Prelude import Control.Monad (void) +import Data.Default.Class import qualified Data.Text as Text import System.FilePath (()) import qualified System.Info as SYS @@ -53,7 +54,7 @@ hprop_plutus_v3 = integrationWorkspace "all-plutus-script-purposes" $ \tempAbsBa sbe = ShelleyBasedEraConway era = toCardanoEra sbe anyEra = AnyCardanoEra era - options = cardanoDefaultTestnetOptions + options = def { cardanoNodeEra = AnyShelleyBasedEra sbe -- TODO: We should only support the latest era and the upcoming era } diff --git a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Conway/StakeSnapshot.hs b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Conway/StakeSnapshot.hs index ffd28a6f02c..0d14aba936f 100644 --- a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Conway/StakeSnapshot.hs +++ b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Conway/StakeSnapshot.hs @@ -16,6 +16,7 @@ import Prelude import Control.Monad import qualified Data.Aeson as Aeson import qualified Data.Aeson.KeyMap as KM +import Data.Default.Class import qualified System.Info as SYS import Testnet.Process.Run (execCliStdoutToJson, mkExecConfig) @@ -39,7 +40,7 @@ hprop_stakeSnapshot = integrationRetryWorkspace 2 "conway-stake-snapshot" $ \tem { testnetMagic , poolNodes , configurationFile - } <- cardanoTestnetDefault cardanoDefaultTestnetOptions conf + } <- cardanoTestnetDefault def conf poolNode1 <- H.headM poolNodes poolSprocket1 <- H.noteShow $ nodeSprocket $ poolRuntime poolNode1 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..755bfcf1010 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 @@ -23,6 +23,7 @@ import Prelude import Control.Monad import qualified Data.Aeson as Aeson import qualified Data.Aeson as J +import Data.Default.Class import Data.Function import qualified Data.Map.Strict as Map import qualified Data.Text as Text @@ -58,7 +59,7 @@ hprop_kes_period_info = integrationRetryWorkspace 2 "kes-period-info" $ \tempAbs let tempBaseAbsPath = makeTmpBaseAbsPath tempAbsPath sbe = ShelleyBasedEraBabbage eraString = eraToString sbe - cTestnetOptions = cardanoDefaultTestnetOptions + cTestnetOptions = def { cardanoNodeEra = AnyShelleyBasedEra sbe -- TODO: We should only support the latest era and the upcoming era } 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..1c95d72e258 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 @@ -45,6 +45,7 @@ import qualified Data.Aeson.Lens as Aeson import Data.Bifunctor (bimap) import qualified Data.ByteString.Lazy as LBS import Data.Data (type (:~:) (Refl)) +import Data.Default.Class import qualified Data.Map as Map import Data.String (IsString (fromString)) import Data.Text (Text) @@ -93,7 +94,7 @@ hprop_cli_queries = integrationWorkspace "cli-queries" $ \tempAbsBasePath' -> H. era = toCardanoEra sbe cEra = AnyCardanoEra era eraName = eraToString era - fastTestnetOptions = cardanoDefaultTestnetOptions + fastTestnetOptions = def { cardanoEpochLength = 100 , cardanoSlotLength = 0.1 , cardanoNodeEra = AnyShelleyBasedEra sbe diff --git a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/QuerySlotNumber.hs b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/QuerySlotNumber.hs index 25257229c1a..5de8c18db65 100644 --- a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/QuerySlotNumber.hs +++ b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/QuerySlotNumber.hs @@ -18,6 +18,7 @@ import Cardano.Testnet import Prelude +import Data.Default.Class import Data.Either import qualified Data.Time.Clock as DT import qualified Data.Time.Format as DT @@ -44,7 +45,7 @@ hprop_querySlotNumber = integrationRetryWorkspace 2 "query-slot-number" $ \tempA tr@TestnetRuntime { testnetMagic , poolNodes - } <- cardanoTestnetDefault cardanoDefaultTestnetOptions conf + } <- cardanoTestnetDefault def conf ShelleyGenesis{sgSlotLength, sgEpochLength} <- H.noteShowM $ shelleyGenesis tr startTime <- H.noteShowM $ getStartTime tempAbsBasePath' tr diff --git a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/FoldEpochState.hs b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/FoldEpochState.hs index ae2a5235026..579e66dd247 100644 --- a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/FoldEpochState.hs +++ b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/FoldEpochState.hs @@ -12,6 +12,7 @@ import Prelude import Control.Concurrent.Async () import Control.Monad.Trans.State.Strict +import Data.Default.Class import qualified System.Directory as IO import System.FilePath (()) @@ -29,7 +30,7 @@ prop_foldEpochState = integrationWorkspace "foldEpochState" $ \tempAbsBasePath' let tempAbsPath' = unTmpAbsPath $ tempAbsPath conf sbe = ShelleyBasedEraBabbage - options = cardanoDefaultTestnetOptions + options = def { cardanoNodeEra = AnyShelleyBasedEra sbe } 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..2d0d5dd8e4d 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 @@ -23,6 +23,7 @@ import Prelude import Control.Monad import qualified Data.Char as C +import Data.Default.Class import qualified Data.Map as Map import Data.Maybe.Strict import Data.Set (Set) @@ -71,7 +72,7 @@ hprop_constitutional_committee_add_new = integrationWorkspace "constitutional-co era = toCardanoEra sbe cEra = AnyCardanoEra era eraName = eraToString era - fastTestnetOptions = cardanoDefaultTestnetOptions + fastTestnetOptions = def { cardanoEpochLength = 200 , cardanoNodeEra = AnyShelleyBasedEra sbe , cardanoNumDReps = nDrepVotes diff --git a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/DRepActivity.hs b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/DRepActivity.hs index d0f278883d7..be35530bc69 100644 --- a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/DRepActivity.hs +++ b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/DRepActivity.hs @@ -22,6 +22,7 @@ import Prelude import Control.Monad import Control.Monad.Catch (MonadCatch) import Data.Data (Typeable) +import Data.Default.Class import qualified Data.Map as Map import Data.Word (Word16) import GHC.Stack (HasCallStack, withFrozenCallStack) @@ -53,7 +54,7 @@ hprop_check_drep_activity = integrationWorkspace "test-activity" $ \tempAbsBaseP -- Create default testnet with 3 DReps and 3 stake holders delegated, one to each DRep. let ceo = ConwayEraOnwardsConway sbe = conwayEraOnwardsToShelleyBasedEra ceo - fastTestnetOptions = cardanoDefaultTestnetOptions + fastTestnetOptions = def { cardanoEpochLength = 200 , cardanoNodeEra = AnyShelleyBasedEra sbe , cardanoNumDReps = 1 diff --git a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/DRepDeposit.hs b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/DRepDeposit.hs index 092daec8738..aaf7caaaa10 100644 --- a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/DRepDeposit.hs +++ b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/DRepDeposit.hs @@ -12,6 +12,7 @@ import Cardano.Testnet import Prelude import Control.Monad (void) +import Data.Default.Class import qualified Data.Map as Map import System.FilePath (()) @@ -42,7 +43,7 @@ hprop_ledger_events_drep_deposits = integrationWorkspace "drep-deposits" $ \temp sbe = conwayEraOnwardsToShelleyBasedEra ceo era = toCardanoEra sbe cEra = AnyCardanoEra era - fastTestnetOptions = cardanoDefaultTestnetOptions + fastTestnetOptions = def { cardanoEpochLength = 100 , cardanoNodeEra = AnyShelleyBasedEra sbe , cardanoNumDReps = 0 diff --git a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/DRepRetirement.hs b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/DRepRetirement.hs index 8b5cec7c68d..9029a1c2b0f 100644 --- a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/DRepRetirement.hs +++ b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/DRepRetirement.hs @@ -16,6 +16,7 @@ import Cardano.Testnet import Prelude +import Data.Default.Class import qualified Data.Text as Text import System.FilePath (()) @@ -46,7 +47,7 @@ hprop_drep_retirement = integrationRetryWorkspace 2 "drep-retirement" $ \tempAbs work <- H.createDirectoryIfMissing $ tempAbsPath' "work" let cardanoNodeEra = AnyShelleyBasedEra sbe - fastTestnetOptions = cardanoDefaultTestnetOptions + fastTestnetOptions = def { cardanoEpochLength = 50 -- 50 * (1/10s) length, i.e. 5 seconds , cardanoSlotLength = 0.1 -- 1/10s slot (100ms) , cardanoNodeEra diff --git a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/GovActionTimeout.hs b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/GovActionTimeout.hs index 350b2f8abfe..4a090dcdfe4 100644 --- a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/GovActionTimeout.hs +++ b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/GovActionTimeout.hs @@ -16,6 +16,7 @@ import Cardano.Testnet import Prelude import Control.Monad (void) +import Data.Default.Class import Data.String (fromString) import System.FilePath (()) @@ -45,7 +46,7 @@ hprop_check_gov_action_timeout = integrationWorkspace "gov-action-timeout" $ \te -- Create default testnet let ceo = ConwayEraOnwardsConway sbe = conwayEraOnwardsToShelleyBasedEra ceo - fastTestnetOptions = cardanoDefaultTestnetOptions + fastTestnetOptions = def { cardanoEpochLength = 200 , cardanoNodeEra = AnyShelleyBasedEra sbe } diff --git a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/InfoAction.hs b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/InfoAction.hs index 2f9fcc28ac6..7541a435694 100644 --- a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/InfoAction.hs +++ b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/InfoAction.hs @@ -24,6 +24,7 @@ import Prelude import Control.Monad import Data.Bifunctor (first) +import Data.Default.Class import Data.Foldable import qualified Data.Map.Strict as Map import Data.String @@ -56,7 +57,7 @@ hprop_ledger_events_info_action = integrationRetryWorkspace 0 "info-hash" $ \tem let ceo = ConwayEraOnwardsConway sbe = conwayEraOnwardsToShelleyBasedEra ceo - fastTestnetOptions = cardanoDefaultTestnetOptions + fastTestnetOptions = def { cardanoEpochLength = 200 , cardanoNodeEra = AnyShelleyBasedEra sbe } 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..b513d794943 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 @@ -22,6 +22,7 @@ import Prelude import Control.Monad import qualified Data.ByteString.Char8 as BSC +import Data.Default.Class import qualified Data.Map.Strict as Map import Data.Maybe.Strict import Data.String @@ -65,7 +66,7 @@ hprop_gov_no_confidence = integrationWorkspace "no-confidence" $ \tempAbsBasePat sbe = conwayEraOnwardsToShelleyBasedEra ceo era = toCardanoEra sbe cEra = AnyCardanoEra era - fastTestnetOptions = cardanoDefaultTestnetOptions + fastTestnetOptions = def { cardanoEpochLength = 200 , cardanoNodeEra = AnyShelleyBasedEra sbe } diff --git a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/PParamChangeFailsSPO.hs b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/PParamChangeFailsSPO.hs index f3f066124ab..78b56abd582 100644 --- a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/PParamChangeFailsSPO.hs +++ b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/PParamChangeFailsSPO.hs @@ -16,6 +16,7 @@ import Cardano.Testnet import Prelude import Control.Monad.Catch (MonadCatch) +import Data.Default.Class import Data.Typeable (Typeable) import Data.Word (Word16) import System.FilePath (()) @@ -50,7 +51,7 @@ hprop_check_pparam_fails_spo = integrationWorkspace "test-pparam-spo" $ \tempAbs -- Create default testnet let ceo = ConwayEraOnwardsConway sbe = conwayEraOnwardsToShelleyBasedEra ceo - fastTestnetOptions = cardanoDefaultTestnetOptions + fastTestnetOptions = def { cardanoEpochLength = 200 , cardanoNodeEra = AnyShelleyBasedEra sbe } diff --git a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/PredefinedAbstainDRep.hs b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/PredefinedAbstainDRep.hs index 1dc5b18b3be..f9baf6cc3c2 100644 --- a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/PredefinedAbstainDRep.hs +++ b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/PredefinedAbstainDRep.hs @@ -24,6 +24,7 @@ import Prelude import Control.Monad import Control.Monad.Catch (MonadCatch) import Data.Data (Typeable) +import Data.Default.Class import Data.String (fromString) import qualified Data.Text as Text import Data.Word (Word16) @@ -74,7 +75,7 @@ hprop_check_predefined_abstain_drep = H.integrationWorkspace "test-activity" $ \ -- Create default testnet with 3 DReps and 3 stake holders delegated, one to each DRep. let ceo = ConwayEraOnwardsConway sbe = conwayEraOnwardsToShelleyBasedEra ceo - fastTestnetOptions = cardanoDefaultTestnetOptions + fastTestnetOptions = def { cardanoEpochLength = 200 , cardanoNodeEra = AnyShelleyBasedEra sbe , cardanoNumDReps = 3 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..d777ac812ab 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 @@ -22,6 +22,7 @@ import Prelude import Control.Monad import Control.Monad.State.Strict (StateT) +import Data.Default.Class import Data.Maybe import Data.Maybe.Strict import Data.String @@ -68,7 +69,7 @@ hprop_ledger_events_propose_new_constitution = integrationWorkspace "propose-new sbe = conwayEraOnwardsToShelleyBasedEra ceo era = toCardanoEra sbe cEra = AnyCardanoEra era - fastTestnetOptions = cardanoDefaultTestnetOptions + fastTestnetOptions = def { cardanoEpochLength = 200 , cardanoNodeEra = AnyShelleyBasedEra sbe , cardanoNumDReps = numVotes diff --git a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/ProposeNewConstitutionSPO.hs b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/ProposeNewConstitutionSPO.hs index 78cdcfdfe82..8479ad50079 100644 --- a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/ProposeNewConstitutionSPO.hs +++ b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/ProposeNewConstitutionSPO.hs @@ -19,6 +19,7 @@ import Prelude import Control.Monad.Trans.State.Strict (put) import Data.Bifunctor (Bifunctor (..)) +import Data.Default.Class import qualified Data.Map.Strict as Map import qualified Data.Text as Text import GHC.Stack (HasCallStack) @@ -52,7 +53,7 @@ hprop_ledger_events_propose_new_constitution_spo = integrationWorkspace "propose sbe = conwayEraOnwardsToShelleyBasedEra ceo era = toCardanoEra sbe cEra = AnyCardanoEra era - fastTestnetOptions = cardanoDefaultTestnetOptions + fastTestnetOptions = def { cardanoEpochLength = 100 , cardanoSlotLength = 0.1 , cardanoNodeEra = AnyShelleyBasedEra sbe diff --git a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/TreasuryDonation.hs b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/TreasuryDonation.hs index 8517cb7cf65..d667df94404 100644 --- a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/TreasuryDonation.hs +++ b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/TreasuryDonation.hs @@ -19,6 +19,7 @@ import Prelude import Control.Monad (unless, void) import Control.Monad.Catch (MonadCatch) +import Data.Default.Class import qualified Data.Text as Text import GHC.Stack (HasCallStack) import System.Exit @@ -44,7 +45,7 @@ hprop_ledger_events_treasury_donation = integrationWorkspace "treasury-donation" let ceo = ConwayEraOnwardsConway sbe = conwayEraOnwardsToShelleyBasedEra ceo - fastTestnetOptions = cardanoDefaultTestnetOptions + fastTestnetOptions = def { cardanoEpochLength = 100 , cardanoSlotLength = 0.1 , cardanoNodeEra = AnyShelleyBasedEra sbe diff --git a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/TreasuryGrowth.hs b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/TreasuryGrowth.hs index c8a21aabe82..e5951010eda 100644 --- a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/TreasuryGrowth.hs +++ b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/TreasuryGrowth.hs @@ -15,6 +15,7 @@ import Cardano.Testnet as TN import Prelude import Control.Monad.Trans.State.Strict +import Data.Default.Class import Data.List (sortOn) import Data.Map.Strict (Map) import qualified Data.Map.Strict as M @@ -41,7 +42,7 @@ prop_check_if_treasury_is_growing = integrationRetryWorkspace 0 "growing-treasur let era = ConwayEra sbe = ShelleyBasedEraConway - options = cardanoDefaultTestnetOptions + options = def { cardanoEpochLength = 100 , cardanoNodeEra = AnyShelleyBasedEra sbe -- TODO: We should only support the latest era and the upcoming era , cardanoActiveSlotsCoeff = 0.3 diff --git a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/TreasuryWithdrawal.hs b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/TreasuryWithdrawal.hs index 1c17d5f7d09..923e7a4ea6c 100644 --- a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/TreasuryWithdrawal.hs +++ b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/TreasuryWithdrawal.hs @@ -29,6 +29,7 @@ import Prelude import Control.Monad import Control.Monad.State.Class import Data.Bifunctor (Bifunctor (..)) +import Data.Default.Class import Data.Map (Map) import qualified Data.Map.Strict as M import qualified Data.Text as Text @@ -60,7 +61,7 @@ hprop_ledger_events_treasury_withdrawal = integrationRetryWorkspace 1 "treasury era = toCardanoEra sbe eraName = eraToString era - fastTestnetOptions = cardanoDefaultTestnetOptions + fastTestnetOptions = def { cardanoEpochLength = 200 , cardanoNodeEra = AnyShelleyBasedEra sbe , cardanoActiveSlotsCoeff = 0.3 diff --git a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Node/Shutdown.hs b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Node/Shutdown.hs index 53a9d75dcfd..9732971ce63 100644 --- a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Node/Shutdown.hs +++ b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Node/Shutdown.hs @@ -21,6 +21,7 @@ import Control.Monad import Data.Aeson import Data.Aeson.Types import qualified Data.ByteString.Lazy.Char8 as LBS +import Data.Default.Class import Data.Either (isRight) import qualified Data.List as L import Data.Maybe @@ -192,7 +193,7 @@ hprop_shutdownOnSlotSynced = integrationRetryWorkspace 2 "shutdown-on-slot-synce let maxSlot = 150 slotLen = 0.01 - let fastTestnetOptions = cardanoDefaultTestnetOptions + let fastTestnetOptions = def { cardanoEpochLength = 300 , cardanoSlotLength = slotLen , cardanoNodes = @@ -239,7 +240,7 @@ hprop_shutdownOnSigint = integrationRetryWorkspace 2 "shutdown-on-sigint" $ \tem -- TODO: Move yaml filepath specification into individual node options conf <- mkConf tempAbsBasePath' - let fastTestnetOptions = cardanoDefaultTestnetOptions + let fastTestnetOptions = def { cardanoEpochLength = 300 } testnetRuntime diff --git a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/SanityCheck.hs b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/SanityCheck.hs index 568f126ad54..b4f4f32dabe 100644 --- a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/SanityCheck.hs +++ b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/SanityCheck.hs @@ -14,6 +14,7 @@ import Cardano.Api.Shelley import Cardano.Testnet +import Data.Default.Class import Prelude import GHC.IO.Exception (IOException) @@ -43,7 +44,7 @@ hprop_ledger_events_sanity_check = integrationWorkspace "ledger-events-sanity-ch -- Start a local test net conf <- mkConf tempAbsBasePath' - let fastTestnetOptions = cardanoDefaultTestnetOptions + let fastTestnetOptions = def { cardanoEpochLength = 100 , cardanoSlotLength = 0.1 } 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/Babbage/Transaction.hs index fc6c6c93788..0bc8d6d268d 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/Babbage/Transaction.hs @@ -25,6 +25,7 @@ import qualified Data.Aeson.Lens as Aeson import qualified Data.ByteString as BS import qualified Data.ByteString.Base16 as Base16 import qualified Data.ByteString.Lazy as LBS +import Data.Default.Class import qualified Data.List as List import qualified Data.Map as Map import qualified Data.Text as Text @@ -54,7 +55,7 @@ hprop_transaction = integrationRetryWorkspace 0 "submit-api-babbage-transaction" let tempAbsPath' = unTmpAbsPath tempAbsPath sbe = ShelleyBasedEraBabbage tempBaseAbsPath = makeTmpBaseAbsPath $ TmpAbsolutePath tempAbsPath' - options = cardanoDefaultTestnetOptions + options = def { cardanoNodeEra = AnyShelleyBasedEra sbe -- TODO: We should only support the latest era and the upcoming era } From c65392d76d8ece24c90cc5fab50938d18feae300 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Hurlin?= Date: Thu, 29 Aug 2024 10:20:48 +0200 Subject: [PATCH 03/10] cardano-testnet: introduce ShelleyTestnetOptions --- cardano-testnet/src/Parsers/Cardano.hs | 61 +++++++++++-------- cardano-testnet/src/Testnet/Defaults.hs | 31 +++++----- .../src/Testnet/Process/Cli/SPO.hs | 2 +- cardano-testnet/src/Testnet/Start/Cardano.hs | 27 ++++---- cardano-testnet/src/Testnet/Start/Types.hs | 28 ++++++--- 5 files changed, 87 insertions(+), 62 deletions(-) diff --git a/cardano-testnet/src/Parsers/Cardano.hs b/cardano-testnet/src/Parsers/Cardano.hs index 89d963d72fb..09b1d93c916 100644 --- a/cardano-testnet/src/Parsers/Cardano.hs +++ b/cardano-testnet/src/Parsers/Cardano.hs @@ -17,7 +17,7 @@ import Options.Applicative import qualified Options.Applicative as OA import Testnet.Start.Cardano -import Testnet.Start.Types +import Testnet.Start.Types (NodeConfigurationYaml(..), ShelleyTestnetOptions(..)) import Testnet.Types (readNodeLoggingFormat) @@ -25,35 +25,13 @@ optsTestnet :: EnvCli -> Parser CardanoTestnetOptions optsTestnet envCli = CardanoTestnetOptions <$> pNumSpoNodes <*> pAnyShelleyBasedEra' - <*> OA.option auto - ( OA.long "epoch-length" - <> OA.help "Epoch length, in number of slots" - <> OA.metavar "SLOTS" - <> OA.showDefault - <> OA.value (cardanoEpochLength def) - ) - <*> OA.option auto - ( OA.long "slot-length" - <> OA.help "Slot length" - <> OA.metavar "SECONDS" - <> OA.showDefault - <> OA.value (cardanoSlotLength def) - ) - <*> pNetworkId - <*> OA.option auto - ( OA.long "active-slots-coeff" - <> OA.help "Active slots co-efficient" - <> OA.metavar "DOUBLE" - <> OA.showDefault - <> OA.value (cardanoActiveSlotsCoeff def) - ) <*> pMaxLovelaceSupply <*> OA.option auto ( OA.long "enable-p2p" <> OA.help "Enable P2P" <> OA.metavar "BOOL" <> OA.showDefault - <> OA.value (cardanoEnableP2P cardanoDefaultTestnetOptions) + <> OA.value (cardanoEnableP2P def) ) <*> OA.option (OA.eitherReader readNodeLoggingFormat) ( OA.long "nodeLoggingFormat" @@ -74,6 +52,7 @@ optsTestnet envCli = CardanoTestnetOptions <> OA.help "Enable new epoch state logging to logs/ledger-epoch-state.log" <> OA.showDefault ) + <*> pShelleyTestnetOptions where pAnyShelleyBasedEra' :: Parser AnyShelleyBasedEra pAnyShelleyBasedEra' = @@ -90,7 +69,6 @@ pNumSpoNodes = <> OA.value (cardanoNodes def) ) - _pSpo :: Parser TestnetNodeOptions _pSpo = SpoTestnetNodeOptions . Just @@ -114,6 +92,39 @@ parseNodeConfigFile = NodeConfigurationYaml <$> , "Or use num-pool-nodes to use cardano-testnet's default configuration." ] +pShelleyTestnetOptions :: Parser ShelleyTestnetOptions +pShelleyTestnetOptions = + ShelleyTestnetOptions + <$> pNetworkId + <*> pEpochLength + <*> pSlotLength + <*> pActiveSlotCoeffs + where + lift f = f . cardanoShelleyOptions $ def + pEpochLength = + OA.option auto + ( OA.long "epoch-length" + <> OA.help "Epoch length, in number of slots" + <> OA.metavar "SLOTS" + <> OA.showDefault + <> OA.value (lift shelleyEpochLength) + ) + pSlotLength = + OA.option auto + ( OA.long "slot-length" + <> OA.help "Slot length" + <> OA.metavar "SECONDS" + <> OA.showDefault + <> OA.value (lift shelleySlotLength) + ) + pActiveSlotCoeffs = + OA.option auto + ( OA.long "active-slots-coeff" + <> OA.help "Active slots co-efficient" + <> OA.metavar "DOUBLE" + <> OA.showDefault + <> OA.value (lift shelleyActiveSlotsCoeff) + ) cmdCardano :: EnvCli -> Mod CommandFields CardanoTestnetOptions cmdCardano envCli = command' "cardano" "Start a testnet in any era" (optsTestnet envCli) diff --git a/cardano-testnet/src/Testnet/Defaults.hs b/cardano-testnet/src/Testnet/Defaults.hs index 7a0d2bb6e83..32029b6333c 100644 --- a/cardano-testnet/src/Testnet/Defaults.hs +++ b/cardano-testnet/src/Testnet/Defaults.hs @@ -68,6 +68,7 @@ import Data.Text (Text) import qualified Data.Text as Text import Data.Time (UTCTime) import qualified Data.Vector as Vector +import Data.Word (Word64) import Lens.Micro import Numeric.Natural import System.FilePath (()) @@ -416,31 +417,31 @@ defaultByronProtocolParamsJsonValue = ] defaultShelleyGenesis - :: UTCTime - -> CardanoTestnetOptions + :: AnyShelleyBasedEra + -> UTCTime + -> Word64 + -> ShelleyTestnetOptions -> Api.ShelleyGenesis StandardCrypto -defaultShelleyGenesis startTime testnetOptions = do - let CardanoTestnetOptions - { cardanoTestnetMagic = testnetMagic - , cardanoSlotLength = slotLength - , cardanoEpochLength = epochLength - , cardanoMaxSupply = sgMaxLovelaceSupply - , cardanoActiveSlotsCoeff - , cardanoNodeEra - } = testnetOptions +defaultShelleyGenesis asbe startTime maxSupply options = do + let ShelleyTestnetOptions + { shelleyTestnetMagic = magic + , shelleySlotLength = slotLength + , shelleyEpochLength = epochLength + , shelleyActiveSlotsCoeff + } = options -- f - activeSlotsCoeff = round (cardanoActiveSlotsCoeff * 100) % 100 + activeSlotsCoeff = round (shelleyActiveSlotsCoeff * 100) % 100 -- make security param k satisfy: epochLength = 10 * k / f -- TODO: find out why this actually degrates network stability - turned off for now -- securityParam = ceiling $ fromIntegral epochLength * cardanoActiveSlotsCoeff / 10 - pVer = eraToProtocolVersion cardanoNodeEra + pVer = eraToProtocolVersion asbe protocolParams = Api.sgProtocolParams Api.shelleyGenesisDefaults protocolParamsWithPVer = protocolParams & ppProtocolVersionL' .~ pVer Api.shelleyGenesisDefaults { Api.sgActiveSlotsCoeff = unsafeBoundedRational activeSlotsCoeff , Api.sgEpochLength = EpochSize $ fromIntegral epochLength - , Api.sgMaxLovelaceSupply - , Api.sgNetworkMagic = fromIntegral testnetMagic + , Api.sgMaxLovelaceSupply = maxSupply + , Api.sgNetworkMagic = fromIntegral magic , Api.sgProtocolParams = protocolParamsWithPVer -- using default from shelley genesis k = 2160 -- , Api.sgSecurityParam = securityParam diff --git a/cardano-testnet/src/Testnet/Process/Cli/SPO.hs b/cardano-testnet/src/Testnet/Process/Cli/SPO.hs index 4161bb25f0e..1a675bb0396 100644 --- a/cardano-testnet/src/Testnet/Process/Cli/SPO.hs +++ b/cardano-testnet/src/Testnet/Process/Cli/SPO.hs @@ -262,7 +262,7 @@ registerSingleSpo -- 5. FilePath: Stake pool VRF verification key registerSingleSpo identifier tap@(TmpAbsolutePath tempAbsPath') nodeConfigFile socketPath termEpoch cTestnetOptions execConfig (fundingInput, fundingSigninKey, changeAddr) = GHC.withFrozenCallStack $ do - let testnetMag = cardanoTestnetMagic cTestnetOptions + let testnetMag = shelleyTestnetMagic $ cardanoShelleyOptions cTestnetOptions workDir <- H.note tempAbsPath' diff --git a/cardano-testnet/src/Testnet/Start/Cardano.hs b/cardano-testnet/src/Testnet/Start/Cardano.hs index 034ba35c33e..17cd6ff2d43 100644 --- a/cardano-testnet/src/Testnet/Start/Cardano.hs +++ b/cardano-testnet/src/Testnet/Start/Cardano.hs @@ -38,7 +38,6 @@ import Data.Aeson import qualified Data.Aeson as Aeson import Data.Bifunctor (first) import qualified Data.ByteString.Lazy as LBS -import Data.Default.Class import Data.Either import qualified Data.List as L import Data.Maybe @@ -46,7 +45,7 @@ import qualified Data.Text as Text import Data.Time (UTCTime, diffUTCTime) import Data.Time.Clock (NominalDiffTime) import qualified Data.Time.Clock as DTC -import Data.Word (Word32) +import Data.Word (Word32, Word64) import GHC.Stack import qualified GHC.Stack as GHC import System.FilePath (()) @@ -98,10 +97,10 @@ cardanoTestnetDefault => CardanoTestnetOptions -> Conf -> H.Integration TestnetRuntime -cardanoTestnetDefault opts conf = do - AnyShelleyBasedEra sbe <- pure $ cardanoNodeEra def +cardanoTestnetDefault opts@CardanoTestnetOptions{cardanoNodeEra, cardanoMaxSupply, cardanoShelleyOptions} conf = do + AnyShelleyBasedEra sbe <- pure cardanoNodeEra alonzoGenesis <- getDefaultAlonzoGenesis sbe - (startTime, shelleyGenesis) <- getDefaultShelleyGenesis opts + (startTime, shelleyGenesis) <- getDefaultShelleyGenesis cardanoNodeEra cardanoMaxSupply cardanoShelleyOptions cardanoTestnet opts conf startTime shelleyGenesis alonzoGenesis Defaults.defaultConwayGenesis -- | An 'AlonzoGenesis' value that is fit to pass to 'cardanoTestnet' @@ -117,12 +116,14 @@ getDefaultShelleyGenesis :: () => HasCallStack => MonadIO m => MonadTest m - => CardanoTestnetOptions + => AnyShelleyBasedEra + -> Word64 -- ^ The max supply + -> ShelleyTestnetOptions -> m (UTCTime, ShelleyGenesis StandardCrypto) -getDefaultShelleyGenesis opts = do +getDefaultShelleyGenesis asbe maxSupply opts = do currentTime <- H.noteShowIO DTC.getCurrentTime startTime <- H.noteShow $ DTC.addUTCTime startTimeOffsetSeconds currentTime - return (startTime, Defaults.defaultShelleyGenesis startTime opts) + return (startTime, Defaults.defaultShelleyGenesis asbe startTime maxSupply opts) -- | Setup a number of credentials and pools, like this: -- @@ -186,9 +187,9 @@ cardanoTestnet testnetOptions Conf {tempAbsPath=TmpAbsolutePath tmpAbsPath} startTime shelleyGenesis alonzoGenesis conwayGenesis = do let shelleyStartTime = sgSystemStart shelleyGenesis - shelleyTestnetMagic = sgNetworkMagic shelleyGenesis - optionsMagic :: Word32 = fromIntegral $ cardanoTestnetMagic testnetOptions - testnetMagic = cardanoTestnetMagic testnetOptions + genesisTestnetMagic = sgNetworkMagic shelleyGenesis + testnetMagic = shelleyTestnetMagic $ cardanoShelleyOptions testnetOptions + optionsMagic :: Word32 = fromIntegral testnetMagic numPoolNodes = length $ cardanoNodes testnetOptions nPools = numPools testnetOptions nDReps = numDReps testnetOptions @@ -201,8 +202,8 @@ cardanoTestnet when (shelleyStartTime /= startTime) $ do H.note_ $ "Expected same system start in shelley genesis and parameter, but got " <> show shelleyStartTime <> " and " <> show startTime H.failure - when (shelleyTestnetMagic /= optionsMagic) $ do - H.note_ $ "Expected same network magic in shelley genesis and parameter, but got " <> show shelleyTestnetMagic <> " and " <> show optionsMagic + when (genesisTestnetMagic /= optionsMagic) $ do + H.note_ $ "Expected same network magic in shelley genesis and parameter, but got " <> show genesisTestnetMagic <> " and " <> show optionsMagic H.failure -- Done with sanity checks diff --git a/cardano-testnet/src/Testnet/Start/Types.hs b/cardano-testnet/src/Testnet/Start/Types.hs index da7158b65bf..67f32fb2454 100644 --- a/cardano-testnet/src/Testnet/Start/Types.hs +++ b/cardano-testnet/src/Testnet/Start/Types.hs @@ -12,6 +12,7 @@ module Testnet.Start.Types , TestnetNodeOptions(..) , extraSpoNodeCliArgs , cardanoDefaultTestnetNodeOptions + , ShelleyTestnetOptions(..) , NodeLoggingFormat(..) , Conf(..) @@ -40,30 +41,41 @@ data CardanoTestnetOptions = CardanoTestnetOptions -- created. cardanoNodes :: [TestnetNodeOptions] , cardanoNodeEra :: AnyShelleyBasedEra -- ^ The era to start at - , cardanoEpochLength :: Int -- ^ An epoch's duration, in number of slots - , cardanoSlotLength :: Double -- ^ Slot length, in seconds - , cardanoTestnetMagic :: Int - , cardanoActiveSlotsCoeff :: Double , cardanoMaxSupply :: Word64 -- ^ The amount of Lovelace you are starting your testnet with (forwarded to shelley genesis) + -- TODO move me to ShelleyTestnetOptions when https://github.com/IntersectMBO/cardano-cli/pull/874 makes it to cardano-node , cardanoEnableP2P :: Bool , cardanoNodeLoggingFormat :: NodeLoggingFormat , cardanoNumDReps :: Int -- ^ The number of DReps to generate at creation , cardanoEnableNewEpochStateLogging :: Bool -- ^ if epoch state logging is enabled + , cardanoShelleyOptions :: ShelleyTestnetOptions } deriving (Eq, Show) instance Default CardanoTestnetOptions where def = CardanoTestnetOptions { cardanoNodes = cardanoDefaultTestnetNodeOptions , cardanoNodeEra = AnyShelleyBasedEra ShelleyBasedEraBabbage - , cardanoEpochLength = 500 - , cardanoSlotLength = 0.1 - , cardanoTestnetMagic = 42 - , cardanoActiveSlotsCoeff = 0.05 , cardanoMaxSupply = 100_000_020_000_000 -- 100 000 billions Lovelace, so 100 millions ADA. This amount should be bigger than the 'byronTotalBalance' in Testnet.Start.Byron , cardanoEnableP2P = False , cardanoNodeLoggingFormat = NodeLoggingFormatAsJson , cardanoNumDReps = 3 , cardanoEnableNewEpochStateLogging = True + , cardanoShelleyOptions = def + } + +-- | Options that are implemented by writing fields in the Shelley genesis file. +data ShelleyTestnetOptions = ShelleyTestnetOptions + { shelleyTestnetMagic :: Int -- TODO Use the NetworkMagic type from API + , shelleyEpochLength :: Int -- ^ An epoch's duration, in number of slots + , shelleySlotLength :: Double -- ^ Slot length, in seconds + , shelleyActiveSlotsCoeff :: Double + } deriving (Eq, Show) + +instance Default ShelleyTestnetOptions where + def = ShelleyTestnetOptions + { shelleyTestnetMagic = 42 + , shelleyEpochLength = 500 + , shelleySlotLength = 0.1 + , shelleyActiveSlotsCoeff = 0.05 } -- | Specify a BFT node (Pre-Babbage era only) or an SPO (Shelley era onwards only) From 77d9d925cb35e5b65db474219fa2bdc23cdf52d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Hurlin?= Date: Thu, 29 Aug 2024 17:17:59 +0200 Subject: [PATCH 04/10] cardano-testnet-test: adapt to introduction of ShelleyTestnetOptions --- .../Cardano/Testnet/Test/Cli/Query.hs | 14 ++++++++------ .../Cardano/Testnet/Test/Gov/CommitteeAddNew.hs | 7 +++++-- .../Cardano/Testnet/Test/Gov/DRepActivity.hs | 7 +++++-- .../Cardano/Testnet/Test/Gov/DRepDeposit.hs | 7 +++++-- .../Cardano/Testnet/Test/Gov/DRepRetirement.hs | 8 +++++--- .../Cardano/Testnet/Test/Gov/GovActionTimeout.hs | 7 +++++-- .../Cardano/Testnet/Test/Gov/InfoAction.hs | 7 +++++-- .../Cardano/Testnet/Test/Gov/NoConfidence.hs | 14 +++++++++++--- .../Testnet/Test/Gov/PParamChangeFailsSPO.hs | 7 +++++-- .../Testnet/Test/Gov/PredefinedAbstainDRep.hs | 8 +++++--- .../Testnet/Test/Gov/ProposeNewConstitution.hs | 7 +++++-- .../Testnet/Test/Gov/ProposeNewConstitutionSPO.hs | 8 +++++--- .../Cardano/Testnet/Test/Gov/TreasuryDonation.hs | 8 +++++--- .../Cardano/Testnet/Test/Gov/TreasuryGrowth.hs | 10 ++++++---- .../Cardano/Testnet/Test/Gov/TreasuryWithdrawal.hs | 10 ++++++---- .../Cardano/Testnet/Test/Node/Shutdown.hs | 11 ++++++++--- .../Cardano/Testnet/Test/SanityCheck.hs | 7 +++++-- 17 files changed, 99 insertions(+), 48 deletions(-) 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 1c95d72e258..238282c1271 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 @@ -70,6 +70,7 @@ import Testnet.Process.Cli.Transaction (TxOutAddress (ReferenceScriptA import Testnet.Process.Run (execCli', execCliStdoutToJson, mkExecConfig) import Testnet.Property.Assert (assertErasEqual) import Testnet.Property.Util (integrationWorkspace) +import Testnet.Start.Types (ShelleyTestnetOptions(..)) import Testnet.TestQueryCmds (TestQueryCmds (..), forallQueryCommands) import Testnet.Types @@ -95,12 +96,13 @@ hprop_cli_queries = integrationWorkspace "cli-queries" $ \tempAbsBasePath' -> H. cEra = AnyCardanoEra era eraName = eraToString era fastTestnetOptions = def - { cardanoEpochLength = 100 - , cardanoSlotLength = 0.1 - , cardanoNodeEra = AnyShelleyBasedEra sbe - -- We change slotCoeff because epochLength must be equal to: - -- securityParam * 10 / slotCoeff - , cardanoActiveSlotsCoeff = 0.5 + { cardanoNodeEra = AnyShelleyBasedEra sbe, + cardanoShelleyOptions = def + { shelleyEpochLength = 100 + -- We change slotCoeff because epochLength must be equal to: + -- securityParam * 10 / slotCoeff + , shelleyActiveSlotsCoeff = 0.5 + } } TestnetRuntime 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 2d0d5dd8e4d..2a014168494 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 @@ -45,6 +45,7 @@ import Testnet.Process.Cli.Transaction import Testnet.Process.Run (execCli', mkExecConfig) import Testnet.Property.Util (integrationWorkspace) import Testnet.Types +import Testnet.Start.Types (ShelleyTestnetOptions(..)) import Hedgehog import qualified Hedgehog.Extras as H @@ -73,9 +74,11 @@ hprop_constitutional_committee_add_new = integrationWorkspace "constitutional-co cEra = AnyCardanoEra era eraName = eraToString era fastTestnetOptions = def - { cardanoEpochLength = 200 - , cardanoNodeEra = AnyShelleyBasedEra sbe + { cardanoNodeEra = AnyShelleyBasedEra sbe , cardanoNumDReps = nDrepVotes + , cardanoShelleyOptions = def { + shelleyEpochLength = 200 + } } TestnetRuntime diff --git a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/DRepActivity.hs b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/DRepActivity.hs index be35530bc69..1fe9913d8b1 100644 --- a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/DRepActivity.hs +++ b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/DRepActivity.hs @@ -35,6 +35,7 @@ import Testnet.Process.Cli.Transaction import Testnet.Process.Run (mkExecConfig) import Testnet.Property.Util (integrationWorkspace) import Testnet.Types +import Testnet.Start.Types import Hedgehog (MonadTest, Property, annotateShow) import qualified Hedgehog.Extras as H @@ -55,9 +56,11 @@ hprop_check_drep_activity = integrationWorkspace "test-activity" $ \tempAbsBaseP let ceo = ConwayEraOnwardsConway sbe = conwayEraOnwardsToShelleyBasedEra ceo fastTestnetOptions = def - { cardanoEpochLength = 200 - , cardanoNodeEra = AnyShelleyBasedEra sbe + { cardanoNodeEra = AnyShelleyBasedEra sbe , cardanoNumDReps = 1 + , cardanoShelleyOptions = def { + shelleyEpochLength = 200 + } } TestnetRuntime diff --git a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/DRepDeposit.hs b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/DRepDeposit.hs index aaf7caaaa10..8aef210bbff 100644 --- a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/DRepDeposit.hs +++ b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/DRepDeposit.hs @@ -22,6 +22,7 @@ import Testnet.Process.Cli.Transaction import Testnet.Process.Run (mkExecConfig) import Testnet.Property.Util (integrationWorkspace) import Testnet.Types +import Testnet.Start.Types import Hedgehog (Property) import qualified Hedgehog.Extras as H @@ -44,9 +45,11 @@ hprop_ledger_events_drep_deposits = integrationWorkspace "drep-deposits" $ \temp era = toCardanoEra sbe cEra = AnyCardanoEra era fastTestnetOptions = def - { cardanoEpochLength = 100 - , cardanoNodeEra = AnyShelleyBasedEra sbe + { cardanoNodeEra = AnyShelleyBasedEra sbe , cardanoNumDReps = 0 + , cardanoShelleyOptions = def { + shelleyEpochLength = 100 + } } TestnetRuntime diff --git a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/DRepRetirement.hs b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/DRepRetirement.hs index 9029a1c2b0f..6c6a9592b46 100644 --- a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/DRepRetirement.hs +++ b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/DRepRetirement.hs @@ -25,6 +25,7 @@ import Testnet.Defaults import Testnet.Process.Cli.Keys import Testnet.Process.Run (execCli', mkExecConfig) import Testnet.Property.Util (integrationRetryWorkspace) +import Testnet.Start.Types import Testnet.Types import Hedgehog @@ -48,9 +49,10 @@ hprop_drep_retirement = integrationRetryWorkspace 2 "drep-retirement" $ \tempAbs let cardanoNodeEra = AnyShelleyBasedEra sbe fastTestnetOptions = def - { cardanoEpochLength = 50 -- 50 * (1/10s) length, i.e. 5 seconds - , cardanoSlotLength = 0.1 -- 1/10s slot (100ms) - , cardanoNodeEra + { cardanoNodeEra + , cardanoShelleyOptions = def { + shelleyEpochLength = 50 -- 50 * (1/10s) length, i.e. 5 seconds + } } TestnetRuntime diff --git a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/GovActionTimeout.hs b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/GovActionTimeout.hs index 4a090dcdfe4..c2da2a617a4 100644 --- a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/GovActionTimeout.hs +++ b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/GovActionTimeout.hs @@ -24,6 +24,7 @@ import Testnet.Components.Query import Testnet.Process.Cli.DRep (makeActivityChangeProposal) import Testnet.Process.Run (mkExecConfig) import Testnet.Property.Util (integrationWorkspace) +import Testnet.Start.Types import Testnet.Types import Hedgehog (Property) @@ -47,8 +48,10 @@ hprop_check_gov_action_timeout = integrationWorkspace "gov-action-timeout" $ \te let ceo = ConwayEraOnwardsConway sbe = conwayEraOnwardsToShelleyBasedEra ceo fastTestnetOptions = def - { cardanoEpochLength = 200 - , cardanoNodeEra = AnyShelleyBasedEra sbe + { cardanoNodeEra = AnyShelleyBasedEra sbe + , cardanoShelleyOptions = def { + shelleyEpochLength = 200 + } } TestnetRuntime diff --git a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/InfoAction.hs b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/InfoAction.hs index 7541a435694..269258f4151 100644 --- a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/InfoAction.hs +++ b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/InfoAction.hs @@ -38,6 +38,7 @@ import Testnet.Defaults import Testnet.Process.Cli.Keys import Testnet.Process.Run (execCli', mkExecConfig) import Testnet.Property.Util (integrationRetryWorkspace) +import Testnet.Start.Types import Testnet.Types import Hedgehog @@ -58,8 +59,10 @@ hprop_ledger_events_info_action = integrationRetryWorkspace 0 "info-hash" $ \tem let ceo = ConwayEraOnwardsConway sbe = conwayEraOnwardsToShelleyBasedEra ceo fastTestnetOptions = def - { cardanoEpochLength = 200 - , cardanoNodeEra = AnyShelleyBasedEra sbe + { cardanoNodeEra = AnyShelleyBasedEra sbe + , cardanoShelleyOptions = def { + shelleyEpochLength = 200 + } } TestnetRuntime 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 b513d794943..56aca9dc0c7 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 @@ -41,6 +41,7 @@ import qualified Testnet.Process.Cli.SPO as SPO import Testnet.Process.Cli.Transaction import qualified Testnet.Process.Run as H import Testnet.Property.Util (integrationWorkspace) +import Testnet.Start.Types import Testnet.Types import Hedgehog @@ -64,11 +65,14 @@ hprop_gov_no_confidence = integrationWorkspace "no-confidence" $ \tempAbsBasePat let ceo = ConwayEraOnwardsConway sbe = conwayEraOnwardsToShelleyBasedEra ceo + asbe = AnyShelleyBasedEra sbe era = toCardanoEra sbe cEra = AnyCardanoEra era fastTestnetOptions = def - { cardanoEpochLength = 200 - , cardanoNodeEra = AnyShelleyBasedEra sbe + { cardanoNodeEra = asbe + , cardanoShelleyOptions = def { + shelleyEpochLength = 200 + } } execConfigOffline <- H.mkExecConfigOffline tempBaseAbsPath @@ -104,7 +108,11 @@ hprop_gov_no_confidence = integrationWorkspace "no-confidence" $ \tempAbsBasePat committee = L.Committee (Map.fromList [(comKeyCred1, EpochNo 100)]) committeeThreshold alonzoGenesis <- getDefaultAlonzoGenesis sbe - (startTime, shelleyGenesis') <- getDefaultShelleyGenesis fastTestnetOptions + (startTime, shelleyGenesis') <- + getDefaultShelleyGenesis + asbe + (cardanoMaxSupply fastTestnetOptions) + (cardanoShelleyOptions fastTestnetOptions) let conwayGenesisWithCommittee = defaultConwayGenesis { L.cgCommittee = committee } diff --git a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/PParamChangeFailsSPO.hs b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/PParamChangeFailsSPO.hs index 78b56abd582..c54fb445fd6 100644 --- a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/PParamChangeFailsSPO.hs +++ b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/PParamChangeFailsSPO.hs @@ -28,6 +28,7 @@ import qualified Testnet.Process.Cli.SPO as SPO import Testnet.Process.Cli.Transaction (failToSubmitTx, signTx) import Testnet.Process.Run (mkExecConfig) import Testnet.Property.Util (integrationWorkspace) +import Testnet.Start.Types import Testnet.Types import Hedgehog (Property, annotateShow) @@ -52,8 +53,10 @@ hprop_check_pparam_fails_spo = integrationWorkspace "test-pparam-spo" $ \tempAbs let ceo = ConwayEraOnwardsConway sbe = conwayEraOnwardsToShelleyBasedEra ceo fastTestnetOptions = def - { cardanoEpochLength = 200 - , cardanoNodeEra = AnyShelleyBasedEra sbe + { cardanoNodeEra = AnyShelleyBasedEra sbe + , cardanoShelleyOptions = def { + shelleyEpochLength = 200 + } } TestnetRuntime diff --git a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/PredefinedAbstainDRep.hs b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/PredefinedAbstainDRep.hs index f9baf6cc3c2..752e4350578 100644 --- a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/PredefinedAbstainDRep.hs +++ b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/PredefinedAbstainDRep.hs @@ -32,7 +32,6 @@ import GHC.Stack (HasCallStack) import Lens.Micro ((^.)) import System.FilePath (()) -import Testnet.Components.Configuration (anyEraToString) import Testnet.Components.Query import Testnet.Defaults (defaultDRepKeyPair, defaultDelegatorStakeKeyPair) import Testnet.Process.Cli.DRep (createCertificatePublicationTxBody, createVotingTxBody, @@ -41,6 +40,7 @@ import qualified Testnet.Process.Cli.Keys as P import Testnet.Process.Cli.Transaction (retrieveTransactionId, signTx, submitTx) import qualified Testnet.Process.Run as H import qualified Testnet.Property.Util as H +import Testnet.Start.Types import Testnet.Types (KeyPair (..), PaymentKeyInfo (paymentKeyInfoAddr, paymentKeyInfoPair), PoolNode (..), SomeKeyPair (SomeKeyPair), StakingKey, TestnetRuntime (..), nodeSocketPath) @@ -76,9 +76,11 @@ hprop_check_predefined_abstain_drep = H.integrationWorkspace "test-activity" $ \ let ceo = ConwayEraOnwardsConway sbe = conwayEraOnwardsToShelleyBasedEra ceo fastTestnetOptions = def - { cardanoEpochLength = 200 - , cardanoNodeEra = AnyShelleyBasedEra sbe + { cardanoNodeEra = AnyShelleyBasedEra sbe , cardanoNumDReps = 3 + , cardanoShelleyOptions = def { + shelleyEpochLength = 200 + } } TestnetRuntime 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 d777ac812ab..40c28d64f96 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 @@ -40,6 +40,7 @@ import Testnet.Process.Cli.Keys import Testnet.Process.Cli.Transaction import Testnet.Process.Run (execCli', mkExecConfig) import Testnet.Property.Util (integrationWorkspace) +import Testnet.Start.Types import Testnet.Types import Hedgehog @@ -70,9 +71,11 @@ hprop_ledger_events_propose_new_constitution = integrationWorkspace "propose-new era = toCardanoEra sbe cEra = AnyCardanoEra era fastTestnetOptions = def - { cardanoEpochLength = 200 - , cardanoNodeEra = AnyShelleyBasedEra sbe + { cardanoNodeEra = AnyShelleyBasedEra sbe , cardanoNumDReps = numVotes + , cardanoShelleyOptions = def { + shelleyEpochLength = 200 + } } TestnetRuntime diff --git a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/ProposeNewConstitutionSPO.hs b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/ProposeNewConstitutionSPO.hs index 8479ad50079..456069d8dbc 100644 --- a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/ProposeNewConstitutionSPO.hs +++ b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/ProposeNewConstitutionSPO.hs @@ -34,6 +34,7 @@ import qualified Testnet.Process.Cli.SPO as SPO import Testnet.Process.Cli.Transaction import Testnet.Process.Run (execCli', mkExecConfig) import Testnet.Property.Util (integrationWorkspace) +import Testnet.Start.Types import Testnet.Types import Hedgehog @@ -54,9 +55,10 @@ hprop_ledger_events_propose_new_constitution_spo = integrationWorkspace "propose era = toCardanoEra sbe cEra = AnyCardanoEra era fastTestnetOptions = def - { cardanoEpochLength = 100 - , cardanoSlotLength = 0.1 - , cardanoNodeEra = AnyShelleyBasedEra sbe + { cardanoNodeEra = AnyShelleyBasedEra sbe + , cardanoShelleyOptions = def { + shelleyEpochLength = 100 + } } TestnetRuntime diff --git a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/TreasuryDonation.hs b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/TreasuryDonation.hs index d667df94404..cfb20c8d135 100644 --- a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/TreasuryDonation.hs +++ b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/TreasuryDonation.hs @@ -28,6 +28,7 @@ import System.FilePath (()) import Testnet.Components.Query import Testnet.Process.Run (execCli', execCliAny, mkExecConfig) import Testnet.Property.Util (integrationWorkspace) +import Testnet.Start.Types import Testnet.Types import Hedgehog @@ -46,9 +47,10 @@ hprop_ledger_events_treasury_donation = integrationWorkspace "treasury-donation" let ceo = ConwayEraOnwardsConway sbe = conwayEraOnwardsToShelleyBasedEra ceo fastTestnetOptions = def - { cardanoEpochLength = 100 - , cardanoSlotLength = 0.1 - , cardanoNodeEra = AnyShelleyBasedEra sbe + { cardanoNodeEra = AnyShelleyBasedEra sbe + , cardanoShelleyOptions = def { + shelleyEpochLength = 100 + } } TestnetRuntime diff --git a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/TreasuryGrowth.hs b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/TreasuryGrowth.hs index e5951010eda..3adfe2bab58 100644 --- a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/TreasuryGrowth.hs +++ b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/TreasuryGrowth.hs @@ -25,7 +25,7 @@ import System.FilePath (()) import Testnet.Process.Run (execCli', mkExecConfig) import Testnet.Property.Util (integrationRetryWorkspace) -import Testnet.Start.Types (eraToString) +import Testnet.Start.Types import Testnet.Types import qualified Hedgehog as H @@ -43,9 +43,11 @@ prop_check_if_treasury_is_growing = integrationRetryWorkspace 0 "growing-treasur let era = ConwayEra sbe = ShelleyBasedEraConway options = def - { cardanoEpochLength = 100 - , cardanoNodeEra = AnyShelleyBasedEra sbe -- TODO: We should only support the latest era and the upcoming era - , cardanoActiveSlotsCoeff = 0.3 + { cardanoNodeEra = AnyShelleyBasedEra sbe -- TODO: We should only support the latest era and the upcoming era + , cardanoShelleyOptions = def { + shelleyEpochLength = 100 + , shelleyActiveSlotsCoeff = 0.3 + } } TestnetRuntime{testnetMagic, configurationFile, poolNodes} <- cardanoTestnetDefault options conf diff --git a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/TreasuryWithdrawal.hs b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/TreasuryWithdrawal.hs index 923e7a4ea6c..a3999242b71 100644 --- a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/TreasuryWithdrawal.hs +++ b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/TreasuryWithdrawal.hs @@ -42,7 +42,7 @@ import Testnet.Defaults import Testnet.Process.Cli.Keys (cliStakeAddressKeyGen) import Testnet.Process.Run (execCli', mkExecConfig) import Testnet.Property.Util (integrationRetryWorkspace) -import Testnet.Start.Types (eraToString) +import Testnet.Start.Types import Testnet.Types import Hedgehog @@ -62,9 +62,11 @@ hprop_ledger_events_treasury_withdrawal = integrationRetryWorkspace 1 "treasury eraName = eraToString era fastTestnetOptions = def - { cardanoEpochLength = 200 - , cardanoNodeEra = AnyShelleyBasedEra sbe - , cardanoActiveSlotsCoeff = 0.3 + { cardanoNodeEra = AnyShelleyBasedEra sbe + , cardanoShelleyOptions = def { + shelleyEpochLength = 200 + , shelleyActiveSlotsCoeff = 0.3 + } } TestnetRuntime diff --git a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Node/Shutdown.hs b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Node/Shutdown.hs index 9732971ce63..4e072540695 100644 --- a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Node/Shutdown.hs +++ b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Node/Shutdown.hs @@ -40,6 +40,7 @@ import Testnet.Defaults import Testnet.Process.Run (execCli_, initiateProcess, procNode) import Testnet.Property.Util (integrationRetryWorkspace) import Testnet.Start.Byron +import Testnet.Start.Types import Testnet.Types import Hedgehog (Property, (===)) @@ -194,8 +195,10 @@ hprop_shutdownOnSlotSynced = integrationRetryWorkspace 2 "shutdown-on-slot-synce let maxSlot = 150 slotLen = 0.01 let fastTestnetOptions = def - { cardanoEpochLength = 300 - , cardanoSlotLength = slotLen + { cardanoShelleyOptions = def { + shelleyEpochLength = 300 + , shelleySlotLength = slotLen + } , cardanoNodes = [ SpoTestnetNodeOptions Nothing ["--shutdown-on-slot-synced", show maxSlot] , SpoTestnetNodeOptions Nothing [] @@ -241,7 +244,9 @@ hprop_shutdownOnSigint = integrationRetryWorkspace 2 "shutdown-on-sigint" $ \tem conf <- mkConf tempAbsBasePath' let fastTestnetOptions = def - { cardanoEpochLength = 300 + { cardanoShelleyOptions = def { + shelleyEpochLength = 300 + } } testnetRuntime <- cardanoTestnetDefault fastTestnetOptions conf diff --git a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/SanityCheck.hs b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/SanityCheck.hs index b4f4f32dabe..b863a362ff7 100644 --- a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/SanityCheck.hs +++ b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/SanityCheck.hs @@ -21,6 +21,7 @@ import GHC.IO.Exception (IOException) import GHC.Stack import Testnet.Property.Util (integrationWorkspace) +import Testnet.Start.Types import Testnet.Types import Hedgehog @@ -45,8 +46,10 @@ hprop_ledger_events_sanity_check = integrationWorkspace "ledger-events-sanity-ch conf <- mkConf tempAbsBasePath' let fastTestnetOptions = def - { cardanoEpochLength = 100 - , cardanoSlotLength = 0.1 + { cardanoShelleyOptions = def { + shelleyEpochLength = 100 + , shelleySlotLength = 0.1 + } } TestnetRuntime{configurationFile, poolNodes} From d96ef13744d5393024a4e03f3281747bbeb0a6f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Hurlin?= Date: Wed, 4 Sep 2024 14:47:39 +0200 Subject: [PATCH 05/10] cardano-testnet: reduce usage of CardanoTestnetOptions: use smaller values in some places --- .../src/Testnet/Process/Cli/SPO.hs | 10 +++----- .../src/Testnet/Property/Assert.hs | 8 +++--- cardano-testnet/src/Testnet/Start/Cardano.hs | 25 ++++++++----------- 3 files changed, 18 insertions(+), 25 deletions(-) diff --git a/cardano-testnet/src/Testnet/Process/Cli/SPO.hs b/cardano-testnet/src/Testnet/Process/Cli/SPO.hs index 1a675bb0396..78430b06fbb 100644 --- a/cardano-testnet/src/Testnet/Process/Cli/SPO.hs +++ b/cardano-testnet/src/Testnet/Process/Cli/SPO.hs @@ -241,12 +241,13 @@ createStakeKeyDeregistrationCertificate tempAbsP sbe stakeVerKey deposit outputF -- | Related documentation: https://github.com/input-output-hk/cardano-node-wiki/blob/main/docs/stake-pool-operations/8_register_stakepool.md registerSingleSpo :: (MonadTest m, MonadCatch m, MonadIO m, HasCallStack) - => Int -- ^ Identifier for stake pool + => AnyShelleyBasedEra + -> Int -- ^ Identifier for stake pool -> TmpAbsolutePath -> NodeConfigFile 'In -> SocketPath -> EpochNo -- ^ Termination epoch - -> CardanoTestnetOptions + -> Int -- ^ Testnet magic -> ExecConfig -> (TxIn, FilePath, String) -> m ( String @@ -260,10 +261,8 @@ registerSingleSpo -- 3. FilePath: Stake pool cold verification key -- 4. FilePath: Stake pool VRF signing key -- 5. FilePath: Stake pool VRF verification key -registerSingleSpo identifier tap@(TmpAbsolutePath tempAbsPath') nodeConfigFile socketPath termEpoch cTestnetOptions execConfig +registerSingleSpo asbe identifier tap@(TmpAbsolutePath tempAbsPath') nodeConfigFile socketPath termEpoch testnetMag execConfig (fundingInput, fundingSigninKey, changeAddr) = GHC.withFrozenCallStack $ do - let testnetMag = shelleyTestnetMagic $ cardanoShelleyOptions cTestnetOptions - workDir <- H.note tempAbsPath' -- In order to register a stake pool we need two certificates: @@ -322,7 +321,6 @@ registerSingleSpo identifier tap@(TmpAbsolutePath tempAbsPath') nodeConfigFile s -- 5. Create registration certificate let poolRegCertFp = spoReqDir "registration.cert" - let asbe = cardanoNodeEra cTestnetOptions -- The pledge, pool cost and pool margin can all be 0 execCli_ diff --git a/cardano-testnet/src/Testnet/Property/Assert.hs b/cardano-testnet/src/Testnet/Property/Assert.hs index 67f0991f804..5840a293e17 100644 --- a/cardano-testnet/src/Testnet/Property/Assert.hs +++ b/cardano-testnet/src/Testnet/Property/Assert.hs @@ -40,7 +40,7 @@ import Data.Type.Equality import Data.Word (Word8) import GHC.Stack as GHC -import Testnet.Components.Configuration (NumPools(..), numPools) +import Testnet.Components.Configuration (NumPools(..)) import Testnet.Process.Run import Testnet.Start.Types @@ -84,12 +84,10 @@ assertByDeadlineIOCustom str deadline f = withFrozenCallStack $ do assertExpectedSposInLedgerState :: (MonadTest m, MonadCatch m, MonadIO m, HasCallStack) => FilePath -- ^ Stake pools query output filepath - -> CardanoTestnetOptions + -> NumPools -> ExecConfig -> m () -assertExpectedSposInLedgerState output tNetOptions execConfig = withFrozenCallStack $ do - let NumPools numExpectedPools = numPools tNetOptions - +assertExpectedSposInLedgerState output (NumPools numExpectedPools) execConfig = withFrozenCallStack $ do void $ execCli' execConfig [ "query", "stake-pools" , "--out-file", output diff --git a/cardano-testnet/src/Testnet/Start/Cardano.hs b/cardano-testnet/src/Testnet/Start/Cardano.hs index 17cd6ff2d43..0cb7c8ef3f4 100644 --- a/cardano-testnet/src/Testnet/Start/Cardano.hs +++ b/cardano-testnet/src/Testnet/Start/Cardano.hs @@ -70,12 +70,10 @@ import qualified Hedgehog.Extras.Stock.OS as OS -- | There are certain conditions that need to be met in order to run -- a valid node cluster. -testnetMinimumConfigurationRequirements :: MonadTest m => CardanoTestnetOptions -> m () -testnetMinimumConfigurationRequirements cTestnetOpts = do - let actualLength = length (cardanoNodes cTestnetOpts) - when (actualLength < 2) $ do - H.noteShow_ ("Need at least two nodes to run a cluster, but got: " <> show actualLength) - H.noteShow_ cTestnetOpts +testnetMinimumConfigurationRequirements :: MonadTest m => NumPools -> m () +testnetMinimumConfigurationRequirements (NumPools n) = + when (n < 2) $ do + H.noteShow_ ("Need at least two nodes to run a cluster, but got: " <> show n) H.failure data ForkPoint @@ -186,19 +184,18 @@ cardanoTestnet :: () cardanoTestnet testnetOptions Conf {tempAbsPath=TmpAbsolutePath tmpAbsPath} startTime shelleyGenesis alonzoGenesis conwayGenesis = do - let shelleyStartTime = sgSystemStart shelleyGenesis + let (CardanoTestnetOptions _ asbe maxSupply _p2p nodeLoggingFormat _ newEpochStateLogging shelleyOptions) = testnetOptions + shelleyStartTime = sgSystemStart shelleyGenesis genesisTestnetMagic = sgNetworkMagic shelleyGenesis - testnetMagic = shelleyTestnetMagic $ cardanoShelleyOptions testnetOptions + testnetMagic = shelleyTestnetMagic shelleyOptions optionsMagic :: Word32 = fromIntegral testnetMagic numPoolNodes = length $ cardanoNodes testnetOptions nPools = numPools testnetOptions nDReps = numDReps testnetOptions - maxSupply = cardanoMaxSupply testnetOptions - asbe = cardanoNodeEra testnetOptions AnyShelleyBasedEra sbe <- pure asbe -- Sanity checks - testnetMinimumConfigurationRequirements testnetOptions + testnetMinimumConfigurationRequirements nPools when (shelleyStartTime /= startTime) $ do H.note_ $ "Expected same system start in shelley genesis and parameter, but got " <> show shelleyStartTime <> " and " <> show startTime H.failure @@ -360,7 +357,7 @@ cardanoTestnet now <- H.noteShowIO DTC.getCurrentTime deadline <- H.noteShow $ DTC.addUTCTime 45 now forM_ (map (nodeStdout . poolRuntime) poolNodes) $ \nodeStdoutFile -> do - assertChainExtended deadline (cardanoNodeLoggingFormat testnetOptions) nodeStdoutFile + assertChainExtended deadline nodeLoggingFormat nodeStdoutFile H.noteShowIO_ DTC.getCurrentTime @@ -396,9 +393,9 @@ cardanoTestnet stakePoolsFp <- H.note $ tmpAbsPath "current-stake-pools.json" - assertExpectedSposInLedgerState stakePoolsFp testnetOptions execConfig + assertExpectedSposInLedgerState stakePoolsFp nPools execConfig - when (cardanoEnableNewEpochStateLogging testnetOptions) $ + when newEpochStateLogging $ TR.startLedgerNewEpochStateLogging runtime tempBaseAbsPath pure runtime From 1549bc5c358d21bcccc1edb5efc9de5debac270c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Hurlin?= Date: Wed, 4 Sep 2024 16:05:46 +0200 Subject: [PATCH 06/10] cardano-testnet-test: adapt to previous change --- .../Testnet/Test/Cli/Babbage/LeadershipSchedule.hs | 11 +++++------ .../Cardano/Testnet/Test/Cli/KesPeriodInfo.hs | 11 +++++------ 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Babbage/LeadershipSchedule.hs b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Babbage/LeadershipSchedule.hs index 8dc36d5bb49..cfd5f1de119 100644 --- a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Babbage/LeadershipSchedule.hs +++ b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Babbage/LeadershipSchedule.hs @@ -60,10 +60,9 @@ hprop_leadershipSchedule = integrationRetryWorkspace 2 "babbage-leadership-sched H.note_ SYS.os conf@Conf { tempAbsPath=tempAbsPath@(TmpAbsolutePath work) } <- mkConf tempAbsBasePath' let tempBaseAbsPath = makeTmpBaseAbsPath tempAbsPath - sbe = shelleyBasedEra @BabbageEra - cTestnetOptions = def - { cardanoNodeEra = AnyShelleyBasedEra sbe -- TODO: We should only support the latest era and the upcoming era - } + sbe = shelleyBasedEra @BabbageEra -- TODO: We should only support the latest era and the upcoming era + asbe = AnyShelleyBasedEra sbe + cTestnetOptions = def { cardanoNodeEra = asbe } tr@TestnetRuntime { testnetMagic @@ -91,11 +90,11 @@ hprop_leadershipSchedule = integrationRetryWorkspace 2 "babbage-leadership-sched let node1SocketPath = Api.File $ IO.sprocketSystemName node1sprocket termEpoch = EpochNo 15 (stakePoolIdNewSpo, stakePoolColdSigningKey, stakePoolColdVKey, vrfSkey, _) - <- registerSingleSpo 1 tempAbsPath + <- registerSingleSpo asbe 1 tempAbsPath configurationFile node1SocketPath (EpochNo 10) - cTestnetOptions + testnetMagic execConfig (txin1, utxoSKeyFile, utxoAddr) 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 755bfcf1010..b925a3c93f0 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 @@ -57,11 +57,10 @@ hprop_kes_period_info = integrationRetryWorkspace 2 "kes-period-info" $ \tempAbs <- mkConf tempAbsBasePath' let tempBaseAbsPath = makeTmpBaseAbsPath tempAbsPath - sbe = ShelleyBasedEraBabbage + sbe = ShelleyBasedEraBabbage -- TODO: We should only support the latest era and the upcoming era + asbe = AnyShelleyBasedEra sbe eraString = eraToString sbe - cTestnetOptions = def - { cardanoNodeEra = AnyShelleyBasedEra sbe -- TODO: We should only support the latest era and the upcoming era - } + cTestnetOptions = def { cardanoNodeEra = asbe } runTime@TestnetRuntime { configurationFile @@ -89,11 +88,11 @@ hprop_kes_period_info = integrationRetryWorkspace 2 "kes-period-info" $ \tempAbs let node1SocketPath = Api.File $ IO.sprocketSystemName node1sprocket termEpoch = EpochNo 3 (stakePoolId, stakePoolColdSigningKey, stakePoolColdVKey, _, _) - <- registerSingleSpo 1 tempAbsPath + <- registerSingleSpo asbe 1 tempAbsPath configurationFile node1SocketPath termEpoch - cTestnetOptions + testnetMagic execConfig (txin1, utxoSKeyFile, utxoAddr) From c0a257d96b74878f5c2178f19b0ae203196316fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Hurlin?= Date: Wed, 4 Sep 2024 16:28:24 +0200 Subject: [PATCH 07/10] cardano-testnet: separate (in types) the options that are encoded in genesis files from other options --- cardano-testnet/src/Parsers/Cardano.hs | 21 ++++++---- cardano-testnet/src/Parsers/Run.hs | 8 ++-- cardano-testnet/src/Testnet/Start/Cardano.hs | 43 +++++++++----------- cardano-testnet/src/Testnet/Start/Types.hs | 20 +++++++-- 4 files changed, 52 insertions(+), 40 deletions(-) diff --git a/cardano-testnet/src/Parsers/Cardano.hs b/cardano-testnet/src/Parsers/Cardano.hs index 09b1d93c916..46abc97f0f2 100644 --- a/cardano-testnet/src/Parsers/Cardano.hs +++ b/cardano-testnet/src/Parsers/Cardano.hs @@ -17,12 +17,17 @@ import Options.Applicative import qualified Options.Applicative as OA import Testnet.Start.Cardano -import Testnet.Start.Types (NodeConfigurationYaml(..), ShelleyTestnetOptions(..)) +import Testnet.Start.Types import Testnet.Types (readNodeLoggingFormat) -optsTestnet :: EnvCli -> Parser CardanoTestnetOptions -optsTestnet envCli = CardanoTestnetOptions +optsTestnet :: EnvCli -> Parser CardanoTestnetCliOptions +optsTestnet envCli = CardanoTestnetCliOptions + <$> pCardanoTestnetCliOptions envCli + <*> pShelleyTestnetOptions + +pCardanoTestnetCliOptions :: EnvCli -> Parser CardanoTestnetOptions +pCardanoTestnetCliOptions envCli = CardanoTestnetOptions <$> pNumSpoNodes <*> pAnyShelleyBasedEra' <*> pMaxLovelaceSupply @@ -52,7 +57,6 @@ optsTestnet envCli = CardanoTestnetOptions <> OA.help "Enable new epoch state logging to logs/ledger-epoch-state.log" <> OA.showDefault ) - <*> pShelleyTestnetOptions where pAnyShelleyBasedEra' :: Parser AnyShelleyBasedEra pAnyShelleyBasedEra' = @@ -100,14 +104,13 @@ pShelleyTestnetOptions = <*> pSlotLength <*> pActiveSlotCoeffs where - lift f = f . cardanoShelleyOptions $ def pEpochLength = OA.option auto ( OA.long "epoch-length" <> OA.help "Epoch length, in number of slots" <> OA.metavar "SLOTS" <> OA.showDefault - <> OA.value (lift shelleyEpochLength) + <> OA.value (shelleyEpochLength def) ) pSlotLength = OA.option auto @@ -115,7 +118,7 @@ pShelleyTestnetOptions = <> OA.help "Slot length" <> OA.metavar "SECONDS" <> OA.showDefault - <> OA.value (lift shelleySlotLength) + <> OA.value (shelleySlotLength def) ) pActiveSlotCoeffs = OA.option auto @@ -123,10 +126,10 @@ pShelleyTestnetOptions = <> OA.help "Active slots co-efficient" <> OA.metavar "DOUBLE" <> OA.showDefault - <> OA.value (lift shelleyActiveSlotsCoeff) + <> OA.value (shelleyActiveSlotsCoeff def) ) -cmdCardano :: EnvCli -> Mod CommandFields CardanoTestnetOptions +cmdCardano :: EnvCli -> Mod CommandFields CardanoTestnetCliOptions cmdCardano envCli = command' "cardano" "Start a testnet in any era" (optsTestnet envCli) pNetworkId :: Parser Int diff --git a/cardano-testnet/src/Parsers/Run.hs b/cardano-testnet/src/Parsers/Run.hs index 428f663c2ec..7ea49f8e920 100644 --- a/cardano-testnet/src/Parsers/Run.hs +++ b/cardano-testnet/src/Parsers/Run.hs @@ -31,7 +31,7 @@ opts envCli = Opt.info (commands envCli <**> helper) idm -- by allowing the user to start testnets in any era (excluding Byron) -- via StartCardanoTestnet data CardanoTestnetCommands - = StartCardanoTestnet CardanoTestnetOptions + = StartCardanoTestnet CardanoTestnetCliOptions | GetVersion VersionOptions | Help ParserPrefs (ParserInfo CardanoTestnetCommands) HelpOptions @@ -51,6 +51,6 @@ runTestnetCmd = \case Help pPrefs pInfo cmdOpts -> runHelpOptions pPrefs pInfo cmdOpts -runCardanoOptions :: CardanoTestnetOptions -> IO () -runCardanoOptions options = - runTestnet $ cardanoTestnetDefault options +runCardanoOptions :: CardanoTestnetCliOptions -> IO () +runCardanoOptions (CardanoTestnetCliOptions testnetOptions shelleyOptions) = + runTestnet $ cardanoTestnetDefault testnetOptions shelleyOptions diff --git a/cardano-testnet/src/Testnet/Start/Cardano.hs b/cardano-testnet/src/Testnet/Start/Cardano.hs index 0cb7c8ef3f4..f473b8aab05 100644 --- a/cardano-testnet/src/Testnet/Start/Cardano.hs +++ b/cardano-testnet/src/Testnet/Start/Cardano.hs @@ -8,6 +8,7 @@ module Testnet.Start.Cardano ( ForkPoint(..) + , CardanoTestnetCliOptions(..) , CardanoTestnetOptions(..) , extraSpoNodeCliArgs , TestnetNodeOptions(..) @@ -42,10 +43,10 @@ import Data.Either import qualified Data.List as L import Data.Maybe import qualified Data.Text as Text -import Data.Time (UTCTime, diffUTCTime) +import Data.Time (diffUTCTime) import Data.Time.Clock (NominalDiffTime) import qualified Data.Time.Clock as DTC -import Data.Word (Word32, Word64) +import Data.Word (Word64) import GHC.Stack import qualified GHC.Stack as GHC import System.FilePath (()) @@ -87,19 +88,23 @@ data ForkPoint startTimeOffsetSeconds :: DTC.NominalDiffTime startTimeOffsetSeconds = if OS.isWin32 then 90 else 15 --- | Like 'cardanoTestnet', but using defaults for all configuration files. +-- | Like 'cardanoTestnet', but using 'ShelleyTestnetOptions' to obtain +-- the genesis files, instead of passing them directly. -- See 'cardanoTestnet' for additional documentation. cardanoTestnetDefault :: () => HasCallStack => CardanoTestnetOptions + -> ShelleyTestnetOptions -> Conf -> H.Integration TestnetRuntime -cardanoTestnetDefault opts@CardanoTestnetOptions{cardanoNodeEra, cardanoMaxSupply, cardanoShelleyOptions} conf = do +cardanoTestnetDefault testnetOptions shelleyOptions conf = do AnyShelleyBasedEra sbe <- pure cardanoNodeEra alonzoGenesis <- getDefaultAlonzoGenesis sbe - (startTime, shelleyGenesis) <- getDefaultShelleyGenesis cardanoNodeEra cardanoMaxSupply cardanoShelleyOptions - cardanoTestnet opts conf startTime shelleyGenesis alonzoGenesis Defaults.defaultConwayGenesis + shelleyGenesis <- getDefaultShelleyGenesis cardanoNodeEra cardanoMaxSupply shelleyOptions + cardanoTestnet testnetOptions conf shelleyGenesis alonzoGenesis Defaults.defaultConwayGenesis + where + CardanoTestnetOptions{cardanoNodeEra, cardanoMaxSupply} = testnetOptions -- | An 'AlonzoGenesis' value that is fit to pass to 'cardanoTestnet' getDefaultAlonzoGenesis :: () @@ -117,11 +122,11 @@ getDefaultShelleyGenesis :: () => AnyShelleyBasedEra -> Word64 -- ^ The max supply -> ShelleyTestnetOptions - -> m (UTCTime, ShelleyGenesis StandardCrypto) + -> m (ShelleyGenesis StandardCrypto) getDefaultShelleyGenesis asbe maxSupply opts = do currentTime <- H.noteShowIO DTC.getCurrentTime startTime <- H.noteShow $ DTC.addUTCTime startTimeOffsetSeconds currentTime - return (startTime, Defaults.defaultShelleyGenesis asbe startTime maxSupply opts) + return $ Defaults.defaultShelleyGenesis asbe startTime maxSupply opts -- | Setup a number of credentials and pools, like this: -- @@ -173,36 +178,26 @@ getDefaultShelleyGenesis asbe maxSupply opts = do -- >    └── utxo.{addr,skey,vkey} cardanoTestnet :: () => HasCallStack - => CardanoTestnetOptions -- ^ The options to use. Must be consistent with the genesis files. + => CardanoTestnetOptions -- ^ The options to use -> Conf - -> UTCTime -- ^ The starting time. Must be the same as the one in the shelley genesis. -> ShelleyGenesis StandardCrypto -- ^ The shelley genesis to use, for example 'getDefaultShelleyGenesis' from this module. -- Some fields are overridden by the accompanying 'CardanoTestnetOptions'. -> AlonzoGenesis -- ^ The alonzo genesis to use, for example 'getDefaultAlonzoGenesis' from this module. -> ConwayGenesis StandardCrypto -- ^ The conway genesis to use, for example 'Defaults.defaultConwayGenesis'. -> H.Integration TestnetRuntime cardanoTestnet - testnetOptions Conf {tempAbsPath=TmpAbsolutePath tmpAbsPath} startTime + testnetOptions Conf {tempAbsPath=TmpAbsolutePath tmpAbsPath} shelleyGenesis alonzoGenesis conwayGenesis = do - let (CardanoTestnetOptions _ asbe maxSupply _p2p nodeLoggingFormat _ newEpochStateLogging shelleyOptions) = testnetOptions - shelleyStartTime = sgSystemStart shelleyGenesis - genesisTestnetMagic = sgNetworkMagic shelleyGenesis - testnetMagic = shelleyTestnetMagic shelleyOptions - optionsMagic :: Word32 = fromIntegral testnetMagic + let (CardanoTestnetOptions _cardanoNodes asbe maxSupply _p2p nodeLoggingFormat _numDReps newEpochStateLogging) = testnetOptions + startTime = sgSystemStart shelleyGenesis + testnetMagic = fromIntegral $ sgNetworkMagic shelleyGenesis numPoolNodes = length $ cardanoNodes testnetOptions nPools = numPools testnetOptions nDReps = numDReps testnetOptions AnyShelleyBasedEra sbe <- pure asbe - -- Sanity checks + -- Sanity check testnetMinimumConfigurationRequirements nPools - when (shelleyStartTime /= startTime) $ do - H.note_ $ "Expected same system start in shelley genesis and parameter, but got " <> show shelleyStartTime <> " and " <> show startTime - H.failure - when (genesisTestnetMagic /= optionsMagic) $ do - H.note_ $ "Expected same network magic in shelley genesis and parameter, but got " <> show genesisTestnetMagic <> " and " <> show optionsMagic - H.failure - -- Done with sanity checks H.note_ OS.os diff --git a/cardano-testnet/src/Testnet/Start/Types.hs b/cardano-testnet/src/Testnet/Start/Types.hs index 67f32fb2454..7ab6af6a5e7 100644 --- a/cardano-testnet/src/Testnet/Start/Types.hs +++ b/cardano-testnet/src/Testnet/Start/Types.hs @@ -3,7 +3,8 @@ {-# LANGUAGE ScopedTypeVariables #-} module Testnet.Start.Types - ( CardanoTestnetOptions(..) + ( CardanoTestnetCliOptions(..) + , CardanoTestnetOptions(..) , anyEraToString , anyShelleyBasedEraToString @@ -35,7 +36,22 @@ import Testnet.Filepath import Hedgehog (MonadTest) import qualified Hedgehog.Extras as H +-- | Command line options for the @cardano-testnet@ executable. They are used +-- in the parser, and then get split into 'CardanoTestnetOptions' and +-- 'ShelleyTestnetOptions' +data CardanoTestnetCliOptions = CardanoTestnetCliOptions + { cliTestnetOptions :: CardanoTestnetOptions + , cliShelleyOptions :: ShelleyTestnetOptions + } deriving (Eq, Show) + +instance Default CardanoTestnetCliOptions where + def = CardanoTestnetCliOptions + { cliTestnetOptions = def + , cliShelleyOptions = def + } +-- | Options which, contrary to 'ShelleyTestnetOptions' are not implemented +-- by tuning the genesis files. data CardanoTestnetOptions = CardanoTestnetOptions { -- | List of node options. Each option will result in a single node being -- created. @@ -47,7 +63,6 @@ data CardanoTestnetOptions = CardanoTestnetOptions , cardanoNodeLoggingFormat :: NodeLoggingFormat , cardanoNumDReps :: Int -- ^ The number of DReps to generate at creation , cardanoEnableNewEpochStateLogging :: Bool -- ^ if epoch state logging is enabled - , cardanoShelleyOptions :: ShelleyTestnetOptions } deriving (Eq, Show) instance Default CardanoTestnetOptions where @@ -59,7 +74,6 @@ instance Default CardanoTestnetOptions where , cardanoNodeLoggingFormat = NodeLoggingFormatAsJson , cardanoNumDReps = 3 , cardanoEnableNewEpochStateLogging = True - , cardanoShelleyOptions = def } -- | Options that are implemented by writing fields in the Shelley genesis file. From ea3c92f09f3c2f5d4acdfca7179aeed7a168325f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Hurlin?= Date: Wed, 4 Sep 2024 18:11:46 +0200 Subject: [PATCH 08/10] cardano-testnet-test: adapt to previous change --- .../Test/Cli/Babbage/LeadershipSchedule.hs | 2 +- .../Testnet/Test/Cli/Babbage/StakeSnapshot.hs | 2 +- .../Testnet/Test/Cli/Babbage/Transaction.hs | 8 +++----- .../Cardano/Testnet/Test/Cli/Conway/Plutus.hs | 8 +++----- .../Testnet/Test/Cli/Conway/StakeSnapshot.hs | 2 +- .../Cardano/Testnet/Test/Cli/KesPeriodInfo.hs | 2 +- .../Cardano/Testnet/Test/Cli/Query.hs | 17 ++++++++--------- .../Testnet/Test/Cli/QuerySlotNumber.hs | 2 +- .../Cardano/Testnet/Test/FoldEpochState.hs | 6 ++---- .../Testnet/Test/Gov/CommitteeAddNew.hs | 6 ++---- .../Cardano/Testnet/Test/Gov/DRepActivity.hs | 6 ++---- .../Cardano/Testnet/Test/Gov/DRepDeposit.hs | 6 ++---- .../Testnet/Test/Gov/DRepRetirement.hs | 10 +++------- .../Testnet/Test/Gov/GovActionTimeout.hs | 11 ++++------- .../Cardano/Testnet/Test/Gov/InfoAction.hs | 11 ++++------- .../Cardano/Testnet/Test/Gov/NoConfidence.hs | 18 +++++++----------- .../Testnet/Test/Gov/PParamChangeFailsSPO.hs | 11 ++++------- .../Testnet/Test/Gov/PredefinedAbstainDRep.hs | 6 ++---- .../Test/Gov/ProposeNewConstitution.hs | 6 ++---- .../Test/Gov/ProposeNewConstitutionSPO.hs | 10 +++------- .../Testnet/Test/Gov/TreasuryDonation.hs | 10 +++------- .../Testnet/Test/Gov/TreasuryGrowth.hs | 15 ++++++--------- .../Testnet/Test/Gov/TreasuryWithdrawal.hs | 13 +++++-------- .../Cardano/Testnet/Test/Node/Shutdown.hs | 19 ++++++++----------- .../Cardano/Testnet/Test/SanityCheck.hs | 9 ++++----- .../Test/SubmitApi/Babbage/Transaction.hs | 2 +- 26 files changed, 83 insertions(+), 135 deletions(-) diff --git a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Babbage/LeadershipSchedule.hs b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Babbage/LeadershipSchedule.hs index cfd5f1de119..14f771e951b 100644 --- a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Babbage/LeadershipSchedule.hs +++ b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Babbage/LeadershipSchedule.hs @@ -69,7 +69,7 @@ hprop_leadershipSchedule = integrationRetryWorkspace 2 "babbage-leadership-sched , wallets=wallet0:_ , configurationFile , poolNodes - } <- cardanoTestnetDefault cTestnetOptions conf + } <- cardanoTestnetDefault cTestnetOptions def conf node1sprocket <- H.headM $ poolSprockets tr execConfig <- mkExecConfig tempBaseAbsPath node1sprocket testnetMagic 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/Babbage/StakeSnapshot.hs index 6d9314951d9..ec2667c24ba 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/Babbage/StakeSnapshot.hs @@ -41,7 +41,7 @@ hprop_stakeSnapshot = integrationRetryWorkspace 2 "babbage-stake-snapshot" $ \te { testnetMagic , poolNodes , configurationFile - } <- cardanoTestnetDefault def conf + } <- cardanoTestnetDefault def def conf poolNode1 <- H.headM poolNodes poolSprocket1 <- H.noteShow $ nodeSprocket $ poolRuntime poolNode1 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/Babbage/Transaction.hs index dc03548712e..896a5510851 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/Babbage/Transaction.hs @@ -48,19 +48,17 @@ hprop_transaction = integrationRetryWorkspace 0 "babbage-transaction" $ \tempAbs work <- H.createDirectoryIfMissing $ tempAbsPath' "work" let - sbe = ShelleyBasedEraBabbage + sbe = ShelleyBasedEraBabbage -- TODO: We should only support the latest era and the upcoming era era = toCardanoEra sbe cEra = AnyCardanoEra era tempBaseAbsPath = makeTmpBaseAbsPath $ TmpAbsolutePath tempAbsPath' - options = def - { cardanoNodeEra = AnyShelleyBasedEra sbe -- TODO: We should only support the latest era and the upcoming era - } + options = def { cardanoNodeEra = AnyShelleyBasedEra sbe } TestnetRuntime { testnetMagic , poolNodes , wallets=wallet0:_ - } <- cardanoTestnetDefault options conf + } <- cardanoTestnetDefault options def conf poolNode1 <- H.headM poolNodes poolSprocket1 <- H.noteShow $ nodeSprocket $ poolRuntime poolNode1 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 012b8ba39d3..dff51f99e39 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 @@ -51,19 +51,17 @@ hprop_plutus_v3 = integrationWorkspace "all-plutus-script-purposes" $ \tempAbsBa let tempBaseAbsPath = makeTmpBaseAbsPath $ TmpAbsolutePath tempAbsPath' - sbe = ShelleyBasedEraConway + sbe = ShelleyBasedEraConway -- TODO: We should only support the latest era and the upcoming era era = toCardanoEra sbe anyEra = AnyCardanoEra era - options = def - { cardanoNodeEra = AnyShelleyBasedEra sbe -- TODO: We should only support the latest era and the upcoming era - } + options = def { cardanoNodeEra = AnyShelleyBasedEra sbe } TestnetRuntime { configurationFile , testnetMagic , poolNodes , wallets=wallet0:wallet1:_ - } <- cardanoTestnetDefault options conf + } <- cardanoTestnetDefault options def conf PoolNode{poolRuntime} <- H.headM poolNodes poolSprocket1 <- H.noteShow $ nodeSprocket poolRuntime diff --git a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Conway/StakeSnapshot.hs b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Conway/StakeSnapshot.hs index 0d14aba936f..6d319cbd72d 100644 --- a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Conway/StakeSnapshot.hs +++ b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Conway/StakeSnapshot.hs @@ -40,7 +40,7 @@ hprop_stakeSnapshot = integrationRetryWorkspace 2 "conway-stake-snapshot" $ \tem { testnetMagic , poolNodes , configurationFile - } <- cardanoTestnetDefault def conf + } <- cardanoTestnetDefault def def conf poolNode1 <- H.headM poolNodes poolSprocket1 <- H.noteShow $ nodeSprocket $ poolRuntime poolNode1 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 b925a3c93f0..a1ebb99f318 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 @@ -67,7 +67,7 @@ hprop_kes_period_info = integrationRetryWorkspace 2 "kes-period-info" $ \tempAbs , testnetMagic , wallets=wallet0:_ , poolNodes - } <- cardanoTestnetDefault cTestnetOptions conf + } <- cardanoTestnetDefault cTestnetOptions def conf node1sprocket <- H.headM $ poolSprockets runTime execConfig <- mkExecConfig tempBaseAbsPath node1sprocket testnetMagic 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 238282c1271..004af280859 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 @@ -92,17 +92,16 @@ hprop_cli_queries = integrationWorkspace "cli-queries" $ \tempAbsBasePath' -> H. let tempBaseAbsPath = makeTmpBaseAbsPath tempAbsPath let sbe = ShelleyBasedEraConway + asbe = AnyShelleyBasedEra sbe era = toCardanoEra sbe cEra = AnyCardanoEra era eraName = eraToString era - fastTestnetOptions = def - { cardanoNodeEra = AnyShelleyBasedEra sbe, - cardanoShelleyOptions = def - { shelleyEpochLength = 100 - -- We change slotCoeff because epochLength must be equal to: - -- securityParam * 10 / slotCoeff - , shelleyActiveSlotsCoeff = 0.5 - } + fastTestnetOptions = def { cardanoNodeEra = asbe } + shelleyOptions = def + { shelleyEpochLength = 100 + -- We change slotCoeff because epochLength must be equal to: + -- securityParam * 10 / slotCoeff + , shelleyActiveSlotsCoeff = 0.5 } TestnetRuntime @@ -111,7 +110,7 @@ hprop_cli_queries = integrationWorkspace "cli-queries" $ \tempAbsBasePath' -> H. , configurationFile , wallets=wallet0:wallet1:_ } - <- cardanoTestnetDefault fastTestnetOptions conf + <- cardanoTestnetDefault fastTestnetOptions shelleyOptions conf let shelleyGeneisFile = work Defaults.defaultGenesisFilepath ShelleyEra diff --git a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/QuerySlotNumber.hs b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/QuerySlotNumber.hs index 5de8c18db65..cdc30d965db 100644 --- a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/QuerySlotNumber.hs +++ b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/QuerySlotNumber.hs @@ -45,7 +45,7 @@ hprop_querySlotNumber = integrationRetryWorkspace 2 "query-slot-number" $ \tempA tr@TestnetRuntime { testnetMagic , poolNodes - } <- cardanoTestnetDefault def conf + } <- cardanoTestnetDefault def def conf ShelleyGenesis{sgSlotLength, sgEpochLength} <- H.noteShowM $ shelleyGenesis tr startTime <- H.noteShowM $ getStartTime tempAbsBasePath' tr diff --git a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/FoldEpochState.hs b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/FoldEpochState.hs index 579e66dd247..55e68125a83 100644 --- a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/FoldEpochState.hs +++ b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/FoldEpochState.hs @@ -30,11 +30,9 @@ prop_foldEpochState = integrationWorkspace "foldEpochState" $ \tempAbsBasePath' let tempAbsPath' = unTmpAbsPath $ tempAbsPath conf sbe = ShelleyBasedEraBabbage - options = def - { cardanoNodeEra = AnyShelleyBasedEra sbe - } + options = def { cardanoNodeEra = AnyShelleyBasedEra sbe } - runtime@TestnetRuntime{configurationFile} <- cardanoTestnetDefault options conf + runtime@TestnetRuntime{configurationFile} <- cardanoTestnetDefault options def conf socketPathAbs <- do socketPath' <- H.sprocketArgumentName <$> H.headM (poolSprockets runtime) 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 2a014168494..d7606eee2e7 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 @@ -76,10 +76,8 @@ hprop_constitutional_committee_add_new = integrationWorkspace "constitutional-co fastTestnetOptions = def { cardanoNodeEra = AnyShelleyBasedEra sbe , cardanoNumDReps = nDrepVotes - , cardanoShelleyOptions = def { - shelleyEpochLength = 200 - } } + shelleyOptions = def { shelleyEpochLength = 200 } TestnetRuntime { testnetMagic @@ -87,7 +85,7 @@ hprop_constitutional_committee_add_new = integrationWorkspace "constitutional-co , wallets=wallet0:_ , configurationFile } - <- cardanoTestnetDefault fastTestnetOptions conf + <- cardanoTestnetDefault fastTestnetOptions shelleyOptions conf PoolNode{poolRuntime, poolKeys} <- H.headM poolNodes poolSprocket1 <- H.noteShow $ nodeSprocket poolRuntime diff --git a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/DRepActivity.hs b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/DRepActivity.hs index 1fe9913d8b1..0165e91da5c 100644 --- a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/DRepActivity.hs +++ b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/DRepActivity.hs @@ -58,10 +58,8 @@ hprop_check_drep_activity = integrationWorkspace "test-activity" $ \tempAbsBaseP fastTestnetOptions = def { cardanoNodeEra = AnyShelleyBasedEra sbe , cardanoNumDReps = 1 - , cardanoShelleyOptions = def { - shelleyEpochLength = 200 - } } + shelleyOptions = def { shelleyEpochLength = 200 } TestnetRuntime { testnetMagic @@ -69,7 +67,7 @@ hprop_check_drep_activity = integrationWorkspace "test-activity" $ \tempAbsBaseP , wallets=wallet0:wallet1:wallet2:_ , configurationFile } - <- cardanoTestnetDefault fastTestnetOptions conf + <- cardanoTestnetDefault fastTestnetOptions shelleyOptions conf PoolNode{poolRuntime} <- H.headM poolNodes poolSprocket1 <- H.noteShow $ nodeSprocket poolRuntime diff --git a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/DRepDeposit.hs b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/DRepDeposit.hs index 8aef210bbff..135025c792b 100644 --- a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/DRepDeposit.hs +++ b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/DRepDeposit.hs @@ -47,10 +47,8 @@ hprop_ledger_events_drep_deposits = integrationWorkspace "drep-deposits" $ \temp fastTestnetOptions = def { cardanoNodeEra = AnyShelleyBasedEra sbe , cardanoNumDReps = 0 - , cardanoShelleyOptions = def { - shelleyEpochLength = 100 - } } + shelleyOptions = def { shelleyEpochLength = 100 } TestnetRuntime { testnetMagic @@ -58,7 +56,7 @@ hprop_ledger_events_drep_deposits = integrationWorkspace "drep-deposits" $ \temp , wallets=wallet0:wallet1:_ , configurationFile } - <- cardanoTestnetDefault fastTestnetOptions conf + <- cardanoTestnetDefault fastTestnetOptions shelleyOptions conf PoolNode{poolRuntime} <- H.headM poolNodes poolSprocket1 <- H.noteShow $ nodeSprocket poolRuntime diff --git a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/DRepRetirement.hs b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/DRepRetirement.hs index 6c6a9592b46..52756141539 100644 --- a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/DRepRetirement.hs +++ b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/DRepRetirement.hs @@ -48,12 +48,8 @@ hprop_drep_retirement = integrationRetryWorkspace 2 "drep-retirement" $ \tempAbs work <- H.createDirectoryIfMissing $ tempAbsPath' "work" let cardanoNodeEra = AnyShelleyBasedEra sbe - fastTestnetOptions = def - { cardanoNodeEra - , cardanoShelleyOptions = def { - shelleyEpochLength = 50 -- 50 * (1/10s) length, i.e. 5 seconds - } - } + fastTestnetOptions = def { cardanoNodeEra } + shelleyOptions = def { shelleyEpochLength = 50 } -- 50 * (1/10s) length, i.e. 5 seconds TestnetRuntime { testnetMagic @@ -61,7 +57,7 @@ hprop_drep_retirement = integrationRetryWorkspace 2 "drep-retirement" $ \tempAbs , wallets=wallet0:_ , configurationFile } - <- cardanoTestnetDefault fastTestnetOptions conf + <- cardanoTestnetDefault fastTestnetOptions shelleyOptions conf PoolNode{poolRuntime} <- H.headM poolNodes poolSprocket1 <- H.noteShow $ nodeSprocket poolRuntime diff --git a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/GovActionTimeout.hs b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/GovActionTimeout.hs index c2da2a617a4..31f170d5b67 100644 --- a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/GovActionTimeout.hs +++ b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/GovActionTimeout.hs @@ -47,12 +47,9 @@ hprop_check_gov_action_timeout = integrationWorkspace "gov-action-timeout" $ \te -- Create default testnet let ceo = ConwayEraOnwardsConway sbe = conwayEraOnwardsToShelleyBasedEra ceo - fastTestnetOptions = def - { cardanoNodeEra = AnyShelleyBasedEra sbe - , cardanoShelleyOptions = def { - shelleyEpochLength = 200 - } - } + asbe = AnyShelleyBasedEra sbe + fastTestnetOptions = def { cardanoNodeEra = asbe } + shelleyOptions = def { shelleyEpochLength = 200 } TestnetRuntime { testnetMagic @@ -60,7 +57,7 @@ hprop_check_gov_action_timeout = integrationWorkspace "gov-action-timeout" $ \te , wallets=wallet0:_ , configurationFile } - <- cardanoTestnetDefault fastTestnetOptions conf + <- cardanoTestnetDefault fastTestnetOptions shelleyOptions conf PoolNode{poolRuntime} <- H.headM poolNodes poolSprocket1 <- H.noteShow $ nodeSprocket poolRuntime diff --git a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/InfoAction.hs b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/InfoAction.hs index 269258f4151..878e2462942 100644 --- a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/InfoAction.hs +++ b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/InfoAction.hs @@ -58,12 +58,9 @@ hprop_ledger_events_info_action = integrationRetryWorkspace 0 "info-hash" $ \tem let ceo = ConwayEraOnwardsConway sbe = conwayEraOnwardsToShelleyBasedEra ceo - fastTestnetOptions = def - { cardanoNodeEra = AnyShelleyBasedEra sbe - , cardanoShelleyOptions = def { - shelleyEpochLength = 200 - } - } + asbe = AnyShelleyBasedEra sbe + fastTestnetOptions = def { cardanoNodeEra = asbe } + shelleyOptions = def { shelleyEpochLength = 200 } TestnetRuntime { testnetMagic @@ -71,7 +68,7 @@ hprop_ledger_events_info_action = integrationRetryWorkspace 0 "info-hash" $ \tem , wallets=wallet0:wallet1:_ , configurationFile } - <- cardanoTestnetDefault fastTestnetOptions conf + <- cardanoTestnetDefault fastTestnetOptions shelleyOptions conf PoolNode{poolRuntime} <- H.headM poolNodes poolSprocket1 <- H.noteShow $ nodeSprocket poolRuntime 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 56aca9dc0c7..bef0d348237 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 @@ -62,18 +62,14 @@ hprop_gov_no_confidence = integrationWorkspace "no-confidence" $ \tempAbsBasePat work <- H.createDirectoryIfMissing $ tempAbsPath' "work" - let ceo = ConwayEraOnwardsConway sbe = conwayEraOnwardsToShelleyBasedEra ceo asbe = AnyShelleyBasedEra sbe era = toCardanoEra sbe cEra = AnyCardanoEra era - fastTestnetOptions = def - { cardanoNodeEra = asbe - , cardanoShelleyOptions = def { - shelleyEpochLength = 200 - } - } + fastTestnetOptions = def { cardanoNodeEra = asbe } + shelleyOptions = def { shelleyEpochLength = 200 } + execConfigOffline <- H.mkExecConfigOffline tempBaseAbsPath -- Step 1. Define generate and define a committee in the genesis file @@ -108,11 +104,11 @@ hprop_gov_no_confidence = integrationWorkspace "no-confidence" $ \tempAbsBasePat committee = L.Committee (Map.fromList [(comKeyCred1, EpochNo 100)]) committeeThreshold alonzoGenesis <- getDefaultAlonzoGenesis sbe - (startTime, shelleyGenesis') <- + shelleyGenesis' <- getDefaultShelleyGenesis asbe - (cardanoMaxSupply fastTestnetOptions) - (cardanoShelleyOptions fastTestnetOptions) + (cardanoMaxSupply fastTestnetOptions) + shelleyOptions let conwayGenesisWithCommittee = defaultConwayGenesis { L.cgCommittee = committee } @@ -123,7 +119,7 @@ hprop_gov_no_confidence = integrationWorkspace "no-confidence" $ \tempAbsBasePat , configurationFile } <- cardanoTestnet fastTestnetOptions - conf startTime shelleyGenesis' + conf shelleyGenesis' alonzoGenesis conwayGenesisWithCommittee poolNode1 <- H.headM poolNodes diff --git a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/PParamChangeFailsSPO.hs b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/PParamChangeFailsSPO.hs index c54fb445fd6..6113c47ba59 100644 --- a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/PParamChangeFailsSPO.hs +++ b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/PParamChangeFailsSPO.hs @@ -52,12 +52,9 @@ hprop_check_pparam_fails_spo = integrationWorkspace "test-pparam-spo" $ \tempAbs -- Create default testnet let ceo = ConwayEraOnwardsConway sbe = conwayEraOnwardsToShelleyBasedEra ceo - fastTestnetOptions = def - { cardanoNodeEra = AnyShelleyBasedEra sbe - , cardanoShelleyOptions = def { - shelleyEpochLength = 200 - } - } + asbe = AnyShelleyBasedEra sbe + fastTestnetOptions = def { cardanoNodeEra = asbe } + shelleyOptions = def { shelleyEpochLength = 200 } TestnetRuntime { testnetMagic @@ -65,7 +62,7 @@ hprop_check_pparam_fails_spo = integrationWorkspace "test-pparam-spo" $ \tempAbs , wallets=wallet0:wallet1:_wallet2:_ , configurationFile } - <- cardanoTestnetDefault fastTestnetOptions conf + <- cardanoTestnetDefault fastTestnetOptions shelleyOptions conf PoolNode{poolRuntime} <- H.headM poolNodes poolSprocket1 <- H.noteShow $ nodeSprocket poolRuntime diff --git a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/PredefinedAbstainDRep.hs b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/PredefinedAbstainDRep.hs index 752e4350578..3f0e6ee8c07 100644 --- a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/PredefinedAbstainDRep.hs +++ b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/PredefinedAbstainDRep.hs @@ -78,10 +78,8 @@ hprop_check_predefined_abstain_drep = H.integrationWorkspace "test-activity" $ \ fastTestnetOptions = def { cardanoNodeEra = AnyShelleyBasedEra sbe , cardanoNumDReps = 3 - , cardanoShelleyOptions = def { - shelleyEpochLength = 200 - } } + shelleyOptions = def { shelleyEpochLength = 200 } TestnetRuntime { testnetMagic @@ -89,7 +87,7 @@ hprop_check_predefined_abstain_drep = H.integrationWorkspace "test-activity" $ \ , wallets=wallet0:wallet1:wallet2:_ , configurationFile } - <- cardanoTestnetDefault fastTestnetOptions conf + <- cardanoTestnetDefault fastTestnetOptions shelleyOptions conf PoolNode{poolRuntime} <- H.headM poolNodes poolSprocket1 <- H.noteShow $ nodeSprocket poolRuntime 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 40c28d64f96..b004e3e277d 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 @@ -73,10 +73,8 @@ hprop_ledger_events_propose_new_constitution = integrationWorkspace "propose-new fastTestnetOptions = def { cardanoNodeEra = AnyShelleyBasedEra sbe , cardanoNumDReps = numVotes - , cardanoShelleyOptions = def { - shelleyEpochLength = 200 - } } + shelleyOptions = def { shelleyEpochLength = 200 } TestnetRuntime { testnetMagic @@ -84,7 +82,7 @@ hprop_ledger_events_propose_new_constitution = integrationWorkspace "propose-new , wallets=wallet0:wallet1:_ , configurationFile } - <- cardanoTestnetDefault fastTestnetOptions conf + <- cardanoTestnetDefault fastTestnetOptions shelleyOptions conf PoolNode{poolRuntime} <- H.headM poolNodes poolSprocket1 <- H.noteShow $ nodeSprocket poolRuntime diff --git a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/ProposeNewConstitutionSPO.hs b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/ProposeNewConstitutionSPO.hs index 456069d8dbc..98017652e5f 100644 --- a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/ProposeNewConstitutionSPO.hs +++ b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/ProposeNewConstitutionSPO.hs @@ -54,12 +54,8 @@ hprop_ledger_events_propose_new_constitution_spo = integrationWorkspace "propose sbe = conwayEraOnwardsToShelleyBasedEra ceo era = toCardanoEra sbe cEra = AnyCardanoEra era - fastTestnetOptions = def - { cardanoNodeEra = AnyShelleyBasedEra sbe - , cardanoShelleyOptions = def { - shelleyEpochLength = 100 - } - } + fastTestnetOptions = def { cardanoNodeEra = AnyShelleyBasedEra sbe } + shelleyOptions = def { shelleyEpochLength = 100 } TestnetRuntime { testnetMagic @@ -67,7 +63,7 @@ hprop_ledger_events_propose_new_constitution_spo = integrationWorkspace "propose , wallets=wallet0:_ , configurationFile } - <- cardanoTestnetDefault fastTestnetOptions conf + <- cardanoTestnetDefault fastTestnetOptions shelleyOptions conf PoolNode{poolRuntime} <- H.headM poolNodes poolSprocket1 <- H.noteShow $ nodeSprocket poolRuntime diff --git a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/TreasuryDonation.hs b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/TreasuryDonation.hs index cfb20c8d135..40becc66154 100644 --- a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/TreasuryDonation.hs +++ b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/TreasuryDonation.hs @@ -46,12 +46,8 @@ hprop_ledger_events_treasury_donation = integrationWorkspace "treasury-donation" let ceo = ConwayEraOnwardsConway sbe = conwayEraOnwardsToShelleyBasedEra ceo - fastTestnetOptions = def - { cardanoNodeEra = AnyShelleyBasedEra sbe - , cardanoShelleyOptions = def { - shelleyEpochLength = 100 - } - } + fastTestnetOptions = def { cardanoNodeEra = AnyShelleyBasedEra sbe } + shelleyOptions = def { shelleyEpochLength = 100 } TestnetRuntime { testnetMagic @@ -59,7 +55,7 @@ hprop_ledger_events_treasury_donation = integrationWorkspace "treasury-donation" , wallets=wallet0:_ , configurationFile } - <- cardanoTestnetDefault fastTestnetOptions conf + <- cardanoTestnetDefault fastTestnetOptions shelleyOptions conf PoolNode{poolRuntime} <- H.headM poolNodes poolSprocket1 <- H.noteShow $ nodeSprocket poolRuntime diff --git a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/TreasuryGrowth.hs b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/TreasuryGrowth.hs index 3adfe2bab58..e7f9e816041 100644 --- a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/TreasuryGrowth.hs +++ b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/TreasuryGrowth.hs @@ -42,15 +42,12 @@ prop_check_if_treasury_is_growing = integrationRetryWorkspace 0 "growing-treasur let era = ConwayEra sbe = ShelleyBasedEraConway - options = def - { cardanoNodeEra = AnyShelleyBasedEra sbe -- TODO: We should only support the latest era and the upcoming era - , cardanoShelleyOptions = def { - shelleyEpochLength = 100 - , shelleyActiveSlotsCoeff = 0.3 - } - } - - TestnetRuntime{testnetMagic, configurationFile, poolNodes} <- cardanoTestnetDefault options conf + options = def { cardanoNodeEra = AnyShelleyBasedEra sbe } -- TODO: We should only support the latest era and the upcoming era + shelleyOptions = def { shelleyEpochLength = 100 + , shelleyActiveSlotsCoeff = 0.3 + } + + TestnetRuntime{testnetMagic, configurationFile, poolNodes} <- cardanoTestnetDefault options shelleyOptions conf (execConfig, socketPathAbs) <- do PoolNode{poolRuntime} <- H.headM poolNodes diff --git a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/TreasuryWithdrawal.hs b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/TreasuryWithdrawal.hs index a3999242b71..e1f24828e37 100644 --- a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/TreasuryWithdrawal.hs +++ b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/TreasuryWithdrawal.hs @@ -61,13 +61,10 @@ hprop_ledger_events_treasury_withdrawal = integrationRetryWorkspace 1 "treasury era = toCardanoEra sbe eraName = eraToString era - fastTestnetOptions = def - { cardanoNodeEra = AnyShelleyBasedEra sbe - , cardanoShelleyOptions = def { - shelleyEpochLength = 200 - , shelleyActiveSlotsCoeff = 0.3 - } - } + fastTestnetOptions = def { cardanoNodeEra = AnyShelleyBasedEra sbe } + shelleyOptions = def { shelleyEpochLength = 200 + , shelleyActiveSlotsCoeff = 0.3 + } TestnetRuntime { testnetMagic @@ -75,7 +72,7 @@ hprop_ledger_events_treasury_withdrawal = integrationRetryWorkspace 1 "treasury , wallets=wallet0:wallet1:_ , configurationFile } - <- cardanoTestnetDefault fastTestnetOptions conf + <- cardanoTestnetDefault fastTestnetOptions shelleyOptions conf PoolNode{poolRuntime} <- H.headM poolNodes poolSprocket1 <- H.noteShow $ nodeSprocket poolRuntime diff --git a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Node/Shutdown.hs b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Node/Shutdown.hs index 4e072540695..a3e41f0a0dc 100644 --- a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Node/Shutdown.hs +++ b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Node/Shutdown.hs @@ -195,17 +195,17 @@ hprop_shutdownOnSlotSynced = integrationRetryWorkspace 2 "shutdown-on-slot-synce let maxSlot = 150 slotLen = 0.01 let fastTestnetOptions = def - { cardanoShelleyOptions = def { - shelleyEpochLength = 300 - , shelleySlotLength = slotLen - } - , cardanoNodes = + { cardanoNodes = [ SpoTestnetNodeOptions Nothing ["--shutdown-on-slot-synced", show maxSlot] , SpoTestnetNodeOptions Nothing [] , SpoTestnetNodeOptions Nothing [] ] } - testnetRuntime <- cardanoTestnetDefault fastTestnetOptions conf + shelleyOptions = def + { shelleyEpochLength = 300 + , shelleySlotLength = slotLen + } + testnetRuntime <- cardanoTestnetDefault fastTestnetOptions shelleyOptions conf let allNodes' = poolNodes testnetRuntime H.note_ $ "All nodes: " <> show (map (nodeName . poolRuntime) allNodes') @@ -244,12 +244,9 @@ hprop_shutdownOnSigint = integrationRetryWorkspace 2 "shutdown-on-sigint" $ \tem conf <- mkConf tempAbsBasePath' let fastTestnetOptions = def - { cardanoShelleyOptions = def { - shelleyEpochLength = 300 - } - } + shelleyOptions = def { shelleyEpochLength = 300 } testnetRuntime - <- cardanoTestnetDefault fastTestnetOptions conf + <- cardanoTestnetDefault fastTestnetOptions shelleyOptions conf node@NodeRuntime{nodeProcessHandle} <- H.headM $ poolRuntime <$> poolNodes testnetRuntime -- send SIGINT diff --git a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/SanityCheck.hs b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/SanityCheck.hs index b863a362ff7..2356df37f57 100644 --- a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/SanityCheck.hs +++ b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/SanityCheck.hs @@ -46,14 +46,13 @@ hprop_ledger_events_sanity_check = integrationWorkspace "ledger-events-sanity-ch conf <- mkConf tempAbsBasePath' let fastTestnetOptions = def - { cardanoShelleyOptions = def { - shelleyEpochLength = 100 - , shelleySlotLength = 0.1 - } + shelleyOptions = def + { shelleyEpochLength = 100 + , shelleySlotLength = 0.1 } TestnetRuntime{configurationFile, poolNodes} - <- cardanoTestnetDefault fastTestnetOptions conf + <- cardanoTestnetDefault fastTestnetOptions shelleyOptions conf nr@NodeRuntime{nodeSprocket} <- H.headM $ poolRuntime <$> poolNodes let socketPath = nodeSocketPath nr 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/Babbage/Transaction.hs index 0bc8d6d268d..609dab2272e 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/Babbage/Transaction.hs @@ -66,7 +66,7 @@ hprop_transaction = integrationRetryWorkspace 0 "submit-api-babbage-transaction" , testnetMagic , poolNodes , wallets=wallet0:_ - } <- cardanoTestnetDefault options conf + } <- cardanoTestnetDefault options def conf poolNode1 <- H.headM poolNodes From a1b727e5553058121fe8b1149f84d39a2088b923 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Hurlin?= Date: Thu, 5 Sep 2024 14:45:00 +0200 Subject: [PATCH 09/10] Adapt cardano-node-chairman's tests --- cardano-node-chairman/cardano-node-chairman.cabal | 1 + cardano-node-chairman/test/Spec/Chairman/Cardano.hs | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/cardano-node-chairman/cardano-node-chairman.cabal b/cardano-node-chairman/cardano-node-chairman.cabal index 4150ad6e125..9a2484ee34a 100644 --- a/cardano-node-chairman/cardano-node-chairman.cabal +++ b/cardano-node-chairman/cardano-node-chairman.cabal @@ -70,6 +70,7 @@ test-suite chairman-tests build-depends: cardano-testnet , cardano-crypto-class ^>= 2.1.2 + , data-default-class , filepath , hedgehog , hedgehog-extras ^>= 0.6.4 diff --git a/cardano-node-chairman/test/Spec/Chairman/Cardano.hs b/cardano-node-chairman/test/Spec/Chairman/Cardano.hs index d84616db172..fee7a3d7a86 100644 --- a/cardano-node-chairman/test/Spec/Chairman/Cardano.hs +++ b/cardano-node-chairman/test/Spec/Chairman/Cardano.hs @@ -4,9 +4,10 @@ module Spec.Chairman.Cardano where -import Cardano.Testnet (NodeRuntime (nodeName), allNodes, cardanoDefaultTestnetOptions, +import Cardano.Testnet (NodeRuntime (nodeName), allNodes, cardanoTestnetDefault, mkConf) +import Data.Default.Class import Testnet.Property.Util (integrationRetryWorkspace) import qualified Hedgehog as H @@ -18,6 +19,6 @@ hprop_chairman :: H.Property hprop_chairman = integrationRetryWorkspace 2 "cardano-chairman" $ \tempAbsPath' -> do conf <- mkConf tempAbsPath' - allNodes' <- fmap nodeName . allNodes <$> cardanoTestnetDefault cardanoDefaultTestnetOptions conf + allNodes' <- fmap nodeName . allNodes <$> cardanoTestnetDefault def def conf chairmanOver 120 50 conf allNodes' From a25c6c1fab604f6872bb9b2e63891cda4f5c7b75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Hurlin?= Date: Thu, 5 Sep 2024 17:51:22 +0200 Subject: [PATCH 10/10] Adapt golden files --- .../files/golden/help.cli | 8 +- .../files/golden/help/cardano.cli | 18 ++--- .../files/golden/queries/govStateOut.json | 80 +++++++++---------- .../queries/protocolParametersFileOut.json | 20 ++--- .../golden/queries/protocolParametersOut.txt | 20 ++--- 5 files changed, 73 insertions(+), 73 deletions(-) diff --git a/cardano-testnet/test/cardano-testnet-golden/files/golden/help.cli b/cardano-testnet/test/cardano-testnet-golden/files/golden/help.cli index a1260b83330..a3432216cfa 100644 --- a/cardano-testnet/test/cardano-testnet-golden/files/golden/help.cli +++ b/cardano-testnet/test/cardano-testnet-golden/files/golden/help.cli @@ -8,15 +8,15 @@ Usage: cardano-testnet cardano [--num-pool-nodes COUNT] | --babbage-era | --conway-era ] - [--epoch-length SLOTS] - [--slot-length SECONDS] - --testnet-magic INT - [--active-slots-coeff DOUBLE] [--max-lovelace-supply WORD64] [--enable-p2p BOOL] [--nodeLoggingFormat LOGGING_FORMAT] [--num-dreps NUMBER] [--enable-new-epoch-state-logging] + --testnet-magic INT + [--epoch-length SLOTS] + [--slot-length SECONDS] + [--active-slots-coeff DOUBLE] Start a testnet in any era 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..16698b98a4c 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 @@ -6,15 +6,15 @@ Usage: cardano-testnet cardano [--num-pool-nodes COUNT] | --babbage-era | --conway-era ] - [--epoch-length SLOTS] - [--slot-length SECONDS] - --testnet-magic INT - [--active-slots-coeff DOUBLE] [--max-lovelace-supply WORD64] [--enable-p2p BOOL] [--nodeLoggingFormat LOGGING_FORMAT] [--num-dreps NUMBER] [--enable-new-epoch-state-logging] + --testnet-magic INT + [--epoch-length SLOTS] + [--slot-length SECONDS] + [--active-slots-coeff DOUBLE] Start a testnet in any era @@ -28,11 +28,6 @@ Available options: --alonzo-era Specify the Alonzo era --babbage-era Specify the Babbage era (default) --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) - --testnet-magic INT Specify a testnet magic id. - --active-slots-coeff DOUBLE - Active slots co-efficient (default: 5.0e-2) --max-lovelace-supply WORD64 Max lovelace supply that your testnet starts with. (default: 100000020000000) @@ -45,4 +40,9 @@ Available options: --enable-new-epoch-state-logging Enable new epoch state logging to logs/ledger-epoch-state.log + --testnet-magic INT Specify a testnet magic id. + --epoch-length SLOTS Epoch length, in number of slots (default: 500) + --slot-length SECONDS Slot length (default: 0.1) + --active-slots-coeff DOUBLE + Active slots co-efficient (default: 5.0e-2) -h,--help Show this help text diff --git a/cardano-testnet/test/cardano-testnet-test/files/golden/queries/govStateOut.json b/cardano-testnet/test/cardano-testnet-test/files/golden/queries/govStateOut.json index 12a7f523266..96dc93f55c8 100644 --- a/cardano-testnet/test/cardano-testnet-test/files/golden/queries/govStateOut.json +++ b/cardano-testnet/test/cardano-testnet-test/files/golden/queries/govStateOut.json @@ -358,16 +358,16 @@ 38887044, 32947, 10, - 9223372036854775807, - 9223372036854775807, - 9223372036854775807, - 9223372036854775807, - 9223372036854775807, - 9223372036854775807, - 9223372036854775807, - 9223372036854775807, - 9223372036854775807, - 9223372036854775807 + 1292075, + 24469, + 74, + 0, + 1, + 936157, + 49601, + 237, + 0, + 1 ], "PlutusV3": [ 0, @@ -1026,16 +1026,16 @@ 38887044, 32947, 10, - 9223372036854775807, - 9223372036854775807, - 9223372036854775807, - 9223372036854775807, - 9223372036854775807, - 9223372036854775807, - 9223372036854775807, - 9223372036854775807, - 9223372036854775807, - 9223372036854775807 + 1292075, + 24469, + 74, + 0, + 1, + 936157, + 49601, + 237, + 0, + 1 ], "PlutusV3": [ 0, @@ -1683,16 +1683,16 @@ 38887044, 32947, 10, - 9223372036854775807, - 9223372036854775807, - 9223372036854775807, - 9223372036854775807, - 9223372036854775807, - 9223372036854775807, - 9223372036854775807, - 9223372036854775807, - 9223372036854775807, - 9223372036854775807 + 1292075, + 24469, + 74, + 0, + 1, + 936157, + 49601, + 237, + 0, + 1 ], "PlutusV3": [ 0, @@ -2337,16 +2337,16 @@ 38887044, 32947, 10, - 9223372036854775807, - 9223372036854775807, - 9223372036854775807, - 9223372036854775807, - 9223372036854775807, - 9223372036854775807, - 9223372036854775807, - 9223372036854775807, - 9223372036854775807, - 9223372036854775807 + 1292075, + 24469, + 74, + 0, + 1, + 936157, + 49601, + 237, + 0, + 1 ], "PlutusV3": [ 0, diff --git a/cardano-testnet/test/cardano-testnet-test/files/golden/queries/protocolParametersFileOut.json b/cardano-testnet/test/cardano-testnet-test/files/golden/queries/protocolParametersFileOut.json index 6f3c1b5982c..bfd05cf4ce3 100644 --- a/cardano-testnet/test/cardano-testnet-test/files/golden/queries/protocolParametersFileOut.json +++ b/cardano-testnet/test/cardano-testnet-test/files/golden/queries/protocolParametersFileOut.json @@ -347,16 +347,16 @@ 38887044, 32947, 10, - 9223372036854775807, - 9223372036854775807, - 9223372036854775807, - 9223372036854775807, - 9223372036854775807, - 9223372036854775807, - 9223372036854775807, - 9223372036854775807, - 9223372036854775807, - 9223372036854775807 + 1292075, + 24469, + 74, + 0, + 1, + 936157, + 49601, + 237, + 0, + 1 ], "PlutusV3": [ 0, diff --git a/cardano-testnet/test/cardano-testnet-test/files/golden/queries/protocolParametersOut.txt b/cardano-testnet/test/cardano-testnet-test/files/golden/queries/protocolParametersOut.txt index 6f3c1b5982c..bfd05cf4ce3 100644 --- a/cardano-testnet/test/cardano-testnet-test/files/golden/queries/protocolParametersOut.txt +++ b/cardano-testnet/test/cardano-testnet-test/files/golden/queries/protocolParametersOut.txt @@ -347,16 +347,16 @@ 38887044, 32947, 10, - 9223372036854775807, - 9223372036854775807, - 9223372036854775807, - 9223372036854775807, - 9223372036854775807, - 9223372036854775807, - 9223372036854775807, - 9223372036854775807, - 9223372036854775807, - 9223372036854775807 + 1292075, + 24469, + 74, + 0, + 1, + 936157, + 49601, + 237, + 0, + 1 ], "PlutusV3": [ 0,