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

fix: add pubkey to tss vote #2844

Merged
merged 11 commits into from
Sep 16, 2024
Merged

Conversation

kingpinXD
Copy link
Contributor

@kingpinXD kingpinXD commented Sep 6, 2024

Description

This pr adds the TSS pub key to the vote for TSS keygen

How Has This Been Tested?

  • Tested CCTX in localnet
  • Tested in development environment
  • Go unit tests
  • Go integration tests
  • Tested via GitHub Actions

Summary by CodeRabbit

  • New Features

    • Enhanced TSS keygen voting mechanism with improved indexing for public keys.
    • Added new test cases to ensure TSS voting logic handles multiple public keys correctly.
  • Bug Fixes

    • Updated the digest output format to include TSS public key for better context in voting processes.
  • Documentation

    • Updated changelog to reflect the new features and improvements in TSS voting functionality.

Copy link
Contributor

coderabbitai bot commented Sep 6, 2024

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

Walkthrough

The changes introduce a new feature for TSS (Threshold Signature Scheme) keygen voting in version 19.0.0, specifically indexing the tsspubkey for enhanced voting functionality. Modifications were made to the voting logic in tests, including the introduction of a sample TSS object and refined handling of votes with different public keys. The Digest method of the MsgVoteTSS struct was updated to include the TssPubkey, altering its output format for improved context.

Changes

Files Change Summary
x/observer/keeper/msg_server_vote_tss_test.go, x/observer/types/message_vote_tss.go, x/observer/types/message_vote_tss_test.go Introduced a new feature for TSS keygen voting, including logic enhancements in tests for handling votes with different public keys and modifications to the Digest method to include TssPubkey in its output.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant TSS_Voting_System
    participant TSS_Public_Key

    User->>TSS_Voting_System: Cast Vote
    TSS_Voting_System->>TSS_Public_Key: Retrieve TSS Public Key
    TSS_Voting_System-->>User: Confirm Vote
    User->>TSS_Voting_System: Cast Another Vote with Different Key
    TSS_Voting_System-->>User: Voting Failed (Different TSS Public Key)
Loading

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 generate interesting stats about this repository and render them as a table.
    -- @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.

@kingpinXD kingpinXD changed the title refactor: add pubkey to tss vote fix: add pubkey to tss vote Sep 6, 2024
@kingpinXD kingpinXD added the TSS_MIGRATION_TESTS Run TSS migration tests label Sep 6, 2024
Copy link

codecov bot commented Sep 6, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 66.84%. Comparing base (aa81140) to head (c06e7e0).
Report is 1 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff            @@
##           develop    #2844   +/-   ##
========================================
  Coverage    66.84%   66.84%           
========================================
  Files          378      378           
  Lines        21098    21098           
========================================
  Hits         14103    14103           
  Misses        6330     6330           
  Partials       665      665           
Files with missing lines Coverage Δ
x/observer/types/message_vote_tss.go 100.00% <100.00%> (ø)

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.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between ba3b1c0 and 0a6846b.

Files selected for processing (4)
  • changelog.md (1 hunks)
  • x/observer/keeper/msg_server_vote_tss_test.go (6 hunks)
  • x/observer/types/message_vote_tss.go (1 hunks)
  • x/observer/types/message_vote_tss_test.go (1 hunks)
Additional context used
Path-based instructions (3)
x/observer/types/message_vote_tss.go (1)

Pattern **/*.go: Review the Go code, point out issues relative to principles of clean code, expressiveness, and performance.

x/observer/types/message_vote_tss_test.go (1)

Pattern **/*.go: Review the Go code, point out issues relative to principles of clean code, expressiveness, and performance.

x/observer/keeper/msg_server_vote_tss_test.go (1)

