-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* chore: update runtime spec checks ⛓️ * chore: add checks to berghain release * chore: add conditional rpc endpoint
- Loading branch information
Showing
3 changed files
with
31 additions
and
11 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
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 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,21 +1,32 @@ | ||
#!/bin/bash | ||
|
||
version=$1 | ||
network=$1 | ||
|
||
runtime_spec_version_file="state-chain/runtime/src/lib.rs" | ||
numeric_version=$(echo $version | tr -d '.') | ||
|
||
# Extract the spec_version from the Rust file | ||
spec_version=$(grep 'spec_version:' $runtime_spec_version_file | awk '{print $2}' | tr -d ',') | ||
|
||
runtime_version=$(cargo read-manifest --manifest-path state-chain/runtime/Cargo.toml | jq -r .version) | ||
|
||
# Compare versions | ||
if [ "$spec_version" != "$numeric_version" ]; then | ||
echo "Error: spec_version ($spec_version) does not match the expected version ($numeric_version)" | ||
if [ -z $network ]; then | ||
echo "Network not specified" | ||
exit 1 | ||
fi | ||
|
||
if [ "$runtime_version" != "$version" ]; then | ||
echo "Error: runtime version ($runtime_version) does not match the expected version ($version)" | ||
exit 1 | ||
if [ $network == "berghain" ]; then | ||
RPC_ENDPOINT="https://mainnet-archive.chainflip.io" | ||
else | ||
RPC_ENDPOINT="https://perseverance.chainflip.xyz" | ||
fi | ||
|
||
live_runtime_version=$(curl -s -H "Content-Type: application/json" -d '{"id":1, "jsonrpc":"2.0", "method": "state_getRuntimeVersion", "params":[]}' $RPC_ENDPOINT | jq .result.specVersion) | ||
|
||
echo "Live runtime version: $live_runtime_version, Current Spec version: $spec_version" | ||
|
||
# Compare versions | ||
if [ $spec_version -gt $live_runtime_version ]; then | ||
echo "Runtime version has been incremented." | ||
exit 0 | ||
else | ||
echo "Runtime version has not been incremented." | ||
exit 2 | ||
fi |