-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use chopsticks to try runtime upgrade
- Loading branch information
Showing
6 changed files
with
116 additions
and
142 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
[ | ||
{ | ||
"name": "rococo", | ||
"package": "rococo-parachain-runtime", | ||
"path": "runtime/rococo", | ||
"uri": "wss://rpc.litentry-parachain.litentry.io:443" | ||
"name": "paseo", | ||
"package": "paseo-parachain-runtime", | ||
"path": "runtime/paseo", | ||
"uri": "wss://rpc.paseo-parachain.litentry.io:443" | ||
}, | ||
{ | ||
"name": "litentry", | ||
"package": "litentry-parachain-runtime", | ||
"path": "runtime/litentry", | ||
"uri": "wss://rpc.litentry-parachain.litentry.io:443" | ||
} | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
endpoint: | ||
- wss://rpc.litentry-parachain.litentry.io:443 | ||
mock-signature-host: true | ||
db: ./db.sqlite | ||
runtime-log-level: 5 | ||
|
||
import-storage: | ||
System: | ||
Account: | ||
- | ||
- | ||
- 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY | ||
- providers: 1 | ||
data: | ||
free: 1000000000000000000000 # Litentry metadata 18 digit | ||
Council: | ||
Members: | ||
- 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY | ||
TechnicalCommittee: | ||
Members: | ||
- 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
endpoint: | ||
- wss://rpc.paseo-parachain.litentry.io:443 | ||
mock-signature-host: true | ||
db: ./db.sqlite | ||
runtime-log-level: 5 | ||
|
||
import-storage: | ||
Sudo: | ||
Key: 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY # Alice | ||
System: | ||
Account: | ||
- | ||
- | ||
- 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY | ||
- providers: 1 | ||
data: | ||
free: 1000000000000000000000 # paseo metadata 18 digit | ||
Council: | ||
Members: | ||
- 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY | ||
TechnicalCommittee: | ||
Members: | ||
- 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,62 +15,99 @@ ROOTDIR=$(git rev-parse --show-toplevel) | |
# 2. do runtime upgrade using wasm from step 1 | ||
# 3. verify if the runtime upgrade is successful | ||
|
||
output_wasm=/tmp/runtime.wasm | ||
new_wasm=/tmp/runtime.wasm | ||
|
||
function usage() { | ||
echo | ||
echo "Usage: $0 wasm-name [release-tag]" | ||
echo "Usage: $0 <wasm-name> <endpoint> <release-tag> " | ||
echo "e.g.:" | ||
echo " $0 litentry wss://rpc.litentry-parachain.litentry.io v0.9.21-01" | ||
} | ||
|
||
[ $# -gt 2 ] && (usage; exit 1) | ||
[ $# -ne 3 ] && (usage; exit 1) | ||
|
||
function print_divider() { | ||
echo "------------------------------------------------------------" | ||
} | ||
|
||
print_divider | ||
# 1. download runtime wasm | ||
echo "Download $1-parachain-runtime.compact.compressed.wasm from release tag $3 ..." | ||
gh release download "$3" -p "$1-parachain-runtime.compact.compressed.wasm" -O "$new_wasm" || true | ||
|
||
# 1. download or copy runtime wasm | ||
if [ -z "$2" ]; then | ||
echo "Copy local wasm $1 ..." | ||
cp -f "$1" "$output_wasm" | ||
if [ -f "$new_wasm" ] && [ -s "$new_wasm" ]; then | ||
ls -l "$new_wasm" | ||
else | ||
echo "Download $1 from release tag $2 ..." | ||
gh release download "$2" -p "$1" -O "$output_wasm" || true | ||
fi | ||
|
||
if [ -f "$output_wasm" ] && [ -s "$output_wasm" ]; then | ||
ls -l "$output_wasm" | ||
else | ||
echo "Cannot find $output_wasm or it has 0 bytes, quit" | ||
echo "Cannot find $new_wasm or it has 0 bytes, quit" | ||
exit 0 | ||
fi | ||
|
||
print_divider | ||
# 2. Install tools | ||
wget -q https://github.com/vi/websocat/releases/latest/download/websocat.x86_64-unknown-linux-musl -O websocat | ||
chmod +x websocat | ||
echo "Websocat version: $(./websocat --version)" | ||
|
||
# 2. check if the released runtime version is greater than the on-chain runtime version, | ||
# which should be now accessible via localhost:9944 | ||
onchain_version=$(curl -s -H "Content-Type: application/json" -d '{"id":1, "jsonrpc":"2.0", "method": "state_getRuntimeVersion", "params": [] }' http://localhost:9944 | jq .result.specVersion) | ||
release_version=$(subwasm --json info "$output_wasm" | jq .core_version.specVersion) | ||
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash | ||
export NVM_DIR="$HOME/.nvm" | ||
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" | ||
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" | ||
echo "nvm version: $(nvm --version)" | ||
|
||
print_divider | ||
# 3. check if the released runtime version is greater than the on-chain runtime version, | ||
echo "Check runtime version ..." | ||
release_version=$(subwasm --json info "$new_wasm" | jq .core_version.specVersion) | ||
|
||
PAYLOAD='{"id":1, "jsonrpc":"2.0", "method": "state_getRuntimeVersion", "params": [] }' | ||
RETRY_INTERVAL=5 | ||
MAX_RETRIES=10 | ||
i=0 | ||
while ((i<MAX_RETRIES)); do | ||
echo "Attempt $i: Trying to fetch on-chain version from $2..." | ||
response=$(echo "$PAYLOAD" | ./websocat "$2") || echo "" | ||
onchain_version=$(echo "$response" | jq -r .result.specVersion 2>/dev/null) | ||
if [[ -n "$onchain_version" && "$onchain_version" != "null" ]]; then | ||
break | ||
else | ||
echo "Invalid or no response. Retrying in $RETRY_INTERVAL seconds..." | ||
sleep $RETRY_INTERVAL | ||
fi | ||
i=$((i + 1)) | ||
done | ||
if [ "$i" -ge $MAX_RETRIES ]; then | ||
echo "Failed to fetch on-chain version after $MAX_RETRIES attempts." | ||
exit 1 | ||
fi | ||
|
||
echo "On-chain: $onchain_version" | ||
echo "Release: $release_version" | ||
|
||
if [ -n "$release_version" ] && \ | ||
[ -n "$onchain_version" ] && \ | ||
[ "$onchain_version" -ge "$release_version" ]; then | ||
echo "Runtime version not increased, quit" | ||
echo "Current On-chain runtime is up to date, quit" | ||
exit 0 | ||
fi | ||
|
||
# 4. do runtime upgrade and verify | ||
print_divider | ||
|
||
# 3. do runtime upgrade and verify | ||
echo "Do runtime upgrade and verify ..." | ||
cd "$ROOTDIR/parachain/ts-tests" | ||
echo "NODE_ENV=ci" > .env | ||
pnpm install && pnpm run test-runtime-upgrade 2>&1 | ||
|
||
nvm install 20 | ||
nvm use 20 | ||
npx @acala-network/[email protected] --config=$1.yml --allow-unresolved-imports=true --wasm-override $new_wasm | ||
|
||
new_onchain_version=$(curl -s -H "Content-Type: application/json" -d '{"id":1, "jsonrpc":"2.0", "method": "state_getRuntimeVersion", "params": [] }' http://localhost:8000 | jq .result.specVersion) | ||
if [ -n "$new_onchain_version" ] && \ | ||
[ "$new_onchain_version" -ne "$release_version" ]; then | ||
echo "Runtime version NOT increased successfully, quit" | ||
exit 0 | ||
fi | ||
|
||
# cd "$ROOTDIR/parachain/ts-tests" | ||
# echo "NODE_ENV=ci" > .env | ||
# pnpm install && pnpm run test-runtime-upgrade 2>&1 | ||
|
||
print_divider | ||
|
||
|