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: remove batch bridge fee logic #728

Merged
merged 1 commit into from
Oct 11, 2024
Merged

Conversation

zakir-code
Copy link
Contributor

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

Summary by CodeRabbit

  • New Features

    • Introduced new command structure for outgoing transactions.
    • Enhanced API endpoint clarity and consistency in the OpenAPI specification.
  • Bug Fixes

    • Refined linting criteria for Go files.
  • Deprecations

    • Deprecated several functions and events related to cross-chain transactions, including CancelSendToExternal and IncreaseBridgeFee.
  • Documentation

    • Updated API documentation to reflect changes in endpoints and response structures.

Copy link

coderabbitai bot commented Oct 11, 2024

Walkthrough

This pull request includes extensive modifications across multiple files, primarily focusing on refining the cross-chain functionality and related components. Key changes involve the removal of deprecated functions and events, adjustments to message types, and updates to the API specifications. The linting process in the Makefile has also been refined. Additionally, several test files and methods related to removed functionalities have been deleted or modified to reflect these changes.

Changes

File Change Summary
Makefile Adjusted check-no-lint target's expected count of 'nolint' or '#nosec' comments from 31 to 29.
app/app_test.go Added new message types to the deprecated map in Test_MsgServiceRouter.
app/encoding_test.go Updated expected count of implementation interfaces in interfaceRegistry from 303 to 300.
app/interface_registry.json Removed multiple entries from InterfaceNames and TypeURLMap.
contract/ICrossChain.go Removed functions and events related to CancelSendToExternal and IncreaseBridgeFee.
docs/swagger-ui/swagger.yaml Renamed several API endpoints and altered response structures for clarity.
docs/swagger_test.go Adjusted assertion in TestSwaggerConfig for handler value length from 198 to 196.
proto/fx/gravity/crosschain/v1/legacy.proto Deprecated multiple messages and updated message fields for clarity.
proto/fx/gravity/crosschain/v1/query.proto Removed BatchFees RPC method and updated OutgoingTxBatches method's HTTP GET endpoint.
proto/fx/gravity/crosschain/v1/tx.proto Deprecated several RPC methods and updated comments.
solidity/contracts/bridge/ICrossChain.sol Deprecated functions and events related to cross-chain actions.
solidity/contracts/test/CrossChainTest.sol Removed functions related to cross-chain actions.
tests/crosschain_suite.go Removed several methods from CrosschainTestSuite.
tests/crosschain_test.go Modified CrossChainTest method to remove bridge fee checks and batch requests.
x/crosschain/client/cli/query.go Replaced CmdBatchRequestByNonce with CmdOutgoingTxBatch.
x/crosschain/client/cli/tx.go Removed transaction management command functions.
x/crosschain/keeper/abci.go Renamed method for handling cancellation of outgoing transaction batches.
x/crosschain/keeper/batch_fee.go Deleted file related to managing batch fees.
x/crosschain/keeper/batch_test.go Deleted unit tests for the Keeper component of the crosschain module.
x/crosschain/keeper/bridge_call_out.go Removed BridgeCallCoinsToERC20Token method.
x/crosschain/keeper/bridge_call_out_test.go Removed test function for BridgeCallCoinsToERC20Token.
x/crosschain/keeper/bridge_token.go Removed deprecated functions related to token management.
x/crosschain/keeper/genesis.go Modified InitGenesis and ExportGenesis functions to remove handling of unbatched transfers.
x/crosschain/keeper/grpc_query.go Removed BatchFees method and updated method signatures.
x/crosschain/types/events.go Removed constants related to event types and attributes.
x/crosschain/types/key.go Added new constants and functions for handling bridge calls.
x/crosschain/types/msgs.go Removed message validation functions for deprecated messages.
x/crosschain/types/params.go Removed OutgoingTxBatchSize constant.
x/crosschain/types/types.go Updated method signatures in OutgoingTxBatch and OutgoingBridgeCall structures.
x/tron/keeper/grpc_query_test.go Updated test cases to reflect changes in outgoing transaction batch querying.

Possibly related PRs

🐇 In the meadow, changes abound,
With bridges refined, new paths are found.
Linting's adjusted, tests shed their weight,
Cross-chain calls simplified, oh what a fate!
Hopping along, we celebrate this cheer,
For every tweak brings us closer, my dear! 🌼


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

🧹 Outside diff range and nitpick comments (22)
docs/swagger-ui/swagger.yaml (5)

5360-5418: LGTM! Consider enhancing the description.

The restructuring of the /fx/crosschain/v1/batch/outgoing_tx endpoint and its response schema looks good. The change from returning multiple batches to a single batch aligns well with the endpoint's singular name.

Consider updating the description of the OutgoingTxBatch object (line 5419-5420) to reflect that it represents a single batch rather than multiple batches. For example:

