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

refactor: improvements on rest v2 server #22292

Merged
merged 4 commits into from
Oct 17, 2024
Merged

refactor: improvements on rest v2 server #22292

merged 4 commits into from
Oct 17, 2024

Conversation

hieuvubk
Copy link
Contributor

@hieuvubk hieuvubk commented Oct 17, 2024

Description

Closes: #XXXX

api key in app.toml change since serverv2/api/rest was merged

Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • included the correct type prefix in the PR title, you can find examples of the prefixes below:
  • confirmed ! in the type prefix if API or client breaking change
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • reviewed "Files changed" and left comments if necessary
  • included the necessary unit and integration tests
  • added a changelog entry to CHANGELOG.md
  • updated the relevant documentation or specification, including comments for documenting Go code
  • confirmed all CI checks have passed

Reviewers Checklist

All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.

Please see Pull Request Reviewer section in the contributing guide for more information on how to review a pull request.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic, API design and naming, documentation is accurate, tests and test coverage

Summary by CodeRabbit

  • New Features

    • Transitioned to enabling the REST interface for improved application configuration.
    • Introduced a new configuration section for the REST server, allowing customization of its status and address.
  • Bug Fixes

    • Enhanced error handling and debugging output in the initialization script.

Copy link
Contributor

coderabbitai bot commented Oct 17, 2024

📝 Walkthrough
📝 Walkthrough

Walkthrough

The pull request updates the init-simapp-v2.sh script to enhance its functionality and error handling. It changes the assignment of SIMD_BIN to a hardcoded path and modifies the command to enable the REST interface instead of a general API. Additionally, the ServerName constant in the rest package is updated from "rest-v2" to "rest", affecting the Name() method of the Server struct without altering its overall functionality. A new configuration section for the REST server is also introduced in the v2-app.toml file.

Changes

File Change Summary
scripts/init-simapp-v2.sh Changed SIMD_BIN to a hardcoded path; modified API enable command from api.enable true to rest.enable true.
server/v2/api/rest/server.go Updated ServerName constant from "rest-v2" to "rest" affecting the Name() method.
tools/confix/data/v2-app.toml Added new section [rest] with parameters enable = true and address = 'localhost:8080'.

Possibly related PRs

Suggested labels

C:server/v2 appmanager, C:server/v2 cometbft, backport/v0.52.x

Suggested reviewers

  • kocubinski
  • sontrinh16
  • akhilkumarpilli

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 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 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.

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: 0

🧹 Outside diff range and nitpick comments (1)
scripts/init-simapp-v2.sh (1)

12-12: LGTM! Consider adding a comment for clarity.

The change from api.enable to rest-v2.enable correctly reflects the update to enable the REST v2 interface, which aligns with the PR objectives and the changes in the serverv2/api/rest module.

Consider adding a comment above this line to explain the purpose of enabling the REST v2 interface, for example:

+# Enable the REST v2 interface
$SIMD_BIN config set app rest-v2.enable true

This would improve the script's readability and make it easier for future maintainers to understand the purpose of this configuration.

📜 Review details

Configuration used: .coderabbit.yml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 553e110 and 3335078.

📒 Files selected for processing (1)
  • scripts/init-simapp-v2.sh (1 hunks)
🧰 Additional context used

@@ -9,7 +9,7 @@ if [ -d "$SIMD_HOME" ]; then rm -rv $SIMD_HOME; fi
$SIMD_BIN config set client chain-id simapp-v2-chain
$SIMD_BIN config set client keyring-backend test
$SIMD_BIN config set client keyring-default-keyname alice
$SIMD_BIN config set app api.enable true
$SIMD_BIN config set app rest-v2.enable true
Copy link
Member

Choose a reason for hiding this comment

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

can we as well rename the server to simply rest? I don't think we should have v2 in there.

@hieuvubk hieuvubk requested a review from a team as a code owner October 17, 2024 06:30
@github-actions github-actions bot added C:server/v2 Issues related to server/v2 C:server/v2 api labels Oct 17, 2024
@julienrbrt
Copy link
Member

Could you add as well the app.toml content to confix (v2-app.toml)?

@@ -1,6 +1,14 @@
#!/usr/bin/env bash
set -o errexit
Copy link
Member

Choose a reason for hiding this comment

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

should be reverted

@github-actions github-actions bot added the C:Confix Issues and PR related to Confix label Oct 17, 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: 0

🧹 Outside diff range and nitpick comments (1)
tools/confix/data/v2-app.toml (1)

44-48: LGTM! Consider adding a comment about production deployment.

The addition of the [rest] section with enable and address parameters is appropriate and aligns with the PR objectives.

Consider adding a comment above the address parameter to remind users to adjust this value for production deployments:

 [rest]
 # Enable defines if the REST server should be enabled.
 enable = true
+# Address defines the REST server address to bind to.
+# Note: For production deployments, consider changing this to a more appropriate address.
 address = 'localhost:8080'
📜 Review details

Configuration used: .coderabbit.yml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between c0c0f75 and caffcc8.

📒 Files selected for processing (2)
  • scripts/init-simapp-v2.sh (1 hunks)
  • tools/confix/data/v2-app.toml (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • scripts/init-simapp-v2.sh
🧰 Additional context used
🔇 Additional comments (1)
tools/confix/data/v2-app.toml (1)

44-48: Clarification needed: Additional app.toml content

In response to the PR comment requesting inclusion of app.toml content in this file:

  1. Could you please specify which additional content from app.toml needs to be included here?
  2. Are there any other REST-related configurations in app.toml that should be transferred to this file?

This information will help ensure that all necessary configurations are properly included and aligned between the two files.

To assist in identifying relevant content, you can run the following command to search for REST-related configurations in the app.toml file:

Once we have clarity on the required content, I can help draft the necessary additions to this file.

@julienrbrt julienrbrt changed the title refactor: Update init-simapp-v2.sh refactor: improvements on rest v2 server Oct 17, 2024
Copy link
Member

@julienrbrt julienrbrt left a comment

Choose a reason for hiding this comment

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

great!

@julienrbrt
Copy link
Member

adding backport 0.52 label solely for confix changes

@julienrbrt julienrbrt added the backport/v0.52.x PR scheduled for inclusion in the v0.52's next stable release label Oct 17, 2024
Copy link
Contributor

@akhilkumarpilli akhilkumarpilli left a comment

Choose a reason for hiding this comment

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

utACK

@tac0turtle tac0turtle added this pull request to the merge queue Oct 17, 2024
Merged via the queue into main with commit 20dd65b Oct 17, 2024
79 of 80 checks passed
@tac0turtle tac0turtle deleted the hieu/update/initv2 branch October 17, 2024 09:09
mergify bot pushed a commit that referenced this pull request Oct 17, 2024
(cherry picked from commit 20dd65b)

# Conflicts:
#	server/v2/api/rest/server.go
julienrbrt added a commit that referenced this pull request Oct 17, 2024
Co-authored-by: Hieu Vu <72878483+hieuvubk@users.noreply.github.com>
Co-authored-by: Julien Robert <julien@rbrt.fr>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport/v0.52.x PR scheduled for inclusion in the v0.52's next stable release C:Confix Issues and PR related to Confix C:server/v2 api C:server/v2 Issues related to server/v2 Type: Build
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants