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

feat(delegation): query maximum undelegation amount #285

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

TimmyExogenous
Copy link
Contributor

@TimmyExogenous TimmyExogenous commented Jan 13, 2025

Description

This PR returns the maximum undelegatable amount in the RPC QuerySingleDelegationInfo.

Summary by CodeRabbit

  • New Features

    • Single delegation queries now return comprehensive details, including grouped delegation amounts and a separate maximum undelegatable amount.
    • Asset and staker identifiers are handled more consistently, enhancing the reliability of delegation and asset queries.
  • Documentation

    • API response descriptions have been updated for clearer communication of delegation data and improved user guidance.

Copy link
Contributor

coderabbitai bot commented Jan 13, 2025

Walkthrough

This pull request updates the API specification, protocol definitions, tests, and keeper logic for delegation information. The OpenAPI documentation and proto files now include a new response type that groups delegation amounts and the maximum undelegatable amount. The gRPC query methods and helper functions have been refactored to handle lowercasing for consistent identifier processing. Additionally, some test utilities have been simplified by removing extra logic and redundant queries, and asset-related constants are now imported from a dedicated package.

Changes

File(s) Change Summary
client/docs/.../swagger.json Updated OpenAPI summary and restructured the response schema for the /exocore/delegation/v1/single_delegation/{staker_id}/{operator_addr}/{asset_id} endpoint by nesting undelegatable_share into a new delegation_amounts object and adding max_undelegatable_amount.
proto/exocore/.../query.proto Introduced a new message type SingleDelegationInfoResponse and updated the QuerySingleDelegationInfo RPC method to return the new type.
testutil/.../tx_check.go Simplified the QueryDelegatedAmount method by removing extra queries and error handling, and now directly returning the MaxUndelegatableAmount.
x/delegation/keeper/.../delegation_op_test.go Modified import statements and variable assignments to use asset-related constants from the assetstypes package.
x/delegation/keeper/.../delegation_state.go Added the new UndelegatableAmount method and refactored other delegation methods to reuse this logic.
x/delegation/keeper/.../grpc_query.go Updated signatures and added lowercasing of identifiers in QuerySingleDelegationInfo along with enhanced error handling and response construction.
x/assets/keeper/.../grpc_query.go Added lowercasing of asset and staker identifiers in query methods to ensure case-insensitive processing.
x/operator/keeper/.../grpc_query.go
x/operator/keeper/.../voting_power_snapshot.go
Adjusted the handling of the AVS parameter: removed lowercasing in snapshot queries in one file while ensuring consistent lowercasing in store lookups in the other.

Sequence Diagram(s)

sequenceDiagram
    participant C as Client
    participant G as gRPC Endpoint
    participant K as Keeper
    participant A as AssetsKeeper

    C->>G: QuerySingleDelegationInfo(request with IDs)
    G->>K: GetSingleDelegationInfo(lowercased IDs)
    K->>K: Retrieve delegationAmounts
    K->>K: Call UndelegatableAmount(...) 
    K->>A: Request asset state for operator
    A-->>K: Return asset state data
    K->>G: Construct SingleDelegationInfoResponse with delegationAmounts and maxUndelegatableAmount
    G->>C: Return constructed response
Loading

Possibly related PRs

Suggested labels

Type: Tests

Suggested reviewers

  • mikebraver
  • leonz789
  • bwhour
  • cloud8little
  • adu-web3

Poem

In my warren of code, I hop with delight,
New methods and schemas shining so bright.
Delegation details are grouped neat and fine,
With every bug nibbled, the code does align.
A carrot of logic, a crunchy review—
Hoppy changes abound, and I celebrate you! 🐇

✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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.

@TimmyExogenous TimmyExogenous changed the title feat(delegation): Return maximum undelegation amount in the RPC QuerySingleDelegationInfo feat(delegation): query maximum undelegation amount Jan 13, 2025
Copy link
Contributor

@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

🧹 Nitpick comments (2)
x/delegation/keeper/grpc_query.go (1)

12-26: LGTM! Consider enhancing error messages.

The implementation correctly retrieves delegation information and calculates the maximum undelegatable amount. The error handling is appropriate with early returns.

