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: mark deprecated APIs #721

Merged
merged 1 commit into from
Oct 10, 2024
Merged

refactor: mark deprecated APIs #721

merged 1 commit into from
Oct 10, 2024

Conversation

zakir-code
Copy link
Contributor

@zakir-code zakir-code commented Oct 9, 2024

Summary by CodeRabbit

  • New Features

    • Introduced new message definitions for bridge fee management.
  • Deprecations

    • Multiple functions and events related to cross-chain transactions have been marked as deprecated.
    • Existing messages and methods have been updated to reflect a transition in the protocol's design.
  • Bug Fixes

    • Updated binary representations in tests to align with the latest contract changes.

Copy link

coderabbitai bot commented Oct 9, 2024

Walkthrough

The pull request introduces significant modifications across multiple files, primarily focusing on the ICrossChain.go contract. Key changes include the removal of specific functions and events related to AddPendingPoolRewards and CancelPendingBridgeCall, along with updates to the ABI definitions. Additionally, several messages in the legacy.proto and tx.proto files are marked as deprecated, indicating a shift in protocol design. The ICrossChain interface also reflects these changes, with deprecated functions and events added, while the CrossChainTest.go file updates the binary representation to align with the new contract structure.

Changes

File Path Change Summary
contract/ICrossChain.go Removed functions and events related to AddPendingPoolRewards and CancelPendingBridgeCall. Updated ABI string.
proto/fx/gravity/crosschain/v1/legacy.proto Added new messages like MsgIncreaseBridgeFee, marked several existing messages as deprecated.
proto/fx/gravity/crosschain/v1/tx.proto Marked several RPC methods as deprecated, removed response messages for deprecated methods.
solidity/contracts/bridge/ICrossChain.sol Added deprecated functions/events; removed cancelPendingBridgeCall and addPendingPoolRewards.
tests/contract/CrossChainTest.go Updated binary representation and marked certain variables as deprecated.
x/crosschain/precompile/cancel_send_to_external.go Marked CancelSendToExternalMethod and its constructor as deprecated.
x/crosschain/precompile/crosschain.go Marked CrossChainMethod and its constructor as deprecated.
x/crosschain/precompile/increase_bridge_fee.go Marked IncreaseBridgeFeeMethod and its constructor as deprecated.

Possibly related PRs

🐰 In the meadow where we play,
Changes hop in bright array.
Functions gone, events anew,
Refactoring brings a clearer view.
With each leap, we redefine,
A brighter path in code we find! 🌼


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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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.

Copy link

@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

🧹 Outside diff range and nitpick comments (13)
solidity/contracts/bridge/ICrossChain.sol (6)

Line range hint 10-18: Approved with a minor suggestion.

The deprecated crossChain function is correctly marked and provides a clear alternative. The function signature is appropriate for cross-chain operations.

Consider adding a @deprecated tag in the NatSpec format for better documentation:

/// @deprecated Use `IBridgeCall.bridgeCall` instead

This will improve IDE support and make the deprecation more visible in generated documentation.


20-24: Approved with the same minor suggestion.

The deprecated cancelSendToExternal function is correctly marked and provides a clear alternative. The function signature is appropriate for cancelling an external send operation.

As with the previous function, consider adding a @deprecated tag in the NatSpec format:

/// @deprecated Use `IBridgeCall.bridgeCall` instead

This will maintain consistency across all deprecated functions.


26-32: Approved with the same minor suggestion.

The deprecated increaseBridgeFee function is correctly marked and provides a clear alternative. The function signature is appropriate for increasing a bridge fee, and being payable allows it to handle fee increases.

As with the previous functions, consider adding a @deprecated tag in the NatSpec format:

/// @deprecated Use `IBridgeCall.bridgeCall` instead

This will maintain consistency across all deprecated functions and improve documentation.


Line range hint 54-64: Approved with a minor suggestion for consistency.

The deprecated CrossChain event is correctly marked. The event parameters cover all necessary information for a cross-chain operation, and the use of indexed parameters will help with efficient event filtering.

For consistency with the deprecated functions, consider adding a comment to indicate the replacement:

// Deprecated: use `BridgeCallEvent` instead

This will provide clear guidance on which event to use instead.


Line range hint 66-80: Approved with the same minor suggestion for consistency.

The deprecated CancelSendToExternal and IncreaseBridgeFee events are correctly marked. The event parameters are appropriate for their respective operations, and the use of indexed parameters will help with efficient event filtering.

For consistency with the previous suggestion and the deprecated functions, consider adding comments to indicate the replacement for both events:

// Deprecated: use `BridgeCallEvent` instead

This will provide clear guidance on which event to use instead and maintain consistency across all deprecated elements in the interface.


Deprecated functions are still in use within test files and need to be updated.

  • File: solidity/contracts/test/CrossChainTest.sol
    • Functions crossChain, cancelSendToExternal, and increaseBridgeFee are still being called. Please update these to use IBridgeCall.bridgeCall.

No usages of deprecated events were found in external JavaScript/TypeScript files.

🔗 Analysis chain

Line range hint 1-105: Summary: Approved changes with suggestions for improved documentation and impact analysis.

The changes to the ICrossChain interface, including the addition of deprecated functions and events, are consistent and well-implemented. The deprecation notices provide clear alternatives, which should help in the transition to the new IBridgeCall interface.

To ensure a smooth transition and maintain backwards compatibility:

  1. Verify that all contracts implementing ICrossChain are updated to use the new IBridgeCall.bridgeCall function instead of the deprecated methods.
  2. Check for any external contracts or scripts that might be listening to the deprecated events and update them to use BridgeCallEvent instead.
  3. Consider adding a migration guide or documentation to help users transition from the old interface to the new one.

Run the following script to identify potential areas that need updating:

This script will help identify areas of the codebase that may need updating due to the deprecations.


To address the issues found with the previous script, please run the updated script below to identify usages of deprecated functions and events:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Find usages of deprecated functions and events in the codebase

echo "Searching for usages of deprecated functions:"
rg --type solidity -i "crossChain\s*\(" -g '!ICrossChain.sol'
rg --type solidity -i "cancelSendToExternal\s*\(" -g '!ICrossChain.sol'
rg --type solidity -i "increaseBridgeFee\s*\(" -g '!ICrossChain.sol'

echo "Searching for usages of deprecated events:"
rg --type solidity -i "emit\s+CrossChain\s*\(" -g '!ICrossChain.sol'
rg --type solidity -i "emit\s+CancelSendToExternal\s*\(" -g '!ICrossChain.sol'
rg --type solidity -i "emit\s+IncreaseBridgeFee\s*\(" -g '!ICrossChain.sol'

echo "Searching for potential event listeners:"
rg --type javascript --type typescript -i "CrossChain|CancelSendToExternal|IncreaseBridgeFee"

Length of output: 1054


Script:

#!/bin/bash
# Description: Find usages of deprecated functions and events in the codebase

echo "Searching for usages of deprecated functions:"
rg -i "crossChain\s*\(" -g "*.sol"
rg -i "cancelSendToExternal\s*\(" -g "*.sol"
rg -i "increaseBridgeFee\s*\(" -g "*.sol"

echo "Searching for usages of deprecated events:"
rg -i "emit\s+CrossChain\s*\(" -g "*.sol"
rg -i "emit\s+CancelSendToExternal\s*\(" -g "*.sol"
rg -i "emit\s+IncreaseBridgeFee\s*\(" -g "*.sol"

echo "Searching for potential event listeners in JavaScript/TypeScript files:"
rg -i "CrossChain|CancelSendToExternal|IncreaseBridgeFee" -g "*.js" -g "*.ts"

Length of output: 2326

x/crosschain/precompile/cancel_send_to_external.go (3)

17-20: Approved: Clear deprecation notice added.

The deprecation notice for CancelSendToExternalMethod is clear and provides an alternative (BridgeCallMethod). This aligns with the PR objective of marking deprecated APIs.

Consider the following suggestions to improve the deprecation process:

  1. Add a specific version or date when this API will be removed completely.
  2. Provide a brief explanation of why this API is being deprecated and the benefits of using BridgeCallMethod.
  3. Update any documentation or README files to reflect this deprecation.

Line range hint 24-31: Approved: Consistent deprecation notice added.

The deprecation notice for NewCancelSendToExternalMethod is clear and consistent with the struct's deprecation notice. This change aligns with the PR objective of marking deprecated APIs.

