Skip to content

Commit

Permalink
Merge pull request #1420 from input-output-hk/hydra-cluster-busy
Browse files Browse the repository at this point in the history
Make hydra-cluster --devnet configurable
  • Loading branch information
locallycompact committed May 9, 2024
2 parents 95c0ff0 + 49ec0f1 commit f081958
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 5 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ changes.
`HandshakeFailure` event will be recorded in the logs and sent as a server
output on the API.

- Make `hydra-cluster --devnet` more configurable
- Now it is idle by default again and a `--busy` will make it busy respending the same UTxO.

## [0.16.0] - 2024-04-03

- Tested with `cardano-node 8.9.0`, `cardano-cli 8.20.3.0` and `mithril 2412.0`.
Expand Down
13 changes: 8 additions & 5 deletions hydra-cluster/exe/hydra-cluster/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import CardanoNode (findRunningCardanoNode, waitForFullySynchronized, withCardan
import Hydra.Cluster.Faucet (publishHydraScriptsAs)
import Hydra.Cluster.Fixture (Actor (Faucet))
import Hydra.Cluster.Mithril (downloadLatestSnapshotTo)
import Hydra.Cluster.Options (Options (..), PublishOrReuse (Publish, Reuse), UseMithril (UseMithril), parseOptions)
import Hydra.Cluster.Options (Options (..), PublishOrReuse (Publish, Reuse), Scenario (..), UseMithril (UseMithril), parseOptions)
import Hydra.Cluster.Scenarios (EndToEndLog (..), respendUTxO, singlePartyHeadFullLifeCycle, singlePartyOpenAHead)
import Hydra.Logging (Verbosity (Verbose), traceWith, withTracer)
import Options.Applicative (ParserInfo, execParser, fullDesc, header, helper, info, progDesc)
Expand Down Expand Up @@ -34,11 +34,14 @@ run options =
withCardanoNodeDevnet fromCardanoNode workDir $ \node -> do
txId <- publishOrReuseHydraScripts tracer node
singlePartyOpenAHead tracer workDir node txId $ \client walletSk -> do
-- Start respending the same UTxO with a 100ms delay.
-- XXX: Should make this configurable
respendUTxO client walletSk 0.1
case scenario of
Idle -> forever $ pure ()
RespendUTxO -> do
-- Start respending the same UTxO with a 100ms delay.
-- XXX: Should make this configurable
respendUTxO client walletSk 0.1
where
Options{knownNetwork, stateDirectory, publishHydraScripts, useMithril} = options
Options{knownNetwork, stateDirectory, publishHydraScripts, useMithril, scenario} = options

withRunningCardanoNode tracer workDir network action =
findRunningCardanoNode (contramap FromCardanoNode tracer) workDir network >>= \case
Expand Down
14 changes: 14 additions & 0 deletions hydra-cluster/src/Hydra/Cluster/Options.hs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ data Options = Options
, stateDirectory :: Maybe FilePath
, publishHydraScripts :: PublishOrReuse
, useMithril :: UseMithril
, scenario :: Scenario
}
deriving stock (Show, Eq, Generic)
deriving anyclass (ToJSON, FromJSON)
Expand All @@ -24,13 +25,18 @@ data UseMithril = NotUseMithril | UseMithril
deriving stock (Show, Eq, Generic)
deriving anyclass (ToJSON, FromJSON)

data Scenario = Idle | RespendUTxO
deriving stock (Show, Eq, Generic)
deriving anyclass (ToJSON, FromJSON)

parseOptions :: Parser Options
parseOptions =
Options
<$> parseKnownNetwork
<*> parseStateDirectory
<*> parsePublishHydraScripts
<*> parseUseMithril
<*> parseScenario
where
parseKnownNetwork =
flag' (Just Preview) (long "preview" <> help "The preview testnet")
Expand Down Expand Up @@ -86,3 +92,11 @@ parseOptions =
\If not set, the cardano-node will synchronize the network given the current \
\cardano-node state in --state-directory."
)

parseScenario =
flag
Idle
RespendUTxO
( long "busy"
<> help "Start respending the same UTxO with a 100ms delay (only for devnet)."
)

0 comments on commit f081958

Please sign in to comment.