Compare commits

..

4 Commits

Author SHA1 Message Date
50ed40b9be
preparation script get data from ghosties file and create rust template code
Signed-off-by: Uncle Stinky <uncle.stinky@ghostchain.io>
2024-10-12 13:36:17 +03:00
7a4a50d588
stash keys added to ghosties file
Signed-off-by: Uncle Stretch <uncle.stretch@ghostchain.io>
2024-10-12 13:34:20 +03:00
40f9dcd2ee
check-keys and insert-keys flags added
Signed-off-by: Uncle Stinky <uncle.stinky@ghostchain.io>
2024-10-12 13:32:17 +03:00
86d762fca3
rename template and make 'local identity' uppercase
Signed-off-by: Uncle Stretch <uncle.stretch@ghostchain.io>
2024-10-11 12:54:51 +03:00
3 changed files with 92 additions and 76 deletions

View File

@ -1,48 +1,46 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -e set -e
if [ "$#" -ne 1 ]; then current_path=$(pwd)
echo "Please provide the number of initial validators!" current_script=$(realpath "$0")
exit 1 script_folder=$(dirname "$current_script")
fi project_folder=("$script_folder/..")
generate_account_id() { num_ghosties=$(grep "Local identity" $project_folder/service/ghosties | wc -l)
./target/release/ghostkey inspect ${3:-} ${4:-} "$SECRET//$1//$2" | grep "Account ID" | awk '{ print $3 }' echo "let endowed_accounts = vec!["
} for num in $(seq 2 $num_ghosties); do
account_id=$(grep -m $num "wallet" $project_folder/service/ghosties | tail -n 1 | awk '{ print $6 }')
generate_address() { public_key=$(ghost key inspect $account_id --public | grep "SS58 Address" | awk '{ print $3 }')
./target/release/ghostkey inspect ${3:-} ${4:-} "$SECRET//$1//$2" | grep "SS58 Address" | awk '{ print $3 }' echo -e "\t// $public_key"
} echo -e "\thex![\"${account_id:2}\"].into();"
generate_public_key() {
./target/release/ghostkey inspect ${3:-} ${4:-} "$SECRET//$1//$2" | grep "Public key (hex)" | awk '{ print $4 }'
}
generate_address_and_account_id() {
ACCOUNT=$(generate_account_id $1 $2 $3)
ADDRESS=$(generate_address $1 $2 $3)
if ${4:-false}; then
INTO="unchecked_into"
else
INTO="into"
fi
printf "//$ADDRESS\nhex![\"${ACCOUNT#'0x'}\"].$INTO(),"
}
V_NUM=$1
AUTHORITIES=""
for i in $(seq 1 $V_NUM); do
AUTHORITIES+="(\n"
AUTHORITIES+="$(generate_address_and_account_id $i stash)\n"
AUTHORITIES+="$(generate_address_and_account_id $i controller)\n"
AUTHORITIES+="$(generate_address_and_account_id $i babe '--scheme sr25519' true)\n"
AUTHORITIES+="$(generate_address_and_account_id $i grandpa '--scheme ed25519' true)\n"
AUTHORITIES+="$(generate_address_and_account_id $i authority_discovery '--scheme sr25519' true)\n"
AUTHORITIES+="$(generate_address_and_account_id $i slow_clap '--scheme sr25519' true)\n"
AUTHORITIES+="),\n"
done done
echo "];"
echo -e "\n"
printf "$AUTHORITIES" print_session_key() {
echo -e "\t\t// $1"
echo -e "\t\thex![\"$2\"].$3(),"
}
echo "let initial_authorities: Vec<("
echo -e "\tAccountId,"
echo -e "\tAccountId,"
echo -e "\tBabeId,"
echo -e "\tGrandpaId,"
echo -e "\tAuthorityDiscoveryId,"
echo -e "\tSlowClapId,"
echo ")> = vec!["
for num in $(seq 2 $num_ghosties); do
echo -e "\t("
for key_word in $(echo stash stash babe gran audi slow); do
account_id=$(grep -m $num $key_word $project_folder/service/ghosties | tail -n 1 | awk '{ print $7 }')
public_key=$(ghost key inspect $account_id --public | grep "SS58 Address" | awk '{ print $3 }')
postfix="unchecked_into"
if [ $key_word = "stash" ]; then
postfix="into"
fi
print_session_key $public_key $account_id $postfix
done
echo -e "\t),"
done
echo "];"

View File

@ -39,7 +39,29 @@ prompt() {
done done
} }
trap 'final "$?"' EXIT sanity_check() {
secret_seed=$(ghost key inspect --scheme="$1" "$2" | grep "Secret seed" | awk '{ print $3 }')
account_id=$(ghost key inspect --scheme="$1" "$2" | grep "Account ID" | awk '{ print $3 }')
echo "[+] inspected account id for $3: $account_id"
num_keys=$(grep $account_id "$PROJECT_FOLDER/service/ghosties" | wc -l)
num_types=$(grep $account_id "$PROJECT_FOLDER/service/ghosties" | grep $3 | wc -l)
if [ ! $num_keys = 1 ] || [ ! $num_types = 1 ]; then
echo "[-] inspected account id not found on 'ghosties' file or wrong key type"
exit 1
fi
}
extract_seed() {
name_with_spaces=$(echo $1 | tr '-' ' ')
read -p "[?] path to the file with $name_with_spaces: (default: /etc/ghost/$1) " seed_path
seed_path="${seed_path:-/etc/ghost/$1}"
if [ ! -f $seed_path ]; then
echo "[-] path to $name_with_spaces is not valid"
fi
seed=$(cat $seed_path)
echo $seed
}
help() { help() {
echo -e "Ghost Node Build automation tool. Helper for Ghost Node environment preparation.\n" echo -e "Ghost Node Build automation tool. Helper for Ghost Node environment preparation.\n"
@ -59,6 +81,8 @@ help() {
echo -e "-h, --help\n\tPrints help information." echo -e "-h, --help\n\tPrints help information."
} }
trap 'final "$?"' EXIT
clear clear
echo " ____ _ _ _ _ _" echo " ____ _ _ _ _ _"
echo " / ___| |__ ___ ___| |_ | \ | | ___ __| | ___" echo " / ___| |__ ___ ___| |_ | \ | | ___ __| | ___"
@ -325,15 +349,17 @@ if [[ $ARGUMENTS = true ]]; then
fi fi
if [ $CHECK_KEYS = true ]; then if [ $CHECK_KEYS = true ]; then
read -p "[?] path to the file with session key: (default: /etc/ghost/session-key) " seed_path seed=$(extract_seed "wallet-key")
seed_path="${seed_path:-/etc/ghost/session-key}" sanity_check "sr25519" $seed "wallet"
if [ ! -f $seed_path ]; then echo "[+] local wallet key found in 'ghosties' with correct key type"
echo "[-] path to session keys not valid" echo
exit 1
fi
echo "[+] path $seed_path is valid"
seed=$(cat $seed_path)
seed=$(extract_seed "stash-key")
sanity_check "sr25519" $seed "stash"
echo "[+] local stash key from found in 'ghosties' with correct key type"
echo
seed=$(extract_seed "session-key")
if [ $INSERT_KEYS = true ]; then if [ $INSERT_KEYS = true ]; then
read -p "[?] JSON RPC endpoint to the node: (default: localhost:9945) " rpc_endpoint read -p "[?] JSON RPC endpoint to the node: (default: localhost:9945) " rpc_endpoint
rpc_endpoint="${rpc_endpoint:-localhost:9945}" rpc_endpoint="${rpc_endpoint:-localhost:9945}"
@ -346,17 +372,7 @@ if [ $CHECK_KEYS = true ]; then
scheme="ed25519" scheme="ed25519"
fi fi
secret_seed=$(ghost key inspect --scheme="$scheme" "$seed//$type" | grep "Secret seed" | awk '{ print $3 }') sanity_check $scheme "$seed//$type" $type
account_id=$(ghost key inspect --scheme="$scheme" "$seed//$type" | grep "Account ID" | awk '{ print $3 }')
echo "[+] inspected account id: $account_id"
num_keys=$(grep $account_id "$PROJECT_FOLDER/service/ghosties" | wc -l)
num_types=$(grep $account_id "$PROJECT_FOLDER/service/ghosties" | grep $type | wc -l)
if [ ! $num_keys = 1 ] || [ ! $num_types = 1 ]; then
echo "[-] inspected account id not found on 'ghosties' file or wrong key type"
exit 1
fi
echo "[+] inspected account id found in 'ghosties' file with correct key type" echo "[+] inspected account id found in 'ghosties' file with correct key type"
if [ $INSERT_KEYS = true ]; then if [ $INSERT_KEYS = true ]; then

View File

@ -1,36 +1,38 @@
### TEMPLATE ### ### TEMPLATE ###
local identity : ./PATH_TO_GHOST/ghost key inspect-node-key --bin --file PATH_TO_NODE_KEY Local identity : ./PATH_TO_GHOST/ghost key inspect-node-key --bin --file PATH_TO_NODE_KEY
personal wallet : ./PATH_TO_GHOST/ghost key inspect $(cat PATH_TO_WALLET_KEY) Public key (hex) wallet : ./PATH_TO_GHOST/ghost key inspect $(cat PATH_TO_WALLET_KEY)
======================================================================================================= ==================================================================================================================
session audi : ./PATH_TO_GHOST/ghost key inspect --scheme=sr25519 "$(cat PATH_TO_SESSION_KEY)//audi" Public key (hex) stash : ./PATH_TO_GHOST/ghost key inspect --scheme=sr25519 $(cat PATH_TO_STASH_KEY)
session babe : ./PATH_TO_GHOST/ghost key inspect --scheme=sr25519 "$(cat PATH_TO_SESSION_KEY)//babe" Public key (hex) audi : ./PATH_TO_GHOST/ghost key inspect --scheme=sr25519 "$(cat PATH_TO_SESSION_KEY)//audi"
session slow : ./PATH_TO_GHOST/ghost key inspect --scheme=sr25519 "$(cat PATH_TO_SESSION_KEY)//slow" Public key (hex) babe : ./PATH_TO_GHOST/ghost key inspect --scheme=sr25519 "$(cat PATH_TO_SESSION_KEY)//babe"
session gran : ./PATH_TO_GHOST/ghost key inspect --scheme=ed25519 "$(cat PATH_TO_SESSION_KEY)//gran" Public key (hex) slow : ./PATH_TO_GHOST/ghost key inspect --scheme=sr25519 "$(cat PATH_TO_SESSION_KEY)//slow"
Public key (hex) gran : ./PATH_TO_GHOST/ghost key inspect --scheme=ed25519 "$(cat PATH_TO_SESSION_KEY)//gran"
### str3tch aka Pierre ### ### str3tch aka Pierre ###
local identity : 12D3KooWFMiBom4mrJ57CaJZBxKWD1eDLYUyWLZzcjTaQW5crcNQ Local identity : 12D3KooWFMiBom4mrJ57CaJZBxKWD1eDLYUyWLZzcjTaQW5crcNQ
Public key (hex) wallet : 0x328d3b7c3046ef7700937d99fb2e98ce2591682c2b5dcf3f562e4da157650237 Public key (hex) wallet : 0x328d3b7c3046ef7700937d99fb2e98ce2591682c2b5dcf3f562e4da157650237
=============================================================================================== ===============================================================================================
Public key (hex) for stash : 0x507045c82be367f95408466cd054ca39bfa52697a3ef22809af14cf9de304f02
Public key (hex) for audi : 0x12c14850562021eb99f58f90ab624fb6cfaf3ac9228a92f8b60115fe6a6af15a Public key (hex) for audi : 0x12c14850562021eb99f58f90ab624fb6cfaf3ac9228a92f8b60115fe6a6af15a
Public key (hex) for babe : 0xdaaaaab6a6e574099e24ae9bb75b543610edef9d374fa85a378edb573b47615f Public key (hex) for babe : 0xdaaaaab6a6e574099e24ae9bb75b543610edef9d374fa85a378edb573b47615f
Public key (hex) for slow : 0x0e9e698c7b2bf5ce3861cb4bc4ddf9e200237c282025b093ada850d764d12a35 Public key (hex) for slow : 0x0e9e698c7b2bf5ce3861cb4bc4ddf9e200237c282025b093ada850d764d12a35
Public key (hex) for gran : 0x55446f9a7aa99ced06b317c80ce90d56b84e56526775683af2525969e8da0b64 Public key (hex) for gran : 0x55446f9a7aa99ced06b317c80ce90d56b84e56526775683af2525969e8da0b64
### Cosmos ### ### Cosmos ###
local identity : 12D3KooWN1hdioQuovznNgw4nNfBqrp2qxJHvr6FdXH5KC55C2c1 Local identity : 12D3KooWN1hdioQuovznNgw4nNfBqrp2qxJHvr6FdXH5KC55C2c1
Public key (hex) wallet : 0xfa9809611a6930c246fcd138475f1d9b5aa7b12e1573cfea5b40f7ddb24a7c74 Public key (hex) wallet : 0xfa9809611a6930c246fcd138475f1d9b5aa7b12e1573cfea5b40f7ddb24a7c74
======================================================================= ===============================================================================================
Public key (hex) for stash :
Public key (hex) for audi : 0xe8646430cc92137f8fb722ade64329e76698096185dff4170cae827b5e8bb86b Public key (hex) for audi : 0xe8646430cc92137f8fb722ade64329e76698096185dff4170cae827b5e8bb86b
Public key (hex) for babe : 0xbc576d9ac94f37c7a3f530ee69774d52cefe2da3e829c430acbff4fb0068ee23 Public key (hex) for babe : 0xbc576d9ac94f37c7a3f530ee69774d52cefe2da3e829c430acbff4fb0068ee23
Public key (hex) for slow : 0x6a7d400964de8e7ddbd38c06b8927b0a988372a264b0669bf06819af25f83214 Public key (hex) for slow : 0x6a7d400964de8e7ddbd38c06b8927b0a988372a264b0669bf06819af25f83214
Public key (hex) for gran : 0x14fd4c3e746866cdc42099e33a5c2aea463dd561407c7bc7460eeb869fea5511 Public key (hex) for gran : 0x14fd4c3e746866cdc42099e33a5c2aea463dd561407c7bc7460eeb869fea5511
### ghost_7 ### ### ghost_7 ###
local identity : 12D3KooWNZYbA3Ty1h8BqfMjzKVeJ83UTJxKUXj9zqnSirJZ51KR Local identity : 12D3KooWNZYbA3Ty1h8BqfMjzKVeJ83UTJxKUXj9zqnSirJZ51KR
Public key (hex) wallet : 0x3666e4e19f87bb8680495f31864ce1f1c69d4178002cc01911aef2cc7313f203 Public key (hex) wallet : 0x3666e4e19f87bb8680495f31864ce1f1c69d4178002cc01911aef2cc7313f203
======================================================================= ===============================================================================================
Public key (hex) for stash :
Public key (hex) for audi : 0x90db5ed339a559ed157995a48d781f44c7df972dfba4bc855e4b59fa46438e17 Public key (hex) for audi : 0x90db5ed339a559ed157995a48d781f44c7df972dfba4bc855e4b59fa46438e17
Public key (hex) for babe : 0x6c4dd88b43e2011cf9a6a73d53446336ac9e04cdd4ca23587df63187ac455e49 Public key (hex) for babe : 0x6c4dd88b43e2011cf9a6a73d53446336ac9e04cdd4ca23587df63187ac455e49
Public key (hex) for slow : 0x3481cdcbcf37a4669c29a78cf9ceb39383a10ef0a18b36b92d149fdd0c24ae00 Public key (hex) for slow : 0x3481cdcbcf37a4669c29a78cf9ceb39383a10ef0a18b36b92d149fdd0c24ae00