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

ci(localnet): Fix script, simplify, and test in CI. #1714

Merged
merged 8 commits into from
Dec 17, 2023

Conversation

Unique-Divine
Copy link
Member

@Unique-Divine Unique-Divine commented Dec 16, 2023

Purpose

  1. The localnet.sh script is broken. This fixes it.
  2. The code in the script is also simplified
  3. A step has been added to the build job in the CI tests to help us maintain it.

Summary by CodeRabbit

  • Refactor

    • Streamlined build process for the application binary.
    • Enhanced the chaos testing script to include process termination scenarios.
    • Introduced a new script for local network setup with simplified configuration steps.
  • Chores

    • Updated local network setup script with new commands for initializing and configuring the application, improving the setup process for developers and testers.

@Unique-Divine Unique-Divine requested a review from a team as a code owner December 16, 2023 01:15
Copy link
Contributor

coderabbitai bot commented Dec 16, 2023

Walkthrough

The recent updates streamline the build and configuration processes for the nibid binary, enhancing the automated testing environment. The build step now utilizes just install, and a new script for local network setup has been added. The chaosnet script includes a step to terminate a process, improving test robustness. Configuration commands have been consolidated, and genesis parameters adjusted, reflecting a more efficient setup. Additionally, the validator setup has been refined with gentx addition and collection steps.

Changes

File Path Change Summary
.github/workflows/unit-tests.yml Altered build step to use just install, expanded chaosnet script with a process kill step, and added a localnet script step.
contrib/scripts/localnet.sh Updated configuration commands, API and Swagger settings, genesis parameters, and added validator gentx commands.
CHANGELOG.md Includes an addition related to CI for the localnet.sh script.
proto/nibiru/sudo/v1/event.proto Added a new message EventUpdateSudoers.
proto/nibiru/sudo/v1/state.proto Modified the comment for the GenesisState message.

Related issues

Poem

🐇✨
In the burrows of code where the binary hops,
A script was refined, and a process stops.
With a just install the build does cheer,
As the rabbit's work makes the pathway clear.
🌟🐾

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 X ?


Tips

Chat with CodeRabbit Bot (@coderabbitai)

  • You can reply to a review comment made by CodeRabbit.
  • You can tag CodeRabbit on specific lines of code or files in the PR by tagging @coderabbitai in a comment.
  • You can tag @coderabbitai in a PR comment and ask one-off questions about the PR and the codebase. Use quoted replies to pass the context for follow-up questions.

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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

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

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 12ee680 and 3d3470c.
Files selected for processing (2)
  • .github/workflows/unit-tests.yml (1 hunks)
  • contrib/scripts/localnet.sh (4 hunks)
Files skipped from review due to trivial changes (1)
  • .github/workflows/unit-tests.yml
Additional comments: 9
contrib/scripts/localnet.sh (9)
  • 112-113: The error handling after attempting to initialize the chain ID is correct, but it's important to ensure that the error message is informative enough for debugging purposes.

  • 115-121: The consolidation of configuration commands into a single nibid config command is a good simplification. However, it's important to verify that the nibid binary accepts these configurations in the new format and that the changes are compatible with the rest of the system.

  • 125-125: Using sed with -i and $SEDOPTION to edit the app.toml file directly is a practical approach, but it's important to ensure that the app.toml file structure is consistent across different environments to avoid potential issues with the sed command.

  • 141-141: The command to add a genesis account is updated. It's crucial to ensure that the $BINARY keys show $val_key_name -a command outputs the expected address format and that the genesis coins are correctly formatted and valid for the network.

  • 195-195: The addition of the add-genesis-perp-market command is a significant change. It's important to ensure that the command is executed with the correct parameters and that the check_fail function is called correctly to handle potential failures.

  • 235-238: The add_genesis_param function is used to set oracle exchange rates. It's important to ensure that the jq command is correctly formatted and that the genesis.json file is properly updated without any syntax errors.

  • 245-246: The gentx command is added to create a genesis transaction for the validator. It's crucial to verify that the amount specified (900000000unibi) is correct and that the --chain-id parameter matches the intended chain ID.

  • 252-253: The collect-gentxs command is used to collect genesis transactions into the genesis.json file. It's important to ensure that this command works as expected and that the genesis.json file is in a valid state after execution.

  • 263-263: The command to start the network is unchanged, but it's important to ensure that the --pruning nothing flag is the desired behavior for the localnet environment.