Consider adding more context to error messages:

-		return nil, err
+		return nil, fmt.Errorf("failed to get delegation info: %w", err)
-		return nil, err
+		return nil, fmt.Errorf("failed to calculate undelegatable amount: %w", err)
client/docs/swagger-ui/swagger.json (1)

20834-20836: Maintain consistent terminology.

The description uses "unbonded" while the field names use "undelegation". Consider using consistent terminology throughout the API documentation.

-                      "description": "wait_undelegation_amount is the amount that is waiting to be unbonded."
+                      "description": "wait_undelegation_amount is the amount that is waiting to be undelegated."
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 59241ba and 3ffdd00.

⛔ Files ignored due to path filters (4)
  • x/delegation/types/genesis.pb.go is excluded by !**/*.pb.go
  • x/delegation/types/query.pb.go is excluded by !**/*.pb.go
  • x/dogfood/types/query.pb.go is excluded by !**/*.pb.go
  • x/dogfood/types/query.pb.gw.go is excluded by !**/*.pb.gw.go
📒 Files selected for processing (7)
  • client/docs/swagger-ui/swagger.json (2 hunks)
  • proto/exocore/delegation/v1/genesis.proto (1 hunks)
  • proto/exocore/delegation/v1/query.proto (4 hunks)
  • testutil/batch/tx_check.go (1 hunks)
  • x/delegation/keeper/delegation_op_test.go (1 hunks)
  • x/delegation/keeper/delegation_state.go (3 hunks)
  • x/delegation/keeper/grpc_query.go (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • x/delegation/keeper/delegation_op_test.go
🧰 Additional context used
🪛 GitHub Check: break-check
proto/exocore/delegation/v1/query.proto

[failure] 182-182:
RPC "QuerySingleDelegationInfo" on service "Query" changed response type from "exocore.delegation.v1.DelegationAmounts" to "exocore.delegation.v1.SingleDelegationInfoResponse".

⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: goreleaser
  • GitHub Check: Analyze (go)
🔇 Additional comments (9)
testutil/batch/tx_check.go (1)

58-58: LGTM! Code simplified correctly.

The method now correctly uses the MaxUndelegatableAmount from the new response structure, removing duplicate calculation logic.

x/delegation/keeper/delegation_state.go (2)

75-87: LGTM! Well-structured new method.

The UndelegatableAmount method is well-implemented with proper validation and error handling.


Line range hint 97-101: Good refactoring to reduce code duplication.

The changes to use UndelegatableAmount in both methods improve code maintainability by centralizing the calculation logic.

Also applies to: 113-117

client/docs/swagger-ui/swagger.json (3)

20827-20847: Well-structured response schema with comprehensive documentation.

The response schema is well-organized with:

  • Clear separation of concerns between delegation amounts and maximum undelegatable amount
  • Detailed documentation of the mathematical formulas for share calculations
  • Proper type definitions and descriptions for all fields

43425-43449: Well-defined schema with proper documentation.

The SingleDelegationInfoResponse schema is well-structured and properly documented. The schema definition aligns perfectly with the endpoint specification and PR objectives.

Note: The same terminology inconsistency between "unbonded" and "undelegation" exists in this section. Please update it for consistency when addressing the previous comment.


20819-20847: Verify integration with proto and keeper changes.

The OpenAPI changes look well-integrated with the mentioned proto and keeper changes. Let's verify the alignment of field names and types across the codebase.

Also applies to: 43425-43449

✅ Verification successful

OpenAPI changes correctly aligned with proto and keeper implementations

The field names, types, and documentation in the OpenAPI specification perfectly match the proto definitions and keeper implementation. The max_undelegatable_amount field is properly exposed as a string type (matching cosmos.Int), and the nested delegation_amounts structure is accurately represented.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify field names and types are consistent across proto and OpenAPI specs

# Check proto definitions
echo "Checking proto definitions for field alignment..."
rg -A 10 "message SingleDelegationInfoResponse" "proto/"

# Check keeper implementation
echo "Checking keeper implementation..."
rg -A 10 "SingleDelegationInfoResponse" "x/delegation/keeper/"

Length of output: 2831


Script:

#!/bin/bash
# Check OpenAPI spec for SingleDelegationInfoResponse
echo "Checking OpenAPI spec..."
rg -A 15 '"SingleDelegationInfoResponse"' client/docs/swagger-ui/swagger.json

Length of output: 138


Script:

#!/bin/bash
# Check specific lines in swagger.json
echo "Checking specific lines in swagger.json..."
sed -n '20819,20847p' client/docs/swagger-ui/swagger.json

# Search for similar patterns in case of different naming
echo -e "\nChecking for similar response patterns..."
rg -i "delegation.*info.*response" client/docs/swagger-ui/swagger.json

Length of output: 2917

proto/exocore/delegation/v1/genesis.proto (1)

45-45: Verify the removal of nullable option

The removal of [(gogoproto.nullable) = false] from the stakers field appears unrelated to the PR's objective of adding maximum undelegatable amount information. This change could affect backward compatibility and data serialization.

Consider keeping the nullable option to maintain consistent behavior with other repeated fields in the file that are marked as non-nullable (e.g., associations, delegation_states).

-  repeated string stakers = 2;
+  repeated string stakers = 2 [(gogoproto.nullable) = false];
proto/exocore/delegation/v1/query.proto (2)

72-82: LGTM! Well-structured response message

The new SingleDelegationInfoResponse message is well-designed with:

  • Clear field names and descriptions
  • Proper use of cosmos scalar types
  • Consistent nullable options

180-185: Breaking change in RPC response type

The change in response type from DelegationAmounts to SingleDelegationInfoResponse is a breaking change that requires careful migration planning.

Please ensure that:

  1. All clients of this RPC endpoint are updated to handle the new response type
  2. The breaking change is documented in the changelog
  3. Consider version bumping according to semantic versioning
🧰 Tools
🪛 GitHub Check: break-check

[failure] 182-182:
RPC "QuerySingleDelegationInfo" on service "Query" changed response type from "exocore.delegation.v1.DelegationAmounts" to "exocore.delegation.v1.SingleDelegationInfoResponse".

@cloud8little cloud8little added this to the Testnet V8 milestone Feb 13, 2025
@cloud8little
Copy link
Contributor

There is delegation record for the staker, but the grpc query(/exocore/delegation/v1/single_delegation/{staker_id}/{operator_addr}/{asset_id}) return no record.

exocored q delegation QueryDelegationInfo 0xa53f68563D22EB0dAFAA871b6C08a6852f91d627_0x9ce1 0x83E6850591425e3C1E263c054f4466838B9Bd9e4_0x9ce1
delegation_infos:
  exo1y7hv3rjnjqu3mxw4k075fsem804yar2jfymjjg:
    undelegatable_share: "2996000000000000000000.000000000000000000"
    wait_undelegation_amount: "2000000000000000000"

exocored q delegation QueryUndelegations 0xa53f68563D22EB0dAFAA871b6C08a6852f91d627_0x9ce1 0x83E6850591425e3C1E263c054f4466838B9Bd9e4_0x9ce1
undelegations:
- hold_count: "1"
  undelegation:
    actual_completed_amount: "2000000000000000000"
    amount: "2000000000000000000"
    asset_id: 0x83e6850591425e3c1e263c054f4466838b9bd9e4_0x9ce1
    block_number: "170"
    completed_epoch_identifier: minute
    completed_epoch_number: "12"
    operator_addr: exo1y7hv3rjnjqu3mxw4k075fsem804yar2jfymjjg
    staker_id: 0xa53f68563d22eb0dafaa871b6c08a6852f91d627_0x9ce1
    tx_hash: 0x2aca4510a84ff8fe27219e9a191984cbae23ca64efa9f231bf6100999d3a4f72
    undelegation_id: "1"

curl http://localhost:1317/exocore/delegation/v1/single_delegation/0xa53f68563D22EB0dAFAA871b6C08a6852f91d627_0x9ce1/exo1y7hv3rjnjqu3mxw4k075fsem804yar2jfymjjg/0x83E6850591425e3C1E263c054f4466838B9Bd9e4_0x9ce1
{"code":2,"message":"codespace delegation code 2: there is not the key for in the store: QuerySingleDelegationInfo: key is 0xa53f68563D22EB0dAFAA871b6C08a6852f91d627_0x9ce1/0x83E6850591425e3C1E263c054f4466838B9Bd9e4_0x9ce1/exo1y7hv3rjnjqu3mxw4k075fsem804yar2jfymjjg","details":[]}

@TimmyExogenous TimmyExogenous force-pushed the max-undelegation-amount branch from 3ffdd00 to 0026a73 Compare February 14, 2025 03:29
@TimmyExogenous
Copy link
Contributor Author

There is delegation record for the staker, but the grpc query(/exocore/delegation/v1/single_delegation/{staker_id}/{operator_addr}/{asset_id}) return no record.

exocored q delegation QueryDelegationInfo 0xa53f68563D22EB0dAFAA871b6C08a6852f91d627_0x9ce1 0x83E6850591425e3C1E263c054f4466838B9Bd9e4_0x9ce1
delegation_infos:
  exo1y7hv3rjnjqu3mxw4k075fsem804yar2jfymjjg:
    undelegatable_share: "2996000000000000000000.000000000000000000"
    wait_undelegation_amount: "2000000000000000000"

exocored q delegation QueryUndelegations 0xa53f68563D22EB0dAFAA871b6C08a6852f91d627_0x9ce1 0x83E6850591425e3C1E263c054f4466838B9Bd9e4_0x9ce1
undelegations:
- hold_count: "1"
  undelegation:
    actual_completed_amount: "2000000000000000000"
    amount: "2000000000000000000"
    asset_id: 0x83e6850591425e3c1e263c054f4466838b9bd9e4_0x9ce1
    block_number: "170"
    completed_epoch_identifier: minute
    completed_epoch_number: "12"
    operator_addr: exo1y7hv3rjnjqu3mxw4k075fsem804yar2jfymjjg
    staker_id: 0xa53f68563d22eb0dafaa871b6c08a6852f91d627_0x9ce1
    tx_hash: 0x2aca4510a84ff8fe27219e9a191984cbae23ca64efa9f231bf6100999d3a4f72
    undelegation_id: "1"

curl http://localhost:1317/exocore/delegation/v1/single_delegation/0xa53f68563D22EB0dAFAA871b6C08a6852f91d627_0x9ce1/exo1y7hv3rjnjqu3mxw4k075fsem804yar2jfymjjg/0x83E6850591425e3C1E263c054f4466838B9Bd9e4_0x9ce1
{"code":2,"message":"codespace delegation code 2: there is not the key for in the store: QuerySingleDelegationInfo: key is 0xa53f68563D22EB0dAFAA871b6C08a6852f91d627_0x9ce1/0x83E6850591425e3C1E263c054f4466838B9Bd9e4_0x9ce1/exo1y7hv3rjnjqu3mxw4k075fsem804yar2jfymjjg","details":[]}

The issue in the gRPCs of the assets, delegation, and operator modules has been fixed in the last commit.

Copy link
Contributor

@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 comments (2)
x/operator/keeper/grpc_query.go (2)

350-357: ⚠️ Potential issue

Ensure consistent case handling for AVS addresses.

The removal of strings.ToLower for req.Avs in QuerySnapshotHelper is inconsistent with the case-insensitive handling added in other files, particularly in GetSnapshotHelper which now converts the AVS address to lowercase.

Apply this diff to maintain consistency:

-    snapshotHelper, err := k.GetSnapshotHelper(ctx, req.Avs)
+    snapshotHelper, err := k.GetSnapshotHelper(ctx, strings.ToLower(req.Avs))

359-369: ⚠️ Potential issue

Ensure consistent case handling for AVS addresses.

The removal of strings.ToLower for req.Avs in QuerySpecifiedSnapshot is inconsistent with the case-insensitive handling pattern.

Apply this diff to maintain consistency:

-    findHeight, snapshot, err := k.LoadVotingPowerSnapshot(ctx, req.Avs, req.Height)
+    findHeight, snapshot, err := k.LoadVotingPowerSnapshot(ctx, strings.ToLower(req.Avs), req.Height)
🧹 Nitpick comments (3)
x/delegation/keeper/delegation_state.go (3)

75-87: Add input validation for assetID and amounts parameters.

The method should validate all input parameters to ensure robustness:

  1. Check if assetID is empty
  2. Validate that amounts is not nil
 func (k Keeper) UndelegatableAmount(ctx sdk.Context, assetID, operator string, amounts *delegationtype.DelegationAmounts) (amount sdkmath.Int, err error) {
+    if assetID == "" {
+        return sdkmath.ZeroInt(), errorsmod.Wrap(delegationtype.ErrInvalidInput, "assetID cannot be empty")
+    }
+    if amounts == nil {
+        return sdkmath.ZeroInt(), errorsmod.Wrap(delegationtype.ErrInvalidInput, "amounts cannot be nil")
+    }
     opAccAddr := sdk.MustAccAddressFromBech32(operator)

89-106: Add input validation for stakerID and assetID parameters.

The method should validate input parameters before processing:

 func (k Keeper) TotalDelegatedAmountForStakerAsset(ctx sdk.Context, stakerID string, assetID string) (amount sdkmath.Int, err error) {
+    if stakerID == "" {
+        return sdkmath.ZeroInt(), errorsmod.Wrap(delegationtype.ErrInvalidInput, "stakerID cannot be empty")
+    }
+    if assetID == "" {
+        return sdkmath.ZeroInt(), errorsmod.Wrap(delegationtype.ErrInvalidInput, "assetID cannot be empty")
+    }
     amount = sdkmath.ZeroInt()

108-125: Add input validation and optimize map initialization.

Consider these improvements:

  1. Add input parameter validation
  2. Add capacity hint for the map based on the expected number of operators
 func (k *Keeper) AllDelegatedInfoForStakerAsset(ctx sdk.Context, stakerID string, assetID string) (map[string]sdkmath.Int, error) {
+    if stakerID == "" {
+        return nil, errorsmod.Wrap(delegationtype.ErrInvalidInput, "stakerID cannot be empty")
+    }
+    if assetID == "" {
+        return nil, errorsmod.Wrap(delegationtype.ErrInvalidInput, "assetID cannot be empty")
+    }
-    ret := make(map[string]sdkmath.Int)
+    // Initialize with capacity hint based on average number of operators per staker
+    ret := make(map[string]sdkmath.Int, 10) // Adjust capacity based on your use case
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3ffdd00 and 0026a73.

⛔ Files ignored due to path filters (1)
  • x/delegation/types/query.pb.go is excluded by !**/*.pb.go
📒 Files selected for processing (9)
  • client/docs/swagger-ui/swagger.json (2 hunks)
  • proto/exocore/delegation/v1/query.proto (4 hunks)
  • testutil/batch/tx_check.go (1 hunks)
  • x/assets/keeper/grpc_query.go (5 hunks)
  • x/delegation/keeper/delegation_op_test.go (6 hunks)
  • x/delegation/keeper/delegation_state.go (3 hunks)
  • x/delegation/keeper/grpc_query.go (4 hunks)
  • x/operator/keeper/grpc_query.go (2 hunks)
  • x/operator/keeper/voting_power_snapshot.go (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • testutil/batch/tx_check.go
  • x/delegation/keeper/delegation_op_test.go
🧰 Additional context used
🪛 GitHub Check: break-check
proto/exocore/delegation/v1/query.proto

[failure] 182-182:
RPC "QuerySingleDelegationInfo" on service "Query" changed response type from "exocore.delegation.v1.DelegationAmounts" to "exocore.delegation.v1.SingleDelegationInfoResponse".

🔇 Additional comments (17)
x/delegation/keeper/grpc_query.go (6)

13-28: LGTM! Enhanced query response with maximum undelegatable amount.

The implementation correctly:

  • Converts identifiers to lowercase for case-insensitive handling
  • Calculates the maximum undelegatable amount
  • Returns both delegation amounts and maximum undelegatable amount in the response

30-33: LGTM! Added case-insensitive handling for identifiers.

Consistent case handling using strings.ToLower for StakerId and AssetId.


35-44: LGTM! Added case-insensitive handling for undelegations query.

Consistent case handling using strings.ToLower for StakerId and AssetId.


57-65: LGTM! Added case-insensitive handling for undelegation hold count.

Consistent case handling using strings.ToLower for StakerId and AssetId.


67-76: LGTM! Added case-insensitive handling for associated operator query.

Consistent case handling using strings.ToLower for StakerId.


89-99: LGTM! Added case-insensitive handling for delegated stakers query.

Consistent case handling using strings.ToLower for AssetId.

x/assets/keeper/grpc_query.go (4)

58-62: LGTM! Added case-insensitive handling for staking asset info query.

Consistent case handling using strings.ToLower for AssetId.


74-82: LGTM! Added case-insensitive handling for staker asset infos query.

Consistent case handling using strings.ToLower for StakerId.


84-88: LGTM! Added case-insensitive handling for staker specified asset amount query.

Consistent case handling using strings.ToLower for both StakerId and AssetId.


104-112: LGTM! Added case-insensitive handling for operator specified asset amount query.

Consistent case handling using strings.ToLower for AssetId.

x/operator/keeper/voting_power_snapshot.go (1)

229-241: LGTM! Added case-insensitive handling for snapshot helper.

Consistent case handling using strings.ToLower for AVS address when accessing store.

client/docs/swagger-ui/swagger.json (3)

20819-20819: LGTM! Clear and descriptive endpoint summary.

The updated summary accurately reflects the enhanced functionality of the endpoint, which now includes both delegation information and maximum undelegatable amount.


20827-20841: LGTM! Well-structured response schema with clear documentation.

The response schema has been thoughtfully organized:

  • Groups related fields under delegation_amounts
  • Includes detailed descriptions for complex calculations
  • Clearly documents the maximum undelegatable amount

Also applies to: 20842-20845, 20847-20847


43425-43449: LGTM! Consistent type definition.

The SingleDelegationInfoResponse type definition matches the endpoint response schema, maintaining consistency across the API specification.

proto/exocore/delegation/v1/query.proto (3)

61-62: LGTM! Clear documentation update.

The message description accurately reflects the enhanced functionality to include maximum undelegatable amount information.


72-82: Breaking change: New response type for enhanced delegation info.

The new SingleDelegationInfoResponse message is well-structured and properly annotated. However, this is a breaking change that requires careful consideration during deployment.

Please ensure that:

  1. All clients are updated to handle the new response type
  2. The API version is incremented appropriately
  3. Migration documentation is updated to reflect this breaking change

180-185:

✅ Verification successful

LGTM! RPC method updated to support maximum undelegatable amount.

The changes align perfectly with the PR objectives to enhance the QuerySingleDelegationInfo RPC method. The implementation addresses the issue reported by cloud8little in the PR comments regarding delegation record retrieval.


🏁 Script executed:

#!/bin/bash
# Description: Verify that the implementation in the keeper matches the proto definition

# Check if the keeper implementation returns both delegation amounts and max undelegatable amount
rg -A 10 "func.*QuerySingleDelegationInfo.*Context.*SingleDelegationInfoReq.*SingleDelegationInfoResponse" 

Length of output: 3307


LGTM! Keeper implementation verified for maximum undelegatable amount.

The proto and keeper changes have been confirmed:

  • The keeper in x/delegation/keeper/grpc_query.go correctly calls GetSingleDelegationInfo and then calculates the undelegatable amount via UndelegatableAmount.
  • The RPC method remains consistent with the proto definition, preserving backward compatibility.

No further modifications are necessary.

🧰 Tools
🪛 GitHub Check: break-check

[failure] 182-182:
RPC "QuerySingleDelegationInfo" on service "Query" changed response type from "exocore.delegation.v1.DelegationAmounts" to "exocore.delegation.v1.SingleDelegationInfoResponse".

Copy link
Contributor

@bwhour bwhour left a comment

Choose a reason for hiding this comment

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

LGTM.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants