From 141f05ddab1e7aaf76894244294e560776baa4ac Mon Sep 17 00:00:00 2001 From: Uncle Stinky Date: Tue, 29 Jul 2025 16:00:58 +0300 Subject: [PATCH] finalize hard reset for starter script Signed-off-by: Uncle Stinky --- scripts/starter.sh | 50 ++++++++++++++++++++++++++++------------------ 1 file changed, 31 insertions(+), 19 deletions(-) diff --git a/scripts/starter.sh b/scripts/starter.sh index 2f7caf7..c963cc8 100755 --- a/scripts/starter.sh +++ b/scripts/starter.sh @@ -80,6 +80,29 @@ extract_seed() { echo $seed } +downgrade_compiler_if_needed() { + # TODO: uncomment later + # echo "[+] fetching the latest ghost-node source code" + # git switch main + # git pull origin main + + # 1.83.0 works fine, tested with: + # ... + # 1.87.0 throws errors during compilation + # 1.88.0 throws errors during compilation + LATEST_TESTED_VERSION=83 + cargo_version=$(cargo --version | cut -d'.' -f2) + if [ "$cargo_version" -gt "$LATEST_TESTED_VERSION" ]; then + echo "[+] downgrading rustc compiler version to 1.83.0" + rustup default 1.83.0 + toolchain_name=$(rustup show | grep default | head -n 1 | cut -d' ' -f1) + rustup target add wasm32-unknown-unknown --toolchain $toolchain_name + rustup component add rust-src --toolchain $toolchain_name + else + echo "[+] rustc compiler version is compatible" + fi +} + help() { echo -e "Ghost Node Build automation tool. Helper for Ghost Node environment preparation.\n" echo -e "With no OPTION nothing will happen, possible OPTION:\n" @@ -195,22 +218,11 @@ if [[ $HARD_RESET = true ]]; then exit 1 fi - cd $PROJECT_FOLDER - # TODO: uncomment later - # echo "[+] fetching the latest ghost-node source code" - # git switch main - # git pull origin main - - # rustc version control, this works fine - # cargo --version | cut -d'.' -f2, if higher then do - # rustup default 1.83.0 - # rustup target add wasm32-unknown-unknown --toolchain 1.83.0-x86_64-unknown-linux-gnu - # rustup component add rust-src --toolchain 1.83.0-x86_64-unknown-linux-gnu - # - # I think we need to do clean before recompilation - # cargo clean + downgrade_compiler_if_needed cd $PROJECT_FOLDER + echo "[+] clean build cache..." + cargo clean echo "[+] starting build in 3 seconds..." sleep 3 cargo build $RELEASE $FEATURES @@ -228,8 +240,9 @@ if [[ $HARD_RESET = true ]]; then echo "[+] ghost executable copied in '$EXECUTABLE_PATH' from '$TARGET'" echo "[+] specification '$SPECIFICATION_NAME.json' copied to '$SPECIFICATION_PATH'" - echo "[+] starting ghost-node" - sudo systemctl start ghost-node + # TODO: uncomment later + # echo "[+] starting ghost-node" + # sudo systemctl start ghost-node exit 0 fi @@ -312,13 +325,12 @@ if [[ $SET_ENVIRONMENT = true ]]; then if prompt "[?] setup the rust environment (e.g. WASM support)?"; then rustup default stable - rustup update - rustup target add wasm32-unknown-unknown - rustup component add rust-src + downgrade_compiler_if_needed fi fi if [[ ! -z $RELEASE ]]; then + downgrade_compiler_if_needed if prompt "[?] 'cargo build $RELEASE $FEATURES' is what you want?"; then cd $PROJECT_FOLDER echo "[+] starting build in 3 seconds..."