Pattern **/*.go: Review the Go code, point out issues relative to principles of clean code, expressiveness, and performance.

Additional comments not posted (4)
x/observer/types/message_vote_tss.go (1)

63-63: Approve the change in the Digest method but verify downstream impact.

The inclusion of TssPubkey in the digest output enhances the context provided by this method, which is beneficial for tracking and validation purposes. However, it is crucial to verify that all systems consuming this digest are updated to handle the new format correctly to prevent any issues with data parsing or validation.

Run the following script to verify the impact on systems using the digest:

x/observer/types/message_vote_tss_test.go (1)

105-105: Approve the updated test for the Digest method.

The test has been correctly updated to expect the new digest format "1-pubkey-tss-keygen", aligning with the changes in the Digest method. Ensure that this test is executed and passes consistently to confirm the correctness of the updated method.

Run the following script to verify the test results:

Verification successful

The test for the Digest method is correctly implemented and consistent with the updated logic.

The Digest method in MsgVoteTSS constructs the expected string format, and the test accurately verifies this behavior. Both the implementation and the test logic are aligned, confirming the correctness of the changes.

  • Implementation Location: x/observer/types/message_vote_tss.go
  • Test Location: x/observer/types/message_vote_tss_test.go
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that the updated test for the `Digest` method passes consistently.

# Test: Execute the test for the `Digest` method. Expect: Test passes consistently.
go test -run TestMsgVoteTSS_Digest

Length of output: 106


Script:

#!/bin/bash
# Search for the implementation of the `Digest` method to verify its logic.
ast-grep --lang go --pattern 'func (msg $_) Digest() string {
  $$$
}'

# Search for the test logic of `TestMsgVoteTSS_Digest` to ensure it aligns with the expected behavior.
rg 'func TestMsgVoteTSS_Digest' -A 20

Length of output: 2697

x/observer/keeper/msg_server_vote_tss_test.go (1)

69-81: Approve the updated tests for the MsgServer_VoteTSS function.

The tests have been appropriately updated to handle scenarios where votes are cast with different public keys, using a consistent sample TSS object. This enhances the clarity and robustness of the tests. Ensure that these tests are executed and pass consistently to confirm the correctness of the updated voting logic.

Run the following script to verify the test results:

Also applies to: 271-287, 419-423, 552-561, 720-786

Verification successful

Comprehensive Test Coverage for MsgServer_VoteTSS Function

The TestMsgServer_VoteTSS function is well-implemented and covers a wide range of scenarios, ensuring robust testing of the voting logic. The tests include various edge cases and use assertions to validate expected outcomes, providing confidence in the correctness of the implementation.

  • The test function is located in x/observer/keeper/msg_server_vote_tss_test.go.
  • Scenarios include handling of node accounts, keygen statuses, ballot creation and finalization, and public key differences.

These tests align with the review comment's approval and enhance the robustness of the codebase.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that the updated tests for the `MsgServer_VoteTSS` function pass consistently.

# Test: Execute the tests for the `MsgServer_VoteTSS` function. Expect: Tests pass consistently.
go test -run TestMsgServer_VoteTSS

Length of output: 106


Script:

#!/bin/bash
# Search for the implementation of the `TestMsgServer_VoteTSS` function in the codebase.
ast-grep --lang go --pattern 'func TestMsgServer_VoteTSS($_) { $$$ }'

Length of output: 62791

changelog.md (1)

41-41: Changelog Entry for TSS Keygen Voting Approved

The addition of the tsspubkey to the index for TSS keygen voting is correctly documented. This change is crucial for enhancing the security and functionality of the TSS voting mechanism, aligning with the project's goals to improve protocol reliability and security.

@kingpinXD kingpinXD enabled auto-merge September 9, 2024 15:18
Copy link
Member

@lumtis lumtis left a comment

Choose a reason for hiding this comment

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

Small comment

x/observer/types/message_vote_tss_test.go Outdated Show resolved Hide resolved
@kingpinXD kingpinXD requested a review from lumtis September 10, 2024 19:18
@kingpinXD kingpinXD added this pull request to the merge queue Sep 16, 2024
Merged via the queue into develop with commit 2c87c5c Sep 16, 2024
31 checks passed
@kingpinXD kingpinXD deleted the fix-tss-key-voting-hash-collision branch September 16, 2024 10:43
@coderabbitai coderabbitai bot mentioned this pull request Nov 21, 2024
10 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
TSS_MIGRATION_TESTS Run TSS migration tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants