Skip to content

Commit 66f560c

Browse files
authored
Merge pull request #1367 from input-output-hk/fix-tutorial
Fix tutorial download instructions
2 parents 09800bd + b3ed1bc commit 66f560c

File tree

7 files changed

+47
-48
lines changed

7 files changed

+47
-48
lines changed

.github/workflows/check-tutorial.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
import re
3232
with open("docs/docs/tutorial/index.md", "r") as tutorial:
3333
body = tutorial.read()
34-
usedCardanoNodeVersions = re.findall(r"cardano-node-.*-([0-9]+\.[0-9]+\.[0-9]+).zip", body)
34+
usedCardanoNodeVersions = re.findall(r"cardano-node-([0-9]+\.[0-9]+\.[0-9]+)-.*\.tar\.gz", body)
3535
3636
with open("hydra-cluster/test/Test/CardanoNodeSpec.hs", "r") as cardanoNodeSpecFile:
3737
body = cardanoNodeSpecFile.read()

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ changes.
1111

1212
## [0.16.0] - UNRELEASED
1313

14-
- Update to and tested against `cardano-node 8.9.0` and `cardano-cli 8.20.3.0`.
14+
- Tested with `cardano-node 8.9.0`, `cardano-cli 8.20.3.0` and `mithril 2408.0`.
1515

1616
- **BREAKING** Hydra scripts changed due to updates in the `plutus` toolchain:
1717
- Overall slight increase in script size.

