-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjustfile
More file actions
328 lines (281 loc) Β· 10.3 KB
/
justfile
File metadata and controls
328 lines (281 loc) Β· 10.3 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
# Scalable Web3 Storage - Development Commands
#
# Install just:
# cargo install just
# Or on macOS:
# brew install just
# Polkadot SDK version (matches Cargo.toml tag)
polkadot_version := "polkadot-stable2512-2"
# Zombienet version
zombienet_version := "v1.3.138"
# Detect OS and architecture
os := `uname -s | tr '[:upper:]' '[:lower:]'`
arch := `uname -m`
# URL components
polkadot_sdk_base := "https://github.com/paritytech/polkadot-sdk/releases/download/" + polkadot_version + "/"
darwin_suffix := if os == "darwin" { "-aarch64-apple-darwin" } else { "" }
zombienet_asset := if os == "darwin" { if arch == "arm64" { "zombienet-macos-arm64" } else { "zombienet-macos-x64" } } else { "zombienet-linux-x64" }
# Network ports (override with: just PROVIDER_PORT=3001 start-provider)
RELAY_PORT := "9900"
CHAIN_PORT := "2222"
PROVIDER_PORT := "3333"
# Network URLs (constructed from ports)
RELAY_WS := "ws://127.0.0.1:" + RELAY_PORT
CHAIN_WS := "ws://127.0.0.1:" + CHAIN_PORT
PROVIDER_URL := "http://127.0.0.1:" + PROVIDER_PORT
# Default recipe
default:
@just --list
# Build the project
build:
cargo build --release
# Build only the runtime
build-runtime:
cargo build --release -p storage-parachain-runtime
# Build only the provider node
build-provider:
cargo build --release -p storage-provider-node
[private]
_download BIN URL:
#!/usr/bin/env bash
set -euo pipefail
mkdir -p .bin
if [[ -x .bin/{{BIN}} ]]; then
echo "{{BIN}} already exists in .bin/"
exit 0
fi
echo "Downloading {{BIN}}..."
curl -L -o .bin/{{BIN}} "{{URL}}"
chmod +x .bin/{{BIN}}
echo "{{BIN}} downloaded to .bin/{{BIN}}"
# Download all required binaries
download-binaries: download-polkadot-sdk-binaries download-zombienet
@echo "All binaries downloaded to .bin/"
# Download Polkadot SDK binaries (polkadot, omni-node, chain-spec-builder)
download-polkadot-sdk-binaries: _download-polkadot _download-polkadot-omni-node _download-chain-spec-builder
# Download zombienet
download-zombienet: (_download "zombienet" "https://github.com/paritytech/zombienet/releases/download/" + zombienet_version + "/" + zombienet_asset)
[private]
_download-polkadot: (_download "polkadot" polkadot_sdk_base + "polkadot" + darwin_suffix) (_download "polkadot-execute-worker" polkadot_sdk_base + "polkadot-execute-worker" + darwin_suffix) (_download "polkadot-prepare-worker" polkadot_sdk_base + "polkadot-prepare-worker" + darwin_suffix)
[private]
_download-polkadot-omni-node: (_download "polkadot-omni-node" polkadot_sdk_base + "polkadot-omni-node" + darwin_suffix)
[private]
_download-chain-spec-builder: (_download "chain-spec-builder" polkadot_sdk_base + "chain-spec-builder" + darwin_suffix)
[private]
check: download-binaries
@echo "Checking prerequisites..."
@command -v cargo >/dev/null 2>&1 || { echo "Error: cargo not found"; exit 1; }
@echo "All prerequisites found!"
# Start the blockchain (relay chain + parachain)
start-chain: check build-runtime
#!/usr/bin/env bash
echo ""
echo "=== Starting Blockchain (Relay Chain + Parachain) ==="
echo ""
echo "Web UIs (once ready):"
echo " Relay chain: https://polkadot.js.org/apps/?rpc={{ RELAY_WS }}"
echo " Parachain: https://polkadot.js.org/apps/?rpc={{ CHAIN_WS }}"
echo ""
.bin/zombienet spawn zombienet.toml
# Start the storage provider node
start-provider SEED="//Alice": build-provider
#!/usr/bin/env bash
echo ""
echo "=== Starting Storage Provider Node ==="
echo ""
echo "Provider health: {{ PROVIDER_URL }}/health"
echo ""
SEED="{{SEED}}" \
CHAIN_RPC="{{ CHAIN_WS }}" \
BIND_ADDR="0.0.0.0:{{ PROVIDER_PORT }}" \
./target/release/storage-provider-node
# Health check for provider node
health:
curl -s {{ PROVIDER_URL }}/health | jq .
# Storage stats for provider node
stats:
curl -s {{ PROVIDER_URL }}/stats | jq .
# Demo: full integration test (PAPI-based)
# Runs setup, upload, 2 challenges + responses, and asserts 2 ChallengeDefended events.
# Requires: npm install in examples/papi/ and descriptors generated (just papi-setup).
demo: papi-setup
node examples/papi/full-flow.js "{{ CHAIN_WS }}" "{{ PROVIDER_URL }}"
# Install PAPI dependencies and generate chain descriptors (requires running chain)
papi-setup:
#!/usr/bin/env bash
set -euo pipefail
cd examples/papi
npm install
npm run papi:generate
# Generate chain spec
generate-chain-spec: build-runtime
./scripts/build-chain-spec.sh > chain-spec.json
@echo "Chain spec generated: chain-spec.json"
# Setup development environment (download binaries + build)
setup: download-binaries build
@echo ""
@echo "Setup complete! Run 'just start-chain' and 'just start-provider' to start the local network."
# ============================================================
# File System (Layer 1) Commands
# ============================================================
# Run the file system basic usage example
fs-example:
#!/usr/bin/env bash
set -euo pipefail
echo "π Running File System Client Example"
echo "Prerequisites: blockchain and provider must be running"
echo " - Parachain: ws://127.0.0.1:9944"
echo " - Provider: http://localhost:3000"
echo ""
cd storage-interfaces/file-system/client
RUST_LOG=info cargo run --example basic_usage
# Test file system client (unit tests)
fs-test:
cargo test -p file-system-client
# Test file system client with logs
fs-test-verbose:
RUST_LOG=debug cargo test -p file-system-client -- --nocapture
# Test all file system components (primitives + pallet + client)
fs-test-all:
#!/usr/bin/env bash
set -euo pipefail
echo "Testing file system primitives..."
cargo test -p file-system-primitives
echo ""
echo "Testing drive registry pallet..."
cargo test -p pallet-drive-registry
echo ""
echo "Testing file system client..."
cargo test -p file-system-client
echo ""
echo "β
All file system tests passed!"
# Start infrastructure and run file system example (full integration test)
fs-integration-test:
#!/usr/bin/env bash
set -euo pipefail
echo ""
echo "=== File System Integration Test ==="
echo ""
echo "This will:"
echo " 1. Start relay chain + parachain"
echo " 2. Start provider node"
echo " 3. Verify on-chain setup"
echo " 4. Run file system example"
echo ""
# Check if zombienet is already running
if lsof -i :9944 > /dev/null 2>&1; then
echo "β οΈ Parachain already running on port 9944"
echo "Skipping blockchain startup..."
else
echo "Starting blockchain network..."
.bin/zombienet spawn zombienet.toml > /tmp/zombienet.log 2>&1 &
ZOMBIENET_PID=$!
trap "kill $ZOMBIENET_PID 2>/dev/null || true" EXIT
echo "Waiting for parachain to be ready..."
until curl -s -o /dev/null http://127.0.0.1:9944; do
sleep 2
done
echo "β
Blockchain ready!"
fi
# Check if provider is already running
if lsof -i :3000 > /dev/null 2>&1; then
echo "β οΈ Provider already running on port 3000"
echo "Skipping provider startup..."
else
echo ""
echo "Starting provider node..."
PROVIDER_ID=5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY \
CHAIN_RPC=ws://127.0.0.1:9944 \
cargo run --release -p storage-provider-node > /tmp/provider.log 2>&1 &
PROVIDER_PID=$!
trap "kill $PROVIDER_PID 2>/dev/null || true; kill $ZOMBIENET_PID 2>/dev/null || true" EXIT
# Wait for provider to be ready
echo "Waiting for provider to be ready..."
for i in {1..30}; do
if curl -s http://localhost:3000/health > /dev/null 2>&1; then
echo "β
Provider ready!"
break
fi
if [ $i -eq 30 ]; then
echo "β Provider failed to start"
exit 1
fi
sleep 1
done
fi
echo ""
echo "Verifying on-chain setup..."
bash scripts/verify-setup.sh || {
echo ""
echo "β οΈ Setup verification failed"
echo "You may need to run the setup manually. See:"
echo " docs/getting-started/QUICKSTART.md"
echo ""
echo "Continuing anyway to test drive creation..."
}
echo ""
echo "=== Running File System Example ==="
echo ""
just fs-example
echo ""
echo "β
Integration test complete!"
# Quick file system demo (assumes infrastructure is running)
fs-demo:
#!/usr/bin/env bash
set -euo pipefail
# Check prerequisites
if ! curl -s http://localhost:3000/health > /dev/null 2>&1; then
echo "β Provider not running on http://localhost:3000"
echo "Run: just start-services"
exit 1
fi
if ! curl -s -o /dev/null http://127.0.0.1:9944; then
echo "β Parachain not running on ws://127.0.0.1:9944"
echo "Run: just start-chain"
exit 1
fi
echo "β
Infrastructure is running"
echo ""
just fs-example
# File system integration test for CI
fs-demo-ci:
#!/usr/bin/env bash
set -euo pipefail
echo "Running File System CI Integration Test"
echo " Chain: {{ CHAIN_WS }}"
echo " Provider: {{ PROVIDER_URL }}"
echo ""
cargo run --release -p file-system-client --example ci_integration_test -- "{{ CHAIN_WS }}" "{{ PROVIDER_URL }}"
# Build file system components only
fs-build:
#!/usr/bin/env bash
set -euo pipefail
echo "Building file system components..."
cargo build --release \
-p file-system-primitives \
-p pallet-drive-registry \
-p file-system-client
echo "β
File system components built!"
# Clean file system build artifacts
fs-clean:
cargo clean -p file-system-primitives
cargo clean -p pallet-drive-registry
cargo clean -p file-system-client
# Show file system documentation
fs-docs:
@echo "π File System Interface Documentation"
@echo ""
@echo "Getting Started:"
@echo " docs/filesystems/README.md"
@echo ""
@echo "User Guide:"
@echo " docs/filesystems/USER_GUIDE.md"
@echo ""
@echo "Example Walkthrough:"
@echo " docs/filesystems/EXAMPLE_WALKTHROUGH.md"
@echo ""
@echo "API Reference:"
@echo " docs/filesystems/API_REFERENCE.md"
@echo ""
@echo "Client SDK:"
@echo " storage-interfaces/file-system/client/README.md"