Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make hydra-cluster --devnet configurable #1420

Merged
merged 1 commit into from
May 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)."
)