-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
P-58 Use Chopsticks to fork live parachain chain #3221
Merged
Merged
Changes from 8 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
ec76ffd
use chopsticks to verify parachain upgrade
BillyWooo 76ebf79
remove unused code
BillyWooo 7ac73f6
fix try-runtime
BillyWooo 14f6cda
Merge remote-tracking branch 'origin/dev' into p-58-chopsticks-new
BillyWooo 3027021
Merge remote-tracking branch 'origin/dev' into p-58-chopsticks-new
BillyWooo c34a463
clean up
BillyWooo e011aaa
Merge remote-tracking branch 'origin/dev' into p-58-chopsticks-new
BillyWooo 88f9daa
Merge branch 'dev' into p-58-chopsticks-new
BillyWooo c40436a
Merge remote-tracking branch 'origin/dev' into p-58-chopsticks-new
BillyWooo 340b826
still use the public rpc uri
BillyWooo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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" | ||
} | ||
"uri": "wss://rpc2.litentry-parachain-de.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 |
---|---|---|
|
@@ -3,75 +3,103 @@ | |
set -eo pipefail | ||
|
||
ROOTDIR=$(git rev-parse --show-toplevel) | ||
|
||
# the script is used to simulate runtime upgrade, see: | ||
# https://github.com/litentry/litentry-parachain/issues/378 | ||
|
||
# The latest state of the blockchain is scraped and used to bootstrap a chain locally via fork-off-substrate, | ||
# see ./scripts/fork-parachain-and-launch.sh | ||
# | ||
# After that, this script: | ||
# 1. get the runtime wasm | ||
# 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 "------------------------------------------------------------" | ||
} | ||
|
||
# Download runtime wasm | ||
print_divider | ||
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 | ||
|
||
# Install tools | ||
print_divider | ||
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)" | ||
|
||
# Check if the released runtime version is greater than the on-chain runtime version, | ||
print_divider | ||
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" | ||
exit 0 | ||
echo "Current On-chain runtime is up to date, quit" | ||
exit 1 | ||
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 | ||
echo "start chopsticks: $1" | ||
npx @acala-network/[email protected] --endpoint=$2 --port=9944 --mock-signature-host=true --db=./new-db.sqlite --runtime-log-level=5 --allow-unresolved-imports=true --wasm-override $new_wasm & | ||
PID=$! | ||
echo "Chopsticks fork parachain PID: $PID" | ||
sleep 30 | ||
|
||
echo "after chopsticks: $1" | ||
new_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) | ||
if [ -n "$new_onchain_version" ] && \ | ||
[ "$new_onchain_version" -ne "$release_version" ]; then | ||
echo "On-chain new: $new_onchain_version" | ||
echo "Runtime version NOT increased successfully, quit" | ||
exit 1 | ||
fi | ||
|
||
echo "Runtime upgrade succeed: $new_onchain_version" | ||
|
||
print_divider | ||
echo "Done" | ||
|
||
echo "Done" |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'd better not expose this URL for now - we can use dwellir's