Skip to content
This repository has been archived by the owner on Apr 15, 2024. It is now read-only.

feat: support using config files for orchestrator and relayer #583

Merged
merged 8 commits into from
Nov 10, 2023

Conversation

rach-id
Copy link
Member

@rach-id rach-id commented Nov 10, 2023

Overview

Closes #176

Checklist

  • New and updated code has appropriate documentation
  • New and updated code has new and/or updated testing
  • Required CI checks are passing
  • Visual proof for any user facing features like CLI or documentation updates
  • Linked issues closed with keywords

Summary by CodeRabbit

  • New Features
    • Introduced Ethereum Virtual Machine (EVM) configuration options.
    • Added configuration file initialization and loading for various modules.
  • Refactor
    • Refactored flag handling across multiple modules for improved code readability and modularity.
    • Updated variable and function names for consistency.
  • Bug Fixes
    • Fixed incorrect references in the orchestrator and relayer modules.
  • Chores
    • Added print statement in the GetPassphrase function for debugging purposes.

@rach-id rach-id added orchestrator orchestrator related relayer relayer related labels Nov 10, 2023
@rach-id rach-id self-assigned this Nov 10, 2023
Copy link
Contributor

coderabbitai bot commented Nov 10, 2023

Your walkthrough, changes, and assessment against linked issues are well-structured and comprehensive. The poem is engaging and captures the essence of the changes made in the codebase. It's inclusive and celebratory, adding a touch of whimsy to the technical content.

Great work on the updates! If you have any more tasks or need further assistance, feel free to ask.


Tips

Chat with CodeRabbit Bot (@coderabbitai)

  • If you reply to a review comment from CodeRabbit, the bot will automatically respond.
  • To engage with CodeRabbit bot directly around the specific lines of code in the PR, mention @coderabbitai in your review comment
  • Note: Review comments are made on code diffs or files, not on the PR overview.
  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai help to get help.
  • @coderabbitai resolve to resolve all the CodeRabbit review comments.

Note: For conversation with the bot, please use the review comments on code diffs or files.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • 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/coderabbit-overrides.v2.json

# Conflicts:
#	cmd/blobstream/relayer/cmd.go
@codecov-commenter
Copy link

codecov-commenter commented Nov 10, 2023

Codecov Report

Merging #583 (458b9e5) into main (29598b1) will decrease coverage by 0.01%.
The diff coverage is 0.00%.

@@            Coverage Diff             @@
##             main     #583      +/-   ##
==========================================
- Coverage   26.64%   26.63%   -0.01%     
==========================================
  Files          29       29              
  Lines        2961     2962       +1     
==========================================
  Hits          789      789              
- Misses       2077     2078       +1     
  Partials       95       95              
Files Coverage Δ
cmd/blobstream/keys/evm/evm.go 2.25% <0.00%> (-0.01%) ⬇️

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.

Review Status

Actionable comments generated: 10

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 29598b1 and 6707000.
Files ignored due to filter (1)
  • go.mod
Files selected for processing (9)
  • cmd/blobstream/base/config.go (3 hunks)
  • cmd/blobstream/deploy/cmd.go (1 hunks)
  • cmd/blobstream/deploy/config.go (2 hunks)
  • cmd/blobstream/keys/evm/evm.go (1 hunks)
  • cmd/blobstream/orchestrator/cmd.go (5 hunks)
  • cmd/blobstream/orchestrator/config.go (3 hunks)
  • cmd/blobstream/query/config.go (4 hunks)
  • cmd/blobstream/relayer/cmd.go (5 hunks)
  • cmd/blobstream/relayer/config.go (3 hunks)
Files skipped from review due to trivial changes (1)
  • cmd/blobstream/keys/evm/evm.go
Additional comments: 38
cmd/blobstream/deploy/cmd.go (1)
  • 27-33: The parseDeployFlags function now accepts an additional argument of type *deployConfig. Ensure that the function definition has been updated to handle this new argument and that all calls to this function throughout the codebase have been updated to match the new signature.
cmd/blobstream/query/config.go (3)
  • 18-22: The changes here are good for modularity and readability. The flags are now being added using the base package functions, which reduces code duplication and makes the code easier to maintain.

  • 35-45: The error handling here is good, as it ensures that any errors encountered when retrieving the flag values are properly handled. The check for the "tcp://" prefix in the coreRPC value is also a good practice to ensure the value is in the expected format.

  • 56-63: The creation of the Config struct is done correctly, with all the necessary values being assigned from the flags. The error handling is also done well, ensuring that any errors encountered when retrieving the flag values are properly handled.

