diff --git a/CODEOWNERS b/CODEOWNERS index d6886d94163..0e71e62ff54 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -26,7 +26,8 @@ nix/workbench @deepfire @denissh trace-dispatcher @deepfire @denisshevchenko @jutaro @mgmeier trace-forward @deepfire @denisshevchenko @jutaro @mgmeier trace-resources @deepfire @denisshevchenko @jutaro @mgmeier -Makefile @deepfire +Makefile @deepfire @mgmeier +*.mk @deepfire @mgmeier .buildkite @devops .github @devops diff --git a/Makefile b/Makefile index 2205d8a8e10..6f968a47223 100644 --- a/Makefile +++ b/Makefile @@ -8,8 +8,8 @@ include legacy.mk PROJECT_NAME = cardano-node NUM_PROC = $(nproc --all) -## One of: shey alra mary alzo -ERA ?= alzo +## One of: shey alra mary alzo bage +ERA ?= bage PROFILE ?= default-${ERA} REV ?= master @@ -53,18 +53,29 @@ ps: ## Plain-text list of profiles ## ## Profile-based cluster shells (autogenerated targets) ## -SHELL_PROFILES += startstop startstop-tracer startstop-oldtracing -SHELL_PROFILES += smoke 10 10-tracer plutus - -SHELL_PROFILES += forge-stress forge-stress-plutus forge-stress-tracer forge-stress-oldtracing - -SHELL_PROFILES += chainsync-early-byron chainsync-early-byron-tracer chainsync-early-byron-oldtracing -SHELL_PROFILES += chainsync-early-alonzo chainsync-early-alonzo-tracer chainsync-early-alonzo-oldtracing +PROFILES_BASE := default plutus +PROFILES_STARTSTOP := startstop startstop-p2p startstop-plutus startstop-tracer startstop-oldtracing +PROFILES_CI_TEST := ci-test ci-test-p2p ci-test-plutus ci-test-tracer +PROFILES_CI_BENCH := ci-bench ci-bench-p2p ci-bench-plutus ci-bench-tracer +PROFILES_10 := 10 10-p2p 10-plutus 10-tracer +PROFILES_FORGE_STRESS := forge-stress forge-stress-p2p forge-stress-plutus forge-stress-plutus-singleton forge-stress-tracer +PROFILES_CHAINSYNC := chainsync-early-byron chainsync-early-byron-tracer chainsync-early-byron-oldtracing +PROFILES_CHAINSYNC += chainsync-early-alonzo chainsync-early-alonzo-tracer chainsync-early-alonzo-oldtracing chainsync-early-alonzo-p2p + +SHELL_PROFILES += $(PROFILES_BASE) +SHELL_PROFILES += $(PROFILES_STARTSTOP) +SHELL_PROFILES += $(PROFILES_CI_TEST) +SHELL_PROFILES += $(PROFILES_CI_BENCH) +SHELL_PROFILES += $(PROFILES_10) +SHELL_PROFILES += $(PROFILES_FORGE_STRESS) +SHELL_PROFILES += $(PROFILES_CHAINSYNC) ## Note: to enable a shell for a profile, just add its name (one of names from 'make ps') to SHELL_PROFILES $(eval $(call define_profile_targets,$(SHELL_PROFILES))) +workbench-ci-test: $(foreach x,$(PROFILES_CI_TEST),${x}-autonix) +workbench-ci-bench: $(foreach x,$(PROFILES_CI_BENCH),${x}-autonix) ### ### Misc @@ -81,4 +92,4 @@ full-clean: clean cls: echo -en "\ec" -.PHONY: cabal-hashes clean cli cls cluster-profiles cluster-shell help node run-test shell shell-dev stylish-haskell +.PHONY: cabal-hashes clean cli cls cluster-profiles cluster-shell help node run-test shell shell-dev stylish-haskell $(SHELL_PROFILES) workbench-ci-test workbench-ci-bench diff --git a/bench/locli/src/Cardano/Analysis/Context.hs b/bench/locli/src/Cardano/Analysis/Context.hs index 1f4fafacd08..c1e806ea2f6 100644 --- a/bench/locli/src/Cardano/Analysis/Context.hs +++ b/bench/locli/src/Cardano/Analysis/Context.hs @@ -48,7 +48,7 @@ data GeneratorProfile { add_tx_size :: Word64 , inputs_per_tx :: Word64 , outputs_per_tx :: Word64 - , tps :: Word64 + , tps :: Double , tx_count :: Word64 } deriving (Generic, Show, FromJSON, ToJSON) diff --git a/bench/tx-generator/src/Cardano/Benchmarking/GeneratorTx/LocalProtocolDefinition.hs b/bench/tx-generator/src/Cardano/Benchmarking/GeneratorTx/LocalProtocolDefinition.hs deleted file mode 100644 index 4b03a1b4976..00000000000 --- a/bench/tx-generator/src/Cardano/Benchmarking/GeneratorTx/LocalProtocolDefinition.hs +++ /dev/null @@ -1,87 +0,0 @@ -{-# LANGUAGE DerivingStrategies #-} -{-# LANGUAGE FlexibleContexts #-} -{-# LANGUAGE GADTs #-} -{-# LANGUAGE LambdaCase #-} -{-# LANGUAGE RankNTypes #-} -{-# LANGUAGE ScopedTypeVariables #-} -module Cardano.Benchmarking.GeneratorTx.LocalProtocolDefinition - ( CliError (..) - , startProtocol - ) where - -import Paths_tx_generator (version) -import Prelude (error, show) - -import Data.Text (pack) -import Data.Version (showVersion) - -import Cardano.Prelude hiding (TypeError, show) -import Control.Monad.Trans.Except.Extra (firstExceptT) - -import Cardano.Tracing.Config (TraceOptions(..)) - -import qualified Cardano.Chain.Genesis as Genesis - -import Cardano.Node.Configuration.Logging -import Cardano.Node.Configuration.POM -import Cardano.Node.Handlers.Shutdown -import Cardano.Node.Protocol.Cardano -import Cardano.Node.Protocol.Types (SomeConsensusProtocol) -import Cardano.Node.Types -import qualified Cardano.Benchmarking.GeneratorTx as GeneratorTx - -startProtocol - :: FilePath - -> ExceptT CliError IO (LoggingLayer, SomeConsensusProtocol) -startProtocol logConfigFile = do - nc <- liftIO $ mkNodeConfig logConfigFile - case ncProtocolConfig nc of - NodeProtocolConfigurationByron _ -> error "NodeProtocolConfigurationByron not supported" - NodeProtocolConfigurationShelley _ -> error "NodeProtocolConfigurationShelley not supported" - NodeProtocolConfigurationCardano byronConfig shelleyConfig alonzoConfig hardforkConfig -> do - ptcl :: SomeConsensusProtocol <- firstExceptT (ProtocolInstantiationError . pack . show) $ - mkSomeConsensusProtocolCardano byronConfig shelleyConfig alonzoConfig hardforkConfig Nothing - - loggingLayer <- mkLoggingLayer nc ptcl - return (loggingLayer, ptcl) - where - mkLoggingLayer :: NodeConfiguration -> SomeConsensusProtocol -> ExceptT CliError IO LoggingLayer - mkLoggingLayer nc ptcl = - firstExceptT (\ case - (ConfigErrorFileNotFound fp) -> ConfigNotFoundError fp - ConfigErrorNoEKG -> EKGNotFoundError) $ - createLoggingLayer - (pack $ showVersion version) - nc {ncTraceConfig=TracingOff} - ptcl - - mkNodeConfig :: FilePath -> IO NodeConfiguration - mkNodeConfig logConfig = do - let configFp = ConfigYamlFilePath logConfig - filesPc = defaultPartialNodeConfiguration - { pncProtocolFiles = Last . Just $ - ProtocolFilepaths - { byronCertFile = Just "" - , byronKeyFile = Just "" - , shelleyKESFile = Just "" - , shelleyVRFFile = Just "" - , shelleyCertFile = Just "" - , shelleyBulkCredsFile = Just "" - } - , pncValidateDB = Last $ Just False - , pncShutdownConfig = Last $ Just $ ShutdownConfig Nothing Nothing - , pncConfigFile = Last $ Just configFp - } - configYamlPc <- parseNodeConfigurationFP . Just $ configFp - case makeNodeConfiguration $ configYamlPc <> filesPc of - Left err -> panic $ "Error in creating the NodeConfiguration: " <> pack err - Right nc' -> return nc' - -data CliError = - GenesisReadError !FilePath !Genesis.GenesisDataError - | FileNotFoundError !FilePath - | ConfigNotFoundError !FilePath - | EKGNotFoundError - | ProtocolInstantiationError !Text - | BenchmarkRunnerError !GeneratorTx.TxGenError - deriving stock Show diff --git a/bench/tx-generator/src/Cardano/Benchmarking/GeneratorTx/NodeToNode.hs b/bench/tx-generator/src/Cardano/Benchmarking/GeneratorTx/NodeToNode.hs index 53ea13b9efb..54a45e87598 100644 --- a/bench/tx-generator/src/Cardano/Benchmarking/GeneratorTx/NodeToNode.hs +++ b/bench/tx-generator/src/Cardano/Benchmarking/GeneratorTx/NodeToNode.hs @@ -88,7 +88,7 @@ benchmarkConnectTxSubmit ioManager handshakeTracer submissionTracer codecConfig foldMap (\p -> p connId controlMessageSTM) bundle n2nVer :: NodeToNodeVersion - n2nVer = NodeToNodeV_7 + n2nVer = NodeToNodeV_10 blkN2nVer :: BlockNodeToNodeVersion blk blkN2nVer = supportedVers Map.! n2nVer supportedVers :: Map.Map NodeToNodeVersion (BlockNodeToNodeVersion blk) diff --git a/bench/tx-generator/src/Cardano/Benchmarking/GeneratorTx/SizedMetadata.hs b/bench/tx-generator/src/Cardano/Benchmarking/GeneratorTx/SizedMetadata.hs index 83b53a67410..6b22316ba7d 100644 --- a/bench/tx-generator/src/Cardano/Benchmarking/GeneratorTx/SizedMetadata.hs +++ b/bench/tx-generator/src/Cardano/Benchmarking/GeneratorTx/SizedMetadata.hs @@ -26,10 +26,12 @@ assume_cbor_properties && prop_mapCostsAllegra && prop_mapCostsMary && prop_mapCostsAlonzo + && prop_mapCostsBabbage && prop_bsCostsShelley && prop_bsCostsAllegra && prop_bsCostsMary && prop_bsCostsAlonzo + && prop_bsCostsBabbage -- The cost of map entries in metadata follows a step function. -- This assumes the map indices are [0..n]. @@ -37,10 +39,12 @@ prop_mapCostsShelley :: Bool prop_mapCostsAllegra :: Bool prop_mapCostsMary :: Bool prop_mapCostsAlonzo :: Bool -prop_mapCostsShelley = measureMapCosts AsShelleyEra == assumeMapCosts AsShelleyEra -prop_mapCostsAllegra = measureMapCosts AsAllegraEra == assumeMapCosts AsAllegraEra -prop_mapCostsMary = measureMapCosts AsMaryEra == assumeMapCosts AsMaryEra -prop_mapCostsAlonzo = measureMapCosts AsAlonzoEra == assumeMapCosts AsAlonzoEra +prop_mapCostsBabbage :: Bool +prop_mapCostsShelley = measureMapCosts AsShelleyEra == assumeMapCosts AsShelleyEra +prop_mapCostsAllegra = measureMapCosts AsAllegraEra == assumeMapCosts AsAllegraEra +prop_mapCostsMary = measureMapCosts AsMaryEra == assumeMapCosts AsMaryEra +prop_mapCostsAlonzo = measureMapCosts AsAlonzoEra == assumeMapCosts AsAlonzoEra +prop_mapCostsBabbage = measureMapCosts AsBabbageEra == assumeMapCosts AsBabbageEra assumeMapCosts :: forall era . IsShelleyBasedEra era => AsType era -> [Int] assumeMapCosts _proxy = stepFunction [ @@ -55,9 +59,8 @@ assumeMapCosts _proxy = stepFunction [ ShelleyBasedEraShelley -> 37 ShelleyBasedEraAllegra -> 39 ShelleyBasedEraMary -> 39 - -- Unconfirmed ! update when alonzo is runnable. - ShelleyBasedEraAlonzo -> error "39" - ShelleyBasedEraBabbage -> error "39" + ShelleyBasedEraAlonzo -> 42 + ShelleyBasedEraBabbage -> 42 -- Bytestring costs are not LINEAR !! -- Costs are piecewise linear for payload sizes [0..23] and [24..64]. @@ -65,11 +68,12 @@ prop_bsCostsShelley :: Bool prop_bsCostsAllegra :: Bool prop_bsCostsMary :: Bool prop_bsCostsAlonzo :: Bool -prop_bsCostsShelley = measureBSCosts AsShelleyEra == [37..60] ++ [62..102] +prop_bsCostsBabbage :: Bool +prop_bsCostsShelley = measureBSCosts AsShelleyEra == [37..60] ++ [62..102] prop_bsCostsAllegra = measureBSCosts AsAllegraEra == [39..62] ++ [64..104] prop_bsCostsMary = measureBSCosts AsMaryEra == [39..62] ++ [64..104] - -- Unconfirmed ! update when alonzo is runnable. -prop_bsCostsAlonzo = measureBSCosts AsAlonzoEra == error "[39..62] ++ [64..104]" +prop_bsCostsAlonzo = measureBSCosts AsAlonzoEra == [42..65] ++ [67..107] +prop_bsCostsBabbage = measureBSCosts AsBabbageEra == [42..65] ++ [67..107] stepFunction :: [(Int, Int)] -> [Int] stepFunction f = scanl1 (+) steps @@ -126,12 +130,9 @@ dummyTxSize _p m = (dummyTxSizeInEra @ era) $ metadataInEra m metadataInEra :: forall era . IsShelleyBasedEra era => Maybe TxMetadata -> TxMetadataInEra era metadataInEra Nothing = TxMetadataNone -metadataInEra (Just m) = case shelleyBasedEra @ era of - ShelleyBasedEraShelley -> TxMetadataInEra TxMetadataInShelleyEra m - ShelleyBasedEraAllegra -> TxMetadataInEra TxMetadataInAllegraEra m - ShelleyBasedEraMary -> TxMetadataInEra TxMetadataInMaryEra m - ShelleyBasedEraAlonzo -> TxMetadataInEra TxMetadataInAlonzoEra m - ShelleyBasedEraBabbage -> TxMetadataInEra TxMetadataInBabbageEra m +metadataInEra (Just m) = case txMetadataSupportedInEra (cardanoEra @ era) of + Nothing -> error "unreachable" + Just e -> TxMetadataInEra e m mkMetadata :: forall era . IsShelleyBasedEra era => Int -> Either String (TxMetadataInEra era) mkMetadata 0 = Right $ metadataInEra Nothing diff --git a/bench/tx-generator/src/Cardano/Benchmarking/GeneratorTx/SubmissionClient.hs b/bench/tx-generator/src/Cardano/Benchmarking/GeneratorTx/SubmissionClient.hs index 1986369f4e4..c7cb5e8d624 100644 --- a/bench/tx-generator/src/Cardano/Benchmarking/GeneratorTx/SubmissionClient.hs +++ b/bench/tx-generator/src/Cardano/Benchmarking/GeneratorTx/SubmissionClient.hs @@ -23,7 +23,7 @@ module Cardano.Benchmarking.GeneratorTx.SubmissionClient , txSubmissionClient ) where -import Prelude (error, fail) +import Prelude (error,fail) import Cardano.Prelude hiding (ByteString, atomically, retry, state, threadDelay) import Control.Arrow ((&&&)) @@ -44,12 +44,10 @@ import Cardano.Tracing.OrphanInstances.Shelley () import qualified Ouroboros.Consensus.Cardano as Consensus (CardanoBlock) import Ouroboros.Consensus.Ledger.SupportsMempool (GenTx, GenTxId, txInBlockSize) import qualified Ouroboros.Consensus.Ledger.SupportsMempool as Mempool -import Ouroboros.Consensus.Shelley.Ledger.Mempool (mkShelleyTx) import qualified Ouroboros.Consensus.Shelley.Ledger.Mempool as Mempool (TxId(ShelleyTxId)) import Ouroboros.Consensus.Shelley.Eras (StandardCrypto) -import Ouroboros.Consensus.Cardano.Block (GenTx (GenTxAllegra, GenTxAlonzo, GenTxShelley, GenTxMary)) -import qualified Ouroboros.Consensus.Cardano.Block as Block (TxId(GenTxIdShelley, GenTxIdAllegra, GenTxIdAlonzo, GenTxIdMary)) +import qualified Ouroboros.Consensus.Cardano.Block as Block (TxId(GenTxIdShelley, GenTxIdAllegra, GenTxIdAlonzo, GenTxIdMary,GenTxIdBabbage )) import Ouroboros.Network.Protocol.TxSubmission2.Client (ClientStIdle (..), ClientStTxIds (..), @@ -59,7 +57,7 @@ import Ouroboros.Network.Protocol.TxSubmission2.Type (BlockingReplyLis TokBlockingStyle (..), TxSizeInBytes) import Cardano.Api -import Cardano.Api.Shelley (Tx(ShelleyTx), fromShelleyTxId) +import Cardano.Api.Shelley (fromShelleyTxId, toConsensusGenTx) import Cardano.Benchmarking.Tracer import Cardano.Benchmarking.Types @@ -191,19 +189,20 @@ txSubmissionClient tr bmtr initialTxSource endOfProtocolCallback = txToIdSize = (Mempool.txId &&& txInBlockSize) . toGenTx toGenTx :: tx -> GenTx CardanoBlock - toGenTx tx = case (shelleyBasedEra @ era , tx) of - (ShelleyBasedEraShelley, ShelleyTx _ tx') -> GenTxShelley (mkShelleyTx tx') - (ShelleyBasedEraAllegra, ShelleyTx _ tx') -> GenTxAllegra (mkShelleyTx tx') - (ShelleyBasedEraMary, ShelleyTx _ tx') -> GenTxMary (mkShelleyTx tx') - (ShelleyBasedEraAlonzo, ShelleyTx _ tx') -> GenTxAlonzo (mkShelleyTx tx') - (ShelleyBasedEraBabbage, ShelleyTx _ _tx') -> error "TODO:Babbage" + toGenTx tx = case shelleyBasedEra @ era of + ShelleyBasedEraShelley -> toConsensusGenTx $ TxInMode tx ShelleyEraInCardanoMode + ShelleyBasedEraAllegra -> toConsensusGenTx $ TxInMode tx AllegraEraInCardanoMode + ShelleyBasedEraMary -> toConsensusGenTx $ TxInMode tx MaryEraInCardanoMode + ShelleyBasedEraAlonzo -> toConsensusGenTx $ TxInMode tx AlonzoEraInCardanoMode + ShelleyBasedEraBabbage -> toConsensusGenTx $ TxInMode tx BabbageEraInCardanoMode fromGenTxId :: GenTxId CardanoBlock -> TxId fromGenTxId (Block.GenTxIdShelley (Mempool.ShelleyTxId i)) = fromShelleyTxId i fromGenTxId (Block.GenTxIdAllegra (Mempool.ShelleyTxId i)) = fromShelleyTxId i fromGenTxId (Block.GenTxIdMary (Mempool.ShelleyTxId i)) = fromShelleyTxId i fromGenTxId (Block.GenTxIdAlonzo (Mempool.ShelleyTxId i)) = fromShelleyTxId i - fromGenTxId _ = error "submission.hs: fromGenTxId" + fromGenTxId (Block.GenTxIdBabbage (Mempool.ShelleyTxId i)) = fromShelleyTxId i + fromGenTxId _ = error "TODO: fix incomplete match" tokIsBlocking :: TokBlockingStyle a -> Bool tokIsBlocking = \case diff --git a/bench/tx-generator/src/Cardano/Benchmarking/GeneratorTx/Tx.hs b/bench/tx-generator/src/Cardano/Benchmarking/GeneratorTx/Tx.hs index ed6e7d6a3c4..f66a8525463 100644 --- a/bench/tx-generator/src/Cardano/Benchmarking/GeneratorTx/Tx.hs +++ b/bench/tx-generator/src/Cardano/Benchmarking/GeneratorTx/Tx.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE EmptyCase #-} {-# LANGUAGE GADTs #-} {-# LANGUAGE LambdaCase #-} {-# LANGUAGE OverloadedStrings #-} @@ -23,7 +24,7 @@ where import Prelude import Cardano.Benchmarking.Types (TxAdditionalSize (..)) -import Cardano.Api hiding (txOutValueToLovelace) +import Cardano.Api type Fund = (TxIn, InAnyCardanoEra TxOutValue) @@ -63,7 +64,7 @@ mkGenesisTransaction key _payloadSize ttl fee txins txouts , txInsCollateral = TxInsCollateralNone , txInsReference = TxInsReferenceNone , txOuts = txouts - , txFee = fees + , txFee = mkFee fee , txValidityRange = (TxValidityNoLowerBound, validityUpperBound) , txMetadata = TxMetadataNone , txAuxScripts = TxAuxScriptsNone @@ -77,12 +78,6 @@ mkGenesisTransaction key _payloadSize ttl fee txins txouts , txReturnCollateral = TxReturnCollateralNone , txTotalCollateral = TxTotalCollateralNone } - fees = case shelleyBasedEra @ era of - ShelleyBasedEraShelley -> TxFeeExplicit TxFeesExplicitInShelleyEra fee - ShelleyBasedEraAllegra -> TxFeeExplicit TxFeesExplicitInAllegraEra fee - ShelleyBasedEraMary -> TxFeeExplicit TxFeesExplicitInMaryEra fee - ShelleyBasedEraAlonzo -> TxFeeExplicit TxFeesExplicitInAlonzoEra fee - ShelleyBasedEraBabbage -> TxFeeExplicit TxFeesExplicitInBabbageEra fee validityUpperBound = case shelleyBasedEra @ era of ShelleyBasedEraShelley -> TxValidityUpperBound ValidityUpperBoundInShelleyEra ttl ShelleyBasedEraAllegra -> TxValidityUpperBound ValidityUpperBoundInAllegraEra ttl @@ -94,45 +89,24 @@ mkFee :: forall era . IsShelleyBasedEra era => Lovelace -> TxFee era -mkFee f = case shelleyBasedEra @ era of - ShelleyBasedEraShelley -> TxFeeExplicit TxFeesExplicitInShelleyEra f - ShelleyBasedEraAllegra -> TxFeeExplicit TxFeesExplicitInAllegraEra f - ShelleyBasedEraMary -> TxFeeExplicit TxFeesExplicitInMaryEra f - ShelleyBasedEraAlonzo -> TxFeeExplicit TxFeesExplicitInAlonzoEra f - ShelleyBasedEraBabbage -> TxFeeExplicit TxFeesExplicitInBabbageEra f +mkFee f = case txFeesExplicitInEra (cardanoEra @ era) of + Right e -> TxFeeExplicit e f + Left b -> TxFeeImplicit b -- error "unreachable" mkValidityUpperBound :: forall era . IsShelleyBasedEra era => SlotNo -> TxValidityUpperBound era -mkValidityUpperBound ttl = case shelleyBasedEra @ era of - ShelleyBasedEraShelley -> TxValidityUpperBound ValidityUpperBoundInShelleyEra ttl - ShelleyBasedEraAllegra -> TxValidityUpperBound ValidityUpperBoundInAllegraEra ttl - ShelleyBasedEraMary -> TxValidityUpperBound ValidityUpperBoundInMaryEra ttl - ShelleyBasedEraAlonzo -> TxValidityUpperBound ValidityUpperBoundInAlonzoEra ttl - ShelleyBasedEraBabbage -> TxValidityUpperBound ValidityUpperBoundInBabbageEra ttl +mkValidityUpperBound ttl = case validityUpperBoundSupportedInEra (cardanoEra @ era) of + Just p -> TxValidityUpperBound p ttl + Nothing -> error "unreachable" mkTxOutValueAdaOnly :: forall era . IsShelleyBasedEra era => Lovelace -> TxOutValue era -mkTxOutValueAdaOnly l = case shelleyBasedEra @ era of - ShelleyBasedEraShelley -> TxOutAdaOnly AdaOnlyInShelleyEra l - ShelleyBasedEraAllegra -> TxOutAdaOnly AdaOnlyInAllegraEra l - ShelleyBasedEraMary -> TxOutValue MultiAssetInMaryEra $ lovelaceToValue l - ShelleyBasedEraAlonzo -> TxOutValue MultiAssetInAlonzoEra $ lovelaceToValue l - ShelleyBasedEraBabbage -> TxOutValue MultiAssetInBabbageEra $ lovelaceToValue l - -txOutValueToLovelace :: TxOutValue era -> Lovelace -txOutValueToLovelace = \case - TxOutAdaOnly AdaOnlyInByronEra x -> x - TxOutAdaOnly AdaOnlyInShelleyEra x -> x - TxOutAdaOnly AdaOnlyInAllegraEra x -> x - TxOutValue _ v -> case valueToLovelace v of - Just c -> c - Nothing -> error "txOutValueLovelace TxOut contains no ADA" +mkTxOutValueAdaOnly l = case multiAssetSupportedInEra (cardanoEra @ era) of + Right p -> TxOutValue p $ lovelaceToValue l + Left p -> TxOutAdaOnly p l txInModeCardano :: forall era . IsShelleyBasedEra era => Tx era -> TxInMode CardanoMode -txInModeCardano tx = case shelleyBasedEra @ era of - ShelleyBasedEraShelley -> TxInMode tx ShelleyEraInCardanoMode - ShelleyBasedEraAllegra -> TxInMode tx AllegraEraInCardanoMode - ShelleyBasedEraMary -> TxInMode tx MaryEraInCardanoMode - ShelleyBasedEraAlonzo -> TxInMode tx AlonzoEraInCardanoMode - ShelleyBasedEraBabbage -> TxInMode tx BabbageEraInCardanoMode +txInModeCardano tx = case toEraInMode (cardanoEra @ era) CardanoMode of + Just t -> TxInMode tx t + Nothing -> error "txInModeCardano :unreachable" diff --git a/bench/tx-generator/src/Cardano/Benchmarking/PlutusExample.hs b/bench/tx-generator/src/Cardano/Benchmarking/PlutusExample.hs index 7c98d88b77d..65c9fbefb9e 100644 --- a/bench/tx-generator/src/Cardano/Benchmarking/PlutusExample.hs +++ b/bench/tx-generator/src/Cardano/Benchmarking/PlutusExample.hs @@ -33,7 +33,7 @@ mkUtxoScript networkId (scriptFile, script, txOutDatum) validity values where mkTxOut v = TxOut plutusScriptAddr - (mkTxOutValueAdaOnly v) + (lovelaceToTxOutValue v) (TxOutDatumHash ScriptDataInAlonzoEra $ hashScriptData txOutDatum) ReferenceScriptNone @@ -47,7 +47,7 @@ mkUtxoScript networkId (scriptFile, script, txOutDatum) validity values mkNewFund :: TxId -> TxIx -> Lovelace -> Fund mkNewFund txId txIx val = Fund $ InAnyCardanoEra AlonzoEra $ FundInEra { _fundTxIn = TxIn txId txIx - , _fundVal = mkTxOutValueAdaOnly val + , _fundVal = lovelaceToTxOutValue val , _fundSigningKey = Nothing , _fundValidity = validity , _fundVariant = PlutusScriptFund scriptFile txOutDatum diff --git a/bench/tx-generator/src/Cardano/Benchmarking/Script.hs b/bench/tx-generator/src/Cardano/Benchmarking/Script.hs index 3c7ec7a0f6a..69086297896 100644 --- a/bench/tx-generator/src/Cardano/Benchmarking/Script.hs +++ b/bench/tx-generator/src/Cardano/Benchmarking/Script.hs @@ -11,16 +11,15 @@ import Prelude import Control.Concurrent (threadDelay) import Control.Monad -import Control.Monad.IO.Class import Ouroboros.Network.NodeToClient (IOManager) -import Cardano.Node.Configuration.Logging (shutdownLoggingLayer) import Cardano.Benchmarking.Tracer (createDebugTracers) import Cardano.Benchmarking.Script.Action import Cardano.Benchmarking.Script.Aeson (parseScriptFileAeson) import Cardano.Benchmarking.Script.Core (setProtocolParameters) import Cardano.Benchmarking.Script.Env +import Cardano.Benchmarking.Script.NodeConfig (shutDownLogging) import Cardano.Benchmarking.Script.Store import Cardano.Benchmarking.Script.Types @@ -42,11 +41,3 @@ runScript script iom = runActionM execScript iom >>= \case set BenchTracers createDebugTracers setProtocolParameters QueryLocalNode forM_ script action - -shutDownLogging :: ActionM () -shutDownLogging = do - ll <- get LoggingLayer - traceError "QRT Last Message. LoggingLayer going to shutdown. 73 . . . ." - liftIO $ do - threadDelay (200*1000) - shutdownLoggingLayer ll diff --git a/bench/tx-generator/src/Cardano/Benchmarking/Script/Action.hs b/bench/tx-generator/src/Cardano/Benchmarking/Script/Action.hs index b8d565536a0..77dce25c96b 100644 --- a/bench/tx-generator/src/Cardano/Benchmarking/Script/Action.hs +++ b/bench/tx-generator/src/Cardano/Benchmarking/Script/Action.hs @@ -4,9 +4,10 @@ where import Data.Functor.Identity import Data.Dependent.Sum (DSum(..)) +import Cardano.Benchmarking.Script.Core import Cardano.Benchmarking.Script.Env +import Cardano.Benchmarking.Script.NodeConfig (startProtocol) import Cardano.Benchmarking.Script.Store -import Cardano.Benchmarking.Script.Core import Cardano.Benchmarking.Script.Types action :: Action -> ActionM () diff --git a/bench/tx-generator/src/Cardano/Benchmarking/Script/Core.hs b/bench/tx-generator/src/Cardano/Benchmarking/Script/Core.hs index 648cc7b9a2b..79cc2b41dfd 100644 --- a/bench/tx-generator/src/Cardano/Benchmarking/Script/Core.hs +++ b/bench/tx-generator/src/Cardano/Benchmarking/Script/Core.hs @@ -35,19 +35,18 @@ import qualified Cardano.Benchmarking.GeneratorTx as GeneratorTx import Cardano.Benchmarking.GeneratorTx as GeneratorTx (AsyncBenchmarkControl, TxGenError) -import Cardano.Benchmarking.GeneratorTx.LocalProtocolDefinition as Core (startProtocol) import Cardano.Benchmarking.GeneratorTx.NodeToNode (ConnectClient, benchmarkConnectTxSubmit) import Cardano.Benchmarking.GeneratorTx.SizedMetadata (mkMetadata) import Cardano.Benchmarking.GeneratorTx.Tx as Core (keyAddress, mkFee, txInModeCardano) import Cardano.Benchmarking.OuroborosImports as Core - (LocalSubmitTx, SigningKeyFile - , getGenesis, protocolToNetworkId, protocolToCodecConfig, makeLocalConnectInfo) + ( LocalSubmitTx, SigningKeyFile + , protocolToCodecConfig, makeLocalConnectInfo) import Cardano.Benchmarking.PlutusExample as PlutusExample import Cardano.Benchmarking.Tracer as Core - ( createLoggingLayerTracers, btTxSubmit_, btN2N_, btConnect_, btSubmission2_) + ( btTxSubmit_, btN2N_, btConnect_, btSubmission2_) import Cardano.Benchmarking.Types as Core - (NumberOfInputsPerTx(..), NumberOfOutputsPerTx(..),NumberOfTxs(..), SubmissionErrorPolicy(..) + ( NumberOfInputsPerTx(..), NumberOfOutputsPerTx(..),NumberOfTxs(..), SubmissionErrorPolicy(..) , TPSRate, TxAdditionalSize(..)) import Cardano.Benchmarking.Wallet as Wallet hiding (keyAddress) import Cardano.Benchmarking.FundSet as FundSet (getFundTxIn) @@ -80,17 +79,6 @@ setProtocolParameters s = case s of protocolParameters <- liftIO $ readProtocolParametersFile file set ProtocolParameterMode $ ProtocolParameterLocal protocolParameters -startProtocol :: FilePath -> ActionM () -startProtocol filePath = do - liftIO (runExceptT $ Core.startProtocol filePath) >>= \case - Left err -> throwE $ CliError err - Right (loggingLayer, protocol) -> do - set LoggingLayer loggingLayer - set Protocol protocol - set BenchTracers $ Core.createLoggingLayerTracers loggingLayer - set Genesis $ Core.getGenesis protocol - set (User TNetworkId) $ protocolToNetworkId protocol - readSigningKey :: KeyName -> SigningKeyFile -> ActionM () readSigningKey name filePath = liftIO ( runExceptT $ GeneratorTx.readSigningKey filePath) >>= \case @@ -114,7 +102,7 @@ addFund era wallet txIn lovelace keyName = do fundKey <- getName keyName let mkOutValue :: forall era. IsShelleyBasedEra era => AsType era -> ActionM (InAnyCardanoEra TxOutValue) - mkOutValue = \_ -> return $ InAnyCardanoEra (cardanoEra @ era) (mkTxOutValueAdaOnly lovelace) + mkOutValue = \_ -> return $ InAnyCardanoEra (cardanoEra @ era) (lovelaceToTxOutValue lovelace) outValue <- withEra era mkOutValue addFundToWallet wallet txIn outValue fundKey @@ -181,12 +169,22 @@ queryRemoteProtocolParameters :: ActionM ProtocolParameters queryRemoteProtocolParameters = do localNodeConnectInfo <- getLocalConnectInfo chainTip <- liftIO $ getLocalChainTip localNodeConnectInfo - ret <- liftIO $ queryNodeLocalState localNodeConnectInfo (Just $ chainTipToChainPoint chainTip) - $ QueryInEra AlonzoEraInCardanoMode $ QueryInShelleyBasedEra ShelleyBasedEraAlonzo QueryProtocolParameters - case ret of - Right (Right pp) -> return pp - Right (Left err) -> throwE $ ApiError $ show err - Left err -> throwE $ ApiError $ show err + era <- queryEra + let + callQuery :: forall a. Show a => QueryInMode CardanoMode (Either a ProtocolParameters) -> ActionM ProtocolParameters + callQuery query = do + res <- liftIO $ queryNodeLocalState localNodeConnectInfo (Just $ chainTipToChainPoint chainTip) query + case res of + Right (Right pp) -> return pp + Right (Left err) -> throwE $ ApiError $ show err + Left err -> throwE $ ApiError $ show err + case era of + AnyCardanoEra ByronEra -> throwE $ ApiError "queryRemoteProtocolParameters Byron not supported" + AnyCardanoEra ShelleyEra -> callQuery $ QueryInEra ShelleyEraInCardanoMode $ QueryInShelleyBasedEra ShelleyBasedEraShelley QueryProtocolParameters + AnyCardanoEra AllegraEra -> callQuery $ QueryInEra AllegraEraInCardanoMode $ QueryInShelleyBasedEra ShelleyBasedEraAllegra QueryProtocolParameters + AnyCardanoEra MaryEra -> callQuery $ QueryInEra MaryEraInCardanoMode $ QueryInShelleyBasedEra ShelleyBasedEraMary QueryProtocolParameters + AnyCardanoEra AlonzoEra -> callQuery $ QueryInEra AlonzoEraInCardanoMode $ QueryInShelleyBasedEra ShelleyBasedEraAlonzo QueryProtocolParameters + AnyCardanoEra BabbageEra -> callQuery $ QueryInEra BabbageEraInCardanoMode $ QueryInShelleyBasedEra ShelleyBasedEraBabbage QueryProtocolParameters getProtocolParameters :: ActionM ProtocolParameters getProtocolParameters = do @@ -244,8 +242,8 @@ runBenchmark era sourceWallet submitMode spendMode threadName txCount tps = case spendMode of SpendOutput -> withEra era $ runBenchmarkInEra sourceWallet submitMode threadName txCount tps SpendScript scriptFile scriptBudget scriptData scriptRedeemer - -> runPlutusBenchmark sourceWallet submitMode scriptFile scriptBudget scriptData scriptRedeemer threadName txCount tps - SpendAutoScript scriptFile -> spendAutoScript sourceWallet submitMode scriptFile threadName txCount tps + -> withEra era $ runPlutusBenchmark sourceWallet submitMode scriptFile scriptBudget scriptData scriptRedeemer threadName txCount tps + SpendAutoScript scriptFile -> withEra era $ spendAutoScript sourceWallet submitMode scriptFile threadName txCount tps runBenchmarkInEra :: forall era. IsShelleyBasedEra era => WalletName @@ -313,8 +311,8 @@ runBenchmarkInEra sourceWallet submitMode (ThreadName threadName) txCount tps er Right ctl -> setName (ThreadName threadName) ctl _otherwise -> runWalletScriptInMode submitMode $ walletScript $ FundSet.Target "alternate-submit-mode" -runPlutusBenchmark :: - WalletName +runPlutusBenchmark :: forall era. IsShelleyBasedEra era + => WalletName -> SubmitMode -> FilePath -> ScriptBudget @@ -323,8 +321,9 @@ runPlutusBenchmark :: -> ThreadName -> NumberOfTxs -> TPSRate + -> AsType era -> ActionM () -runPlutusBenchmark sourceWallet submitMode scriptFile scriptBudget scriptData scriptRedeemer (ThreadName threadName) txCount tps = do +runPlutusBenchmark sourceWallet submitMode scriptFile scriptBudget scriptData scriptRedeemer (ThreadName threadName) txCount tps era = do tracers <- get BenchTracers (NumberOfInputsPerTx numInputs) <- getUser TNumberOfInputsPerTx (NumberOfOutputsPerTx numOutputs) <- getUser TNumberOfOutputsPerTx @@ -405,31 +404,36 @@ runPlutusBenchmark sourceWallet submitMode scriptFile scriptBudget scriptData sc -- inToOut = FundSet.inputsToOutputsWithFee totalFee 1 PlutusScript PlutusScriptV1 script' = script - scriptWitness :: ScriptWitness WitCtxTxIn AlonzoEra - scriptWitness = PlutusScriptWitness - PlutusScriptV1InAlonzo + scriptWitness :: ScriptWitness WitCtxTxIn era + scriptWitness = case scriptLanguageSupportedInEra (cardanoEra @ era) (PlutusScriptLanguage PlutusScriptV1) of + Nothing -> error $ "runPlutusBenchmark: Plutus V1 scriptlanguage not supported : in era" ++ show (cardanoEra @ era) + Just scriptLang -> PlutusScriptWitness + scriptLang PlutusScriptV1 script' (ScriptDatumForTxIn scriptData) scriptRedeemer executionUnits - collateral = (TxInsCollateral CollateralInAlonzoEra $ map getFundTxIn collateralFunds, collateralFunds) + collateral = case collateralSupportedInEra (cardanoEra @ era) of + Nothing -> error $ "runPlutusBenchmark: collateral: era not supported :" ++ show (cardanoEra @ era) + Just p -> (TxInsCollateral p $ map getFundTxIn collateralFunds, collateralFunds) + txGenerator = genTx protocolParameters collateral (mkFee totalFee) metadata (ScriptWitness ScriptWitnessForSpending scriptWitness) fundToStore = mkWalletFundStore walletRefDst - toUTxO :: FundSet.Target -> FundSet.SeqNumber -> ToUTxO AlonzoEra + toUTxO :: FundSet.Target -> FundSet.SeqNumber -> ToUTxO era toUTxO target seqNumber = Wallet.mkUTxO networkId fundKey (InFlight target seqNumber) - walletScript :: FundSet.Target -> WalletScript AlonzoEra + walletScript :: FundSet.Target -> WalletScript era walletScript = benchmarkWalletScript walletRefSrc txGenerator txCount (const fundSource) inToOut toUTxO fundToStore case submitMode of NodeToNode targetNodes -> do connectClient <- getConnectClient ret <- liftIO $ runExceptT $ GeneratorTx.walletBenchmark (btTxSubmit_ tracers) (btN2N_ tracers) connectClient - threadName targetNodes tps LogErrors AsAlonzoEra txCount walletScript + threadName targetNodes tps LogErrors era txCount walletScript case ret of Left err -> liftTxGenError err Right ctl -> setName (ThreadName threadName) ctl @@ -593,8 +597,16 @@ It is intended to be used with the the loop script from cardano-node/plutus-exam loopScriptFile is the FilePath to the Plutus script that implements the delay loop. (for example in /nix/store/). spendAutoScript relies on a particular calling convention of the loop script. -} -spendAutoScript :: WalletName -> SubmitMode -> FilePath -> ThreadName -> NumberOfTxs -> TPSRate -> ActionM () -spendAutoScript sourceWallet submitMode loopScriptFile threadName txCount tps = do +spendAutoScript :: forall era. IsShelleyBasedEra era + => WalletName + -> SubmitMode + -> FilePath + -> ThreadName + -> NumberOfTxs + -> TPSRate + -> AsType era + -> ActionM () +spendAutoScript sourceWallet submitMode loopScriptFile threadName txCount tps era = do protocolParameters <- getProtocolParameters perTxBudget <- case protocolParamMaxTxExUnits protocolParameters of Nothing -> throwE $ ApiError "Cannot determine protocolParamMaxTxExUnits" @@ -617,7 +629,7 @@ spendAutoScript sourceWallet submitMode loopScriptFile threadName txCount tps = redeemer <- case startSearch isInLimits 0 searchUpperBound of Left err -> throwE $ ApiError $ "cannot find fitting redeemer :" ++ err Right n -> return $ toLoopArgument n - runPlutusBenchmark sourceWallet submitMode loopScriptFile PreExecuteScript (ScriptDataNumber 0) redeemer threadName txCount tps + runPlutusBenchmark sourceWallet submitMode loopScriptFile PreExecuteScript (ScriptDataNumber 0) redeemer threadName txCount tps era where -- This is the hardcoded calling convention of the loop.plutus script. -- To loop n times one has to pass n + 1_000_000 as redeemer. diff --git a/bench/tx-generator/src/Cardano/Benchmarking/Script/Env.hs b/bench/tx-generator/src/Cardano/Benchmarking/Script/Env.hs index 2a4987ff92e..55ff2ccc26a 100644 --- a/bench/tx-generator/src/Cardano/Benchmarking/Script/Env.hs +++ b/bench/tx-generator/src/Cardano/Benchmarking/Script/Env.hs @@ -25,11 +25,11 @@ import Control.Monad.Trans.RWS.Strict (RWST) import qualified Control.Monad.Trans.RWS.Strict as RWS import Control.Tracer (traceWith) +import qualified Cardano.Node.Types (ConfigError) import qualified Cardano.Benchmarking.Tracer as Tracer import Ouroboros.Network.NodeToClient (IOManager) import Cardano.Benchmarking.GeneratorTx.Error (TxGenError) -import Cardano.Benchmarking.GeneratorTx.LocalProtocolDefinition (CliError) import Cardano.Benchmarking.Script.Setters as Setters import Cardano.Benchmarking.Script.Store @@ -51,7 +51,9 @@ type SetKeyVal = DSum Setters.Tag Identity data Error where LookupError :: !(Store v) -> Error TxGenError :: !TxGenError -> Error - CliError :: !CliError -> Error + NodeConfigError :: Cardano.Node.Types.ConfigError -> Error + ProtocolInstantiationError :: !String -> Error + MkNodeConfigError :: !String -> Error ApiError :: !String -> Error UserError :: !String -> Error WalletError :: !String -> Error diff --git a/bench/tx-generator/src/Cardano/Benchmarking/Script/NodeConfig.hs b/bench/tx-generator/src/Cardano/Benchmarking/Script/NodeConfig.hs new file mode 100644 index 00000000000..8be2544b5f1 --- /dev/null +++ b/bench/tx-generator/src/Cardano/Benchmarking/Script/NodeConfig.hs @@ -0,0 +1,101 @@ +module Cardano.Benchmarking.Script.NodeConfig + ( startProtocol + , shutDownLogging + ) where + +import Paths_tx_generator (version) +import Prelude + +import Data.Monoid +import Data.Text (pack) +import Data.Version (showVersion) + +import Control.Concurrent (threadDelay) +import Control.Monad.IO.Class +import Control.Monad.Trans.Except + +import Cardano.Tracing.Config (TraceOptions(..)) + +import Cardano.Node.Configuration.Logging (LoggingLayer, createLoggingLayer, shutdownLoggingLayer) +import Cardano.Node.Configuration.POM +import Cardano.Node.Handlers.Shutdown +import Cardano.Node.Protocol.Cardano +import Cardano.Node.Protocol.Types (SomeConsensusProtocol) +import Cardano.Node.Types + +import Cardano.Benchmarking.OuroborosImports as Core (getGenesis, protocolToNetworkId) +import Cardano.Benchmarking.Tracer +import Cardano.Benchmarking.Script.Env +import Cardano.Benchmarking.Script.Setters +import Cardano.Benchmarking.Script.Store as Store + +liftToAction :: ExceptT Error IO a -> ActionM a +liftToAction = ExceptT . liftIO . runExceptT + +makeConsensusProtocol + :: NodeConfiguration + -> ActionM SomeConsensusProtocol +makeConsensusProtocol nodeConfig = liftToAction $ case ncProtocolConfig nodeConfig of + NodeProtocolConfigurationByron _ -> throwE $ ProtocolInstantiationError "NodeProtocolConfigurationByron not supported" + NodeProtocolConfigurationShelley _ -> throwE $ ProtocolInstantiationError "NodeProtocolConfigurationShelley not supported" + NodeProtocolConfigurationCardano byronConfig shelleyConfig alonzoConfig hardforkConfig + -> withExceptT (ProtocolInstantiationError . show) $ + mkSomeConsensusProtocolCardano byronConfig shelleyConfig alonzoConfig hardforkConfig Nothing + +makeLegacyLoggingLayer :: NodeConfiguration -> SomeConsensusProtocol -> ActionM LoggingLayer +makeLegacyLoggingLayer nc ptcl = liftToAction $ withExceptT NodeConfigError $ + createLoggingLayer + (pack $ showVersion version) + nc {ncTraceConfig=TracingOff} + ptcl + +makeNodeConfig :: FilePath -> ActionM NodeConfiguration +makeNodeConfig logConfig = liftToAction $ ExceptT $ do + let configFp = ConfigYamlFilePath logConfig + filesPc = defaultPartialNodeConfiguration + { pncProtocolFiles = Last . Just $ + ProtocolFilepaths + { byronCertFile = Just "" + , byronKeyFile = Just "" + , shelleyKESFile = Just "" + , shelleyVRFFile = Just "" + , shelleyCertFile = Just "" + , shelleyBulkCredsFile = Just "" + } + , pncValidateDB = Last $ Just False + , pncShutdownConfig = Last $ Just $ ShutdownConfig Nothing Nothing + , pncConfigFile = Last $ Just configFp + } + configYamlPc <- parseNodeConfigurationFP . Just $ configFp + case makeNodeConfiguration $ configYamlPc <> filesPc of + Left err -> return $ Left $ MkNodeConfigError err + Right nc' -> return $ Right nc' + +startProtocol :: FilePath -> ActionM () +startProtocol filePath = do + nodeConfig <- makeNodeConfig filePath + protocol <- makeConsensusProtocol nodeConfig + set Protocol protocol + set Genesis $ Core.getGenesis protocol + set (User TNetworkId) $ protocolToNetworkId protocol + case ncTraceConfig nodeConfig of + TraceDispatcher _ -> do + set Store.LoggingLayer Nothing + set Store.BenchTracers createDebugTracers + TracingOnLegacy _ -> do + loggingLayer <- makeLegacyLoggingLayer nodeConfig protocol + set Store.LoggingLayer $ Just loggingLayer + set Store.BenchTracers $ createLoggingLayerTracers loggingLayer + TracingOff -> do + set Store.LoggingLayer Nothing + set Store.BenchTracers createDebugTracers + +shutDownLogging :: ActionM () +shutDownLogging = do + ll <- get LoggingLayer + traceError "QRT Last Message. LoggingLayer going to shutdown. 73 . . . ." + liftIO $ do + threadDelay (200*1000) + case ll of + Just x -> shutdownLoggingLayer x + Nothing -> return () diff --git a/bench/tx-generator/src/Cardano/Benchmarking/Script/Store.hs b/bench/tx-generator/src/Cardano/Benchmarking/Script/Store.hs index 684928d43f3..91ea22583e3 100644 --- a/bench/tx-generator/src/Cardano/Benchmarking/Script/Store.hs +++ b/bench/tx-generator/src/Cardano/Benchmarking/Script/Store.hs @@ -36,7 +36,7 @@ type Fund = (Core.Fund, SigningKey PaymentKey) data Store v where User :: Setters.Tag x -> Store x - LoggingLayer :: Store LoggingLayer + LoggingLayer :: Store (Maybe LoggingLayer) Protocol :: Store SomeConsensusProtocol BenchTracers :: Store Core.BenchTracers Genesis :: Store (ShelleyGenesis StandardShelley) diff --git a/bench/tx-generator/src/Cardano/Benchmarking/Wallet.hs b/bench/tx-generator/src/Cardano/Benchmarking/Wallet.hs index 85049a31dd1..ca38790cf36 100644 --- a/bench/tx-generator/src/Cardano/Benchmarking/Wallet.hs +++ b/bench/tx-generator/src/Cardano/Benchmarking/Wallet.hs @@ -121,14 +121,14 @@ mkUTxOVariant variant networkId key validity values , newFunds ) where - mkTxOut v = TxOut (keyAddress @ era networkId key) (mkTxOutValueAdaOnly v) TxOutDatumNone ReferenceScriptNone + mkTxOut v = TxOut (keyAddress @ era networkId key) (lovelaceToTxOutValue v) TxOutDatumNone ReferenceScriptNone newFunds txId = zipWith (mkNewFund txId) [TxIx 0 ..] values mkNewFund :: TxId -> TxIx -> Lovelace -> Fund mkNewFund txId txIx val = Fund $ InAnyCardanoEra (cardanoEra @ era) $ FundInEra { _fundTxIn = TxIn txId txIx - , _fundVal = mkTxOutValueAdaOnly val + , _fundVal = lovelaceToTxOutValue val , _fundSigningKey = Just key , _fundValidity = validity , _fundVariant = variant @@ -229,11 +229,3 @@ keyAddress networkId k networkId (PaymentCredentialByKey $ verificationKeyHash $ getVerificationKey k) NoStakeAddress - -mkTxOutValueAdaOnly :: forall era . IsShelleyBasedEra era => Lovelace -> TxOutValue era -mkTxOutValueAdaOnly l = case shelleyBasedEra @ era of - ShelleyBasedEraShelley -> TxOutAdaOnly AdaOnlyInShelleyEra l - ShelleyBasedEraAllegra -> TxOutAdaOnly AdaOnlyInAllegraEra l - ShelleyBasedEraMary -> TxOutValue MultiAssetInMaryEra $ lovelaceToValue l - ShelleyBasedEraAlonzo -> TxOutValue MultiAssetInAlonzoEra $ lovelaceToValue l - ShelleyBasedEraBabbage -> TxOutValue MultiAssetInBabbageEra $ lovelaceToValue l diff --git a/bench/tx-generator/test/Main.hs b/bench/tx-generator/test/Main.hs index 65deef7d02c..9f4336d482a 100644 --- a/bench/tx-generator/test/Main.hs +++ b/bench/tx-generator/test/Main.hs @@ -18,11 +18,15 @@ tests = testGroup "cardano-tx-generator" ] sizedMetadata = testGroup "properties of the CBOR encoding relevant for generating sized metadat" - [ testCase "Shelley metadata map costs" $ assertBool "metadata map costs" prop_mapCostsShelley - , testCase "Shelley metadata ByteString costs" $ assertBool "metadata ByteString costs" prop_bsCostsShelley - , testCase "Allegra metadata map costs" $ assertBool "metadata map costs" prop_mapCostsAllegra - , testCase "Allegra metadata ByteString costs" $ assertBool "metadata ByteString costs" prop_bsCostsAllegra - , testCase "Mary metadata map costs" $ assertBool "metadata map costs" prop_mapCostsMary - , testCase "Marymetadata ByteString costs" $ assertBool "metadata ByteString costs" prop_bsCostsMary + [ testCase "Shelley metadata map costs" $ assertBool "metadata map costs" prop_mapCostsShelley + , testCase "Shelley metadata ByteString costs" $ assertBool "metadata ByteString costs" prop_bsCostsShelley + , testCase "Allegra metadata map costs" $ assertBool "metadata map costs" prop_mapCostsAllegra + , testCase "Allegra metadata ByteString costs" $ assertBool "metadata ByteString costs" prop_bsCostsAllegra + , testCase "Mary metadata map costs" $ assertBool "metadata map costs" prop_mapCostsMary + , testCase "Mary metadata ByteString costs" $ assertBool "metadata ByteString costs" prop_bsCostsMary + , testCase "Alonzo metadata map costs" $ assertBool "metadata map costs" prop_mapCostsAlonzo + , testCase "Alonzo metadata ByteString costs" $ assertBool "metadata ByteString costs" prop_bsCostsAlonzo + , testCase "Babbage metadata map costs" $ assertBool "metadata map costs" prop_mapCostsBabbage + , testCase "Babbage metadata ByteString costs" $ assertBool "metadata ByteString costs" prop_bsCostsBabbage , testCase "Test mkMetadata" $ assertBool "" True --WIP ] diff --git a/bench/tx-generator/tx-generator.cabal b/bench/tx-generator/tx-generator.cabal index fbcac7db42e..63795f65677 100644 --- a/bench/tx-generator/tx-generator.cabal +++ b/bench/tx-generator/tx-generator.cabal @@ -1,5 +1,5 @@ name: tx-generator -version: 2.0 +version: 2.2 description: The transaction generator for cardano node author: IOHK maintainer: operations@iohk.io @@ -30,7 +30,6 @@ library Cardano.Benchmarking.FundSet Cardano.Benchmarking.GeneratorTx Cardano.Benchmarking.GeneratorTx.Error - Cardano.Benchmarking.GeneratorTx.LocalProtocolDefinition Cardano.Benchmarking.GeneratorTx.Genesis Cardano.Benchmarking.GeneratorTx.NodeToNode Cardano.Benchmarking.GeneratorTx.Tx @@ -45,6 +44,7 @@ library Cardano.Benchmarking.Script.Aeson Cardano.Benchmarking.Script.Core Cardano.Benchmarking.Script.Env + Cardano.Benchmarking.Script.NodeConfig Cardano.Benchmarking.Script.Selftest Cardano.Benchmarking.Script.Setters Cardano.Benchmarking.Script.Store diff --git a/cabal.project b/cabal.project index e9430123b22..682f1320235 100644 --- a/cabal.project +++ b/cabal.project @@ -130,6 +130,9 @@ package small-steps package small-steps-test tests: False +package tx-generator + tests: True + package goblins tests: False diff --git a/cardano-api/cardano-api.cabal b/cardano-api/cardano-api.cabal index 93778aec982..1cadb712d2a 100644 --- a/cardano-api/cardano-api.cabal +++ b/cardano-api/cardano-api.cabal @@ -61,6 +61,7 @@ library Cardano.Api.HasTypeProxy Cardano.Api.IPC Cardano.Api.IPC.Monad + Cardano.Api.InMode Cardano.Api.Json Cardano.Api.Key Cardano.Api.KeysByron @@ -86,7 +87,6 @@ library Cardano.Api.StakePoolMetadata Cardano.Api.Tx Cardano.Api.TxBody - Cardano.Api.InMode Cardano.Api.TxMetadata Cardano.Api.TxSubmit.ErrorRender Cardano.Api.TxSubmit.Types diff --git a/cardano-api/src/Cardano/Api/Shelley.hs b/cardano-api/src/Cardano/Api/Shelley.hs index 0d34e59820c..7fe38c21f7b 100644 --- a/cardano-api/src/Cardano/Api/Shelley.hs +++ b/cardano-api/src/Cardano/Api/Shelley.hs @@ -211,6 +211,7 @@ module Cardano.Api.Shelley nextEpochEligibleLeadershipSlots, -- ** Conversions shelleyPayAddrToPlutusPubKHash, + toConsensusGenTx, --TODO: arrange not to export these toShelleyNetwork, fromShelleyPParams, @@ -223,6 +224,7 @@ import Cardano.Api.Block import Cardano.Api.Certificate import Cardano.Api.Eras import Cardano.Api.IPC +import Cardano.Api.InMode import Cardano.Api.KeysPraos import Cardano.Api.KeysShelley import Cardano.Api.LedgerState diff --git a/cardano-node/src/Cardano/Node/Run.hs b/cardano-node/src/Cardano/Node/Run.hs index fd356af9509..2b2ea634158 100644 --- a/cardano-node/src/Cardano/Node/Run.hs +++ b/cardano-node/src/Cardano/Node/Run.hs @@ -6,7 +6,6 @@ {-# LANGUAGE NamedFieldPuns #-} {-# LANGUAGE PackageImports #-} {-# LANGUAGE ScopedTypeVariables #-} -{-# LANGUAGE TupleSections #-} {-# LANGUAGE TypeApplications #-} #if !defined(mingw32_HOST_OS) @@ -192,59 +191,63 @@ handleNodeWithTracers cmdPc nc p networkMagic runP = do let fp = maybe "No file path found!" unConfigPath (getLast (pncConfigFile cmdPc)) - (tracers, mLoggingLayer) <- - case ncTraceConfig nc of - TraceDispatcher{} -> do - (, Nothing) <$> - initTraceDispatcher - nc - p - networkMagic - nodeKernelData - p2pMode - _ -> do - eLoggingLayer <- runExceptT $ createLoggingLayer - (Text.pack (showVersion version)) + case ncTraceConfig nc of + TraceDispatcher{} -> do + tracers <- + initTraceDispatcher nc p - - loggingLayer <- case eLoggingLayer of - Left err -> putTextLn (Text.pack $ show err) >> exitFailure - Right res -> return res - !trace <- setupTrace loggingLayer - let tracer = contramap pack $ toLogObject trace - logTracingVerbosity nc tracer - - -- Legacy logging infrastructure must trace 'nodeStartTime' and 'nodeBasicInfo'. - startTime <- getCurrentTime - traceCounter "nodeStartTime" trace (ceiling $ utcTimeToPOSIXSeconds startTime) - nbi <- nodeBasicInfo nc p startTime - forM_ nbi $ \(LogObject nm mt content) -> - traceNamedObject (appendName nm trace) (mt, content) - - (,Just loggingLayer) <$> - mkTracers - (Consensus.configBlock cfg) - (ncTraceConfig nc) - trace - nodeKernelData - (llEKGDirect loggingLayer) - p2pMode - - getStartupInfo nc p fp - >>= mapM_ (traceWith $ startupTracer tracers) - - Async.withAsync (handlePeersListSimple (error "Implement Tracer IO [Peer blk]") nodeKernelData) - $ \_peerLoggingThread -> - -- We ignore peer logging thread if it dies, but it will be killed - -- when 'handleSimpleNode' terminates. - handleSimpleNode runP p2pMode tracers nc - (\nk -> do - setNodeKernel nodeKernelData nk - traceWith (nodeStateTracer tracers) NodeKernelOnline) - `finally` - forM_ mLoggingLayer - shutdownLoggingLayer + networkMagic + nodeKernelData + p2pMode + handleSimpleNode runP p2pMode tracers nc + (\nk -> do + setNodeKernel nodeKernelData nk + traceWith (nodeStateTracer tracers) NodeKernelOnline) + + _ -> do + eLoggingLayer <- runExceptT $ createLoggingLayer + (Text.pack (showVersion version)) + nc + p + + loggingLayer <- case eLoggingLayer of + Left err -> putTextLn (Text.pack $ show err) >> exitFailure + Right res -> return res + !trace <- setupTrace loggingLayer + let tracer = contramap pack $ toLogObject trace + logTracingVerbosity nc tracer + + -- Legacy logging infrastructure must trace 'nodeStartTime' and 'nodeBasicInfo'. + startTime <- getCurrentTime + traceCounter "nodeStartTime" trace (ceiling $ utcTimeToPOSIXSeconds startTime) + nbi <- nodeBasicInfo nc p startTime + forM_ nbi $ \(LogObject nm mt content) -> + traceNamedObject (appendName nm trace) (mt, content) + + tracers <- + mkTracers + (Consensus.configBlock cfg) + (ncTraceConfig nc) + trace + nodeKernelData + (llEKGDirect loggingLayer) + p2pMode + + getStartupInfo nc p fp + >>= mapM_ (traceWith $ startupTracer tracers) + + Async.withAsync (handlePeersListSimple (error "Implement Tracer IO [Peer blk]") nodeKernelData) + $ \_peerLoggingThread -> + -- We ignore peer logging thread if it dies, but it will be killed + -- when 'handleSimpleNode' terminates. + handleSimpleNode runP p2pMode tracers nc + (\nk -> do + setNodeKernel nodeKernelData nk + traceWith (nodeStateTracer tracers) NodeKernelOnline) + `finally` + forM_ eLoggingLayer + shutdownLoggingLayer logTracingVerbosity :: NodeConfiguration -> Tracer IO String -> IO () diff --git a/cardano-node/src/Cardano/Node/Tracing/Tracers.hs b/cardano-node/src/Cardano/Node/Tracing/Tracers.hs index 0fa8f47e8c3..aa0d2df8824 100644 --- a/cardano-node/src/Cardano/Node/Tracing/Tracers.hs +++ b/cardano-node/src/Cardano/Node/Tracing/Tracers.hs @@ -89,12 +89,12 @@ mkDispatchTracers mkDispatchTracers nodeKernel trBase trForward mbTrEKG trDataPoint trConfig enableP2P p = do -- Some special tracers -- NodeInfo tracer - nodeInfoTr <- mkDataPointTracer + nodeInfoDP <- mkDataPointTracer trDataPoint (const ["NodeInfo"]) - configureTracers trConfig docNodeInfoTraceEvent [nodeInfoTr] + configureTracers trConfig docNodeInfoTraceEvent [nodeInfoDP] - nodeStateTr <- mkDataPointTracer + nodeStateDP <- mkDataPointTracer trDataPoint (const ["NodeState"]) @@ -107,7 +107,7 @@ mkDispatchTracers nodeKernel trBase trForward mbTrEKG trDataPoint trConfig enabl allPublic configureTracers trConfig SR.docNodeState [stateTr] - nodePeersTr <- mkDataPointTracer + nodePeersDP <- mkDataPointTracer trDataPoint (const ["NodePeers"]) @@ -204,19 +204,24 @@ mkDispatchTracers nodeKernel trBase trForward mbTrEKG trDataPoint trConfig enabl diffusionTrExtra :: Diffusion.ExtraTracers p2p <- mkDiffusionTracersExtra trBase trForward mbTrEKG trDataPoint trConfig enableP2P pure Tracers - { chainDBTracer = Tracer (\x -> traceWith chainDBTr' x >> SR.traceNodeStateChainDB p nodeStateTr x) - <> Tracer (\x -> traceWith replayBlockTr' x >> SR.traceNodeStateChainDB p nodeStateTr x) + { chainDBTracer = Tracer (traceWith chainDBTr') + <> Tracer (traceWith replayBlockTr') + <> Tracer (SR.traceNodeStateChainDB p nodeStateDP) , consensusTracers = consensusTr , nodeToClientTracers = nodeToClientTr , nodeToNodeTracers = nodeToNodeTr , diffusionTracers = diffusionTr , diffusionTracersExtra = diffusionTrExtra - , startupTracer = Tracer $ \x -> traceWith startupTr x >> SR.traceNodeStateStartup nodeStateTr x - , shutdownTracer = Tracer $ \x -> traceWith shutdownTr x >> SR.traceNodeStateShutdown nodeStateTr x - , nodeInfoTracer = Tracer (traceWith nodeInfoTr) - , nodeStateTracer = Tracer (traceWith stateTr) <> Tracer (traceWith nodeStateTr) + , startupTracer = Tracer (traceWith startupTr) + <> Tracer (SR.traceNodeStateStartup nodeStateDP) + , shutdownTracer = Tracer (traceWith shutdownTr) + <> Tracer (SR.traceNodeStateShutdown nodeStateDP) + , nodeInfoTracer = Tracer (traceWith nodeInfoDP) + , nodeStateTracer = Tracer (traceWith stateTr) + <> Tracer (traceWith nodeStateDP) , resourcesTracer = Tracer (traceWith resourcesTr) - , peersTracer = Tracer $ \x -> traceWith peersTr x >> traceNodePeers nodePeersTr x + , peersTracer = Tracer (traceWith peersTr) + <> Tracer (traceNodePeers nodePeersDP) } mkConsensusTracers :: forall blk. diff --git a/lib.mk b/lib.mk index 98fc5596f1a..1d5d1bafae6 100644 --- a/lib.mk +++ b/lib.mk @@ -6,7 +6,7 @@ ifeq ($(3),true) $(1): ARGS += --arg 'workbenchDevMode' true endif ifeq ($(4),true) -$(1): CMD := start-cluster; exit +$(1): CMD := start-cluster && exit || exit 1 endif ifeq ($(3)$(4),truefalse) define EXTRA_HELP += diff --git a/nix/custom-config.nix b/nix/custom-config.nix index d6689d47e5f..c2e1cef445d 100644 --- a/nix/custom-config.nix +++ b/nix/custom-config.nix @@ -4,7 +4,7 @@ self: { cacheDir = "${self.localCluster.stateDir}/.cache"; stateDir = "run/current"; batchName = "plain"; - profileName = "default-alzo"; + profileName = "default-bage"; basePort = 30000; enableEKG = true; workbenchDevMode = false; diff --git a/nix/nixos/tx-generator-service.nix b/nix/nixos/tx-generator-service.nix index 23f02687a61..0642af47ebc 100644 --- a/nix/nixos/tx-generator-service.nix +++ b/nix/nixos/tx-generator-service.nix @@ -6,7 +6,7 @@ let targetNodes = targetNodesList cfg.targetNodes; era = capitalise cfg.era; plutusLoopScript = plutusScriptFile cfg "loop.plutus"; - inherit + inherit plutusMode plutusData plutusRedeemer @@ -21,7 +21,7 @@ let tx_fee tps init_cooldown - sigKey + sigKey min_utxo_value nodeConfigFile localNodeSocketPath; @@ -37,7 +37,7 @@ let (if runScript != null then runScript else runScriptFn cfg); - + capitalise = x: (pkgs.lib.toUpper (__substring 0 1 x)) + __substring 1 99999 x; plutusScript = cfg: plutusScriptFile cfg cfg.plutusScript; @@ -106,6 +106,7 @@ in pkgs.commonLib.defServiceModule "allegra" "mary" "alonzo" + "babbage" ]) "mary" "Cardano era to generate transactions for."; @@ -114,7 +115,7 @@ in pkgs.commonLib.defServiceModule decideRunScript = opt (functionTo str) defaultDecideRunScript "Decision procedure for the run script content."; }; - + configExeArgsFn = cfg: [ "json_highlevel" "${pkgs.writeText "tx-gen-config.json" (cfg.decideRunScript cfg)}" diff --git a/nix/workbench/genesis.sh b/nix/workbench/genesis.sh index fdde67c9302..d441500a232 100644 --- a/nix/workbench/genesis.sh +++ b/nix/workbench/genesis.sh @@ -173,10 +173,26 @@ case "$op" in sponge "$dir"/genesis.spec.json msg "genesis: mutating into staked genesis" +# local time=( +# -f '{ +# , "wall_clock_s": %e +# , "user_cpu_s": %U +# , "sys_cpu_s": %S +# , "avg_cpu_pct": "%P" +# , "rss_peak_kb": %M +# , "ctxsw_involuntary": %c +# , "ctxsw_volunt_waits": %w +# , "pageflt_major": %F +# , "pageflt_minor": %R +# , "io_fs_reads": %I +# , "io_fs_writes": %O +# }' +# -o "$dir"/cardano-cli-execution-stats.json +# ) params=(--genesis-dir "$dir" $(jq '.cli_args.createFinalBulk | join(" ")' "$profile_json" --raw-output) ) - cardano-cli genesis create-staked "${params[@]}" + time cardano-cli genesis create-staked "${params[@]}" mv "$dir"/genesis.json "$dir"/genesis-shelley.json mv "$dir"/genesis.spec.json "$dir"/genesis-shelley.spec.json diff --git a/nix/workbench/lib.sh b/nix/workbench/lib.sh index d6b9fde14c2..25a981f30dd 100644 --- a/nix/workbench/lib.sh +++ b/nix/workbench/lib.sh @@ -93,6 +93,10 @@ green() { with_color green $* } +blue() { + with_color blue $* +} + white() { with_color white $* } diff --git a/nix/workbench/profile-run.jq b/nix/workbench/profile-run.jq index 5eb01cd41f5..b1e97bdc11f 100644 --- a/nix/workbench/profile-run.jq +++ b/nix/workbench/profile-run.jq @@ -4,8 +4,9 @@ def profile_timing($prof; $start_human; $start_tag; $systemStart): - ($systemStart | fromdateiso8601 | . + $prof.derived.shutdown_time) as $shutdown_end -| ($systemStart | fromdateiso8601 | . + $prof.derived.generator_duration) as $workload_end + ($systemStart | fromdateiso8601 | . + $prof.derived.generator_duration) as $workload_end +| ($systemStart | fromdateiso8601 | . + ($prof.derived.shutdown_time + // $prof.derived.generator_duration)) as $shutdown_end | ( [$shutdown_end, $workload_end] | map(select(. != null)) | min) as $earliest_end diff --git a/nix/workbench/profile.sh b/nix/workbench/profile.sh index c84da3f729c..2ac706a2452 100644 --- a/nix/workbench/profile.sh +++ b/nix/workbench/profile.sh @@ -17,13 +17,14 @@ global_profile_eras=( allegra mary alonzo + babbage ) profile() { local op=${1:-show}; test $# -gt 0 && shift case "$op" in - list | names ) + list | names | ls ) profile generate-all | jq 'keys' ;; diff --git a/nix/workbench/profiles/defaults.jq b/nix/workbench/profiles/defaults.jq index e17956f6bfa..30e615b87e1 100644 --- a/nix/workbench/profiles/defaults.jq +++ b/nix/workbench/profiles/defaults.jq @@ -1,13 +1,13 @@ ## Testable with: ## -## jq -n 'include "defaults" { search: "nix/workbench/profiles" }; era_defaults("alonzo")' +## jq -n 'include "defaults" { search: "nix/workbench/profiles" }; era_defaults("babbage")' ## def era_defaults($era): { common: { era: $era ## Choice of a cluster run scenario (wb scenario --help): - , scenario: "default" + , scenario: "fixed-loaded" ## Cluster topology and composition: , composition: @@ -36,12 +36,12 @@ def era_defaults($era): ## Blockchain time & block density , active_slots_coeff: 0.05 - , epoch_length: 2200 # Ought to be at least (10 * k / f). - , parameter_k: 10 + , epoch_length: 600 # Ought to be at least (10 * k / f). + , parameter_k: 3 , slot_duration: 1 ## Block size & contents - , max_block_size: 64000 + , max_block_size: 80000 , max_tx_size: 16384 ## Verbatim overlay, for all era-specific genesis slices: @@ -61,24 +61,41 @@ def era_defaults($era): } , generator: - { add_tx_size: 0 - , init_cooldown: 25 + { add_tx_size: 100 + , init_cooldown: 5 , inputs_per_tx: 2 , outputs_per_tx: 2 , tx_fee: 1000000 - , epochs: 10 - , tps: 2 + , epochs: 3 + , tps: 12 } , node: { rts_flags_override: [] - , shutdown_on_slot_synced: null + , shutdown_on_slot_synced: 300 + , shutdown_on_block_synced: null , tracing_backend: "trace-dispatcher" ## or "iohk-monitoring" - , tracer: true + , tracer: false + , verbatim: + { EnableP2P: false + + , MempoolCapacityBytesOverride: "NoOverride" + , ProtocolIdleTimeout: 5 + , TimeWaitTimeout: 60 + , AcceptedConnectionsLimit: + { acceptedConnectionsHardLimit: 512 + , acceptedConnectionsSoftLimit: 384 + , acceptedConnectionsDelay: 5 + } + , TargetNumberOfRootPeers: 100 + , TargetNumberOfKnownPeers: 100 + , TargetNumberOfEstablishedPeers: 50 + , TargetNumberOfActivePeers: 20 + } } , analysis: - { type: null + { type: "standard" , cluster_startup_overhead_s: 10 , start_log_spread_s: 120 , last_log_spread_s: 120 @@ -104,7 +121,15 @@ def era_defaults($era): } , alonzo: - (.genesis.shelley.protocolParams.protocolVersion = + ({} | + .genesis.shelley.protocolParams.protocolVersion = + { major: 5 + , minor: 0 + }) + +, babbage: + ({} | + .genesis.shelley.protocolParams.protocolVersion = { major: 5 , minor: 0 }) diff --git a/nix/workbench/profiles/node-services.nix b/nix/workbench/profiles/node-services.nix index ae7637e8e1c..be4b5ec1f0f 100644 --- a/nix/workbench/profiles/node-services.nix +++ b/nix/workbench/profiles/node-services.nix @@ -123,6 +123,13 @@ let TestMaryHardForkAtEpoch = 0; TestAlonzoHardForkAtEpoch = 0; }; + babbage = + { TestShelleyHardForkAtEpoch = 0; + TestAllegraHardForkAtEpoch = 0; + TestMaryHardForkAtEpoch = 0; + TestAlonzoHardForkAtEpoch = 0; + TestBabbageHardForkAtEpoch = 0; + }; }.${profile.value.era}; }; in diff --git a/nix/workbench/profiles/variants.jq b/nix/workbench/profiles/variants.jq index 7d9ae6cdc64..6e975026f64 100644 --- a/nix/workbench/profiles/variants.jq +++ b/nix/workbench/profiles/variants.jq @@ -6,7 +6,7 @@ def all_profile_variants: | 1000000 as $M #################################################################################################### ## - ### Record history + ### Historic record ## | { genesis: { utxo: (4 * $M) @@ -54,10 +54,17 @@ def all_profile_variants: | #################################################################################################### ## - ### Status quo + ### Definition vocabulary: dataset size ## $dataset_jun2022 as $current_dataset + | ({}| + .generator.tps = 15 + ) as $current_tps_saturation_value + | + ({}| + .generator.tps = 0.2 + ) as $current_tps_saturation_plutus | ({}| .genesis.max_block_size = $params_feb2022.genesis.max_block_size @@ -67,23 +74,60 @@ def all_profile_variants: .genesis.alonzo = $params_feb2022.genesis.alonzo ) as $current_plutus | - ($current_dataset * - $current_block_size * - $current_plutus - ) as $status_quo + ($current_block_size * + $current_plutus * + $current_dataset + ) as $dataset_status_quo + | + ($current_block_size * + $current_plutus * + { genesis: + { utxo: (0.5 * $M) + , delegators: (0.1 * $M) + } + }) as $dataset_miniature | - #################################################################################################### ## - ### Definition vocabulary + ### Definition vocabulary: chain ## - ({}| - .generator.tps = 15 - ) as $saturation_tps_value + { chaindb: + { mainnet_chunks: + { chaindb_server: 10 + , observer: 0 + } + , ledger_snapshot: + { chaindb_server: 237599 + , observer: 0 + } + } + , node: + { shutdown_on_slot_synced: + { observer: 237599 + } + } + } as $chaindb_early_byron | - ({}| - .generator.tps = 0.2 - ) as $saturation_tps_plutus + ($dataset_oct2021 * + { chaindb: + { mainnet_chunks: + { chaindb_server: 1800 + , observer: 1799 + } + , ledger_snapshot: + { chaindb_server: 38901589 + , observer: 37173650 + } + } + , node: + { shutdown_on_slot_synced: + { observer: 38901589 + } + } + }) as $chaindb_early_alonzo | + ## + ### Definition vocabulary: cluster size + ## { composition: { n_singular_hosts: 1 , n_dense_hosts: 0 @@ -95,6 +139,12 @@ def all_profile_variants: , n_dense_hosts: 0 } } as $doublet + | + { composition: + { n_singular_hosts: 6 + , n_dense_hosts: 0 + } + } as $hexagon | { composition: { n_singular_hosts: 10 @@ -102,140 +152,181 @@ def all_profile_variants: } } as $tenner | - ({}| - .node.tracer = true - ) as $with_tracer - | - ({}| - .node.tracing_backend = "iohk-monitoring" - ) as $old_tracing + { composition: + { n_singular_hosts: 0 + , n_dense_hosts: 0 + , with_chaindb_server: true + , with_observer: true + } + } as $chainsync_cluster | + ## + ### Definition vocabulary: timescale + ## { genesis: { epoch_length: 600 , parameter_k: 3 } - } as $compressed + } as $compressed_timescale | - ($compressed * $saturation_tps_value * - { scenario: "fixed-loaded" - , analysis: - { type: "standard" } - }) as $fixed_loaded + { genesis: + { epoch_length: (3600 * 24 * 5) + , parameter_k: (18 * 24 * 5) + } + } as $mainnet_timescale + | + ## + ### Definition vocabulary: duration + ## + ({} | + .generator.epochs = 3 + ) as $for_3ep + | + ({} | + .generator.epochs = 4 + ) as $for_4ep + | + ({} | + .node.shutdown_on_block_synced = 1 + ) as $for_1blk + | + ({} | + .node.shutdown_on_block_synced = 3 + ) as $for_3blk + | + ({} | + .node.shutdown_on_block_synced = 15 + ) as $for_15blk + | + ({} | + .node.shutdown_on_block_synced = 30 + ) as $for_30blk | - ($fixed_loaded * $saturation_tps_plutus * - { generator: + ## + ### Definition vocabulary: workload + ## + ($current_tps_saturation_plutus * + { extra_desc: "with Plutus workload" + , generator: { inputs_per_tx: 1 , outputs_per_tx: 1 , plutusMode: true , plutusAutoMode: true } , analysis: - { type: "standard" - , filters: ["base", "size-small"] + { filters: ["base", "size-small"] } }) as $plutus | - ($fixed_loaded * $doublet * - { genesis: - { utxo: 6000 - , delegators: 1300 - , max_block_size: 80000 - } - , node: - { shutdown_on_slot_synced: 10 - } - }) as $startstop_base + ## + ### Definition vocabulary: node config variants + ## + ({ extra_desc: "with cardano-tracer" + , suffix: "tracer" + }| + .node.tracer = true + ) as $with_tracer | - ($status_quo * $fixed_loaded * $doublet * - { node: - { shutdown_on_slot_synced: 2400 - } - }) as $forge_stress_base + ({ extra_desc: "with legacy iohk-monitoring" + , suffix: "oldtracing" + }| + .node.tracing_backend = "iohk-monitoring" + ) as $old_tracing + | + ({ extra_desc: "with P2P networking" + , suffix: "p2p" + }| + .node.verbatim.EnableP2P = true + ) as $p2p | - { scenario: "chainsync" + ## + ### Definition vocabulary: scenario + ## + ($mainnet_timescale * $chainsync_cluster * + { desc: "Mainnet chain syncing benchmark" + , scenario: "chainsync" , preset: "mainnet" - , composition: - { n_singular_hosts: 0 - , n_dense_hosts: 0 - , with_chaindb_server: true - , with_observer: true - } , analysis: { type: "performance" , filters: [] } - } as $chainsync_base + }) as $scenario_chainsync | - { chaindb: - { mainnet_chunks: - { chaindb_server: 10 - , observer: 0 - } - , ledger_snapshot: - { chaindb_server: 237599 - , observer: 0 - } - } - , node: - { shutdown_on_slot_synced: - { observer: 237599 - } - } - } as $chaindb_early_byron + ($compressed_timescale * $current_tps_saturation_value * + { scenario: "fixed-loaded" + }) as $scenario_fixed_loaded | - ($dataset_oct2021 * - { chaindb: - { mainnet_chunks: - { chaindb_server: 1800 - , observer: 1799 - } - , ledger_snapshot: - { chaindb_server: 38901589 - , observer: 37173650 - } - } - , node: - { shutdown_on_slot_synced: - { observer: 38901589 - } + ## + ### Definition vocabulary: base variant + ## + ($scenario_fixed_loaded * $doublet * $dataset_miniature * $for_1blk * + { desc: "Stop as soon as we've seen a single block" + }) as $startstop_base + | + ($scenario_fixed_loaded * $doublet * $dataset_miniature * $for_3blk * + { desc: "Miniature dataset, CI-friendly duration, test scale" + }) as $citest_base + | + ($scenario_fixed_loaded * $doublet * $dataset_miniature * $for_15blk * + { desc: "Miniature dataset, CI-friendly duration, bench scale" + }) as $cibench_base + | + ($scenario_fixed_loaded * $doublet * $dataset_status_quo * + { node: + { shutdown_on_slot_synced: 2400 } - }) as $chaindb_early_alonzo + , desc: "Status-quo dataset size, honest four epochs." + }) as $forge_stress_base | #################################################################################################### ## ### Actual profiles ## - ## Baseline: - [ { name: "default" - , desc: "Default profile, as per nix/workbench/profiles/defaults.jq" - } - + ### First, auto-named profiles: + ### ## Short slots: - , $status_quo * + [ $dataset_status_quo * ({}| .genesis.slot_duration = 0.2 ) ## Dense pool: - , $status_quo * + , $dataset_status_quo * ({}| .genesis.dense_pool_density = 10 ) ## Sub-saturation TPS: - , ($status_quo | .generator.tps = 5 ) - , ($status_quo | .generator.tps = 10 ) + , ($dataset_status_quo | .generator.tps = 5 ) + , ($dataset_status_quo | .generator.tps = 10 ) ## Block size: - , ($status_quo | .genesis.max_block_size = 128000 | .generator.tps = 16 ) - , ($status_quo | .genesis.max_block_size = 256000 | .generator.tps = 32 ) - , ($status_quo | .genesis.max_block_size = 512000 | .generator.tps = 64 ) - , ($status_quo | .genesis.max_block_size = 1024000 | .generator.tps = 128 ) - , ($status_quo | .genesis.max_block_size = 2048000 | .generator.tps = 256 ) + , ($dataset_status_quo | .genesis.max_block_size = 128000 | .generator.tps = 16 ) + , ($dataset_status_quo | .genesis.max_block_size = 256000 | .generator.tps = 32 ) + , ($dataset_status_quo | .genesis.max_block_size = 512000 | .generator.tps = 64 ) + , ($dataset_status_quo | .genesis.max_block_size = 1024000 | .generator.tps = 128 ) + , ($dataset_status_quo | .genesis.max_block_size = 2048000 | .generator.tps = 256 ) - ## Fixed + ### Next, semantically-named profiles: + ### + ## Base variants: + , { name: "default" + , desc: "Default, as per nix/workbench/profiles/defaults.jq" + } + , $plutus * + { name: "plutus" + , desc: "Default with Plutus workload" + } + + ## Fastest -- start-stop , $startstop_base * { name: "startstop" } + , $startstop_base * $p2p * + { name: "startstop-p2p" + } + , $startstop_base * $plutus * + { name: "startstop-plutus" + } , $startstop_base * $with_tracer * { name: "startstop-tracer" } @@ -243,57 +334,85 @@ def all_profile_variants: { name: "startstop-oldtracing" } - , $fixed_loaded * $saturation_tps_value * - { name: "smoke" - , node: - { shutdown_on_slot_synced: 80 - } + ## CI variants: test duration, 3 blocks + , $citest_base * + { name: "ci-test" + } + , $citest_base * $p2p * + { name: "ci-test-p2p" + } + , $citest_base * $plutus * + { name: "ci-test-plutus" + } + , $citest_base * $with_tracer * + { name: "ci-test-tracer" } - , $fixed_loaded * $tenner * - { name: "10" + ## CI variants: bench duration, 15 blocks + , $cibench_base * + { name: "ci-bench" } - , $fixed_loaded * $tenner * $with_tracer * - { name: "10-tracer" + , $cibench_base * $p2p * + { name: "ci-bench-p2p" + } + , $cibench_base * $plutus * + { name: "ci-bench-plutus" + } + , $cibench_base * $with_tracer * + { name: "ci-bench-tracer" } - , $plutus * - { name: "plutus" - , generator: - { tx_count: 800 - } + ## Large local cluster -- 10 nodes + , $cibench_base * $tenner * + { name: "10" + } + , $cibench_base * $tenner * $p2p * + { name: "10-p2p" + } + , $cibench_base * $tenner * $plutus * + { name: "10-plutus" + } + , $cibench_base * $tenner * $with_tracer * + { name: "10-tracer" } + ## Status-quo (huge) dataset, small cluster (2 nodes) , $forge_stress_base * { name: "forge-stress" } - , $forge_stress_base * $plutus * $singleton * + , $forge_stress_base * $plutus * + { name: "forge-stress-p2p" + } + , $forge_stress_base * $plutus * { name: "forge-stress-plutus" - , generator: - { tx_count: 800 - } } - , $forge_stress_base * $old_tracing * $with_tracer * - { name: "forge-stress-tracer" + , $forge_stress_base * $plutus * $singleton * + { name: "forge-stress-plutus-singleton" } - , $forge_stress_base * $old_tracing * - { name: "forge-stress-oldtracing" + , $forge_stress_base * $with_tracer * + { name: "forge-stress-tracer" } - , $chainsync_base * $chaindb_early_byron * + , $scenario_chainsync * $chaindb_early_byron * { name: "chainsync-early-byron" } - , $chainsync_base * $chaindb_early_byron * $with_tracer * + , $scenario_chainsync * $chaindb_early_byron * $with_tracer * { name: "chainsync-early-byron-tracer" } - , $chainsync_base * $chaindb_early_byron * $old_tracing * + , $scenario_chainsync * $chaindb_early_byron * $old_tracing * { name: "chainsync-early-byron-oldtracing" } - , $chainsync_base * $chaindb_early_alonzo * + , $scenario_chainsync * $chaindb_early_alonzo * { name: "chainsync-early-alonzo" } - , $chainsync_base * $chaindb_early_alonzo * $old_tracing * + , $scenario_chainsync * $chaindb_early_alonzo * $with_tracer * + { name: "chainsync-early-alonzo-tracer" + } + , $scenario_chainsync * $chaindb_early_alonzo * $old_tracing * { name: "chainsync-early-alonzo-oldtracing" } + , $scenario_chainsync * $chaindb_early_alonzo * $p2p * + { name: "chainsync-early-alonzo-p2p" + } ]; diff --git a/nix/workbench/run.sh b/nix/workbench/run.sh index d5df75386ec..d662bcd59b5 100644 --- a/nix/workbench/run.sh +++ b/nix/workbench/run.sh @@ -17,7 +17,7 @@ usage_run() { --scenario forces a scenario, different from what is implied by the run profile; See 'wb scenario --help' for scenario descriptions - --idle is a short-cut for the 'generic-idle' scenario + --idle is a short-cut for '--scenario idle' --analyse triggers analysis after 'start' returns stop TAG Stop the named run diff --git a/nix/workbench/scenario.sh b/nix/workbench/scenario.sh index 9284b8e80ba..0055805d858 100644 --- a/nix/workbench/scenario.sh +++ b/nix/workbench/scenario.sh @@ -1,9 +1,11 @@ usage_scenario() { usage "scenario" "Run scenario control" <&2 - msg "scenario: $(with_color yellow end of time reached) for: $(with_color red $(jq '.meta.tag' -r $__scenario_exit_trap_dir/meta.json))" + msg "scenario: $(yellow end of time reached) for: $(red $(jq '.meta.tag' -r $__scenario_exit_trap_dir/meta.json))" rm -f $dir/flag/cluster-termination - msg "scenario: $(with_color red signalled termination)" + msg "scenario: $(red signalled termination)" + progress "scenario" "now: $(yellow $(date))" } scenario_setup_termination() { @@ -134,8 +131,16 @@ scenario_setup_termination() { export __scenario_watcher_self=$BASHPID local termination_tolerance_s=40 - export __scenario_watcher_end_time=$(jq ' - .meta.timing.earliest_end + '$termination_tolerance_s $run_dir/meta.json) + local now=$(date +%s) + local till_shutdown=$(($(jq '.meta.timing.shutdown_end' $run_dir/meta.json) - now)) + local till_workload=$(($(jq '.meta.timing.workload_end' $run_dir/meta.json) - now)) + local till_earliest=$(($(jq '.meta.timing.earliest_end' $run_dir/meta.json) - now)) + export __scenario_watcher_end_time=$((now + till_earliest + termination_tolerance_s)) + progress "scenario" "now: $(yellow $(date --date=@$now))" + progress "scenario" "until end: workload $(yellow $till_workload), $(blue shutdown) $(yellow $till_shutdown), $(blue earliest) $(yellow $till_earliest)" + progress "scenario" "shutdown tolerance: $(yellow $termination_tolerance_s) s" + # progress "scenario" "until end: workload $(yellow $(date --date=@$__scenario_watcher_end_time))" + progress "scenario" "termination in $(white $((till_earliest + termination_tolerance_s))) seconds.." scenario_watcher & __scenario_watcher_pid=$! } diff --git a/nix/workbench/supervisor-run.nix b/nix/workbench/supervisor-run.nix index 36c5b6f2b4d..b75bb9dc9e5 100644 --- a/nix/workbench/supervisor-run.nix +++ b/nix/workbench/supervisor-run.nix @@ -1,6 +1,6 @@ let batchNameDefault = "plain"; - profileNameDefault = "default-alzo"; + profileNameDefault = "default-bage"; in { pkgs diff --git a/nix/workbench/supervisor.sh b/nix/workbench/supervisor.sh index fe6d57d42bc..b0e1c6337fb 100755 --- a/nix/workbench/supervisor.sh +++ b/nix/workbench/supervisor.sh @@ -175,18 +175,21 @@ EOF local usage="USAGE: wb supervisor $op RUN-DIR" local dir=${1:?$usage}; shift - local i=0 pools=$(jq .composition.n_pool_hosts $dir/profile.json) + local i=0 pools=$(jq .composition.n_pool_hosts $dir/profile.json) start_time=$(date +%s) msg_ne "supervisor: waiting until all pool nodes are stopped: 000000" touch $dir/flag/cluster-termination + for ((pool_ix=0; pool_ix < $pools; pool_ix++)) do while supervisorctl status node-${pool_ix} > /dev/null && test -f $dir/flag/cluster-termination - do echo -ne "\b\b\b\b\b\b"; printf "%6d" $i; i=$((i+1)); sleep 1; done + do echo -ne "\b\b\b\b\b\b"; printf "%6d" $((i + 1)); i=$((i+1)); sleep 1; done echo -ne "\b\b\b\b\b\b"; echo -n "node-${pool_ix} 000000" done >&2 + echo -ne "\b\b\b\b\b\b" + local elapsed=$(($(date +%s) - start_time)) if test -f $dir/flag/cluster-termination - then echo " done." >&2 - else echo " termination requested." >&2; fi + then echo " All nodes exited -- after $(yellow $elapsed)s" >&2 + else echo " Termination requested -- after $(yellow $elapsed)s" >&2; fi ;; stop-cluster ) diff --git a/shell.nix b/shell.nix index bb62c1d30e0..df783c700e8 100644 --- a/shell.nix +++ b/shell.nix @@ -123,7 +123,7 @@ let devops = let cluster = pkgs.supervisord-workbench-for-profile - { profileName = "devops-alzo"; + { profileName = "devops-bage"; useCabalRun = false; }; in cardanoNodeProject.shellFor {