forked from 0xMiden/node
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
240 lines (187 loc) · 9.79 KB
/
Makefile
File metadata and controls
240 lines (187 loc) · 9.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
.DEFAULT_GOAL := help
.PHONY: help
help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
# -- variables ------------------------------------------------------------------------------------
WARNINGS=RUSTDOCFLAGS="-D warnings"
STRESS_TEST_DATA_DIR ?= stress-test-store-$(shell date +%Y%m%d-%H%M%S)
COMPOSE_FILES = -f docker-compose.yml -f compose/telemetry.yml -f compose/monitor.yml
# -- linting --------------------------------------------------------------------------------------
.PHONY: clippy
clippy: ## Runs Clippy with configs
cargo clippy --locked --all-targets --all-features --workspace -- -D warnings
cargo clippy --locked --all-targets --all-features -p miden-remote-prover -- -D warnings
cargo clippy --locked -p miden-remote-prover-client --target wasm32-unknown-unknown --no-default-features --features batch-prover,block-prover,tx-prover -- -D warnings
.PHONY: fix
fix: ## Runs Fix with configs
cargo fix --allow-staged --allow-dirty --all-targets --all-features --workspace
cargo fix --allow-staged --allow-dirty --all-targets --all-features -p miden-remote-prover
.PHONY: format
format: ## Runs Format using nightly toolchain
cargo +nightly fmt --all
.PHONY: format-check
format-check: ## Runs Format using nightly toolchain but only in check mode
cargo +nightly fmt --all --check
.PHONY: shear
shear: ## Runs cargo-shear to find unused or misplaced dependencies
cargo shear
.PHONY: toml
toml: ## Runs Format for all TOML files
taplo fmt
.PHONY: toml-check
toml-check: ## Runs Format for all TOML files but only in check mode
taplo fmt --check --verbose
.PHONY: typos-check
typos-check: ## Runs spellchecker
typos
.PHONY: workspace-check
workspace-check: ## Runs a check that all packages have `lints.workspace = true`
cargo workspace-lints
.PHONY: lint
lint: typos-check format fix clippy toml shear ## Runs all linting tasks at once (Clippy, fixing, formatting, cargo-shear)
# --- docs ----------------------------------------------------------------------------------------
.PHONY: doc
doc: ## Generates & checks documentation
$(WARNINGS) cargo doc --all-features --keep-going --release --locked
.PHONY: book
book: ## Builds the book & serves documentation site
mdbook serve --open docs/internal
.PHONY: serve-docs
serve-docs: ## Serves the docs
cd docs/external && npm run start:dev
# --- testing -------------------------------------------------------------------------------------
.PHONY: test
test: ## Runs all tests
cargo nextest run --all-features --workspace
# --- checking ------------------------------------------------------------------------------------
.PHONY: check
check: ## Check all targets and features for errors without code generation
cargo check --all-features --all-targets --locked --workspace
.PHONY: check-features
check-features: ## Checks all feature combinations compile without warnings using cargo-hack
@scripts/check-features.sh
# --- building ------------------------------------------------------------------------------------
.PHONY: build
build: ## Builds all crates and re-builds protobuf bindings for proto crates
cargo build --locked --workspace
cargo build --locked -p miden-remote-prover-client --target wasm32-unknown-unknown --no-default-features --features batch-prover,block-prover,tx-prover # no-std compatible build
# --- installing ----------------------------------------------------------------------------------
.PHONY: install-node
install-node: ## Installs node
cargo install --path bin/node --locked
.PHONY: install-validator
install-validator: ## Installs validator
cargo install --path bin/validator --locked
.PHONY: install-remote-prover
install-remote-prover: ## Install remote prover's CLI
cargo install --path bin/remote-prover --bin miden-remote-prover --locked
.PHONY: stress-test-smoke
stress-test: ## Runs stress-test benchmarks
cargo build --release --locked -p miden-node-stress-test
@mkdir -p $(STRESS_TEST_DATA_DIR)
./target/release/miden-node-stress-test seed-store --data-directory $(STRESS_TEST_DATA_DIR) --num-accounts 500 --public-accounts-percentage 50
./target/release/miden-node-stress-test benchmark-store --data-directory $(STRESS_TEST_DATA_DIR) --iterations 10 --concurrency 1 sync-state
./target/release/miden-node-stress-test benchmark-store --data-directory $(STRESS_TEST_DATA_DIR) --iterations 10 --concurrency 1 sync-notes
./target/release/miden-node-stress-test benchmark-store --data-directory $(STRESS_TEST_DATA_DIR) --iterations 10 --concurrency 1 sync-nullifiers --prefixes 10
.PHONY: install-stress-test
install-stress-test: ## Installs stress-test binary
cargo install --path bin/stress-test --locked
.PHONY: install-network-monitor
install-network-monitor: ## Installs network monitor binary
cargo install --path bin/network-monitor --locked
# --- docker --------------------------------------------------------------------------------------
.PHONY: compose-genesis
compose-genesis: ## Wipes node volumes and creates a fresh genesis block
docker compose $(COMPOSE_FILES) down --volumes --remove-orphans
docker volume rm -f miden-node_node-data
docker compose $(COMPOSE_FILES) --profile genesis run --rm genesis-store
docker compose $(COMPOSE_FILES) --profile genesis rm -f
.PHONY: compose-up
compose-up: ## Starts all node components, telemetry, and monitor via docker compose
docker compose $(COMPOSE_FILES) up -d
.PHONY: compose-down
compose-down: ## Stops and removes all containers via docker compose
docker compose $(COMPOSE_FILES) down
.PHONY: compose-logs
compose-logs: ## Follows logs for all components via docker compose
docker compose $(COMPOSE_FILES) logs -f
.PHONY: docker-build
docker-build: docker-build-node docker-build-validator docker-build-ntx-builder docker-build-monitor ## Builds all Docker images
.PHONY: docker-build-node
docker-build-node: ## Builds the Miden node using Docker
@CREATED=$$(date) && \
VERSION=$$(cat bin/node/Cargo.toml | grep -m 1 '^version' | cut -d '"' -f 2) && \
COMMIT=$$(git rev-parse HEAD) && \
docker build --build-arg CREATED="$$CREATED" \
--build-arg VERSION="$$VERSION" \
--build-arg COMMIT="$$COMMIT" \
--build-arg BIN=miden-node \
--build-arg PORT=57291 \
-t miden-node .
.PHONY: docker-build-validator
docker-build-validator: ## Builds the Miden validator using Docker
@CREATED=$$(date) && \
VERSION=$$(cat bin/validator/Cargo.toml | grep -m 1 '^version' | cut -d '"' -f 2) && \
COMMIT=$$(git rev-parse HEAD) && \
docker build --build-arg CREATED="$$CREATED" \
--build-arg VERSION="$$VERSION" \
--build-arg COMMIT="$$COMMIT" \
--build-arg BIN=miden-validator \
--build-arg PORT=50101 \
-t miden-validator .
.PHONY: docker-build-ntx-builder
docker-build-ntx-builder: ## Builds the Miden network transaction builder using Docker
@CREATED=$$(date) && \
VERSION=$$(cat bin/ntx-builder/Cargo.toml | grep -m 1 '^version' | cut -d '"' -f 2) && \
COMMIT=$$(git rev-parse HEAD) && \
docker build --build-arg CREATED="$$CREATED" \
--build-arg VERSION="$$VERSION" \
--build-arg COMMIT="$$COMMIT" \
--build-arg BIN=miden-ntx-builder \
--build-arg PORT=50301 \
-t miden-ntx-builder .
.PHONY: docker-build-monitor
docker-build-monitor: ## Builds the network monitor using Docker
@CREATED=$$(date) && \
VERSION=$$(cat bin/network-monitor/Cargo.toml | grep -m 1 '^version' | cut -d '"' -f 2) && \
COMMIT=$$(git rev-parse HEAD) && \
docker build --build-arg CREATED="$$CREATED" \
--build-arg VERSION="$$VERSION" \
--build-arg COMMIT="$$COMMIT" \
--build-arg BIN=miden-network-monitor \
--build-arg PORT=3000 \
-t miden-network-monitor .
.PHONY: docker-run-node
docker-run-node: ## Runs the Miden node as a Docker container
docker volume create miden-db
docker run --name miden-node \
-p 57291:57291 \
-v miden-db:/db \
-d miden-node
## --- setup --------------------------------------------------------------------------------------
.PHONY: check-tools
check-tools: ## Checks if development tools are installed
@echo "Checking development tools..."
@command -v mdbook >/dev/null 2>&1 && echo "[OK] mdbook is installed" || echo "[MISSING] mdbook (make install-tools)"
@command -v typos >/dev/null 2>&1 && echo "[OK] typos is installed" || echo "[MISSING] typos (make install-tools)"
@command -v cargo nextest >/dev/null 2>&1 && echo "[OK] cargo-nextest is installed" || echo "[MISSING] cargo-nextest(make install-tools)"
@command -v taplo >/dev/null 2>&1 && echo "[OK] taplo is installed" || echo "[MISSING] taplo (make install-tools)"
@command -v cargo-shear >/dev/null 2>&1 && echo "[OK] cargo-shear is installed" || echo "[MISSING] cargo-shear is not installed (run: make install-tools)"
@command -v npm >/dev/null 2>&1 && echo "[OK] npm is installed" || echo "[MISSING] npm is not installed (run: make install-tools)"
.PHONY: install-tools
install-tools: ## Installs tools required by the Makefile
@echo "Installing development tools..."
# Rust-related
cargo install mdbook --locked
cargo install typos-cli --locked
cargo install cargo-nextest --locked
cargo install taplo-cli --locked
cargo install cargo-shear --version 1.11.2 --locked
@if ! command -v node >/dev/null 2>&1; then \
echo "Node.js not found. Please install Node.js from https://nodejs.org/ or using your package manager"; \
echo "On macOS: brew install node"; \
echo "On Ubuntu/Debian: sudo apt install nodejs npm"; \
echo "On Windows: Download from https://nodejs.org/"; \
exit 1; \
fi
@echo "Development tools installation complete!"