Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 34 additions & 12 deletions .envrc
Original file line number Diff line number Diff line change
Expand Up @@ -22,29 +22,51 @@ export POSTGRES_USER="postgres"

# A random password is used for your safety. Docker (but not podman) exposes
# ports to the internet by default. This needs to be unguessable.
if [ ! -f postgres.password ]; then
uuidgen | tr -d '-' | head -c 16 > postgres.password
if [ ! -f postgres.secret ]; then
uuidgen | tr -d '-' | head -c 16 > postgres.secret
fi
export POSTGRES_PASSWORD="$(cat ./postgres.password)"
export POSTGRES_PASSWORD="$(cat ./postgres.secret)"

export POSTGRES_DB="cexplorer"

# We bring together the above variables into a database connection string:
export DB_SYNC_POSTGRES_CONNECTION_STRING="psql://$POSTGRES_USER:$POSTGRES_PASSWORD@$POSTGRES_HOST:$POSTGRES_PORT/$POSTGRES_DB"


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


# Validator Values:
if [ ! -f node.privatekey ]; then
# generate node key like this:
DOCKER_DEFAULT_PLATFORM=linux/amd64 docker run --rm -it docker.io/parity/subkey:latest generate-node-key | sed -n '2p' > midnight-node.privatekey
# Use the second line of output for NODE_KEY (that's what sed -n '2p' does)
# Node Key:
# Generate a unique node key for P2P networking
if [ ! -f midnight-node.secret ]; then
# Generate node key using parity/subkey
DOCKER_DEFAULT_PLATFORM=linux/amd64 docker run --rm docker.io/parity/subkey:latest generate-node-key > midnight-node.secret
fi
export NODE_KEY="$(cat ./midnight-node.secret)"

# Indexer Values:
if [ ! -f indexer.secret ]; then
# Generate 32-byte hex secret for indexer
uuidgen | tr -d '-' | head -c 32 > indexer.secret
fi
export INDEXER_SECRET="$(cat ./indexer.secret)"

#
# Mock mode vs Cardano stack:
# Set USE_MOCK=true to run midnight-node with mock Cardano (fast, for dev/testing)
# Set USE_MOCK=false (default) to run full Cardano stack (real blockchain data)
#
export USE_MOCK=${USE_MOCK:-false}

if [ "$USE_MOCK" = "true" ]; then
# Mock mode: Skip Cardano services and indexer
export COMPOSE_PROFILES=""
export DB_SYNC_POSTGRES_CONNECTION_STRING=""
echo "📝 Mock mode enabled - midnight-node will use mock Cardano data"
else
# Cardano stack mode: Run all services
export COMPOSE_PROFILES="cardano"
export DB_SYNC_POSTGRES_CONNECTION_STRING="psql://$POSTGRES_USER:$POSTGRES_PASSWORD@$POSTGRES_HOST:$POSTGRES_PORT/$POSTGRES_DB"
fi
export NODE_KEY="$(cat ./midnight-node.privatekey)"

#
# Partner chains config:
Expand Down
11 changes: 11 additions & 0 deletions .envrc.preview
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# overrides for preview
export MIDNIGHT_NODE_IMAGE="ghcr.io/midnight-ntwrk/midnight-node:0.17.0-rc.4"
export INDEXER_IMAGE="ghcr.io/midnight-ntwrk/indexer-standalone:3.0.0-alpha.5"
Copy link
Collaborator

@gilescope gilescope Nov 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: Node needs to publish to dockerhub for all named releases. (these referenced images aren't public)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gilescope Good catch on the ghcr.io images requiring auth. Is this blocking for the PR, or should we track it separately for the node team?

For context:

  • testnet-02 already uses public Docker Hub image (midnightnetwork/midnight-node:0.12.1)
  • preview/qanet use ghcr.io which needs GitHub authentication

export INDEXER_NETWORK_ID="preview"

# Mock mode configuration
export MOCK_REGISTRATIONS_FILE="res/mock-bridge-data/default-registrations.json"

# Well known addresses of network that allow discovery of all other nodes.
export BOOTNODES="/dns/midnight-node-boot-01/tcp/30333/ws/p2p/12D3KooWK66i7dtGVNSwDh9tTeqov1q6LSdWsRLJvTyzTCaywYgK \
/dns/midnight-node-boot-02/tcp/30333/ws/p2p/12D3KooWHqFfXFwb7WW4jwR8pr4BEf562v5M6c8K3CXAJq4Wx6ym"
5 changes: 5 additions & 0 deletions .envrc.qanet
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# overrides for qanet
export MIDNIGHT_NODE_IMAGE="ghcr.io/midnight-ntwrk/midnight-node:0.12.0-rc.3"
export INDEXER_IMAGE="ghcr.io/midnight-ntwrk/indexer-standalone:2.1.4"
export INDEXER_NETWORK_ID="qanet"

# Mock mode configuration
export MOCK_REGISTRATIONS_FILE="res/mock-bridge-data/qanet-mock.json"

# Well known addresses of network that allow discovery of all other nodes.
export BOOTNODES="/dns/boot-node-01.qanet.dev.midnight.network/tcp/30333/ws/p2p/12D3KooWEyoppNCUx8Yx66oV9fJnriXwCcXwDDUA2kj6vnc6iDEp \
Expand Down
7 changes: 6 additions & 1 deletion .envrc.testnet-02
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# overrides for testnet-02
export MIDNIGHT_NODE_IMAGE="midnightnetwork/midnight-node:0.12.0"
export MIDNIGHT_NODE_IMAGE="midnightnetwork/midnight-node:0.12.1"
export INDEXER_IMAGE="ghcr.io/midnight-ntwrk/indexer-standalone:2.1.4"
export INDEXER_NETWORK_ID="testnet"

# Mock mode configuration
export MOCK_REGISTRATIONS_FILE="res/mock-bridge-data/testnet-02-mock.json"

# These are well known addresses of a network that allow you to discover all the other nodes.
export BOOTNODES="/dns/boot-node-01.testnet-02.midnight.network/tcp/30333/ws/p2p/12D3KooWMjUq13USCvQR9Y6yFzYNYgTQBLNAcmc8psAuPx2UUdnB \
Expand Down
10 changes: 7 additions & 3 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,13 @@ jobs:
- name: Check compose files
run: |
source ./.envrc
docker compose -f compose.yml config -q
docker compose -f compose-partner-chains.yml config -q
docker compose -f proof-server.yml config -q
# Test main compose file
docker compose config -q
# Test profiles
docker compose --profile cardano config -q
docker compose --profile ogmios config -q
docker compose --profile proof-server config -q
docker compose --profile cardano --profile ogmios --profile proof-server config -q

- name: Run Super-linter
uses: github/super-linter@b807e99ddd37e444d189cfd2c2ca1274d8ae8ef1 #v7
Expand Down
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/cardano-data/*
/data
*.privatekey
*.password
*.secret
ogmios_client.log
40 changes: 26 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,38 +12,50 @@ This allows for easy orchestration of the Midnight Node service.

1. Clone repository

2. In `.envrc` set CFG_PRESET to be the environment you wish to point to (E.g. testnet-02).
2. In `.envrc` set CFG_PRESET to be the environment you wish to point to. Available options:
- `qanet` - QA network
- `testnet-02` - TestNet 02
- `preview` - Preview network

3. run `direnv allow` to load the environment variables

4. Run `docker-compose up`

The `.envrc` file will automatically create a random private key and save it as `midnight-node.privatekey`.
The `.envrc` file will automatically create random secrets and save them as `postgres.secret` (database password), `midnight-node.secret` (node private key), and `indexer.secret` (indexer app secret).

Choose which compose files to use:
All services are defined in a single `compose.yml` file. Use Docker Compose profiles to control which services run:

- `compose.yml` for Midnight Node
- `compose-partner-chains.yml` for Cardano + DB Sync
- `proof-server.yml` for Local Proof Server
**Available profiles:**

One can use one or multiple compose files at once.
- (no profile) - Midnight Node only
- `cardano` - Adds Cardano stack (cardano-node, postgres, cardano-db-sync) and Indexer with GraphQL API at `http://localhost:8088`
- `ogmios` - Adds Ogmios service at `http://localhost:1337`
- `proof-server` - Adds local Proof Server at `http://localhost:6300`

For example, to run the Midnight Node, you can do:
**Usage examples:**

Run Midnight Node only:

```shell
docker compose up -d
```

or to run the Midnight Node and Cardano DB Sync, you can do:
Run Midnight Node + Cardano stack + Indexer:

```shell
docker compose --profile cardano up -d
```

Run with Cardano stack + Ogmios:

```shell
docker compose -f ./compose-partner-chains.yml -f ./compose.yml up -d
docker compose --profile cardano --profile ogmios up -d
```

or to run the Midnight Node, Cardano DB Sync and a local Proof Server, you can do:
Run everything (Cardano + Ogmios + Proof Server):

```shell
docker compose -f ./compose-partner-chains.yml -f ./compose.yml -f ./proof-server.yml up -d
docker compose --profile cardano --profile ogmios --profile proof-server up -d
```

🚀 That's it.
Expand All @@ -60,8 +72,8 @@ If you're using `midnight-node smartcontract` or `midnight-node wizards` that ne
To restart from fresh, run:

```sh
docker compose -f ./compose-partner-chains.yml -f ./compose.yml -f ./proof-server.yml down -v
docker compose -f ./compose-partner-chains.yml -f ./compose.yml -f ./proof-server.yml kill
docker compose --profile cardano --profile ogmios --profile proof-server down -v
docker compose --profile cardano --profile ogmios --profile proof-server kill
rm -R ./cardano-data
docker volume rm midnight-node-docker_midnight-data-testnet
```
Expand Down
92 changes: 0 additions & 92 deletions compose-partner-chains.yml

This file was deleted.

Loading