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

Problem: iavl rollback not tested #1693

Merged
merged 3 commits into from
Nov 13, 2024

Conversation

yihuang
Copy link
Collaborator

@yihuang yihuang commented Nov 13, 2024

👮🏻👮🏻👮🏻 !!!! REFERENCE THE PROBLEM YOUR ARE SOLVING IN THE PR TITLE AND DESCRIBE YOUR SOLUTION HERE !!!! DO NOT FORGET !!!! 👮🏻👮🏻👮🏻

PR Checklist:

  • Have you read the CONTRIBUTING.md?
  • Does your PR follow the C4 patch requirements?
  • Have you rebased your work on top of the latest master?
  • Have you checked your code compiles? (make)
  • Have you included tests for any non-trivial functionality?
  • Have you checked your code passes the unit tests? (make test)
  • Have you checked your code formatting is correct? (go fmt)
  • Have you checked your basic code style is fine? (golangci-lint run)
  • If you added any dependencies, have you checked they do not contain any known vulnerabilities? (go list -json -m all | nancy sleuth)
  • If your changes affect the client infrastructure, have you run the integration test?
  • If your changes affect public APIs, does your PR follow the C4 evolution of public contracts?
  • If your code changes public APIs, have you incremented the crate version numbers and documented your changes in the CHANGELOG.md?
  • If you are contributing for the first time, please read the agreement in CONTRIBUTING.md now and add a comment to this pull request stating that your PR is in accordance with the Developer's Certificate of Origin.

Thank you for your code, it's appreciated! :)

Summary by CodeRabbit

  • New Features

    • Introduced new validators for rollback testing, enhancing the configuration options.
  • Bug Fixes

    • Improved the rollback testing logic to accommodate multiple nodes, increasing scalability and maintainability.
  • Refactor

    • Renamed and generalized the command update function to handle multiple nodes, streamlining the test process.

@yihuang yihuang requested a review from a team as a code owner November 13, 2024 07:20
@yihuang yihuang requested review from JayT106 and thomas-nguy and removed request for a team November 13, 2024 07:20
Copy link
Contributor

coderabbitai bot commented Nov 13, 2024

Walkthrough

The pull request modifies the configuration of validators in integration_tests/configs/rollback.jsonnet, replacing the 'fullnode' validator with 'rollback-test-memiavl' and introducing a new 'rollback-test-iavl' validator. Additionally, it updates the test logic in integration_tests/test_rollback.py by renaming the update_node2_cmd function to update_node_cmd for improved scalability and generalization, allowing it to handle multiple nodes. The test logic is further enhanced to dynamically manage commands for both nodes 2 and 3.

Changes

File Change Summary
integration_tests/configs/rollback.jsonnet - Replaced validator 'fullnode' with 'rollback-test-memiavl' (enabled memiavl).
- Added new validator 'rollback-test-iavl' (disabled memiavl).
integration_tests/test_rollback.py - Renamed function update_node2_cmd to update_node_cmd for handling multiple nodes.
- Updated test_rollback logic to support dynamic handling of nodes 2 and 3.

Possibly related PRs

Suggested reviewers

  • calvinaco
  • mmsqe
  • thomas-nguy

Poem

In the meadow, changes bloom,
Validators shift, dispelling gloom.
From 'fullnode' to 'rollback-test',
New commands for nodes, we do our best!
With each update, our code takes flight,
Hopping forward, all feels right! 🐇✨

Warning

Rate limit exceeded

@yihuang has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 15 minutes and 13 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 3e109f4 and b355ad4.


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.

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

codecov bot commented Nov 13, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 11.63%. Comparing base (6dc645a) to head (b355ad4).
Report is 1 commits behind head on main.

❗ There is a different number of reports uploaded between BASE (6dc645a) and HEAD (b355ad4). Click for more details.

HEAD has 21 uploads less than BASE
Flag BASE (6dc645a) HEAD (b355ad4)
2 0
integration_tests 20 1
Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##             main    #1693       +/-   ##
===========================================
- Coverage   35.47%   11.63%   -23.85%     
===========================================
  Files         124       72       -52     
  Lines       11893     6163     -5730     
===========================================
- Hits         4219      717     -3502     
+ Misses       7251     5395     -1856     
+ Partials      423       51      -372     

see 84 files with indirect coverage changes

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

🧹 Outside diff range and nitpick comments (1)
integration_tests/test_rollback.py (1)

85-107: Consider enhancing error reporting in the test

While the test logic is thorough, consider adding more detailed error messages to help diagnose failures. For example:

-        assert cli.block_height() == 10
+        height = cli.block_height()
+        assert height == 10, f"Expected node {i} to be stuck at height 10, but got height {height}"

The overall test implementation is well-structured and properly tests the rollback functionality for both memiavl and iavl nodes.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 6dc645a and 3e109f4.

📒 Files selected for processing (2)
  • integration_tests/configs/rollback.jsonnet (1 hunks)
  • integration_tests/test_rollback.py (3 hunks)
🔇 Additional comments (5)
integration_tests/configs/rollback.jsonnet (2)

