-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
463 lines (373 loc) · 14.4 KB
/
Makefile
File metadata and controls
463 lines (373 loc) · 14.4 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
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
# Makefile for Aethelred - Sovereign L1 for Verifiable AI
# The Digital Seal for Verifiable Intelligence
#
# ARCHITECTURE: This project has two independent runtime stacks:
#
# Go Stack (Cosmos SDK) Rust Stack (crates/)
# ├── app/ ABCI++ app ├── aethelred-core Core crypto
# ├── x/pouw/ PoUW module ├── aethelred-consensus VRF consensus
# ├── x/seal/ Seal module ├── aethelred-vm WASM VM
# ├── x/verify/ Verify mod ├── aethelred-mempool Mempool
# └── cmd/ Node binary ├── aethelred-bridge Bridge relayer
# └── falcon-lion Trade demo
#
# Integration: HTTP/gRPC only (no FFI/CGo). Shared contract: proto/*.proto
# Go chain is source of truth. Rust services are stateless workers.
BINARY_NAME = aethelredd
BUILD_DIR = ./build
GO = go
# Rust uses a top-level vendor/ directory; force module mode for Go commands.
GOFLAGS ?= -mod=mod
GOCACHE ?= $(CURDIR)/.cache/go-build
LDFLAGS = -s -w -X github.com/aethelred/aethelred/app.Version=$(VERSION)
VERSION := $(shell git describe --tags --always --dirty 2>/dev/null || echo "v0.1.0-dev")
COMMIT := $(shell git rev-parse --short HEAD 2>/dev/null || echo "unknown")
BUILD_TIME := $(shell date -u '+%Y-%m-%d_%H:%M:%S')
# Docker
DOCKER_IMAGE = aethelred/aethelredd
DOCKER_TAG = $(VERSION)
# Testnet
CHAIN_ID = aethelred-testnet-1
MONIKER = aethelred-node
.PHONY: all build install clean test lint fmt proto openapi openapi-validate docs docker help sdk-version-check sdk-release-check sdk-publish-dry-run audit-signoff-check loadtest loadtest-scenarios coverage-critical release-preflight fuzz-check
## help: Show this help message
help:
@echo "Aethelred - The Digital Seal for Verifiable Intelligence"
@echo ""
@echo "Usage:"
@echo " make <target>"
@echo ""
@echo "Targets:"
@sed -n 's/^##//p' $(MAKEFILE_LIST) | column -t -s ':' | sed 's/^/ /'
## all: Build everything
all: build
## build: Build the aethelredd binary
build:
@echo "Building $(BINARY_NAME) $(VERSION)..."
@mkdir -p $(BUILD_DIR)
@mkdir -p $(GOCACHE)
GOCACHE=$(GOCACHE) $(GO) build $(GOFLAGS) -ldflags "$(LDFLAGS)" -o $(BUILD_DIR)/$(BINARY_NAME) ./cmd/aethelredd
## install: Install aethelredd to GOPATH/bin
install:
@echo "Installing $(BINARY_NAME)..."
@mkdir -p $(GOCACHE)
GOCACHE=$(GOCACHE) $(GO) install $(GOFLAGS) -ldflags "$(LDFLAGS)" ./cmd/aethelredd
## clean: Remove build artifacts
clean:
@echo "Cleaning build artifacts..."
rm -rf $(BUILD_DIR)
rm -rf ~/.aethelred
## test: Run all tests
test:
@echo "Running tests..."
@mkdir -p $(GOCACHE)
GOCACHE=$(GOCACHE) $(GO) test $(GOFLAGS) -v ./...
## test-unit: Run unit tests
test-unit:
@echo "Running unit tests..."
@mkdir -p $(GOCACHE)
GOCACHE=$(GOCACHE) $(GO) test $(GOFLAGS) -v -short ./...
## test-integration: Run integration tests
test-integration:
@echo "Running integration tests..."
@mkdir -p $(GOCACHE)
GOCACHE=$(GOCACHE) $(GO) test $(GOFLAGS) -v -run Integration ./...
## test-consensus: Run consensus-specific tests
test-consensus:
@echo "Running consensus tests..."
@mkdir -p $(GOCACHE)
GOCACHE=$(GOCACHE) $(GO) test $(GOFLAGS) -v ./app/... -run Consensus
## test-coverage: Run tests with coverage
test-coverage:
@echo "Running tests with coverage..."
@mkdir -p $(GOCACHE)
GOCACHE=$(GOCACHE) $(GO) test $(GOFLAGS) -v -coverprofile=coverage.out ./...
GOCACHE=$(GOCACHE) $(GO) tool cover -html=coverage.out -o coverage.html
## coverage-critical: Enforce >=95% average coverage for consensus/verification critical guardrails
coverage-critical:
@python3 ./scripts/check_critical_coverage.py --threshold 95
## bench: Run benchmarks for core packages
bench:
@echo "Running benchmarks..."
@mkdir -p $(GOCACHE)
GOCACHE=$(GOCACHE) $(GO) test $(GOFLAGS) -run=^$$ -bench=. -benchmem ./x/pouw/... ./x/verify/...
## bench-report: Run benchmarks and save a timestamped report
bench-report:
@./scripts/run_benchmarks.sh
## loadtest: Run load test with default baseline settings
loadtest:
@echo "Running baseline load test..."
$(GO) run ./cmd/aethelred-loadtest --scenario baseline
## loadtest-scenarios: Run all predefined stress scenarios
loadtest-scenarios:
@echo "Running all load test scenarios..."
$(GO) run ./cmd/aethelred-loadtest --all-scenarios
FUZZ_CRATES = bridge/fuzz consensus/fuzz core/fuzz vm/fuzz
## fuzz-check: Type-check all fuzz crates (requires network; bypasses vendor source replacement)
fuzz-check:
@echo "Checking fuzz crates (bypassing vendor source replacement)..."
@for crate in $(FUZZ_CRATES); do \
echo " Checking crates/$$crate ..."; \
mv .cargo/config.toml .cargo/config.toml.fuzz-bak 2>/dev/null; \
mv crates/.cargo/config.toml crates/.cargo/config.toml.fuzz-bak 2>/dev/null; \
cargo check --manifest-path crates/$$crate/Cargo.toml; \
status=$$?; \
mv .cargo/config.toml.fuzz-bak .cargo/config.toml 2>/dev/null; \
mv crates/.cargo/config.toml.fuzz-bak crates/.cargo/config.toml 2>/dev/null; \
if [ $$status -ne 0 ]; then exit $$status; fi; \
done
@echo "All fuzz crates compile cleanly."
## lint: Run linters
lint:
@echo "Running linters..."
@if command -v golangci-lint >/dev/null 2>&1; then \
golangci-lint run ./...; \
else \
echo "golangci-lint not installed. Run: brew install golangci-lint"; \
fi
## fmt: Format code
fmt:
@echo "Formatting code..."
@mkdir -p $(GOCACHE)
GOCACHE=$(GOCACHE) $(GO) fmt ./...
@if command -v goimports >/dev/null 2>&1; then \
goimports -w .; \
fi
## proto: Generate protobuf files
proto:
@echo "Generating protobuf files..."
@./scripts/protocgen.sh
## openapi: Generate OpenAPI (Swagger) specification
openapi:
@echo "Generating OpenAPI spec..."
@./scripts/openapi_gen.sh
## openapi-validate: Generate and validate OpenAPI artifacts
openapi-validate: openapi
@echo "Validating OpenAPI artifacts..."
@test -f docs/api/openapi/aethelred.openapi.yaml
@test -f docs/api/openapi/aethelred.swagger.json
@jq . docs/api/openapi/aethelred.swagger.json >/dev/null
@echo "OpenAPI validation passed."
## docs: Generate documentation
docs:
@echo "Generating documentation..."
@mkdir -p $(GOCACHE)
@GOCACHE=$(GOCACHE) $(GO) doc -all ./... > docs/api/godoc.txt
## sdk-version-check: Validate SDK/API versions against the matrix
sdk-version-check:
@echo "Checking SDK/API version matrix..."
@python3 ./scripts/check_sdk_versions.py
## sdk-release-check: Run SDK release gates (versions + OpenAPI)
sdk-release-check: sdk-version-check openapi-validate
@echo "SDK release checks passed."
## sdk-publish-dry-run: Run local SDK publish dry-run (build/package only)
sdk-publish-dry-run:
@./scripts/sdk_publish_dry_run.sh
## audit-signoff-check: Enforce completed external audit signoff for contracts + consensus
audit-signoff-check:
@python3 ./scripts/check_contract_audit_signoff.py \
--required-scope /contracts/ethereum \
--required-scope "Consensus + vote extensions" \
--require-signed-report
## release-preflight: Run all pre-release validation checks
release-preflight: audit-signoff-check coverage-critical sdk-version-check openapi-validate
@echo "All release preflight checks passed"
## docker-build: Build Docker image
docker-build:
@echo "Building Docker image $(DOCKER_IMAGE):$(DOCKER_TAG)..."
docker build -t $(DOCKER_IMAGE):$(DOCKER_TAG) .
docker tag $(DOCKER_IMAGE):$(DOCKER_TAG) $(DOCKER_IMAGE):latest
## docker-push: Push Docker image
docker-push:
@echo "Pushing Docker image..."
docker push $(DOCKER_IMAGE):$(DOCKER_TAG)
docker push $(DOCKER_IMAGE):latest
## init: Initialize a new node
init:
@echo "Initializing $(MONIKER) on chain $(CHAIN_ID)..."
$(BUILD_DIR)/$(BINARY_NAME) init $(MONIKER) --chain-id $(CHAIN_ID)
## genesis: Create genesis file
genesis:
@echo "Creating genesis file..."
$(BUILD_DIR)/$(BINARY_NAME) add-genesis-account $(shell $(BUILD_DIR)/$(BINARY_NAME) keys show validator -a) 1000000000uaeth
$(BUILD_DIR)/$(BINARY_NAME) gentx validator 100000000uaeth --chain-id $(CHAIN_ID)
$(BUILD_DIR)/$(BINARY_NAME) collect-gentxs
## start: Start a single node
start: build
@echo "Starting $(BINARY_NAME)..."
$(BUILD_DIR)/$(BINARY_NAME) start
## testnet-start: Start local testnet (3 validators)
testnet-start: build
@echo "Starting local testnet..."
@./scripts/testnet.sh start
## testnet-stop: Stop local testnet
testnet-stop:
@echo "Stopping local testnet..."
@./scripts/testnet.sh stop
## testnet-reset: Reset local testnet
testnet-reset:
@echo "Resetting local testnet..."
@./scripts/testnet.sh reset
## keys-add: Add a new key
keys-add:
@$(BUILD_DIR)/$(BINARY_NAME) keys add $(name)
## keys-list: List all keys
keys-list:
@$(BUILD_DIR)/$(BINARY_NAME) keys list
## status: Show node status
status:
@$(BUILD_DIR)/$(BINARY_NAME) status
## version: Show version
version:
@echo "Version: $(VERSION)"
@echo "Commit: $(COMMIT)"
@echo "Build Time: $(BUILD_TIME)"
# Module-specific targets
## seal-query: Query seal module
seal-query:
@$(BUILD_DIR)/$(BINARY_NAME) query seal $(args)
## pouw-query: Query pouw module
pouw-query:
@$(BUILD_DIR)/$(BINARY_NAME) query pouw $(args)
## verify-query: Query verify module
verify-query:
@$(BUILD_DIR)/$(BINARY_NAME) query verify $(args)
## submit-job: Submit a compute job
submit-job:
@echo "Submitting compute job..."
@$(BUILD_DIR)/$(BINARY_NAME) tx pouw submit-job $(args)
## register-model: Register an AI model
register-model:
@echo "Registering AI model..."
@$(BUILD_DIR)/$(BINARY_NAME) tx pouw register-model $(args)
# Development helpers
## mod-tidy: Tidy go modules
mod-tidy:
@echo "Tidying go modules..."
@mkdir -p $(GOCACHE)
GOCACHE=$(GOCACHE) $(GO) mod tidy
## mod-download: Download go modules
mod-download:
@echo "Downloading go modules..."
@mkdir -p $(GOCACHE)
GOCACHE=$(GOCACHE) $(GO) mod download
## benchmark: Run benchmarks
benchmark:
@echo "Running benchmarks..."
$(GO) test -bench=. -benchmem ./...
## profile: Generate CPU profile
profile:
@echo "Generating CPU profile..."
$(GO) test -cpuprofile=cpu.prof -bench=. ./app
## trace: Generate execution trace
trace:
@echo "Generating execution trace..."
$(GO) test -trace=trace.out -bench=. ./app
# ============================================================================
# Rust Targets (crates/)
# ============================================================================
## rust-build: Build all Rust crates
rust-build:
@echo "Building Rust crates..."
cd crates && cargo build --release --workspace
## rust-test: Run all Rust tests
rust-test:
@echo "Running Rust tests..."
cd crates && cargo test --all-features --workspace
## rust-lint: Run Rust linters
rust-lint:
@echo "Running Rust linters..."
cd crates && cargo fmt --all -- --check
cd crates && cargo clippy --all-targets --all-features -- -D warnings
## rust-clean: Clean Rust build artifacts
rust-clean:
@echo "Cleaning Rust build artifacts..."
cd crates && cargo clean
# ============================================================================
# Full Stack Targets
# ============================================================================
## build-all: Build both Go and Rust stacks
build-all: build rust-build
## test-all: Test both Go and Rust stacks
test-all: test rust-test
## lint-all: Lint both Go and Rust stacks
lint-all: lint rust-lint
## clean-all: Clean both Go and Rust build artifacts
clean-all: clean rust-clean
# ============================================================================
# Solidity Contracts Targets
# ============================================================================
## contracts-install: Install contract dependencies
contracts-install:
@echo "Installing contract dependencies..."
cd contracts && npm ci
## contracts-build: Compile Solidity contracts
contracts-build:
@echo "Compiling Solidity contracts..."
cd contracts && npx hardhat compile
## contracts-test: Run contract tests
contracts-test:
@echo "Running contract tests..."
cd contracts && npx hardhat test
## contracts-lint: Lint Solidity contracts
contracts-lint:
@echo "Linting Solidity contracts..."
cd contracts && npx solhint 'contracts/**/*.sol'
# ============================================================================
# Frontend Targets
# ============================================================================
## frontend-install: Install frontend dependencies
frontend-install:
@echo "Installing frontend dependencies..."
cd frontend && npm ci
## frontend-build: Build frontend
frontend-build:
@echo "Building frontend..."
cd frontend && npm run build
## frontend-dev: Start frontend dev server
frontend-dev:
@echo "Starting frontend dev server..."
cd frontend && npm run dev
# ============================================================================
# SDK Targets
# ============================================================================
## sdk-build: Build all SDKs
sdk-build:
@echo "Building TypeScript SDK..."
cd sdk/typescript && npm ci && npm run build
## sdk-test: Test all SDKs
sdk-test:
@echo "Testing TypeScript SDK..."
cd sdk/typescript && npm test
# ============================================================================
# Tools Targets
# ============================================================================
## tools-build: Build developer tools
tools-build:
@echo "Building developer tools..."
cd tools && npm ci && npm run build 2>/dev/null || true
# ============================================================================
# Full Monorepo Targets
# ============================================================================
## build-monorepo: Build all stacks (Go, Rust, Solidity, SDK, Frontend)
build-monorepo: build rust-build contracts-build sdk-build frontend-build
## test-monorepo: Test all stacks
test-monorepo: test rust-test contracts-test sdk-test
# ============================================================================
# Local Testnet (Docker Compose)
# ============================================================================
## local-testnet-up: Start local testnet (mock or real-node via AETHELRED_LOCAL_TESTNET_PROFILE)
local-testnet-up:
@bash scripts/devtools-local-testnet.sh up
## local-testnet-down: Stop local testnet
local-testnet-down:
@bash scripts/devtools-local-testnet.sh down
## local-testnet-status: Show local testnet service status
local-testnet-status:
@bash scripts/devtools-local-testnet.sh status
## local-testnet-logs: Stream local testnet logs
local-testnet-logs:
@bash scripts/devtools-local-testnet.sh logs
## local-testnet-doctor: Health-check all local testnet services
local-testnet-doctor:
@bash scripts/devtools-local-testnet.sh doctor