-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
137 lines (104 loc) · 5.12 KB
/
Copy pathMakefile
File metadata and controls
137 lines (104 loc) · 5.12 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
# ==============================================================
# balddev DAO Voting Program — Makefile
# ==============================================================
#
# Common targets:
# make build — compile BPF/SBF program via Anchor
# make test — run Anchor test suite
# make verify — run all 34 Kani harnesses
# make fmt — format Rust source
# make lint — Clippy (deny warnings)
# make clean — remove build artefacts
# make docker-build — build Docker images
# make docker-test — run tests inside Docker
# make docker-verify — run Kani inside Docker
# make help — list annotated targets
# ==============================================================
.PHONY: all build build-size test test-skip-validator \
verify verify-quick verify-list verify-one \
fmt fmt-check lint clean \
docker-build docker-build-program docker-test docker-verify \
docker-localnet docker-down \
deploy-devnet deploy-mainnet id help
PROGRAM_ID := Cz7vK7QDJ8MYVUsgYxvEudXEZbAFqGYfzPuhUS5RWKjm
KANI_DIR := kani_verification
SO_FILE := target/deploy/balddev_dao_voting.so
# ── Build ──────────────────────────────────────────────────────────────────
all: build
## Compile the Anchor program (BPF/SBF target)
build:
anchor build
## Build and display compiled .so size
build-size: build
@ls -lh $(SO_FILE)
# ── Test ───────────────────────────────────────────────────────────────────
## Run Anchor test suite (starts/stops a local validator automatically)
test:
anchor test
## Run test suite against an already-running local validator
test-skip-validator:
anchor test --skip-local-validator
# ── Kani formal verification ───────────────────────────────────────────────
## Run all 34 harnesses — full unbounded proof (slow, exhaustive)
verify:
cd $(KANI_DIR) && ./verify.sh
## Run all harnesses with --default-unwind 4 (fast bounded check)
verify-quick:
cd $(KANI_DIR) && ./verify.sh --quick
## List all harness names
verify-list:
cd $(KANI_DIR) && ./verify.sh --list
## Run a single named harness: make verify-one HARNESS=prove_threshold_zero_now_rejected
verify-one:
@test -n "$(HARNESS)" || (echo "Usage: make verify-one HARNESS=<harness_name>" && exit 1)
cd $(KANI_DIR) && ./verify.sh --harness $(HARNESS)
# ── Code quality ───────────────────────────────────────────────────────────
## Format all Rust source in-place
fmt:
cargo fmt --all
## Check formatting without writing (CI mode)
fmt-check:
cargo fmt --all -- --check
## Clippy across all targets, deny warnings
lint:
cargo clippy --all-targets -- -D warnings
# ── Cleanup ────────────────────────────────────────────────────────────────
## Remove build artefacts from both workspace and kani crate
clean:
cargo clean
cd $(KANI_DIR) && cargo clean
# ── Deploy ─────────────────────────────────────────────────────────────────
## Deploy to devnet
deploy-devnet:
anchor deploy --provider.cluster devnet
## Deploy to mainnet via hardened deployment script
deploy-mainnet:
bash scripts/deploy-mainnet.sh
# ── Docker ─────────────────────────────────────────────────────────────────
## Build all Docker images (build, test, verify)
docker-build:
docker compose build
## Build the BPF program inside Docker
docker-build-program:
docker compose run --rm build
## Run the test suite inside Docker
docker-test:
docker compose run --rm test
## Run Kani formal verification inside Docker
docker-verify:
docker compose run --rm verify
## Start the persistent local validator
docker-localnet:
docker compose up localnet
## Stop all containers and remove named volumes
docker-down:
docker compose down --volumes --remove-orphans
# ── Misc ───────────────────────────────────────────────────────────────────
## Print the program ID
id:
@echo $(PROGRAM_ID)
## Show annotated target list
help:
@echo "balddev DAO Voting Program — available make targets"
@echo "──────────────────────────────────────────────────"
@grep -E '^## ' $(MAKEFILE_LIST) | sed 's/## / /'