Skip to content
Merged
Show file tree
Hide file tree
Changes from 18 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
5 changes: 2 additions & 3 deletions hydra-cluster/bench/Bench/EndToEnd.hs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ bench startingNodeId timeoutSeconds workDir dataset = do
let cardanoKeys = hydraNodeKeys dataset <&> \sk -> (getVerificationKey sk, sk)
let hydraKeys = generateSigningKey . show <$> [1 .. toInteger (length cardanoKeys)]
statsTvar <- newLabelledTVarIO "bench-stats" mempty
scenarioData <- withCardanoNodeDevnet (contramap FromCardanoNode tracer) workDir $ \_ backend -> do
scenarioData <- withCardanoNodeDevnet (contramap FromCardanoNode tracer) workDir $ \blockTime backend -> do
let nodeSocket' = case Backend.getOptions backend of
Direct DirectOptions{nodeSocket} -> nodeSocket
_ -> error "Unexpected Blockfrost backend"
Expand All @@ -83,8 +83,7 @@ bench startingNodeId timeoutSeconds workDir dataset = do
hydraScriptsTxId <- publishHydraScriptsAs backend Faucet
putStrLn $ "Starting hydra cluster in " <> workDir
let hydraTracer = contramap FromHydraNode tracer

withHydraCluster hydraTracer workDir nodeSocket' startingNodeId cardanoKeys hydraKeys hydraScriptsTxId 10 $ \clients -> do
withHydraCluster hydraTracer blockTime workDir nodeSocket' startingNodeId cardanoKeys hydraKeys hydraScriptsTxId 10 $ \clients -> do
waitForNodesConnected hydraTracer 20 clients
scenario hydraTracer backend workDir dataset clients
systemStats <- readTVarIO statsTvar
Expand Down
130 changes: 66 additions & 64 deletions hydra-cluster/src/Hydra/Cluster/Scenarios.hs

Large diffs are not rendered by default.

22 changes: 13 additions & 9 deletions hydra-cluster/src/HydraNode.hs
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ getMetrics HydraClient{hydraNodeId, apiHost = Host{hostname}} = do
withHydraCluster ::
HasCallStack =>
Tracer IO HydraNodeLog ->
NominalDiffTime ->
FilePath ->
SocketPath ->
-- | First node id
Expand All @@ -294,7 +295,7 @@ withHydraCluster ::
ContestationPeriod ->
(NonEmpty HydraClient -> IO a) ->
IO a
withHydraCluster tracer workDir nodeSocket firstNodeId allKeys hydraKeys hydraScriptsTxId contestationPeriod action = do
withHydraCluster tracer blockTime workDir nodeSocket firstNodeId allKeys hydraKeys hydraScriptsTxId contestationPeriod action = do
when (clusterSize == 0) $
failure "Cannot run a cluster with 0 number of nodes"
when (length allKeys /= length hydraKeys) $
Expand Down Expand Up @@ -332,6 +333,7 @@ withHydraCluster tracer workDir nodeSocket firstNodeId allKeys hydraKeys hydraSc
}
withHydraNode
tracer
blockTime
chainConfig
workDir
nodeId
Expand Down Expand Up @@ -438,18 +440,19 @@ prepareHydraNode chainConfig workDir hydraNodeId hydraSKey hydraVKeys allNodeIds
withPreparedHydraNodeInSync ::
HasCallStack =>
Tracer IO HydraNodeLog ->
NominalDiffTime ->
FilePath ->
Int ->
RunOptions ->
(HydraClient -> IO a) ->
IO a
withPreparedHydraNodeInSync tracer workDir hydraNodeId runOptions action =
withPreparedHydraNode tracer workDir hydraNodeId runOptions action'
withPreparedHydraNodeInSync tracer blockTime workDir hydraNodeId runOptions action = do
let waitTime = blockTime * waitFactor
withPreparedHydraNode tracer workDir hydraNodeId runOptions (action' waitTime)
where
action' client = do
getHydraBackend >>= \case
DirectBackendType -> waitForNodesSynced 5 $ client :| []
BlockfrostBackendType -> waitForNodesSynced 10 $ client :| []
waitFactor = 5
action' waitTime client = do
waitForNodesSynced waitTime $ client :| []
action client

-- | Run a hydra-node with given 'RunOptions'.
Expand Down Expand Up @@ -496,6 +499,7 @@ withPreparedHydraNode tracer workDir hydraNodeId runOptions action =
withHydraNode ::
HasCallStack =>
Tracer IO HydraNodeLog ->
NominalDiffTime ->
ChainConfig ->
FilePath ->
Int ->
Expand All @@ -504,9 +508,9 @@ withHydraNode ::
[Int] ->
(HydraClient -> IO a) ->
IO a
withHydraNode tracer chainConfig workDir hydraNodeId hydraSKey hydraVKeys allNodeIds action = do
withHydraNode tracer blockTime chainConfig workDir hydraNodeId hydraSKey hydraVKeys allNodeIds action = do
opts <- prepareHydraNode chainConfig workDir hydraNodeId hydraSKey hydraVKeys allNodeIds id
withPreparedHydraNodeInSync tracer workDir hydraNodeId opts action
withPreparedHydraNodeInSync tracer blockTime workDir hydraNodeId opts action

-- | Run a hydra-node with given 'ChainConfig' and using the config from
-- config and catching up with chain backend/.
Expand Down
4 changes: 2 additions & 2 deletions hydra-cluster/test/Test/ChainObserverSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ spec = do
showLogsOnFailure "ChainObserverSpec" $ \tracer -> do
withTempDir "hydra-cluster" $ \tmpDir -> do
-- Start a cardano devnet
withCardanoNodeDevnet (contramap FromCardanoNode tracer) tmpDir $ \_ backend -> do
withCardanoNodeDevnet (contramap FromCardanoNode tracer) tmpDir $ \blockTime backend -> do
-- Prepare a hydra-node
let hydraTracer = contramap FromHydraNode tracer
hydraScriptsTxId <- publishHydraScriptsAs backend Faucet
(aliceCardanoVk, _) <- keysFor Alice
aliceChainConfig <- chainConfigFor Alice tmpDir backend hydraScriptsTxId [] cperiod
withHydraNode hydraTracer aliceChainConfig tmpDir 1 aliceSk [] [1] $ \hydraNode -> do
withHydraNode hydraTracer blockTime aliceChainConfig tmpDir 1 aliceSk [] [1] $ \hydraNode -> do
withChainObserver backend $ \observer -> do
seedFromFaucet_ backend aliceCardanoVk 100_000_000 (contramap FromFaucet tracer)

Expand Down
Loading
Loading