3
3
# Tries runtime upgrade (via try-runtime).
4
4
#
5
5
# 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>]
7
7
#
8
8
# Dependencies:
9
9
# - rust toolchain
@@ -13,23 +13,44 @@ set -eou pipefail
13
13
14
14
runtime_wasm_path=" ./target/release/wbuild/node-subtensor-runtime/node_subtensor_runtime.compact.wasm"
15
15
live_chain_url=" wss://dev.chain.opentensor.ai:443"
16
+ snapshot_path=" "
16
17
17
18
parse_args () {
18
- while getopts " p:u:" opt; do
19
+ u_provided=false
20
+
21
+ while getopts " r:u:s:" opt; do
19
22
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 ;;
23
30
esac
24
31
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
25
38
}
26
39
27
40
build_runtime () {
28
41
cargo build -p node-subtensor-runtime --release --features " metadata-hash,try-runtime"
29
42
}
30
43
31
44
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 "
33
54
}
34
55
35
56
parse_args " $@ "
0 commit comments