Compare commits

..

No commits in common. "a1423bc9e7a377fcf36fe1201a20ae94095eb69c" and "37a7de8f9370c1dd7c04f8958c41015f1d7225ba" have entirely different histories.

3 changed files with 56 additions and 133 deletions

View File

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

View File

@ -2,8 +2,6 @@
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
@ -39,29 +37,7 @@ prompt() {
done done
} }
sanity_check() { trap 'final "$?"' EXIT
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"
@ -70,8 +46,6 @@ 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\"'"
@ -81,8 +55,6 @@ 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 " / ___| |__ ___ ___| |_ | \ | | ___ __| | ___"
@ -107,12 +79,6 @@ 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"
@ -326,11 +292,6 @@ 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")
@ -347,41 +308,3 @@ 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,38 +1,36 @@
### 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
Public key (hex) wallet : ./PATH_TO_GHOST/ghost key inspect $(cat PATH_TO_WALLET_KEY) personal wallet : ./PATH_TO_GHOST/ghost key inspect $(cat PATH_TO_WALLET_KEY)
================================================================================================================== =======================================================================================================
Public key (hex) stash : ./PATH_TO_GHOST/ghost key inspect --scheme=sr25519 $(cat PATH_TO_STASH_KEY) session audi : ./PATH_TO_GHOST/ghost key inspect --scheme=sr25519 "$(cat PATH_TO_SESSION_KEY)//audi"
Public key (hex) audi : ./PATH_TO_GHOST/ghost key inspect --scheme=sr25519 "$(cat PATH_TO_SESSION_KEY)//audi" session babe : ./PATH_TO_GHOST/ghost key inspect --scheme=sr25519 "$(cat PATH_TO_SESSION_KEY)//babe"
Public key (hex) babe : ./PATH_TO_GHOST/ghost key inspect --scheme=sr25519 "$(cat PATH_TO_SESSION_KEY)//babe" session slow : ./PATH_TO_GHOST/ghost key inspect --scheme=sr25519 "$(cat PATH_TO_SESSION_KEY)//slow"
Public key (hex) slow : ./PATH_TO_GHOST/ghost key inspect --scheme=sr25519 "$(cat PATH_TO_SESSION_KEY)//slow" session gran : ./PATH_TO_GHOST/ghost key inspect --scheme=ed25519 "$(cat PATH_TO_SESSION_KEY)//gran"
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