Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
f16ac6e
installer script for linux and mac
n13 May 21, 2025
4850c56
more scripts
n13 May 21, 2025
c431b7e
formatting
n13 May 21, 2025
ced6d2c
move to github
n13 May 21, 2025
cfa0140
generate 24 words
n13 May 21, 2025
f06f0a9
print seed, make standard scheme default
n13 May 21, 2025
c331e9d
unit tests and seed phrase length
n13 May 21, 2025
f5ae67e
more better parsing
n13 May 21, 2025
490effe
known value test added, refactor
n13 May 21, 2025
e3f71fc
comment
n13 May 21, 2025
6d3eb7e
underscore names
n13 May 21, 2025
710d169
fix create address script
n13 May 21, 2025
47d44b1
script updates
n13 May 22, 2025
ab85f96
some additions
n13 May 23, 2025
3dc7f29
move rusty-crystals to github
n13 May 24, 2025
19a3113
CLI updates
n13 May 24, 2025
a22c6cb
moved test data to file
n13 May 24, 2025
5c3c78e
Merge branch 'feature/update_cli' into feature/installer-script
n13 May 24, 2025
259b9c8
remove redundant comments
n13 May 24, 2025
2a7ef77
Merge branch 'feature/update_cli' into feature/installer-script
n13 May 24, 2025
0c6cc45
poseidon-resonance 0.5.0
n13 May 24, 2025
15b4035
Merge branch 'move_to_github' into feature/update_cli
n13 May 24, 2025
b55d773
Merge branch 'main' into feature/update_cli
n13 May 26, 2025
84a53e0
merge from main
n13 May 26, 2025
586a16a
Update readme for new CLI commands
n13 May 26, 2025
735d3bc
Merge branch 'feature/update_cli' into feature/installer-script
n13 May 26, 2025
80e2632
clean and install scripts
n13 May 26, 2025
d91ab0e
better install
n13 May 26, 2025
21f69dc
fix commands
n13 May 26, 2025
b31017b
Merge branch 'main' into feature/installer-script
n13 May 27, 2025
607453a
remove stray file
n13 May 27, 2025
17331cc
fix install script
n13 May 28, 2025
5c6dac8
Update install-quantus-node.sh
n13 May 28, 2025
62b55c7
rename key file - its not a json file
n13 May 28, 2025
2695fb2
remove stuff we don't need
n13 May 28, 2025
3e8625e
chain params
n13 May 28, 2025
26184d1
remove unneeded change
n13 May 28, 2025
3d66288
start script
n13 May 28, 2025
da4eaad
more params
n13 May 28, 2025
2394e30
comments added
n13 May 28, 2025
f9de22e
cooler printout at the end
n13 May 29, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions scripts/clean-quantus-node.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#!/bin/bash

# Clean an existing quantus node installation
#
# USAGE:
# ./clean-quantus-node.sh
#
# This script will remove the Quantus node binary, node identity file, and rewards address file.
# It will also remove the Quantus home directory.
#

set -e

# Configuration
SYSTEM_BINARY_PATH="/usr/local/bin/quantus-node"
USER_BINARY_PATH="$HOME/.local/bin/quantus-node"
QUANTUS_HOME="$HOME/.quantus"
NODE_IDENTITY_PATH="$QUANTUS_HOME/node_key.p2p"
REWARDS_ADDRESS_PATH="$QUANTUS_HOME/rewards-address.txt"

echo "Starting Quantus node cleanup..."

# Remove system node binary
if [ -f "$SYSTEM_BINARY_PATH" ]; then
echo "Deleting system node binary: $SYSTEM_BINARY_PATH"
sudo rm -f "$SYSTEM_BINARY_PATH"
echo "✓ System node binary deleted"
else
echo "No system node binary found at: $SYSTEM_BINARY_PATH"
fi

