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

feat: add vote extension support #1641

Merged
merged 16 commits into from
May 7, 2024
Merged

feat: add vote extension support #1641

merged 16 commits into from
May 7, 2024

Conversation

tzdybal
Copy link
Member

@tzdybal tzdybal commented Apr 24, 2024

Overview

Resolves #1593

Summary by CodeRabbit

  • New Features

    • Enhanced voting extension capabilities in the blockchain management system, including saving and retrieving extended commit information.
    • Added a new test function to verify the functionality of extended commits in the blockchain store.
    • Introduced a new field in the state initialization to enable vote extensions at a specified block height.
  • Enhancements

    • Updated the block creation process to include extended commit information, improving the integration with voting extensions.
    • Streamlined the SetHeight method in the store for better performance and simplicity.
  • Bug Fixes

    • Adjusted test cases to accommodate new parameters related to extended commit information, ensuring consistency and reliability in block creation tests.
  • Documentation

    • Updated code comments and versioning information to reflect new functionalities and changes in mock functions.

@tzdybal tzdybal self-assigned this Apr 24, 2024
Copy link
Contributor

coderabbitai bot commented Apr 24, 2024

Walkthrough

The recent updates focus on integrating vote extensions within the blockchain management system. These changes include the addition of new methods and functionalities across various components to handle extended commit information and support ABCI methods related to vote extensions. This comprehensive update ensures the system's compatibility with new voting protocols, enhancing its efficiency and security in processing votes.

Changes

File Path Change Summary
block/manager.go Updated publishBlock to handle vote extensions, added new methods and imports.
node/.../full_node_test.go Added TestVoteExtension and related helper functions for testing.
state/executor.go Modified CreateBlock to use lastExtendedCommit, added ExtendVote method.
state/.../executor_test.go Updated CreateBlock function calls in tests to include new parameter.
store/... Enhanced to manage extended commit information, added new test functions.
types/state.go Added new field for vote extensions enablement in state initialization.

Assessment against linked issues

Objective Addressed Explanation
Add support for vote extensions (#1593)
Implement ABCI methods ExtendVote and VerifyVoteExtension (#1593) Methods appear to be planned but not yet fully implemented.

Poem

"In the code where logic intertwines, 🌿
A rabbit hopped through lines of signs. 🐇
With every hop, a block extends,
Vote extensions weave, the chain amends.
Cheers to the devs, with carrots blend!" 🥕🎉

Enjoy the celebration of these integral changes to our system, as narrated by our very own CodeRabbit!


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.

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

@tzdybal tzdybal force-pushed the tzdybal/voteext branch 4 times, most recently from dff81d9 to 71626f1 Compare April 24, 2024 13:56
@tzdybal tzdybal marked this pull request as ready for review April 25, 2024 13:50
@tzdybal tzdybal requested a review from gupadhyaya April 25, 2024 13:52
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

Out of diff range and nitpick comments (1)
node/full_node_test.go (1)

266-322: The implementation of TestVoteExtension looks solid and correctly tests the vote extension functionality. However, consider using a context with a longer timeout or a context without a timeout for integration tests to avoid flakiness due to time constraints.

block/manager.go Outdated Show resolved Hide resolved
block/manager.go Outdated Show resolved Hide resolved
node/full_node_test.go Outdated Show resolved Hide resolved
node/full_node_test.go Outdated Show resolved Hide resolved
store/store.go Outdated Show resolved Hide resolved
state/executor.go Outdated 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: 1

Out of diff range and nitpick comments (1)
block/manager.go (1)

Line range hint 816-986: Refactor the handling of extended commits for clarity and error handling.

The logic for handling extended commits within the publishBlock method and related functions is complex and could benefit from refactoring for better clarity and error handling. Consider breaking down the operations into smaller, more manageable functions, especially the error handling and conditional checks around the vote extension feature.

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

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 4a1ee21 and f26d903.
Files selected for processing (9)
  • block/manager.go (5 hunks)
  • node/full_node_test.go (3 hunks)
  • state/executor.go (3 hunks)
  • state/executor_test.go (6 hunks)
  • store/store.go (3 hunks)
  • store/store_test.go (1 hunks)
  • store/types.go (1 hunks)
  • test/mocks/Store.go (3 hunks)
  • types/state.go (1 hunks)
Files skipped from review as they are similar to previous changes (7)
  • state/executor.go
  • state/executor_test.go
  • store/store.go
  • store/store_test.go
  • store/types.go
  • test/mocks/Store.go
  • types/state.go
Additional comments not posted (1)
node/full_node_test.go (1)

363-401: Consider refactoring createAggregatorWithApp to reduce duplication.

As previously discussed in comments by MSevey, gupadhyaya, and tzdybal, there is a significant overlap with createAggregatorWithPersistence and potential for refactoring to reduce duplication. A follow-up issue has already been created (#1648). It's important to ensure this refactoring task is prioritized to maintain code cleanliness and prevent technical debt from accumulating.

block/manager.go Show resolved Hide resolved
node/full_node_test.go Show resolved Hide resolved
tzdybal added 16 commits May 7, 2024 10:28
Implemented the ability to get and save extended commit information. This allows new blocks to be created with extended vote information if the feature is enabled.
Manager creates initial state from genesis in constructor,
so VoteExtensionEnableHeight has to be set early.
The commit updates the expected vote extension in full_node_test.go. Previously, it was a hardcoded string, now it's a dynamic string based on the block height.
A new functionality to sign vote extensions has been introduced in the block manager. This allows to attach a signature to a vote extension and ensures its verification in the full node tests.
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: 2

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between dff7980 and e3accb5.
Files selected for processing (9)
  • block/manager.go (5 hunks)
  • node/full_node_test.go (3 hunks)
  • state/executor.go (3 hunks)
  • state/executor_test.go (6 hunks)
  • store/store.go (3 hunks)
  • store/store_test.go (1 hunks)
  • store/types.go (1 hunks)
  • test/mocks/Store.go (3 hunks)
  • types/state.go (1 hunks)
Files skipped from review as they are similar to previous changes (7)
  • state/executor.go
  • state/executor_test.go
  • store/store.go
  • store/store_test.go
  • store/types.go
  • test/mocks/Store.go
  • types/state.go
Additional Context Used
Learnings (1)
node/full_node_test.go (1)
User: tzdybal
PR: rollkit/rollkit#1641
File: node/full_node_test.go:266-321
Timestamp: 2024-05-07T07:23:53.788Z
Learning: Issue #1663 was created to address adding comprehensive tests for error scenarios in `TestVoteExtension` in the rollkit repository.
Additional comments not posted (2)
node/full_node_test.go (2)

266-321: The implementation of TestVoteExtension effectively tests the happy path for the vote extension feature. The mock setups and assertions are well-constructed to ensure the correct behavior is validated.


363-401: The function createAggregatorWithApp is correctly implemented to set up a node with specific configurations for testing. The use of helper methods and comprehensive error checks enhances the robustness of the test setup.

block/manager.go Show resolved Hide resolved
block/manager.go Show resolved Hide resolved
@tzdybal tzdybal added this pull request to the merge queue May 7, 2024
Merged via the queue into main with commit 0f9369c May 7, 2024
23 checks passed
@tzdybal tzdybal deleted the tzdybal/voteext branch May 7, 2024 19:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Add support for vote extensions
3 participants