Skip to content

feat(eth-validator-cli): new plugin. by TobiWo. managing validators via execution layer requests#97

Merged
coincashew merged 2 commits intomainfrom
eth-validator-cli
May 6, 2025
Merged

feat(eth-validator-cli): new plugin. by TobiWo. managing validators via execution layer requests#97
coincashew merged 2 commits intomainfrom
eth-validator-cli

Conversation

@coincashew
Copy link
Copy Markdown
Owner

@coincashew coincashew commented May 6, 2025

Summary by CodeRabbit

  • New Features

    • Added a new plugin option for "eth-validator-cli" in the EthPillar TUI, enabling Ethereum validator management through an interactive menu.
    • Introduced validator operations including switching withdrawal credentials, consolidating validators, withdrawing ETH, and exiting validators.
    • Included options to edit plugin configuration, update, and uninstall the plugin.
  • Chores

    • Added an example environment configuration file to assist with setting up connection endpoints and request limits for the plugin.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented May 6, 2025

"""

Walkthrough

The changes introduce a new plugin, "eth-validator-cli by TobiWo," to the EthPillar TUI. This includes updating the main script to handle the new plugin, adding an example environment configuration, and providing scripts for plugin installation, upgrading, removal, and an interactive menu for Ethereum validator operations.

Changes

File(s) Change Summary
ethpillar.sh Added a new plugins submenu entry for "eth-validator-cli by TobiWo." Handles plugin installation, environment setup, and menu launch.
plugins/eth-validator-cli/env.example Added an example environment file for plugin configuration (RPC URLs, request limits).
plugins/eth-validator-cli/menu.sh Added an interactive Bash menu for managing Ethereum validators via the plugin, with command execution and configuration options.
plugins/eth-validator-cli/plugin_eth-validator-cli.sh Added a helper script for plugin installation, upgrading, and removal, with architecture checks and user dialogs.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant EthPillar TUI
    participant Plugin Installer
    participant Plugin Menu

    User->>EthPillar TUI: Selects "eth-validator-cli" plugin
    EthPillar TUI->>EthPillar TUI: Export env vars, check plugin dir
    alt Plugin not installed
        EthPillar TUI->>Plugin Installer: Run install script (-i)
        Plugin Installer->>EthPillar TUI: Complete installation
    end
    EthPillar TUI->>Plugin Menu: Launch menu.sh
    User->>Plugin Menu: Interact with validator management options
Loading

Poem

In the warren of code, a new path appears,
For validators brave, and Ethereum peers.
With scripts and with menus, the rabbits delight,
Managing keys in the soft glow of night.
Hop, hop, hooray!—a new plugin to try,
EthPillar grows stronger, as blockchains hop by.
🐇✨
"""

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🔭 Outside diff range comments (1)
plugins/eth-validator-cli/plugin_eth-validator-cli.sh (1)

130-152: 🛠️ Refactor suggestion

Provide a default action when no flags supplied.
If the script is invoked without -i, -u, or -r, it silently exits. It’s better to show usage:

if [[ $OPTIND -eq 1 ]]; then
  usage
  exit 1
fi

or force at least one option.

♻️ Duplicate comments (3)
plugins/eth-validator-cli/menu.sh (3)

62-74: Duplicate of previous command-invocation pattern.
The same string-concatenation approach is used in exitCommand. Please apply the array-based fix described above to harden against word splitting.


76-88: Duplicate of previous command-invocation pattern.
switchWithdrawalCredentialTypeCommand also builds command as a string. Refactor to use an array as per the earlier suggestion to avoid edge-case failures.


90-104: Duplicate of previous command-invocation pattern.
withdrawCommand follows the same pattern—please refactor to use an array-based invocation to ensure robust handling of user input.

🧹 Nitpick comments (8)
plugins/eth-validator-cli/env.example (1)

1-3: Consider adding inline documentation to the template.
While the three variables are clear, it would help first-time users if each line had a brief comment explaining its purpose and expected format. For example:

