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

fix: remove denom from query path #123

Merged
merged 3 commits into from
Nov 15, 2024
Merged

Conversation

beer-1
Copy link
Member

@beer-1 beer-1 commented Nov 11, 2024

Description

Closes: #XXXX


Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • included the correct type prefix in the PR title, you can find examples of the prefixes below:
  • confirmed ! in the type prefix if API or client breaking change
  • targeted the correct branch
  • provided a link to the relevant issue or specification
  • reviewed "Files changed" and left comments if necessary
  • included the necessary unit and integration tests
  • updated the relevant documentation or specification, including comments for documenting Go code
  • confirmed all CI checks have passed

Reviewers Checklist

All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic, API design and naming, documentation is accurate, tests and test coverage

Summary by CodeRabbit

  • New Features

    • Introduced new message types for querying validators and bridge information.
    • Added a new field HookMaxGas to specify the maximum gas limit for hook execution.
    • Updated BaseDenom endpoint to simplify requests.
  • Bug Fixes

    • Updated pagination handling in response structures to improve data retrieval.
  • Chores

    • Updated Go version and dependencies for improved compatibility and security.

@beer-1 beer-1 self-assigned this Nov 11, 2024
@beer-1 beer-1 requested a review from a team as a code owner November 11, 2024 08:32
Copy link

coderabbitai bot commented Nov 11, 2024

Walkthrough

This pull request introduces several modifications to the query.pulsar.go and types.pulsar.go files, enhancing the message types for querying validators, bridge information, and parameters in a blockchain context. Key updates include the addition of new request and response types, changes to existing structures, and the introduction of a HookMaxGas field in the Params struct. Additionally, the go.mod file is updated to reflect a new Go version and changes in dependency versions, while the query.proto file modifies the HTTP endpoint for the BaseDenom method.

Changes

File Change Summary
api/opinit/opchild/v1/query.pulsar.go - Added new request/response message types for querying validators, bridge info, and parameters.
- Updated QueryValidatorsResponse, QueryValidatorResponse, QueryBridgeInfoResponse, QueryParamsResponse, QueryNextL1SequenceResponse, QueryNextL2SequenceResponse, QueryBaseDenomResponse structures.
- Added various getter methods for new fields.
api/opinit/opchild/v1/types.pulsar.go - Added HookMaxGas field to Params struct and its corresponding getter method GetHookMaxGas().
- Updated methods of fastReflection_Params to handle HookMaxGas.
go.mod - Updated Go version from 1.22.2 to 1.23.0.
- Incremented github.com/initia-labs/OPinit/api module version from v0.5.1 to v0.5.8.
- Adjusted various replace directives for dependencies.
proto/opinit/opchild/v1/query.proto - Modified the HTTP GET endpoint for the BaseDenom RPC method from "/opinit/opchild/v1/base_denom/{denom}" to "/opinit/opchild/v1/base_denom", removing the path parameter.

Possibly related PRs

  • feat: introduce hook max gas #119: The changes in this PR introduce a new hook_max_gas parameter in the Params struct, which is directly related to the modifications in the main PR that also involve handling gas limits for various operations, including the FinalizeTokenDeposit process.

Suggested reviewers

  • sh-cha

Poem

In the code where rabbits play,
New messages hop in, hooray!
Gas limits set, the queries flow,
With each change, our knowledge grows.
From validators to bridges wide,
In this code, we take great pride! 🐇✨


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

codecov bot commented Nov 11, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 49.37%. Comparing base (3965ef4) to head (a45081a).
Report is 2 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #123   +/-   ##
=======================================
  Coverage   49.37%   49.37%           
=======================================
  Files          57       57           
  Lines        4249     4249           
=======================================
  Hits         2098     2098           
  Misses       1721     1721           
  Partials      430      430           

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

🧹 Outside diff range and nitpick comments (4)
go.mod (2)

Line range hint 3-5: Fix Go version inconsistency.

There's an inconsistency between the go directive (1.22.2) and the toolchain directive (1.23.0). This could lead to build issues or unexpected behavior.

Apply this diff to align the versions:

-go 1.22.2
+go 1.23.0

toolchain go1.23.0

Line range hint 246-248: Document temporary dependency override.

The custom fork of cometbft-client is used as a temporary solution. Consider adding a TODO comment to track when this can be reverted.

Add a TODO comment to track the temporary nature of this override:

 // use custom version until this PR is merged
 // - https://github.com/strangelove-ventures/cometbft-client/pull/10
