Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ubuntu systemctl support & Fix relayer l2 flow #10

Merged
merged 4 commits into from
Dec 11, 2024
Merged

Conversation

traviolus
Copy link
Collaborator

@traviolus traviolus commented Dec 11, 2024

Changes

  • Fix relayer L2 flow where it may use local rollup chain id to query initia registry
  • Update service package to fully support ubuntu systemctl

Summary by CodeRabbit

  • New Features

    • Introduced functionality for querying bank balances using the Initia protocol.
    • Enhanced error handling for balance fetching and version string processing.
  • Bug Fixes

    • Improved robustness in handling version strings and user home directory retrieval.
  • Refactor

    • Updated balance querying logic to utilize a new querier, enhancing flexibility.
    • Revised command execution logic for dynamic service name and binary path construction.
  • Documentation

    • Minor adjustments to comments for clarity.

@traviolus traviolus requested a review from Benzbeeb as a code owner December 11, 2024 09:25
Copy link
Contributor

coderabbitai bot commented Dec 11, 2024

Walkthrough

The changes in this pull request involve modifications to several files within the cosmosutils package and related components. Key updates include enhancements to the GetInitiaBinaryPath function for better version string handling, the introduction of a new querying mechanism for bank balances using the Initia protocol, and refinements to the relayer configuration handling. Additionally, the Create method in the Systemd struct has been updated to dynamically determine the binary path and service name based on command types.

Changes

File Change Summary
cosmosutils/binary.go Modified GetInitiaBinaryPath to handle version strings with "@" and improved error handling for user home directory retrieval.
cosmosutils/cli_query.go Introduced InitiadBankBalancesQueryResponse and InitiadQuerier types, added NewInitiadQuerier function, and implemented QueryBankBalances method.
models/relayer/init.go Replaced direct balance queries with cosmosutils.NewInitiadQuerier, added error handling for balance fetching, and updated funding requirement logic.
service/systemd.go Updated Create method in Systemd struct to use a switch-case for binaryPath and serviceName based on j.commandName, improving command execution logic.

Possibly related PRs

🐇 In the code we hop and play,
With version strings, we pave the way.
Queries for balances, now refined,
In the world of Initia, we're aligned.
So let us cheer, with joy and glee,
For coding rabbits, as happy as can be! 🐰✨


🪧 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.

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. (Experiment)
  • @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
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: 5

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 7a02b3e and 4b5a5ed.

📒 Files selected for processing (4)
  • cosmosutils/binary.go (1 hunks)
  • cosmosutils/cli_query.go (1 hunks)
  • models/relayer/init.go (2 hunks)
  • service/systemd.go (2 hunks)

cosmosutils/cli_query.go Show resolved Hide resolved
cosmosutils/cli_query.go Show resolved Hide resolved
service/systemd.go Outdated Show resolved Hide resolved
models/relayer/init.go Outdated Show resolved Hide resolved
cosmosutils/binary.go Show resolved Hide resolved
coderabbitai[bot]
coderabbitai bot previously approved these changes Dec 11, 2024
coderabbitai[bot]
coderabbitai bot previously approved these changes Dec 11, 2024
Copy link
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

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 5f605b4 and 171f613.

📒 Files selected for processing (1)
  • service/systemd.go (2 hunks)
🔇 Additional comments (3)
service/systemd.go (3)

13-13: LGTM!

The new import is correctly placed and necessary for the GetInitiaBinaryPath function used in the changes below.


56-56: ⚠️ Potential issue

Initialize serviceName consistently across all command types

The previous review comment about serviceName initialization is still applicable. The template formatting uses command name directly without proper initialization across all cases.

 var binaryPath string
+var serviceName string
+serviceName = binaryName // Default to binaryName if not set in switch
 switch j.commandName {
     case Initia:
         binaryPath = filepath.Dir(cosmosutils.GetInitiaBinaryPath(binaryVersion))
     case Minitia:
         binaryPath = filepath.Join(userHome, common.WeaveDataDirectory, binaryVersion, strings.ReplaceAll(binaryVersion, "@", "_"))
     case OPinitExecutor:
         serviceName = "executor"
     case OPinitChallenger:
         serviceName = "challenger"
 }
-cmd.Stdin = strings.NewReader(fmt.Sprintf(string(template), binaryName, currentUser.Username, binaryPath, string(j.commandName), appHome))
+cmd.Stdin = strings.NewReader(fmt.Sprintf(string(template), binaryName, currentUser.Username, binaryPath, serviceName, appHome))

44-52: Verify binary path construction across different environments

The switch statement handles path construction differently for each command type. Please ensure that:

  1. The paths are correctly constructed on different Ubuntu versions
  2. The paths exist and are accessible
  3. The version string replacement in Minitia case handles all possible version formats
✅ Verification successful

Let me gather more information about the binary path construction by checking the related utility functions and path handling logic.


Based on the analysis of the shell script results, I can now provide a final response:

Binary path construction is correctly implemented and consistent

The verification shows that:

  1. The path construction is consistent with the codebase's established patterns:
    • Initia: Uses GetInitiaBinaryPath() which handles version formats and OS-specific paths
    • Minitia: Follows the same pattern as other binaries in the codebase, storing under WeaveDataDirectory
    • Default: Uses the base WeaveDataDirectory as expected
  2. Version string handling is properly implemented:
    • @ character in versions is handled consistently across the codebase
    • Version string replacement is used in similar patterns elsewhere
  3. All paths are constructed relative to the user's home directory using WeaveDataDirectory constant
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify binary path construction and permissions

# Test: Check if the paths exist and are accessible
echo "Checking common paths..."
fd -t d "weave" $HOME

# Test: Check version string handling
echo "Checking version string handling..."
rg -A 2 'binaryVersion.*=|version.*=' 

Length of output: 4738


Script:

#!/bin/bash
# Check the implementation of GetInitiaBinaryPath and related functions
echo "Checking Initia binary path implementation..."
ast-grep --pattern 'func GetInitiaBinaryPath($$$)'

echo "\nChecking WeaveDataDirectory constant..."
rg "WeaveDataDirectory.*=" -A 2

echo "\nChecking related filepath operations..."
rg "filepath\.(Join|Dir)" -A 2

echo "\nChecking version string handling in path construction..."
ast-grep --pattern 'strings.ReplaceAll($version, "@", $_)'

Length of output: 29336

service/systemd.go Show resolved Hide resolved
Copy link
Collaborator

@Benzbeeb Benzbeeb left a comment

Choose a reason for hiding this comment

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

LGTM

@traviolus traviolus merged commit ce73348 into main Dec 11, 2024
4 checks passed
@traviolus traviolus deleted the feat/ubuntu-support branch January 17, 2025 07:58
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.

2 participants