Skip to content

Commit 10051de

Browse files
authored
Merge pull request #6477 from IntersectMBO/revert-6447-testnet-run-tx-gen
Revert #6447: [cardano-testnet] Add flag to run tx-generator from cardano-testnet
2 parents f83af0d + bd3bc43 commit 10051de

11 files changed

Lines changed: 31 additions & 99 deletions

File tree

cardano-testnet/cardano-testnet.cabal

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,6 @@ library
134134
Testnet.Start.Types
135135
Testnet.SubmitApi
136136
Testnet.TestQueryCmds
137-
Testnet.TxGenRuntime
138137
Testnet.Types
139138

140139
other-modules: Parsers.Cardano

cardano-testnet/changelog.d/20260220_005344_palas_testnet_run_tx_gen.md

Lines changed: 0 additions & 4 deletions
This file was deleted.

cardano-testnet/src/Parsers/Cardano.hs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -71,15 +71,10 @@ pCardanoTestnetCliOptions = CardanoTestnetOptions
7171
<> OA.help "Enable new epoch state logging to logs/ledger-epoch-state.log"
7272
<> OA.showDefault
7373
)
74-
<*> ( OA.flag' GenerateTemplateConfigForTxGenerator
75-
( OA.long "generate-tx-generator-config"
76-
<> OA.help "Generate a template configuration file for tx-generator."
77-
)
78-
<|> OA.flag' GenerateAndRunTxGenerator
79-
( OA.long "run-tx-generator"
80-
<> OA.help "Generate a configuration file for tx-generator and run it."
81-
)
82-
<|> pure NoTxGeneratorSupport
74+
<*> OA.flag NoTxGeneratorSupport GenerateTemplateConfigForTxGenerator
75+
( OA.long "generate-tx-generator-config"
76+
<> OA.help "Generate a template configuration file for tx-generator."
77+
<> OA.showDefault
8378
)
8479
<*> (maybe NoUserProvidedEnv UserProvidedEnv <$> optional (OA.strOption
8580
( OA.long "output-dir"
Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{-# LANGUAGE CPP #-}
2+
{-# LANGUAGE NamedFieldPuns #-}
23

34
#if !defined(mingw32_HOST_OS)
45
#define UNIX
@@ -11,18 +12,19 @@ module Testnet.Handlers
1112
#ifdef UNIX
1213
import Control.Monad
1314
import System.Posix.Signals (Handler (..), installHandler, raiseSignal, sigINT)
14-
import System.Process (interruptProcessGroupOf, ProcessHandle)
15+
import System.Process (interruptProcessGroupOf)
1516
#endif
1617

18+
import Testnet.Types
19+
20+
interruptNodesOnSigINT :: [TestnetNode] -> IO ()
1721
#ifdef UNIX
18-
interruptNodesOnSigINT :: [ProcessHandle] -> IO ()
19-
interruptNodesOnSigINT processHandlers =
22+
interruptNodesOnSigINT testnetNodes =
2023
-- Interrupt cardano nodes when the main process is interrupted
2124
void $ flip (installHandler sigINT) Nothing $ CatchOnce $ do
22-
forM_ processHandlers $ \nodeProcessHandle ->
25+
forM_ testnetNodes $ \TestnetNode{nodeProcessHandle} ->
2326
interruptProcessGroupOf nodeProcessHandle
2427
raiseSignal sigINT
2528
#else
26-
interruptNodesOnSigINT :: processHandle -> IO ()
2729
interruptNodesOnSigINT _testnetNodes = pure ()
2830
#endif

cardano-testnet/src/Testnet/Process/RunIO.hs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ module Testnet.Process.RunIO
1010
, execCli_
1111
, mkExecConfig
1212
, procNode
13-
, procFlex
1413
, liftIOAnnotated
1514
) where
1615

@@ -39,6 +38,8 @@ import Hedgehog.Extras.Test.Process (ExecConfig (..))
3938

4039
import RIO
4140

41+
42+
4243
defaultExecConfig :: ExecConfig
4344
defaultExecConfig = ExecConfig
4445
{ execConfigEnv = mempty

cardano-testnet/src/Testnet/Start/Cardano.hs

Lines changed: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ import Testnet.Process.RunIO (execCli', execCli_, liftIOAnnotated, mkE
7575
import Testnet.Property.Assert (assertExpectedSposInLedgerState)
7676
import Testnet.Runtime as TR
7777
import Testnet.Start.Types
78-
import Testnet.TxGenRuntime (startTxGenRuntime)
7978
import Testnet.Types as TR hiding (shelleyGenesis)
8079

8180
import qualified Hedgehog.Extras as H
@@ -355,11 +354,20 @@ cardanoTestnet
355354
throwString $ "Some nodes failed to start:\n" ++ show (vsep $ prettyError <$> failedNodes)
356355

357356
-- Interrupt cardano nodes when the main process is interrupted
358-
liftIOAnnotated $ interruptNodesOnSigINT (map nodeProcessHandle testnetNodes')
357+
liftIOAnnotated $ interruptNodesOnSigINT testnetNodes'
359358

360359
-- Make sure that all nodes are healthy by waiting for a chain extension
361360
mapConcurrently_ (waitForBlockThrow 45 (File nodeConfigFile)) testnetNodes'
362361

362+
let node1SocketPath = tmpAbsPath </> "socket" </> "node1" </> "sock"
363+
utxoSigningKeyFile = File $ (tmpAbsPath </>) $ unFile $ signingKey $ Defaults.defaultUtxoKeys 1
364+
nodeDescriptions = NEL.map (\(i, port) -> NodeDescription (NodeAddress (NodeHostIPv4Address (fromHostAddress testnetDefaultIpv4Address)) port) (Defaults.defaultNodeName i) ) portNumbers
365+
366+
case cardanoEnableTxGenerator testnetOptions of
367+
NoTxGeneratorSupport -> pure ()
368+
GenerateTemplateConfigForTxGenerator ->
369+
generateTxGenConfig tmpAbsPath nodeConfigFile utxoSigningKeyFile node1SocketPath nodeDescriptions
370+
363371
let runtime = TestnetRuntime
364372
{ configurationFile = File nodeConfigFile
365373
, shelleyGenesisFile = tmpAbsPath </> Defaults.defaultGenesisFilepath ShelleyEra
@@ -391,24 +399,7 @@ cardanoTestnet
391399
when enableNewEpochStateLogging $
392400
TR.startLedgerNewEpochStateLogging runtime tempBaseAbsPath
393401

394-
let node1SocketPath = tmpAbsPath </> "socket" </> "node1" </> "sock"
395-
utxoSigningKeyFile = File $ (tmpAbsPath </>) $ unFile $ signingKey $ Defaults.defaultUtxoKeys 1
396-
nodeDescriptions = NEL.map (\(i, port) -> NodeDescription (NodeAddress (NodeHostIPv4Address (fromHostAddress testnetDefaultIpv4Address)) port) (Defaults.defaultNodeName i) ) portNumbers
397-
398-
case cardanoEnableTxGenerator testnetOptions of
399-
NoTxGeneratorSupport -> pure ()
400-
GenerateTemplateConfigForTxGenerator ->
401-
void $ generateTxGenConfig tmpAbsPath nodeConfigFile utxoSigningKeyFile node1SocketPath nodeDescriptions
402-
GenerateAndRunTxGenerator -> do
403-
configFile <- generateTxGenConfig tmpAbsPath nodeConfigFile utxoSigningKeyFile node1SocketPath nodeDescriptions
404-
hProcess <- runRIO () $ startTxGenRuntime (TmpAbsolutePath tmpAbsPath)
405-
[ "json_highlevel"
406-
, configFile
407-
]
408-
liftIOAnnotated $ interruptNodesOnSigINT (hProcess : map nodeProcessHandle testnetNodes')
409-
410402
pure runtime
411-
412403
where
413404
extraCliArgs = \case
414405
SpoNodeOptions args -> args
@@ -419,10 +410,9 @@ cardanoTestnet
419410
mkTestnetNodeKeyPaths :: Int -> SpoNodeKeys
420411
mkTestnetNodeKeyPaths n = makePathsAbsolute $ Defaults.defaultSpoKeys n
421412

422-
generateTxGenConfig :: MonadUnliftIO m => FilePath -> FilePath -> SigningKeyFile 'In -> String -> NonEmpty NodeDescription -> m FilePath
413+
generateTxGenConfig :: MonadUnliftIO m => FilePath -> FilePath -> SigningKeyFile 'In -> String -> NonEmpty NodeDescription -> m ()
423414
generateTxGenConfig basePath nodeConfigFilePath utxoSigningKeyFile localNodeSocketPath nodeTopology = do
424-
let file = basePath </> "tx-generator-config.json"
425-
nixServiceOptions = NixServiceOptions {
415+
let nixServiceOptions = NixServiceOptions {
426416
_nix_debugMode = False
427417
, _nix_tx_count = 100
428418
, _nix_tps = 10
@@ -441,8 +431,8 @@ cardanoTestnet
441431
, _nix_localNodeSocketPath = localNodeSocketPath
442432
, _nix_targetNodes = nodeTopology
443433
}
444-
liftIOAnnotated . LBS.writeFile file $ A.encodePretty nixServiceOptions
445-
pure file
434+
liftIOAnnotated . LBS.writeFile (basePath </> "tx-generator-config.json") $ A.encodePretty nixServiceOptions
435+
pure ()
446436

447437
-- wait for new blocks or throw an exception if there are none in the timeout period
448438
waitForBlockThrow :: MonadUnliftIO m

cardano-testnet/src/Testnet/Start/Types.hs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,6 @@ data CardanoTestnetCreateEnvOptions = CardanoTestnetCreateEnvOptions
170170
data TxGeneratorSupport
171171
= NoTxGeneratorSupport
172172
| GenerateTemplateConfigForTxGenerator
173-
| GenerateAndRunTxGenerator
174173
deriving (Eq, Show)
175174

176175
-- | Options which, contrary to 'GenesisOptions' are not implemented

cardano-testnet/src/Testnet/TxGenRuntime.hs

Lines changed: 0 additions & 46 deletions
This file was deleted.

cardano-testnet/test/cardano-testnet-golden/files/golden/help.cli

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Usage: cardano-testnet cardano [--num-pool-nodes COUNT]
55
[--nodeLoggingFormat LOGGING_FORMAT]
66
[--num-dreps NUMBER]
77
[--enable-new-epoch-state-logging]
8-
[--generate-tx-generator-config | --run-tx-generator]
8+
[--generate-tx-generator-config]
99
[--output-dir DIRECTORY]
1010
[--testnet-magic INT]
1111
[--epoch-length SLOTS]
@@ -21,7 +21,7 @@ Usage: cardano-testnet create-env [--num-pool-nodes COUNT]
2121
[--nodeLoggingFormat LOGGING_FORMAT]
2222
[--num-dreps NUMBER]
2323
[--enable-new-epoch-state-logging]
24-
[--generate-tx-generator-config | --run-tx-generator]
24+
[--generate-tx-generator-config]
2525
[--output-dir DIRECTORY]
2626
[--testnet-magic INT]
2727
[--epoch-length SLOTS]

cardano-testnet/test/cardano-testnet-golden/files/golden/help/cardano.cli

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Usage: cardano-testnet cardano [--num-pool-nodes COUNT]
33
[--nodeLoggingFormat LOGGING_FORMAT]
44
[--num-dreps NUMBER]
55
[--enable-new-epoch-state-logging]
6-
[--generate-tx-generator-config | --run-tx-generator]
6+
[--generate-tx-generator-config]
77
[--output-dir DIRECTORY]
88
[--testnet-magic INT]
99
[--epoch-length SLOTS]
@@ -33,8 +33,6 @@ Available options:
3333
--generate-tx-generator-config
3434
Generate a template configuration file for
3535
tx-generator.
36-
--run-tx-generator Generate a configuration file for tx-generator and
37-
run it.
3836
--output-dir DIRECTORY Directory where to store files, sockets, and so on.
3937
It is created if it doesn't exist. If unset, a
4038
temporary directory is used.

0 commit comments

Comments
 (0)