Skip to content

Commit

Permalink
Add ARM64 architecture support
Browse files Browse the repository at this point in the history
  • Loading branch information
coincashew committed Jul 26, 2024
1 parent 64a9d1e commit d72c271
Show file tree
Hide file tree
Showing 12 changed files with 192 additions and 40 deletions.
54 changes: 47 additions & 7 deletions deploy-nimbus-nethermind.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import zipfile
import random
import sys
import platform
from consolemenu import *
from consolemenu.items import *
import argparse
Expand Down Expand Up @@ -125,6 +126,27 @@
args = parser.parse_args()
#print(args)

def get_machine_architecture():
machine_arch=platform.machine()
if machine_arch == "x86_64":
return "amd64"
elif machine_arch == "aarch64":
return "arm64"
else:
print(f'Unsupported machine architecture: {machine_arch}')
exit(1)

def get_computer_platform():
platform_name=platform.system()
if platform_name == "Linux":
return platform_name
else:
print(f'Unsupported platform: {platform_name}')
exit(1)

binary_arch=get_machine_architecture()
platform_arch=get_computer_platform()

# Change to the home folder
os.chdir(os.path.expanduser("~"))

Expand Down Expand Up @@ -321,11 +343,11 @@ def install_mevboost():
global mevboost_version
mevboost_version = response.json()['tag_name']

# Search for the asset with the name that ends in linux_amd64.tar.gz
# Search for the asset with the name that ends in {platform_arch}_{binary_arch}.tar.gz
assets = response.json()['assets']
download_url = None
for asset in assets:
if asset['name'].endswith('linux_amd64.tar.gz'):
if asset['name'].endswith(f'{platform_arch.lower()}_{binary_arch}.tar.gz'):
download_url = asset['browser_download_url']
break

Expand Down Expand Up @@ -418,12 +440,21 @@ def download_and_install_nethermind():
global nethermind_version
nethermind_version = response.json()['tag_name']

# Search for the asset with the name that ends in linux-x64.zip
# Adjust binary name
if binary_arch == "amd64":
_arch="x64"
elif binary_arch == "arm64":
_arch="arm64"
else:
print("Error: Unknown binary architecture.")
exit(1)

# Search for the asset with the name that ends in {platform_arch}-{_arch}.zip
assets = response.json()['assets']
download_url = None
zip_filename = None
for asset in assets:
if asset['name'].endswith('linux-x64.zip'):
if asset['name'].endswith(f'{platform_arch.lower()}-{_arch}.zip'):
download_url = asset['browser_download_url']
zip_filename = asset['name']
break
Expand Down Expand Up @@ -504,11 +535,20 @@ def download_nimbus():
global nimbus_version
nimbus_version = response.json()['tag_name']

# Search for the asset with the name that ends in _Linux_amd64.tar.gz
# Adjust binary name
if binary_arch == "amd64":
_arch="amd64"
elif binary_arch == "arm64":
_arch="arm64v8"
else:
print("Error: Unknown binary architecture.")
exit(1)

# Search for the asset appropriate for this system architecture and platform
assets = response.json()['assets']
download_url = None
for asset in assets:
if '_Linux_amd64' in asset['name'] and asset['name'].endswith('.tar.gz'):
if f'_{platform_arch}_{_arch}' in asset['name'] and asset['name'].endswith('.tar.gz'):
download_url = asset['browser_download_url']
break

Expand All @@ -532,7 +572,7 @@ def download_nimbus():
# Find the extracted folder
extracted_folder = None
for item in os.listdir():
if item.startswith("nimbus-eth2_Linux_amd64"):
if item.startswith(f'nimbus-eth2_{platform.system()}_{_arch}'):
extracted_folder = item
break

Expand Down
19 changes: 18 additions & 1 deletion eth-duties.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,27 @@
#
# Made for home and solo stakers 🏠🥩

# Base directory with scripts
BASE_DIR=$HOME/git/ethpillar

# Load functions
source $BASE_DIR/functions.sh

# Get machine info
_platform=$(get_platform)
_arch=$(get_arch)

# Binaries only available for amd64
if [[ ! "${_arch}" == "amd64" ]]; then
echo "eth-duties binaries are only available for amd64 architecture"
sleep 5
exit 1
fi

# Variables
GITHUB_URL=https://api.github.com/repos/TobiWo/eth-duties/releases/latest
GITHUB_RELEASE_NODES=https://github.com/TobiWo/eth-duties/releases
RELEASE_SUFFIX="ubuntu2204-amd64.tar.gz"
RELEASE_SUFFIX="ubuntu2204-${_arch}.tar.gz"
DESCRIPTION="eth-duties logs upcoming validator duties to the console. Developed mainly for home stakers."
DOCUMENTATION=https://tobiwo.github.io/eth-duties
SOURCE_CODE=https://github.com/TobiWo/eth-duties
Expand Down
14 changes: 12 additions & 2 deletions ethdo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,20 @@
#
# Made for home and solo stakers 🏠🥩

# Base directory with scripts
BASE_DIR=$HOME/git/ethpillar

# Load functions
source $BASE_DIR/functions.sh

# Get machine info
_platform=$(get_platform)
_arch=$(get_arch)

# Variables
GITHUB_URL=https://api.github.com/repos/wealdtech/ethdo/releases/latest
GITHUB_RELEASE_NODES=https://github.com/wealdtech/ethdo/releases
RELEASE_SUFFIX="linux-amd64.tar.gz$"
RELEASE_SUFFIX="${_platform}-${_arch}.tar.gz$"
DESCRIPTION="A command-line tool for managing common tasks in Ethereum"
DOCUMENTATION=https://github.com/wealdtech/ethdo/blob/master/docs/howto.md
SOURCE_CODE=https://github.com/wealdtech/ethdo
Expand All @@ -32,7 +42,7 @@ function getLatestVersion(){

# Downloads latest release
function downloadClient(){
BINARIES_URL="$(curl -s $GITHUB_URL | jq -r ".assets[] | select(.name) | .browser_download_url" | grep ${RELEASE_SUFFIX})"
BINARIES_URL="$(curl -s $GITHUB_URL | jq -r ".assets[] | select(.name) | .browser_download_url" | grep --ignore-case ${RELEASE_SUFFIX})"
echo Downloading URL: $BINARIES_URL
cd $HOME
# Download
Expand Down
17 changes: 10 additions & 7 deletions ethereum-metrics-exporter.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@
#
# Made for home and solo stakers 🏠🥩

BASE_DIR=$HOME/git/ethpillar

# Load functions
source $BASE_DIR/functions.sh

# Get machine info
_platform=$(get_platform)
_arch=$(get_arch)

# Variables
GITHUB_URL=https://api.github.com/repos/ethpandaops/ethereum-metrics-exporter/releases/latest
GITHUB_RELEASE_NODES=https://github.com/ethpandaops/ethereum-metrics-exporter/releases
Expand All @@ -18,12 +27,6 @@ ETHEREUM_METRICS_EXPORTER_OPTIONS=(
GRAFANA_DIR=/etc/grafana
PROMETHEUS_DIR=/etc/prometheus

function getNetworkConfig() {
ip_current=$(hostname --ip-address)
interface_current=$(ip route | grep default | head -1 | sed 's/.*dev \([^ ]*\) .*/\1/')
network_current="$(ip route | grep $interface_current | grep -v default | head -1 | awk '{print $1}')"
}

# Asks to update
function upgradeBinaries(){
getLatestVersion
Expand All @@ -48,7 +51,7 @@ function getLatestVersion(){

# Downloads latest release of ethereum-metrics-exporter
function downloadClient(){
BINARIES_URL="$(curl -s $GITHUB_URL | jq -r ".assets[] | select(.name) | .browser_download_url" | grep linux_amd64.tar.gz$)"
BINARIES_URL="$(curl -s $GITHUB_URL | jq -r ".assets[] | select(.name) | .browser_download_url" | grep --ignore-case ${_platform}_${_arch}.tar.gz$)"
echo Downloading URL: $BINARIES_URL
cd $HOME
# Download
Expand Down
11 changes: 9 additions & 2 deletions ethpillar.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# 🙌 Ask questions on Discord:
# * https://discord.gg/dEpAVWgFNB

EP_VERSION="1.9.1"
EP_VERSION="2.0.0"

# VARIABLES
export BASE_DIR="$HOME/git/ethpillar" && cd $BASE_DIR
Expand All @@ -32,6 +32,10 @@ API_BN_ENDPOINT="http://${CL_IP_ADDRESS}:${CL_REST_PORT}"
# Execution layer RPC API
EL_RPC_ENDPOINT="${EL_IP_ADDRESS}:${EL_RPC_PORT}"

# Get machine info
_platform=$(get_platform)
_arch=$(get_arch)

menuMain(){

# Define the options for the main menu
Expand All @@ -50,7 +54,7 @@ OPTIONS+=(
9 "Restart all clients"
- ""
10 "System Administration"
11 "Tools"
11 "Toolbox"
99 "Quit"
)

Expand Down Expand Up @@ -889,6 +893,8 @@ while true; do
1)
# Skip if no validators installed
if [[ ! -f /etc/systemd/system/validator.service ]]; then echo "No validator(s) installed. Press ENTER to continue."; read; break; fi
# Skip if arm64
[[ "${_arch}" == "arm64" ]] && echo "eth-duties not available for arm64. Press ENTER to continue." && read && break

# Install eth-duties if not yet installed
if [[ ! -f /usr/local/bin/eth-duties ]]; then
Expand Down Expand Up @@ -927,6 +933,7 @@ while true; do
checkValidatorQueue
;;
9)
[[ "${_arch}" == "arm64" ]] && echo "EL Switcher not available for arm64. Press ENTER to continue." && read && break
sudo /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/coincashew/client-switcher/master/install.sh)"
;;
10)
Expand Down
23 changes: 23 additions & 0 deletions functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,29 @@ network_isConnected() {
sudo ip route get 1 2>/dev/null
}

get_arch(){
machine_arch="$(uname --machine)"
if [[ "${machine_arch}" = "x86_64" ]]; then
binary_arch="amd64"
elif [[ "${machine_arch}" = "aarch64" ]]; then
binary_arch="arm64"
else
echo "Unsupported architecture: ${machine_arch}"
exit 1
fi
echo "${binary_arch}"
}

get_platform(){
platform="$(uname)"
if [[ "${platform}" = "Linux" ]]; then
echo "${platform}"
else
echo "Unsupported platform: ${platform}"
exit 1
fi
}

print_node_info() {
current_time=$(date)
os_descrip=$(grep PRETTY_NAME /etc/os-release | sed 's/PRETTY_NAME=//g')
Expand Down
19 changes: 19 additions & 0 deletions install-nimbus-nethermind.sh
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,22 @@ ohai() {
printf "${tty_blue}==>${tty_bold} %s${tty_reset}\n" "$(shell_join "$@")"
}

requirements_check() {
# Check CPU architecture
if ! [[ $(lscpu | grep -oE 'x86') || $(lscpu | grep -oE 'aarch64') ]]; then
echo "This machine's CPU architecture is not yet unsuppported."
echo "Recommend using Intel-AMD x86 or arm64 systems for best experience."
exit 1
fi

# Check operating system
if ! [[ "$(uname)" == "Linux" ]]; then
echo "This operating system is not yet unsuppported."
echo "Recommend installing Ubuntu Desktop 24.04+ LTS or Ubuntu Server 24.04+ LTS for best experience."
exit 1
fi
}

linux_install_pre() {
sudo apt-get update
sudo apt-get install --no-install-recommends --no-install-suggests -y curl git ccze jq tmux bc
Expand Down Expand Up @@ -123,6 +139,9 @@ linux_install_validator-install() {
exit_on_error $?
}

# Check OS and CPU requirements
requirements_check

# Do install.
OS="$(uname)"
if [[ "$OS" == "Linux" ]]; then
Expand Down
6 changes: 3 additions & 3 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ ohai() {

requirements_check() {
# Check CPU architecture
if ! [[ $(lscpu | grep -oE 'x86') ]]; then
if ! [[ $(lscpu | grep -oE 'x86') || $(lscpu | grep -oE 'aarch64') ]]; then
echo "This machine's CPU architecture is not yet unsuppported."
echo "Recommend using Intel or AMD x86 systems for best experience."
echo "Recommend using Intel-AMD x86 or arm64 systems for best experience."
exit 1
fi

Expand All @@ -94,7 +94,7 @@ requirements_check() {

linux_install_pre() {
sudo apt-get update
sudo apt-get install --no-install-recommends --no-install-suggests -y curl git ccze bc tmux jq
sudo apt-get install --no-install-recommends --no-install-suggests -y curl git ccze bc tmux jq nano btop
exit_on_error $?
}

Expand Down
22 changes: 16 additions & 6 deletions manage_validator_keys.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ source $BASE_DIR/functions.sh
# Load Lido CSM withdrawal address and fee recipient
source $BASE_DIR/env

# Get machine info
_platform=$(get_platform)
_arch=$(get_arch)

function downloadStakingDepositCLI(){
if [ -d $STAKING_DEPOSIT_CLI_DIR/staking-deposit-cli ]; then
ohai "staking-deposit-tool already downloaded."
Expand All @@ -30,9 +34,9 @@ function downloadStakingDepositCLI(){

#Setup variables
RELEASE_URL="https://api.github.com/repos/ethereum/staking-deposit-cli/releases/latest"
BINARIES_URL="$(curl -s $RELEASE_URL | jq -r ".assets[] | select(.name) | .browser_download_url" | grep linux-amd64.tar.gz$)"
BINARIES_URL="$(curl -s $RELEASE_URL | jq -r ".assets[] | select(.name) | .browser_download_url" | grep --ignore-case ${_platform}-${_arch}.tar.gz$)"
BINARY_FILE="staking-deposit-cli.tar.gz"

[[ -z $BINARIES_URL ]] && echo "Error: Unable to determine BINARIES URL" && exit 1
ohai "Downloading URL: $BINARIES_URL"
# Dir to install staking-deposit-cli
cd $STAKING_DEPOSIT_CLI_DIR
Expand All @@ -43,7 +47,7 @@ function downloadStakingDepositCLI(){
# Cleanup
rm staking-deposit-cli.tar.gz
# Rename
mv staking_deposit-cli*amd64 staking-deposit-cli
mv staking_deposit-cli*${_arch} staking-deposit-cli
cd staking-deposit-cli
}

Expand Down Expand Up @@ -236,7 +240,7 @@ function loadKeys(){
getLAUNCHPAD_URL
queryValidatorQueue
setLaunchPadMessage
whiptail --title "Next Steps: Upload JSON Deposit Data File" --msgbox "$MSG_LAUNCHPAD" 31 78
whiptail --title "Next Steps: Upload JSON Deposit Data File" --msgbox "$MSG_LAUNCHPAD" 40 78
ohai "Finished loading keys. Press enter to continue."
read
promptViewLogs
Expand All @@ -251,7 +255,10 @@ function setLaunchPadMessage(){
\n5) Wait for validators to become active. $MSG_VALIDATOR_QUEUE
\nTips:
\n - Wait for Node Sync: Before making a deposit, ensure your EL/CL client is synced to avoid missing rewards.
\n - Timing of Validator Activation: After depositing, it takes about 15 hours for a validator to be activated unless there's a long entry queue."
\n - Timing of Validator Activation: After depositing, it takes about 15 hours for a validator to be activated unless there's a long entry queue.
\n - Backup Keystores: For faster recovery, keep copies of the keystore files on offline USB storage.
\n Location: ~/staking-deposit-cli/$(basename $KEYFOLDER)
\n - Cleanup Keystores: Delete keystore files from node after backup."

MSG_LAUNCHPAD_LIDO="1) Visit Lido CSM: $LAUNCHPAD_URL_LIDO
\n2) Connect your wallet on the correct network, review and accept terms.
Expand All @@ -263,7 +270,10 @@ cat ~/staking-deposit-cli/$(basename $KEYFOLDER)/deposit*json
\nTips:
\n - DO NOT DEPOSIT 32ETH YOURSELF: Lido will handle the validator deposit for you.
\n - Wait for Node Sync: Before making the ~2ETH bond deposit, ensure your EL/CL client is synced to avoid missing rewards.
\n - Timing of Validator Activation: After depositing, it takes about 15 hours for a validator to be activated unless there's a long entry queue."
\n - Timing of Validator Activation: After depositing, it takes about 15 hours for a validator to be activated unless there's a long entry queue.
\n - Backup Keystores: For faster recovery, keep copies of the keystore files on offline USB storage.
\n Location: ~/staking-deposit-cli/$(basename $KEYFOLDER)
\n - Cleanup Keystores: Delete keystore files from node after backup."
if [[ $(grep -oE "${CSM_FEE_RECIPIENT_ADDRESS}" /etc/systemd/system/validator.service) ]]; then
# Update message for Lido
MSG_LAUNCHPAD="${MSG_LAUNCHPAD_LIDO}"
Expand Down
Loading

0 comments on commit d72c271

Please sign in to comment.