hydra-cluster
Safe HaskellSafe-Inferred
LanguageGHC2021

Hydra.Cluster.Util

Description

Utilities used across hydra-cluster

Synopsis

Documentation

readConfigFile :: FilePath -> IO ByteString Source #

Lookup a config file similar reading a file from disk. If the env variable HYDRA_CONFIG_DIR is set, filenames will be resolved relative to its value otherwise they will be looked up in the package's data path.

keysFor :: Actor -> IO (VerificationKey PaymentKey, Secret (SigningKey PaymentKey)) Source #

Get the "well-known" keys for given actor. The signing key is Secret-wrapped so callers cannot accidentally log or serialise it.

createAndSaveSigningKey :: FilePath -> IO (Secret (SigningKey PaymentKey)) Source #

Create and save new signing key at the provided path, returning the key Secret-wrapped. NOTE: Uses TextEnvelope format.

type BlockTime = NominalDiffTime Source #

Expected time between blocks (on average)

data Timing Source #

Timing parameters that determine the behavior of a (cluster of) hydra-node.

Constructors

Timing 

Fields

  • blockTime :: BlockTime
     
  • contestationPeriod :: ContestationPeriod
     
  • depositPeriod :: DepositPeriod
     
  • depositActivation :: DepositPeriod

    Time a deposit must mature before it becomes active. Configured independently from Timing; the smart constructors default it to the same value so deposits activate as fast as they expire, but tests can set it separately to exercise decoupled activation.

Instances

Instances details
Show Timing Source # 
Instance details

Defined in Hydra.Cluster.Util

truncatedDepositPeriod :: NominalDiffTime -> DepositPeriod Source #

Truncate a duration to a whole-second DepositPeriod.

mkTestTiming :: BlockTime -> Timing Source #

Set up reasonable timing parameters for testing given a BlockTime.

mkTestTiming' :: Int -> BlockTime -> Timing Source #

Like mkTestTiming but scales Timing by the number of concurrent deposits expected. Each increment tx must be processed sequentially on-chain, so N concurrent deposits require N times the base deposit period.

depositTimeout :: Timing -> NominalDiffTime Source #

Get a timeout until a deposit should have happened given a Timing. A deposit becomes active after Timing and then needs about one Timing to be picked up and incremented, so both are accounted for (with the defaults where they are equal this is 2 * depositPeriod).

The slack term covers the two on-chain round trips (deposit and increment: submit, include, observe) plus multi-node processing. Those costs are dominated by fixed latencies, not by block time, so the slack has a constant floor; with the devnet's 0.1s blocks a pure 5 * blockTime came to 0.5s and timed out regularly on loaded CI runners.

onChainObservationBudget :: NominalDiffTime -> NominalDiffTime Source #

Budget for observing the effect of one L1 transaction on the API: submission, block inclusion, chain-follower observation and node processing. The constant floor covers the fixed latencies, which dominate at devnet block times; a pure blockTime multiple (e.g. a literal 3s) fired regularly on loaded CI runners.

nodeStartupBudget :: NominalDiffTime Source #

Budget for a hydra-node (re)start up to its Greetings. Process spawn, etcd bootstrap and websocket connect are fixed costs, unrelated to block time, so this is a constant.

chainConfigFor Source #

Arguments

:: HasCallStack 
=> Actor 
-> FilePath 
-> ChainBackendOptions 
-> [TxId]

Transaction ids at which Hydra scripts should have been published.

-> [Actor] 
-> Timing 
-> IO ChainConfig 

Create a (test) chain config for a given actor.

chainConfigFor' Source #

Arguments

:: HasCallStack 
=> Actor 
-> FilePath 
-> ChainBackendOptions 
-> [TxId]

Transaction ids at which Hydra scripts should have been published.

-> [Actor] 
-> ContestationPeriod 
-> DepositPeriod 
-> DepositPeriod

Deposit activation, independent from the deposit period.

-> IO ChainConfig 

modifyConfig :: (CardanoChainConfig -> CardanoChainConfig) -> ChainConfig -> ChainConfig Source #

setNetworkId :: NetworkId -> ChainConfig -> ChainConfig Source #