-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathjustfile
More file actions
448 lines (367 loc) · 15.9 KB
/
justfile
File metadata and controls
448 lines (367 loc) · 15.9 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
SUDO := if `groups | grep -q docker > /dev/null 2>&1 && echo true || echo false` == "true" { "" } else { "sudo" }
TAG := env_var_or_default("TAG", "")
WASI_OUT_DIR := "./examples/build/components"
COMPONENTS_DIR := "./examples/components"
COSMWASM_OUT_DIR := "./examples/build/contracts"
REPO_ROOT := `git rev-parse --show-toplevel`
DOCKER_WAVS_ID := `docker ps | grep wavs | awk '{print $1}'`
ARCH := `uname -m`
COSMWASM_OPTIMIZER_VERSION := env_var_or_default("COSMWASM_OPTIMIZER_VERSION", "0.17.0")
help:
just --list
# WAVS Desktop App (React/TypeScript frontend)
app-dev:
cd app && pnpm tauri dev
app-dev-frontend:
cd app && pnpm dev
app-build-release:
cd app && pnpm tauri build
app-build-debug:
cd app && pnpm tauri build --debug
app-build-frontend:
cd app && pnpm build
# builds wavs
docker-build TAG="local":
{{SUDO}} docker build . -t ghcr.io/lay3rlabs/wavs:{{TAG}}
# run wavs:latest
docker-run:
{{SUDO}} docker run --rm ghcr.io/lay3rlabs/wavs:latest
# stop the running wavs container
docker-stop:
if [ "{{DOCKER_WAVS_ID}}" != "" ]; then \
{{SUDO}} docker kill {{DOCKER_WAVS_ID}}; \
echo "Stopped container {{DOCKER_WAVS_ID}}"; \
else \
echo "No container running"; \
fi
install-native HOME DATA="":
@if [ "{{DATA}}" != "" ]; then \
just _install-native {{HOME}} {{DATA}}; \
else \
just _install-native {{HOME}} {{HOME}}; \
fi
_install-native HOME DATA:
@rm -rf "{{HOME}}"
@rm -rf "{{DATA}}"
@mkdir -p "{{HOME}}"
@mkdir -p "{{DATA}}"
@cp "./wavs.toml" "{{HOME}}"
@cp "./.env.example" "{{HOME}}/.env"
@cargo install --path ./packages/wavs
@cargo install --path ./packages/cli
@echo "Add these variables to your system environment:"
@echo ""
@echo "export WAVS_HOME=\"{{HOME}}\""
@echo "export WAVS_DATA=\"{{DATA}}/wavs\""
@echo "export WAVS_CLI_HOME=\"{{HOME}}\""
@echo "export WAVS_CLI_DATA=\"{{DATA}}/wavs-cli\""
@echo "export WAVS_DOTENV=\"{{HOME}}/.env\""
wasi-build COMPONENT="*" TAG="latest":
#!/usr/bin/env bash
set -euo pipefail
IMAGE_NAME="ghcr.io/lay3rlabs/wasi-builder:{{TAG}}"
# Pull latest (unless tag is local)
if [ "{{TAG}}" != "local" ]; then
docker pull $IMAGE_NAME
fi
# Run Docker build
if [ "{{COMPONENT}}" = "*" ]; then
docker run --rm \
-v "$(pwd):/docker" \
-v "$(pwd)/{{WASI_OUT_DIR}}:/docker/output" \
-e HOST_UID=$(id -u) -e HOST_GID=$(id -g) \
-e COMPONENTS_DIR="{{COMPONENTS_DIR}}" \
-e EXCLUDE_FOLDERS="_helpers,_types" \
"$IMAGE_NAME"
else
docker run --rm \
-v "$(pwd):/docker" \
-v "$(pwd)/{{WASI_OUT_DIR}}:/docker/output" \
-e HOST_UID=$(id -u) -e HOST_GID=$(id -g) \
-e COMPONENTS_DIR="{{COMPONENTS_DIR}}" \
"$IMAGE_NAME" "{{COMPONENT}}"
fi
just generate-checksums
# Generate checksums for all WASM files in output directory
generate-checksums:
#!/usr/bin/env bash
CHECKSUM_FILE="checksums.txt"
if [ ! -d "{{WASI_OUT_DIR}}" ]; then
echo "Error: Output directory {{WASI_OUT_DIR}} not found"
exit 1
fi
if ! ls "{{WASI_OUT_DIR}}"/*.wasm >/dev/null 2>&1; then
echo "No WASM files found in {{WASI_OUT_DIR}}"
exit 1
fi
echo "Generating checksums for WASM files in {{WASI_OUT_DIR}}..."
sha256sum "{{WASI_OUT_DIR}}"/*.wasm > "$CHECKSUM_FILE"
echo "Checksums written to $CHECKSUM_FILE"
cat "$CHECKSUM_FILE"
# compile solidity contracts (including examples) and copy the ABI to contracts/solidity/abi
# example ABI's will be copied to examples/contracts/solidity/abi
solidity-build CLEAN="":
@if [ "{{CLEAN}}" = "clean" ]; then \
rm -rf {{REPO_ROOT}}/out; \
rm -rf {{REPO_ROOT}}/packages/types/src/contracts/solidity/abi; \
rm -rf {{REPO_ROOT}}/examples/contracts/solidity/abi; \
rm -rf {{REPO_ROOT}}/packages/wavs/tests/contracts/solidity/abi; \
fi
mkdir -p {{REPO_ROOT}}/out
mkdir -p {{REPO_ROOT}}/packages/types/src/contracts/solidity/abi
mkdir -p {{REPO_ROOT}}/examples/contracts/solidity/abi
forge build --root {{REPO_ROOT}} --out {{REPO_ROOT}}/out --contracts {{REPO_ROOT}}/contracts/solidity;
forge build --root {{REPO_ROOT}} --out {{REPO_ROOT}}/out --contracts {{REPO_ROOT}}/examples/contracts/solidity;
forge build --root {{REPO_ROOT}} --out {{REPO_ROOT}}/out --contracts {{REPO_ROOT}}/packages/wavs/tests/contracts/solidity;
# examples
cp -r {{REPO_ROOT}}/out/SimpleTrigger.sol {{REPO_ROOT}}/examples/contracts/solidity/abi/
cp -r {{REPO_ROOT}}/out/ISimpleTrigger.sol {{REPO_ROOT}}/examples/contracts/solidity/abi/
cp -r {{REPO_ROOT}}/out/SimpleSubmit.sol {{REPO_ROOT}}/examples/contracts/solidity/abi/
cp -r {{REPO_ROOT}}/out/ISimpleSubmit.sol {{REPO_ROOT}}/examples/contracts/solidity/abi/
# wavs-types
cp -r {{REPO_ROOT}}/out/IWavsServiceHandler.sol {{REPO_ROOT}}/packages/types/src/contracts/solidity/abi/
cp -r {{REPO_ROOT}}/out/IWavsServiceManager.sol {{REPO_ROOT}}/packages/types/src/contracts/solidity/abi/
cp -r {{REPO_ROOT}}/out/SimpleServiceManager.sol {{REPO_ROOT}}/packages/types/src/contracts/solidity/abi/
# layer-tests mock contracts
cp -r {{REPO_ROOT}}/out/LogSpam.sol {{REPO_ROOT}}/examples/contracts/solidity/abi/
cp -r {{REPO_ROOT}}/out/TestServiceContracts.sol {{REPO_ROOT}}/examples/contracts/solidity/abi/
# wavs tests - some funkiness with it sometimes not creating the .sol directory so make sure to create it first
mkdir -p {{REPO_ROOT}}/packages/wavs/tests/contracts/solidity/abi/EventEmitter.sol
cp -r {{REPO_ROOT}}/out/EventEmitter.sol {{REPO_ROOT}}/packages/wavs/tests/contracts/solidity/abi/
# compile cosmwasm example contracts
cosmwasm-build CONTRACT="*":
rm -rf ./artifacts/*.wasm
rm -rf {{COSMWASM_OUT_DIR}}
mkdir -p {{COSMWASM_OUT_DIR}}
just cosmwasm-build-inner examples/contracts/cosmwasm/trigger/simple
just cosmwasm-build-inner examples/contracts/cosmwasm/mock/service-handler
cp ./artifacts/*.wasm {{COSMWASM_OUT_DIR}}
cosmwasm-build-inner CONTRACT_PATH:
@if [ "{{ARCH}}" = "arm64" ]; then \
docker run --rm \
-v "{{REPO_ROOT}}:/code" \
--mount type=volume,source="layer_wavs_cache",target=/target \
--mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \
cosmwasm/optimizer-arm64:{{COSMWASM_OPTIMIZER_VERSION}} "{{CONTRACT_PATH}}"; \
else \
docker run --rm \
-v "{{REPO_ROOT}}:/code" \
--mount type=volume,source="layer_wavs_cache",target=/target \
--mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \
cosmwasm/optimizer:{{COSMWASM_OPTIMIZER_VERSION}} "{{CONTRACT_PATH}}"; \
fi;
# on-chain integration test
test-wavs-e2e:
ulimit -n 65536 && RUST_LOG=debug,alloy_rpc=off,alloy_provider=off,wasmtime=off,cranelift=off,hyper_util=off cargo test -p layer-tests
update-submodules:
git submodule update --init --recursive
lint:
cargo fmt --all -- --check
cargo clippy --all-targets --all-features -- -D warnings
lint-fix:
cargo fmt --all
cargo fix --workspace --all-targets --all-features --allow-dirty --allow-staged
cargo clippy --fix --workspace --all-targets --all-features --allow-dirty -- -D warnings
cargo check --workspace --all-targets --all-features
# waiting on: https://github.com/casey/just/issues/626
start-all:
#!/bin/bash -eux
just start-anvil &
just start-wavs &
trap 'kill $(jobs -pr)' EXIT
wait
start-wavs:
cd packages/wavs && cargo run
start-dev:
#!/bin/bash -eux
just start-telemetry &
just start-wavs-dev &
trap 'kill $(jobs -pr)' EXIT
wait
start-wavs-dev:
#!/bin/bash -eu
ROOT_DIR="$(pwd)"
TEMP_DIR="$(mktemp -d)"
trap 'rm -rf "$TEMP_DIR"' EXIT
cd packages/wavs && \
WAVS_DOTENV="${ROOT_DIR}/.env" WAVS_HOME="../.." WAVS_DATA="$TEMP_DIR" \
cargo run --features dev -- \
--dev-endpoints-enabled=true \
--disable-trigger-networking=true \
--disable-submission-networking=true \
--prometheus="http://127.0.0.1:9090" \
--jaeger="http://127.0.0.1:4317" \
--prometheus-push-interval-secs=1
start-jaeger:
docker run --rm -p 4317:4317 -p 16686:16686 jaegertracing/jaeger:2.5.0
start-prometheus:
docker run --rm --name prometheus --network host -v ./config/prometheus.yml:/etc/prometheus/prometheus.yml -v ./config/alerts.yml:/etc/prometheus/alerts.yml prom/prometheus --config.file=/etc/prometheus/prometheus.yml --web.enable-otlp-receiver
start-alertmanager:
docker run --rm --name alertmanager --network host -v ./config/alertmanager.yml:/etc/alertmanager/alertmanager.yml prom/alertmanager:v0.27.0 --config.file=/etc/alertmanager/alertmanager.yml
start-telemetry:
just start-prometheus &
just start-alertmanager &
just start-jaeger &
dev-tool *args:
cd packages/dev-tool && RUST_LOG=info cargo run -- {{args}}
start-anvil:
anvil
# e.g. `just cli-exec ./examples/build/components/echo_data.wasm "hello world"`
cli-exec COMPONENT INPUT:
@cd packages/cli && cargo run exec --component {{COMPONENT}} --input '{{INPUT}}'
# remove fetched WIT dependency directories
wit-deps-clean:
rm -rf wit-definitions/operator/wit/deps
rm -rf wit-definitions/aggregator/wit/deps
rm -rf wit-definitions/types/wit/deps
# fetch WIT dependencies for each wit-definitions subdirectory
wit-deps-fetch:
cd wit-definitions/types && wkg wit fetch
cd wit-definitions/operator && wkg wit fetch
cd wit-definitions/aggregator && wkg wit fetch
# remove built WIT .wasm artifacts
wit-clean:
rm -f wit-definitions/wasi-tls/*.wasm
rm -f wit-definitions/types/wavs:types@*.wasm
rm -f wit-definitions/operator/wavs:operator@*.wasm
rm -f wit-definitions/aggregator/wavs:aggregator@*.wasm
# build WIT packages via wkg wit build
wit-build config="":
just _inner-wit-build "{{ if config != '' { ' --config ' + '../../' + config } else { '' } }}"
# publish WIT packages to registry
wit-publish config="":
just _inner-wit-publish "{{ if config != '' { ' --config ' + '../../' + config } else { '' } }}"
_inner-wit-build config-arg:
just wit-clean
cd wit-definitions/wasi-tls && wkg wit build{{config-arg}}
cd wit-definitions/types && wkg wit build{{config-arg}}
cd wit-definitions/operator && wkg wit build{{config-arg}}
cd wit-definitions/aggregator && wkg wit build{{config-arg}}
_inner-wit-publish config-arg:
cd wit-definitions/types && wkg publish wavs:types@*.wasm{{config-arg}}
cd wit-definitions/operator && wkg publish wavs:operator@*.wasm{{config-arg}}
cd wit-definitions/aggregator && wkg publish wavs:aggregator@*.wasm{{config-arg}}
# update version in root Cargo.toml and all WIT files (eg. just set-version v2.7.0)
set-version version:
#!/usr/bin/env bash
set -euo pipefail
# Ensure version doesn't start with 'v' for file updates
VERSION="{{version}}"
if [[ "$VERSION" == v* ]]; then
VERSION="${VERSION#v}"
fi
echo "Setting version to: ${VERSION}"
if command -v gsed >/dev/null 2>&1; then
SED_CMD="gsed -i"
else
SED_CMD="sed -i"
fi
# root Cargo.toml workspace version
$SED_CMD 's/^version = ".*"/version = "'"${VERSION}"'"/' Cargo.toml
# all WIT packages
find wit-definitions -name "*.wit" -type f | while read -r file; do
$SED_CMD 's/^package wavs:\([^@]*\)@.*/package wavs:\1@'"${VERSION}"';/' "$file"
$SED_CMD 's|use wavs:\([^/]*/[^@]*\)@[^[:space:]]*|use wavs:\1@'"${VERSION}"'|g' "$file"
done
echo "Version updated to ${VERSION} in all files"
# create and push git tags (eg. just push-tag v2.7.0)
push-tag version:
#!/usr/bin/env bash
set -euo pipefail
# Ensure version starts with 'v'
if [[ "{{version}}" != v* ]]; then
TAG="v{{version}}"
else
TAG="{{version}}"
fi
GO_TAG="wasi/go/${TAG}"
echo "Creating tags: ${TAG} and ${GO_TAG}"
# check if main tag already exists
if git rev-parse "${TAG}" >/dev/null 2>&1; then
echo "Error: Tag ${TAG} already exists"
exit 1
fi
# check if go tag already exists
if git rev-parse "${GO_TAG}" >/dev/null 2>&1; then
echo "Error: Tag ${GO_TAG} already exists"
exit 1
fi
git tag "${TAG}" -m "Release ${TAG}"
git tag "${GO_TAG}" -m "Go module release ${TAG}"
echo "Pushing tags to origin..."
git push origin "${TAG}"
git push origin "${GO_TAG}"
echo "Successfully created and pushed tags: ${TAG} and ${GO_TAG}"
# downloads the latest solidity repo
download-solidity branch="dev":
# Create a temporary directory
rm -rf temp_clone
mkdir temp_clone
# Clone the specific branch into the temp directory
git -C temp_clone clone --depth=1 --branch {{branch}} --single-branch https://github.com/Lay3rLabs/wavs-middleware.git
# Clear existing content and create solidity directory
rm -rf contracts/solidity
rm -rf examples/contracts/solidity
mkdir -p contracts/solidity/interfaces
mkdir -p examples/contracts/solidity/interfaces
mkdir -p examples/contracts/solidity/mocks
# Copy just the interfaces
cp temp_clone/wavs-middleware/contracts/src/eigenlayer/ecdsa/interfaces/*.sol contracts/solidity/interfaces/
# and, for examples - interfaces and mocks
cp temp_clone/wavs-middleware/contracts/src/eigenlayer/ecdsa/interfaces/*.sol examples/contracts/solidity/interfaces/
cp temp_clone/wavs-middleware/contracts/src/eigenlayer/ecdsa/mocks/*.sol examples/contracts/solidity/mocks/
# Clean up
rm -rf temp_clone
# downloads the latest mock cosmwasm contracts from the cw-middleware repo
# we only need the service-handler and API though, service-manager is handled by middleware
download-cosmwasm branch="main":
# Create a temporary directory
rm -rf temp_clone
mkdir temp_clone
# Clone the specific branch into the temp directory
git -C temp_clone clone --depth=1 --branch {{branch}} --single-branch https://github.com/Lay3rLabs/cw-middleware.git
# Clear existing content and directories
rm -rf examples/contracts/cosmwasm
mkdir -p examples/contracts/cosmwasm/mock
mkdir -p examples/contracts/cosmwasm/trigger
# Copy it over
cp -r temp_clone/cw-middleware/packages/contracts/mock/api examples/contracts/cosmwasm/mock/api
cp -r temp_clone/cw-middleware/packages/contracts/mock/service-handler examples/contracts/cosmwasm/mock/service-handler
cp -r temp_clone/cw-middleware/packages/contracts/trigger examples/contracts/cosmwasm/
# Clean up
rm -rf temp_clone
wasi-publish version component="*" flags="":
if [ "{{component}}" = "*" ]; then \
awk '{print $2}' checksums.txt | while read path; do \
id=$(basename "$path"); \
id="${id%.wasm}"; \
id=$(echo "$id" | sed 's/_/-/g'); \
echo "Publishing $path at wavs-tests:$id@{{version}}"; \
wkg publish "$path" --package="wavs-tests:$id@{{version}}" {{flags}}; \
done; \
else \
awk '{print $2}' checksums.txt | while read path; do \
id=$(basename "$path"); \
id="${id%.wasm}"; \
id=$(echo "$id" | sed 's/_/-/g'); \
if [ "$id" = "{{component}}" ]; then \
echo "Publishing $path at wavs-tests:$id@{{version}}"; \
wkg publish "$path" --package="wavs-tests:$id@{{version}}" {{flags}}; \
fi; \
done; \
fi
ts-bindings:
rm -rf packages/types/bindings
cargo test -p wavs-types --features ts-bindings
cargo run --bin ts
# Install the WAVS Claude Code skill globally
install-claude-skill:
@mkdir -p ~/.claude/skills
@cp -r .claude/skills/wavs ~/.claude/skills/wavs
@echo "WAVS skill installed to ~/.claude/skills/wavs"
@echo "Restart Claude Code to pick up the skill."
# Register wavs-mcp with Claude Code (interactive wizard)
setup-claude-mcp:
@node packages/wavs-mcp/bin/setup.mjs
debug:
cargo test --package wavs --features dev --test aggregator_tests send_to_self