Skip to content

Commit 9ee9dd7

Browse files
committed
PR review changes
Signed-off-by: Sasha Bogicevic <[email protected]>
1 parent 2435c58 commit 9ee9dd7

File tree

9 files changed

+34
-25
lines changed

9 files changed

+34
-25
lines changed

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: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,15 +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-
Since we pre-publish hydra scrips before each release, in case you want to run the official released version 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`).
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+
:::
8793

8894
Check the scripts against which a hydra-node was compiled using:
8995

9096
```shell
9197
hydra-node --script-info
9298
```
9399

94-
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).
95101

96102
To publish scripts yourself, use the `publish-scripts` command:
97103

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-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: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ license-files:
1212
data-files:
1313
json-schemas/api.yaml
1414
json-schemas/common.yaml
15-
networks.json
15+
16+
extra-source-files: networks.json
1617

1718
source-repository head
1819
type: git
File renamed without changes.

hydra-node/src/Hydra/NetworkVersions.hs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{-# LANGUAGE DerivingStrategies #-}
2+
{-# LANGUAGE TemplateHaskell #-}
23

34
module Hydra.NetworkVersions where
45

@@ -9,16 +10,16 @@ import Data.Aeson (Value (..))
910
import Data.Aeson.Key qualified as Key
1011
import Data.Aeson.KeyMap qualified as KeyMap
1112
import Data.Aeson.Lens (members, _Object)
13+
import Data.FileEmbed (embedFile, makeRelativeToProject)
1214
import Data.List qualified as List
1315
import Data.Text (pack, splitOn, toLower, unpack)
1416
import Data.Text.Encoding (encodeUtf8)
1517
import Hydra.Cardano.Api (TxId, deserialiseFromRawBytesHex)
16-
import Paths_hydra_node qualified as Pkg
17-
import System.IO.Unsafe (unsafePerformIO)
18+
import Hydra.Version (embeddedRevision)
1819

1920
{-# NOINLINE networkVersions #-}
2021
networkVersions :: ByteString
21-
networkVersions = unsafePerformIO $ Pkg.getDataFileName "networks.json" >>= readFileBS
22+
networkVersions = $(makeRelativeToProject "./networks.json" >>= embedFile)
2223

2324
parseNetworkTxIds :: String -> Either String [TxId]
2425
parseNetworkTxIds networkString = do
@@ -30,9 +31,12 @@ parseNetworkTxIds networkString = do
3031
where
3132
getLastTxId t = do
3233
lastTxIds <-
33-
case List.last $ KeyMap.elems t of
34-
String s -> Right s
35-
_ -> Left "Failed to find the last tx-id string in networks.json"
34+
case embeddedRevision of
35+
Nothing -> Left "Missing hydra-node revision."
36+
Just rev ->
37+
case List.find (String (pack rev) ==) (KeyMap.elems t) of
38+
Just (String s) -> Right s
39+
_ -> Left "Failed to find released hydra-node version in networks.json."
3640
mapM parseToTxId (splitOn "," lastTxIds)
3741

3842
parseToTxId textTxId = do

hydra-node/test/Hydra/OptionsSpec.hs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ import Hydra.Options (
4444
)
4545
import Test.Aeson.GenericSpecs (roundtripAndGoldenSpecs)
4646
import Test.QuickCheck (Property, chooseEnum, counterexample, forAll, property, vectorOf, (===))
47-
import Test.QuickCheck.Monadic (monadicIO)
4847
import Text.Regex.TDFA ((=~))
4948

5049
spec :: Spec
@@ -326,18 +325,17 @@ spec = parallel $
326325
{ chainConfig = Cardano (defaultCardanoChainConfig & #chainBackendOptions .~ Blockfrost (BlockfrostOptions "blockfrost-project.txt"))
327326
}
328327

329-
it "parses --network into related tx ids" $ monadicIO $ do
328+
it "parses --network into related tx ids" $ do
330329
let networks = ["Mainnet", "preview", "Preprod"]
331330
forM_ networks $ \network -> do
332331
case parseNetworkTxIds network of
333-
Left err -> error $ "Failed to parse network versions: " <> show err
334-
Right txIds -> do
335-
pure $
336-
["--network", network]
337-
`shouldParse` Run
338-
defaultRunOptions
339-
{ chainConfig = Cardano defaultCardanoChainConfig{hydraScriptsTxId = txIds}
340-
}
332+
Left err -> err `shouldBe` ("Failed to find released hydra-node version in networks.json." :: String)
333+
Right txIds ->
334+
["--network", network]
335+
`shouldParse` Run
336+
defaultRunOptions
337+
{ chainConfig = Cardano defaultCardanoChainConfig{hydraScriptsTxId = txIds}
338+
}
341339

342340
it "switches to offline mode when using --offline-head-seed and --initial-utxo" $
343341
mconcat

release.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ check_networks_is_up_to_date() {
145145
preview
146146
)
147147

148-
local networks_file=networks.json
148+
local networks_file=hydra-node/networks.json
149149

150150
for network in "${networks[@]}"; do
151151
cat ${networks_file} | jq -e ".\"${network}\".\"${version}\"" >/dev/null ||

0 commit comments

Comments
 (0)