# JSON-RPC endpoint for your execution client
JSON_RPC_URL=http://localhost:8545
# Beacon node API endpoint
BEACON_API_URL=http://localhost:5052
# Maximum number of validator operations per block
MAX_REQUESTS_PER_BLOCK=5
plugins/eth-validator-cli/menu.sh (2)

13-20: Remove or leverage unused color variables.
ShellCheck flags y, b, and p as unused (SC2034). Either delete them or use them for warnings/prompts to avoid stale code.

🧰 Tools
🪛 Shellcheck (0.10.0)

[warning] 14-14: y appears unused. Verify use (or export if used externally).

(SC2034)


[warning] 15-15: b appears unused. Verify use (or export if used externally).

(SC2034)


[warning] 16-16: p appears unused. Verify use (or export if used externally).

(SC2034)


106-160: Add robust error handling and shell safety flags.
Consider adding at the top:

set -euo pipefail

and catching the absence of dependencies (whiptail, jq, etc.) before entering the main loop. This will improve maintainability and prevent partial failures.

plugins/eth-validator-cli/plugin_eth-validator-cli.sh (5)

10-11: Consider enabling strict mode.
Right after the shebang, add:

set -euo pipefail
IFS=$'\n\t'

to catch errors early, avoid unset variables, and handle pipelines correctly.


53-60: Handle missing current_version gracefully.
If the plugin isn’t installed yet, current_version won’t exist. Before reading it:

if [[ ! -f "$PLUGIN_INSTALL_PATH/current_version" ]]; then
  error "No installed version found; please install first (-i)"; return
fi

This prevents confusing upgrade prompts.


63-100: After copying the example env, ensure executables have correct permissions.
You copy env.example to env, but don’t set the menu.sh and client binary as executable. Consider:

sudo chmod +x "$PLUGIN_INSTALL_PATH/eth-validator-cli" "$PLUGIN_INSTALL_PATH/menu.sh"

so users can run the menu immediately.


103-108: Verify removal path before rm -rf.
To avoid catastrophic deletion if PLUGIN_INSTALL_PATH is unset, wrap:

if [[ -d "$PLUGIN_INSTALL_PATH" ]]; then
  sudo rm -rf "$PLUGIN_INSTALL_PATH"
else
  error "Installation directory not found"
fi

111-128: Typo in usage help formatting.
The Options) and About $APP_NAME) lines use a closing parenthesis instead of a colon, which is inconsistent. Changing them to:

Options:
...
About $APP_NAME:

improves readability.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8a6f0aa and e5003c1.

📒 Files selected for processing (4)
  • ethpillar.sh (2 hunks)
  • plugins/eth-validator-cli/env.example (1 hunks)
  • plugins/eth-validator-cli/menu.sh (1 hunks)
  • plugins/eth-validator-cli/plugin_eth-validator-cli.sh (1 hunks)
🧰 Additional context used
🪛 Shellcheck (0.10.0)
plugins/eth-validator-cli/plugin_eth-validator-cli.sh

[warning] 31-31: _arch is referenced but not assigned.

(SC2154)


[warning] 35-35: _platform is referenced but not assigned.

(SC2154)

plugins/eth-validator-cli/menu.sh

[warning] 14-14: y appears unused. Verify use (or export if used externally).

(SC2034)


[warning] 15-15: b appears unused. Verify use (or export if used externally).

(SC2034)


[warning] 16-16: p appears unused. Verify use (or export if used externally).

(SC2034)

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: run-lido-csm-staking-node
🔇 Additional comments (3)
ethpillar.sh (2)

1192-1193: New plugin submenu entry looks consistent.
The "🔧 eth-validator-cli by TobiWo" entry follows the existing pattern and iconography. No issues spotted.


