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

refactor: migrator length check to use consensus type #2556

Merged
merged 15 commits into from
Jul 26, 2024

Conversation

kingpinXD
Copy link
Contributor

@kingpinXD kingpinXD commented Jul 25, 2024

Description

Closes #2555

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

    • Introduced methods to retrieve supported foreign chains based on specific consensus types, enhancing the chain management functionality.
    • Added a functionality to get a list of chains that support migration, improving migration-related processes.
  • Bug Fixes

    • Refined test logic to ensure accurate behavior when retrieving chains relevant to migration.
  • Tests

    • Expanded test coverage for the Keeper functionality regarding foreign chains and migration, ensuring robust performance across consensus types.

Copy link
Contributor

coderabbitai bot commented Jul 25, 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 recent changes enhance the functionality of the migrator by refactoring the checks to be based on consensus types instead of merely counting supported chains. This introduces new methods to streamline the retrieval of chains supporting migration for specific consensus mechanisms, improving the clarity and modularity of the code. Additionally, test coverage has been expanded to validate the new functionalities, ensuring the system behaves correctly across different scenarios.

Changes

Files Change Summary
changelog.md Added entry documenting the refactor of the migrator length check to utilize a consensus type for improved functionality.
testutil/keeper/mocks/crosschain/observer.go Introduced GetSupportedForeignChainsByConsensus method for consensus-specific chain retrieval in mock framework.
x/crosschain/keeper/msg_server_update_tss.go Added GetChainsSupportingMigration function for retrieving chains based on consensus types, enhancing modularity.
x/crosschain/keeper/msg_server_update_tss_test.go Updated tests to use GetChainsSupportingMigration and added TestKeeper_GetChainsSupportingMigration for improved test coverage of migration logic.
x/crosschain/types/expected_keepers.go Added GetSupportedForeignChainsByConsensus method to the ObserverKeeper interface for more specific chain management.
x/observer/keeper/chain_params.go Introduced GetSupportedForeignChainsByConsensus function for retrieving chains filtered by consensus type.
x/observer/keeper/chain_params_test.go Added tests for GetSupportedForeignChainsByConsensus, improving coverage for various consensus mechanisms.

Assessment against linked issues

