Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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: reimplement BridgeTokens gRPC query #748
refactor: reimplement BridgeTokens gRPC query #748
Changes from all commits
f095bfe
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codebase verification
Deprecated
MsgBridgeCallConfirmResponse
is Still Referencedproto/fx/gravity/crosschain/v1/tx.proto
🔗 Analysis chain
Verify usage of deprecated
MsgBridgeCallConfirmResponse
The
MsgBridgeCallConfirmResponse
message is marked as deprecated. Please confirm that all references to this message in the codebase have been properly updated or handled to prevent unintended usage.Run the following script to identify any remaining usages:
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
Length of output: 76
Script:
Length of output: 247
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid adding new messages that are immediately deprecated
The
BridgeToken
message is added and immediately marked as deprecated. This could cause confusion for developers and users of the API. If these messages are no longer intended for use, consider not adding them at all or providing a clear rationale for their inclusion and immediate deprecation.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reevaluate the addition of deprecated messages
Similarly, the
BatchFees
message is introduced with a deprecation notice. Adding new messages that are deprecated from the outset may lead to maintenance challenges and confusion. Ensure that adding these messages is necessary and that there is documentation explaining their purpose despite being deprecated.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clarify the necessity of deprecated
MinBatchFee
messageThe
MinBatchFee
message is also added and marked as deprecated immediately. Please verify whether this message is required. If it is included for backward compatibility or future use, provide appropriate documentation.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check the use of nullable option on repeated fields
In the
QueryBatchFeeRequest
message, the fieldmin_batch_fees
is defined as:Setting
(gogoproto.nullable) = false
on arepeated
field may be unnecessary, asrepeated
fields are lists and are not nullable by default in Protobuf. Consider removing this option to avoid potential issues with code generation and serialization.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assess the immediate deprecation of
QueryBatchFeeResponse
The
QueryBatchFeeResponse
message is added and marked as deprecated. If this message is no longer needed, consider excluding it entirely. If it must be included, ensure that its deprecation status and purpose are clearly documented to aid developers.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codebase verification
Inconsistent
GetBridgeToken
Parameter Order DetectedThe verification script identified multiple calls to
GetBridgeToken
with varying second parameters. While some instances correctly usemoduleName
, others usechainName
, which may lead to inconsistencies and potential runtime errors. Please ensure that all calls passmoduleName
as the second parameter to maintain consistency across the codebase.🔗 Analysis chain
LGTM. Verify consistent application of parameter reordering.
The change in the order of parameters for
k.erc20Keeper.GetBridgeToken
looks good and aligns with the reported modifications. However, it's crucial to ensure this change has been consistently applied across all calls toGetBridgeToken
in the codebase to prevent potential runtime errors.To verify the consistent application of this change, run the following script:
If the script returns any results, those might be instances where the parameter reordering hasn't been applied and should be addressed.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
Length of output: 1685
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Refine error handling for
GetBridgeTokens
to provide more specific gRPC error codes.Currently, any error from
k.erc20Keeper.GetBridgeTokens(c, req.ChainName)
results in anInternal
error code. Consider returning more specific error codes based on the nature of the error (e.g.,codes.NotFound
if the chain name is not found, orcodes.InvalidArgument
if the chain name is invalid) to offer clearer feedback to clients.Apply this diff to enhance error handling:
Ensure that
types.ErrChainNotFound
andtypes.ErrInvalidChainName
are the actual error variables used in your codebase to represent these error conditions.📝 Committable suggestion
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codebase verification
Inconsistent Parameter Order in GetBridgeToken Calls
The following instances of
GetBridgeToken
still use the old parameter order and need to be updated:x/crosschain/keeper/bridge_token.go
:x/crosschain/keeper/many_to_one.go
:🔗 Analysis chain
LGTM. Verify consistency across the codebase.
The change in parameter order for the
GetBridgeToken
call looks good. This appears to be part of a larger refactoring effort to standardize parameter order.To ensure consistency, please run the following script to check for any remaining instances of the old parameter order:
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
Length of output: 2587
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codebase verification
Inconsistent
GetBridgeToken
Method Signatures DetectedMultiple instances of
GetBridgeToken
have been found with differing parameter counts:Two Parameters:
x/crosschain/keeper/many_to_one.go: GetBridgeToken(ctx, tokenAddr)
x/crosschain/keeper/many_to_one.go: func (k Keeper) GetBridgeToken(ctx context.Context, tokenAddr string) (erc20types.BridgeToken, error)
Three Parameters (Updated Order):
(ctx context.Context, chainName, baseDenom string)
This inconsistency may lead to potential bugs or runtime errors.
🔗 Analysis chain
Approve parameter reordering for
GetBridgeToken
The reordering of parameters from
(ctx context.Context, baseDenom, chainName string)
to(ctx context.Context, chainName, baseDenom string)
improves readability and consistency. It follows a logical order from broader (chainName) to more specific (baseDenom).Please ensure all calls to this method throughout the codebase are updated to reflect this change. Run the following script to identify potential places that need updating:
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
Length of output: 832
Script:
Length of output: 1449
Script:
Length of output: 1449