Skip to content

Conversation

@tuxcanfly
Copy link
Contributor

@tuxcanfly tuxcanfly commented Jul 27, 2024

Overview

Update height only after block responses are saved.

Partially fixes evstack/ev-abci#21

Summary by CodeRabbit

  • New Features

    • Enhanced testing capabilities for the block publishing process, including validation for successful executions and error handling.
  • Bug Fixes

    • Improved state management logic during block publication to enhance consistency and error handling.
  • Tests

    • Added new test cases to ensure the correct behavior of the block publishing method under various scenarios.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 27, 2024

Walkthrough

The recent changes enhance the publishBlock method in the Manager class within block/manager.go, refining the execution order to bolster state consistency. Additionally, the testing capabilities in block/manager_test.go have been significantly improved with new functions and comprehensive tests, ensuring thorough validation of both successful and erroneous block publishing scenarios. These modifications align with the objective of achieving atomic storage operations.

Changes

Files Change Summary
block/manager.go Repositioned m.store.SetHeight(ctx, blockHeight) for improved execution order during block processing.
block/manager_test.go Added TestManager_publishBlock function to enhance validation of the publishBlock method across various scenarios with mocked components.

Assessment against linked issues

Objective Addressed Explanation
Block processing should use storage atomically (#477) It's unclear if the changes fully ensure atomicity across all operations as stated.

🐇 In the meadow, blocks do hop,
With heights that climb and never stop.
Through tests so bright, our code we cheer,
Atomic dreams now drawing near!
Let's celebrate this change today,
For a happy path, hip-hip-hooray! 🎉


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 as 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.

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

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.

@tuxcanfly tuxcanfly force-pushed the tux/fix-block-height branch 2 times, most recently from 0a8ef11 to 58dc593 Compare August 8, 2024 13:54
@tuxcanfly tuxcanfly force-pushed the tux/fix-block-height branch from 58dc593 to 0341c26 Compare August 9, 2024 02:32
@tuxcanfly tuxcanfly marked this pull request as ready for review August 9, 2024 02:33
@RollkitBot RollkitBot requested a review from a team August 9, 2024 02:33
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 92a7df1 and 0341c26.

Files selected for processing (2)
  • block/manager.go (2 hunks)
  • block/manager_test.go (3 hunks)
Additional comments not posted (3)
block/manager_test.go (2)

44-48: LGTM!

The prepareProposalResponse function correctly constructs a response with the transactions from the request.


568-719: Comprehensive test coverage for publishBlock.

The TestManager_publishBlock function effectively tests the publishBlock method under various scenarios, including successful execution and error handling. The use of mocks for dependencies and assertions for expected outcomes is well-implemented.

block/manager.go (1)

944-946: Improved atomicity in block processing.

The repositioning of m.store.SetHeight(ctx, blockHeight) ensures that the store height is updated only after block responses are saved, enhancing atomicity and reducing potential inconsistencies in the database.

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 0341c26 and 82446d4.

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

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 82446d4 and b7bce1b.

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

6-11: Imports look good.

The added imports are necessary for the new functionalities and tests.

Also applies to: 15-27, 36-37


44-48: Helper function prepareProposalResponse is well-implemented.

This function correctly returns a mock response for proposal preparation.


568-709: Comprehensive test for publishBlock method.

The test function effectively verifies the behavior of publishBlock in both successful and error scenarios. It ensures the block height is updated correctly and handles errors as expected.

gupadhyaya
gupadhyaya previously approved these changes Aug 9, 2024
tzdybal
tzdybal previously approved these changes Aug 9, 2024
Copy link
Member

@tzdybal tzdybal left a comment

Choose a reason for hiding this comment

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

I left some nit-picking comments about error strings - IMHO they can as well be handled as followup good first issue.

@tuxcanfly tuxcanfly dismissed stale reviews from tzdybal and gupadhyaya via 3cc3769 August 9, 2024 15:12
@tuxcanfly
Copy link
Contributor Author

There are quite a few err strings around the same place e.g.: failed to save block, failed to Commit. So refactoring might be better suited for a follow up PR.

@codecov
Copy link

codecov bot commented Aug 9, 2024

Codecov Report

Attention: Patch coverage is 0% with 1 line in your changes missing coverage. Please review.

Project coverage is 43.84%. Comparing base (5f1c0ad) to head (b60bb62).
Report is 1 commits behind head on main.

Files Patch % Lines
block/manager.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    rollkit/rollkit#1782      +/-   ##
==========================================
+ Coverage   43.27%   43.84%   +0.56%     
==========================================
  Files          76       76              
  Lines       10033    10033              
==========================================
+ Hits         4342     4399      +57     
+ Misses       4975     4900      -75     
- Partials      716      734      +18     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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 b7bce1b and 6c40f73.

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

gupadhyaya
gupadhyaya previously approved these changes Aug 13, 2024
Copy link
Contributor

@MSevey MSevey left a comment

Choose a reason for hiding this comment

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

Comment should be updated to prevent confusion.

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 6c40f73 and b60bb62.

Files selected for processing (2)
  • block/manager.go (2 hunks)
  • block/manager_test.go (3 hunks)
Files skipped from review as they are similar to previous changes (2)
  • block/manager.go
  • block/manager_test.go

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.

Block processing should use storage atomically

6 participants