-
Notifications
You must be signed in to change notification settings - Fork 172
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1025 from opentensor/chore/chainspecs-folder
Move chainspecs to a dedicated directory
- Loading branch information
Showing
9 changed files
with
64 additions
and
28 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
File renamed without changes.
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 |
---|---|---|
|
@@ -105141,4 +105141,4 @@ | |
} | ||
} | ||
} | ||
} | ||
} |
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 |
---|---|---|
|
@@ -71,4 +71,4 @@ | |
} | ||
} | ||
} | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,39 +1,75 @@ | ||
#!/bin/bash | ||
|
||
# The genesis is not allowed to change. Since the wasm genesis will change | ||
# depending on the system architecture used, we need to extract the genesis from | ||
# the old chain specs and insert them into the new chain specs to ensure there | ||
# are no genesis mismatch issues. | ||
|
||
# This script updates the chain spec files keeping the genesis unchanged. | ||
|
||
set -e | ||
|
||
echo "*** Building node..." | ||
cargo build -p node-subtensor | ||
raw_finney="chainspecs/raw_spec_finney.json" | ||
plain_finney="chainspecs/plain_spec_finney.json" | ||
raw_testfinney="chainspecs/raw_spec_testfinney.json" | ||
plain_testfinney="chainspecs/plain_spec_testfinney.json" | ||
raw_devnet="chainspecs/raw_spec_devnet.json" | ||
plain_devnet="chainspecs/plain_spec_devnet.json" | ||
|
||
save_genesis() { | ||
jq -r ".genesis" "$1" >"$2" | ||
} | ||
|
||
buildspec() { | ||
local chain="$1" | ||
shift | ||
./target/debug/node-subtensor build-spec --chain "$chain" --disable-default-bootnode "$@" | ||
} | ||
|
||
echo "*** Building new chainspecs..." | ||
# Update genesis in new chainspecs using the extracted genesis data from the | ||
# temporary files | ||
update_genesis() { | ||
jq --slurpfile genesis "$1" '.genesis = $genesis[0]' "$2" >"$3" | ||
} | ||
|
||
finney_genesis_temp=$(mktemp) | ||
testfinney_genesis_temp=$(mktemp) | ||
raw_spec_finney_temp=$(mktemp) | ||
raw_spec_testfinney_temp=$(mktemp) | ||
update_spec() { | ||
local chain="$1" | ||
local raw_path="$2" | ||
local plain_path="$3" | ||
|
||
# Save old genesis state before doing anything | ||
jq -r ".genesis" raw_spec_finney.json >"$finney_genesis_temp" | ||
jq -r ".genesis" raw_spec_testfinney.json >"$testfinney_genesis_temp" | ||
raw_genesis_temp=$(mktemp) | ||
plain_genesis_temp=$(mktemp) | ||
raw_spec_temp=$(mktemp) | ||
plain_spec_temp=$(mktemp) | ||
|
||
# Build new chainspecs | ||
./target/debug/node-subtensor build-spec --raw --chain finney >"$raw_spec_finney_temp" | ||
./target/debug/node-subtensor build-spec --chain finney >plain_spec_finney.json | ||
echo "*** Backing up genesis for '$chain'..." | ||
|
||
./target/debug/node-subtensor build-spec --raw --chain test_finney >"$raw_spec_testfinney_temp" | ||
./target/debug/node-subtensor build-spec --chain test_finney >plain_spec_testfinney.json | ||
save_genesis "$raw_path" "$raw_genesis_temp" | ||
save_genesis "$plain_path" "$plain_genesis_temp" | ||
|
||
echo "*** Updating genesis..." | ||
echo "*** Building new chainspec for '$chain'..." | ||
|
||
# The genesis is not allowed to change. Since the wasm genesis will change depending on the system | ||
# architecture used, we need to extract the genesis from the old chain specs and insert them into | ||
# the new chain specs to ensure there are no genesis mismatch issues. | ||
# Build new chainspecs | ||
buildspec "$chain" >"$plain_spec_temp" | ||
buildspec "$chain" --raw >"$raw_spec_temp" | ||
|
||
# Update genesis in new chainspecs using the extracted genesis data from the temporary files | ||
jq --slurpfile genesis "$finney_genesis_temp" '.genesis = $genesis[0]' "$raw_spec_finney_temp" >raw_spec_finney.json | ||
jq --slurpfile genesis "$testfinney_genesis_temp" '.genesis = $genesis[0]' "$raw_spec_testfinney_temp" >raw_spec_testfinney.json | ||
echo "*** Restoring genesis in '$chain'..." | ||
|
||
update_genesis "$raw_genesis_temp" "$raw_spec_temp" "$raw_path" | ||
update_genesis "$plain_genesis_temp" "$plain_spec_temp" "$plain_path" | ||
|
||
# cleanup | ||
rm -f "$raw_genesis_temp" "$plain_genesis_temp" "$raw_spec_temp" \ | ||
"$plain_spec_temp" | ||
} | ||
|
||
# SCRIPT | ||
|
||
echo "*** Building node..." | ||
cargo build -p node-subtensor | ||
|
||
# Cleanup | ||
rm -f "$finney_genesis_temp" "$testfinney_genesis_temp" "$raw_spec_finney_temp" "$raw_spec_testfinney_temp" | ||
update_spec finney "$raw_finney" "$plain_finney" | ||
update_spec test_finney "$raw_testfinney" "$plain_testfinney" | ||
update_spec devnet "$raw_devnet" "$plain_devnet" | ||
|
||
echo "*** Done!" |
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