From 4842fc51081e895566d7854d8ad12fd34ece9c34 Mon Sep 17 00:00:00 2001 From: Uncle Stretch Date: Sun, 1 Nov 2026 14:40:39 +0300 Subject: [PATCH] update keytype ID prefix to 'wevr' for validator consistency Signed-off-by: Uncle Stretch --- Cargo.lock | 2 +- pallets/weaver/Cargo.toml | 2 +- pallets/weaver/src/lib.rs | 2 +- pallets/weaver/src/tests.rs | 4 +-- scripts/starter.sh | 54 +++++++++++++++++++++++++++++++++++-- 5 files changed, 57 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 33965f8..ee13a1b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4114,7 +4114,7 @@ dependencies = [ [[package]] name = "ghost-weaver" -version = "0.0.24" +version = "0.0.25" dependencies = [ "frame-benchmarking", "frame-support", diff --git a/pallets/weaver/Cargo.toml b/pallets/weaver/Cargo.toml index 350afb9..1a43f92 100644 --- a/pallets/weaver/Cargo.toml +++ b/pallets/weaver/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ghost-weaver" -version = "0.0.24" +version = "0.0.25" description = "Weaving a secure cryptographic tapestry across different external chains." license.workspace = true authors.workspace = true diff --git a/pallets/weaver/src/lib.rs b/pallets/weaver/src/lib.rs index b8dadcf..4191607 100644 --- a/pallets/weaver/src/lib.rs +++ b/pallets/weaver/src/lib.rs @@ -66,7 +66,7 @@ pub use pallet::*; pub mod sr25519 { mod app_sr25519 { use sp_application_crypto::{app_crypto, sr25519, KeyTypeId}; - const WEAVER: KeyTypeId = KeyTypeId(*b"weav"); + const WEAVER: KeyTypeId = KeyTypeId(*b"wevr"); app_crypto!(sr25519, WEAVER); } diff --git a/pallets/weaver/src/tests.rs b/pallets/weaver/src/tests.rs index 57b7386..072ad75 100644 --- a/pallets/weaver/src/tests.rs +++ b/pallets/weaver/src/tests.rs @@ -284,7 +284,7 @@ fn offchain_worker_should_fetch_block_and_submit_unsigned_tx() { ); sp_io::crypto::sr25519_generate( - sp_core::crypto::KeyTypeId(*b"weav"), + sp_core::crypto::KeyTypeId(*b"wevr"), Some(b"//Alice".to_vec()), ); }); @@ -465,7 +465,7 @@ fn offchain_worker_should_fetch_hash_and_submit_unsigned_tx() { ); sp_io::crypto::sr25519_generate( - sp_core::crypto::KeyTypeId(*b"weav"), + sp_core::crypto::KeyTypeId(*b"wevr"), Some(b"//Alice".to_vec()), ); }); diff --git a/scripts/starter.sh b/scripts/starter.sh index dde3bc7..ff52340 100755 --- a/scripts/starter.sh +++ b/scripts/starter.sh @@ -9,6 +9,7 @@ UNIT_FILE=false SKIP_BUILD=false SET_ENVIRONMENT=false VALIDATE=false +FIX_WEAVER_KEYSTORE=false EXECUTABLE_PATH="/usr/bin/" SPECIFICATION_PATH="/etc/ghost/" BASE_PATH="/var/lib/ghost" @@ -120,7 +121,8 @@ help() { echo -e "-s, --base-path\n\tPath to the folder with chain database ('/var/lib/ghost' is default)." echo -e "-c, --specification-path\n\tPath to specification ('/etc/ghost' is default)." echo -e "-n, --specification-name\n\tSpecification name to be used ('casper' is default)." - echo -e "-g, --generate-genesis\n\tGenerate keys to participate in the genesis file." + echo -e "--generate-genesis\n\tGenerate keys to participate in the genesis file." + echo -e "--fix-weaver-keystore\n\tFix keystore prefixes (weav -> wevr) to ensure the offchain worker can find the key." echo -e "--hard-reset-i-know-what-im-doing\n\tWill completely remove ledger along with associated session keys." echo -e "-h, --help\n\tPrints help information." } @@ -192,9 +194,12 @@ while [ $# -gt 0 ]; do --hard-reset-i-know-what-im-doing) HARD_RESET=true ;; - --generate-genesis|-g) + --generate-genesis) GENERATE_GENESIS=true ;; + --check-keys) + FIX_WEAVER_KEYSTORE=true + ;; --help|-h) help exit 0 @@ -528,6 +533,51 @@ if [ $UNIT_FILE = true ]; then fi fi +if [ $FIX_WEAVER_KEYSTORE = true ]; then + echo "[+] Starting keystore prefix fix (weav -> wevr)..." + + KEYSTORE_DIR="${BASE_PATH%/}/chains/${SPECIFICATION_NAME}_staging_testnet/keystore" + + echo "[+] Requesting sudo privileges to modify keystore files..." + sudo -v + + if ! sudo test -d "$KEYSTORE_DIR"; then + echo "[-] Keystore directory not found at: $KEYSTORE_DIR" + echo "[-] Please check your --base-path and --specification-name settings." + exit 1 + fi + + WRONG_PREFIX="77656176" # "weav" + CORRECT_PREFIX="77657672" # "wevr" + CHANGES_MADE=0 + + while IFS= read -r file; do + if sudo test -f "$file"; then + filename=$(basename "$file") + if [[ "$filename" == "$WRONG_PREFIX"* ]]; then + new_filename="${CORRECT_PREFIX}${filename#$WRONG_PREFIX}" + new_file_path="$KEYSTORE_DIR/$new_filename" + + if sudo test -f "$new_file_path"; then + echo "[!] WARNING: File with correct prefix already exists: $new_filename. Skipping." + else + sudo mv "$file" "$new_file_path" + echo "[+] Renamed: $filename -> $new_filename" + CHANGES_MADE=1 + fi + fi + fi + done < <(sudo find "$KEYSTORE_DIR" -maxdepth 1 -type f) + + if [ $CHANGES_MADE -eq 1 ]; then + echo "[+] Keystore fix applied successfully." + echo "[+] IMPORTANT: You must restart the ghost-node service for changes to take effect." + echo "[+] Run: sudo systemctl restart ghost-node" + else + echo "[+] No files with the wrong 'weav' prefix were found. Everything is fine." + fi +fi + if [ "$GENERATE_GENESIS" = true ]; then echo "[+] Generating keys for genesis configuration..."