+// TODO: Remove this override once PR #10 is merged
 replace github.com/strangelove-ventures/cometbft-client => github.com/initia-labs/cometbft-client v0.0.0-20240924071428-ef115cefa07e
api/opinit/opchild/v1/query.pulsar.go (2)

Line range hint 4-4: Documentation Update Needed

The TODO comment about adding tests should be addressed, especially since this is a query interface that clients depend on.

Would you like me to help create a test template for these query methods?


Line range hint 12-24: Consider Adding Response Validation

The query response messages don't have any validation logic. Consider adding validation for critical fields, especially for responses that include addresses or numeric values.

Example validation could include:

  • Non-negative sequence numbers
  • Well-formed addresses
  • Non-empty required fields
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 3965ef4 and a45081a.

⛔ Files ignored due to path filters (2)
  • x/opchild/types/query.pb.go is excluded by !**/*.pb.go
  • x/opchild/types/query.pb.gw.go is excluded by !**/*.pb.gw.go
📒 Files selected for processing (4)
  • api/opinit/opchild/v1/query.pulsar.go (2 hunks)
  • api/opinit/opchild/v1/types.pulsar.go (16 hunks)
  • go.mod (1 hunks)
  • proto/opinit/opchild/v1/query.proto (1 hunks)
🔇 Additional comments (9)
proto/opinit/opchild/v1/query.proto (2)

57-57: Implementation aligns with PR objectives

The change successfully removes "denom" from the query path as intended in the PR title "fix: remove denom from query path". The implementation moves the parameter to what appears to be a query parameter, which is a cleaner approach for optional parameters.


57-57: ⚠️ Potential issue

Breaking Change: API endpoint modification

The modification of the BaseDenom endpoint from /opinit/opchild/v1/base_denom/{denom} to /opinit/opchild/v1/base_denom is a breaking change that will affect existing API clients. While moving from path parameter to query parameter is valid, this change requires careful consideration of backward compatibility.

Let's verify the impact on existing API clients:

Consider the following recommendations:

  1. Document this breaking change in the changelog
  2. Consider implementing an API version upgrade strategy
  3. Update API documentation to reflect the new endpoint structure

Would you like me to help draft the changelog entry or documentation updates?

go.mod (1)

27-27: Verify API version bump impact.

The API version bump from v0.5.1 to v0.5.8 is significant and may introduce breaking changes. Please ensure all dependent code has been updated accordingly.

Let's verify the impact:

✅ Verification successful

Let me gather more information about the API usage to better understand the impact.


API version bump appears safe to proceed

The version bump from v0.5.1 to v0.5.8 appears to be safe based on the following findings:

  • The API is used in a limited scope, primarily in autocli configurations and type definitions
  • The repository has a local replacement directive (replace github.com/initia-labs/OPinit/api => ./api), meaning it's using a local copy of the API
  • The upgrade was done gradually (v0.5.1 -> v0.5.7 -> v0.5.8) suggesting controlled updates
  • No references to the old version remain in the codebase
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any remaining references to the old API version and verify imports
# Test: Search for old version references. Expect: No matches for old version.
rg "v0\.5\.1" --type go

# Test: Check all Go files importing the API package to ensure they're compatible
rg --type go "github.com/initia-labs/OPinit/api"

Length of output: 338


Script:

#!/bin/bash
# Check the actual usage of the API types and methods in the codebase
rg --type go -A 5 "github.com/initia-labs/OPinit/api" 

# Look for any potential version-specific API usage
ast-grep --pattern 'import $_ "github.com/initia-labs/OPinit/api/$$$"'

# Check git history for the version bump to see what changed
git log -p go.mod | grep -A 5 -B 5 "github.com/initia-labs/OPinit/api"

Length of output: 3063

api/opinit/opchild/v1/types.pulsar.go (4)

3814-3815: LGTM: New field declaration and getter are well-structured.

The new HookMaxGas field is properly documented and uses an appropriate type (uint64) for storing gas limits. The generated getter method follows standard protobuf patterns.

Also applies to: 3880-3885


173-173: LGTM: Field descriptor initialization follows standard patterns.

The field descriptor for HookMaxGas is properly declared and initialized following the same pattern as other fields in the file.

Also applies to: 185-185


289-294: LGTM: Reflection method implementations are complete and correct.

