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

feat: add optional persistence to localnet #2868

Merged
merged 3 commits into from
Sep 20, 2024
Merged

Conversation

gartnera
Copy link
Member

@gartnera gartnera commented Sep 11, 2024

This enables you to change the binaries without resetting the data. Use like this

export NODE_COMPOSE_ARGS="-f docker-compose-persistent.yml"
make start-localnet

This will enable you to easily connect your localnet to external chains.

Also upgrade grafana and enable anonymous auth so you don't get prompted for credentials. Example of using grafana too:

export NODE_COMPOSE_ARGS="--profile monitoring -f docker-compose-persistent.yml"
make start-localnet

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced a new docker-compose-persistent.yml for deploying services with persistent data storage.
    • Added support for anonymous access in Grafana, allowing users to view the dashboard without login credentials.
  • Improvements

    • Enhanced Docker Compose configurations for better service management and data persistence.
    • Updated Grafana to a newer version, improving functionality and security.
    • Streamlined scripts for improved maintainability and error reduction.
  • Chores

    • Updated .gitignore to exclude environment-specific files from version control.

Copy link
Contributor

coderabbitai bot commented Sep 11, 2024

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

Walkthrough

The pull request introduces several changes across multiple files. Key modifications include the addition of a path to the .gitignore file, updates to the Makefile for improved Docker Compose argument handling, the creation of a new docker-compose-persistent.yml for services with persistent data, and adjustments to existing Docker Compose configurations. Furthermore, the Grafana configuration is modified to enable anonymous access, and a script is enhanced to dynamically merge an external JSON configuration file. These changes collectively aim to streamline deployment and improve configuration management.

Changes

File Path Change Summary
.gitignore Added contrib/localnet/scripts/extra-evm-chains.json to ignore list.
Makefile Modified to replace DOCKER_COMPOSE_ARGS with NODE_COMPOSE_ARGS and updated stop-localnet target to include -f docker-compose.yml.
contrib/localnet/docker-compose-persistent.yml Introduced a new file defining multiple services with persistent volumes for data storage.
contrib/localnet/docker-compose.yml Updated geth service entry point to include --datadir, upgraded grafana image version, and added volume mapping for grafana.ini.
contrib/localnet/grafana/grafana.ini Added configuration to enable anonymous authentication with specific organization settings.
contrib/localnet/orchestrator/start-zetae2e.sh Added directory creation for /root/state and introduced a variable for the deployed configuration file path.
contrib/localnet/scripts/start-zetaclientd.sh Enhanced to merge extra-evm-chains.json into zetaclient_config.json using jq.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Script
    participant ConfigFile
    participant ExternalJSON

    User->>Script: Start Client Script
    Script->>ConfigFile: Check for existing config
    alt External JSON exists
        Script->>ExternalJSON: Load extra-evm-chains.json
        ExternalJSON-->>Script: Provide configurations
        Script->>ConfigFile: Merge configurations
    end
    Script->>User: Client setup complete
Loading

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.

@gartnera gartnera force-pushed the persistent-localnet branch 2 times, most recently from 5a69ca9 to 0aeb30c Compare September 16, 2024 16:10
orchestrator persistence

geth and orchestrator persistence

also persist zetaclient dir (observer databases)

add extra-evm-chains.json merge into zetaclient config
@gartnera gartnera added the no-changelog Skip changelog CI check label Sep 19, 2024
@gartnera gartnera marked this pull request as ready for review September 19, 2024 16:44
@gartnera gartnera requested a review from a team September 19, 2024 16:48
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: 2

Outside diff range and nitpick comments (1)
contrib/localnet/orchestrator/start-zetae2e.sh (1)

Line range hint 184-193: Consider using a more reliable waiting mechanism and clarify the purpose of running zetae2e twice.

  1. Using the deployed_config_path variable is consistent and improves maintainability.

  2. The 10-second wait might not be sufficient in all scenarios, potentially leading to race conditions. Consider using a more reliable waiting mechanism, such as polling for a specific condition or using an exponential backoff strategy.

  3. The purpose of running zetae2e twice with different flags is unclear from the given context. Please add comments to clarify the reasoning behind this approach.

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 9b704a5 and 93f5b57.

Files selected for processing (7)
  • .gitignore (1 hunks)
  • Makefile (2 hunks)
  • contrib/localnet/docker-compose-persistent.yml (1 hunks)
  • contrib/localnet/docker-compose.yml (3 hunks)
  • contrib/localnet/grafana/grafana.ini (1 hunks)
  • contrib/localnet/orchestrator/start-zetae2e.sh (8 hunks)
  • contrib/localnet/scripts/start-zetaclientd.sh (1 hunks)
