forked from 0xMiden/crypto
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
208 lines (152 loc) · 8.07 KB
/
Makefile
File metadata and controls
208 lines (152 loc) · 8.07 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
.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 --------------------------------------------------------------------------------------
ALL_FEATURES_EXCEPT_ROCKSDB="concurrent executable internal serde std"
WARNINGS=RUSTDOCFLAGS="-D warnings"
# -- linting --------------------------------------------------------------------------------------
.PHONY: clippy
clippy: ## Run Clippy with configs
cargo clippy --workspace --all-targets --all-features -- -D warnings
.PHONY: fix
fix: ## Run Fix with configs
cargo +nightly fix --allow-staged --allow-dirty --all-targets --all-features
.PHONY: format
format: ## Run Format using nightly toolchain
cargo +nightly fmt --all
.PHONY: format-check
format-check: ## Run 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: cargo-deny
cargo-deny: ## Run cargo-deny to check dependencies for security vulnerabilities and license compliance
cargo deny check
.PHONY: zeroize-audit
zeroize-audit: ## Run Zeroize audit using rustdoc JSON
cargo +nightly rustdoc -p miden-crypto --all-features -- -Zunstable-options --output-format json --document-private-items
cargo run --quiet --manifest-path tools/zeroize-audit/Cargo.toml -- target/doc/miden_crypto.json
.PHONY: lint
lint: format fix clippy toml typos-check machete cargo-deny ## Run all linting tasks at once (Clippy, fixing, formatting, machete, cargo-deny)
# --- docs ----------------------------------------------------------------------------------------
.PHONY: doc
doc: ## Generate and check documentation for workspace crates only
rm -rf "${CARGO_TARGET_DIR:-target}/doc"
RUSTDOCFLAGS="--enable-index-page -Zunstable-options -D warnings" cargo +nightly doc --all-features --keep-going --release --no-deps
# --- testing -------------------------------------------------------------------------------------
.PHONY: test-default
test-default: ## Run tests with default features
cargo nextest run --profile default --cargo-profile test-release --features ${ALL_FEATURES_EXCEPT_ROCKSDB}
.PHONY: test-no-std
test-no-std: ## Run tests with `no-default-features` (std)
cargo nextest run --profile default --cargo-profile test-release --no-default-features
.PHONY: test-smt-concurrent
test-smt-concurrent: ## Run only concurrent SMT tests
cargo nextest run --profile smt-concurrent --cargo-profile test-release
.PHONY: test-docs
test-docs:
cargo test --doc --all-features --profile test-release
.PHONY: test-large-smt
test-large-smt: ## Run only large SMT tests
cargo nextest run --success-output immediate --profile large-smt --cargo-profile test-release --features rocksdb
.PHONY: test
test: test-default test-no-std test-docs test-large-smt ## Run all tests except concurrent SMT tests
# --- checking ------------------------------------------------------------------------------------
.PHONY: check
check: ## Check all targets and features for errors without code generation
cargo check --all-targets --all-features
.PHONY: check-fuzz
check-fuzz: ## Check miden-crypto-fuzz compilation
cd miden-crypto-fuzz && cargo check
# --- building ------------------------------------------------------------------------------------
.PHONY: build
build: ## Build with default features enabled
cargo build --release
.PHONY: build-no-std
build-no-std: ## Build without the standard library
cargo build --release --no-default-features --target wasm32-unknown-unknown
.PHONY: build-target-miden
build-target-miden: ## Build `miden-field` for wasm32-wasip2 with `--cfg miden`
RUSTFLAGS="$${RUSTFLAGS:+$$RUSTFLAGS }--cfg miden" cargo build --release -p miden-field --target wasm32-wasip2
.PHONY: build-avx2
build-avx2: ## Build with avx2 support
RUSTFLAGS="-C target-feature=+avx2" cargo build --release
.PHONY: build-avx512
build-avx512: ## Build with avx512 support
RUSTFLAGS="-C target-feature=+avx512f,+avx512dq" cargo build --release
.PHONY: build-sve
build-sve: ## Build with sve support
RUSTFLAGS="-C target-feature=+sve" cargo build --release
# --- benchmarking --------------------------------------------------------------------------------
.PHONY: bench
bench: ## Run crypto benchmarks
cargo bench --features concurrent
.PHONY: bench-smt-concurrent
bench-smt-concurrent: ## Run SMT benchmarks with concurrent feature
cargo run --release --features concurrent,executable -- --size 1000000
.PHONY: bench-large-smt-memory
bench-large-smt-memory: ## Run large SMT benchmarks with memory storage
cargo run --release --features concurrent,executable -- --size 1000000
.PHONY: bench-large-smt-rocksdb
bench-large-smt-rocksdb: ## Run large SMT benchmarks with rocksdb storage
cargo run --release --features concurrent,rocksdb,executable -- --storage rocksdb --size 1000000
.PHONY: bench-large-smt-rocksdb-open
bench-large-smt-rocksdb-open: ## Run large SMT benchmarks with rocksdb storage and open existing database
cargo run --release --features concurrent,rocksdb,executable -- --storage rocksdb --open
# --- fuzzing --------------------------------------------------------------------------------
.PHONY: fuzz-smt
fuzz-smt: ## Run fuzzing for SMT (sequential vs parallel consistency)
cargo +nightly fuzz run smt --release --fuzz-dir miden-crypto-fuzz -- -max_len=10485760
.PHONY: fuzz-word
fuzz-word: ## Run fuzzing for Word serialization
cargo +nightly fuzz run word --release --fuzz-dir miden-crypto-fuzz
.PHONY: fuzz-merkle
fuzz-merkle: ## Run fuzzing for Merkle tree serialization
cargo +nightly fuzz run merkle --release --fuzz-dir miden-crypto-fuzz
.PHONY: fuzz-smt-serde
fuzz-smt-serde: ## Run fuzzing for SMT serialization
cargo +nightly fuzz run smt_serde --release --fuzz-dir miden-crypto-fuzz
.PHONY: fuzz-mmr
fuzz-mmr: ## Run fuzzing for MMR structures serialization
cargo +nightly fuzz run mmr --release --fuzz-dir miden-crypto-fuzz
.PHONY: fuzz-crypto
fuzz-crypto: ## Run fuzzing for cryptographic types serialization
cargo +nightly fuzz run crypto --release --fuzz-dir miden-crypto-fuzz
.PHONY: fuzz-aead
fuzz-aead: ## Run fuzzing for AEAD decryption paths
cargo +nightly fuzz run aead --release --fuzz-dir miden-crypto-fuzz
.PHONY: fuzz-signatures
fuzz-signatures: ## Run fuzzing for DSA signature deserialization
cargo +nightly fuzz run signatures --release --fuzz-dir miden-crypto-fuzz
# --- installing ----------------------------------------------------------------------------------
.PHONY: check-tools
check-tools: ## Checks if development tools are installed
@echo "Checking development tools..."
@command -v typos >/dev/null 2>&1 && echo "[OK] typos is installed" || echo "[MISSING] typos is not installed (run: make install-tools)"
@command -v cargo nextest >/dev/null 2>&1 && echo "[OK] nextest is installed" || echo "[MISSING] nextest is not installed (run: make install-tools)"
@command -v taplo >/dev/null 2>&1 && echo "[OK] taplo is installed" || echo "[MISSING] taplo is not installed (run: make install-tools)"
@command -v cargo machete >/dev/null 2>&1 && echo "[OK] machete is installed" || echo "[MISSING] machete is not installed (run: make install-tools)"
@command -v cargo deny >/dev/null 2>&1 && echo "[OK] cargo-deny is installed" || echo "[MISSING] cargo-deny is not installed (run: make install-tools)"
.PHONY: install-tools
install-tools: ## Installs development tools required by the Makefile (typos, nextest, taplo, machete, cargo-deny)
@echo "Installing development tools..."
cargo install typos-cli --locked
cargo install cargo-nextest --locked
cargo install taplo-cli --locked
cargo install cargo-machete --locked
cargo install cargo-deny --locked
@echo "Development tools installation complete!"