Skip to content

Commit

Permalink
disallow changing genesis
Browse files Browse the repository at this point in the history
  • Loading branch information
orriin committed Jun 19, 2024
1 parent 9b5a3ea commit e2282e4
Show file tree
Hide file tree
Showing 5 changed files with 50,904 additions and 50,876 deletions.
101,732 changes: 50,866 additions & 50,866 deletions plain_spec_finney.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion plain_spec_testfinney.json

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions raw_spec_finney.json

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions raw_spec_testfinney.json

Large diffs are not rendered by default.

34 changes: 31 additions & 3 deletions scripts/build_all_chainspecs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,39 @@ set -e
echo "*** Building node..."
cargo build

echo "*** Building chainspecs..."
./target/debug/node-subtensor build-spec --raw --chain finney >raw_spec_finney.json
echo "*** Building new chainspecs..."

finney_genesis_temp=$(mktemp)
testfinney_genesis_temp=$(mktemp)
raw_spec_finney_temp=$(mktemp)
raw_spec_testfinney_temp=$(mktemp)

# Save old genesis state before doing anything
jq -r ".genesis" /tmp/raw_spec_finney.json.old >"$finney_genesis_temp"
jq -r ".genesis" /tmp/raw_spec_testfinney.json.old >"$testfinney_genesis_temp"

# 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

./target/debug/node-subtensor build-spec --raw --chain test_finney >raw_spec_testfinney.json
./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

echo "*** Updating genesis..."

# 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.

# 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_temp_updated
jq --slurpfile genesis "$testfinney_genesis_temp" '.genesis = $genesis[0]' "$raw_spec_testfinney_temp" >raw_spec_testfinney_temp_updated

# Success! Actually replace the raw spec files.
mv raw_spec_finney_temp_updated raw_spec_finney.json
mv raw_spec_testfinney_temp_updated raw_spec_testfinney.json

# Cleanup
rm -f "$finney_genesis_temp" "$testfinney_genesis_temp" "$raw_spec_finney_temp" "$raw_spec_testfinney_temp"

echo "*** Done!"

0 comments on commit e2282e4

Please sign in to comment.