Skip to content

Commit cb6b4ce

Browse files
committed
Makefile: update producer key filename, bp key generation target
Use new encrypted key file generator
1 parent b7947ea commit cb6b4ce

File tree

1 file changed

+24
-23
lines changed

1 file changed

+24
-23
lines changed

Makefile

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ PG_HOST ?= localhost
1515
PG_PORT ?= 5432
1616

1717
# Block producer configuration
18-
PRODUCER_KEY ?= ./openmina-workdir/producer-key
18+
PRODUCER_KEY_FILENAME ?= ./openmina-workdir/producer-key
1919
COINBASE_RECEIVER ?=
2020
OPENMINA_LIBP2P_EXTERNAL_IP ?=
2121
OPENMINA_LIBP2P_PORT ?= 8302
@@ -313,44 +313,45 @@ run-archive: build-release ## Run an archive node with local storage
313313

314314
.PHONY: run-block-producer
315315
run-block-producer: build-release ## Run a block producer node on $(NETWORK) network
316-
@if [ ! -f "$(PRODUCER_KEY)" ]; then \
317-
echo "Error: Producer key not found at $(PRODUCER_KEY)"; \
318-
echo "Please place your producer private key at $(PRODUCER_KEY)"; \
316+
@if [ ! -f "$(PRODUCER_KEY_FILENAME)" ]; then \
317+
echo "Error: Producer key not found at $(PRODUCER_KEY_FILENAME)"; \
318+
echo "Please place your producer private key at $(PRODUCER_KEY_FILENAME)"; \
319319
exit 1; \
320320
fi
321-
MINA_PRIVKEY_PASS="$(MINA_PRIVKEY_PASS)" \
322-
cargo run --bin openmina \
321+
cargo run \
322+
--bin openmina \
323+
--package=cli \
323324
--release -- \
324325
node \
325-
--producer-key $(PRODUCER_KEY) \
326+
--producer-key $(PRODUCER_KEY_FILENAME) \
326327
$(if $(COINBASE_RECEIVER),--coinbase-receiver $(COINBASE_RECEIVER)) \
327328
$(if $(OPENMINA_LIBP2P_EXTERNAL_IP),--libp2p-external-ip $(OPENMINA_LIBP2P_EXTERNAL_IP)) \
328329
$(if $(OPENMINA_LIBP2P_PORT),--libp2p-port $(OPENMINA_LIBP2P_PORT)) \
329330
--network $(NETWORK)
330331

331-
.PHONY: run-block-producer-devnet
332-
run-block-producer-devnet: ## Run a block producer node on devnet
333-
$(MAKE) run-block-producer NETWORK=devnet
334-
335-
.PHONY: run-block-producer-mainnet
336-
run-block-producer-mainnet: ## Run a block producer node on mainnet
337-
$(MAKE) run-block-producer NETWORK=mainnet
338332

339333
.PHONY: generate-block-producer-key
340-
generate-block-producer-key: build-release ## Generate a new block producer key pair
334+
generate-block-producer-key: build-release ## Generate a new block producer key pair (fails if keys exist, use PRODUCER_KEY_FILENAME to customize, MINA_PRIVKEY_PASS for password)
335+
@if [ -f "$(PRODUCER_KEY_FILENAME)" ]; then \
336+
echo "Error: Producer key already exists at $(PRODUCER_KEY_FILENAME)"; \
337+
echo ""; \
338+
echo "To generate a key with a different filename, set PRODUCER_KEY_FILENAME:"; \
339+
echo " make generate-block-producer-key PRODUCER_KEY_FILENAME=./path/to/new-key"; \
340+
echo ""; \
341+
echo "Or remove the existing key first to regenerate it."; \
342+
exit 1; \
343+
fi
341344
@mkdir -p openmina-workdir
342-
@echo "Generating new block producer key pair..."
343-
@OUTPUT=$$(cargo run --release --package=cli --bin openmina -- misc mina-key-pair); \
344-
SECRET_KEY=$$(echo "$$OUTPUT" | grep "secret key:" | cut -d' ' -f3); \
345+
@echo "Generating new encrypted block producer key..."
346+
@OUTPUT=$$($(if $(MINA_PRIVKEY_PASS),MINA_PRIVKEY_PASS="$(MINA_PRIVKEY_PASS)") cargo run --release --package=cli --bin openmina -- misc mina-encrypted-key --file $(PRODUCER_KEY_FILENAME)); \
345347
PUBLIC_KEY=$$(echo "$$OUTPUT" | grep "public key:" | cut -d' ' -f3); \
346-
echo "$$SECRET_KEY" > $(PRODUCER_KEY); \
347-
chmod 600 $(PRODUCER_KEY); \
348+
chmod 600 $(PRODUCER_KEY_FILENAME); \
348349
echo ""; \
349-
echo "✓ Generated new producer key pair:"; \
350-
echo " Secret key saved to: $(PRODUCER_KEY)"; \
350+
echo "✓ Generated new encrypted producer key:"; \
351+
echo " Encrypted key saved to: $(PRODUCER_KEY_FILENAME)"; \
351352
echo " Public key: $$PUBLIC_KEY"; \
352353
echo ""; \
353-
echo "⚠️ IMPORTANT: Keep your secret key secure and backed up!"
354+
echo "⚠️ IMPORTANT: Keep your encrypted key file and password secure and backed up!"
354355

355356
.PHONY: postgres-clean
356357
postgres-clean:

0 commit comments

Comments
 (0)