To ensure a smooth transition away from this deprecated API:

  1. Consider adding a warning log when this method is called, to alert developers using it at runtime.
  2. If possible, implement and document the BridgeCallMethod alternative to facilitate easier migration for users of this API.
  3. Update any unit tests or integration tests that use this method to either use the new alternative or to expect the deprecation warning.

Action Required: Deprecated CancelSendToExternalMethod Still in Use

The deprecated CancelSendToExternalMethod is still being used in x/crosschain/precompile/contract.go. This indicates that the deprecation process is not yet complete and further action is needed to fully migrate to BridgeCallMethod.

Next Steps:

  • Refactor Production Code: Replace the usage of CancelSendToExternalMethod in contract.go with BridgeCallMethod.
  • Comprehensive Codebase Review: Conduct a thorough search to ensure no other production files are using the deprecated method.
  • Update Documentation: Ensure all references to the deprecated method are removed or updated in the documentation.
  • Plan for Removal: Schedule the removal of CancelSendToExternalMethod in a future release once all dependencies are migrated.
🔗 Analysis chain

Line range hint 1-105: Overall impact: Successful API deprecation with minimal risk.

The changes in this file successfully mark the CancelSendToExternalMethod struct and its constructor as deprecated, meeting the PR objective. The modifications are non-breaking, allowing current users to continue using the API while being informed of its deprecated status.

To complete this deprecation process:

  1. Conduct a codebase-wide search for usages of CancelSendToExternalMethod and plan their migration to BridgeCallMethod.
  2. Update relevant documentation, including API references and migration guides.
  3. Consider implementing the BridgeCallMethod if not already done, ensuring it provides equivalent or improved functionality.
  4. Plan for the eventual removal of this deprecated API in a future release.

To assist in identifying usages of the deprecated API, you can run the following command:

This will help in planning the migration process and ensuring all instances are updated.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for usages of CancelSendToExternalMethod across the codebase
rg "CancelSendToExternalMethod" --type go

Length of output: 1829


Script:

#!/bin/bash
# Search for usages of CancelSendToExternalMethod outside of test directories
rg "CancelSendToExternalMethod" --type go --glob '!tests/*' --glob '!**/*_test.go'

Length of output: 1615

x/crosschain/precompile/increase_bridge_fee.go (1)

Line range hint 1-146: Summary of changes and next steps

The deprecation notices for IncreaseBridgeFeeMethod and its constructor have been added correctly. These changes maintain backward compatibility while signaling the intention to move towards using BridgeCallMethod.

To ensure a smooth transition:

  1. Implement BridgeCallMethod if not already done.
  2. Update documentation, examples, and tests to reflect these deprecations.
  3. Plan for the eventual removal of the deprecated code in future releases.
  4. Consider adding migration guides for users of the deprecated methods.

To facilitate a smooth transition and maintain code quality:

  1. Create a tracking issue for the deprecation and eventual removal of IncreaseBridgeFeeMethod.
  2. Set up deprecation warnings in the code to notify users at runtime.
  3. In the next major version, consider removing the deprecated code entirely.

Would you like me to create a GitHub issue to track these tasks?

x/crosschain/precompile/crosschain.go (1)

Line range hint 1-138: Summary: Manage API transition from CrossChainMethod to BridgeCallMethod

This file shows the initial steps in deprecating CrossChainMethod in favor of BridgeCallMethod. While the approach maintains backward compatibility, several steps can be taken to ensure a smoother transition and clearer code.

Recommendations for managing this API transition:

  1. Create a detailed migration guide explaining how to transition from CrossChainMethod to BridgeCallMethod.
  2. Add deprecation warnings that will be visible during compilation or runtime for all CrossChainMethod-related code.
  3. Implement BridgeCallMethod with equivalent functionality to CrossChainMethod.
  4. Consider adding wrapper methods using BridgeCallMethod internally to allow for a more gradual transition.
  5. Set a timeline for the complete removal of CrossChainMethod in a future release.
  6. Update all relevant documentation to reflect these changes and guide users towards the new API.

By following these steps, you can ensure a cleaner codebase in the long term while providing users with a clear path forward.

proto/fx/gravity/crosschain/v1/legacy.proto (2)

126-126: Approve new response message, suggest adding explanatory comment.

