-
Notifications
You must be signed in to change notification settings - Fork 35
/
Copy pathMakefile
188 lines (137 loc) · 7.9 KB
/
Makefile
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
.DEFAULT_GOAL := help
.PHONY: help
help: ## Show description of all commands
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
# --- Variables -----------------------------------------------------------------------------------
# Enable file generation in the `src` directory.
# This is used in the build script of the client to generate the node RPC-related code, from the
# protobuf files.
CODEGEN=CODEGEN=1
FEATURES_WEB_CLIENT=--features "testing"
FEATURES_CLIENT=--features "testing, concurrent" --no-default-features
FEATURES_CLI=--features "concurrent"
WARNINGS=RUSTDOCFLAGS="-D warnings"
NODE_DIR="miden-node"
NODE_REPO="https://github.com/0xPolygonMiden/miden-node.git"
NODE_BRANCH="main"
PROVER_DIR="miden-base"
PROVER_REPO="https://github.com/0xPolygonMiden/miden-base.git"
PROVER_BRANCH="main"
PROVER_FEATURES_TESTING=--features "testing"
PROVER_PORT=50051
# --- Linting -------------------------------------------------------------------------------------
.PHONY: clippy
clippy: ## Run Clippy with configs
cargo clippy --workspace --exclude miden-client-web --all-targets $(FEATURES_CLI) -- -D warnings
.PHONY: clippy-wasm
clippy-wasm: ## Run Clippy for the miden-client-web package
cargo clippy --package miden-client-web --target wasm32-unknown-unknown --all-targets $(FEATURES_WEB_CLIENT) -- -D warnings
.PHONY: fix
fix: ## Run Fix with configs
cargo +nightly fix --workspace --exclude miden-client-web --allow-staged --allow-dirty --all-targets $(FEATURES_CLI)
.PHONY: fix-wasm
fix-wasm: ## Run Fix for the miden-client-web package
cargo +nightly fix --package miden-client-web --target wasm32-unknown-unknown --allow-staged --allow-dirty --all-targets $(FEATURES_WEB_CLIENT)
.PHONY: format
format: ## Run format using nightly toolchain
cargo +nightly fmt --all && yarn prettier . --write
.PHONY: format-check
format-check: ## Run format using nightly toolchain but only in check mode
cargo +nightly fmt --all --check && yarn prettier . --check
.PHONY: lint
lint: format fix clippy fix-wasm clippy-wasm ## Run all linting tasks at once (clippy, fixing, formatting)
# --- Documentation site --------------------------------------------------------------------------
.PHONY: doc-deps
doc-deps: ## Install dependencies to build and serve documentation site
pip3 install -r scripts/docs_requirements.txt
.PHONY: doc-build
doc-build: doc-deps ## Build documentation site
mkdocs build
.PHONY: doc-serve
doc-serve: doc-deps ## Serve documentation site
mkdocs serve
# --- Rust documentation --------------------------------------------------------------------------
.PHONY: doc
doc: ## Generate & check rust documentation. You'll need `jq` in order for this to run.
@cd crates/rust-client && \
FEATURES=$$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[] | select(.name == "miden-client") | .features | keys[] | select(. != "web-tonic" and . != "idxdb")' | tr '\n' ',') && \
RUSTDOCFLAGS="-D warnings" cargo doc --no-deps --features "$$FEATURES" --keep-going --release
# --- Testing -------------------------------------------------------------------------------------
.PHONY: test
test: ## Run tests
$(CODEGEN) cargo nextest run --workspace --exclude miden-client-web --release --lib $(FEATURES_CLIENT)
.PHONY: test-deps
test-deps: ## Install dependencies for tests
$(CODEGEN) cargo install cargo-nextest
.PHONY: test-docs
test-docs: ## Run documentation tests
$(CODEGEN) cargo test --doc $(FEATURES_CLIENT)
# --- Integration testing -------------------------------------------------------------------------
.PHONY: integration-test
integration-test: ## Run integration tests
$(CODEGEN) cargo nextest run --workspace --exclude miden-client-web --release --test=integration $(FEATURES_CLI)
.PHONY: integration-test-web-client
integration-test-web-client: ## Run integration tests for the web client
$(CODEGEN) cd ./crates/web-client && npm run test:clean
.PHONY: integration-test-remote-prover-web-client
integration-test-remote-prover-web-client: ## Run integration tests for the web client with remote prover
$(CODEGEN) cd ./crates/web-client && npm run test:remote_prover
.PHONY: integration-test-full
integration-test-full: ## Run the integration test binary with ignored tests included
$(CODEGEN) cargo nextest run --workspace --exclude miden-client-web --release --test=integration $(FEATURES_CLI)
cargo nextest run --workspace --exclude miden-client-web --release --test=integration $(FEATURES_CLI) --run-ignored ignored-only -- test_import_genesis_accounts_can_be_used_for_transactions
.PHONY: kill-node
kill-node: ## Kill node process
pkill miden-node || echo 'process not running'
.PHONY: clean-node
clean-node: ## Clean node directory
rm -rf miden-node
.PHONY: node
node: setup-miden-node update-node-branch build-node ## Setup node directory
.PHONY: setup-miden-node
setup-miden-node: ## Clone the miden-node repository if it doesn't exist
if [ ! -d $(NODE_DIR) ]; then git clone $(NODE_REPO) $(NODE_DIR); fi
.PHONY: update-node-branch
update-node-branch: setup-miden-base ## Checkout and update the specified branch in miden-node
cd $(NODE_DIR) && git checkout $(NODE_BRANCH) && git pull origin $(NODE_BRANCH)
.PHONY: build-node
build-node: update-node-branch ## Update dependencies and build the node binary with specified features
cd $(NODE_DIR) && rm -rf miden-store.sqlite3* && cargo run --locked --bin miden-node -- make-genesis --inputs-path ../tests/config/genesis.toml --force
.PHONY: start-node
start-node: ## Run node. This requires the node repo to be present at `miden-node`
cd miden-node && cargo run --bin miden-node $(NODE_FEATURES_TESTING) --locked -- start --config ../tests/config/miden-node.toml node
.PHONY: clean-prover
clean-prover: ## Uninstall prover
cargo uninstall miden-proving-service || echo 'prover not installed'
.PHONY: prover
prover: setup-miden-base update-prover-branch build-prover ## Setup prover directory
.PHONY: setup-miden-base
setup-miden-base: ## Clone the miden-base repository if it doesn't exist
if [ ! -d $(PROVER_DIR) ]; then git clone $(PROVER_REPO) $(PROVER_DIR); fi
.PHONY: update-prover-branch
update-prover-branch: setup-miden-base ## Checkout and update the specified branch in miden-base
cd $(PROVER_DIR) && git checkout $(PROVER_BRANCH) && git pull origin $(PROVER_BRANCH)
.PHONY: build-prover
build-prover: update-prover-branch ## Update dependencies and build the prover binary with specified features
cd $(PROVER_DIR) && cargo update && cargo build --bin miden-proving-service --locked $(PROVER_FEATURES_TESTING) --release
.PHONY: start-prover
start-prover: ## Run prover. This requires the base repo to be present at `miden-base`
cd $(PROVER_DIR) && RUST_LOG=info cargo run --bin miden-proving-service $(PROVER_FEATURES_TESTING) --release --locked -- start-worker -p $(PROVER_PORT)
.PHONY: kill-prover
kill-prover: ## Kill prover process
pkill miden-tx-prover || echo 'process not running'
# --- Installing ----------------------------------------------------------------------------------
install: ## Install the CLI binary
cargo install $(FEATURES_CLI) --path bin/miden-cli --locked
# --- Building ------------------------------------------------------------------------------------
build: ## Build the CLI binary and client library in release mode
CODEGEN=1 cargo build --workspace --exclude miden-client-web --release $(FEATURES_CLI)
build-wasm: ## Build the client library for wasm32
CODEGEN=1 cargo build --package miden-client-web --target wasm32-unknown-unknown $(FEATURES_WEB_CLIENT)
# --- Check ---------------------------------------------------------------------------------------
.PHONY: check
check: ## Build the CLI binary and client library in release mode
cargo check --workspace --exclude miden-client-web --release $(FEATURES_CLI)
.PHONY: check-wasm
check-wasm: ## Build the client library for wasm32
cargo check --package miden-client-web --target wasm32-unknown-unknown $(FEATURES_WEB_CLIENT)