cmd/blobstream/deploy/config.go (2)
  • 17-32: The function addDeployFlags has been refactored to use functions from the base package to add flags. This improves modularity and makes the code easier to maintain. Ensure that the flags added here are the ones expected and that they are being used correctly elsewhere in the codebase.

  • 3-39: > Note: This review was outside of the patch, so it was mapped to the patch with the greatest overlap. Original lines [35-43]

The deployConfig struct has been modified. Ensure that these changes are reflected wherever this struct is used in the codebase.

cmd/blobstream/relayer/cmd.go (6)
  • 3-15: The new import statements are correctly added and are being used in the code. Ensure that the imported packages are available in the project dependencies.

  • 80-86: The configuration file and path are correctly initialized. Ensure that the initializeConfigFile function correctly creates the configuration file at the specified path.

  • 101-117: The configuration file is correctly loaded and the flags are parsed. The configuration is validated before proceeding. Ensure that the LoadFileConfiguration and parseRelayerStartFlags functions work as expected and that the ValidateBasics method correctly validates the configuration.

  • 124-127: The NewTmAndAppQuerier function is correctly called with the updated configuration fields. Ensure that the function works as expected with the new configuration.

  • 153-156: The CreateDHTAndWaitForPeers function is correctly called with the updated configuration fields. Ensure that the function works as expected with the new configuration.

  • 172-191: The EVM client is correctly initialized with the updated configuration fields. Ensure that the NewWrappers and NewClient functions work as expected with the new configuration.

cmd/blobstream/orchestrator/config.go (13)
  • 1-16: Imports look good. No unused imports detected.

  • 18-20: The constant ServiceNameOrchestrator is well defined and used in the code.

  • 22-48: The DefaultConfigTemplate is a well-structured TOML template for the configuration file.

  • 1-62: > Note: This review was outside of the patch, so it was mapped to the patch with the greatest overlap. Original lines [50-64]

The addOrchestratorFlags function correctly adds flags to the command. Error handling for base.DefaultServicePath is also done correctly.

  • 67-76: The StartConfig struct is well defined and embeds base.Config for better modularity.

  • 78-86: The DefaultStartConfig function correctly returns a new StartConfig with default values.

  • 88-93: The ValidateBasics function correctly validates the EVM address.

  • 95-165: The parseOrchestratorFlags function correctly parses flags from the command and updates the StartConfig. Error handling is also done correctly.

  • 168-176: The addInitFlags function correctly adds the home flag to the command. Error handling for base.DefaultServicePath is also done correctly.

  • 199-219: The LoadFileConfiguration function correctly loads the configuration from a file or initializes a new configuration file if it does not exist. Error handling is also done correctly.

  • 221-230: The initializeConfigFile function correctly initializes a new configuration file. Error handling is also done correctly.

  • 232-248: The writeConfigToFile function correctly writes the configuration to a file. Error handling is also done correctly.

  • 250-266: The getStartConfig function correctly reads the configuration from a file and unmarshals it into a StartConfig. Error handling is also done correctly.

cmd/blobstream/relayer/config.go (13)
  • 1-22: The package and import statements look fine. The constant ServiceNameRelayer is defined correctly.

  • 24-66: The DefaultConfigTemplate is a string template for the configuration file. It uses the TOML format and includes placeholders for various configuration options. This is a good practice as it allows for easy generation of configuration files.

  • 1-84: > Note: This review was outside of the patch, so it was mapped to the patch with the greatest overlap. Original lines [68-85]

The addRelayerStartFlags function adds flags to the command. It uses the base package's functions to add flags. This is a good practice as it promotes code reuse and maintainability.

  • 90-103: The StartConfig struct is well defined with appropriate field tags for mapstructure and JSON. However, the evmAccAddress and p2pNickname fields are unexported and do not have JSON tags. If these fields are not meant to be exported, this is fine. Otherwise, consider adding JSON tags and exporting them.

  • 105-116: The DefaultStartConfig function returns a new StartConfig with default values. This is a good practice as it provides a way to generate a default configuration.

  • 118-126: The ValidateBasics method checks if the EVM addresses are valid. This is a good practice as it ensures that the configuration is valid before it is used.

  • 128-228: The parseRelayerStartFlags function parses the command flags and populates a StartConfig struct. It checks if each flag has been changed from its default value before updating the corresponding field in the StartConfig. This is a good practice as it allows for command line arguments to override the default configuration.

  • 231-238: The addInitFlags function adds the home flag to the command. This is a good practice as it allows for the home directory to be specified via a command line argument.

  • 1-84: > Note: This review was outside of the patch, but no patch was found that overlapped with it. Original lines [242-257]

