Skip to content

Commit

Permalink
update - firedancer setup
Browse files Browse the repository at this point in the history
  • Loading branch information
POPPIN-FUMI committed Feb 10, 2025
1 parent 0dd51b9 commit 4fe3560
Show file tree
Hide file tree
Showing 51 changed files with 1,551 additions and 111 deletions.
2 changes: 1 addition & 1 deletion cli/deno.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@slv/cli",
"version": "0.5.0",
"version": "0.5.1",
"exports": "./dist/exe",
"publish": {
"include": ["src"],
Expand Down
4 changes: 2 additions & 2 deletions cli/src/validator/init/initTestnetConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ const initTestnetConfig = async (sshConnection: SSHConnection) => {
name: 'validatorType',
message: 'Select Validator Type',
type: Select,
options: ['firedancer', 'agave'],
default: 'agave',
options: ['firedancer'],
default: 'firedancer',
},
])
if (!validatorType) {
Expand Down
2 changes: 1 addition & 1 deletion cli/uploadExe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const uploadExe = async () => {
console.log(`Uploading slv v${version} to Solana`)
await Promise.all(compileTargets.map(async (target) => {
const cmd =
`aws --endpoint-url=https://278a7109e511280594fe6a2ebb778333.r2.cloudflarestorage.com/slv s3 cp slv-${target}-exe.tar.gz s3://slv/${version}/${target}-exe.tar.gz --content-disposition 'attachment; filename=install'`
`aws --endpoint-url=https://278a7109e511280594fe6a2ebb778333.r2.cloudflarestorage.com/slv s3 cp ${target}-exe.tar.gz s3://slv/${version}/${target}-exe.tar.gz --content-disposition 'attachment; filename=install'`
const result = await spawnSync(cmd, './dist')
console.log(result.message)
}))
Expand Down
6 changes: 3 additions & 3 deletions deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
"dev": "deno run -A --watch cli/src/index.ts",
"build:all": "deno task build && deno task upload:script && deno task upload:exe && deno task upload:template && deno task purge:cache",
"build": "deno task build:linux & deno task build:mac",
"build:linux": "deno compile -A --target x86_64-unknown-linux-gnu --no-check --output dist/slv-x86_64-unknown-linux-gnu-exe cli/src/index.ts && tar -czvf dist/slv-x86_64-unknown-linux-gnu-exe.tar.gz dist/slv-x86_64-unknown-linux-gnu-exe",
"build:mac": "deno compile -A --target x86_64-apple-darwin --no-check --output dist/slv-x86_64-apple-darwin-exe cli/src/index.ts && tar -czvf dist/slv-x86_64-apple-darwin-exe.tar.gz dist/slv-x86_64-apple-darwin-exe",
"build:linux": "deno compile -A --target x86_64-unknown-linux-gnu --no-check --output dist/x86_64-unknown-linux-gnu-exe cli/src/index.ts && tar -czvf dist/x86_64-unknown-linux-gnu-exe.tar.gz dist/x86_64-unknown-linux-gnu-exe",
"build:mac": "deno compile -A --target x86_64-apple-darwin --no-check --output dist/x86_64-apple-darwin-exe cli/src/index.ts && tar -czvf dist/x86_64-apple-darwin-exe.tar.gz dist/x86_64-apple-darwin-exe",
"upload:script": "cd ./sh/ && aws --endpoint-url=https://278a7109e511280594fe6a2ebb778333.r2.cloudflarestorage.com/slv s3 cp install s3://slv/ --content-disposition 'attachment; filename=install'",
"upload:exe": "deno run -A cli/uploadExe.ts",
"upload:template": "tar -czf dist/template.tar.gz ./template/0.5.0 && deno run -A cli/uploadTemplate.ts",
"upload:template": "tar -czf dist/template.tar.gz ./template/0.5.1 && deno run -A cli/uploadTemplate.ts",
"purge:cache": "deno run -A cmn/lib/purgeR2Cache.ts",
"slv-dev": "npm run --prefix website/slv-dev"
},
Expand Down
15 changes: 8 additions & 7 deletions sh/0.5.0/install
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ install_slv() {
mkdir -p "$HOME/.slv"
mkdir -p "$HOME/.slv/keys"

if [ "$platform" == "x86_64-pc-windows-msvc" ]; then
if [ "$platform" = "x86_64-pc-windows-msvc" ]; then
INSTALL_DIR="$HOME/.local/bin"
mkdir -p "$INSTALL_DIR"
fi
Expand Down Expand Up @@ -63,11 +63,12 @@ install_slv() {
sudo mkdir -p "$INSTALL_DIR"
fi

if [ "$platform" == "x86_64-pc-windows-msvc" ]; then
sudo mv "$SLV_FILE" "$INSTALL_DIR/slv.exe"
else
sudo mv "$SLV_FILE" "$INSTALL_DIR/slv"
sudo chmod +x "$INSTALL_DIR/slv"
if [ "$platform" = "x86_64-apple-darwin" ]; then
SLV_FILE="$TEMP_DIR/slv-x86_64-apple-darwin-exe"
elif [ "$platform" = "x86_64-unknown-linux-gnu" ]; then
SLV_FILE="$TEMP_DIR/slv-x86_64-unknown-linux-gnu-exe"
elif [ "$platform" = "x86_64-pc-windows-msvc" ]; then
SLV_FILE="$TEMP_DIR/slv-x86_64-pc-windows-msvc.exe"
fi

echo "Cleaning up..."
Expand All @@ -77,7 +78,7 @@ install_slv() {

echo "slv has been installed successfully!"
echo "Ensure $INSTALL_DIR is in your PATH."
if [ "$platform" == "x86_64-pc-windows-msvc" ]; then
if [ "$platform" = "x86_64-pc-windows-msvc" ]; then
echo "Windows users, add $INSTALL_DIR to your PATH manually."
fi
mkdir -p ~/.slv/keys
Expand Down
88 changes: 88 additions & 0 deletions sh/0.5.1/install
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
#!/bin/bash

set -e

VERSION="0.5.1"
BASE_URL="https://storage.slv.dev/slv"

detect_platform() {
uname_out="$(uname -s)"
case "${uname_out}" in
Linux*) platform="x86_64-unknown-linux-gnu"; osfamily="linux";;
Darwin*) platform="x86_64-apple-darwin"; osfamily="darwin";;
CYGWIN*|MINGW*|MSYS*|Windows*) platform="x86_64-pc-windows-msvc"; osfamily="windows";;
*) echo "Unsupported platform: ${uname_out}" && exit 1;;
esac
}