The addition of MsgIncreaseBridgeFeeResponse is consistent with the previous MsgIncreaseBridgeFee message.

For consistency and clarity, consider adding a similar deprecation comment as suggested for MsgIncreaseBridgeFee. For example:

// Deprecated: This message is the response type for the deprecated MsgIncreaseBridgeFee.
// It will be removed along with MsgIncreaseBridgeFee in <version> scheduled for <date>.
message MsgIncreaseBridgeFeeResponse { option deprecated = true; }

This maintains consistency in documentation across related deprecated messages.


114-132: Summary: Consistent API deprecation, but improvements needed in documentation and clarity.

The changes in this file consistently implement the PR objective of marking deprecated APIs. The addition of new, immediately deprecated messages suggests a transition strategy in the API.

To improve the clarity and maintainability of this deprecation process, consider the following recommendations:

  1. Add a file-level comment explaining the overall deprecation strategy, including:

    • The reason for these changes
    • The timeline for removal of deprecated messages
    • Any replacement functionality or messages that should be used instead
  2. Ensure that all deprecated messages have consistent, informative comments explaining their deprecated status and providing guidance for developers.

  3. Clarify the status of the corresponding request messages for the new response messages added in this file. Are they defined in other files, or have they been removed as part of this deprecation process?

  4. Consider grouping all deprecated messages together in the file, possibly in a separate section, to make it easier to manage and eventually remove them.

  5. If this deprecation is part of a larger API change, consider creating or updating API migration documentation to guide users through the transition process.

These improvements will greatly enhance the clarity of the code and ease future maintenance efforts.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 0698a42 and 43e3542.

⛔ Files ignored due to path filters (2)
  • x/crosschain/types/legacy.pb.go is excluded by !**/*.pb.go
  • x/crosschain/types/tx.pb.go is excluded by !**/*.pb.go
