Skip to content

Commit b45e473

Browse files
Update node version to PC1.5 and remove Kupo (#13)
* fix: ogmios version required by PC 1.5 * feat: added test.sh * rename containers to not conflict with local environment containers. * feat: midnight-shell to allow multiple midnight commands to be run. * fix: add qanet pc-chain-config.json * fix: cardano data dir should be mounted for cardano-cli.sh * fix: proof server 4 * fix: point to public image for node --------- Signed-off-by: Squirrel <giles.cope@iohk.io> Co-authored-by: MonikaJassova <monika.jassova@iohk.io>
1 parent 506209d commit b45e473

18 files changed

+698
-44
lines changed

.envrc

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
# If your on windows use wsl / git bash / cygwin / msys2 with direnv
22

3+
export CFG_PRESET=testnet-02
4+
5+
source ./.envrc.${CFG_PRESET}
6+
37
# This repository only accepts signed commits:
8+
49
# point out to users at commit time that commits need to be signed,
510
# not once they've done many commits and are trying to push a PR:
611
git config --local commit.gpgSign true
@@ -11,8 +16,6 @@ if [[ "$(uname -s)" == "Darwin" ]] && [[ "$(uname -m)" == "arm64" ]]; then
1116
export DOCKER_DEFAULT_PLATFORM=linux/arm64
1217
fi
1318

14-
export MIDNIGHT_NODE_IMAGE="midnightnetwork/midnight-node:0.8.0"
15-
1619
export POSTGRES_HOST="postgres" # TODO: replace with IP or host to postgres connection if not connecting to the docker one.
1720
export POSTGRES_PORT="5432"
1821
export POSTGRES_USER="postgres"
@@ -29,16 +32,11 @@ export POSTGRES_DB="cexplorer"
2932
# We bring together the above variables into a database connection string:
3033
export DB_SYNC_POSTGRES_CONNECTION_STRING="psql://$POSTGRES_USER:$POSTGRES_PASSWORD@$POSTGRES_HOST:$POSTGRES_PORT/$POSTGRES_DB"
3134

32-
# These are well known addresses of a network that allow you to discover all the other nodes.
33-
export BOOTNODES="/dns/boot-node-01.testnet-02.midnight.network/tcp/30333/ws/p2p/12D3KooWMjUq13USCvQR9Y6yFzYNYgTQBLNAcmc8psAuPx2UUdnB \
34-
/dns/boot-node-02.testnet-02.midnight.network/tcp/30333/ws/p2p/12D3KooWR1cHBUWPCqk3uqhwZqUFekfWj8T7ozK6S18DUT745v4d \
35-
/dns/boot-node-03.testnet-02.midnight.network/tcp/30333/ws/p2p/12D3KooWQxxUgq7ndPfAaCFNbAxtcKYxrAzTxDfRGNktF75SxdX5"
3635

3736
# To start with debug logs, add "-l debug" to APPEND_ARGS
38-
# To expose safe rpc method to the host port 9944, add "--rpc-external" to APPEND_ARGS
39-
export APPEND_ARGS="--no-private-ip --validator --pool-limit 10 --trie-cache-size 0 --prometheus-external"
37+
# To expose safe rpc method to the host port 9944, add "--unsafe-rpc-external" to APPEND_ARGS or --validator
38+
export APPEND_ARGS="--allow-private-ip --pool-limit 10 --trie-cache-size 0 --prometheus-external --rpc-external --rpc-cors all"
4039

41-
export CFG_PRESET=testnet-02
4240

4341
# Validator Values:
4442
if [ ! -f node.privatekey ]; then

.envrc.qanet

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# overrides for qanet
2+
export MIDNIGHT_NODE_IMAGE="ghcr.io/midnight-ntwrk/midnight-node:0.12.0-rc.3"
3+
4+
# Well known addresses of network that allow discovery of all other nodes.
5+
export BOOTNODES="/dns/boot-node-01.qanet.dev.midnight.network/tcp/30333/ws/p2p/12D3KooWEyoppNCUx8Yx66oV9fJnriXwCcXwDDUA2kj6vnc6iDEp \
6+
/dns/boot-node-02.qanet.dev.midnight.network/tcp/30333/ws/p2p/12D3KooWHdiAxVd8uMQR1hGWXccidmfCwLqcMpGwR6QcTP6QRMuD \
7+
/dns/boot-node-03.qanet.dev.midnight.network/tcp/30333/ws/p2p/12D3KooWSCufgHzV4fCwRijfH2k3abrpAJxTKxEvN1FDuRXA2U9x"

.envrc.testnet-02

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# overrides for testnet-02
2+
export MIDNIGHT_NODE_IMAGE="midnightnetwork/midnight-node:0.12.0"
3+
4+
# These are well known addresses of a network that allow you to discover all the other nodes.
5+
export BOOTNODES="/dns/boot-node-01.testnet-02.midnight.network/tcp/30333/ws/p2p/12D3KooWMjUq13USCvQR9Y6yFzYNYgTQBLNAcmc8psAuPx2UUdnB \
6+
/dns/boot-node-02.testnet-02.midnight.network/tcp/30333/ws/p2p/12D3KooWR1cHBUWPCqk3uqhwZqUFekfWj8T7ozK6S18DUT745v4d \
7+
/dns/boot-node-03.testnet-02.midnight.network/tcp/30333/ws/p2p/12D3KooWQxxUgq7ndPfAaCFNbAxtcKYxrAzTxDfRGNktF75SxdX5"

.github/workflows/ci.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ jobs:
4242
VALIDATE_BASH_EXEC: true
4343
VALIDATE_CHECOV: true
4444
VALIDATE_GITHUB_ACTIONS: true
45-
VALIDATE_GITLEAKS: true
4645
VALIDATE_NATURAL_LANGUAGE: true
4746
VALIDATE_MARKDOWN: true
4847
VALIDATE_DOCKERFILE: true

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
/data
33
*.privatekey
44
*.password
5+
ogmios_client.log

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## 🚀 Features
99

10+
- Switch networks by altering CFG_PRESET only
11+
- Added `test.sh` to detect problems and provide solutions.
12+
- Added `reset-midnight.sh` script to clear down midnight's blockchain.
13+
- `--validator` flag not set by default.
1014
- Port from prior repository (#3)
1115
- If direnv isn't working give an appropriate error message.
1216
- /data dir should be .gitignored

README.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@ This allows for easy orchestration of the Midnight Node service.
1212

1313
1. Clone repository
1414

15-
2. run `direnv allow` to load the environment variables
15+
2. In `.envrc` set CFG_PRESET to be the environment you wish to point to (E.g. testnet-02).
1616

17-
3. Run `docker-compose up`
17+
3. run `direnv allow` to load the environment variables
18+
19+
4. Run `docker-compose up`
1820

1921
The `.envrc` file will automatically create a random private key and save it as `midnight-node.privatekey`.
2022

@@ -48,6 +50,11 @@ docker compose -f ./compose-partner-chains.yml -f ./compose.yml -f ./proof-serve
4850

4951
### Troubleshooting
5052

53+
### Connecting to Ogmios
54+
55+
If you're using `midnight-node smartcontract` or `midnight-node wizards` that need ogmios, and you're running midnight-node in docker you must pass `-O ws://host.docker.internal:1337` as an argument.
56+
(Once PartnerChains 1.7+ is released OGMIOS_URL env var can be set so that it just works, but for now you have to pass it as an argument.)
57+
5158
### Clean start
5259

5360
To restart from fresh, run:
@@ -56,8 +63,8 @@ To restart from fresh, run:
5663
docker compose -f ./compose-partner-chains.yml -f ./compose.yml -f ./proof-server.yml down -v
5764
docker compose -f ./compose-partner-chains.yml -f ./compose.yml -f ./proof-server.yml kill
5865
rm ~/ipc/node.socket
59-
rm -R ./data
6066
rm -R ./cardano-data
67+
docker volume rm midnight-node-docker_midnight-data-testnet
6168
```
6269

6370
#### Env vars not setup

cardano-cli.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,6 @@ DOCKER_DEFAULT_PLATFORM=linux/amd64 docker run --rm \
1616
-e CARDANO_NODE_SOCKET_PATH="/ipc/node.socket" \
1717
-e CARDANO_NODE_NETWORK_ID="${CARDANO_NODE_NETWORK_ID}" \
1818
-v ~/ipc:/ipc \
19+
-v "${CARDANO_DATA_DIR}:/data" \
1920
"${CARDANO_IMAGE}" \
2021
cli "$@"

check-chain.sh

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
# ─── Configuration ─────────────────────────────────────────────────────────────
5+
RPC_URL="http://127.0.0.1:9944" # your node’s JSON-RPC HTTP endpoint
6+
RPC_URL="https://rpc.qanet.dev.midnight.network/"
7+
8+
echo Get genesis utxo from running midnight node...
9+
GET_PC_PARAMS="curl -s -H \"Content-Type:application/json\" \
10+
-d '{\"jsonrpc\":\"2.0\",\"method\":\"sidechain_getParams\",\"params\":[],\"id\":1}' \
11+
\"$RPC_URL\""
12+
GENESIS_UTXO=$(eval "$GET_PC_PARAMS" | jq -r '.result.genesis_utxo')
13+
echo "GENESIS_UTXO=$GENESIS_UTXO"
14+
15+
16+
export GENESIS_TX_HASH="${GENESIS_UTXO%%#*}"
17+
export GENESIS_COIN_INDEX="${GENESIS_UTXO##*#}"
18+
echo Check coin has been spent according to cardano...
19+
QUERY_UTXO_CMD="./cardano-cli.sh query utxo --tx-in $GENESIS_UTXO --output-json 2>/dev/null"
20+
genesis_utxo_json=$(eval "$QUERY_UTXO_CMD");
21+
22+
if [ "$genesis_utxo_json" = "{}" ] ; then
23+
echo "✅ Genesis can't be found in UTXOs."
24+
else
25+
echo "❌ As part of chain registration process Genesis UTXO should have been spent but $genesis_utxo_json"
26+
fi
27+
28+
# Assume that db-sync is synced.
29+
30+
# Find spent UTXO:
31+
export PGPASSWORD=$POSTGRES_PASSWORD
32+
33+
spent_utxo=$(psql \
34+
-h 127.0.0.1 -p "$POSTGRES_PORT" \
35+
-U "$POSTGRES_USER" -d "$POSTGRES_DB" \
36+
-tAc "SELECT
37+
tx_out.tx_id,
38+
encode(tx.hash, 'hex') AS tx_hash,
39+
tx_out.index,
40+
tx_out.value,
41+
tx_out.address,
42+
datum.bytes AS inline_datum
43+
FROM tx_out
44+
JOIN tx ON tx.id = tx_out.tx_id
45+
LEFT JOIN datum ON tx_out.inline_datum_id = datum.id
46+
WHERE tx.hash = '\\x${GENESIS_TX_HASH}'
47+
LIMIT 10;
48+
;")
49+
50+
if [ "$spent_utxo" = "" ] ; then
51+
echo "❌ As part of chain registration process Genesis UTXO should have been spent but can't find it in db-sync's spent list: $spent_utxo"
52+
else
53+
echo "✅ Spent genesis coin found: '$spent_utxo'"
54+
55+
# can show url to tx hash https://preview.cexplorer.io/tx/1bb8027cb698c4b4c829396ac6eabac2ad46d80744c7a6822298dd76633c4f4f
56+
fi
57+
58+
59+
EPOCH_CMD="./cardano-cli.sh query tip 2>/dev/null"
60+
tip=$(eval "$EPOCH_CMD");
61+
CURRENT_EPOCH=$(echo "$tip" | jq -r '.epoch')
62+
echo "epoc=$CURRENT_EPOCH"
63+
64+
65+
# curl -s -H "Content-Type:application/json" -d '{"jsonrpc":"2.0","method":"sidechain_getStatus","params":[],"id":1}' https://rpc.qanet.dev.midnight.network/
66+
67+
# {"jsonrpc":"2.0","id":1,"result":{"sidechain":{"epoch":242583,"slot":291100548,"nextEpochTimestamp":1746604800000},"mainchain":{"epoch":925,"slot":79947270,"nextEpochTimestamp":1746662400000}}}%
68+
69+
# sidechain_getEpochCommittee
70+
# sidechain_getRegistrations
71+
72+
EPOCH=$CURRENT_EPOCH
73+
GET_PC_ARIADNE_PARAMS="curl -s -H \"Content-Type:application/json\" \
74+
-d '{\"jsonrpc\":\"2.0\",\"method\":\"sidechain_getAriadneParameters\",\"params\":[$EPOCH],\"id\":1}' \"$RPC_URL\""
75+
echo "$GET_PC_ARIADNE_PARAMS"
76+
ARIADNE_PARAMS=$(eval "$GET_PC_ARIADNE_PARAMS")
77+
if [[ $ARIADNE_PARAMS == *ExpectedDataNotFound* ]]; then
78+
echo No current ariadne registration...
79+
echo Checking for future ariadne registration...
80+
START_EPOCH=$CURRENT_EPOCH # Assume EPOCH is already set
81+
82+
for ((i = 0; i <= 10; i++)); do
83+
CURRENT_EPOCH=$((START_EPOCH + i))
84+
echo "Checking epoch $CURRENT_EPOCH"
85+
86+
# Replace this with your actual command and condition
87+
RESPONSE=$(curl -s -H "Content-Type: application/json" \
88+
-d '{"jsonrpc":"2.0","method":"sidechain_getAriadneParameters","params":['"$CURRENT_EPOCH"'], "id":1}' "$RPC_URL")
89+
90+
if [[ "$RESPONSE" != *"ExpectedDataNotFound"* ]]; then
91+
ACTIVE_EPOCH=$CURRENT_EPOCH
92+
ARIADNE_PARAMS=$RESPONSE
93+
DIFF=$((CURRENT_EPOCH - EPOCH))
94+
echo "Registration found at epoch $CURRENT_EPOCH (active in $DIFF days time)"
95+
echo "(SPOs can start registering now)"
96+
break
97+
fi
98+
done
99+
if [[ -z "$ACTIVE_EPOCH" ]]; then
100+
echo "No pending registration for the chain. Please register the chain's Genesis UTXO:"
101+
echo "./midnight-node wizards setup-main-chain-state (but ./midnight-node wizards prepare-configuration will need to have been done first and ./midnight-node wizards generate-keys before that.)"
102+
fi
103+
else
104+
ACTIVE_EPOCH=$CURRENT_EPOCH
105+
echo Found current ariadne registration...
106+
fi
107+
108+
START_EPOCH=$CURRENT_EPOCH # Assume EPOCH is already set
109+
for ((i = 0; i <= 10; i++)); do
110+
CURRENT_EPOCH=$((START_EPOCH + i))
111+
# echo "Checking epoch $CURRENT_EPOCH"
112+
113+
# Replace this with your actual command and condition
114+
RESPONSE=$(curl -s -H "Content-Type: application/json" \
115+
-d '{"jsonrpc":"2.0","method":"sidechain_getAriadneParameters","params":['"$CURRENT_EPOCH"'], "id":1}' "$RPC_URL")
116+
117+
if [[ "$RESPONSE" != *"ExpectedDataNotFound"* ]]; then
118+
ACTIVE_EPOCH=$CURRENT_EPOCH
119+
ARIADNE_PARAMS=$RESPONSE
120+
DIFF=$((CURRENT_EPOCH - EPOCH))
121+
122+
# given there is a registration, check it's valid.
123+
PERMISSIONED_CANDIDATES_VALID=$(echo "$ARIADNE_PARAMS" | jq -r '[.result.permissionedCandidates[] | select(.isValid == true)] | length')
124+
CANDIDATES_VALID=$(echo "$ARIADNE_PARAMS" | jq -r '[.result.candidateRegistrations[][] | select(.isValid == true)] | length')
125+
INTERNAL_SPO_COUNT=$(echo "$ARIADNE_PARAMS" |jq '.result.permissionedCandidates | length')
126+
EXTERNAL_SPO_COUNT=$(echo "$ARIADNE_PARAMS" |jq '.result.candidateRegistrations | length')
127+
if [[ "$PERMISSIONED_CANDIDATES_VALID" == "$INTERNAL_SPO_COUNT" ]]; then
128+
PERM_MSG="✅ All $INTERNAL_SPO_COUNT permissioned candidates valid"
129+
else
130+
PERM_MSG="$PERMISSIONED_CANDIDATES_VALID of $INTERNAL_SPO_COUNT permissioned candidates are valid"
131+
fi
132+
if [[ "$CANDIDATES_VALID" == "$EXTERNAL_SPO_COUNT" ]]; then
133+
CAND_MSG="✅ All $EXTERNAL_SPO_COUNT candidate registrations valid"
134+
else
135+
CAND_MSG="$CANDIDATES_VALID of $EXTERNAL_SPO_COUNT candidate registrations valid"
136+
fi
137+
138+
echo "✅ Epoch $CURRENT_EPOCH ($DIFF days time) | $CAND_MSG | $PERM_MSG"
139+
else
140+
echo "❌ Epoch $CURRENT_EPOCH : ExpectedDataNotFound"
141+
fi
142+
done
143+
144+
# midnight_apiVersions
145+
# midnight_ledgerVersion
146+
147+
148+
149+
# Registrations status for epoch 929:
150+
# running external command: /midnight-node registration-status --mainchain-pub-key 0x1f4bf447da2b78482b2656f7f504b321c9f0b8712faabbd0de7c47ab13d9cd4a --mc-epoch-number 929 --chain chain-spec.json --base-path /tmp/.tmpii6vGf
151+
# command output: Error: Input("ChainSpec Parse error: Error opening spec file `chain-spec.json`: No such file or directory (os error 2)")
152+
# Running executable failed with status exit status

compose-partner-chains.yml

Lines changed: 7 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ volumes:
1818
db-sync-data: {}
1919
postgres-data: {}
2020
ogmios-data: {}
21-
kupo-data: {}
2221

2322
services:
2423
cardano-node:
2524
image: ${CARDANO_IMAGE}
25+
platform: linux/amd64
2626
restart: unless-stopped
2727
container_name: cardano-node
2828
ports:
@@ -52,10 +52,10 @@ services:
5252
timeout: 5s
5353
retries: 5
5454

55-
db-sync:
55+
cardano-db-sync:
5656
image: ghcr.io/intersectmbo/cardano-db-sync:13.6.0.4
5757
platform: linux/amd64
58-
container_name: db-sync
58+
container_name: cardano-db-sync
5959
restart: unless-stopped
6060
depends_on:
6161
postgres:
@@ -71,9 +71,10 @@ services:
7171
- ${HOME_IPC}:/node-ipc # Use ${HOME_IPC} from .envrc
7272
- db-sync-data:/var/lib
7373

74-
ogmios:
75-
image: cardanosolutions/ogmios:v6.5.0
76-
container_name: ogmios
74+
cardano-ogmios:
75+
image: cardanosolutions/ogmios:v6.11.0
76+
platform: linux/amd64
77+
container_name: cardano-ogmios
7778
restart: unless-stopped
7879
environment:
7980
- DATA_DIR=/data
@@ -89,26 +90,3 @@ services:
8990
- /config/${CARDANO_NETWORK}/cardano-node/config.json
9091
- --host
9192
- 0.0.0.0
92-
93-
kupo:
94-
image: cardanosolutions/kupo:v2.9.0
95-
container_name: kupo
96-
command:
97-
- --node-socket
98-
- /ipc/node.socket
99-
- --node-config
100-
- /config/config.json
101-
- --host
102-
- 0.0.0.0
103-
- --workdir
104-
- /db
105-
- --match
106-
- "*"
107-
- --since
108-
- "origin"
109-
ports:
110-
- "1442:1442"
111-
volumes:
112-
- kupo-data:/db
113-
- ${HOME_IPC}:/ipc # Use ${HOME_IPC} from .envrc
114-
- $CARDANO_CONFIG_DIR:/config

0 commit comments

Comments
 (0)