docs/docs/tutorial/index.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ version=0.15.0
4545
curl -L -O https://github.com/input-output-hk/hydra/releases/download/${version}/hydra-x86_64-linux-${version}.zip
4646
unzip -d bin hydra-x86_64-linux-${version}.zip
4747
curl -L -o - https://github.com/input-output-hk/cardano-node/releases/download/8.9.0/cardano-node-8.9.0-linux.tar.gz \
48-
| tar xz -C bin ./cardano-node ./cardano-cli
49-
curl -L -o - https://github.com/input-output-hk/mithril/releases/download/2347.0/mithril-2347.0-linux-x64.tar.gz \
48+
| tar xz ./bin/cardano-node ./bin/cardano-cli
49+
curl -L -o - https://github.com/input-output-hk/mithril/releases/download/2408.0/mithril-2408.0-linux-x64.tar.gz \
5050
| tar xz -C bin mithril-client
5151
chmod +x bin/*
5252
```
@@ -59,10 +59,10 @@ mkdir -p bin
5959
version=0.15.0
6060
curl -L -O https://github.com/input-output-hk/hydra/releases/download/${version}/hydra-aarch64-darwin-${version}.zip
6161
unzip -d bin hydra-aarch64-darwin-${version}.zip
62-
curl -L -o - https://github.com/input-output-hk/hydra/releases/download/${version}/cardano-node-aarch-darwin-8.9.0.zip
63-
unzip -d bin cardano-node-8.9.0-linux.zip
6462
curl -L -o - https://github.com/input-output-hk/cardano-node/releases/download/8.9.0/cardano-node-8.9.0-macos.tar.gz \
65-
| tar xz -C bin --wildcards ./cardano-node ./cardano-cli '*.dylib'
63+
| tar xz --wildcards ./bin/cardano-node ./bin/cardano-cli './bin/*.dylib'
64+
curl -L -o - https://github.com/input-output-hk/mithril/releases/download/2408.0/mithril-2408.0-macos-x64.tar.gz \
65+
| tar xz -C bin
6666
chmod +x bin/*
6767
```
6868

@@ -122,8 +122,7 @@ We will be using the `mithril-client` configured to download from
122122
`preprod` network to download the latest blockchain snapshot:
123123

124124
```shell
125-
SNAPSHOT_DIGEST=$(mithril-client snapshot list --json | jq -r '.[0].digest')
126-
mithril-client snapshot download $SNAPSHOT_DIGEST
125+
mithril-client snapshot download latest
127126
```
128127

129128
<details>

flake.lock

Lines changed: 19 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
flake = false;
2020
};
2121
cardano-node.url = "github:intersectmbo/cardano-node/8.9.0";
22-
mithril.url = "github:input-output-hk/mithril/2347.0";
22+
mithril.url = "github:input-output-hk/mithril/2408.0";
2323
nix-npm-buildpackage.url = "github:serokell/nix-npm-buildpackage";
2424
};
2525

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ import Data.ByteString qualified as BS
1010
import Hydra.Cluster.Fixture (KnownNetwork (..))
1111
import Network.HTTP.Simple (getResponseBody, httpBS, parseRequest)
1212
import System.IO.Error (isEOFError)
13-
import System.Process.Typed (createPipe, getStdout, proc, setStdout, withProcessWait_)
13+
import System.Process.Typed (createPipe, getStderr, proc, setStderr, withProcessWait_)
1414

1515
data MithrilLog
1616
= StartSnapshotDownload {network :: KnownNetwork, directory :: FilePath}
17-
| -- | Output captured directly from mithril-client
18-
StdOut {output :: Value}
17+
| -- | Output captured directly from mithril-client stderr.
18+
StdErr {output :: Value}
1919
deriving stock (Eq, Show, Generic)
2020
deriving anyclass (ToJSON, FromJSON)
2121

@@ -28,7 +28,7 @@ downloadLatestSnapshotTo tracer network directory = do
2828
traceWith tracer StartSnapshotDownload{network, directory}
2929
genesisKey <- parseRequest genesisKeyURL >>= httpBS <&> getResponseBody
3030
let cmd =
31-
setStdout createPipe $
31+
setStderr createPipe $
3232
proc "mithril-client" $
3333
concat
3434
[ ["--aggregator-endpoint", aggregatorEndpoint]
@@ -37,15 +37,15 @@ downloadLatestSnapshotTo tracer network directory = do
3737
, ["--download-dir", directory]
3838
, ["--json"]
3939
]
40-
withProcessWait_ cmd traceStdout
40+
withProcessWait_ cmd traceStderr
4141
_ -> error $ "Network " <> show network <> " not supported by mithril."
4242
where
43-
traceStdout p =
43+
traceStderr p =
4444
ignoreEOFErrors . forever $ do
45-
bytes <- BS.hGetLine (getStdout p)
45+
bytes <- BS.hGetLine (getStderr p)
4646
case Aeson.eitherDecodeStrict bytes of
4747
Left err -> error $ "failed to decode: \n" <> show bytes <> "\nerror: " <> show err
48-
Right output -> traceWith tracer StdOut{output}
48+
Right output -> traceWith tracer StdErr{output}
4949

5050
ignoreEOFErrors =
5151
handleJust (guard . isEOFError) (const $ pure ())

hydra-cluster/test/Test/Hydra/Cluster/MithrilSpec.hs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import Hydra.Prelude
44
import Test.Hydra.Prelude
55

66
import Control.Concurrent.Class.MonadSTM (newTVarIO, readTVarIO)
7-
import Control.Lens ((^?!))
8-
import Data.Aeson.Lens (key, _Number)
7+
import Control.Lens ((^?))
8+
import Data.Aeson.Lens (key)
99
import Hydra.Cluster.Mithril (MithrilLog (..), downloadLatestSnapshotTo)
1010
import Hydra.Logging (Envelope (..), Tracer, traceInTVar)
1111
import System.Directory (doesDirectoryExist)
@@ -22,19 +22,19 @@ spec = parallel $ do
2222
doesDirectoryExist dbPath `shouldReturn` False
2323
race_
2424
(downloadLatestSnapshotTo tracer network tmpDir)
25-
(waitForStep 3 getTraces)
25+
(waitForDownload getTraces)
2626

27-
-- | Wait for the 'StdOut' message that matches the given step number.
28-
waitForStep :: HasCallStack => Natural -> IO [Envelope MithrilLog] -> IO ()
29-
waitForStep step getTraces = do
27+
-- | Wait for the 'StdErr' message to indicate it starts downloading.
28+
waitForDownload :: HasCallStack => IO [Envelope MithrilLog] -> IO ()
29+
waitForDownload getTraces = do
3030
traces <- getTraces
31-
unless (any isRightStep traces) $ do
31+
unless (any isRightTrace traces) $ do
3232
threadDelay 1
33-
waitForStep step getTraces
33+
waitForDownload getTraces
3434
where
35-
isRightStep = \case
36-
Envelope{message = StdOut{output}} ->
37-
output ^?! key "step_num" . _Number == fromIntegral step
35+
isRightTrace = \case
36+
Envelope{message = StdErr{output}} ->
37+
isJust $ output ^? key "bytes_downloaded"
3838
_ -> False
3939

4040
-- | Create a tracer that captures all messages and a function to retrieve all

0 commit comments

Comments
 (0)