Comment on lines 232 to +246
add_genesis_param '.app_state.sudo.sudoers.root = "'"$val_address"'"'

# hack for localnet since we don't have a pricefeeder yet
add_genesis_param '.app_state.oracle.exchange_rates[0].pair = "ubtc:unusd"'
add_genesis_param '.app_state.oracle.exchange_rates[0].pair = "ubtc:uuusd"'
add_genesis_param '.app_state.oracle.exchange_rates[0].exchange_rate = "'"$price_btc"'"'
add_genesis_param '.app_state.oracle.exchange_rates[1].pair = "ueth:unusd"'
add_genesis_param '.app_state.oracle.exchange_rates[1].pair = "ueth:uuusd"'
add_genesis_param '.app_state.oracle.exchange_rates[1].exchange_rate = "'"$price_eth"'"'

# ------------------------------------------------------------------------
# Gentx
# ------------------------------------------------------------------------

echo_info "Adding gentx validator..."
if $BINARY genesis gentx $val_key_name 900000000unibi --chain-id $CHAIN_ID; then
echo_success "Successfully added gentx"
Copy link
Member Author

Choose a reason for hiding this comment

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

Gentx has to occur after we add the address to the x/sudo genesis

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 3d3470c and b5e7da5.
Files selected for processing (1)
  • CHANGELOG.md (1 hunks)
Additional comments: 1
CHANGELOG.md (1)
  • 74-74: The changelog entry correctly summarizes the CI improvements and script fixes for localnet.sh.

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 b5e7da5 and 3012f70.
Files ignored due to filter (2)
  • x/sudo/types/event.pb.go
  • x/sudo/types/state.pb.go
Files selected for processing (3)
  • CHANGELOG.md (1 hunks)
  • proto/nibiru/sudo/v1/event.proto (1 hunks)
  • proto/nibiru/sudo/v1/state.proto (1 hunks)
Files skipped from review due to trivial changes (2)
  • CHANGELOG.md
  • proto/nibiru/sudo/v1/state.proto
Additional comments: 1
proto/nibiru/sudo/v1/event.proto (1)
  • 11-13: The addition of the EventUpdateSudoers message with a non-nullable sudoers field is correctly defined according to protobuf syntax and conventions.

proto/nibiru/sudo/v1/event.proto 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 3012f70 and 034fc75.
Files selected for processing (1)
  • .github/workflows/unit-tests.yml (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • .github/workflows/unit-tests.yml

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

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 034fc75 and ea35c9b.
Files selected for processing (4)
  • .github/workflows/unit-tests.yml (1 hunks)
  • CHANGELOG.md (1 hunks)
  • contrib/bashlib.sh (2 hunks)
  • justfile (3 hunks)
Files skipped from review due to trivial changes (1)
  • CHANGELOG.md
Files skipped from review as they are similar to previous changes (1)
  • .github/workflows/unit-tests.yml
Additional comments: 5
justfile (5)
  • 11-13: The install-clean recipe is a good addition for ensuring a clean state before installation. However, ensure that the temp directory is indeed the correct directory to remove and that no other artifacts need cleaning.

  • 42-44: The localnet recipe correctly delegates to the make localnet command, which should handle the setup of the local network.

  • 57-62: The test-chaosnet recipe runs the chaosnet.sh script. Ensure that this script has proper error handling and cleanup mechanisms in place, as the justfile recipe does not provide any.

  • 76-77: The renaming of release-test to test-release is not shown in the hunks, but it aligns with the naming convention of other test recipes, which is a good practice for consistency.

  • 39-66: > Note: This review was outside the patches, so it was mapped to the patch with the greatest overlap. Original lines [8-78]

The changes to the justfile align with the PR objectives of fixing, simplifying, and enhancing the reliability of the localnet.sh script, as well as ensuring its functionality is tested during CI.

contrib/bashlib.sh Outdated Show resolved Hide resolved
contrib/bashlib.sh Show resolved Hide resolved
justfile Show resolved Hide resolved
@Unique-Divine Unique-Divine merged commit e890d4f into main Dec 17, 2023
17 checks passed
@Unique-Divine Unique-Divine deleted the realu/chore-fix-localnet branch December 17, 2023 18:57
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