forked from 0xMiden/node
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
178 lines (134 loc) · 7.32 KB
/
Makefile
File metadata and controls
178 lines (134 loc) · 7.32 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
.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"
BUILD_PROTO=BUILD_PROTO=1
CONTAINER_RUNTIME ?= docker
STRESS_TEST_DATA_DIR ?= stress-test-store-$(shell date +%Y%m%d-%H%M%S)
# -- 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: machete
machete: ## Runs machete to find unused dependencies
cargo machete
.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 machete ## Runs all linting tasks at once (Clippy, fixing, formatting, machete)
# --- 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
${BUILD_PROTO} 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
${BUILD_PROTO} cargo build --locked --workspace
${BUILD_PROTO} 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
${BUILD_PROTO} cargo install --path bin/node --locked
.PHONY: install-remote-prover
install-remote-prover: ## Install remote prover's CLI
$(BUILD_PROTO) cargo install --path bin/remote-prover --bin miden-remote-prover --locked
.PHONY: stress-test-smoke
stress-test: ## Runs stress-test benchmarks
${BUILD_PROTO} 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: docker-build-node
docker-build-node: ## Builds the Miden node using Docker (override with CONTAINER_RUNTIME=podman)
@CREATED=$$(date) && \
VERSION=$$(cat bin/node/Cargo.toml | grep -m 1 '^version' | cut -d '"' -f 2) && \
COMMIT=$$(git rev-parse HEAD) && \
$(CONTAINER_RUNTIME) build --build-arg CREATED="$$CREATED" \
--build-arg VERSION="$$VERSION" \
--build-arg COMMIT="$$COMMIT" \
-f bin/node/Dockerfile \
-t miden-node-image .
.PHONY: docker-run-node
docker-run-node: ## Runs the Miden node as a Docker container (override with CONTAINER_RUNTIME=podman)
$(CONTAINER_RUNTIME) volume create miden-db
$(CONTAINER_RUNTIME) run --name miden-node \
-p 57291:57291 \
-v miden-db:/db \
-d miden-node-image
## --- 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-machete >/dev/null 2>&1 && echo "[OK] cargo-machete is installed" || echo "[MISSING] cargo-machete (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-machete --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!"