Skip to content

Commit f8f749e

Browse files
committed
feat(dynamic-forging): include --start-as-non-producing-node flag for dynamic forging
- update readme with new env var and usage Signed-off-by: Reza Rajan <[email protected]>
1 parent 8cb3a9b commit f8f749e

File tree

2 files changed

+52
-1
lines changed

2 files changed

+52
-1
lines changed

README.md

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,46 @@ docker run --detach \
148148
ghcr.io/blinklabs-io/cardano-node run
149149
```
150150

151+
##### Dynamic Block Forging
152+
153+
To start a block producer in non-producing mode initially (for dynamic block forging):
154+
155+
```bash
156+
docker run --detach \
157+
--name cardano-node \
158+
--restart unless-stopped \
159+
-e CARDANO_BLOCK_PRODUCER=true \
160+
-e START_AS_NON_PRODUCING=true \
161+
-e CARDANO_SHELLEY_KES_KEY=/opt/cardano/config/keys/kes.skey \
162+
-e CARDANO_SHELLEY_OPERATIONAL_CERTIFICATE=/opt/cardano/config/keys/node.cert \
163+
-e CARDANO_SHELLEY_VRF_KEY=/opt/cardano/config/keys/vrf.skey \
164+
-v /src/cardano/node-keys:/opt/cardano/config/keys \
165+
-v /srv/cardano/node-db:/data/db \
166+
-v /srv/cardano/node-ipc:/ipc \
167+
-p 3001:3001 \
168+
-p 12798:12798 \
169+
ghcr.io/blinklabs-io/cardano-node run
170+
```
171+
172+
With dynamic block forging enabled, you can control block production without restarting the node:
173+
174+
- **Enable block forging**: Ensure credential files are present and send SIGHUP
175+
```bash
176+
docker exec cardano-node pkill -SIGHUP cardano-node
177+
```
178+
179+
- **Disable block forging**: Move/rename credential files and send SIGHUP
180+
```bash
181+
docker exec cardano-node mv /opt/cardano/config/keys/kes.skey /opt/cardano/config/keys/kes.skey.disabled
182+
docker exec cardano-node pkill -SIGHUP cardano-node
183+
```
184+
185+
- **Re-enable block forging**: Restore credential files and send SIGHUP
186+
```bash
187+
docker exec cardano-node mv /opt/cardano/config/keys/kes.skey.disabled /opt/cardano/config/keys/kes.skey
188+
docker exec cardano-node pkill -SIGHUP cardano-node
189+
```
190+
151191
The above uses Docker's built in supervisor to restart a container which fails
152192
for any reason. This will also cause the container to automatically restart
153193
after a host reboot, so long as Docker is configured to start on boot. We
@@ -224,7 +264,12 @@ and operational certificate.
224264
`${CARDANO_CONFIG_BASE}/keys/vrf.skey`)
225265
- `CARDANO_SHELLEY_OPERATIONAL_CERTIFICATE`
226266
- Stake pool identity certificate (default:
227-
`${CARDANO_CONFIG_BASE}/keys/node.cert`
267+
`${CARDANO_CONFIG_BASE}/keys/node.cert`)
268+
- `START_AS_NON_PRODUCING`
269+
- Start block producer node in non-producing mode (default: `false`)
270+
- When set to `true`, adds the `--start-as-non-producing-node` flag
271+
- Only applies when `CARDANO_BLOCK_PRODUCER=true`
272+
- Enables dynamic block forging control via SIGHUP signals
228273

229274
#### Controlling Mithril snapshots
230275

bin/run-node

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ if [[ -z $GENESIS_VERIFICATION_KEY && -f $GENESIS_VERIFICATION_KEY_PATH ]]; then
7777
fi
7878
SNAPSHOT_DIGEST=${SNAPSHOT_DIGEST:-latest}
7979
RESTORE_SNAPSHOT=${RESTORE_SNAPSHOT:-true}
80+
START_AS_NON_PRODUCING=${START_AS_NON_PRODUCING:-false}
8081

8182
echo CARDANO_BIND_ADDR=${CARDANO_BIND_ADDR}
8283
echo CARDANO_BLOCK_PRODUCER=${CARDANO_BLOCK_PRODUCER}
@@ -88,6 +89,7 @@ echo CARDANO_PORT=${CARDANO_PORT}
8889
echo CARDANO_RTS_OPTS=${CARDANO_RTS_OPTS}
8990
echo CARDANO_SOCKET_PATH=${CARDANO_SOCKET_PATH}
9091
echo CARDANO_TOPOLOGY=${CARDANO_TOPOLOGY}
92+
echo START_AS_NON_PRODUCING=${START_AS_NON_PRODUCING}
9193

9294
# block producer only
9395
if [[ ${CARDANO_BLOCK_PRODUCER} == true ]]; then
@@ -164,6 +166,10 @@ if [[ ${CARDANO_BLOCK_PRODUCER} == true ]]; then
164166
--shelley-vrf-key ${CARDANO_SHELLEY_VRF_KEY} \
165167
--socket-path ${CARDANO_SOCKET_PATH} \
166168
--topology ${CARDANO_TOPOLOGY})
169+
# Add --start-as-non-producing-node flag if START_AS_NON_PRODUCING is true
170+
if [[ ${START_AS_NON_PRODUCING} == true ]]; then
171+
effopts+=(--start-as-non-producing-node)
172+
fi
167173
else
168174
effopts=(--config ${CARDANO_CONFIG} \
169175
--database-path ${CARDANO_DATABASE_PATH} \

0 commit comments

Comments
 (0)