1251-1257: Ensure necessary env vars are available to the plugin.
You export BACKTITLE, EDITOR, _platform, and _arch before invoking the installer and menu. The plugin’s menu.sh also sources its own env to pick up JSON_RPC_URL, BEACON_API_URL, and MAX_REQUESTS_PER_BLOCK. Verify at runtime that both sets of variables (global and plugin-specific) are correctly merged.

plugins/eth-validator-cli/menu.sh (1)

21-32: Nice modular logging and prompting functions.
The info, error, and question helpers keep the code DRY and readable. Consider adding a check for whiptail / jq availability at the top to preempt runtime failures.

@coincashew coincashew force-pushed the eth-validator-cli branch from e5003c1 to c2340ee Compare May 6, 2025 21:41
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (1)
plugins/eth-validator-cli/plugin_eth-validator-cli.sh (1)

30-36: Initialize _arch and _platform before use.
These variables are referenced in downloadClient() but never set, causing SC2154 warnings and download failures. Insert this before downloadClient():

+ # Detect architecture and platform
+ _arch=$(uname -m)
+ case "$_arch" in
+   x86_64) _arch=amd64 ;;
+   aarch64) _arch=arm64 ;;
+   *) error "Unsupported arch: $_arch"; exit 1 ;;
+ esac
+ _platform=$(uname -s | tr '[:upper:]' '[:lower:]')
🧰 Tools
🪛 Shellcheck (0.10.0)

[warning] 32-32: _arch is referenced but not assigned.

(SC2154)


[warning] 36-36: _platform is referenced but not assigned.

(SC2154)

🧹 Nitpick comments (3)
plugins/eth-validator-cli/menu.sh (2)

32-35: Consider quoting paths in file checks.
To prevent globbing or word-splitting if PLUGIN_INSTALL_PATH ever contains spaces, quote the tests:

- [[ -f $PLUGIN_INSTALL_PATH/env ]] && source $PLUGIN_INSTALL_PATH/env
+ [[ -f "$PLUGIN_INSTALL_PATH/env" ]] && source "$PLUGIN_INSTALL_PATH/env"
- [[ -f $PLUGIN_INSTALL_PATH/current_version ]] && VERSION=$(cat $PLUGIN_INSTALL_PATH/current_version)
+ [[ -f "$PLUGIN_INSTALL_PATH/current_version" ]] && VERSION=$(cat "$PLUGIN_INSTALL_PATH/current_version")

152-156: Use the install path for helper script invocation.
Relying on a relative path (./plugins/...) may fail if the CWD changes. Prefer the absolute install location:

- exec ./plugins/eth-validator-cli/plugin_eth-validator-cli.sh -u
+ exec "$PLUGIN_INSTALL_PATH"/plugin_eth-validator-cli.sh -u

And similarly for -r.

plugins/eth-validator-cli/plugin_eth-validator-cli.sh (1)

35-38: Guard against empty binary URLs.
If BINARIES_URL is empty, wget will silently fail. Add a check:

- BINARIES_URL=$(echo "$json" | jq -r ".assets[] | select(.name) | .browser_download_url" | grep -i "${_platform}-${_custom}")
+ BINARIES_URL=$(echo "$json" | jq -r ".assets[] | select(.name) | .browser_download_url" | grep -i "${_platform}-${_custom}")
+ if [[ -z "$BINARIES_URL" ]]; then
+   error "Failed to find a matching binary for $_platform-$_custom"
+   exit 1
+ fi
🧰 Tools
🪛 Shellcheck (0.10.0)

[warning] 36-36: _platform is referenced but not assigned.

(SC2154)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e5003c1 and c2340ee.

