Skip to content

Commit 7a0af4d

Browse files
authored
Derive hydra scripts tx-ids (#2019)
- Since we pre-publish hydra scrips upon each release provide the `--network` option in order to complement `--hydra-scripts-tx-id` option and have a nice shortcut. - We always use the latest published version (user issue seem to imply that by proposing _default_ argument). - This new argument is Invoked as `--network preview` for example. --- <!-- Consider each and tick it off one way or the other --> * [x] CHANGELOG updated or not needed * [x] Documentation updated or not needed * [x] Haddocks updated or not needed * [x] No new TODOs introduced or explained herafter
2 parents da4ee11 + a374873 commit 7a0af4d

File tree

15 files changed

+138
-35
lines changed

15 files changed

+138
-35
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ changes.
4848

4949
- Add API query (GET /head) to fetch the latest head state by a node and help introspecting the whole internal state.
5050

51+
- Provide `--network` option to hydra-node in order to use pre-published hydra scripts.
52+
5153
## [0.21.0] - 2025-04-28
5254

5355
- New metric for counting the number of active peers: `hydra_head_peers_connected`

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ To perform a release of the next `<version>`:
156156
1. Make sure all tests are passing.
157157
2. Publish Hydra scripts onto `preview`, `preprod`, and `mainnet` using the
158158
[smoke test][smoke-test] and put the transaction IDs as new `<version>`
159-
entries into [networks.json](./networks.json).
159+
entries into [networks.json](./hydra-node/networks.json).
160160
3. Update CHANGELOG.md by replacing `UNRELEASED` with a date in
161161
[ISO8601](https://en.wikipedia.org/wiki/ISO_8601) and prepare contents.
162162
4. Run `./release.sh <version>`.

docs/docs/configuration.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ Being a protocol parameter, all participants in a head must configure the same `
5252

5353
:::
5454

55-
The default contestation period is _600 seconds_, but it should be tailored to the network conditions, as different networks have varying block production rates. A good rule of thumb is the maximum time you would expect an attacker to launch a withholding attack onto the cardano network you are on. Also, consider the time it takes to propagate a transaction to the network and the time it takes for a block to be produced, and the contestation period should be long enough to accommodate any downtime of the `hydra-node`.
55+
The default contestation period is _600 seconds_, but it should be tailored to the network conditions, as different networks have varying block production rates. A good rule of thumb is the maximum time you would expect an attacker to launch a withholding attack onto the cardano network you are on. Also, consider the time it takes to propagate a transaction to the network and the time it takes for a block to be produced, and the contestation period should be long enough to accommodate any downtime of the `hydra-node`.
5656

5757
The contestation deadline decides when a closed head can be fanned out. At worst, this is `(1 + n) * CP` after submitting a `Close` transaction, where `n` is the number of participants in the head. This is because the deadline is pushed forward on each `Contest`. With no contestations which may still be `2 * CP` after `Close` depending on the upper validity set on che close transaction. The `hydra-node` currently picks a blanket 200 seconds as [max grace time](https://hydra.family/head-protocol/haddock/hydra-node/Hydra-Chain-Direct-Handlers.html#v:maxGraceTime).
5858

@@ -83,13 +83,21 @@ See the [how-to](./how-to/incremental-commit) and [protocol documentation](./dev
8383

8484
The `hydra-node` uses reference scripts to reduce transaction sizes driving the head's lifecycle. Specify the `--hydra-scripts-tx-id` to reference the correct scripts. The `hydra-node` will verify the availability of these scripts on-chain.
8585

86+
:::important Alternative: use --network
87+
Since we pre-publish hydra scrips before each release, instead of specifying hydra-scripts using `--hydra-scripts-tx-id`, you can use `--network` together with the network name you would like to run your hydra-node on (e.g. `--network preview`).
88+
:::
89+
90+
:::warning
91+
`--network` argument only works with officially released hydra-node versions!
92+
:::
93+
8694
Check the scripts against which a hydra-node was compiled using:
8795

8896
```shell
8997
hydra-node --script-info
9098
```
9199

92-
For public [(test) networks](https://book.world.dev.cardano.org/environments.html), we publish Hydra scripts with each new release, listing transaction IDs in the [release notes](https://github.com/cardano-scaling/hydra/releases) and [`networks.json`](https://github.com/cardano-scaling/hydra/blob/master/networks.json).
100+
For public [(test) networks](https://book.world.dev.cardano.org/environments.html), we publish Hydra scripts with each new release, listing transaction IDs in the [release notes](https://github.com/cardano-scaling/hydra/releases) and [`networks.json`](https://github.com/cardano-scaling/hydra/blob/master/hydra-node/networks.json).
93101

94102
To publish scripts yourself, use the `publish-scripts` command:
95103

docs/docs/tutorial/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ hydra-node \
421421
--persistence-dir persistence-alice \
422422
--cardano-signing-key credentials/alice-node.sk \
423423
--hydra-signing-key credentials/alice-hydra.sk \
424-
--hydra-scripts-tx-id $(curl https://raw.githubusercontent.com/cardano-scaling/hydra/master/networks.json | jq -r ".preprod.\"${hydra_version}\"") \
424+
--hydra-scripts-tx-id $(curl https://raw.githubusercontent.com/cardano-scaling/hydra/master/hydra-node/networks.json | jq -r ".preprod.\"${hydra_version}\"") \
425425
--ledger-protocol-parameters protocol-parameters.json \
426426
--testnet-magic 1 \
427427
--node-socket node.socket \
@@ -443,7 +443,7 @@ hydra-node \
443443
--persistence-dir persistence-bob \
444444
--cardano-signing-key credentials/bob-node.sk \
445445
--hydra-signing-key credentials/bob-hydra.sk \
446-
--hydra-scripts-tx-id $(curl https://raw.githubusercontent.com/cardano-scaling/hydra/master/networks.json | jq -r ".preprod.\"${hydra_version}\"") \
446+
--hydra-scripts-tx-id $(curl https://raw.githubusercontent.com/cardano-scaling/hydra/master/hydra-node/networks.json | jq -r ".preprod.\"${hydra_version}\"") \
447447
--ledger-protocol-parameters protocol-parameters.json \
448448
--testnet-magic 1 \
449449
--node-socket node.socket \

hydra-chain-observer/src/Hydra/ChainObserver.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import Hydra.ChainObserver.NodeClient (ChainObservation, ChainObserverLog (..),
1111
import Hydra.ChainObserver.Options (Backend (..), Options (..), hydraChainObserverOptions)
1212
import Hydra.Contract qualified as Contract
1313
import Hydra.Logging (Verbosity (..), traceWith, withTracer)
14-
import Hydra.Options (hydraNodeVersion)
14+
import Hydra.NetworkVersions (hydraNodeVersion)
1515
import Hydra.Ouroborus.ChainObserver (ouroborusClient)
1616
import Network.HTTP.Simple (getResponseBody, httpNoBody, parseRequestThrow, setRequestBodyJSON)
1717
import Network.URI (URI)

hydra-chain-observer/src/Hydra/ChainObserver/Options.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import Hydra.Prelude
66

77
import Data.Version (showVersion)
88
import Hydra.Cardano.Api (ChainPoint, NetworkId, SocketPath)
9+
import Hydra.NetworkVersions (hydraNodeVersion)
910
import Hydra.Options (
10-
hydraNodeVersion,
1111
networkIdParser,
1212
nodeSocketParser,
1313
startChainFromParser,

hydra-cluster/src/Hydra/Cluster/Faucet.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,8 @@ seedFromFaucetBlockfrost receivingVerificationKey lovelace = do
134134
case eResult of
135135
Left err -> liftIO $ throwIO $ FaucetBlockfrostError{blockFrostError = show err}
136136
Right _ -> do
137-
void $ Blockfrost.awaitUTxO networkId [changeAddress] (txId signedTx) 100
138-
Blockfrost.awaitUTxO networkId [receivingAddress] (txId signedTx) 100
137+
void $ Blockfrost.awaitUTxO networkId [changeAddress] (txId signedTx) 200
138+
Blockfrost.awaitUTxO networkId [receivingAddress] (txId signedTx) 200
139139
where
140140
findUTxO networkId address lovelace' = do
141141
faucetUTxO <- Blockfrost.queryUTxO networkId [address]

hydra-node/hydra-node.cabal

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
cabal-version: 3.0
2-
name: hydra-node
3-
version: 0.22.0
4-
synopsis: The Hydra node
5-
author: IOG
6-
copyright: 2022 IOG
7-
license: Apache-2.0
1+
cabal-version: 3.0
2+
name: hydra-node
3+
version: 0.22.0
4+
synopsis: The Hydra node
5+
author: IOG
6+
copyright: 2022 IOG
7+
license: Apache-2.0
88
license-files:
99
LICENSE
1010
NOTICE
@@ -13,6 +13,8 @@ data-files:
1313
json-schemas/api.yaml
1414
json-schemas/common.yaml
1515

16+
extra-source-files: networks.json
17+
1618
source-repository head
1719
type: git
1820
location: https://github.com/cardano-scaling/hydra
@@ -86,6 +88,7 @@ library
8688
Hydra.Network.Authenticate
8789
Hydra.Network.Etcd
8890
Hydra.Network.Message
91+
Hydra.NetworkVersions
8992
Hydra.Node
9093
Hydra.Node.DepositPeriod
9194
Hydra.Node.EmbedTH
@@ -324,6 +327,7 @@ test-suite tests
324327
Hydra.ModelSpec
325328
Hydra.Network.AuthenticateSpec
326329
Hydra.NetworkSpec
330+
Hydra.NetworkVersionsSpec
327331
Hydra.Node.InputQueueSpec
328332
Hydra.Node.RunSpec
329333
Hydra.NodeSpec
File renamed without changes.

hydra-node/src/Hydra/API/WSServer.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ import Hydra.Chain.Direct.State ()
4343
import Hydra.HeadLogic (ClosedState (ClosedState, readyToFanoutSent), HeadState, StateChanged)
4444
import Hydra.HeadLogic.State qualified as HeadState
4545
import Hydra.Logging (Tracer, traceWith)
46-
import Hydra.Options qualified as Options
46+
import Hydra.NetworkVersions qualified as NetworkVersions
4747
import Hydra.Tx (Party)
4848
import Hydra.Tx.HeadId (HeadId (..))
4949
import Network.WebSockets (
@@ -104,7 +104,7 @@ wsApp party tracer history callback headStateP headIdP responseChannel ServerOut
104104
, headStatus = getHeadStatus headState
105105
, hydraHeadId
106106
, snapshotUtxo = getSnapshotUtxo headState
107-
, hydraNodeVersion = showVersion Options.hydraNodeVersion
107+
, hydraNodeVersion = showVersion NetworkVersions.hydraNodeVersion
108108
}
109109

110110
Projection{getLatest} = headStateP

0 commit comments

Comments
 (0)