Skip to content

Commit 06ba8e5

Browse files
committed
Add an option to run try-runtime script with a snapshot
1 parent 4163b91 commit 06ba8e5

File tree

1 file changed

+27
-6
lines changed

1 file changed

+27
-6
lines changed

scripts/try-runtime-upgrade.sh

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Tries runtime upgrade (via try-runtime).
44
#
55
# Usage:
6-
# try-runtime-upgrade.sh [-p <runtime-path>] [-u <live-chain-url>]
6+
# try-runtime-upgrade.sh [-p <runtime-path>] [-u <live-chain-url>] [-s <snapshot-path>]
77
#
88
# Dependencies:
99
# - rust toolchain
@@ -13,23 +13,44 @@ set -eou pipefail
1313

1414
runtime_wasm_path="./target/release/wbuild/node-subtensor-runtime/node_subtensor_runtime.compact.wasm"
1515
live_chain_url="wss://dev.chain.opentensor.ai:443"
16+
snapshot_path=""
1617

1718
parse_args() {
18-
while getopts "p:u:" opt; do
19+
u_provided=false
20+
21+
while getopts "r:u:s:" opt; do
1922
case "${opt}" in
20-
p) runtime_wasm_path="${OPTARG}" ;;
21-
u) live_chain_url="${OPTARG}" ;;
22-
*) echo "Usage: $(basename "$0") [-p <runtime-path>] [-u <live-chain-url>]" && exit 1 ;;
23+
r) runtime_wasm_path="${OPTARG}" ;;
24+
u)
25+
live_chain_url="${OPTARG}"
26+
u_provided=true
27+
;;
28+
s) snapshot_path="${OPTARG}" ;;
29+
*) echo "Usage: $(basename "$0") [-r <runtime-path>] [-u <live-chain-url>] [-s <snapshot-path>]" && exit 1 ;;
2330
esac
2431
done
32+
33+
# Prevent specifying URI if snapshot is specified
34+
if [ -n "$snapshot_path" ] && [ "$u_provided" = true ]; then
35+
echo "Error: Either live URI or snapshot path should be specified, but not both."
36+
exit 1
37+
fi
2538
}
2639

2740
build_runtime() {
2841
cargo build -p node-subtensor-runtime --release --features "metadata-hash,try-runtime"
2942
}
3043

3144
do_try_runtime() {
32-
try-runtime --runtime "$runtime_wasm_path" on-runtime-upgrade live --uri "$live_chain_url"
45+
if [ -n "$snapshot_path" ]; then
46+
chain_state="snap --path $snapshot_path"
47+
else
48+
chain_state="live --uri $live_chain_url"
49+
fi
50+
51+
eval "try-runtime --runtime $runtime_wasm_path on-runtime-upgrade \
52+
--no-weight-warnings --disable-spec-version-check --disable-idempotency-checks \
53+
$chain_state"
3354
}
3455

3556
parse_args "$@"

0 commit comments

Comments
 (0)