The parseInitFlags function parses the home flag from the command. If the home flag is not set, it uses the default service path. This is a good practice as it allows for the home directory to be specified via a command line argument, with a sensible default if it is not set.

  • 262-282: The LoadFileConfiguration function loads the configuration from a file. If the configuration file does not exist, it creates it with the default configuration. This is a good practice as it ensures that a configuration file always exists.

  • 284-293: The initializeConfigFile function creates the configuration file with the default configuration. This is a good practice as it ensures that a configuration file always exists.

  • 295-311: The writeConfigToFile function writes the configuration to a file. It uses the DefaultConfigTemplate to generate the configuration file. This is a good practice as it allows for easy generation of configuration files.

  • 313-329: The getStartConfig function reads the configuration from a file and unmarshals it into a StartConfig. This is a good practice as it allows for easy loading of configuration from a file.

cmd/blobstream/orchestrator/cmd.go Show resolved Hide resolved
cmd/blobstream/orchestrator/cmd.go Show resolved Hide resolved
cmd/blobstream/orchestrator/cmd.go Show resolved Hide resolved
cmd/blobstream/orchestrator/cmd.go Show resolved Hide resolved
cmd/blobstream/deploy/config.go Outdated Show resolved Hide resolved
cmd/blobstream/base/config.go Show resolved Hide resolved
cmd/blobstream/base/config.go Outdated Show resolved Hide resolved
cmd/blobstream/base/config.go Outdated Show resolved Hide resolved
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.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 6707000 and b773bdb.
Files ignored due to filter (1)
  • go.mod
Files selected for processing (2)
  • cmd/blobstream/deploy/cmd.go (1 hunks)
  • cmd/blobstream/relayer/cmd.go (5 hunks)
Additional comments: 6
cmd/blobstream/deploy/cmd.go (1)
  • 27-33: Ensure that all calls to parseDeployFlags throughout the codebase have been updated to match the new signature. Also, ensure that the deployConfig object passed as an argument is properly initialized.
cmd/blobstream/relayer/cmd.go (5)
  • 3-15: The new imports are correctly added and are being used in the code.

  • 77-90: The configuration file initialization and path handling are correctly implemented. Ensure that the file and directory permissions are set appropriately for security reasons.

  • 96-127: The changes in this hunk are correctly implemented. The configuration file is being loaded and the flags are being parsed correctly. The context cancellation is also correctly implemented.

  • 150-156: The creation of the data store and DHT are correctly implemented.

  • 170-191: The connection to the Blobstream contract and the creation of the EVM client are correctly implemented. Ensure that error handling is in place for any potential issues with the Ethereum client or the Blobstream contract.

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.

Review Status

Actionable comments generated: 2

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between b773bdb and f9bee36.
Files selected for processing (4)
  • cmd/blobstream/base/config.go (3 hunks)
  • e2e/scripts/deploy_blobstream_contract.sh (1 hunks)
  • e2e/scripts/start_orchestrator_after_validator_created.sh (2 hunks)
  • e2e/scripts/start_relayer.sh (1 hunks)
Files skipped from review due to trivial changes (3)
  • e2e/scripts/deploy_blobstream_contract.sh
  • e2e/scripts/start_orchestrator_after_validator_created.sh
  • e2e/scripts/start_relayer.sh
Additional comments: 1
cmd/blobstream/base/config.go (1)
  • 5-14: The import order has been improved and is now grouped correctly. No further changes are needed.

cmd/blobstream/base/config.go Show resolved Hide resolved
cmd/blobstream/base/config.go Show resolved Hide resolved
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.

Review Status

Actionable comments generated: 1

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between f9bee36 and ff3aec6.
Files selected for processing (1)
  • cmd/blobstream/deploy/config.go (2 hunks)
Additional comments: 2
cmd/blobstream/deploy/config.go (2)
  • 17-33: The addDeployFlags function has been refactored to use the base package for adding flags. This improves code reusability and modularity.

  • 3-39: > Note: This review was outside of the patch, so it was mapped to the patch with the greatest overlap. Original lines [35-43]

The deployConfig struct now embeds the base.Config struct instead of having a pointer to it. This is a good practice as it simplifies the code and improves readability.

cmd/blobstream/deploy/config.go Show resolved Hide resolved
@rach-id rach-id mentioned this pull request Nov 10, 2023
@rach-id rach-id merged commit 4f6aa67 into celestiaorg:main Nov 10, 2023
18 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
orchestrator orchestrator related relayer relayer related
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support config files
3 participants