# Remove user node binary
if [ -f "$USER_BINARY_PATH" ]; then
echo "Deleting user node binary: $USER_BINARY_PATH"
rm -f "$USER_BINARY_PATH"
echo "✓ User node binary deleted"
else
echo "No user node binary found at: $USER_BINARY_PATH"
fi

# Remove node identity file
if [ -f "$NODE_IDENTITY_PATH" ]; then
echo "Deleting node identity file: $NODE_IDENTITY_PATH"
rm -f "$NODE_IDENTITY_PATH"
echo "✓ Node identity file deleted"
else
echo "No node identity file found at: $NODE_IDENTITY_PATH"
fi

# Remove rewards address file
if [ -f "$REWARDS_ADDRESS_PATH" ]; then
echo "Deleting rewards address file: $REWARDS_ADDRESS_PATH"
rm -f "$REWARDS_ADDRESS_PATH"
echo "✓ Rewards address file deleted"
else
echo "No rewards address file found at: $REWARDS_ADDRESS_PATH"
fi

# Remove Quantus home directory
if [ -d "$QUANTUS_HOME" ]; then
echo "Deleting Quantus home directory: $QUANTUS_HOME"
rm -rf "$QUANTUS_HOME"
echo "✓ Quantus home directory deleted"
else
echo "No Quantus home directory found at: $QUANTUS_HOME"
fi

echo "Clean completed successfully!"
275 changes: 275 additions & 0 deletions scripts/install-quantus-node.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,275 @@
#!/bin/bash

# Install the Quantus node binary
#
# USAGE:
# ./install-quantus-node.sh
#
# This script will install the Quantus node binary, create a node identity file, and create a rewards address file.
# It will also create the Quantus home directory.

set -e

# Get the directory where the script is located
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"

# Configuration
REPO_OWNER="Quantus-Network"
REPO_NAME="chain"
BINARY_NAME="quantus-node"
QUANTUS_HOME="$HOME/.quantus"
NODE_IDENTITY_PATH="$QUANTUS_HOME/node_key.p2p"
REWARDS_ADDRESS_PATH="$QUANTUS_HOME/rewards-address.txt"

# Detect OS and Architecture
OS=""
ARCH=""
TARGET_ARCH_NAME=""

case "$(uname -s)" in
Linux*)
OS="linux"
;;
Darwin*)
OS="macos"
;;
*)
echo "Unsupported operating system: $(uname -s)"
exit 1
;;
esac

case "$(uname -m)" in
x86_64|amd64)
ARCH="x86_64"
if [ "$OS" = "linux" ]; then
TARGET_ARCH_NAME="x86_64-unknown-linux-gnu"
elif [ "$OS" = "macos" ]; then
TARGET_ARCH_NAME="x86_64-apple-darwin"
fi
;;
arm64|aarch64)
ARCH="arm64"
if [ "$OS" = "linux" ]; then
TARGET_ARCH_NAME="aarch64-unknown-linux-gnu"
elif [ "$OS" = "macos" ]; then
TARGET_ARCH_NAME="aarch64-apple-darwin"
fi
;;
*)
echo "Unsupported architecture: $(uname -m)"
exit 1
;;
esac

echo "Detected OS: $OS"
echo "Detected Architecture: $ARCH (Target: $TARGET_ARCH_NAME)"

# Determine installation path based on root status
if [ "$EUID" -eq 0 ]; then
NODE_BINARY_PATH="/usr/local/bin/quantus-node"
else
NODE_BINARY_PATH="$HOME/.local/bin/quantus-node"
# Create .local/bin if it doesn't exist
mkdir -p "$(dirname "$NODE_BINARY_PATH")"
echo "Installing node binary to user directory: $NODE_BINARY_PATH"
echo "Note: Make sure $HOME/.local/bin is in your PATH"
echo "You can add it by running:"
echo " echo 'export PATH=\"\$HOME/.local/bin:\$PATH\"' >> ~/.bashrc # for bash"
echo " echo 'export PATH=\"\$HOME/.local/bin:\$PATH\"' >> ~/.zshrc # for zsh"
echo "Then source your shell config file or open a new terminal"
fi

