Compare commits

..

7 Commits

Author SHA1 Message Date
a1423bc9e7
stash keys added for ghost_7|cosmos
Signed-off-by: ghost_7 <ghostie_7777@proton.me>
2024-10-12 12:45:01 -04:00
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
ea21a24c3e
keys for ghost_7 added to ghosties file
Signed-off-by: Uncle Stretch <uncle.stretch@ghostchain.io>
2024-10-11 12:28:51 +03:00
e850ed9aea
session key helper added
Signed-off-by: Uncle Stinky <uncle.stinky@ghostchain.io>
2024-10-11 02:16:33 +03:00
3 changed files with 134 additions and 57 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

@ -2,6 +2,8 @@
set -Ee set -Ee
CHECK_KEYS=false
INSERT_KEYS=false
UNIT_FILE=false UNIT_FILE=false
SKIP_BUILD=false SKIP_BUILD=false
SET_ENVIRONMENT=false SET_ENVIRONMENT=false
@ -37,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"
@ -46,6 +70,8 @@ help() {
echo -e "-u, --unit-file\n\tCreation of systemd unit file." echo -e "-u, --unit-file\n\tCreation of systemd unit file."
echo -e "-m, --make-global\n\tStore compiled ghost executable and chain specification globally." echo -e "-m, --make-global\n\tStore compiled ghost executable and chain specification globally."
echo -e "-a, --set-arguments\n\tPrepare CLI arguments for running ghost node." echo -e "-a, --set-arguments\n\tPrepare CLI arguments for running ghost node."
echo -e "-k, --check-keys\n\tCheck if your keys are already included in 'ghosties' file."
echo -e "-r, --insert-keys\n\tInsert session keys to the keystore via JSON RPC."
echo -e "-r, --release\n\tCompile node with '--release' flag." echo -e "-r, --release\n\tCompile node with '--release' flag."
echo -e "-p, --profile\n\tCompile node with '--profile [PROFILE]' flag." echo -e "-p, --profile\n\tCompile node with '--profile [PROFILE]' flag."
echo -e "-f, --features\n\tCompilation features '--features=\"FEATURE1,FEATURE2\"'" echo -e "-f, --features\n\tCompilation features '--features=\"FEATURE1,FEATURE2\"'"
@ -55,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 " / ___| |__ ___ ___| |_ | \ | | ___ __| | ___"
@ -79,6 +107,12 @@ while [ $# -gt 0 ]; do
--set-arguments|-a) --set-arguments|-a)
ARGUMENTS=true ARGUMENTS=true
;; ;;
--check-keys|-k)
CHECK_KEYS=true
;;
--insert-keys|-k)
INSERT_KEYS=true
;;
--release|-r) --release|-r)
RELEASE="--release" RELEASE="--release"
TARGET="release" TARGET="release"
@ -292,6 +326,11 @@ if [[ $ARGUMENTS = true ]]; then
CLI_ARGS+=("--no-prometheus") CLI_ARGS+=("--no-prometheus")
fi fi
read -p "[?] list of bootnodes if any: " bootnodes
if [ ! -z $bootnodes ]; then
CLI_ARGS+=("--bootnodes=$bootnodes")
fi
# default for now # default for now
CLI_ARGS+=("--base-path=$NODE_PATH") CLI_ARGS+=("--base-path=$NODE_PATH")
CLI_ARGS+=("--state-pruning=archive") CLI_ARGS+=("--state-pruning=archive")
@ -308,3 +347,41 @@ if [[ $ARGUMENTS = true ]]; then
echo "[+] new CLI arguments stored in '/etc/default/ghost'" echo "[+] new CLI arguments stored in '/etc/default/ghost'"
cat /etc/default/ghost cat /etc/default/ghost
fi fi
if [ $CHECK_KEYS = true ]; then
seed=$(extract_seed "wallet-key")
sanity_check "sr25519" $seed "wallet"
echo "[+] local wallet key found in 'ghosties' with correct key type"
echo
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
read -p "[?] JSON RPC endpoint to the node: (default: localhost:9945) " rpc_endpoint
rpc_endpoint="${rpc_endpoint:-localhost:9945}"
fi
for type in $(echo audi babe gran slow); do
echo "[+] parsing session key for [$type]"
scheme="sr25519"
if [ $type = "gran" ]; then
scheme="ed25519"
fi
sanity_check $scheme "$seed//$type" $type
echo "[+] inspected account id found in 'ghosties' file with correct key type"
if [ $INSERT_KEYS = true ]; then
echo "[+] trying to make an 'author_insertKey' RPC call to $rpc_endpoint..."
curl --location $rpc_endpoint \
--header "Content-Type: application/json" \
--data '{ "id":1, "jsonrpc":"2.0", "method":"author_insertKey", "params": ["'"$type"'", "'"$secret_seed"'", "'"$account_id"'"] }'
fi
echo
done
fi

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 : 0xa0ba0196e6ee7e6b5b0553035c5cb5c04e9725001b5732839d0529cbc00c9600
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