-
Notifications
You must be signed in to change notification settings - Fork 119
Expand file tree
/
Copy pathMakefile
More file actions
266 lines (207 loc) · 11.2 KB
/
Makefile
File metadata and controls
266 lines (207 loc) · 11.2 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
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
.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
CONFIG_DIR = .config
README_FILES = $(shell git ls-files '*README.md')
PRETTIER_CONFIG = $(CONFIG_DIR)/prettier.json
PRETTIER_LOG_LEVEL = warn
PRETTIER_VERSION ?= 3.8.3
MARKDOWNLINT_CONFIG = $(CONFIG_DIR)/markdownlint-cli2.yaml
MARKDOWNLINT_CLI2_VERSION ?= 0.22.1
RUSTFMT_CONFIG = $(CONFIG_DIR)/rustfmt.toml
TAPLO_CONFIG = $(CONFIG_DIR)/taplo.toml
# -- 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: markdown-format ## Runs rustfmt, README formatting, and comment reflow
cargo xtask fmt-comments --write --rustfmt-config $(RUSTFMT_CONFIG)
cargo +nightly fmt --all -- --config-path $(RUSTFMT_CONFIG)
.PHONY: format-check
format-check: markdown-format-check ## Checks rustfmt, README formatting, and comment reflow
cargo xtask fmt-comments --check --rustfmt-config $(RUSTFMT_CONFIG)
cargo +nightly fmt --all --check -- --config-path $(RUSTFMT_CONFIG)
.PHONY: markdown-format
markdown-format: ## Formats README Markdown files
@prettier --config $(PRETTIER_CONFIG) --log-level $(PRETTIER_LOG_LEVEL) --write $(README_FILES)
.PHONY: markdown-format-check
markdown-format-check: ## Checks README Markdown formatting
@prettier --config $(PRETTIER_CONFIG) --log-level $(PRETTIER_LOG_LEVEL) --check $(README_FILES)
.PHONY: markdown-lint
markdown-lint: ## Lints README Markdown files
markdownlint-cli2 --config $(MARKDOWNLINT_CONFIG) $(README_FILES)
.PHONY: shear
shear: ## Runs cargo-shear to find unused or misplaced dependencies
cargo shear --check-test-targets --deny-warnings
.PHONY: toml
toml: ## Runs Format for all TOML files
taplo fmt --config $(TAPLO_CONFIG)
.PHONY: toml-check
toml-check: ## Runs Format for all TOML files but only in check mode
taplo fmt --config $(TAPLO_CONFIG) --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 markdown-lint fix clippy toml shear ## Runs all linting tasks at once (Clippy, formatting, Markdown, 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-ntx-builder
install-ntx-builder: ## Installs ntx-builder
cargo install --path bin/ntx-builder --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-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 --remove-orphans
.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)"
@command -v prettier >/dev/null 2>&1 && echo "[OK] prettier is installed" || echo "[MISSING] prettier is not installed (run: make install-tools)"
@command -v markdownlint-cli2 >/dev/null 2>&1 && echo "[OK] markdownlint-cli2 is installed" || echo "[MISSING] markdownlint-cli2 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.12.4 --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
npm install --global prettier@$(PRETTIER_VERSION) markdownlint-cli2@$(MARKDOWNLINT_CLI2_VERSION)
@echo "Development tools installation complete!"