Skip to content

Commit aa9028a

Browse files
authored
Merge pull request #1203 from o1-labs/dw/makefile-target-archive
Makefile: add target to run an archive node
2 parents 9507c50 + ab5168f commit aa9028a

File tree

1 file changed

+43
-2
lines changed

1 file changed

+43
-2
lines changed

Makefile

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,23 @@
11
# OpenMina Makefile
22

3+
# Rust
34
NIGHTLY_RUST_VERSION = "nightly"
45

6+
# Docker
7+
DOCKER_ORG ?= openmina
8+
9+
# PostgreSQL configuration for archive node
10+
OPEN_ARCHIVE_ADDRESS ?= http://localhost:3007
11+
PG_USER ?= openmina
12+
PG_PW ?= openminaopenmina
13+
PG_DB ?= openmina_archive
14+
PG_HOST ?= localhost
15+
PG_PORT ?= 5432
16+
17+
# Utilities
18+
NETWORK ?= devnet
19+
GIT_COMMIT := $(shell git rev-parse --short=8 HEAD)
20+
521
.PHONY: help
622
help: ## Ask for help!
723
@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
@@ -157,8 +173,6 @@ test-vrf: ## Run VRF tests, requires nightly Rust
157173
@cd vrf && cargo +nightly test --release -- -Z unstable-options --report-time
158174

159175
# Docker build targets
160-
DOCKER_ORG ?= openmina
161-
GIT_COMMIT := $(shell git rev-parse --short=8 HEAD)
162176

163177
.PHONY: docker-build-all
164178
docker-build-all: docker-build-bootstrap-sandbox docker-build-debugger \
@@ -218,3 +232,30 @@ docker-build-producer-dashboard: ## Build producer dashboard Docker image
218232
docker-build-test: ## Build test Docker image
219233
docker build -t $(DOCKER_ORG)/openmina-test:$(GIT_COMMIT) \
220234
-f node/testing/docker/Dockerfile.test node/testing/docker/
235+
236+
# Postgres related targets + archive node
237+
.PHONY: run-archive
238+
run-archive: build-release ## Run an archive node with local storage
239+
OPENMINA_ARCHIVE_ADDRESS=$(OPENMINA_ARCHIVE_ADDRESS) \
240+
cargo run --bin openmina \
241+
--release -- \
242+
node \
243+
--archive-archiver-process \
244+
--archive-local-storage
245+
--network $(NETWORK)
246+
247+
.PHONY: postgres-clean
248+
postgres-clean:
249+
@echo "Dropping DB: ${PG_DB} and user: ${PG_USER}"
250+
@sudo -u postgres psql -c "DROP DATABASE IF EXISTS ${PG_DB}"
251+
@sudo -u postgres psql -c "DROP DATABASE IF EXISTS ${PG_USER}"
252+
@sudo -u postgres psql -c "DROP ROLE IF EXISTS ${PG_USER}"
253+
@echo "Cleanup complete."
254+
255+
.PHONY: postgres-setup
256+
postgres-setup: ## Set up PostgreSQL database for archive node
257+
@echo "Setting up PostgreSQL database: ${PG_DB} with user: ${PG_USER}"
258+
@sudo -u postgres createuser -d -r -s $(PG_USER) 2>/dev/null || true
259+
@sudo -u postgres psql -c "ALTER USER $(PG_USER) PASSWORD '$(PG_PW)'" 2>/dev/null || true
260+
@sudo -u postgres createdb -O $(PG_USER) $(PG_DB) 2>/dev/null || true
261+
@sudo -u postgres createdb -O $(PG_USER) $(PG_USER) 2>/dev/null || true

0 commit comments

Comments
 (0)