install_slv() {
echo "Detecting platform..."
detect_platform
echo "Platform detected: $platform"

DOWNLOAD_URL="${BASE_URL}/${VERSION}/${platform}-exe.tar.gz?cachebuster=$(date +%s)"
TEMPLATE_URL="${BASE_URL}/template/${VERSION}/template.tar.gz?cachebuster=$(date +%s)"
INSTALL_DIR="/usr/local/bin"
TEMPLATE_DIR="$HOME/.slv/template"
TEMP_DIR=$(mktemp -d)
mkdir -p "$HOME/.slv"
mkdir -p "$HOME/.slv/keys"

if [ "$platform" = "x86_64-pc-windows-msvc" ]; then
INSTALL_DIR="$HOME/.local/bin"
mkdir -p "$INSTALL_DIR"
fi

echo "Temporary directory: $TEMP_DIR"

echo "Downloading slv from $DOWNLOAD_URL..."
curl -fsSL "$DOWNLOAD_URL" -o "$TEMP_DIR/slv.tar.gz"

echo "Downloading templates from $TEMPLATE_URL..."
curl -fsSL "$TEMPLATE_URL" -o "$HOME/.slv/template.tar.gz"

echo "Extracting slv..."
tar -xzvf "$TEMP_DIR/slv.tar.gz" -C "$TEMP_DIR" --strip-components=1

echo "Extracting templates..."
tar -xzvf "$HOME/.slv/template.tar.gz" -C "$HOME/.slv" --strip-components=1
mkdir -p "$HOME/.slv/template"
echo "Copying templates to $HOME/.slv/template"

SLV_FILE="$TEMP_DIR/slv-x86_64-apple-darwin-exe"
TEMPLATE_DL_DIR="$HOME/.slv/"

if [ ! -f "$SLV_FILE" ]; then
echo "Error: Extracted file not found."
exit 1
fi

echo "Installing slv..."
if [ ! -d "$INSTALL_DIR" ]; then
echo "$INSTALL_DIR does not exist. Creating it..."
sudo mkdir -p "$INSTALL_DIR"
fi

if [ "$platform" = "x86_64-apple-darwin" ]; then
SLV_FILE="$TEMP_DIR/slv-x86_64-apple-darwin-exe"
elif [ "$platform" = "x86_64-unknown-linux-gnu" ]; then
SLV_FILE="$TEMP_DIR/slv-x86_64-unknown-linux-gnu-exe"
elif [ "$platform" = "x86_64-pc-windows-msvc" ]; then
SLV_FILE="$TEMP_DIR/slv-x86_64-pc-windows-msvc.exe"
fi

echo "Cleaning up..."
rm -rf "$TEMP_DIR"
rm -rf "$TEMP_DIR2"
rm -rf "$HOME/.slv/template.tar.gz"

echo "slv has been installed successfully!"
echo "Ensure $INSTALL_DIR is in your PATH."
if [ "$platform" = "x86_64-pc-windows-msvc" ]; then
echo "Windows users, add $INSTALL_DIR to your PATH manually."
fi
mkdir -p ~/.slv/keys
slv -P
}

install_slv
45 changes: 32 additions & 13 deletions sh/install
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

set -e

VERSION="0.5.0"
VERSION="0.5.1"
BASE_URL="https://storage.slv.dev/slv"

# Detect the platform (Linux/macOS/Windows) based on 'uname'
detect_platform() {
uname_out="$(uname -s)"
case "${uname_out}" in
Expand All @@ -15,31 +16,36 @@ detect_platform() {
esac
}

# Install the 'slv' tool
install_slv() {
echo "Detecting platform..."
detect_platform
echo "Platform detected: $platform"

# Build the download URLs
DOWNLOAD_URL="${BASE_URL}/${VERSION}/${platform}-exe.tar.gz?cachebuster=$(date +%s)"
TEMPLATE_URL="${BASE_URL}/template/${VERSION}/template.tar.gz?cachebuster=$(date +%s)"
INSTALL_DIR="/usr/local/bin"
TEMPLATE_DIR="$HOME/.slv/template"
TEMP_DIR=$(mktemp -d)

# Prepare directories
mkdir -p "$HOME/.slv"
mkdir -p "$HOME/.slv/keys"

if [ "$platform" == "x86_64-pc-windows-msvc" ]; then
# If on Windows, override the install directory
if [ "$platform" = "x86_64-pc-windows-msvc" ]; then
INSTALL_DIR="$HOME/.local/bin"
mkdir -p "$INSTALL_DIR"
fi

echo "Temporary directory: $TEMP_DIR"

echo "Downloading slv from $DOWNLOAD_URL..."
curl -fsSL "$DOWNLOAD_URL" -o "$TEMP_DIR/slv.tar.gz"
# Use --progress-bar to show download progress
curl -fSL --progress-bar "$DOWNLOAD_URL" -o "$TEMP_DIR/slv.tar.gz"

echo "Downloading templates from $TEMPLATE_URL..."
curl -fsSL "$TEMPLATE_URL" -o "$HOME/.slv/template.tar.gz"
curl -fSL --progress-bar "$TEMPLATE_URL" -o "$HOME/.slv/template.tar.gz"

echo "Extracting slv..."
tar -xzvf "$TEMP_DIR/slv.tar.gz" -C "$TEMP_DIR" --strip-components=1
Expand All @@ -49,21 +55,34 @@ install_slv() {
mkdir -p "$HOME/.slv/template"
echo "Copying templates to $HOME/.slv/template"

SLV_FILE="$TEMP_DIR/slv-x86_64-apple-darwin-exe"
TEMPLATE_DL_DIR="$HOME/.slv/"
# Determine the correct executable filename for the current platform
if [ "$platform" = "x86_64-apple-darwin" ]; then
SLV_FILE="$TEMP_DIR/slv-x86_64-apple-darwin-exe"
elif [ "$platform" = "x86_64-unknown-linux-gnu" ]; then
SLV_FILE="$TEMP_DIR/slv-x86_64-unknown-linux-gnu-exe"
elif [ "$platform" = "x86_64-pc-windows-msvc" ]; then
SLV_FILE="$TEMP_DIR/slv-x86_64-pc-windows-msvc.exe"
else
echo "Error: Unsupported platform $platform"
exit 1
fi

# Check if the extracted file exists
if [ ! -f "$SLV_FILE" ]; then
echo "Error: Extracted file not found."
exit 1
fi

echo "Installing slv..."

# Create the install directory if it doesn't exist
if [ ! -d "$INSTALL_DIR" ]; then
echo "$INSTALL_DIR does not exist. Creating it..."
sudo mkdir -p "$INSTALL_DIR"
fi

if [ "$platform" == "x86_64-pc-windows-msvc" ]; then
# Move the executable and make it executable
if [ "$platform" = "x86_64-pc-windows-msvc" ]; then
sudo mv "$SLV_FILE" "$INSTALL_DIR/slv.exe"
else
sudo mv "$SLV_FILE" "$INSTALL_DIR/slv"
Expand All @@ -72,16 +91,16 @@ install_slv() {

echo "Cleaning up..."
rm -rf "$TEMP_DIR"
rm -rf "$TEMP_DIR2"
rm -rf "$HOME/.slv/template.tar.gz"
rm -f "$HOME/.slv/template.tar.gz"

echo "slv has been installed successfully!"
echo "Ensure $INSTALL_DIR is in your PATH."
if [ "$platform" == "x86_64-pc-windows-msvc" ]; then
if [ "$platform" = "x86_64-pc-windows-msvc" ]; then
echo "Windows users, add $INSTALL_DIR to your PATH manually."
fi
mkdir -p ~/.slv/keys
slv -P

# Optional: Test the installed 'slv'
slv -P || true
}

install_slv
99 changes: 99 additions & 0 deletions template/0.5.1/ansible/cmn/create_user.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
---
- name: Create solv user with specific password and configure SSH access
hosts: all
become: yes
vars:
home_paths_authorized_keys: /home/solv/.ssh/authorized_keys
ansible_remote_tmp: /tmp/ansible_tmp
local_public_key_path: "{{ lookup('env', 'HOME') + '/.ssh/id_rsa.pub' }}"
vars_files:
- ~/.slv/config.pwd.yml
tasks:
- name: Ensure solv user exists
user:
name: solv
password: "{{ encrypted_password }}"
state: present
shell: /bin/bash

- name: Ensure .ssh directory exists for solv user
file:
path: /home/solv/.ssh
state: directory
owner: solv
group: solv
mode: "0700"

- name: Add local public key to authorized_keys
lineinfile:
path: "{{ home_paths_authorized_keys }}"
line: "{{ lookup('file', local_public_key_path) }}"
create: yes
owner: solv
group: solv
mode: "0600"

- name: Generate SSH key for solv user if not exists
shell: su - solv -c "ssh-keygen -t rsa -b 4096 -N '' -f /home/solv/.ssh/id_rsa"
args:
creates: /home/solv/.ssh/id_rsa

- name: Ensure correct permissions for .ssh directory
file:
path: /home/solv/.ssh
state: directory
owner: solv
group: solv
mode: "0700"

- name: Ensure correct permissions for authorized_keys
file:
path: "{{ home_paths_authorized_keys }}"
state: file
owner: solv
group: solv
mode: "0600"

- name: Add solv user to sudoers group
user:
name: solv
groups: sudo
append: yes

- name: Configure sudoers file for solv user (no password required)
lineinfile:
path: /etc/sudoers
state: present
regexp: '^solv ALL=\(ALL\) NOPASSWD:ALL'
line: "solv ALL=(ALL) NOPASSWD:ALL"
validate: "visudo -cf %s"

- name: Ensure PubkeyAuthentication is enabled
lineinfile:
path: /etc/ssh/sshd_config
regexp: '^#?PubkeyAuthentication\s+.*'
line: "PubkeyAuthentication yes"
notify:
- restart ssh

- name: Ensure PasswordAuthentication is disabled
lineinfile:
path: /etc/ssh/sshd_config
regexp: '^#?PasswordAuthentication\s+.*'
line: "PasswordAuthentication no"
notify:
- restart ssh

- name: Ensure ChallengeResponseAuthentication is disabled
lineinfile:
path: /etc/ssh/sshd_config
regexp: '^#?ChallengeResponseAuthentication\s+.*'
line: "ChallengeResponseAuthentication no"
notify:
- restart ssh

handlers:
- name: restart ssh
service:
name: ssh
state: restarted
13 changes: 13 additions & 0 deletions template/0.5.1/ansible/cmn/find_unmounted_disks.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

find_unmounted_nvme_disks() {
lsblk -nr -o NAME,TYPE,SIZE,MOUNTPOINT | awk '
$2 == "disk" &&
$1 ~ /^nvme/ &&
(($3 ~ /G$/ && substr($3, 1, length($3)-1) + 0 >= 800) ||
($3 ~ /T$/ && substr($3, 1, length($3)-1) + 0 >= 0.8)) &&
($4 == "" || $4 ~ /^[[:space:]]*$/) &&
system("lsblk -nr -o TYPE /dev/" $1 " | grep -q part") != 0 {print $1}'
}

find_unmounted_nvme_disks
Loading

0 comments on commit 4fe3560

Please sign in to comment.