Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
450 lines (363 loc) · 21.7 KB
/
Copy pathMakefile
File metadata and controls
450 lines (363 loc) · 21.7 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
SHELL := /bin/bash
# INSTANCE selects the mirror: the namespace, the kustomize overlay, the
# instance TOML and the engine image all follow from it.
INSTANCE ?= diorama-mainnet
NS := $(INSTANCE)
OVERLAY := k8s/overlays/$(INSTANCE)
BOOTSTRAP := k8s/bootstrap
KUBECTL := kubectl -n $(NS)
# The engine image/tag of the selected instance, scraped from the manifest
# that deploys it - the deployed manifest stays the single source of truth.
# diorama-mainnet runs the ethereum engine, diorama-venue the venue engine: one
# deployment shape per profile, one image per binary.
ENGINE_MANIFEST := k8s/base/$(INSTANCE)/engine.yaml
ENGINE_REF := $(shell grep -ohE 'image: localhost/[^ ]+' $(ENGINE_MANIFEST) | head -1 | awk '{print $$2}')
ENGINE_IMAGE := $(word 1,$(subst :, ,$(ENGINE_REF)))
ENGINE_TAG := $(lastword $(subst :, ,$(ENGINE_REF)))
ENGINE_BIN := $(notdir $(ENGINE_IMAGE))
# The anvil components of the selected instance (pin-show).
ANVILS := $(if $(filter diorama-mainnet,$(INSTANCE)),anvil-t,anvil-v)
# The selected instance's Namespace manifest: the overlay owns it (instance
# identity, not a service template) - one rule for both mirrors.
NS_MANIFEST := $(OVERLAY)/namespace.yaml
.DEFAULT_GOAL := help
##@ Cluster
ns: ## Create namespace + StorageClass (idempotent)
kubectl apply -f $(NS_MANIFEST)
kubectl apply -f k8s/base/shared/storageclass.yaml
mainnet-secrets: ## Create the reth<->lighthouse JWT secret if missing (mainnet namespace)
@NS=diorama-mainnet; \
if kubectl -n $$NS get secret reth-jwt >/dev/null 2>&1; then \
echo "secret reth-jwt already exists in $$NS (left untouched)"; \
else \
kubectl -n $$NS create secret generic reth-jwt --from-literal=jwt.hex="$$(openssl rand -hex 32)" >/dev/null; \
echo "created secret reth-jwt in $$NS"; \
fi
CCTP_NS ?= diorama-cctp
CCTP_OVERLAY := k8s/overlays/diorama-cctp
# The daloc-monorepo sibling owns the gateway stack and the end-to-end DOD
# scripts. The portfolio DOD drives every user action through the gateway and
# reads the deployed factories/registry directly; it needs the sibling checkout,
# the deploy env, and a borrower key funded on chain 999.
DALOC_REPO ?= ../daloc-monorepo
DALOC_OUT ?= /tmp/opencode/daloc-out
BORROWER_KEY_FILE ?= /tmp/daloc-borrower.key
DALOC_GATEWAY_URL ?= http://127.0.0.1:32001
DALOC_RPC_999 ?= http://127.0.0.1:31545
ALLOW_TEST_POSTURE ?= 1
venue-secrets: ## Create the venue-side secrets (no CCTP key: the bridge owns its own)
@NS=diorama-venue; \
if kubectl -n $$NS get secret cctp-relay-key >/dev/null 2>&1; then \
echo "legacy cctp-relay-key still exists in $$NS (the standalone bridge uses $(CCTP_NS))"; \
fi
cctp-secrets: ## Create the bridge's relay-wallet secret (CCTP_RELAY_KEY=0x…; CCTP_NS)
@NS=$(CCTP_NS); \
if kubectl -n $$NS get secret cctp-relay-key >/dev/null 2>&1; then \
echo "secret cctp-relay-key already exists in $$NS (left untouched)"; \
else \
test -n "$$CCTP_RELAY_KEY" || { echo "set CCTP_RELAY_KEY - the dedicated relay wallet hex key" >&2; exit 1; }; \
kubectl -n $$NS create secret generic cctp-relay-key --from-literal=relay-key="$$CCTP_RELAY_KEY" >/dev/null; \
echo "created secret cctp-relay-key in $$NS"; \
fi
apply: ## Apply the selected instance's stack (INSTANCE selects the overlay)
kubectl apply -k $(OVERLAY)
diff: ## Show what `make apply` would change
kubectl diff -k $(OVERLAY) || true
delete: ## Delete the namespace (data survives: StorageClass is reclaimPolicy Retain)
kubectl delete namespace $(NS) --ignore-not-found
##@ Bootstrap
mainnet-snapshot: ## Download the reth snapshot into the reth PVC (scales reth down first)
kubectl -n diorama-mainnet scale deploy/reth --replicas=0 2>/dev/null || true
kubectl -n diorama-mainnet delete job reth-snapshot --ignore-not-found
kubectl apply -f $(BOOTSTRAP)/snapshot-job.yaml
@# The wait bound is the Job's own spec.activeDeadlineSeconds, not a second
@# hardcoded number: the manifest already owns how long the download may run.
@deadline=$$(kubectl -n diorama-mainnet get job reth-snapshot -o jsonpath='{.spec.activeDeadlineSeconds}'); \
test -n "$$deadline" || { echo "reth-snapshot Job declares no activeDeadlineSeconds" >&2; exit 1; }; \
echo "waiting for snapshot to finish (Job deadline $${deadline}s; resumable)..."; \
kubectl -n diorama-mainnet wait --for=condition=complete job/reth-snapshot --timeout="$${deadline}s" || \
{ echo "not complete within the Job's own deadline ($${deadline}s) - check: make mainnet-snapshot-status"; exit 1; }
mainnet-snapshot-status: ## Show snapshot job status + progress
@$(KUBECTL) get job reth-snapshot 2>/dev/null || echo "no snapshot job"
@$(KUBECTL) logs job/reth-snapshot --tail=3 2>/dev/null || true
mainnet-bootstrap: ns mainnet-secrets images ## First-time setup (mainnet): namespace, secrets, images, snapshot, full stack
kubectl apply -f k8s/base/diorama-mainnet/pvcs.yaml
$(MAKE) mainnet-snapshot
$(MAKE) apply
@echo "bootstrap complete. watch: make status"
##@ Images
# Every image is pinned by full version tag (see k8s/base/**/*.yaml). Pre-importing
# them into the k3s containerd store keeps pod start-up independent of registry
# DNS - measured: containerd's resolver can fail transiently while podman's
# works, which turned a deploy into ImagePullBackOff.
# Single source of truth: the manifests. LOCAL_IMAGES are the images this repo
# builds (one binary per image, `--build-arg BIN`); IMAGES are the third-party
# references, pinned by tag *and* digest. Bumping a version means editing the
# manifest once.
LOCAL_IMAGES := $(shell grep -rhoE 'image: localhost/[^ ]+' k8s/ | awk '{print $$2}' | sort -u)
IMAGES := $(shell grep -rhoE 'image: [^ ]+' k8s/ | awk '{print $$2}' \
| grep -v '^localhost/' | sort -u)
check-pins: ## Verify every image reference is pinned by tag+digest and present locally
@fail=0; \
for ref in $$(grep -rhoE 'image: [^ ]+' k8s/ | awk '{print $$2}' | sort -u); do \
case "$$ref" in \
localhost/*) \
printf " %-62s local build, tag pinned\n" "$$ref" ;; \
*@sha256:*) \
if sudo k3s ctr images ls -q 2>/dev/null | grep -qF "$${ref%%:*}@$${ref##*@}"; then \
printf " %-62s pinned + present locally\n" "$${ref%%@*}"; \
else \
printf " %-62s PINNED BUT MISSING locally\n" "$${ref%%@*}"; fail=1; \
fi ;; \
*) \
printf " %-62s NOT PINNED (no digest)\n" "$$ref"; fail=1 ;; \
esac; \
done; \
if grep -rqE 'image: [^ ]*:latest' k8s/; then echo " 'latest' tag found in k8s/"; fail=1; fi; \
if [ $$fail -eq 0 ]; then echo "all images pinned by tag+digest and present"; \
else echo "pin check FAILED"; exit 1; fi
images: ## Build + import the local images, then pull + import the pinned third-party images
@for ref in $(LOCAL_IMAGES); do \
bin=$${ref##*/}; bin=$${bin%%:*}; \
if [ ! -f "bins/$$bin/src/main.rs" ]; then \
printf " %-62s manifest only (bins/%s has no source yet)\n" "$$ref" "$$bin"; continue; \
fi; \
printf "== %s (build)\n" "$$ref"; \
podman build -q -f Dockerfile --build-arg BIN=$$bin -t "$$ref" . || exit 1; \
rm -f /tmp/diorama-img.tar; \
podman save -o /tmp/diorama-img.tar "$$ref" || exit 1; \
sudo k3s ctr images import /tmp/diorama-img.tar >/dev/null || exit 1; \
done
@for img in $(IMAGES); do \
printf "== %s\n" "$$img"; \
podman pull -q "$$img" || exit 1; \
rm -f /tmp/diorama-img.tar; \
podman save -o /tmp/diorama-img.tar "$$img" || exit 1; \
sudo k3s ctr images import /tmp/diorama-img.tar >/dev/null || exit 1; \
done
@rm -f /tmp/diorama-img.tar
@echo "local: $(LOCAL_IMAGES)"
@echo "imported: $(IMAGES)"
@$(MAKE) --no-print-directory check-pins
##@ Engine
build: ## Build the selected instance's engine image with podman (Dockerfile at the workspace root)
podman build -f Dockerfile --build-arg BIN=$(ENGINE_BIN) -t $(ENGINE_IMAGE):$(ENGINE_TAG) .
import: build ## Import the engine image into the k3s containerd store
podman save -o /tmp/engine-image.tar $(ENGINE_IMAGE):$(ENGINE_TAG)
sudo k3s ctr images import /tmp/engine-image.tar
rm -f /tmp/engine-image.tar
deploy-engine: import ## Rebuild + redeploy the selected instance's engine
$(KUBECTL) rollout restart deploy/engine
@# Bound the wait by the Deployment's own progressDeadlineSeconds (the
@# Kubernetes default is 600s when unset), not a second hardcoded timeout.
@deadline=$$(kubectl -n $(NS) get deploy/engine -o jsonpath='{.spec.progressDeadlineSeconds}' 2>/dev/null); \
$(KUBECTL) rollout status deploy/engine --timeout="$${deadline:-600}s"
venue-build: ## Build the venue binaries on the host (cargo: diorama-venue-engine + diorama-venue-sim)
PATH="$$HOME/.cargo/bin:$$PATH" cargo build -p diorama-venue-engine -p diorama-venue-sim
mainnet-build: ## Build the mainnet engine on the host (cargo: diorama-mainnet-engine)
PATH="$$HOME/.cargo/bin:$$PATH" cargo build -p diorama-mainnet-engine
cctp-build: ## Build the CCTP bridge on the host (cargo: diorama-cctp-bridge)
PATH="$$HOME/.cargo/bin:$$PATH" cargo build -p diorama-cctp-bridge
test-engine: ## Run workspace unit tests on the host (cargo)
PATH="$$HOME/.cargo/bin:$$PATH" cargo test --workspace
config-bootstrap: ## Copy each tracked project template to the gitignored live file when absent
@for f in config/instances/*/daloc.example.toml; do \
d=$${f%/*}; \
if [ ! -f "$$d/daloc.toml" ]; then cp "$$f" "$$d/daloc.toml"; echo "created $$d/daloc.toml from template"; fi; \
done
config-check: ## Validate every instance file through the layered loader
@for f in config/instances/*/instance.toml; do \
PATH="$$HOME/.cargo/bin:$$PATH" cargo run -q -p diorama-config -- check "$$f" || exit 1; \
done
fitness: lint design-assertions config-check ast-scope ## Run the structural gates: lint, design assertions, config check, AST scope
lint: ## lint-gate: clippy, all targets, warnings are errors
PATH="$$HOME/.cargo/bin:$$PATH" cargo clippy --workspace --all-targets -- -D warnings
design-assertions: ## Public types keep Send + Sync (rule 11)
PATH="$$HOME/.cargo/bin:$$PATH" cargo test --workspace design_assertions
ast-scope: ## AST scope analysis: fn/struct size and nesting depth (syn, the compiler's parser)
PATH="$$HOME/.cargo/bin:$$PATH" cargo run -q -p diorama-ast-scope -- crates bins
##@ Ops
status: ## Pods, PVCs, engine status
@$(KUBECTL) get pods -o wide
@$(KUBECTL) get pvc
@echo "--- engine status ---"
@$(KUBECTL) exec deploy/engine -- curl -sf http://localhost:8080/status | jq . 2>/dev/null || echo "(engine not ready)"
logs: ## Tail logs of all pods of the selected instance (follow)
$(KUBECTL) logs -f -l app.kubernetes.io/part-of=$(NS) --max-log-requests=10 --prefix
logs-%: ## Tail logs of one component, e.g. make logs-engine / logs-reth / logs-anvil-t
$(KUBECTL) logs -f deploy/$* --tail=100
# The mirror-specific targets pin their own namespace (the shared targets
# follow INSTANCE): a `mainnet-*` target is about the mainnet mirror, a
# `venue-*` target about the venue's.
mainnet-smoke: ## End-to-end smoke test (mainnet)
NS=diorama-mainnet ./scripts/mainnet-smoke.sh
venue-smoke: ## End-to-end smoke test of the Venue Mirror (V, engine, sim, bridge)
NS=diorama-venue ./scripts/venue-smoke.sh
venue-bootstrap: ns venue-secrets images ## First-time setup (venue): namespace, secrets, images, full stack
kubectl apply -f k8s/base/diorama-venue/pvcs.yaml
$(MAKE) INSTANCE=diorama-venue apply
@echo "venue bootstrap complete. watch: make INSTANCE=diorama-venue status"
cctp-ns: ## Create the bridge namespace + StorageClass
kubectl apply -f $(CCTP_OVERLAY)/namespace.yaml
kubectl apply -f k8s/base/shared/storageclass.yaml
cctp-apply: ## Apply the standalone CCTP bridge instance
kubectl apply -k $(CCTP_OVERLAY)
cctp-diff: ## Show what `make cctp-apply` would change
kubectl diff -k $(CCTP_OVERLAY) || true
cctp-status: ## Pods, PVC and health of the standalone bridge
@kubectl -n $(CCTP_NS) get pods,pvc
@kubectl -n $(CCTP_NS) exec deploy/cctp-bridge -- curl -sf localhost:8096/health | jq . 2>/dev/null || echo "(bridge not ready)"
cctp-logs: ## Tail the standalone bridge's logs
kubectl -n $(CCTP_NS) logs -f deploy/cctp-bridge --tail=100
cctp-bootstrap: cctp-ns cctp-secrets images ## First-time setup: namespace, secret, images, bridge
$(MAKE) cctp-apply
@echo "cctp bootstrap complete. watch: make cctp-status"
venue-repin: ## Re-pin V to the fork source's latest block (the engine's /admin/epoch)
kubectl -n diorama-venue exec deploy/engine -- curl -sf -m 90 -X POST localhost:8080/admin/epoch
venue-scenario: ## The venue epoch scenario (same-pin restore, new-pin epoch, driver liveness)
NS=diorama-venue ./scripts/venue-scenario.sh
venue-proof: ## The venue capability proof (mint, sim deal, crash⇒liquidation, bridge round-trip, block production)
NS=diorama-venue ./scripts/venue-proof.sh
venue-order-proof: ## The venue order-lane proof (fills vs the real book, the market-impact invariants, hand-back)
NS=diorama-venue ./scripts/venue-order-proof.sh
cctp-smoke: ## The CCTP bridge smoke (health, store coherence, metric set)
NS=$(CCTP_NS) ./scripts/cctp-smoke.sh
cctp-roundtrip: ## The CCTP round trip (burn -> mint, exact delta; SOURCE/DESTINATION/AMOUNT env)
NS=$(CCTP_NS) ./scripts/cctp-roundtrip.sh
cctp-margin-cycle: ## The crosschain unified-margin cycle (T mint -> CCTP -> venue collateral -> trade -> CCTP back)
NS=$(CCTP_NS) ./scripts/cctp-margin-cycle.sh
daloc-portfolio-dod: ## The portfolio cardinality DOD on the live daloc stack (simple 1=1=1=1; unified 1 CM + 1 agent + N debts)
DALOC_REPO=$(abspath $(DALOC_REPO)) \
BORROWER_KEY_FILE=$(BORROWER_KEY_FILE) \
DALOC_OUT=$(DALOC_OUT) \
GATEWAY_URL=$(DALOC_GATEWAY_URL) \
RPC_999=$(DALOC_RPC_999) \
ALLOW_TEST_POSTURE=$(ALLOW_TEST_POSTURE) \
$(abspath $(DALOC_REPO))/tools/e2e/portfolio-dod.sh
portfolio-sim: ## The portfolio simulation: a delta-neutral basis book across both mirrors (carry + shock + capital efficiency)
NS=diorama-venue ./scripts/portfolio-sim.sh
basis-capture: ## The live T-vs-V basis series, traded: the capture + the live carry, the identity checked
NS=diorama-venue ./scripts/basis-capture.sh
portfolio-reaction: ## A held portfolio vs another account's impact: both directions, the thresholds, the hedge
NS=diorama-venue ./scripts/portfolio-reaction.sh
crosschain-margin: ## The crosschain margin book: bridged collateral, funding costs, served unrealized PnL, the loop closed
NS=diorama-venue ./scripts/crosschain-margin.sh
crosschain-recovery: ## The deeper crosschain reads: the funding sign flip + the collateral's way back after a forced close
NS=diorama-venue ./scripts/crosschain-recovery.sh
capital-frontier: ## The capital-efficiency frontier: the liquidation distance measured at each leverage
NS=diorama-venue ./scripts/capital-frontier.sh
hedged-book: ## The hedged book: same collateral and gross exposure as the unhedged, flat through a 60% crash
NS=diorama-venue ./scripts/hedged-book.sh
impact-scenarios: ## The impact ladder: a whale moves the book and the mark; the portfolio's reaction measured
NS=diorama-venue ./scripts/impact-scenarios.sh
shadow-audit: ## The shadowing audit: deliberate anvil states vs the COW shadow, both mirrors
./scripts/shadow-audit.sh
benchmark: ## The prime-brokerage benchmark session: the seven portfolio studies in sequence
@echo "== benchmark session: the seven portfolio studies =="
@$(MAKE) --no-print-directory portfolio-sim
@$(MAKE) --no-print-directory basis-capture
@$(MAKE) --no-print-directory portfolio-reaction
@$(MAKE) --no-print-directory crosschain-margin
@$(MAKE) --no-print-directory capital-frontier
@$(MAKE) --no-print-directory hedged-book
@$(MAKE) --no-print-directory impact-scenarios
@echo "== benchmark session: all seven studies green =="
engine-symmetry: ## Both engines' shared HTTP verbs must answer identically (cross-mirror contract)
./scripts/engine-symmetry.sh
log-surface: ## The symmetric log contract, attested against the running services
./scripts/log-surface.sh
attest: ## The behavioral attestation: the pass over both mirrors, then the asserting suites
./scripts/attest.sh
./scripts/log-surface.sh
./scripts/engine-symmetry.sh
mainnet-scenario: ## Scenario test: self-containment, live parity (T vs reth), devnet workflow
NS=diorama-mainnet ./scripts/mainnet-scenario.sh
mainnet-proof: ## Capability proof: live fork, mint funds, real Aave/Uniswap/liquidation interaction
NS=diorama-mainnet ./scripts/mainnet-proof.sh
mainnet-product-sim: ## Product simulation: levered position, live-data sampling, bot liquidation on T
NS=diorama-mainnet ./scripts/mainnet-product-sim.sh
mainnet-closure-check: ## Audit the watchlist closure: every storage dep of every market-data view
NS=diorama-mainnet ./scripts/mainnet-closure-check.sh
mainnet-selftest: ## Run the engine selftest Job (public RPC + scratch anvil; no reth needed)
kubectl -n diorama-mainnet delete job mainnet-selftest --ignore-not-found
kubectl apply -f $(BOOTSTRAP)/mainnet-selftest-job.yaml
@# The Job never reaches Complete: its anvil sidecar is a long-running
@# server. The engine container prints the verdict, so poll that container
@# and gate on `== selftest PASSED ==` instead of waiting on the Job.
@for _ in $$(seq 1 450); do \
out=$$(kubectl -n diorama-mainnet logs job/mainnet-selftest -c engine 2>/dev/null || true); \
case "$$out" in \
*"== selftest PASSED =="*) printf '%s\n' "$$out"; exit 0 ;; \
*"== selftest FAILED =="*) printf '%s\n' "$$out"; exit 1 ;; \
esac; \
sleep 2; \
done; \
echo "mainnet-selftest produced no verdict within 900s" >&2; exit 1
venue-selftest: ## Run the venue selftest Job (public RPC + scratch anvil; no cluster stack needed)
kubectl -n diorama-venue delete job venue-selftest --ignore-not-found
kubectl apply -f $(BOOTSTRAP)/venue-selftest-job.yaml
@# Same shape as mainnet-selftest: poll the engine container's verdict.
@for _ in $$(seq 1 450); do \
out=$$(kubectl -n diorama-venue logs job/venue-selftest -c engine 2>/dev/null || true); \
case "$$out" in \
*"== selftest PASSED =="*) printf '%s\n' "$$out"; exit 0 ;; \
*"== selftest FAILED =="*) printf '%s\n' "$$out"; exit 1 ;; \
esac; \
sleep 2; \
done; \
echo "venue-selftest produced no verdict within 900s" >&2; exit 1
logs-check: ## Deep log scan: warnings/errors per component (last 30 min, normalized)
@for c in reth lighthouse anvil-t engine; do \
printf "== %s\n" "$$c"; \
kubectl -n $(NS) logs deploy/$$c --since=30m 2>/dev/null \
| grep -aE "WARN|ERROR|\"level\":\"(WARN|ERROR)\"" \
| sed -E 's/\"timestamp\":\"[^\"]*\"/TS/; s/[0-9a-fx]{8,}/HEX/g; s/[0-9]{4,}/N/g' \
| sort | uniq -c | sort -rn | head -6; \
done
mainnet-backfill: ## Show the CL backfill progress and the lighthouse datadir sizes
@$(KUBECTL) logs deploy/lighthouse --tail=200 2>/dev/null \
| jq -r 'select(.msg != null and (.msg|test("historical";"i"))) | "backfill: distance=\(.distance // "?") speed=\(.speed // "?") est=\(.est_time // "?")"' 2>/dev/null | tail -1
@sudo sh -c 'du -sh /var/lib/rancher/k3s/storage/pvc-*_$(NS)_lighthouse-data/beacon/* 2>/dev/null | sort -h | tail -4'
mainnet-prune-blobs: ## Reclaim backfilled blob storage (needs the CL stopped; safe for the mirror)
@echo "scaling lighthouse down (the prune needs the database lock)..."
kubectl -n $(NS) scale deploy/lighthouse --replicas=0
kubectl -n $(NS) wait --for=delete pod -l app.kubernetes.io/name=lighthouse --timeout=180s || true
kubectl -n $(NS) delete job lighthouse-prune-blobs --ignore-not-found
kubectl apply -f $(BOOTSTRAP)/prune-blobs-job.yaml
kubectl -n $(NS) wait --for=condition=complete job/lighthouse-prune-blobs --timeout=3600s || true
$(KUBECTL) logs job/lighthouse-prune-blobs --tail=20 || true
kubectl -n $(NS) delete job lighthouse-prune-blobs --ignore-not-found
kubectl -n $(NS) scale deploy/lighthouse --replicas=1
kubectl -n $(NS) rollout status deploy/lighthouse --timeout=300s
@$(MAKE) --no-print-directory mainnet-backfill
pin-show: ## Show the resolved fork pins of the instance's anvils
@for c in $(ANVILS); do \
printf "%s pin: " $$c; $(KUBECTL) exec deploy/$$c -- cat /state/pin 2>/dev/null || echo "(not resolved yet)"; \
done
mainnet-repin: ## Re-pin drill: wipe the pin, restart the anvil (engine auto-rebases; a new epoch starts)
kubectl -n diorama-mainnet scale deploy/anvil-t --replicas=0
# Wait until the pod is really gone before wiping: the wipe must not
# race a container that is still shutting down (its init container
# re-resolves the pin on the next start).
kubectl -n diorama-mainnet wait --for=delete pod -l app.kubernetes.io/name=anvil-t --timeout=180s || true
kubectl -n diorama-mainnet delete job repin-wipe --ignore-not-found
kubectl apply -f $(BOOTSTRAP)/repin-job.yaml
kubectl -n diorama-mainnet wait --for=condition=complete job/repin-wipe --timeout=300s
kubectl -n diorama-mainnet delete job repin-wipe --ignore-not-found
kubectl -n diorama-mainnet scale deploy/anvil-t --replicas=1
kubectl -n $(NS) rollout status deploy/anvil-t --timeout=600s
@echo "re-pinned. engine will rebase automatically on its next poll."
##@ Help
help: ## Show this help
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage: make \033[36m<target>\033[0m\n"} \
/^[a-zA-Z0-9_-]+:.*?##/ { printf " \033[36m%-18s\033[0m %s\n", $$1, $$2 } \
/^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) }' $(MAKEFILE_LIST)
@echo
.PHONY: fitness lint design-assertions config-check config-bootstrap ast-scope
.PHONY: ns mainnet-secrets venue-secrets apply diff delete \
mainnet-snapshot mainnet-snapshot-status mainnet-bootstrap venue-bootstrap \
images build venue-build mainnet-build cctp-build import deploy-engine test-engine \
status logs logs-check check-pins mainnet-smoke venue-smoke venue-repin venue-scenario \
venue-proof venue-order-proof venue-selftest cctp-smoke cctp-roundtrip cctp-margin-cycle daloc-portfolio-dod engine-symmetry \
mainnet-scenario mainnet-proof mainnet-product-sim mainnet-closure-check \
mainnet-selftest mainnet-backfill mainnet-prune-blobs pin-show mainnet-repin help