Skip to content

refactor(node-checker): simplify-delete#96

Merged
coincashew merged 1 commit intomainfrom
dev
May 6, 2025
Merged

refactor(node-checker): simplify-delete#96
coincashew merged 1 commit intomainfrom
dev

Conversation

@coincashew
Copy link
Copy Markdown
Owner

@coincashew coincashew commented May 6, 2025

Summary by CodeRabbit

  • Refactor
    • Improved internal version extraction and comparison processes for client checks, resulting in more consistent and streamlined version reporting during node checks. No changes to user-facing commands or outputs.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented May 6, 2025

Walkthrough

The script plugins/node-checker/run.sh was refactored to unify and simplify semantic version extraction for execution, consensus, validator, and MEV-Boost clients. Version strings are now extracted using a single grep -oE command, and version comparisons include checks to ensure the latest version variable is non-empty before proceeding.

Changes

File(s) Change Summary
plugins/node-checker/run.sh Unified version extraction using grep -oE across multiple functions; removed intermediate variables; added non-empty checks for latest version before comparisons.

Poem

A hop and a skip through the versioning wood,
The checker now cleans as a good bunny should.
No more confusion with versions to parse,
Just one tidy hop—no need to rehearse!
With streamlined commands and output so neat,
This bunny’s script runs light on its feet.
🐇✨


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 162e9fd and fcd0fe9.

📒 Files selected for processing (1)
  • plugins/node-checker/run.sh (7 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • plugins/node-checker/run.sh
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: run-lido-csm-staking-node
✨ 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: 0

🔭 Outside diff range comments (2)
plugins/node-checker/run.sh (2)

625-655: 🛠️ Refactor suggestion

Strengthen version extraction and comparison in check_execution_version
The refactored pipeline consolidates extraction and comparison but can be made more robust:

  • Use jq -r '.result' to strip JSON quotes instead of jq '.result'.
  • Quote ${EL_RPC_ENDPOINT} to prevent word-splitting.
  • Replace sed with grep -oE '[0-9]+\.[0-9]+\.[0-9]+' for reliable semver extraction, avoiding fallback to raw JSON.
  • Ensure LATEST_VERSION is non-empty before comparing to prevent false positives.

Suggested diff:

- EL_INSTALLED=$(curl -s -X POST ... ${EL_RPC_ENDPOINT} | jq '.result' | sed 's/.*[v\/]\([0-9]\+\.[0-9]\+\.[0-9]\+\).*/\1/')
+ EL_INSTALLED=$(curl -s -X POST ... "${EL_RPC_ENDPOINT}" \
+   | jq -r '.result' \
+   | grep -oE '[0-9]+\.[0-9]+\.[0-9]+')

- LATEST_VERSION=$(curl -s $TAG_URL | jq -r .tag_name | sed 's/.*[v\/]\([0-9]\+\.[0-9]\+\.[0-9]\+\).*/\1/')
+ LATEST_VERSION=$(curl -s "$TAG_URL" \
+   | jq -r .tag_name \
+   | grep -oE '[0-9]+\.[0-9]+\.[0-9]+')

+ if [[ -n "$LATEST_VERSION" && "${EL_INSTALLED#v}" == "${LATEST_VERSION#v}" ]]; then
     print_check_result "PASS" "Execution client ($EL) version: $EL_INSTALLED (latest)"
   else
     print_check_result "WARN" "Execution client ($EL) version: $EL_INSTALLED (latest: $LATEST_VERSION)"
     ((warning_checks++))
   fi

665-695: 🛠️ Refactor suggestion

Apply consistent semver parsing in check_consensus_version
Similar improvements should be applied here to mirror the execution-layer fix:

  1. Quote "$API_BN_ENDPOINT".
  2. Switch from sed -n to grep -oE '[0-9]+\.[0-9]+\.[0-9]+'.
  3. Use jq -r to drop quotes before parsing.
  4. Validate LATEST_VERSION is set before comparing.

Example adjustment:

- CL_VERSION=$(curl -s -X GET "${API_BN_ENDPOINT}/eth/v1/node/version" ... | jq -r '.data.version' | sed -n 's/.*v\([0-9]*\.[0-9]*\.[0-9]*\).*/\1/p')
+ CL_VERSION=$(curl -s -X GET "$API_BN_ENDPOINT/eth/v1/node/version" ... \
+   | jq -r '.data.version' \
+   | grep -oE '[0-9]+\.[0-9]+\.[0-9]+')
🧹 Nitpick comments (1)
plugins/node-checker/run.sh (1)

705-735: DRY out validator version logic
check_validator_version duplicates the same fetch-and-compare steps as check_consensus_version. Consider extracting a helper function, e.g.:

check_client_version() {
  local name=$1 endpoint=$2 path=$3 tag_url=$4
  ((total_checks++))
  version=$(curl -s -X GET "$endpoint" | jq -r "$path" | grep -oE '[0-9]+\.[0-9]+\.[0-9]+')
  latest=$(curl -s "$tag_url" | jq -r .tag_name | grep -oE '[0-9]+\.[0-9]+\.[0-9]+')
  if [[ -n "$latest" && "${version#v}" == "${latest#v}" ]]; then
    print_check_result "PASS" "$name version: $version (latest)"
  else
    print_check_result "WARN" "$name version: $version (latest: $latest)"
    ((warning_checks++))
  fi
}

Then call it for execution, consensus, and validator, passing the appropriate parameters.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 6ffbdce and 162e9fd.

📒 Files selected for processing (1)
  • plugins/node-checker/run.sh (4 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: run-lido-csm-staking-node

@coincashew coincashew merged commit 8a6f0aa into main May 6, 2025
2 checks passed
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