-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathMakefile
195 lines (159 loc) · 8.33 KB
/
Makefile
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
SHELL := /bin/bash
ENV_FILE ?= .env
.PHONY: setup pool domain fund
mint-ai-tokens-to-provider:
set -a; source ${ENV_FILE}; set +a; \
cargo run -p dev-utils --example mint_ai_token -- --address $${PROVIDER_ADDRESS} --key $${PRIVATE_KEY_FEDERATOR} --rpc-url $${RPC_URL}
mint-ai-tokens-to-federator:
set -a; source ${ENV_FILE}; set +a; \
cargo run -p dev-utils --example mint_ai_token -- --address $${FEDERATOR_ADDRESS} --key $${PRIVATE_KEY_FEDERATOR} --rpc-url $${RPC_URL} --amount 1000000000000000000
transfer-eth-to-provider:
set -a; source ${ENV_FILE}; set +a; \
cargo run -p dev-utils --example transfer_eth -- --address $${PROVIDER_ADDRESS} --key $${PRIVATE_KEY_FEDERATOR} --rpc-url $${RPC_URL} --amount 10000000000000000
transfer-eth-to-pool-owner:
set -a; source ${ENV_FILE}; set +a; \
cargo run -p dev-utils --example transfer_eth -- --address $${POOL_OWNER_ADDRESS} --key $${PRIVATE_KEY_FEDERATOR} --rpc-url $${RPC_URL} --amount 1000000000000000000
create-domain:
set -a; source ${ENV_FILE}; set +a; \
cargo run -p dev-utils --example create_domain -- --domain-name "$${DOMAIN_NAME:-default_domain}" --domain-uri "$${DOMAIN_URI:-http://default.uri}" --key $${PRIVATE_KEY_FEDERATOR} --validation-logic $${WORK_VALIDATION_CONTRACT} --rpc-url $${RPC_URL}
create-training-domain:
set -a; source ${ENV_FILE}; set +a; \
cargo run -p dev-utils --example create_domain -- --domain-name "$${DOMAIN_NAME:-training}" --domain-uri "$${DOMAIN_URI:-http://default.uri}" --key $${PRIVATE_KEY_FEDERATOR} --rpc-url $${RPC_URL} --validation-logic $${WORK_VALIDATION_CONTRACT}
create-synth-data-domain:
set -a; source ${ENV_FILE}; set +a; \
cargo run -p dev-utils --example create_domain -- --domain-name "$${DOMAIN_NAME:-synth_data}" --domain-uri "$${DOMAIN_URI:-http://default.uri}" --key $${PRIVATE_KEY_FEDERATOR} --rpc-url $${RPC_URL} --validation-logic $${WORK_VALIDATION_CONTRACT}
create-compute-pool:
set -a; source ${ENV_FILE}; set +a; \
cargo run -p dev-utils --example compute_pool -- --domain-id "$${DOMAIN_ID:-0}" --compute-manager-key "$${POOL_OWNER_ADDRESS}" --pool-name "$${POOL_NAME:-default_pool}" --pool-data-uri "$${POOL_DATA_URI:-http://default.pool.data}" --key $${PRIVATE_KEY_FEDERATOR} --rpc-url $${RPC_URL}
start-compute-pool:
set -a; source ${ENV_FILE}; set +a; \
cargo run -p dev-utils --example start_compute_pool -- --key $${POOL_OWNER_PRIVATE_KEY} --rpc-url $${RPC_URL} --pool-id="$${POOL_ID:-0}"
setup:
make mint-ai-tokens-to-provider
make transfer-eth-to-provider
make transfer-eth-to-pool-owner
make create-domain
make create-compute-pool
make start-compute-pool
setup-dev-env:
make create-training-domain
make create-synth-data-domain
make mint-ai-tokens-to-federator
up:
tmuxinator start prime-dev
down:
docker compose down
tmuxinator stop prime-dev
pkill -f "target/debug/worker" 2>/dev/null || true
pkill -f "target/debug/orchestrator" 2>/dev/null || true
pkill -f "target/debug/validator" 2>/dev/null || true
pkill -f "target/debug/discovery" 2>/dev/null || true
whitelist-provider:
set -a; source ${ENV_FILE}; set +a; \
cargo run -p dev-utils --example whitelist_provider -- --provider-address $${PROVIDER_ADDRESS} --key $${PRIVATE_KEY_VALIDATOR} --rpc-url $${RPC_URL}
watch-discovery:
set -a; source .env; set +a; \
cargo watch -w crates/discovery/src -x "run --bin discovery -- --rpc-url $${RPC_URL}"
watch-worker:
set -a; source ${ENV_FILE}; set +a; \
cargo watch -w crates/worker/src -x "run --bin worker -- run --port 8091 --external-ip $${WORKER_EXTERNAL_IP:-localhost} --compute-pool-id $$WORKER_COMPUTE_POOL_ID --skip-system-checks $${LOKI_URL:+--loki-url $${LOKI_URL}} --log-level $${LOG_LEVEL:-info}"
watch-check:
cargo watch -w crates/worker/src -x "run --bin worker -- check"
watch-validator:
set -a; source ${ENV_FILE}; set +a; \
cargo watch -w crates/validator/src -x "run --bin validator -- --validator-key $${PRIVATE_KEY_VALIDATOR} --rpc-url $${RPC_URL} --pool-id $${WORKER_COMPUTE_POOL_ID} --toploc-server-url $${TOPLOC_SERVER_URL} --toploc-auth-token $${TOPLOC_AUTH_TOKEN} --s3-credentials $${S3_CREDENTIALS} --bucket-name $${BUCKET_NAME} -l $${LOG_LEVEL:-info} --toploc-grace-interval $${TOPLOC_GRACE_INTERVAL:-30}"
watch-orchestrator:
set -a; source ${ENV_FILE}; set +a; \
cargo watch -w crates/orchestrator/src -x "run --bin orchestrator -- -r $$RPC_URL -k $$POOL_OWNER_PRIVATE_KEY -d 0 -p 8090 -i 10 -u http://localhost:8090 --s3-credentials $$S3_CREDENTIALS --compute-pool-id $$WORKER_COMPUTE_POOL_ID --bucket-name $$BUCKET_NAME -l $${LOG_LEVEL:-info} --hourly-s3-upload-limit $${HOURLY_S3_LIMIT:-3}"
build-worker:
cargo build --release --bin worker
run-worker-bin:
@test -n "$$PRIVATE_KEY_PROVIDER" || (echo "PRIVATE_KEY_PROVIDER is not set" && exit 1)
@test -n "$$PRIVATE_KEY_NODE" || (echo "PRIVATE_KEY_NODE is not set" && exit 1)
set -a; source .env; set +a; \
./target/release/worker run --port 8091 --external-ip 0.0.0.0 --compute-pool-id $$WORKER_COMPUTE_POOL_ID --validator-address $$VALIDATOR_ADDRESS
SSH_CONNECTION ?= your-ssh-conn string
EXTERNAL_IP ?= 0.0.0.0
PORT = 8091
# Remote setup
# Remote setup
.PHONY: setup-remote
setup-remote:
$(SSH_CONNECTION) '\
sudo apt-get update; \
sudo apt-get install pkg-config libssl-dev; \
if ! command -v rustc > /dev/null; then \
curl --proto "=https" --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y; \
. "$$HOME/.cargo/env"; \
fi; \
. "$$HOME/.cargo/env"; \
if ! command -v cargo-watch > /dev/null; then \
cargo install cargo-watch; \
fi; \
if ! groups | grep -q docker; then \
sudo usermod -aG docker $$USER; \
fi'
# Setup SSH tunnel
.PHONY: setup-tunnel
setup-tunnel:
$(SSH_CONNECTION) -f -N \
-R 8545:localhost:8545 \
-R 8090:localhost:8090 \
-R 8089:localhost:8089
# Sync project to remote
.PHONY: sync-remote
sync-remote:
rsync -avz -e "$(SSH_CONNECTION)" \
--exclude 'target/' \
--exclude '.git/' \
--exclude 'node_modules/' \
. :~/$(notdir $(CURDIR))
# Run worker on remote GPU
.PHONY: watch-worker-remote
watch-worker-remote: setup-remote setup-tunnel sync-remote
$(SSH_CONNECTION) -t "cd ~/$(notdir $(CURDIR)) && \
export PATH=\"\$$HOME/.cargo/bin:\$$PATH\" && \
. \"\$$HOME/.cargo/env\" && \
export TERM=xterm-256color && \
bash --login -i -c '\
set -a && source .env && set +a && \
export EXTERNAL_IP=$(EXTERNAL_IP) && \
clear && \
RUST_BACKTRACE=1 RUST_LOG=debug cargo watch -w worker/src -x \"run --bin worker -- run \
--port $(PORT) \
--external-ip \$$EXTERNAL_IP \
--compute-pool-id \$$WORKER_COMPUTE_POOL_ID \
--auto-accept \
2>&1 | tee worker.log\"'"
# Kill SSH tunnel
.PHONY: kill-tunnel
kill-tunnel:
pkill -f "ssh.*$(SSH_HOST).*-[NR]" || true
$(SSH_CONNECTION) "pkill -f \"sshd.*:8091\"" || true
# Full remote execution with cleanup
.PHONY: remote-worker
remote-worker:
@trap 'make kill-tunnel' EXIT; \
make watch-worker-remote
# testing:
eject-node:
set -a; source ${ENV_FILE}; set +a; \
cargo run -p dev-utils --example eject_node -- --pool-id $${WORKER_COMPUTE_POOL_ID} --node $${NODE_ADDRESS} --provider-address $${PROVIDER_ADDRESS} --key $${POOL_OWNER_PRIVATE_KEY} --rpc-url $${RPC_URL}
sign-message:
set -a; source ${ENV_FILE}; set +a; \
cargo watch -w worker/src -x "run --bin worker -- sign-message --message example-content --private-key-provider $$PRIVATE_KEY_PROVIDER --private-key-node $$PRIVATE_KEY_NODE"
balance:
set -a; source ${ENV_FILE}; set +a; \
cargo watch -w worker/src -x "run --bin worker -- balance --private-key $$PRIVATE_KEY_PROVIDER --rpc-url $$RPC_URL"
get-node-info:
set -a; source ${ENV_FILE}; set +a; \
cargo run -p dev-utils --example get_node_info -- --provider-address $${PROVIDER_ADDRESS} --node-address $${NODE_ADDRESS} --key $${PRIVATE_KEY_FEDERATOR} --rpc-url $${RPC_URL}
submit-work:
set -a; source ${ENV_FILE}; set +a; \
cargo run -p dev-utils --example submit_work -- --pool-id $${POOL_ID:-0} --node $${NODE_ADDRESS} --work-key $${WORK_KEY} --key $${PRIVATE_KEY_PROVIDER} --rpc-url $${RPC_URL}
invalidate-work:
set -a; source ${ENV_FILE}; set +a; \
cargo run -p dev-utils --example invalidate_work -- --pool-id $${POOL_ID:-0} --penalty $${PENALTY} --work-key $${WORK_KEY} --key $${PRIVATE_KEY_VALIDATOR} --rpc-url $${RPC_URL}
deregister-worker:
set -a; source ${ENV_FILE}; set +a; \
cargo run --bin worker -- deregister --compute-pool-id $${WORKER_COMPUTE_POOL_ID} --private-key-provider $${PRIVATE_KEY_PROVIDER} --private-key-node $${PRIVATE_KEY_NODE} --rpc-url $${RPC_URL}