📒 Files selected for processing (8)
  • contract/ICrossChain.go (1 hunks)
  • proto/fx/gravity/crosschain/v1/legacy.proto (1 hunks)
  • proto/fx/gravity/crosschain/v1/tx.proto (1 hunks)
  • solidity/contracts/bridge/ICrossChain.sol (4 hunks)
  • tests/contract/CrossChainTest.go (1 hunks)
  • x/crosschain/precompile/cancel_send_to_external.go (1 hunks)
  • x/crosschain/precompile/crosschain.go (1 hunks)
  • x/crosschain/precompile/increase_bridge_fee.go (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • tests/contract/CrossChainTest.go
🧰 Additional context used
🔇 Additional comments (8)
x/crosschain/precompile/increase_bridge_fee.go (1)

Line range hint 27-33: Constructor deprecation notice added correctly.

The deprecation notice for NewIncreaseBridgeFeeMethod is consistent with the struct deprecation. The implementation remains unchanged, which is correct for maintaining backward compatibility.

To ensure a smooth transition, please run the following script to identify other parts of the codebase that might need updating:

#!/bin/bash
# Search for usages of NewIncreaseBridgeFeeMethod
rg --type go "NewIncreaseBridgeFeeMethod" -C 3

Consider the following:

  1. Ensure that a constructor for BridgeCallMethod exists and is properly implemented.
  2. Update any documentation or examples that reference NewIncreaseBridgeFeeMethod.
  3. Plan for the eventual removal of this deprecated code in future releases.
x/crosschain/precompile/crosschain.go (2)

Line range hint 34-138: Clarify the relationship between CrossChainMethod and BridgeCallMethod

While CrossChainMethod and its constructor are deprecated, all its methods remain unchanged. This maintains backward compatibility but may lead to confusion.

To improve clarity and guide users towards the new API:

  1. Add comments to each method explaining how its functionality is handled in BridgeCallMethod.
  2. If possible, add deprecation warnings to these methods as well.
  3. Consider creating wrapper methods that use BridgeCallMethod internally, allowing for a more gradual transition.

Let's check if BridgeCallMethod exists and has similar methods:

#!/bin/bash
# Search for BridgeCallMethod definition and its methods
rg --type go "type BridgeCallMethod struct" -A 20
rg --type go "func \(.*BridgeCallMethod\) .*\(" -C 3

Would you like help in drafting comments that explain the relationship between CrossChainMethod and BridgeCallMethod for each method?


Line range hint 26-32: Update constructor usage and provide alternative

The NewCrossChainMethod constructor has been deprecated along with its associated struct. This is consistent with the move towards BridgeCallMethod.

To facilitate the transition:

  1. Ensure that there's a corresponding constructor or factory method for BridgeCallMethod.
  2. Update the documentation to clearly indicate the deprecated status and provide examples of using the new BridgeCallMethod.
  3. Consider adding a compiler warning or runtime deprecation notice when this constructor is used.

Let's check for any remaining usages of NewCrossChainMethod in the codebase:

#!/bin/bash
# Search for usages of NewCrossChainMethod
rg --type go "NewCrossChainMethod" -C 3

Would you like assistance in creating a migration guide or updating the documentation for the transition to BridgeCallMethod?

proto/fx/gravity/crosschain/v1/legacy.proto (4)

115-124: Approve new message, but clarification needed on deprecation strategy.

The addition of MsgIncreaseBridgeFee is noted. However, it's unusual to add a new message and immediately mark it as deprecated.

Could you please clarify:

  1. The rationale behind adding a new deprecated message?
  2. The timeline for its removal?
  3. Any replacement functionality?

Consider adding a comment explaining the deprecation reason and future plans. For example:

// Deprecated: This message is added for backwards compatibility during the transition to <new_feature>.
// It will be removed in <version> scheduled for <date>. Use <alternative_message> instead.
message MsgIncreaseBridgeFee {
  ...
}

This will help future maintainers understand the context and plan for this message's lifecycle.


128-128: Approve new response message, suggest documentation and seek clarification.

The addition of MsgOracleSetConfirmResponse is noted and appears to be part of the API deprecation effort.

Please consider the following:

  1. Add a deprecation comment explaining the reason and future plans, similar to previous messages.
  2. Could you clarify where the corresponding request message (MsgOracleSetConfirm) is defined? It's not visible in this file, which could indicate incomplete refactoring or that it's defined elsewhere.

Example comment:

// Deprecated: This message is the response type for the deprecated MsgOracleSetConfirm.
// It will be removed in <version> scheduled for <date>. Use <alternative_message> instead.
message MsgOracleSetConfirmResponse { option deprecated = true; }

This documentation will help maintain consistency and provide context for future developers.


130-130: Approve new response message, recommend documentation and seek clarification.

The addition of MsgConfirmBatchResponse is noted and follows the pattern of API deprecation seen in previous messages.

Please address the following points:

  1. Add a deprecation comment explaining the reason and future plans, maintaining consistency with previous messages.
  2. Clarify the location of the corresponding request message (MsgConfirmBatch). Is it defined in another file or has it been removed?

Suggested comment:

// Deprecated: This message is the response type for the deprecated MsgConfirmBatch.
// It will be removed in <version> scheduled for <date>. Use <alternative_message> instead.
message MsgConfirmBatchResponse { option deprecated = true; }

This documentation ensures consistency across the deprecated messages and provides valuable context for future maintenance.


132-132: Approve new response message, suggest documentation improvements and seek clarification.

The addition of MsgBridgeCallConfirmResponse is consistent with the ongoing API deprecation effort.

Please address the following:

  1. Add a deprecation comment explaining the reason and future plans, similar to previous suggestions.
  2. Clarify the location of the corresponding request message (MsgBridgeCallConfirm). Is it defined elsewhere or has it been removed?

Suggested comment:

// Deprecated: This message is the response type for the deprecated MsgBridgeCallConfirm.
// It will be removed in <version> scheduled for <date>. Use <alternative_message> instead.
message MsgBridgeCallConfirmResponse { option deprecated = true; }

Given the repetitive nature of these deprecated message additions, consider a more general approach to documentation:

  1. Add a comment at the file level explaining the deprecation strategy, affected message types, and the timeline for removal.
  2. Use a consistent format for individual message comments, possibly with a shorter reference to the file-level comment.

This approach would reduce redundancy and provide a centralized location for deprecation information, making future maintenance easier.

proto/fx/gravity/crosschain/v1/tx.proto (1)

51-53: Clarify the purpose of the newly added and deprecated IncreaseBridgeFee method

The addition of the IncreaseBridgeFee method, which is immediately marked as deprecated, is unusual. This could indicate a recent design change or possibly an oversight. Could you please clarify:

  1. Why was this method added if it's immediately deprecated?
  2. Is there a replacement method for this functionality?
  3. Should this method be removed entirely instead of being added as deprecated?

Additionally, with the deprecation of multiple methods (OracleSetConfirm, SendToExternal, CancelSendToExternal, RequestBatch, ConfirmBatch, BridgeCallConfirm, and now IncreaseBridgeFee), it would be helpful to provide documentation or comments explaining:

  1. The reasons for deprecating these methods.
  2. Any replacement methods or alternative approaches that should be used instead.
  3. The timeline for removing these deprecated methods, if applicable.

This information will help users of the API understand the changes and plan for migrations accordingly.

To ensure consistency across the codebase, let's check for any usages of these deprecated methods:

✅ Verification successful

Deprecated IncreaseBridgeFee Method Usage Verified

The IncreaseBridgeFee method is currently used exclusively within various test files. Deprecating it in the .proto file should not impact the main production codebase. However, please ensure that all relevant tests are updated to reflect this deprecation and transition to any new methods if they are intended to replace IncreaseBridgeFee.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for usages of deprecated methods
echo "Searching for usages of deprecated methods:"
rg --type go "OracleSetConfirm|SendToExternal|CancelSendToExternal|RequestBatch|ConfirmBatch|BridgeCallConfirm|IncreaseBridgeFee" .

Length of output: 173398

Comment on lines +20 to 23
// Deprecated: please use BridgeCallMethod
type IncreaseBridgeFeeMethod struct {
*Keeper
abi.Method
Copy link

Choose a reason for hiding this comment

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

💡 Codebase verification

Deprecated method IncreaseBridgeFeeMethod is still in use.

The usage of IncreaseBridgeFeeMethod was found in the following locations:

  • x/crosschain/precompile/contract.go:

    • NewIncreaseBridgeFeeMethod(keeper)
  • x/crosschain/precompile/increase_bridgefee_test.go:

    • precompile.NewIncreaseBridgeFeeMethod(nil)

These instances should be updated to use BridgeCallMethod as per the deprecation notice.

🔗 Analysis chain

Deprecation notice added correctly.

The deprecation notice for IncreaseBridgeFeeMethod is clear and provides an alternative (BridgeCallMethod). This change maintains backward compatibility while signaling future removal.

To ensure a smooth transition, please run the following script to identify other parts of the codebase that might need updating:

Consider updating the documentation and any relevant tests to reflect this deprecation.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for usages of IncreaseBridgeFeeMethod
rg --type go "IncreaseBridgeFeeMethod" -C 3

Length of output: 2862

Comment on lines +19 to 22
// Deprecated: please use BridgeCallMethod
type CrossChainMethod struct {
*Keeper
abi.Method
Copy link

Choose a reason for hiding this comment

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

💡 Codebase verification

⚠️ Potential issue

Deprecated CrossChainMethod Still in Use Within Test Files

The CrossChainMethod and NewCrossChainMethod are still being utilized in crosschain_test.go. To fully deprecate CrossChainMethod, please update all test cases to use BridgeCallMethod.

🔗 Analysis chain

Consider updating usage of CrossChainMethod to BridgeCallMethod

The CrossChainMethod struct has been marked as deprecated. While it's good practice to maintain backward compatibility, it's important to plan for the transition to BridgeCallMethod.

To ensure a smooth transition:

  1. Document the deprecation in the project's changelog or release notes.
  2. If possible, add a deprecation warning that will be visible during compilation or runtime.
  3. Create a migration guide for users to transition from CrossChainMethod to BridgeCallMethod.
  4. Set a timeline for the complete removal of CrossChainMethod in a future release.

Let's check for any remaining usages of CrossChainMethod in the codebase:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for usages of CrossChainMethod
rg --type go "CrossChainMethod" -C 3

Length of output: 1552


Script:

#!/bin/bash
# Corrected shell script to search for usages of CrossChainMethod and NewCrossChainMethod
rg --type go "CrossChainMethod|NewCrossChainMethod" -C 3

Length of output: 4989

@@ -31,7 +31,7 @@ var (

// ICrossChainMetaData contains all meta data concerning the ICrossChain contract.
var ICrossChainMetaData = &bind.MetaData{
ABI: "[{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"string\",\"name\":\"chain\",\"type\":\"string\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"txID\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"reward\",\"type\":\"uint256\"}],\"name\":\"AddPendingPoolRewardsEvent\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"_sender\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"_receiver\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"_to\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"_txOrigin\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"_value\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"_eventNonce\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"string\",\"name\":\"_dstChain\",\"type\":\"string\"},{\"indexed\":false,\"internalType\":\"address[]\",\"name\":\"_tokens\",\"type\":\"address[]\"},{\"indexed\":false,\"internalType\":\"uint256[]\",\"name\":\"_amounts\",\"type\":\"uint256[]\"},{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"_data\",\"type\":\"bytes\"},{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"_memo\",\"type\":\"bytes\"}],\"name\":\"BridgeCallEvent\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"_sender\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"string\",\"name\":\"chain\",\"type\":\"string\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"txID\",\"type\":\"uint256\"}],\"name\":\"CancelPendingBridgeCallEvent\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"string\",\"name\":\"chain\",\"type\":\"string\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"txID\",\"type\":\"uint256\"}],\"name\":\"CancelSendToExternal\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"string\",\"name\":\"denom\",\"type\":\"string\"},{\"indexed\":false,\"internalType\":\"string\",\"name\":\"receipt\",\"type\":\"string\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"fee\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"target\",\"type\":\"bytes32\"},{\"indexed\":false,\"internalType\":\"string\",\"name\":\"memo\",\"type\":\"string\"}],\"name\":\"CrossChain\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"_sender\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"_eventNonce\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"string\",\"name\":\"_chain\",\"type\":\"string\"}],\"name\":\"ExecuteClaimEvent\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"string\",\"name\":\"chain\",\"type\":\"string\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"txID\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"fee\",\"type\":\"uint256\"}],\"name\":\"IncreaseBridgeFee\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"_chain\",\"type\":\"string\"},{\"internalType\":\"uint256\",\"name\":\"_txID\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"_token\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_reward\",\"type\":\"uint256\"}],\"name\":\"addPendingPoolRewards\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"_result\",\"type\":\"bool\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"_dstChain\",\"type\":\"string\"},{\"internalType\":\"address\",\"name\":\"_refund\",\"type\":\"address\"},{\"internalType\":\"address[]\",\"name\":\"_tokens\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"_amounts\",\"type\":\"uint256[]\"},{\"internalType\":\"address\",\"name\":\"_to\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"_data\",\"type\":\"bytes\"},{\"internalType\":\"uint256\",\"name\":\"_value\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"_memo\",\"type\":\"bytes\"}],\"name\":\"bridgeCall\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"_eventNonce\",\"type\":\"uint256\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_token\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"_target\",\"type\":\"bytes32\"}],\"name\":\"bridgeCoinAmount\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"_amount\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"_chain\",\"type\":\"string\"},{\"internalType\":\"uint256\",\"name\":\"_txID\",\"type\":\"uint256\"}],\"name\":\"cancelPendingBridgeCall\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"_result\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"_chain\",\"type\":\"string\"},{\"internalType\":\"uint256\",\"name\":\"_txID\",\"type\":\"uint256\"}],\"name\":\"cancelSendToExternal\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"_result\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_token\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"_receipt\",\"type\":\"string\"},{\"internalType\":\"uint256\",\"name\":\"_amount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_fee\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"_target\",\"type\":\"bytes32\"},{\"internalType\":\"string\",\"name\":\"_memo\",\"type\":\"string\"}],\"name\":\"crossChain\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"_result\",\"type\":\"bool\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"_chain\",\"type\":\"string\"},{\"internalType\":\"uint256\",\"name\":\"_eventNonce\",\"type\":\"uint256\"}],\"name\":\"executeClaim\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"_result\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"_chain\",\"type\":\"string\"},{\"internalType\":\"address\",\"name\":\"_externalAddress\",\"type\":\"address\"}],\"name\":\"hasOracle\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"_result\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"_chain\",\"type\":\"string\"},{\"internalType\":\"uint256\",\"name\":\"_txID\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"_token\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_fee\",\"type\":\"uint256\"}],\"name\":\"increaseBridgeFee\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"_result\",\"type\":\"bool\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"_chain\",\"type\":\"string\"},{\"internalType\":\"address\",\"name\":\"_externalAddress\",\"type\":\"address\"}],\"name\":\"isOracleOnline\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"_result\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"}]",
ABI: "[{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"_sender\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"_receiver\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"_to\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"_txOrigin\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"_value\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"_eventNonce\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"string\",\"name\":\"_dstChain\",\"type\":\"string\"},{\"indexed\":false,\"internalType\":\"address[]\",\"name\":\"_tokens\",\"type\":\"address[]\"},{\"indexed\":false,\"internalType\":\"uint256[]\",\"name\":\"_amounts\",\"type\":\"uint256[]\"},{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"_data\",\"type\":\"bytes\"},{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"_memo\",\"type\":\"bytes\"}],\"name\":\"BridgeCallEvent\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"string\",\"name\":\"chain\",\"type\":\"string\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"txID\",\"type\":\"uint256\"}],\"name\":\"CancelSendToExternal\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"string\",\"name\":\"denom\",\"type\":\"string\"},{\"indexed\":false,\"internalType\":\"string\",\"name\":\"receipt\",\"type\":\"string\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"fee\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"target\",\"type\":\"bytes32\"},{\"indexed\":false,\"internalType\":\"string\",\"name\":\"memo\",\"type\":\"string\"}],\"name\":\"CrossChain\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"_sender\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"_eventNonce\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"string\",\"name\":\"_chain\",\"type\":\"string\"}],\"name\":\"ExecuteClaimEvent\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"string\",\"name\":\"chain\",\"type\":\"string\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"txID\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"fee\",\"type\":\"uint256\"}],\"name\":\"IncreaseBridgeFee\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"_dstChain\",\"type\":\"string\"},{\"internalType\":\"address\",\"name\":\"_refund\",\"type\":\"address\"},{\"internalType\":\"address[]\",\"name\":\"_tokens\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"_amounts\",\"type\":\"uint256[]\"},{\"internalType\":\"address\",\"name\":\"_to\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"_data\",\"type\":\"bytes\"},{\"internalType\":\"uint256\",\"name\":\"_value\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"_memo\",\"type\":\"bytes\"}],\"name\":\"bridgeCall\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"_eventNonce\",\"type\":\"uint256\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_token\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"_target\",\"type\":\"bytes32\"}],\"name\":\"bridgeCoinAmount\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"_amount\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"_chain\",\"type\":\"string\"},{\"internalType\":\"uint256\",\"name\":\"_txID\",\"type\":\"uint256\"}],\"name\":\"cancelSendToExternal\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"_result\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_token\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"_receipt\",\"type\":\"string\"},{\"internalType\":\"uint256\",\"name\":\"_amount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_fee\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"_target\",\"type\":\"bytes32\"},{\"internalType\":\"string\",\"name\":\"_memo\",\"type\":\"string\"}],\"name\":\"crossChain\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"_result\",\"type\":\"bool\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"_chain\",\"type\":\"string\"},{\"internalType\":\"uint256\",\"name\":\"_eventNonce\",\"type\":\"uint256\"}],\"name\":\"executeClaim\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"_result\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"_chain\",\"type\":\"string\"},{\"internalType\":\"address\",\"name\":\"_externalAddress\",\"type\":\"address\"}],\"name\":\"hasOracle\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"_result\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"_chain\",\"type\":\"string\"},{\"internalType\":\"uint256\",\"name\":\"_txID\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"_token\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_fee\",\"type\":\"uint256\"}],\"name\":\"increaseBridgeFee\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"_result\",\"type\":\"bool\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"_chain\",\"type\":\"string\"},{\"internalType\":\"address\",\"name\":\"_externalAddress\",\"type\":\"address\"}],\"name\":\"isOracleOnline\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"_result\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"}]",
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Consider deprecating APIs instead of removing them

The PR title suggests marking APIs as deprecated, but the methods and events related to AddPendingPoolRewards and CancelPendingBridgeCall have been entirely removed. Removing public APIs can introduce breaking changes for clients that depend on them. To maintain backward compatibility, consider marking these APIs as deprecated first before fully removing them in a future release.

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.

1 participant