# Function to download and install the node binary
install_node_binary() {
echo "Downloading latest Quantus node binary..."
# Create a temporary directory for the download
TEMP_DIR=$(mktemp -d)
trap 'rm -rf "$TEMP_DIR"' EXIT

# Get the latest release info
echo "Fetching latest release information..."
LATEST_RELEASE=$(curl -s https://api.github.com/repos/${REPO_OWNER}/${REPO_NAME}/releases/latest)
if [ -z "$LATEST_RELEASE" ]; then
echo "Error: Failed to fetch latest release information"
exit 1
fi

LATEST_TAG=$(echo "$LATEST_RELEASE" | grep -o '"tag_name": "[^"]*"' | head -n 1 | cut -d'"' -f4)
if [ -z "$LATEST_TAG" ]; then
echo "Error: Could not find latest release tag"
exit 1
fi

echo "Latest release tag: $LATEST_TAG"

# Construct the asset filename and URL
ASSET_FILENAME="${BINARY_NAME}-${LATEST_TAG}-${TARGET_ARCH_NAME}.tar.gz"
ASSET_URL="https://github.com/${REPO_OWNER}/${REPO_NAME}/releases/download/${LATEST_TAG}/${ASSET_FILENAME}"

echo "Attempting to download asset: $ASSET_URL"

# Download the asset
if ! curl -L "$ASSET_URL" -o "$TEMP_DIR/$ASSET_FILENAME"; then
echo "Error: Failed to download node binary"
exit 1
fi

echo "Asset downloaded to $TEMP_DIR/$ASSET_FILENAME"

# Extract the binary
echo "Extracting $BINARY_NAME from $TEMP_DIR/$ASSET_FILENAME..."
tar -xzf "$TEMP_DIR/$ASSET_FILENAME" -C "$TEMP_DIR"

# Verify extracted binary
if [ ! -f "$TEMP_DIR/$BINARY_NAME" ]; then
echo "Error: Failed to extract $BINARY_NAME from the archive"
exit 1
fi

chmod +x "$TEMP_DIR/$BINARY_NAME"

# Move to final location
mv "$TEMP_DIR/$BINARY_NAME" "$NODE_BINARY_PATH"

echo "Node binary installed successfully at $NODE_BINARY_PATH"
}

# Function to handle node identity setup
setup_node_identity() {
echo "Checking node identity setup..."
if [ ! -f "$NODE_IDENTITY_PATH" ]; then
echo "No node identity file found at $NODE_IDENTITY_PATH"
echo "Would you like to:"
echo "[1] Provide a path to an existing node identity file"
echo "[2] Generate a new node identity"
read -p "Enter your choice (1/2): " choice

case $choice in
1)
read -p "Enter the path to your node identity file: " identity_path
if [ -f "$identity_path" ]; then
cp "$identity_path" "$NODE_IDENTITY_PATH"
echo "Node identity file copied to $NODE_IDENTITY_PATH"
else
echo "Error: File not found at $identity_path"
exit 1
fi
;;
2)
echo "Generating new node identity..."
if ! command -v "$NODE_BINARY_PATH" &> /dev/null; then
echo "Error: Node binary not found at $NODE_BINARY_PATH"
exit 1
fi
$NODE_BINARY_PATH key generate-node-key --file "$NODE_IDENTITY_PATH"
echo "New node identity generated and saved to $NODE_IDENTITY_PATH"
;;
*)
echo "Invalid choice"
exit 1
;;
esac
else
echo "Node identity file already exists at $NODE_IDENTITY_PATH"
fi
}

secret_phrase=""