Files skipped from review due to trivial changes (1)
  • .gitignore
Additional context used
Path-based instructions (2)
contrib/localnet/orchestrator/start-zetae2e.sh (1)

Pattern **/*.sh: Review the shell scripts, point out issues relative to security, performance, and maintainability.

contrib/localnet/scripts/start-zetaclientd.sh (1)

Pattern **/*.sh: Review the shell scripts, point out issues relative to security, performance, and maintainability.

Additional comments not posted (12)
contrib/localnet/docker-compose-persistent.yml (5)

1-2: Informative comments.

The comments effectively describe the purpose of the file and provide a useful command for clearing the persistent volumes. This enhances the maintainability and usability of the configuration.


4-51: Well-structured services with persistent volumes.

The services section is properly configured with appropriate volume mappings for each service. The volume names are descriptive and follow a consistent naming convention. This setup ensures data persistence for critical directories, enhancing the reliability and robustness of the services.


53-71: Properly declared persistent volumes.

The volumes section correctly declares all the required named volumes without any extraneous configuration. The volume names match the mappings used in the services section, ensuring proper data persistence for each service.


1-71: Well-structured and organized configuration file.

The docker-compose-persistent.yml file is well-organized with clear sections for services and volumes. The separation of concerns and the informative comments at the top enhance the readability and maintainability of the configuration. This structure makes it easy for users and maintainers to understand and work with the file.


1-71: No issues or improvements identified.

After a thorough review of the docker-compose-persistent.yml file, no issues or areas for improvement were found. The configuration follows best practices, and the persistent storage setup is properly implemented. The file is ready for integration into the project.

contrib/localnet/docker-compose.yml (2)

196-196: Approve the --datadir and -- additions to the geth service.

The inclusion of the --datadir option and the trailing -- in the geth service's entrypoint is a welcome enhancement. It improves data management and allows for further customization of the geth process.


316-316: Approve the Grafana version upgrade and grafana.ini volume mapping.

Updating the Grafana image to version 10.4.8 is a positive change that likely introduces new features, improvements, and security patches. This upgrade enhances the overall functionality and stability of the monitoring service.

Furthermore, the addition of the grafana.ini volume mapping is a valuable enhancement. It allows for custom configuration of the Grafana instance, improving its configurability and adaptability to specific requirements.

Also applies to: 325-325

contrib/localnet/orchestrator/start-zetae2e.sh (3)

163-165: LGTM!

The changes ensure the required directory exists and improve the script's maintainability by using a variable for the file path.


173-174: Looks good!

The changes consistently use the deployed_config_path variable, improving the script's maintainability.


217-218: LGTM!

The changes consistently use the deployed_config_path variable across the script, improving its maintainability and readability.

Also applies to: 232-232, 271-271, 273-273, 289-290, 305-305

Makefile (2)

8-11: Excellent enhancement to improve flexibility!

The introduction of the NODE_COMPOSE_ARGS variable enables users to pass additional arguments to Docker Compose, such as setting profiles and optional overlays. The provided example in the comments clearly illustrates the usage of this new variable.


228-228: Clear and explicit file resolution for stopping the local network.

The inclusion of the -f docker-compose.yml flag in the stop-localnet target ensures that the correct Docker Compose file is used when bringing down the local network. This change enhances clarity and mitigates potential issues related to file resolution.

contrib/localnet/grafana/grafana.ini Show resolved Hide resolved
contrib/localnet/scripts/start-zetaclientd.sh Show resolved Hide resolved
Copy link
Member

@lumtis lumtis left a comment

Choose a reason for hiding this comment

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

Can we add mention of the option in https://github.com/zeta-chain/node/blob/develop/docs/development/LOCAL_TESTING.md?
Also maybe we could consider to have persistence by default when using start-localnet?

@gartnera
Copy link
Member Author

Can we add mention of the option in https://github.com/zeta-chain/node/blob/develop/docs/development/LOCAL_TESTING.md?

Done

Also maybe we could consider to have persistence by default when using start-localnet?

I think it might be a bit confusing to change the default. I'd like to get a bit more feedback and fully document the localnet -> real network process before doing that.

@gartnera gartnera added this pull request to the merge queue Sep 20, 2024
Merged via the queue into develop with commit c7ac9b4 Sep 20, 2024
31 checks passed
@gartnera gartnera deleted the persistent-localnet branch September 20, 2024 18:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no-changelog Skip changelog CI check
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants