Skip to content
Merged
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
53 changes: 49 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,22 +140,62 @@ docker run --detach \
-e CARDANO_SHELLEY_KES_KEY=/opt/cardano/config/keys/kes.skey \
-e CARDANO_SHELLEY_OPERATIONAL_CERTIFICATE=/opt/cardano/config/keys/node.cert \
-e CARDANO_SHELLEY_VRF_KEY=/opt/cardano/config/keys/vrf.skey \
-v /src/cardano/node-keys:/opt/cardano/config/keys \
-v /srv/cardano/node-keys:/opt/cardano/config/keys \
-v /srv/cardano/node-db:/data/db \
-v /srv/cardano/node-ipc:/ipc \
-p 3001:3001 \
-p 12798:12798 \
ghcr.io/blinklabs-io/cardano-node run
```

##### Dynamic Block Forging

To start a block producer in non-producing mode initially (for dynamic block forging):

```bash
docker run --detach \
--name cardano-node \
--restart unless-stopped \
-e CARDANO_BLOCK_PRODUCER=true \
-e START_AS_NON_PRODUCING=true \
-e CARDANO_SHELLEY_KES_KEY=/opt/cardano/config/keys/kes.skey \
-e CARDANO_SHELLEY_OPERATIONAL_CERTIFICATE=/opt/cardano/config/keys/node.cert \
-e CARDANO_SHELLEY_VRF_KEY=/opt/cardano/config/keys/vrf.skey \
-v /srv/cardano/node-keys:/opt/cardano/config/keys \
-v /srv/cardano/node-db:/data/db \
-v /srv/cardano/node-ipc:/ipc \
-p 3001:3001 \
-p 12798:12798 \
ghcr.io/blinklabs-io/cardano-node run
```

With dynamic block forging enabled, you can control block production without restarting the node:

- **Enable block forging**: Ensure credential files are present and send SIGHUP
```bash
docker exec cardano-node pkill -SIGHUP cardano-node
```

- **Disable block forging**: Move/rename credential files and send SIGHUP
```bash
docker exec cardano-node mv /opt/cardano/config/keys/kes.skey /opt/cardano/config/keys/kes.skey.disabled
docker exec cardano-node pkill -SIGHUP cardano-node
```

- **Re-enable block forging**: Restore credential files and send SIGHUP
```bash
docker exec cardano-node mv /opt/cardano/config/keys/kes.skey.disabled /opt/cardano/config/keys/kes.skey
docker exec cardano-node pkill -SIGHUP cardano-node
```

The above uses Docker's built in supervisor to restart a container which fails
for any reason. This will also cause the container to automatically restart
after a host reboot, so long as Docker is configured to start on boot. We
set variables to configure a block producer and pass the paths to the 3 keys
we need. Our node's persistent data and client communication socket are mapped
to `/src/cardano/node-db` and `/src/cardano/node-ipc` on the host,
to `/srv/cardano/node-db` and `/srv/cardano/node-ipc` on the host,
respectively. This allows for running applications directly on the host which
may need access to these. We also map `/src/cardano/node-keys` on the host to
may need access to these. We also map `/srv/cardano/node-keys` on the host to
a path within the container to support running as a block producer. Last, we
add mapping the host's port 12798 to the container 12798, which is the port for
exposing the node's metrics in Prometheus format, for monitoring.
Expand Down Expand Up @@ -224,7 +264,12 @@ and operational certificate.
`${CARDANO_CONFIG_BASE}/keys/vrf.skey`)
- `CARDANO_SHELLEY_OPERATIONAL_CERTIFICATE`
- Stake pool identity certificate (default:
`${CARDANO_CONFIG_BASE}/keys/node.cert`
`${CARDANO_CONFIG_BASE}/keys/node.cert`)
- `START_AS_NON_PRODUCING`
- Start block producer node in non-producing mode (default: `false`)
- When set to `true`, adds the `--start-as-non-producing-node` flag
- Only applies when `CARDANO_BLOCK_PRODUCER=true`
- Enables dynamic block forging control via SIGHUP signals

#### Controlling Mithril snapshots

Expand Down
7 changes: 7 additions & 0 deletions bin/run-node
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ for i in ${!options[@]}; do
--shelley-vrf-key) CARDANO_SHELLEY_VRF_KEY=${v}; found=true ;;
--socket-path) CARDANO_SOCKET_PATH=${v}; found=true ;;
--topology) CARDANO_TOPOLOGY=${v}; found=true ;;
--start-as-non-producing-node) START_AS_NON_PRODUCING=${v}; found=true ;;
esac
if [[ ${found} == true ]]; then
options[i]="";
Expand All @@ -44,6 +45,7 @@ CARDANO_PORT=${CARDANO_PORT:-3001}
CARDANO_RTS_OPTS=${CARDANO_RTS_OPTS:--N2 -A64m -I0 -qg -qb --disable-delayed-os-memory-return}
CARDANO_SOCKET_PATH=${CARDANO_SOCKET_PATH:-/ipc/node.socket}
CARDANO_TOPOLOGY=${CARDANO_TOPOLOGY:-${CARDANO_CONFIG_BASE}/${CARDANO_NETWORK}/topology.json}
START_AS_NON_PRODUCING=${START_AS_NON_PRODUCING:-false}
# mithril and devnet
case ${CARDANO_NETWORK} in
mainnet|preprod) __path=release-${CARDANO_NETWORK} ;;
Expand Down Expand Up @@ -92,6 +94,7 @@ echo CARDANO_PORT=${CARDANO_PORT}
echo CARDANO_RTS_OPTS=${CARDANO_RTS_OPTS}
echo CARDANO_SOCKET_PATH=${CARDANO_SOCKET_PATH}
echo CARDANO_TOPOLOGY=${CARDANO_TOPOLOGY}
echo START_AS_NON_PRODUCING=${START_AS_NON_PRODUCING}

# block producer only
if [[ ${CARDANO_BLOCK_PRODUCER} == true ]]; then
Expand Down Expand Up @@ -170,6 +173,10 @@ if [[ ${CARDANO_BLOCK_PRODUCER} == true ]]; then
--shelley-vrf-key ${CARDANO_SHELLEY_VRF_KEY} \
--socket-path ${CARDANO_SOCKET_PATH} \
--topology ${CARDANO_TOPOLOGY})
# Add --start-as-non-producing-node flag if START_AS_NON_PRODUCING is true
if [[ ${START_AS_NON_PRODUCING} == true ]]; then
effopts+=(--start-as-non-producing-node)
fi
else
effopts=(--config ${CARDANO_CONFIG} \
--database-path ${CARDANO_DATABASE_PATH} \
Expand Down
Loading