# Function to handle rewards address setup
setup_rewards_address() {
echo "Checking rewards address setup..."
if [ ! -f "$REWARDS_ADDRESS_PATH" ]; then
echo "No rewards address found at $REWARDS_ADDRESS_PATH"
echo "Would you like to:"
echo "[1] Provide an existing rewards address"
echo "[2] Generate a new rewards address"
read -p "Enter your choice (1/2): " choice

case $choice in
1)
read -p "Enter your rewards address: " address
echo "$address" > "$REWARDS_ADDRESS_PATH"
echo "Rewards address saved to $REWARDS_ADDRESS_PATH"
;;
2)
echo "Generating new rewards address..."
if ! command -v "$NODE_BINARY_PATH" &> /dev/null; then
echo "Error: Node binary not found at $NODE_BINARY_PATH"
exit 1
fi
# Generate new address and capture all output
output=$($NODE_BINARY_PATH key quantus)

# Extract the address (assuming it's the last line)
address=$(echo "$output" | grep "Address:" | awk '{print $2}')

# Secret phrase: shadow valve wild recall jeans blush mandate diagram recall slide alley water wealth transfer soup fit above army crisp involve level trust rabbit panda
line=$(printf '%s\n' "$output" | grep "Secret phrase:")
# strip everything up through "Secret phrase: "
secret_phrase="${line#*Secret phrase: }"

# Save only the address to the file
echo "$address" > "$REWARDS_ADDRESS_PATH"

# Display all details to the user
echo "New rewards address generated. Please save these details securely:"
echo "$output"
echo "Address has been saved to $REWARDS_ADDRESS_PATH"
;;
*)
echo "Invalid choice"
exit 1
;;
esac
else
echo "Rewards address already exists at $REWARDS_ADDRESS_PATH"
fi
}

# Main installation process
echo "Starting Quantus node installation..."

# Create Quantus home directory if it doesn't exist
echo "Creating Quantus home directory at $QUANTUS_HOME"
mkdir -p "$QUANTUS_HOME"

# Install node binary
install_node_binary

# Verify node binary is installed and executable
if ! command -v "$NODE_BINARY_PATH" &> /dev/null; then
echo "Error: Node binary not found at $NODE_BINARY_PATH after installation"
exit 1
fi

# Setup node identity
setup_node_identity

# Setup rewards address
setup_rewards_address

echo "Installation completed successfully!"
echo "Node binary: $NODE_BINARY_PATH"
echo "Node identity: $NODE_IDENTITY_PATH"
echo "Rewards address: $REWARDS_ADDRESS_PATH"
if [ "$secret_phrase" != "" ]; then
echo ""
echo "PLEASE SAVE YOUR SECRET PHRASE IN A SAFE PLACE"
echo "Secret phrase: $secret_phrase"
fi
echo ""
echo "To start mining Quantus node, run the following command:"
echo ""
cat <<EOF
$NODE_BINARY_PATH \\
--node-key-file "$NODE_IDENTITY_PATH" \\
--rewards-address "$REWARDS_ADDRESS_PATH" \\
--validator \\
--chain live_resonance \\
--port 30333 \\
--prometheus-port 9616 \\
--name "ResonanceLiveTestnetNode" \\
--experimental-rpc-endpoint "listen-addr=127.0.0.1:9944,methods=unsafe,cors=all"
EOF
21 changes: 21 additions & 0 deletions scripts/start_testnet.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash

# Start a Quantus node in testnet mode
#
# USAGE:
# ./start_testnet.sh
#
# This script will start a Quantus node in testnet mode (Resonance Live Testnet)
#

rm -rf /tmp/validator1

./target/release/quantus-node \
--base-path /tmp/validator1 \
--chain live_resonance \
--port 30333 \
--prometheus-port 9616 \
--name ResonanceLiveTestnetNode \
--experimental-rpc-endpoint "listen-addr=127.0.0.1:9944,methods=unsafe,cors=all" \
--node-key cffac33ca656d18f3ae94393d01fe03d6f9e8bf04106870f489acc028b214b15 \
--validator