generated from coax1d/substrate-parachain-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·115 lines (88 loc) · 2.86 KB
/
build.sh
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
#!/usr/bin/env sh
# Function to toggle the value between 1000 and 1001 on a specific line
toggle_paraid() {
local line=$1
local file=$2
local current_value=$(sed -n "${line}p" "$file" | grep -o '[1000|1001]*')
if [ "$current_value" = "1000" ]; then
sed -i'' -e "${line}s/1000/1001/" "$file"
elif [ "$current_value" = "1001" ]; then
sed -i'' -e "${line}s/1001/1000/" "$file"
fi
}
echo "Creating bin for storing binaries"
# Check if the bin directory exists, create it if it does not
if [ ! -d "bin" ]; then
echo "bin directory does not exist. Creating one..."
mkdir bin
if [ $? -ne 0 ]; then
echo "Failed to create bin directory"
exit 1
fi
fi
echo "Building parachain runtimes first.."
sleep 1
cargo build --release -p parachain-template-node -p pallet-xcmp-message-stuffer -p parachain-template-runtime
if [ $? -eq 0 ]; then
echo "Building Parachain Succeeded"
cp ./target/release/parachain-template-node ./bin/parachain-template-node-v1.1.0-1000
if [ $? -ne 0 ]; then
echo "Failed to copy parachain-template-node to bin directory"
exit 1
fi
else
echo "Building Parachain Failed"
exit 1
fi
toggle_paraid 161 node/src/chain_spec.rs
toggle_paraid 177 node/src/chain_spec.rs
echo "Building second parachain runtime for paraid 1001"
sleep 1
cargo build --release -p parachain-template-node -p pallet-xcmp-message-stuffer -p parachain-template-runtime
if [ $? -eq 0 ]; then
echo "Building Parachain Succeeded"
cp ./target/release/parachain-template-node ./bin/parachain-template-node-v1.1.0-1001
if [ $? -ne 0 ]; then
echo "Failed to copy parachain-template-node to bin directory"
exit 1
fi
else
echo "Building Parachain Failed"
exit 1
fi
echo "Resetting para_ids for next build"
toggle_paraid 161 node/src/chain_spec.rs
toggle_paraid 177 node/src/chain_spec.rs
echo "Starting Parachain Node to get Metadata"
nohup ./target/release/parachain-template-node --dev --rpc-port 54887 &
PARACHAIN_PID=$!
echo "Parachain started with PID: $PARACHAIN_PID"
sleep 5
nohup ./bin/polkadot --alice --tmp --allow-private-ip --discover-local --chain zombienet/rococo-local.json --rpc-port 54886 &
RELAYCHAIN_PID=$!
echo "Relaychain started with PID: $RELAYCHAIN_PID"
sleep 5
echo "Now building Relayer"
cargo build --release -p xcmp_relayer
if [ $? -eq 0 ]; then
echo "Building Relayer Succeeded"
else
echo "Building Relayer Failed"
kill $PARACHAIN_PID
kill $RELAYCHAIN_PID
exit 1
fi
kill $PARACHAIN_PID
kill $RELAYCHAIN_PID
sleep 2
if kill -0 $PARACHAIN_PID 2>/dev/null; then
echo "Parachain node could not be killed"
else
echo "Parachain node killed successfully"
fi
if kill -0 $RELAYCHAIN_PID 2>/dev/null; then
echo "Relaychain node could not be killed"
else
echo "Relaychain node killed successfully"
fi
echo "Build complete!!"