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

[Bug]: x/bank: query balances with --resolve-denom panics when metadata lacks display field #23147

Open
1 task done
arlai-mk opened this issue Jan 2, 2025 · 0 comments · May be fixed by #23149
Open
1 task done

[Bug]: x/bank: query balances with --resolve-denom panics when metadata lacks display field #23147

arlai-mk opened this issue Jan 2, 2025 · 0 comments · May be fixed by #23149
Labels

Comments

@arlai-mk
Copy link

arlai-mk commented Jan 2, 2025

Is there an existing issue for this?

  • I have searched the existing issues

What happened?

The bank query balances command panics when used with --resolve-denom flag if any token's metadata lacks a display field. The panic occurs in sdk.NewCoin() during coin validation because an empty denom string is passed when metadata.Display is empty.

For example, querying metadata for factory/neutron10r39fueph9fq7a6lgswu4zdsg8t3gxlqgn9xk5/Governance on Neutron shows:

{
  "metadata": {
    "denom_units": [
      {
        "denom": "factory/neutron10r39fueph9fq7a6lgswu4zdsg8t3gxlqgn9xk5/Governance"
      }
    ],
    "base": "factory/neutron10r39fueph9fq7a6lgswu4zdsg8t3gxlqgn9xk5/Governance"
  }
}

The code at x/bank/keeper/grpc_query.go:68 uses metadata.Display without checking if it exists, passing an empty string to sdk.NewCoin(). This triggers a panic in the NewCoin function during coin.Validate() as empty denom strings are invalid.

Expected behavior:
When display field is missing from metadata, the query should fall back to using the base denom instead of attempting to create a coin with an empty denom.

Cosmos SDK Version

main

How to reproduce?

How to reproduce:

  1. Find an account holding tokens whose metadata lacks a display field
  2. Run bank balances query with --resolve-denom flag:
neutrond query bank balances neutron1qpqw3h7a2k9s0jkjtjfa8ghhes4jdevs89uljn --resolve-denom

Current output:

Error: rpc error: code = Unknown desc = invalid denom: : panic

Expected output: The query should complete successfully, showing balances with base denoms for tokens lacking display fields.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: 📋 Backlog
Development

Successfully merging a pull request may close this issue.

1 participant