Objective Addressed Explanation
Refactor migrator check to use consensus types (Issue #2555)
Ensure retrieval logic for chains supports migration (Issue #2555)
Validate behavior of retrieval functions through testing (Issue #2555)
Maintain clarity and modularity in chain management (Issue #2555)

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

@kingpinXD kingpinXD changed the title feat: remove solana for required migration list refactor: migrator length check to use consensus type Jul 25, 2024
@kingpinXD kingpinXD marked this pull request as ready for review July 25, 2024 18:16
@kingpinXD kingpinXD added the TSS_MIGRATION_TESTS Run TSS migration tests label Jul 25, 2024
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 43a2468 and 56cb61d.

Files selected for processing (7)
  • changelog.md (1 hunks)
  • testutil/keeper/mocks/crosschain/observer.go (1 hunks)
  • x/crosschain/keeper/msg_server_update_tss.go (3 hunks)
  • x/crosschain/keeper/msg_server_update_tss_test.go (13 hunks)
  • x/crosschain/types/expected_keepers.go (1 hunks)
  • x/observer/keeper/chain_params.go (1 hunks)
  • x/observer/keeper/chain_params_test.go (1 hunks)
Additional context used
Path-based instructions (6)
x/observer/keeper/chain_params.go (1)

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

x/crosschain/keeper/msg_server_update_tss.go (1)

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

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

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

x/crosschain/types/expected_keepers.go (1)

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

x/crosschain/keeper/msg_server_update_tss_test.go (1)

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

testutil/keeper/mocks/crosschain/observer.go (1)

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

Additional comments not posted (21)
x/observer/keeper/chain_params.go (1)

79-90: LGTM!

The function GetSupportedForeignChainsByConsensus is well-structured and follows best practices. It correctly filters supported chains by the specified consensus type, excluding Zeta chains.

x/crosschain/keeper/msg_server_update_tss.go (2)

Line range hint 9-75:
LGTM!

The modifications to the UpdateTssAddress function enhance clarity and modularity by using the new GetChainsSupportingMigration function. The overall structure and logic remain intact and well-organized.


76-80: LGTM!

The function GetChainsSupportingMigration is well-structured and correctly consolidates the logic for fetching supported foreign chains based on Ethereum and Bitcoin consensus types.

x/observer/keeper/chain_params_test.go (3)

114-174: Comprehensive test coverage for GetSupportedForeignChainsByConsensus.

The test case TestKeeper_GetSupportedForeignChainsByConsensus is thorough and covers multiple scenarios, ensuring the correctness of the function across different consensus mechanisms.


176-199: Well-structured test coverage for GetSupportedForeignChains.

The test case TestKeeper_GetSupportedForeignChains is well-structured and ensures the correctness of the function, covering various scenarios.


201-215: Helper functions improve test clarity and maintainability.

The helper functions getAllForeignChains and getForeignChains are well-structured and enhance the readability and maintainability of the test cases.

x/crosschain/types/expected_keepers.go (1)

107-107: Addition of new method to ObserverKeeper interface.

The new method GetSupportedForeignChainsByConsensus has been added to the ObserverKeeper interface. This method enhances the interface by allowing retrieval of supported foreign chains based on a specified consensus type. Ensure that the implementation of this method in the corresponding struct adheres to the expected functionality and that appropriate unit tests are in place to validate its behavior.

x/crosschain/keeper/msg_server_update_tss_test.go (12)

7-7: Import of chains package.

The import of the chains package is necessary for the new functionality related to chain management. Ensure that all required dependencies are correctly imported and utilized.


69-69: Replacement of GetSupportedChains with GetChainsSupportingMigration.

The method GetSupportedChains has been replaced with GetChainsSupportingMigration to refine the logic to specifically target chains that support migration. This change ensures that the test aligns with the updated migration logic.


82-82: Equality check for the number of migrators and chains supporting migration.

The equality check ensures that the number of TSS fund migrators matches the number of chains supporting migration. This validation is crucial for the integrity of the migration process.


113-113: Replacement of GetSupportedChains with GetChainsSupportingMigration.

The method GetSupportedChains has been replaced with GetChainsSupportingMigration to refine the logic to specifically target chains that support migration. This change ensures that the test aligns with the updated migration logic.


126-126: Equality check for the number of migrators and chains supporting migration.

The equality check ensures that the number of TSS fund migrators matches the number of chains supporting migration. This validation is crucial for the integrity of the migration process.


143-143: Equality check for the number of migrators and chains supporting migration.

The equality check ensures that the number of TSS fund migrators matches the number of chains supporting migration. This validation is crucial for the integrity of the migration process.


160-160: Replacement of GetSupportedChains with GetChainsSupportingMigration.

The method GetSupportedChains has been replaced with GetChainsSupportingMigration to refine the logic to specifically target chains that support migration. This change ensures that the test aligns with the updated migration logic.


173-173: Equality check for the number of migrators and chains supporting migration.

The equality check ensures that the number of TSS fund migrators matches the number of chains supporting migration. This validation is crucial for the integrity of the migration process.


211-211: Replacement of GetSupportedChains with GetChainsSupportingMigration.

The method GetSupportedChains has been replaced with GetChainsSupportingMigration to refine the logic to specifically target chains that support migration. This change ensures that the test aligns with the updated migration logic.


258-258: Replacement of GetSupportedChains with GetChainsSupportingMigration.

The method GetSupportedChains has been replaced with GetChainsSupportingMigration to refine the logic to specifically target chains that support migration. This change ensures that the test aligns with the updated migration logic.


305-305: Replacement of GetSupportedChains with GetChainsSupportingMigration.

The method GetSupportedChains has been replaced with GetChainsSupportingMigration to refine the logic to specifically target chains that support migration. This change ensures that the test aligns with the updated migration logic.


334-352: Addition of TestKeeper_GetChainsSupportingMigration test function.

The new test function TestKeeper_GetChainsSupportingMigration validates the behavior of the GetChainsSupportingMigration method. It ensures that only Ethereum and Bitcoin chains are returned, excluding other consensus types. This test enhances the coverage and robustness of the migration-related functionality.

testutil/keeper/mocks/crosschain/observer.go (1)

627-645: Addition of GetSupportedForeignChainsByConsensus method to CrosschainObserverKeeper mock.

The new method GetSupportedForeignChainsByConsensus has been added to the CrosschainObserverKeeper mock. This method enhances the mock functionality by allowing testing of consensus-specific foreign chain retrieval. Ensure that this method is correctly utilized in the test cases to validate its behavior.

changelog.md (1)

68-68: Changelog Entry Approved

The new entry documenting the refactor of the migrator length check to use consensus type is clear and concise.

x/crosschain/keeper/msg_server_update_tss.go Outdated Show resolved Hide resolved
x/crosschain/keeper/msg_server_update_tss.go Outdated Show resolved Hide resolved
x/crosschain/keeper/msg_server_update_tss.go Outdated Show resolved Hide resolved
x/crosschain/keeper/msg_server_update_tss.go Outdated Show resolved Hide resolved
@kingpinXD kingpinXD requested a review from lumtis July 26, 2024 16:23
Copy link

codecov bot commented Jul 26, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 46.72%. Comparing base (545896d) to head (72f617f).

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #2556      +/-   ##
===========================================
+ Coverage    46.63%   46.72%   +0.09%     
===========================================
  Files          464      465       +1     
  Lines        30843    30882      +39     
===========================================
+ Hits         14383    14429      +46     
+ Misses       15604    15597       -7     
  Partials       856      856              
Files Coverage Δ
pkg/chains/chain_filters.go 100.00% <100.00%> (ø)
pkg/chains/chains.go 93.61% <100.00%> (+0.43%) ⬆️
x/crosschain/keeper/grpc_query_cctx_rate_limit.go 95.59% <100.00%> (+0.05%) ⬆️
x/crosschain/keeper/msg_server_update_tss.go 100.00% <100.00%> (ø)
x/observer/keeper/chain_params.go 100.00% <ø> (+14.58%) ⬆️

Copy link
Contributor

@swift1337 swift1337 left a comment

Choose a reason for hiding this comment

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

Approved. Left some non-blocking comments.

@kingpinXD kingpinXD enabled auto-merge July 26, 2024 17:46
@kingpinXD kingpinXD disabled auto-merge July 26, 2024 18:04
@kingpinXD kingpinXD enabled auto-merge July 26, 2024 18:09
@kingpinXD kingpinXD added this pull request to the merge queue Jul 26, 2024
Merged via the queue into develop with commit 680cf6a Jul 26, 2024
28 checks passed
@kingpinXD kingpinXD deleted the remove-solana-migration branch July 26, 2024 19:13
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.

zetacored : tss migration migrators check using consensus type
5 participants