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

chore(systemtest): More stable fraud test #21949

Merged
merged 1 commit into from
Sep 27, 2024
Merged

chore(systemtest): More stable fraud test #21949

merged 1 commit into from
Sep 27, 2024

Conversation

alpe
Copy link
Contributor

@alpe alpe commented Sep 27, 2024

Description

Minor update to have longer pull for validator status and some redundancies removed

Summary by CodeRabbit

  • Tests
    • Improved the logic for validating double-signing events, enhancing the reliability of power updates for nodes.
    • Streamlined the block confirmation process for better efficiency.

@alpe alpe requested a review from a team as a code owner September 27, 2024 09:15
Copy link
Contributor

coderabbitai bot commented Sep 27, 2024

📝 Walkthrough
📝 Walkthrough

Walkthrough

The changes in the TestValidatorDoubleSign function enhance the logic for monitoring a node's power after a double-signing event. The iteration count for checking the validator's power has been increased, and the initialization of the nodePowerAfter variable has been modified for clarity. The code has been streamlined by consolidating certain operations and adjusting the logging placement. Additionally, the block confirmation process has been simplified.

Changes

File Change Summary
tests/systemtests/fraud_test.go Modified TestValidatorDoubleSign to extend the power check iterations, simplify logic, and streamline block confirmation.

Possibly related PRs

  • test: e2e/staking to system tests #21882: The changes in TestStakeUnstake enhance the validation of staking operations, which may relate to the logic of waiting for a node's power to update in TestValidatorDoubleSign as both involve validator state changes.

Suggested reviewers

  • akhilkumarpilli
  • julienrbrt
  • tac0turtle

📜 Recent review details

Configuration used: .coderabbit.yml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between b40c7c2 and f89e6ab.

📒 Files selected for processing (1)
  • tests/systemtests/fraud_test.go (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/systemtests/fraud_test.go

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 (2)
tests/systemtests/fraud_test.go (2)

45-47: Approved: Changes improve test stability

The modifications in these lines enhance the test's reliability:

  1. Increasing the loop count from 20 to 30 allows more time for the validator power to update.
  2. Initializing nodePowerAfter to -1 provides a clear initial state.

These changes align well with the PR objective of improving the stability of the fraud test.

Consider adding a comment explaining the significance of the -1 initial value for nodePowerAfter, e.g.:

// Initialize nodePowerAfter to -1 to distinguish from the case where power is 0
var nodePowerAfter int64 = -1

49-52: Approved: Improved code clarity and observability

The changes in these lines enhance the test's readability and debuggability:

  1. Moving the nodePowerAfter assignment into the if condition simplifies the code.
  2. Adding a log statement for the current height improves visibility into the test progress.

These modifications contribute positively to the overall code quality and align with the PR's objectives.

For consistency with the Uber Go Style Guide, consider using strconv.Itoa() instead of %d for integer to string conversion in the log statement:

t.Logf("wait %s", strconv.Itoa(sut.CurrentHeight()))
📜 Review details

Configuration used: .coderabbit.yml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between dc09671 and b40c7c2.

📒 Files selected for processing (1)
  • tests/systemtests/fraud_test.go (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
tests/systemtests/fraud_test.go (3)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.


Pattern tests/**/*: "Assess the integration and e2e test code assessing sufficient code coverage for the changes associated in the pull request"


Pattern **/*_test.go: "Assess the unit test code assessing sufficient code coverage for the changes associated in the pull request"

🔇 Additional comments (2)
tests/systemtests/fraud_test.go (2)

Line range hint 1-63: Overall assessment: Changes improve test stability and clarity

The modifications in this file successfully address the PR objectives:

  1. The test's stability is improved by allowing more time for validator power updates.
  2. Code redundancies have been removed, particularly in the block confirmation process.
  3. Observability has been enhanced with additional logging.

These changes should result in a more reliable and maintainable fraud test. The suggestions provided in the review comments are minor and aimed at further improving code quality and consistency.

To ensure comprehensive test coverage, consider adding the following test cases if they're not already present elsewhere:

  1. Test with multiple validators to ensure the correct validator is jailed.
  2. Test with different network conditions to verify the robustness of the updated timing.
  3. Verify that a validator can't rejoin the active set after being jailed for double-signing.

62-63: Approved: Streamlined block confirmation process

The changes in these lines improve the test's efficiency and clarity:

  1. Replacing the loop with a single AwaitNBlocks call simplifies the code.
  2. Reducing the wait from 10 to 5 blocks could potentially speed up the test.

These modifications align well with the PR's goal of removing redundancies and improving test stability.

To ensure this change doesn't affect the test's reliability, please verify that waiting for 5 blocks is sufficient for all necessary updates to propagate. You can run the following command to check for any timing-related issues in recent test runs:

If no issues are found, the change is likely safe. Otherwise, consider reverting to 10 blocks or finding an optimal number through experimentation.

@alpe alpe enabled auto-merge September 27, 2024 09:30
@alpe alpe added this pull request to the merge queue Sep 27, 2024
Merged via the queue into main with commit dcf00cf Sep 27, 2024
73 of 74 checks passed
@alpe alpe deleted the alex/chore_fraud_test branch September 27, 2024 09:43
@julienrbrt
Copy link
Member

@mergify backport release/v0.52.x

Copy link
Contributor

mergify bot commented Sep 27, 2024

backport release/v0.52.x

✅ Backports have been created

mergify bot pushed a commit that referenced this pull request Sep 27, 2024
julienrbrt pushed a commit that referenced this pull request Sep 27, 2024
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.

4 participants