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

Add e2e test case to check for monomer rollbacks #192

Merged
merged 9 commits into from
Sep 9, 2024

Conversation

natebeauregard
Copy link
Collaborator

@natebeauregard natebeauregard commented Sep 4, 2024

Checks to ensure that the latest monomer block height is never less than the last checked monomer block height.

Rollbacks can be triggered to make the test fail by commenting out this line in stack.go.

Summary by CodeRabbit

  • New Features

    • Added a configuration option for Sequencer Window Size to enhance stack management capabilities.
    • Introduced a new end-to-end test case to ensure the Monomer blockchain maintains stability without rollbacks during execution.
  • Bug Fixes

    • Improved management of the L2 client lifecycle, ensuring more reliable operations.

Copy link
Contributor

coderabbitai bot commented Sep 4, 2024

Walkthrough

The pull request introduces enhancements to the Monomer blockchain's end-to-end testing framework. A new test case, "No Rollbacks," is added to monitor block height and detect any rollbacks during execution. Additionally, modifications to the StackConfig struct and the run method improve the configuration and lifecycle management of the L2 client, ensuring better control over its operations.

Changes

File Change Summary
e2e/stack.go Added SequencerWindowSize uint64 and RollupConfig *rollup.Config to StackConfig. Modified the run method to change L2 client instantiation and include lifecycle management for the L2 client.
e2e/stack_test.go Added new test case "No Rollbacks" with function checkForRollbacks to monitor block height and detect rollbacks.

Possibly related issues

  • Fix rollbacks in e2e tests #169: This change addresses the issue of rollbacks occurring during end-to-end tests, aiming to improve the alignment of sequencing window size and OP batcher parameters.

Possibly related PRs

  • Capture root logger output in e2e tests #194: The changes in e2e/stack_test.go related to logging enhancements are in the same file as the main PR, indicating a potential overlap in testing framework improvements, although they focus on different functionalities.

Poem

🐇 In the land of blocks and chains,
A test was born to ease our pains.
No rollbacks here, just steady heights,
With checks in place, we’ll win the fights!
So hop along, let’s cheer and play,
For stability is here to stay! 🌟

Tip

New features

Walkthrough comment now includes:

  • Possibly related PRs: A list of potentially related PRs to help you recall past context.
  • Suggested labels: CodeRabbit can now suggest labels by learning from your past PRs. You can also provide custom labeling instructions in the UI or configuration file.

Notes:

  • Please share any feedback in the discussion post on our Discord.
  • Possibly related PRs, automatic label suggestions based on past PRs, learnings, and possibly related issues require data opt-in (enabled by default).

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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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.

require.Fail(t, "monomer has rolled back")
}
// End the test once the target monomer block height is reached
if currentBlock.Number().Int64() >= int64(15) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

question for reviewers - With a SWS of 4, L1 block time of 2 ,and L2 block time of 1, the rollbacks will always occur at monomer block 13 so this check is sufficient. However, if any config param ever changes, the target monomer block height may need to be tuned to correctly check for rollbacks. Should I make calculating the target block height more formulaic based on those config params?

Copy link
Collaborator

Choose a reason for hiding this comment

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

We should hit the rollback after a single sequencing window has passed on L1, correct? Therefore, it makes sense to wait one SWS + 1 L1 blocks.

@natebeauregard natebeauregard marked this pull request as draft September 4, 2024 21:31
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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 5cc67ab and d2e6f48.

Files selected for processing (1)
  • e2e/stack_test.go (3 hunks)
Additional comments not posted (3)
e2e/stack_test.go (3)

12-12: LGTM!

The time package import is approved.


60-63: LGTM!

The "No Rollbacks" test case declaration is approved.


125-143: LGTM!

The checkForRollbacks function is approved. It correctly checks for rollbacks by comparing the current block height with the last checked block height and triggers a failure if a rollback is detected. The function also terminates the test once the target block height is reached and introduces a delay between checks to avoid excessive querying.

@natebeauregard natebeauregard marked this pull request as ready for review September 6, 2024 18:20
e2e/stack_test.go Outdated Show resolved Hide resolved
e2e/stack_test.go Outdated Show resolved Hide resolved
@natebeauregard natebeauregard force-pushed the nkb.add-rollback-e2e-test branch from c1da0c5 to dd88c16 Compare September 9, 2024 14:57
@natebeauregard
Copy link
Collaborator Author

force-pushed to rebase on main

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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between d2e6f48 and dd88c16.

Files selected for processing (2)
  • e2e/stack.go (3 hunks)
  • e2e/stack_test.go (3 hunks)
Files skipped from review as they are similar to previous changes (1)
  • e2e/stack_test.go
Additional comments not posted (3)
e2e/stack.go (3)

56-56: Field addition approved: SequencerWindowSize.

The addition of the SequencerWindowSize field to the StackConfig struct is appropriate and well-typed as uint64. This change enhances the configuration capabilities of the stack, aligning with the PR's objectives to manage transaction sequencing more effectively.


254-254: Verify the impact of hardcoded endpoint in L2 client instantiation.

The change to use a hardcoded string "/websocket" as the endpoint in the bftclient.New function call simplifies the connection setup but may reduce flexibility. It's important to verify that this change does not adversely affect the communication protocol or endpoint used in different environments.

Consider making the endpoint configurable to maintain flexibility across different deployment scenarios.


259-264: Proper management of L2 client lifecycle.

The addition of the l2Client.Start() method call and its subsequent error handling, along with the deferred stopping of the Comet client, are crucial for ensuring the L2 client is properly managed throughout its lifecycle. These changes enhance the robustness and reliability of the client management within the run method.

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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between dd88c16 and f456866.

Files selected for processing (1)
  • e2e/stack_test.go (3 hunks)
Files skipped from review as they are similar to previous changes (1)
  • e2e/stack_test.go

e2e/stack_test.go Outdated Show resolved Hide resolved
e2e/stack_test.go Show resolved Hide resolved
e2e/stack_test.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.

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between f456866 and 7c4ab4e.

Files selected for processing (2)
  • e2e/stack.go (4 hunks)
  • e2e/stack_test.go (3 hunks)
Files skipped from review as they are similar to previous changes (1)
  • e2e/stack_test.go
Additional comments not posted (4)
e2e/stack.go (4)

24-24: LGTM!

The import statement for the rollup package is valid and follows the correct syntax.


55-55: LGTM!

The new field RollupConfig of type *rollup.Config has been correctly added to the StackConfig struct. This field enhances the configuration capabilities of the stack by allowing it to specify rollup-related settings.


255-255: Verify the change to the L2 client connection.

The second argument of the bftclient.New function call has been changed from s.monomerCometURL.String() to a hardcoded string "/websocket". This change may indicate a shift in how the L2 client connects to the Comet service, potentially affecting the communication protocol or endpoint used.

Please ensure that this change is intentional and does not introduce any issues with the L2 client connection. Provide additional context or documentation if necessary.


260-265: LGTM!

The code block for starting and stopping the L2 client is well-implemented and follows best practices:

  • The L2 client is actively started using l2Client.Start(), ensuring it is properly initialized within the lifecycle of the run method.
  • Error handling is performed for the l2Client.Start() operation, adhering to proper error management.
  • The deferred stopping of the client using env.DeferErr ensures proper cleanup and resource management.

The code block enhances the control flow and improves the overall reliability of the L2 client management.

@natebeauregard natebeauregard merged commit 2417000 into main Sep 9, 2024
15 checks passed
@natebeauregard natebeauregard deleted the nkb.add-rollback-e2e-test branch September 9, 2024 19:54
This was referenced Sep 16, 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.

2 participants