The field handling is properly implemented across all required reflection methods:

  • Range, Has, Clear, Get, Set, Mutable, and NewField methods
  • Size calculation for wire format
  • Marshal/Unmarshal operations with proper error handling
  • Consistent with protobuf patterns and other fields in the file

Also applies to: 322-323, 352-353, 397-399, 438-439, 484-485, 514-515, 613-615, 645-649, 918-936


Line range hint 1-4284: Verify completeness of field integration.

Let's verify that all necessary references to the new field are present in the codebase.

✅ Verification successful

The search results show that the HookMaxGas field is properly integrated across the codebase:

  1. Proto/Go generated files:
  • Properly defined in types.pb.go and types.pulsar.go with correct protobuf tags
  • All necessary getter/setter methods generated
  • Proper serialization/deserialization handling
  1. Business logic integration:
  • Used in msg_server.go for handling bridge hooks with gas limits
  • Default value defined in params.go
  • Test coverage in msg_server_test.go
  1. Parameter handling:
  • Default value set to 1,000,000
  • Included in parameter initialization
  • Proper YAML tags for configuration

Let me verify the proto files specifically since the previous command had an issue with proto file type:


Based on the comprehensive verification results, I can now provide a final response:

Field integration is complete and properly implemented

The HookMaxGas field is fully integrated across all necessary layers:

  • Properly defined in proto file with correct tags and documentation
  • Generated code includes all necessary serialization/deserialization handling
  • Business logic integration present in msg_server.go
  • Default values and parameters properly configured
  • Test coverage exists

The implementation follows all the necessary patterns for protobuf field additions and is consistent with the codebase standards.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any missed references to HookMaxGas field
# This helps ensure the field is properly integrated everywhere it should be

# Search for HookMaxGas references
echo "Searching for HookMaxGas references..."
rg --type go "HookMaxGas"

# Search for hook_max_gas references (proto style)
echo "Searching for hook_max_gas references..."
rg --type proto "hook_max_gas"

Length of output: 2715


Script:

#!/bin/bash
# Search specifically in .proto files
echo "Searching for hook_max_gas in .proto files..."
find . -name "*.proto" -exec grep -l "hook_max_gas" {} \;

# Show the context of hook_max_gas in proto files
echo -e "\nShowing context in proto files:"
find . -name "*.proto" -exec grep -A 2 -B 2 "hook_max_gas" {} \;

Length of output: 491

api/opinit/opchild/v1/query.pulsar.go (2)

Line range hint 1-6485: LGTM for Generated Code

The overall structure of the generated protobuf code looks correct and follows standard patterns. The message definitions and service interfaces are well-organized.


6469-6471: ⚠️ Potential issue

API Endpoint Change Verification Required

The endpoint path for BaseDenom query has been modified to remove the denom parameter from the path. This change needs verification to ensure all clients are updated accordingly.

Run the following script to check for any remaining old endpoint usages:

✅ Verification successful

Based on the search results, I can now provide a final response:

API Endpoint Change is Safe and Consistent

The endpoint change in query.pulsar.go is consistent with the protobuf definition in proto/opinit/opchild/v1/query.proto which defines the route as /opinit/opchild/v1/base_denom. The changes are part of the generated code and correctly reflect the API design in the proto files.

  • The endpoint is properly defined in the proto file and consistently implemented across generated files
  • No old endpoint pattern /base_denom/{denom} was found in the codebase
  • The query interface and handler implementations are consistent with the new path
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any remaining references to the old endpoint pattern
rg -A 2 "/base_denom/\{denom\}"

# Search for client code that might need updates
ast-grep --pattern 'client.$$$base_denom$$$'

Length of output: 80


Script:

#!/bin/bash
# Let's try a broader search for base_denom related patterns
rg -i "base.?denom" -A 2

# Also search for any gRPC route definitions
rg "/opinit/opchild/v1/base_denom" -A 2

# Search for protobuf route definitions
fd "\.proto$" --exec grep -l "base_denom" {} \;

# Look for any client implementations
ast-grep --pattern 'func $$$BaseDenom$$$'

Length of output: 68225

Copy link
Contributor

@Vritra4 Vritra4 left a comment

Choose a reason for hiding this comment

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

LGTM

@beer-1 beer-1 merged commit 92268c7 into main Nov 15, 2024
8 checks passed
@beer-1 beer-1 deleted the fix/remove-denom-from-query-path branch November 15, 2024 06:27
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.

2 participants