title: >-
  OutgoingTxBatch represents a single batch of transactions going from
  gravity to ETH

5620-5695: LGTM! Consider clarifying the description.

The addition of the /fx/crosschain/v1/batch/outgoing_txs endpoint is a good complement to the single batch endpoint. It provides a way to retrieve multiple batches and includes useful query parameters for filtering.

Consider adding a description to the endpoint to clarify its purpose and how it differs from the single batch endpoint. For example, you could add:

description: Retrieves multiple outgoing transaction batches, optionally filtered by token contract and nonce.

Also, consider updating the description of the OutgoingTxBatch object (line 5693-5695) to be consistent with the suggested change in the previous comment.


5897-5942: LGTM! Consider adding a description and query parameters.

The addition of the /fx/crosschain/v1/bridge_call_by_nonce endpoint is well-structured and aligns with the PR objective. The bridge_call object in the response schema is comprehensive and includes all necessary information.

Consider the following improvements:

  1. Add a description to the endpoint to clarify its purpose:
description: Retrieves a specific bridge call by its nonce.
  1. Add a query parameter for the nonce, as it's likely required to identify the specific bridge call:
parameters:
  - name: nonce
    in: query
    required: true
    type: string
    format: uint64
    description: The nonce of the bridge call to retrieve.

These additions would improve the clarity and usability of the API documentation.


11885-11896: LGTM! Consider enhancing the documentation.

The addition of the /fx/crosschain/v1/projected_batch_timeout endpoint is straightforward and aligns with the PR objective. The simple response structure with just the timeout_height is appropriate for its purpose.

Consider the following improvements to enhance the API documentation:

  1. Add a description to the endpoint to clarify its purpose:
description: Retrieves the projected timeout height for the next batch.
  1. Add query parameters if any are needed to calculate the projected timeout. For example:
parameters:
  - name: token_contract
    in: query
    required: false
    type: string
    description: The token contract address to calculate the timeout for (optional).
  1. Add a description to the timeout_height property in the response:
timeout_height:
  type: string
  format: uint64
  description: The projected block height at which the next batch will timeout.

These additions would provide more context and improve the usability of the API.


44050-44102: LGTM! Consider adding property descriptions.

The addition of the fx.gravity.crosschain.v1.QueryOutgoingTxBatchResponse definition is consistent with the changes made to the /fx/crosschain/v1/batch/outgoing_tx endpoint. The structure is comprehensive and includes all necessary properties for an outgoing transaction batch.

To improve the documentation, consider adding descriptions to the main properties of the batch object. For example:

batch:
  type: object
  description: Represents a single batch of outgoing transactions.
  properties:
    batch_nonce:
      type: string
      format: uint64
      description: Unique identifier for the batch.
    batch_timeout:
      type: string
      format: uint64
      description: Block height at which this batch times out.
    transactions:
      type: array
      description: List of transactions included in this batch.
      items:
        # ... (existing properties)
    token_contract:
      type: string
      description: The token contract address for this batch.
    block:
      type: string
      format: uint64
      description: Block height at which this batch was created.
    feeReceive:
      type: string
      description: Address that receives the fees for this batch.

Adding these descriptions would provide more context and improve the overall documentation quality.

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

Line range hint 1-132: Summary of changes in legacy.proto

This file has undergone significant changes as part of the effort to remove batch bridge fee logic:

  1. Multiple messages have been deprecated, including MsgSendToExternal, MsgRequestBatch, and others.
  2. Field names have been updated for consistency, notably changing outgoing_tx_id to batch_nonce.
  3. Deprecation notices have been updated to provide clearer guidance on alternative approaches.

These changes suggest a substantial shift in the system's architecture or design. Ensure that all deprecated messages are properly handled and that any code depending on the changed field names is updated accordingly.

Consider creating a migration guide or updating existing documentation to reflect these changes and guide users in transitioning to the new architecture.


Incomplete Deprecation of MsgRequestBatchResponse

The MsgRequestBatchResponse message is still referenced in the following locations:

  • x/crosschain/types/legacy.pb.go
  • proto/fx/gravity/crosschain/v1/legacy.proto

Please ensure that all usages of MsgRequestBatchResponse are removed or updated to complete the deprecation process.

🔗 Analysis chain

Line range hint 110-110: Note deprecation of MsgRequestBatchResponse

The MsgRequestBatchResponse message has been explicitly marked as deprecated with the comment "do not use". This change is consistent with the overall trend of deprecating certain messages in this file. The field name 'batch_nonce' remains unchanged, maintaining consistency with the change made to MsgSendToExternalResponse.

To ensure proper handling of this deprecation, please run the following script to check for any remaining uses of MsgRequestBatchResponse:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for references to MsgRequestBatchResponse in the codebase
rg --type-add 'proto:*.proto' --type proto --type go 'MsgRequestBatchResponse'

Length of output: 2537

tests/precompile_test.go (1)

Line range hint 1-132: Overall impact assessment and suggested next steps.

The changes in this file consistently remove cross-chain transfer test cases across multiple methods, aligning with the PR objective of removing batch bridge fee logic. While this is likely necessary due to architectural changes, it raises concerns about maintaining comprehensive test coverage.

To ensure the quality and reliability of the codebase:

  1. Conduct a comprehensive review of the test suite to identify any gaps in coverage resulting from these changes.
  2. Develop new test cases that cover the updated functionality, ensuring that all critical paths are still being tested.
  3. Consider implementing integration or end-to-end tests that verify the system's behavior in the absence of the removed batch bridge fee logic.
  4. Update documentation to reflect the changes in the testing approach and any new test cases added.

Given the significant changes to the test suite, it may be beneficial to revisit the overall testing strategy for cross-chain functionality. Consider implementing a more modular testing approach that can easily adapt to future changes in the cross-chain architecture.

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

136-138: Approve the change to batch processing.

The change from AddToOutgoingPool to BuildOutgoingTxBatch appears to be an improvement in the transaction handling mechanism. The new method name is more descriptive of its functionality, and the use of batchNonce as the return value is more appropriate.

Consider updating any related documentation or comments to reflect this change in batch processing approach.


136-141: Summary of changes and potential impact.

The modifications in this file appear to be part of a larger refactoring effort to improve the batch processing of outgoing transactions in the cross-chain functionality. The changes from AddToOutgoingPool to BuildOutgoingTxBatch and the consistent use of batchNonce suggest a more structured approach to handling outgoing transfers.

While these changes improve code clarity and potentially efficiency, they may have broader implications:

  1. Performance: The new batch building approach might affect the timing and grouping of transactions.
  2. Consistency: Ensure that all related components (e.g., event emissions, logging) are updated to reflect the new batch-oriented approach.
  3. API Changes: If txID was exposed in any public APIs, those might need to be updated or versioned.

Consider reviewing the entire cross-chain module to ensure these changes are consistently applied and that they align with the overall architecture goals. It may be beneficial to update the module's documentation to reflect this new approach to transaction batching.

Makefile (1)

145-145: LGTM! Consider making the linter check more flexible.

The reduction in allowed 'nolint' or '#nosec' occurrences from 31 to 29 reflects an improvement in code quality. This change aligns well with the PR objective of refactoring and removing deprecated code.

To make this check more maintainable in the future, consider using a range instead of an exact number. This would allow for small fluctuations without requiring frequent updates to the Makefile. For example:

-	@if [ $$(find . -name '*.go' -type f | xargs grep 'nolint\|#nosec' | wc -l) -ne 29 ]; then \
+	@if [ $$(find . -name '*.go' -type f | xargs grep 'nolint\|#nosec' | wc -l) -lt 25 ] || [ $$(find . -name '*.go' -type f | xargs grep 'nolint\|#nosec' | wc -l) -gt 35 ]; then \

This change would allow for a range of 25-35 occurrences, providing some flexibility while still catching significant increases in linter suppressions.

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

29-30: Approved: ConfirmBatch deprecation consistent with API simplification.

The deprecation of ConfirmBatch in favor of Confirm is consistent with the previous change and supports the goal of simplifying the API.

Consider updating any related documentation or guides that may reference ConfirmBatch to reflect this change and direct users to the new Confirm method.


31-33: Approved: BridgeCallConfirm deprecation completes API simplification.

The deprecation of BridgeCallConfirm in favor of Confirm completes the pattern of simplifying the confirmation API. This change is in line with the overall refactoring goal.

To ensure a smooth transition:

  1. Update all client code that uses these deprecated methods to use the new Confirm method.
  2. Consider adding a migration guide for users of the API.
  3. Plan for the eventual removal of these deprecated methods in a future release.

37-37: Approved: BridgeCall method added as replacement for SendToExternal.

The addition of the BridgeCall method is a positive step, providing a replacement for the deprecated SendToExternal method.

To ensure smooth adoption of this new method:

  1. Please add comprehensive documentation for BridgeCall, including its parameters, return value, and expected behavior.
  2. Consider providing a code example demonstrating how to use BridgeCall in place of SendToExternal.
  3. Update any relevant API documentation or developer guides to reflect this new method.

26-37: Summary: Significant API changes align with refactoring goals.

The changes in this file represent a significant refactoring of the cross-chain API:

  1. Deprecation of OracleSetConfirm, ConfirmBatch, and BridgeCallConfirm in favor of a unified Confirm method.
  2. Deprecation of SendToExternal in favor of a new BridgeCall precompile.
  3. Addition of a new BridgeCall RPC method.

These changes align well with the PR objective of removing batch bridge fee logic and simplifying the API. However, they will require careful migration of existing client code.

