Skip to content

Commit 17a687a

Browse files
committed
added prerequisite handling for westend, removed helper function
1 parent c1a442e commit 17a687a

File tree

1 file changed

+96
-22
lines changed

1 file changed

+96
-22
lines changed

examples/justfile

Lines changed: 96 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,65 @@ default: (run-authorize-and-store "smoldot" "bulletin-polkadot-runtime")
1414
build runtime="bulletin-polkadot-runtime":
1515
cargo build --release -p {{ runtime }}
1616

17+
# Setup prerequisites for Westend runtime (polkadot and polkadot-parachain binaries)
18+
# This recipe clones polkadot-sdk, builds required binaries, and copies them to ~/local_bridge_testing/bin
19+
setup-westend-prerequisites:
20+
#!/usr/bin/env bash
21+
set -e
22+
23+
BIN_DIR=~/local_bridge_testing/bin
24+
POLKADOT_SDK_DIR=~/local_bridge_testing/polkadot-sdk
25+
26+
echo "🔧 Setting up Westend runtime prerequisites..."
27+
echo " Target directory: $BIN_DIR"
28+
29+
# Create bin directory
30+
mkdir -p $BIN_DIR
31+
32+
# Clone polkadot-sdk if it doesn't exist
33+
if [ ! -d "$POLKADOT_SDK_DIR" ]; then
34+
echo " Cloning polkadot-sdk repository..."
35+
git clone https://github.com/paritytech/polkadot-sdk.git $POLKADOT_SDK_DIR
36+
else
37+
echo " polkadot-sdk already exists at $POLKADOT_SDK_DIR"
38+
fi
39+
40+
cd $POLKADOT_SDK_DIR
41+
42+
# Check out the required branch
43+
echo " Checking out branch bko-bulletin-para-support..."
44+
git fetch origin
45+
git reset --hard origin/bko-bulletin-para-support
46+
47+
# Build polkadot binary
48+
echo " Building polkadot binary (this may take a while)..."
49+
cargo build -p polkadot -r
50+
51+
# Verify and copy polkadot binaries
52+
echo " Copying polkadot binaries..."
53+
ls -la target/release/polkadot
54+
cp target/release/polkadot $BIN_DIR/
55+
cp target/release/polkadot-prepare-worker $BIN_DIR/
56+
cp target/release/polkadot-execute-worker $BIN_DIR/
57+
58+
# Verify polkadot version
59+
$BIN_DIR/polkadot --version
60+
61+
# Build polkadot-parachain binary
62+
echo " Building polkadot-parachain binary (this may take a while)..."
63+
cargo build -p polkadot-parachain-bin -r
64+
65+
# Verify and copy polkadot-parachain binary
66+
echo " Copying polkadot-parachain binary..."
67+
ls -la target/release/polkadot-parachain
68+
cp target/release/polkadot-parachain $BIN_DIR/
69+
70+
# Verify polkadot-parachain version
71+
$BIN_DIR/polkadot-parachain --version
72+
73+
echo "✅ Westend prerequisites setup complete!"
74+
echo " Binaries installed in: $BIN_DIR"
75+
1776
# Install JavaScript dependencies
1877
npm-install:
1978
npm install
@@ -30,25 +89,6 @@ _ipfs-cmd:
3089
exit 1
3190
fi
3291

33-
# Helper function to map runtime package name to zombienet config filename (toml file)
34-
_zombienet-config-name runtime:
35-
#!/usr/bin/env bash
36-
case "{{ runtime }}" in
37-
"bulletin-polkadot-runtime")
38-
echo "bulletin-polkadot-local.toml"
39-
;;
40-
"bulletin-westend-runtime")
41-
echo "bulletin-westend-local.toml"
42-
;;
43-
"polkadot-bulletin-chain-runtime")
44-
echo "bulletin-polkadot.toml"
45-
;;
46-
*)
47-
echo "❌ Error: Unknown runtime '{{ runtime }}'" >&2
48-
exit 1
49-
;;
50-
esac
51-
5292
# Start solo chain or parachain with zombienet in background
5393
# Parameters:
5494
# runtime - Runtime name (e.g., "bulletin-polkadot-runtime", "bulletin-westend-runtime"), taken from ../scripts/runtimes-matrix.json
@@ -78,9 +118,43 @@ bulletin-solo-zombienet-start runtime="bulletin-polkadot-runtime":
78118

79119
# Get absolute paths for bulletin binary and config
80120
BULLETIN_BINARY=$(cd .. && pwd)/target/release/polkadot-bulletin-chain
81-
ZOMBIENET_CONFIG=$(cd .. && pwd)/zombienet/bulletin-polkadot-local.toml
82-
83-
POLKADOT_BULLETIN_BINARY_PATH=$BULLETIN_BINARY $ZOMBIENET_BIN -p native spawn $ZOMBIENET_CONFIG > /tmp/zombienet.log 2>&1 &
121+
122+
# Handle different runtimes
123+
if [ "{{ runtime }}" = "bulletin-westend-runtime" ]; then
124+
echo " Setting up Westend runtime..."
125+
126+
# Run prerequisites setup first
127+
just setup-westend-prerequisites
128+
129+
# Set paths to binaries
130+
POLKADOT_BINARY_PATH=~/local_bridge_testing/bin/polkadot
131+
POLKADOT_PARACHAIN_BINARY_PATH=~/local_bridge_testing/bin/polkadot-parachain
132+
133+
# Verify binaries exist after setup
134+
if [ ! -f "$POLKADOT_BINARY_PATH" ] || [ ! -f "$POLKADOT_PARACHAIN_BINARY_PATH" ]; then
135+
echo "❌ Error: Prerequisites setup completed but binaries still not found"
136+
echo " Expected POLKADOT_BINARY_PATH: $POLKADOT_BINARY_PATH"
137+
echo " Expected POLKADOT_PARACHAIN_BINARY_PATH: $POLKADOT_PARACHAIN_BINARY_PATH"
138+
exit 1
139+
fi
140+
141+
echo " Using POLKADOT_BINARY_PATH=$POLKADOT_BINARY_PATH"
142+
echo " Using POLKADOT_PARACHAIN_BINARY_PATH=$POLKADOT_PARACHAIN_BINARY_PATH"
143+
144+
# Create chain spec
145+
echo " Creating Westend chain spec..."
146+
(cd .. && ./scripts/create_bulletin_westend_spec.sh)
147+
148+
ZOMBIENET_CONFIG=$(cd .. && pwd)/zombienet/bulletin-westend-local.toml
149+
POLKADOT_BINARY_PATH=$POLKADOT_BINARY_PATH \
150+
POLKADOT_PARACHAIN_BINARY_PATH=$POLKADOT_PARACHAIN_BINARY_PATH \
151+
$ZOMBIENET_BIN -p native spawn $ZOMBIENET_CONFIG > /tmp/zombienet.log 2>&1 &
152+
else
153+
# Default: bulletin-polkadot-runtime
154+
echo " Setting up Polkadot runtime..."
155+
ZOMBIENET_CONFIG=$(cd .. && pwd)/zombienet/bulletin-polkadot-local.toml
156+
POLKADOT_BULLETIN_BINARY_PATH=$BULLETIN_BINARY $ZOMBIENET_BIN -p native spawn $ZOMBIENET_CONFIG > /tmp/zombienet.log 2>&1 &
157+
fi
84158

85159
ZOMBIENET_PID=$!
86160
echo $ZOMBIENET_PID > {{ PID_DIR }}/zombienet.pid

0 commit comments

Comments
 (0)