6-18: LGTM! Well-structured validator configurations for rollback testing.

The configuration properly sets up two validators with opposite memiavl settings, enabling comprehensive rollback testing for both memiavl and traditional iavl scenarios. The naming is clear and purpose-driven.


6-18: Verify integration with test files.

Let's verify that the test files correctly reference these new validator configurations.

✅ Verification successful

Let me gather more information about the test files to ensure proper integration.


Integration with test files is properly configured

The verification confirms proper integration:

  • The test file test_rollback.py correctly loads the configuration from rollback.jsonnet
  • The test's docstring explicitly documents the validator roles: "node2: test memiavl node, node3: test iavl node"
  • The rollback.jsonnet configuration properly defines both validators with correct memiavl settings
  • There are no lingering references to old configurations

The new validator configurations are properly referenced and integrated within the test infrastructure.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that test files correctly reference the new validator names
# and that there are no lingering references to the old 'fullnode' validator

# Check for references to the new validator names
echo "Checking references to new validator names:"
rg -l "rollback-test-(mem)?iavl" integration_tests/

# Check for any remaining references to the old validator name
echo "Checking for lingering references to 'fullnode':"
rg -l "fullnode" integration_tests/

# Look for the test file mentioned in the summary
echo "Checking test_rollback.py contents:"
rg -A 5 "update_node_cmd" integration_tests/test_rollback.py

Length of output: 1112


Script:

#!/bin/bash
# Check the content of test_rollback.py to see how validators are referenced
echo "Checking test_rollback.py for validator configuration:"
rg -A 10 "def test_rollback" integration_tests/test_rollback.py

# Check the content of rollback.jsonnet to understand the complete configuration
echo "Checking complete rollback.jsonnet configuration:"
cat integration_tests/configs/rollback.jsonnet

# Look for any test configuration loading or parsing
echo "Checking for configuration loading in test files:"
rg -A 5 "rollback.jsonnet" integration_tests/

Length of output: 1586

integration_tests/test_rollback.py (3)

Line range hint 15-28: Well-structured generalization of the node command update function!

Good improvement in making the function reusable across different nodes. The implementation correctly handles configuration updates and properly manages the supervisor settings.


34-35: Good addition of iavl node testing!

The initialization of both memiavl (node2) and iavl (node3) nodes aligns well with the PR's objective to test iavl rollback functionality.


70-74: Clear documentation and efficient test setup!

Good job on:

  • Clearly documenting the role of each node (memiavl vs iavl)
  • Using efficient dictionary comprehension for CLI setup

integration_tests/test_rollback.py Outdated Show resolved Hide resolved
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Signed-off-by: yihuang <[email protected]>
@yihuang yihuang requested a review from mmsqe November 13, 2024 07:36
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 (2)
integration_tests/test_rollback.py (2)

34-35: Consider using a loop for better maintainability.

While the implementation is correct, consider using a loop to make it more maintainable:

-        update_node_cmd(path / chain_id, broken_binary, 2)
-        update_node_cmd(path / chain_id, broken_binary, 3)
+        for node_id in [2, 3]:
+            update_node_cmd(path / chain_id, broken_binary, node_id)

85-107: Consider extracting magic numbers as constants.

The implementation correctly handles rollback and recovery for multiple nodes. However, consider extracting the block heights (10, 13, 15) as named constants for better maintainability:

+# At the top of the file
+STUCK_BLOCK_HEIGHT = 10
+HEALTHY_BLOCK_HEIGHT = 13
+RECOVERY_BLOCK_HEIGHT = 15

 def test_rollback(custom_cronos):
     # ...
-    wait_for_block(cli, 10)
+    wait_for_block(cli, STUCK_BLOCK_HEIGHT)
     # ...
-    wait_for_block(cli, 13)
+    wait_for_block(cli, HEALTHY_BLOCK_HEIGHT)
     # ...
-    wait_for_block(cli, 15)
+    wait_for_block(cli, RECOVERY_BLOCK_HEIGHT)
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 3e109f4 and b355ad4.

📒 Files selected for processing (1)
  • integration_tests/test_rollback.py (3 hunks)
🔇 Additional comments (3)
integration_tests/test_rollback.py (3)

Line range hint 15-28: LGTM! Good function generalization.

The function rename from update_node2_cmd to update_node_cmd improves code reusability and makes the implementation more generic by accepting the node index as a parameter.


70-74: LGTM! Clear documentation and well-structured setup.

The documentation clearly explains the role of each node (memiavl vs iavl), and the setup code is well organized with proper initialization of node list and CLI dictionary.


75-78: LGTM! Proper synchronization handling for multiple nodes.

The implementation correctly handles port waiting and block synchronization for multiple nodes with proper logging.

@yihuang yihuang enabled auto-merge November 13, 2024 07:44
@yihuang yihuang added this pull request to the merge queue Nov 13, 2024
Merged via the queue into crypto-org-chain:main with commit f1ee213 Nov 13, 2024
42 of 43 checks passed
@yihuang yihuang deleted the test-iavl-rollback branch November 13, 2024 08:06
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