To ensure a smooth transition:

  1. Create a comprehensive migration guide for API users.
  2. Update all internal usages of the deprecated methods.
  3. Consider adding temporary backwards compatibility measures if this is a widely-used public API.
  4. Plan for a future release to remove the deprecated methods entirely.
  5. Update all relevant documentation, including API docs, developer guides, and examples.
x/tron/keeper/grpc_query_test.go (1)

Line range hint 13-130: LGTM! Consider enhancing error handling in test cases.

The refactoring from TestKeeper_BatchRequestByNonce to TestKeeper_OutgoingTxBatch improves clarity and aligns well with the underlying functionality being tested. The changes to request and response types, as well as the method call updates, are consistent and appropriate.

Consider enhancing the error handling in the test cases that expect failures (lines 125-131). Instead of just checking for the presence of an error, you could verify the specific error type or message to ensure the correct error is being returned. This would make the tests more robust and informative. For example:

if testCase.expPass {
    suite.Require().NoError(err)
    suite.Require().Equal(response.Batch, res.Batch)
} else {
    suite.Require().Error(err)
    // Add specific error checks here, e.g.:
    // suite.Require().Contains(err.Error(), "expected error message")
    // or
    // suite.Require().IsType(&expectedErrorType{}, err)
}

This enhancement would provide more confidence that the error handling in the actual implementation is working as expected.

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

Line range hint 1-1: Summary of changes and potential impact.

The changes in this file, particularly the refactoring of BatchRequestByNonce to OutgoingTxBatch and the removal of BatchFees, are consistent with the PR objective of removing batch bridge fee logic. These modifications improve code clarity but may have broader implications:

  1. The renaming of methods may require updates in other parts of the codebase that use these functions.
  2. The removal of batch fee functionality could affect how fees are handled or queried throughout the system.
  3. There may be a need to update documentation, API specifications, and potentially client-side code that interacts with these endpoints.

Consider the following to ensure a smooth transition:

  1. Update all relevant documentation and API specifications.
  2. Review and update any client-side code that may be affected by these changes.
  3. Consider adding a deprecation notice or temporary backwards compatibility for any external systems that might be using the old endpoints.
  4. Ensure that the removal of batch fees doesn't create any inconsistencies in the overall fee handling logic of the system.
x/crosschain/client/cli/query.go (1)

Line range hint 511-538: LGTM! Consider adding error handling for empty results.

The CmdOutgoingTxBatch function is well-implemented and correctly replaces the previous CmdBatchRequestByNonce. It properly validates inputs and uses the new QueryOutgoingTxBatchRequest type.

Consider adding a check for empty results before printing the protocol buffer. This could improve the user experience by providing a clear message when no batch is found:

 if err != nil {
   return err
 }
+if res.Batch == nil {
+  return fmt.Errorf("no outgoing tx batch found for token contract %s and nonce %d", tokenContract, nonce)
+}
 return clientCtx.PrintProto(res.Batch)
x/crosschain/types/key.go (1)

Line range hint 220-223: Add error handling to ParseOutgoingBridgeCallNonce to ensure correct parsing.

The function ParseOutgoingBridgeCallNonce assumes that the provided key contains the expected prefixes. If the key does not have the OutgoingBridgeCallAddressAndNonceKey prefix or the address prefix, bytes.TrimPrefix will not alter the slice, potentially leading to incorrect nonce values or panics. To enhance robustness, consider adding checks to verify the presence of these prefixes and handle cases where they are missing.

Apply this diff to incorporate error handling:

+import "fmt"

-func ParseOutgoingBridgeCallNonce(key []byte, address string) (nonce uint64) {
+func ParseOutgoingBridgeCallNonce(key []byte, address string) (nonce uint64, err error) {
+	if !bytes.HasPrefix(key, OutgoingBridgeCallAddressAndNonceKey) {
+		return 0, fmt.Errorf("key does not have expected OutgoingBridgeCallAddressAndNonceKey prefix")
+	}
	addrNonce := bytes.TrimPrefix(key, OutgoingBridgeCallAddressAndNonceKey)
+	if !bytes.HasPrefix(addrNonce, []byte(address)) {
+		return 0, fmt.Errorf("key does not have expected address prefix")
+	}
	nonceBytes := bytes.TrimPrefix(addrNonce, []byte(address))
-	return sdk.BigEndianToUint64(nonceBytes)
+	return sdk.BigEndianToUint64(nonceBytes), nil
}
x/crosschain/keeper/grpc_query.go (1)

Line range hint 138-149: Enhance error messages for better user understanding

The error messages returned in case of invalid input could be more descriptive. Instead of generic terms like "nonce" or "token contract address", provide clearer messages that specify the issue. This will improve usability by helping users understand what went wrong.

Apply this diff to improve the error messages:

 func (k QueryServer) OutgoingTxBatch(c context.Context, req *types.QueryOutgoingTxBatchRequest) (*types.QueryOutgoingTxBatchResponse, error) {
     if err := types.ValidateExternalAddr(req.ChainName, req.GetTokenContract()); err != nil {
-        return nil, status.Error(codes.InvalidArgument, "token contract address")
+        return nil, status.Errorf(codes.InvalidArgument, "invalid token contract address: %v", err)
     }
     if req.GetNonce() <= 0 {
-        return nil, status.Error(codes.InvalidArgument, "nonce")
+        return nil, status.Error(codes.InvalidArgument, "invalid nonce: must be greater than 0")
     }
     foundBatch := k.GetOutgoingTxBatch(sdk.UnwrapSDKContext(c), req.TokenContract, req.Nonce)
     if foundBatch == nil {
-        return nil, status.Error(codes.NotFound, "tx batch")
+        return nil, status.Errorf(codes.NotFound, "outgoing transaction batch not found for token contract %s and nonce %d", req.TokenContract, req.Nonce)
     }
     return &types.QueryOutgoingTxBatchResponse{Batch: foundBatch}, nil
 }
x/crosschain/keeper/grpc_query_v1_test.go (2)

Line range hint 791-799: Ensure test case names are unique

Duplicate test case names can cause confusion when running tests and interpreting results. The test case named "query token contract error" is used more than once. Please update the test case names to be unique and descriptive.


Line range hint 804-812: Rename test case to reflect the error being tested

The test case name is "query token contract error", but it tests for an invalid nonce error. To improve clarity, consider renaming the test case to accurately reflect the scenario being tested.

Apply this diff to fix the test case name:

-			name: "query token contract error",
+			name: "query nonce error",
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 6d2f7ce and 702fe30.

⛔ Files ignored due to path filters (4)
  • x/crosschain/types/legacy.pb.go is excluded by !**/*.pb.go
  • x/crosschain/types/query.pb.go is excluded by !**/*.pb.go
  • x/crosschain/types/query.pb.gw.go is excluded by !**/*.pb.gw.go
  • x/crosschain/types/tx.pb.go is excluded by !**/*.pb.go
📒 Files selected for processing (52)
  • Makefile (1 hunks)
  • app/app_test.go (1 hunks)
  • app/encoding_test.go (1 hunks)
  • app/interface_registry.json (0 hunks)
  • contract/ICrossChain.go (1 hunks)
  • docs/swagger-ui/swagger.yaml (5 hunks)
  • docs/swagger_test.go (1 hunks)
  • proto/fx/gravity/crosschain/v1/legacy.proto (2 hunks)
  • proto/fx/gravity/crosschain/v1/query.proto (2 hunks)
  • proto/fx/gravity/crosschain/v1/tx.proto (1 hunks)
  • solidity/contracts/bridge/ICrossChain.sol (0 hunks)
  • solidity/contracts/test/CrossChainTest.sol (0 hunks)
  • tests/contract/CrossChainTest.go (1 hunks)
  • tests/crosschain_suite.go (0 hunks)
  • tests/crosschain_test.go (0 hunks)
  • tests/integration_test.go (0 hunks)
  • tests/precompile_suite.go (0 hunks)
  • tests/precompile_test.go (5 hunks)
  • x/crosschain/client/cli/query.go (3 hunks)
  • x/crosschain/client/cli/tx.go (2 hunks)
  • x/crosschain/keeper/abci.go (1 hunks)
  • x/crosschain/keeper/batch_fee.go (0 hunks)
  • x/crosschain/keeper/batch_test.go (0 hunks)
  • x/crosschain/keeper/bridge_call_out.go (0 hunks)
  • x/crosschain/keeper/bridge_call_out_test.go (0 hunks)
  • x/crosschain/keeper/bridge_token.go (0 hunks)
  • x/crosschain/keeper/genesis.go (0 hunks)
  • x/crosschain/keeper/genesis_test.go (0 hunks)
  • x/crosschain/keeper/grpc_query.go (2 hunks)
  • x/crosschain/keeper/grpc_query_router.go (1 hunks)
  • x/crosschain/keeper/grpc_query_v1_test.go (5 hunks)
  • x/crosschain/keeper/msg_server.go (2 hunks)
  • x/crosschain/keeper/msg_server_router.go (0 hunks)
  • x/crosschain/keeper/msg_server_test.go (0 hunks)
  • x/crosschain/keeper/outgoing_pool.go (0 hunks)
  • x/crosschain/keeper/outgoing_pool_test.go (0 hunks)
  • x/crosschain/keeper/outgoing_tx.go (3 hunks)
  • x/crosschain/precompile/cancel_send_to_external.go (0 hunks)
  • x/crosschain/precompile/cancel_send_to_external_test.go (0 hunks)
  • x/crosschain/precompile/contract.go (0 hunks)
  • x/crosschain/precompile/crosschain_test.go (0 hunks)
  • x/crosschain/precompile/expected_keepers.go (1 hunks)
  • x/crosschain/precompile/increase_bridge_fee.go (0 hunks)
  • x/crosschain/precompile/increase_bridgefee_test.go (0 hunks)
  • x/crosschain/precompile/keeper.go (1 hunks)
  • x/crosschain/types/events.go (0 hunks)
  • x/crosschain/types/key.go (1 hunks)
  • x/crosschain/types/msgs.go (0 hunks)
  • x/crosschain/types/msgs_test.go (0 hunks)
  • x/crosschain/types/params.go (0 hunks)
  • x/crosschain/types/types.go (0 hunks)
  • x/tron/keeper/grpc_query_test.go (8 hunks)
💤 Files with no reviewable changes (29)
  • app/interface_registry.json
  • solidity/contracts/bridge/ICrossChain.sol
  • solidity/contracts/test/CrossChainTest.sol
  • tests/crosschain_suite.go
  • tests/crosschain_test.go
  • tests/integration_test.go
  • tests/precompile_suite.go
  • x/crosschain/keeper/batch_fee.go
  • x/crosschain/keeper/batch_test.go
  • x/crosschain/keeper/bridge_call_out.go
  • x/crosschain/keeper/bridge_call_out_test.go
  • x/crosschain/keeper/bridge_token.go
  • x/crosschain/keeper/genesis.go
  • x/crosschain/keeper/genesis_test.go
  • x/crosschain/keeper/msg_server_router.go
  • x/crosschain/keeper/msg_server_test.go
  • x/crosschain/keeper/outgoing_pool.go
  • x/crosschain/keeper/outgoing_pool_test.go
  • x/crosschain/precompile/cancel_send_to_external.go
  • x/crosschain/precompile/cancel_send_to_external_test.go
  • x/crosschain/precompile/contract.go
  • x/crosschain/precompile/crosschain_test.go
  • x/crosschain/precompile/increase_bridge_fee.go
  • x/crosschain/precompile/increase_bridgefee_test.go
  • x/crosschain/types/events.go
  • x/crosschain/types/msgs.go
  • x/crosschain/types/msgs_test.go
  • x/crosschain/types/params.go
  • x/crosschain/types/types.go
🧰 Additional context used
🔇 Additional comments (22)
docs/swagger-ui/swagger.yaml (1)

Line range hint 1-44102: Overall, excellent refactoring of the API specification.

The changes made to the swagger.yaml file represent a significant improvement in the API design and align well with the PR objective of removing batch bridge fee logic. The new structure is more logical, consistent, and easier to understand. Key improvements include:

  1. Clearer separation of single and multiple batch retrieval endpoints.
  2. Introduction of a new bridge_call_by_nonce endpoint to replace the previous batch fees endpoint.
  3. Addition of a projected_batch_timeout endpoint for better batch management.
  4. Consistent and well-structured response schemas across all endpoints.

The minor suggestions provided in the previous comments, if implemented, would further enhance the clarity and usability of the API documentation.

Great job on this refactoring effort!

app/encoding_test.go (1)

46-46: Verify the reduction in interface count and update documentation if needed.

The change from 303 to 300 in the expected count of implementation interfaces aligns with the PR objective of removing batch bridge fee logic. This reduction indicates that some interfaces have been removed from the system.

To ensure consistency across the codebase:

  1. Verify that this change is reflected in other parts of the code where these interfaces might have been used.
  2. Update any relevant documentation that might reference the removed interfaces or the total count of interfaces.

Run the following script to check for any remaining references to the removed interfaces:

If you find any inconsistencies or outdated references, please update them accordingly.

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

59-59: LGTM: Changes align with PR objectives

The modification of the CrosschainKeeper interface, specifically the replacement of AddToOutgoingPool with BuildOutgoingTxBatch, aligns with the PR objective of removing batch bridge fee logic. This change suggests a shift in how outgoing transactions are processed, potentially moving towards a more efficient batching mechanism.

To ensure consistency across the codebase, please run the following verification scripts:

Please review the output of these scripts to ensure that:

  1. There are no remaining references to the removed methods.
  2. The new BuildOutgoingTxBatch method is being used appropriately.
  3. There are no lingering references to the old AddToOutgoingPool method.

If any inconsistencies are found, they should be addressed to maintain the integrity of the codebase.

✅ Verification successful

**** The changes have been successfully verified. No lingering references to the removed methods were found, and the new BuildOutgoingTxBatch method is utilized appropriately across the codebase.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any remaining references to removed methods and verify usage of the new method.

# Test 1: Search for references to removed methods
echo "Searching for references to removed methods..."
rg --type go 'RemoveFromOutgoingPoolAndRefund|AddUnbatchedTxBridgeFee'

# Test 2: Verify usage of the new BuildOutgoingTxBatch method
echo "Verifying usage of BuildOutgoingTxBatch method..."
rg --type go 'BuildOutgoingTxBatch'

# Test 3: Check for any remaining references to AddToOutgoingPool
echo "Checking for remaining references to AddToOutgoingPool..."
rg --type go 'AddToOutgoingPool'

Length of output: 1062

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

76-76: Update handling of MsgSendToExternalResponse

The field in MsgSendToExternalResponse has been changed from outgoing_tx_id to batch_nonce. This change suggests a shift in how transactions are identified or grouped, possibly indicating that transactions are now processed in batches rather than individually.

To ensure all references are updated, please run the following script:

#!/bin/bash
# Search for references to outgoing_tx_id in the codebase
rg --type-add 'proto:*.proto' --type proto --type go 'outgoing_tx_id'

63-63: Update references to MsgSendToExternal

The deprecation notice for MsgSendToExternal has been updated to recommend using "precompile BridgeCall" instead of "MsgBridgeCall". This change suggests a shift in the recommended approach for this functionality.

To ensure consistency, please run the following script to check for any remaining references to MsgBridgeCall:

✅ Verification successful

No remaining references to MsgBridgeCall found

All references to MsgBridgeCall have been successfully removed from the codebase, confirming that the deprecation of MsgSendToExternal is properly handled. No further action is required.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for references to MsgBridgeCall in the codebase
rg --type-add 'proto:*.proto' --type proto --type go 'MsgBridgeCall'

Length of output: 322

tests/precompile_test.go (2)

28-30: Verify the removal of cross-chain transfer test cases.

The commented out lines suggest that cross-chain transfer functionality is no longer being tested in this method. While this aligns with the PR objective of removing batch bridge fee logic, it's crucial to ensure that we're not leaving critical functionality untested.

Could you please confirm if these test cases are being replaced by alternative tests elsewhere? If not, consider adding appropriate test coverage for the remaining cross-chain transfer functionality.

✅ Verification successful

Cross-chain transfer test coverage confirmed elsewhere.

The search results indicate that cross-chain transfer related test cases are present in other test files, such as tests/integration_test.go and tests/crosschain_test.go. This ensures that the removal of these test cases from tests/precompile_test.go does not leave critical functionality untested.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any new or modified test cases related to cross-chain transfers
rg --type go -e "func.*CrossChain.*Test" --stats

Length of output: 7480


44-46: Verify the purpose of the remaining code in PrecompileCrossChainTest.

With the removal of the cross-chain transfer test cases, it appears that this method may no longer be fully testing its intended functionality.

Please review the remaining code in this method and consider the following:

  1. Does the method still serve a purpose without the cross-chain transfer tests?
  2. If so, should the method be renamed to reflect its new purpose?
  3. If not, should the entire method be removed?
proto/fx/gravity/crosschain/v1/tx.proto (1)

26-28: Approved: OracleSetConfirm deprecation aligns with refactoring goals.

The deprecation of OracleSetConfirm and the suggestion to use Confirm instead is a good step towards simplifying the API. This change aligns well with the PR objective to remove batch bridge fee logic.

To ensure a smooth transition, please run the following script to check for any remaining usages of OracleSetConfirm in the codebase:

#!/bin/bash
# Search for OracleSetConfirm usages
rg --type proto --type go "OracleSetConfirm"
x/crosschain/keeper/grpc_query_router.go (2)

94-100: Approve refactoring of batch querying functionality.

The renaming from BatchRequestByNonce to OutgoingTxBatch improves clarity and aligns with the removal of BatchFees. The core logic remains intact, maintaining the pattern used throughout the file.

To ensure this change doesn't introduce issues elsewhere in the codebase, please run the following script:

This will help identify any places where the old method name is still being used and confirm that the new method name is being used correctly.

✅ Verification successful

Approve refactoring of batch querying functionality.

The removal of BatchRequestByNonce was successful with no remaining references, and the new OutgoingTxBatch method is consistently used across the codebase. This refactoring enhances clarity and maintains existing functionality.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any remaining references to BatchRequestByNonce

# Search for any remaining references to BatchRequestByNonce
echo "Searching for remaining references to BatchRequestByNonce:"
rg --type go "BatchRequestByNonce"

# Search for usage of the new OutgoingTxBatch method
echo "Searching for usage of the new OutgoingTxBatch method:"
rg --type go "OutgoingTxBatch"

Length of output: 36236


Line range hint 1-1: Verify impact of removing BatchFees method.

The removal of the BatchFees method aligns with the PR objective to remove batch bridge fee logic. However, this change may have broader implications on the system.

Please run the following script to identify any remaining references to BatchFees and ensure that all related functionality has been properly addressed:

Additionally, please confirm that:

  1. Any code that previously relied on batch fee information has been updated or removed.
  2. The removal of batch fees doesn't introduce any inconsistencies in the fee handling logic.
  3. Documentation and API specifications have been updated to reflect this change.
x/crosschain/client/cli/query.go (3)

Line range hint 540-556: LGTM! Great addition for querying all outgoing tx batches.

The CmdOutgoingTxBatches function is a well-implemented new command that allows querying all outgoing transaction batches. This is a valuable addition to the CLI, providing users with a comprehensive view of all pending outgoing transactions.


Line range hint 1-956: Removal of deprecated functions aligns with PR objectives.

The removal of CmdGetPendingSendToExternal and CmdGetBatchFees functions is in line with the PR objective of removing batch bridge fee logic. This simplification of the CLI removes potentially outdated or unnecessary functionality, contributing to a cleaner and more focused codebase.


Line range hint 1-956: Overall changes improve and streamline the cross-chain CLI queries.

The modifications in this file successfully refactor the outgoing transaction batch queries, aligning with the PR objectives. The addition of CmdOutgoingTxBatch and CmdOutgoingTxBatches provides more comprehensive and flexible ways to query outgoing transaction batches. Simultaneously, the removal of deprecated functions related to batch fees (CmdGetPendingSendToExternal and CmdGetBatchFees) simplifies the module and removes outdated functionality.

These changes contribute to a more focused and efficient CLI for cross-chain operations, improving the overall user experience and maintainability of the codebase.

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

56-70: Verify the correctness of telemetry metrics implementation

Telemetry metrics have been added to track outgoing transactions. Please ensure that these metrics accurately capture the intended data and that all labels and values are correct. Additionally, consider error handling in case telemetry recording fails.

Run the following script to check for proper usage of telemetry functions:

#!/bin/bash
# Description: Verify telemetry function calls for correctness.

# Search for telemetry function usage in Go files
rg --type go 'telemetry\.[A-Za-z]+\(' -A 2

15-15: Update all references to BuildOutgoingTxBatch with the new signature

The function BuildOutgoingTxBatch has changed its signature. Ensure that all calls to this function across the codebase are updated to match the new parameters to prevent any compilation or runtime errors.

Run the following script to find all usages of BuildOutgoingTxBatch and verify that they have been updated:

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

207-209: Deprecation of GetTokenToDenomKey is properly indicated.

The function GetTokenToDenomKey is correctly marked as deprecated. This clear documentation will help developers avoid using outdated functions.

x/crosschain/client/cli/tx.go (1)

298-298: Consistent Method Calls on Renamed Variable

Ensure that method calls on the renamed variable outgoingTxBatchResp are correctly updated. In this line, the method chain should reflect the new variable name:

proto/fx/gravity/crosschain/v1/query.proto (3)

65-65: Updated HTTP GET endpoint for OutgoingTxBatches

The HTTP GET endpoint has been updated to /fx/crosschain/v1/batch/outgoing_txs, which accurately reflects the plural form and improves clarity.


207-210: Definition of QueryOutgoingTxBatchRequest is appropriate

The request message QueryOutgoingTxBatchRequest includes necessary fields (chain_name, token_contract, and nonce) to uniquely identify an outgoing transaction batch.


212-212: Definition of QueryOutgoingTxBatchResponse is appropriate

The response message QueryOutgoingTxBatchResponse contains an OutgoingTxBatch, which correctly represents the batch details.

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

Line range hint 389-401: BridgeCall method implementation looks good

The BridgeCall function is correctly implemented and follows the required patterns for handling bridge calls, including error handling and event emission.

tests/contract/CrossChainTest.go (1)

34-35: ABI and Binary Metadata Updated Correctly

The ABI and Bin fields in CrossChainTestMetaData have been appropriately updated to reflect the removal of the CancelSendToExternal and IncreaseBridgeFee functions. This ensures that the contract bindings are consistent with the updated contract interface.

app/app_test.go Show resolved Hide resolved
docs/swagger_test.go Show resolved Hide resolved
tests/precompile_test.go Show resolved Hide resolved
x/crosschain/precompile/keeper.go Show resolved Hide resolved
proto/fx/gravity/crosschain/v1/tx.proto Show resolved Hide resolved
x/crosschain/keeper/msg_server.go Show resolved Hide resolved
x/crosschain/keeper/msg_server.go Show resolved Hide resolved
x/crosschain/keeper/msg_server.go Show resolved Hide resolved
x/crosschain/keeper/msg_server.go Show resolved Hide resolved
contract/ICrossChain.go Show resolved Hide resolved
@zakir-code zakir-code merged commit ebd652f into main Oct 11, 2024
16 checks passed
@zakir-code zakir-code deleted the zakir/crosschain branch October 11, 2024 03:55
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