-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathget_node_metadata.sh
More file actions
executable file
·71 lines (60 loc) · 2.08 KB
/
get_node_metadata.sh
File metadata and controls
executable file
·71 lines (60 loc) · 2.08 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
#!/usr/bin/env bash
set -euo pipefail
# Cleanup function to ensure node container is removed.
cleanup() {
docker rm -f node >/dev/null 2>&1 || true
}
# Set up trap to cleanup on exit.
trap cleanup EXIT
if [ -z "$1" ]; then
echo "Error: node version parameter is required" >&2
echo "Usage: $0 <node_version>" >&2
exit 1
fi
node_version="$1"
# Check if subxt is installed and verify version
if ! command -v subxt &> /dev/null; then
echo "Error: subxt is not installed. Install it with: cargo install subxt-cli" >&2
exit 1
fi
# Extract expected version from Cargo.toml
expected_version=$(grep 'subxt.*version' Cargo.toml | sed -E 's/.*version = "([^"]+)".*/\1/')
# Get installed version (subxt outputs version like "subxt-cli 0.44.0-unknown")
installed_version=$(subxt version | sed -E 's/subxt-cli ([0-9]+\.[0-9]+).*/\1/')
if [ "$installed_version" != "$expected_version" ]; then
echo "Error: subxt version mismatch" >&2
echo " Expected: $expected_version (from Cargo.toml)" >&2
echo " Installed: $installed_version" >&2
echo " Install correct version with: cargo install subxt-cli --version ${expected_version}" >&2
exit 1
fi
mkdir -p ./.node/$node_version
# Start the node container.
docker run \
-d \
--name node \
-p 9944:9944 \
-e SHOW_CONFIG=false \
-e CFG_PRESET=dev \
-e SIDECHAIN_BLOCK_BENEFICIARY="04bcf7ad3be7a5c790460be82a713af570f22e0f801f6659ab8e84a52be6969e" \
midnightntwrk/midnight-node:$node_version
# Wait for port to be available (max 30 seconds)
echo "Waiting for node to be ready..."
for i in {1..30}; do
if curl -f http://localhost:9944/health/readiness 2>/dev/null; then
echo "Node is ready"
sleep 2 # Give it a moment to fully initialize
break
fi
if [ $i -eq 30 ]; then
echo "Error: Node failed to start after 30 seconds" >&2
docker logs node 2>&1 | tail -20
exit 1
fi
sleep 1
done
subxt metadata \
-f bytes \
--url ws://localhost:9944 > \
./.node/$node_version/metadata.scale
echo "Written node metadata to .node/$node_version/metadata.scale"