-
Notifications
You must be signed in to change notification settings - Fork 14
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(proto): generate pulsar protobuf files #742
Conversation
WalkthroughThe changes in this pull request include updates to a Changes
Poem
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? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 16
🧹 Outside diff range and nitpick comments (9)
Makefile (1)
Line range hint
214-217
: New statik installation target is a good addition.The new target ensures that the statik tool is installed, which is used in the
update-swagger-docs
target. This is a good practice to make sure all necessary tools are available.Consider pinning the statik version to ensure consistency across different environments:
$(STATIK): @echo "Installing statik..." - @go install github.com/rakyll/statik@latest + @go install github.com/rakyll/[email protected] # Replace with the desired versionapi/fx/migrate/v1/migrate.pulsar.go (1)
1-696
: Consider excluding generated code from version controlIncluding generated code in the repository can lead to increased repository size and potential merge conflicts. It might be beneficial to exclude generated files from version control and generate them during the build process.
api/fx/evm/v1/tx.pulsar.go (2)
945-946
: Improve the comment for the 'ContractAddress' field.The current comment for
ContractAddress
can be made clearer:// specify to call the contract address
Consider rephrasing it for better clarity and to follow Go documentation conventions.
Apply this diff to improve the comment:
-// specify to call the contract address +// ContractAddress specifies the address of the contract to call.
1-1134
: Consider excluding generated code from version control.This file is generated code, as indicated by the comment on line 1:
// Code generated by protoc-gen-go-pulsar. DO NOT EDIT.
Including generated code in version control can lead to:
- Merge conflicts when regenerated by multiple developers.
- Increased repository size due to potentially large generated files.
- Duplication of source of truth, since the actual source is the
.proto
files.It's a common best practice to exclude generated code from version control and instead generate it as part of the build or CI process.
[best_practice]
api/fx/erc20/v1/genesis.pulsar.go (1)
1-2
: Note on Reviewing Generated CodeThis file is generated by
protoc-gen-go-pulsar
as indicated by the comment on line 1. Generally, generated code should not be manually modified, and code reviews should focus on the source.proto
files or the code generation process if there are issues with the generated output.api/fx/ibc/applications/transfer/v1/ibc_legacy.pulsar.go (2)
1515-1536
: Clarify field comments inMsgTransfer
structSeveral fields in the
MsgTransfer
struct have comments that could be improved for clarity:
Router field (line 1531):
Current comment:
// the router is hook destination chain
Suggested revision:
-// the router is hook destination chain +// The router address on the destination chain for handling transfer hooksFee field (line 1534):
Current comment:
// the tokens to be destination fee
Suggested revision:
-// the tokens to be destination fee +// The fee to be paid to the destination chain for processing the transferMemo field (line 1536):
Current comment:
// optional memo
Suggested revision:
-// optional memo +// An optional memo to include with the transferUpdating these comments will enhance readability and understanding of the code.
1644-1647
: Enhance documentation forHeight
fieldsThe
Height
struct fields lack detailed descriptions. Providing clear comments will improve code maintainability:
RevisionNumber field (line 1645):
Current comment:
// the revision that the client is currently on
Suggested revision:
-// the revision that the client is currently on +// RevisionNumber represents the revision number of the blockchain. It is used to differentiate between different chains or forks.RevisionHeight field (line 1646):
Current comment:
// the height within the given revision
Suggested revision:
-// the height within the given revision +// RevisionHeight represents the block height within the given revision.Adding these details will help developers understand the purpose of each field.
api/fx/gov/v1/query.pulsar.go (1)
393-402
: RedundantslowProtoReflect()
MethodThe
slowProtoReflect()
method may be unnecessary sinceProtoReflect()
is already implemented:func (x *QuerySwitchParamsRequest) slowProtoReflect() protoreflect.Message { // Implementation details... }If
slowProtoReflect()
is not required, consider removing it to simplify the codebase.api/fx/gov/v1/params.pulsar.go (1)
1917-1918
: Incomplete comment forDepositRatio
fieldThe comment for the
DepositRatio
field seems incomplete: "For EGF parameters, what percentage of deposit is required to enter the". Please complete the comment to provide full context.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
⛔ Files ignored due to path filters (21)
api/fx/auth/v1/query_grpc.pb.go
is excluded by!**/*.pb.go
api/fx/base/v1/legacy_grpc.pb.go
is excluded by!**/*.pb.go
api/fx/erc20/v1/query_grpc.pb.go
is excluded by!**/*.pb.go
api/fx/erc20/v1/tx_grpc.pb.go
is excluded by!**/*.pb.go
api/fx/evm/v1/tx_grpc.pb.go
is excluded by!**/*.pb.go
api/fx/gov/v1/query_grpc.pb.go
is excluded by!**/*.pb.go
api/fx/gov/v1/tx_grpc.pb.go
is excluded by!**/*.pb.go
api/fx/gravity/crosschain/v1/query_grpc.pb.go
is excluded by!**/*.pb.go
api/fx/gravity/crosschain/v1/tx_grpc.pb.go
is excluded by!**/*.pb.go
api/fx/migrate/v1/query_grpc.pb.go
is excluded by!**/*.pb.go
api/fx/migrate/v1/tx_grpc.pb.go
is excluded by!**/*.pb.go
api/fx/other/legacy_grpc.pb.go
is excluded by!**/*.pb.go
proto/buf.lock
is excluded by!**/*.lock
types/legacy/evm_proposal_testnet.pb.go
is excluded by!**/*.pb.go
types/legacy/gravity_legacy.pb.go
is excluded by!**/*.pb.go
types/legacy/ibc_legacy.pb.go
is excluded by!**/*.pb.go
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/types.pb.go
is excluded by!**/*.pb.go
x/gov/types/tx.pb.go
is excluded by!**/*.pb.go
x/migrate/types/query.pb.go
is excluded by!**/*.pb.go
📒 Files selected for processing (12)
- Makefile (1 hunks)
- api/fx/auth/v1/query.pulsar.go (1 hunks)
- api/fx/base/v1/legacy.pulsar.go (1 hunks)
- api/fx/erc20/v1/genesis.pulsar.go (1 hunks)
- api/fx/evm/v1/tx.pulsar.go (1 hunks)
- api/fx/gov/v1/params.pulsar.go (1 hunks)
- api/fx/gov/v1/query.pulsar.go (1 hunks)
- api/fx/gravity/crosschain/v1/genesis.pulsar.go (1 hunks)
- api/fx/ibc/applications/transfer/v1/call.pulsar.go (1 hunks)
- api/fx/ibc/applications/transfer/v1/ibc_legacy.pulsar.go (1 hunks)
- api/fx/migrate/v1/genesis.pulsar.go (1 hunks)
- api/fx/migrate/v1/migrate.pulsar.go (1 hunks)
🧰 Additional context used
🔇 Additional comments (12)
Makefile (2)
Line range hint
1-365
: Overall, the changes to the Makefile are minimal and beneficial.The updates to the Protobuf version and the addition of the statik installation target improve the build process and dependency management. These changes don't introduce any significant risks or alterations to the overall functionality of the Makefile.
To ensure everything works as expected after these changes, it's recommended to:
- Run a full build and test cycle.
- Verify that the Protobuf generation process works correctly with the new version.
- Confirm that the Swagger documentation is generated successfully using the new statik installation.
193-193
: Protobuf version update looks good.The Protobuf version has been updated from 0.13.0 to 0.14.0. This minor version update is likely to introduce new features or bug fixes.
Please ensure that this update is compatible with the rest of the project. You can verify this by running the following commands:
api/fx/migrate/v1/genesis.pulsar.go (1)
1-3
: Generated code noticeThe file starts with a code generation notice from
protoc-gen-go-pulsar
, indicating that it is generated code and should not be edited manually.api/fx/migrate/v1/migrate.pulsar.go (2)
560-609
: LGTM:MigrateRecord
struct definition is correctThe definition of
MigrateRecord
and its associated methods are correctly generated and adhere to protobuf standards.
1-696
: Verify the integration of code generated by multiple toolsThis file contains code generated by both
protoc-gen-go-pulsar
andprotoc-gen-go
. Please verify that combining code from multiple generators does not introduce conflicts, especially with type definitions and method implementations.Run the following script to check for multiple definitions of
MigrateRecord
:✅ Verification successful
✅ Verification Successful: No Conflicts Detected
The
MigrateRecord
struct is defined in separate packages (migratev1
andtypes
), ensuring that combining code generated byprotoc-gen-go-pulsar
andprotoc-gen-go
does not introduce any conflicts with type definitions or method implementations.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Search for all definitions of 'type MigrateRecord struct' in the Go codebase. # Command: Search for the type definition of MigrateRecord rg --type go "^type MigrateRecord struct" # Expectation: Only one definition should be found.Length of output: 165
Script:
#!/bin/bash # Description: Extract and display the 'MigrateRecord' struct definitions from both files for comparison. # Extract 'MigrateRecord' struct from migrate.pulsar.go echo "Definition in api/fx/migrate/v1/migrate.pulsar.go:" sed -n '/type MigrateRecord struct {/,/^}/p' api/fx/migrate/v1/migrate.pulsar.go echo "" # Extract 'MigrateRecord' struct from migrate.pb.go echo "Definition in x/migrate/types/migrate.pb.go:" sed -n '/type MigrateRecord struct {/,/^}/p' x/migrate/types/migrate.pb.goLength of output: 1029
Script:
#!/bin/bash # Description: Extract and display the package declarations from both files to verify if they are in the same package. echo "Package declaration in api/fx/migrate/v1/migrate.pulsar.go:" sed -n 's/^package\s\+\(\w\+\).*/\1/p' api/fx/migrate/v1/migrate.pulsar.go echo "" echo "Package declaration in x/migrate/types/migrate.pb.go:" sed -n 's/^package\s\+\(\w\+\).*/\1/p' x/migrate/types/migrate.pb.goLength of output: 420
api/fx/ibc/applications/transfer/v1/call.pulsar.go (1)
629-631
: Consider verifying the field types in theIbcCallEvmPacket
structThe fields
To
,Data
, andValue
in theIbcCallEvmPacket
struct are defined asstring
types with Protobuf tags indicating thebytes
type:To string `protobuf:"bytes,1,opt,name=to,proto3" json:"to,omitempty"` Data string `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` Value string `protobuf:"bytes,3,opt,name=value,proto3" json:"value,omitempty"`If these fields are intended to represent binary data, it may be more appropriate to use
[]byte
instead ofstring
in Go to safely handle arbitrary binary data. Usingstring
for binary data can lead to issues with encoding, especially if the data contains invalid UTF-8 sequences.Please confirm whether the Protobuf definitions for these fields specify the
bytes
type. If so, consider regenerating the Go code to correctly map these fields to[]byte
.Run the following script to check the Protobuf definitions for these fields:
#!/bin/bash # Description: Search the Protobuf definition files for the `IbcCallEvmPacket` message. # Find the Protobuf message definition of `IbcCallEvmPacket`. rg --type proto 'message IbcCallEvmPacket' -A 10 # Search for the field types within the `IbcCallEvmPacket` message. rg --type proto -A 3 'message IbcCallEvmPacket' | rg '^\s+\w+\s+\w+'This script will help you verify the field types specified in the Protobuf definitions.
api/fx/base/v1/legacy.pulsar.go (1)
1-1
: Note: This file is auto-generatedThis file is generated by
protoc-gen-go-pulsar
. Manual edits to this file may be overwritten. Please ensure that any changes are made in the source.proto
files and then regenerate the code.api/fx/auth/v1/query.pulsar.go (1)
1-1
: Generated Code Should Not Be Manually EditedThe file is auto-generated by
protoc-gen-go-pulsar
as indicated by the header comment. Any changes should be made in the corresponding.proto
files, not directly in this generated code.api/fx/gov/v1/query.pulsar.go (3)
1-1
: 🛠️ Refactor suggestionConsider Excluding Generated Code from Version Control
The file begins with
// Code generated by protoc-gen-go-pulsar. DO NOT EDIT.
, indicating it's auto-generated. Including generated code in version control can lead to large diffs and merge conflicts. It's generally a best practice to generate these files during the build process instead.Would you like to adjust the build process to generate this code dynamically and exclude it from version control?
1663-1667
:⚠️ Potential issueInconsistent Code Generation Tools Detected
At line 1663, there's another header:
// Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.27.0 // protoc (unknown) // source: fx/gov/v1/query.protoThis suggests that both
protoc-gen-go-pulsar
andprotoc-gen-go
were used to generate this file. Mixing different code generators may introduce inconsistencies or unexpected behaviors.Please confirm if both generators are intended. If not, consider using a single code generator for consistency.
1903-1977
: Ensure Initialization of Proto Message TypesThe
init()
function is defined multiple times to initialize message types:func init() { file_fx_gov_v1_query_proto_init() // Additional initialization... }Ensure that all proto message types are properly initialized to prevent potential runtime issues.
api/fx/gravity/crosschain/v1/genesis.pulsar.go (1)
1950-2095
: Validate theGenesisState
struct for completenessThe
GenesisState
struct is crucial for the initialization and management of the cross-chain oracle system. Ensure that all necessary fields are included and correctly typed. The current definition appears comprehensive, but double-check for any missing parameters or recent updates in the protocol that might require additional fields.Run the following script to compare the
GenesisState
struct with the latest Protobuf definition:✅ Verification successful
GenesisState struct is complete and matches the Protobuf definition.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Compare the `GenesisState` struct fields with the Protobuf definition to ensure completeness. # Test: List fields in the Go struct. echo "Fields in Go struct:" grep -A 20 'type GenesisState struct' api/fx/gravity/crosschain/v1/genesis.pulsar.go | grep -E '^\s+\w+' # Test: List fields in the Protobuf file. echo "Fields in Protobuf definition:" grep -A 50 'message GenesisState' api/fx/gravity/crosschain/v1/genesis.proto | grep -E '^\s+\w+' # Expected result: Both lists should match in field names and types.Length of output: 2908
Script:
#!/bin/bash # Description: Locate the `genesis.proto` file in the repository. echo "Searching for genesis.proto files:" fd 'genesis\.proto$'Length of output: 212
Script:
#!/bin/bash # Description: Compare the `GenesisState` struct fields with the Protobuf definition to ensure completeness. # Test: List fields in the Go struct. echo "Fields in Go struct:" grep -A 20 'type GenesisState struct' api/fx/gravity/crosschain/v1/genesis.pulsar.go | grep -E '^\s+\w+' # Test: List fields in the Protobuf file. echo "Fields in Protobuf definition:" grep -A 50 'message GenesisState' proto/fx/gravity/crosschain/v1/genesis.proto | grep -E '^\s+\w+' # Expected result: Both lists should match in field names and types.Length of output: 3766
Summary by CodeRabbit
New Features
Bug Fixes
Documentation