📒 Files selected for processing (3)
  • plugins/eth-validator-cli/env.example (1 hunks)
  • plugins/eth-validator-cli/menu.sh (1 hunks)
  • plugins/eth-validator-cli/plugin_eth-validator-cli.sh (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • plugins/eth-validator-cli/env.example
🧰 Additional context used
🪛 Shellcheck (0.10.0)
plugins/eth-validator-cli/plugin_eth-validator-cli.sh

[warning] 32-32: _arch is referenced but not assigned.

(SC2154)


[warning] 36-36: _platform is referenced but not assigned.

(SC2154)

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: run-lido-csm-staking-node
🔇 Additional comments (3)
plugins/eth-validator-cli/menu.sh (3)

37-39: Environment validation is solid.
Using the : "${VAR:?…}" pattern ensures immediate failure on missing configuration, which is exactly what we want here.


41-46: Ensure NETWORK is defined.
You lowercase ${NETWORK,,}, but if NETWORK isn’t set in env you’ll hit set -u and exit. Confirm NETWORK exists in env.example and is documented.


48-62: Robust command invocation.
Building cmd as an array and prompting for confirmation before execution follows best practices and avoids word-splitting issues.

Also applies to: 64-76, 78-90, 92-106

Comment on lines +132 to +135
if [[ $OPTIND -eq 1 ]]; then
usage
exit 1
fi
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Correct the “no flags” logic.
Checking OPTIND here always evaluates to true, so the script never reaches flag parsing. Use the argument count instead:

- if [[ $OPTIND -eq 1 ]]; then
+ if [[ $# -eq 0 ]]; then
    usage
    exit 1
  fi

This ensures usage is shown only when no flags are passed.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if [[ $OPTIND -eq 1 ]]; then
usage
exit 1
fi
if [[ $# -eq 0 ]]; then
usage
exit 1
fi

@coincashew coincashew force-pushed the eth-validator-cli branch from c2340ee to a3dc6b6 Compare May 6, 2025 21:48
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

♻️ Duplicate comments (2)
plugins/eth-validator-cli/plugin_eth-validator-cli.sh (2)

132-137: 🛠️ Refactor suggestion

Show usage when no flags are provided
Currently, running the script without any options results in no action. Add a pre-check before getopts to display help:

+if [[ $# -eq 0 ]]; then
+  usage
+  exit 1
+fi
 while getopts :iurh opt; do
   case ${opt} in
     i ) install ;;

13-21: ⚠️ Potential issue

Missing architecture & platform detection
Variables _arch and _platform are later referenced in downloadClient() but never initialized, causing SC2154 warnings and breaking the download logic. Add detection via uname:

 # Variables
 RELEASE_URL="https://api.github.com/repos/TobiWo/eth-validator-cli/releases/latest"
 ...
 PLUGIN_SOURCE_PATH="$SOURCE_DIR"
+
+# Detect architecture and platform
+_arch=$(uname -m)
+case "$_arch" in
+  x86_64) _arch=amd64 ;;
+  aarch64) _arch=arm64 ;;
+  *) echo "Unsupported architecture: $_arch"; exit 1 ;;
+esac
+_platform=$(uname -s | tr '[:upper:]' '[:lower:]')
🧹 Nitpick comments (3)
plugins/eth-validator-cli/plugin_eth-validator-cli.sh (3)

23-26: Use failure-safe curl flags
In getLatestVersion(), replace curl -s with flags that cause errors on non-2xx responses. This makes your empty-TAG check more reliable:

-function getLatestVersion(){
-  TAG=$(curl -s $RELEASE_URL | jq -r .tag_name )
+function getLatestVersion() {
+  TAG=$(curl -fsSL "$RELEASE_URL" | jq -r .tag_name)
   if [[ -z "$TAG" ]]; then echo "Failed to fetch latest version"; exit 1; fi
}

29-36: Quote variables & improve error branch
Inside downloadClient(), always quote expansions to prevent globbing/word-splitting and make the unsupported-arch check clearer:

-function downloadClient(){
-  local _custom
-  [[ $_arch == "amd64" ]] && _custom="x64"
-  [[ -z $_custom ]] && echo "Unsupported arch: $_arch" && exit 1
+function downloadClient() {
+  local _custom
+  [[ "$_arch" == "amd64" ]] && _custom="x64"
+  if [[ -z "$_custom" ]]; then
+    echo "Unsupported architecture: $_arch"
+    exit 1
+  fi

Also, when grepping the JSON, quote ${_platform} and ${_custom}:

-  BINARIES_URL=$(echo "$json" | jq -r ".assets[] | select(.name) | .browser_download_url" | grep --ignore-case "${_platform}"-"${_custom}")
+  BINARIES_URL=$(echo "$json" | jq -r '.assets[] .browser_download_url' | grep -i "${_platform}-${_custom}")
🧰 Tools
🪛 Shellcheck (0.10.0)

[warning] 32-32: _arch is referenced but not assigned.

(SC2154)


[warning] 36-36: _platform is referenced but not assigned.

(SC2154)


113-120: Minor help text formatting
In usage(), the “Options” header uses a parenthesis. For consistency with other help tools, switch to a colon:

-Options)
+Options:
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c2340ee and a3dc6b6.

📒 Files selected for processing (3)
  • plugins/eth-validator-cli/env.example (1 hunks)
  • plugins/eth-validator-cli/menu.sh (1 hunks)
  • plugins/eth-validator-cli/plugin_eth-validator-cli.sh (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • plugins/eth-validator-cli/env.example
  • plugins/eth-validator-cli/menu.sh
🧰 Additional context used
🪛 Shellcheck (0.10.0)
plugins/eth-validator-cli/plugin_eth-validator-cli.sh

[warning] 32-32: _arch is referenced but not assigned.

(SC2154)


[warning] 36-36: _platform is referenced but not assigned.

(SC2154)

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: run-lido-csm-staking-node

Comment on lines +1 to +10
#!/bin/bash

# Author: coincashew.eth | coincashew.com
# License: GNU GPL
# Source: https://github.com/coincashew/ethpillar
# Description: Contributoor helper script
#
# Made for home and solo stakers 🏠🥩

SOURCE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add strict mode and robust error handling
To catch failures early and avoid unbound variables, enable strict mode at the very top of the script. For example, immediately after the shebang:

+# Enable strict mode
+set -euo pipefail
+IFS=$'\n\t'
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
#!/bin/bash
# Author: coincashew.eth | coincashew.com
# License: GNU GPL
# Source: https://github.com/coincashew/ethpillar
# Description: Contributoor helper script
#
# Made for home and solo stakers 🏠🥩
SOURCE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
#!/bin/bash
# Enable strict mode
set -euo pipefail
IFS=$'\n\t'
# Author: coincashew.eth | coincashew.com
# License: GNU GPL
# Source: https://github.com/coincashew/ethpillar
# Description: Contributoor helper script
#
# Made for home and solo stakers 🏠🥩
SOURCE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

@coincashew coincashew force-pushed the eth-validator-cli branch from a3dc6b6 to 7ebe574 Compare May 6, 2025 21:55
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

♻️ Duplicate comments (4)
plugins/eth-validator-cli/plugin_eth-validator-cli.sh (4)

133-134: Show usage when no options are provided
Invoking the script without flags currently does nothing. Add a guard to display help instead of silently exiting.

Insert before the getopts loop:

if [[ $# -eq 0 ]]; then
  usage
  exit 1
fi

1-2: 🛠️ Refactor suggestion

Enable strict mode for robust error handling
We should bail out on errors, undefined variables, and pipeline failures to avoid silent failures.

Apply this diff right after the shebang:

 #!/bin/bash
+set -euo pipefail
+IFS=$'\n\t'

30-36: ⚠️ Potential issue

Detect architecture and platform before downloading
The variables _arch and _platform are used but never set, causing the download logic to always exit with “Unsupported architecture.”

Add detection logic (e.g. before downloadClient or at the top of the script):

_arch=$(uname -m)
case "$_arch" in
  x86_64) _arch=amd64 ;;
  aarch64) _arch=arm64 ;;
  *) echo "Unsupported architecture: $_arch"; exit 1 ;;
esac

_platform=$(uname -s | tr '[:upper:]' '[:lower:]')
🧰 Tools
🪛 Shellcheck (0.10.0)

[warning] 32-32: _arch is referenced but not assigned.

(SC2154)


67-79: 🛠️ Refactor suggestion

Fix newline handling in MSG_ABOUT
Backslash-escaped \n inside double quotes won’t render as newlines. Use ANSI-C quoting or a here-doc.

Replace with:

-MSG_ABOUT="🔧 eth-validator-cli by TobiWo: CLI tool for managing validators via execution layer requests
-\nFeatures:
-- Consolidate one or multiple source validators to one target validator
-...
-Continue to install?"
+MSG_ABOUT=$'🔧 eth-validator-cli by TobiWo: CLI tool for managing validators via execution layer requests\n\nFeatures:\n- Consolidate one or multiple source validators to one target validator\n- Switch withdrawal credentials from type 0x01 to 0x02 (compounding) for one or multiple validators\n- Partially withdraw ETH from one or many validators\n- Exit one or many validators\n- This CLI currently only supports validator related features included in the Pectra hardfork.\n- The tool is especially useful if you need to manage multiple validators at once.\n- Currently it only supports private keys as secret. This will change soon with e.g. hardware ledger support.\n- ⚠️ Tool is very early. Use on Hoodi only. Not recommended for mainnet yet!\n\nDocumentation: '"$DOCUMENTATION"$'\nSource Code: '"$SOURCE_CODE"$'\n\nContinue to install?'
🧹 Nitpick comments (2)
plugins/eth-validator-cli/plugin_eth-validator-cli.sh (2)

37-43: Validate the download URL before attempting to fetch
If the asset URL isn’t found, wget will fail in an unclear way. Let’s catch an empty BINARIES_URL early.

For example:

-  BINARIES_URL=$(echo "$json" | jq -r ".assets[] | select(.name) | .browser_download_url" | grep --ignore-case "${_platform}"-"${_custom}")
+  BINARIES_URL=$(echo "$json" | jq -r ".assets[] | select(.name) | .browser_download_url" | grep --ignore-case "${_platform}-${_custom}")
+  if [[ -z "$BINARIES_URL" ]]; then
+    echo "Error: No download URL found for ${_platform}-${_custom}"
+    exit 1
+  fi
🧰 Tools
🪛 Shellcheck (0.10.0)

[warning] 38-38: _platform is referenced but not assigned.

(SC2154)


127-131: Nit: Fix stray parenthesis in usage help
The line About $APP_NAME) includes an extra ). It should read:

About $APP_NAME
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a3dc6b6 and 7ebe574.

📒 Files selected for processing (3)
  • plugins/eth-validator-cli/env.example (1 hunks)
  • plugins/eth-validator-cli/menu.sh (1 hunks)
  • plugins/eth-validator-cli/plugin_eth-validator-cli.sh (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • plugins/eth-validator-cli/env.example
  • plugins/eth-validator-cli/menu.sh
🧰 Additional context used
🪛 Shellcheck (0.10.0)
plugins/eth-validator-cli/plugin_eth-validator-cli.sh

[warning] 32-32: _arch is referenced but not assigned.

(SC2154)


[warning] 38-38: _platform is referenced but not assigned.

(SC2154)

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: run-lido-csm-staking-node

@coincashew coincashew force-pushed the eth-validator-cli branch from 7ebe574 to fc9f697 Compare May 6, 2025 22:04
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (3)
plugins/eth-validator-cli/plugin_eth-validator-cli.sh (3)

30-36: Implement architecture and platform detection
past_review_comments: Critical: _arch and _platform are unset.
You must populate these before using them in downloadClient().

 function downloadClient(){
-  local _custom
+  local _custom
+  # Detect host architecture and platform
+  _arch=$(uname -m)
+  case "${_arch}" in
+    x86_64) _arch="amd64" ;;
+    aarch64) _arch="arm64" ;;
+    *) echo "Unsupported architecture: ${_arch}"; exit 1 ;;
+  esac
+  _platform=$(uname -s | tr '[:upper:]' '[:lower:]')

This snippet must appear before you reference $_arch or $_platform.

🧰 Tools
🪛 Shellcheck (0.10.0)

[warning] 32-32: _arch is referenced but not assigned.

(SC2154)


71-83: Fix newline handling in multi-line MSG_ABOUT
past_review_comments: Backslash-n in double quotes won’t render as newlines in whiptail. Use ANSI-C quoting or a here-doc.

- MSG_ABOUT="🔧 eth-validator-cli by TobiWo: CLI tool for managing validators via execution layer requests
-\nFeatures:
-- Consolidate ...
-...
-"
+ MSG_ABOUT=$'🔧 eth-validator-cli by TobiWo: CLI tool for managing validators via execution layer requests\n\nFeatures:\n- Consolidate one or multiple source validators to one target validator\n- Switch withdrawal credentials from type 0x01 to 0x02 (compounding) for one or multiple validators\n- Partially withdraw ETH from one or many validators\n- Exit one or many validators\n- This CLI currently only supports features from the Pectra hardfork.\n- Useful for batch validator operations.\n- ⚠️ Early-stage: use on testnets only!\n\nDocumentation: '"$DOCUMENTATION"$'\nSource Code: '"$SOURCE_CODE"$'\n\nContinue to install?'

1-2: 🛠️ Refactor suggestion

Enable strict mode for safer scripting

Adding strict mode (set -euo pipefail) and a safe IFS prevents silent failures, unbound variables, and word-splitting issues early in the script.

 #!/bin/bash
+set -euo pipefail
+IFS=$'\n\t'
🧹 Nitpick comments (3)
plugins/eth-validator-cli/plugin_eth-validator-cli.sh (3)

131-135: Remove stray parenthesis in usage output

There's an extra ) on the "About" line that may confuse users.

- About $APP_NAME)
+ About $APP_NAME

14-17: Consistent naming: rename GITHUB_RELEASE_NODES to GITHUB_RELEASE_NOTES

NODES suggests a collection; NOTES better reflects that this is a link to the release notes page.

- GITHUB_RELEASE_NODES="https://github.com/TobiWo/eth-validator-cli/releases"
+ GITHUB_RELEASE_NOTES="https://github.com/TobiWo/eth-validator-cli/releases"

And update all references accordingly.


22-27: Check for required dependencies before execution

Fail early if curl, jq, wget, tar, or whiptail are missing:

function check_dependencies() {
  for cmd in curl jq wget tar whiptail; do
    command -v "$cmd" >/dev/null 2>&1 || { echo "Error: $cmd is required but not installed."; exit 1; }
  done
}
check_dependencies

This ensures users get a clear error rather than cryptic failures.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7ebe574 and fc9f697.

📒 Files selected for processing (3)
  • plugins/eth-validator-cli/env.example (1 hunks)
  • plugins/eth-validator-cli/menu.sh (1 hunks)
  • plugins/eth-validator-cli/plugin_eth-validator-cli.sh (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • plugins/eth-validator-cli/env.example
  • plugins/eth-validator-cli/menu.sh
🧰 Additional context used
🪛 Shellcheck (0.10.0)
plugins/eth-validator-cli/plugin_eth-validator-cli.sh

[warning] 32-32: _arch is referenced but not assigned.

(SC2154)


[warning] 38-38: _platform is referenced but not assigned.

(SC2154)

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: run-lido-csm-staking-node

@coincashew coincashew merged commit 186eb26 into main May 6, 2025
2 checks passed
@coincashew coincashew deleted the eth-validator-cli branch May 6, 2025 22:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant