Skip to content

Commit

Permalink
chore: python script
Browse files Browse the repository at this point in the history
  • Loading branch information
tomjohnburton committed Sep 13, 2023
1 parent 93bbb5b commit af72b7d
Show file tree
Hide file tree
Showing 10 changed files with 714 additions and 36 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/_60_create_chainspec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,12 @@ jobs:
with:
name: chainflip-backend-bin-ubuntu-22.04

- name: Setup python
uses: actions/setup-python@v3

- name: Create chainspec
run: |
./ci/scripts/create_chainspec.sh ${{ inputs.network }}
python3 ./ci/scripts/create_chainspec.py ${{ inputs.network }} ./chainflip-node
- name: Upload artifact
if: always()
Expand Down
42 changes: 42 additions & 0 deletions ci/scripts/create_chainspec.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import json
import sys
import os
import stat
import subprocess

bootnodes_base_path = "state-chain/node/bootnodes/"
chainspecs_base_path = "state-chain/node/chainspecs/"

# Set the first argument to variable network
network = sys.argv[1]

# Set the path of a binary file to variable binary
binary = sys.argv[2]

os.chmod(binary, stat.S_IXUSR)

bootnodes_filename = bootnodes_base_path + network + ".txt"

# Save contents of bootnodes file to variable
with open(bootnodes_filename, "r") as bootnodes_data:
bootnodes = bootnodes_data.read().splitlines()

chainspec_filename = chainspecs_base_path + network + ".chainspec.json"

generate_chainspec_subprocess=[binary, "build-spec", "--chain", network, "--disable-default-bootnode"]
with open(chainspec_filename, "w") as chainspec:
subprocess.call(generate_chainspec_subprocess, stdout=chainspec)

# Load the chainspec file
with open(chainspec_filename, "r") as chainspec:
chainspec_data = json.load(chainspec)

chainspec_data["bootNodes"] = bootnodes
with open(chainspec_filename, "w") as chainspec:
json.dump(chainspec_data, chainspec, indent=4)

chainspec_filename_raw = chainspecs_base_path + network + ".chainspec.raw.json"

generate_chainspec_raw_subprocess=[binary, "build-spec", "--chain", chainspec_filename, "--raw", "--disable-default-bootnode"]
with open(chainspec_filename_raw, "w") as chainspec_raw:
subprocess.call(generate_chainspec_raw_subprocess, stdout=chainspec_raw)
21 changes: 0 additions & 21 deletions ci/scripts/create_chainspec.sh

This file was deleted.

8 changes: 0 additions & 8 deletions state-chain/node/bootnodes/perseverance.json

This file was deleted.

4 changes: 4 additions & 0 deletions state-chain/node/bootnodes/perseverance.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/ip4/165.232.114.128/tcp/30333/p2p/12D3KooWPFZo5JzqiWASDSrAtbyKgW2kw4Rb5FruE29PAhJ1u4xL
/ip4/95.217.229.18/tcp/30333/p2p/12D3KooWAEq6VLm7FWzgyTxFwf8irsd3uEYoa1ZNoHmZAWgpkdfi
/ip4/178.128.36.211/tcp/30333/p2p/12D3KooWMDs3oyT2YpQw88V7TdmN1dJa73D1jrfQorLaBovh7Kim
/ip4/167.172.41.253/tcp/30333/p2p/12D3KooWGjx7vu1wB4xJwPZFbYj3rsVE9gW5eyMFcxRnYWu4sgtX
5 changes: 0 additions & 5 deletions state-chain/node/bootnodes/sisyphos.json

This file was deleted.

1 change: 1 addition & 0 deletions state-chain/node/bootnodes/sisyphos.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/ip4/206.81.20.229/tcp/30333/p2p/12D3KooWKiPoWsdTdG9XacrQZ5qyavsmSayGU4P969Qs6PipCNZs
5 changes: 4 additions & 1 deletion state-chain/node/bootnodes/test.txt
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
"/ip4/206.81.20.229/tcp/30333/p2p/12D3KooWKiPoWsdTdG9XacrQZ5qyavsmSayGU4P969Qs6PipCNZs"
/ip4/206.81.20.229/tcp/30333/p2p/12D3KooWKiPoWsdTdG9XacrQZ5qyavsmSayGU4P969Qs6PipCNZs
/ip4/206.81.20.229/tcp/30333/p2p/12D3KooWKiPoWsdTdG9XacrQZ5qyavsmSayGU4P969Qs6PipCNZs
/ip4/206.81.20.229/tcp/30333/p2p/12D3KooWKiPoWsdTdG9XacrQZ5qyavsmSayGU4P969Qs6PipCNZs
/ip4/206.81.20.229/tcp/30333/p2p/12D3KooWKiPoWsdTdG9XacrQZ5qyavsmSayGU4P969Qs6PipCNZs
473 changes: 473 additions & 0 deletions state-chain/node/chainspecs/test.chainspec.json

Large diffs are not rendered by default.

186 changes: 186 additions & 0 deletions state-chain/node/chainspecs/test.chainspec.raw.json

Large diffs are not rendered by default.

0 comments on commit af72b7d

Please sign in to comment.