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

Query redemption records for multiple addresses #1075

Merged
merged 3 commits into from
Jan 15, 2024

Conversation

ethan-stride
Copy link
Contributor

This allows the QueryAddressUnbondings RPC to either pass in a single address or a comma separated list of multiple addresses. The proto was not changed on purpose so that the grpc endpoint wouldn't change, and queries which were working before with a single input address will continue to work just fine. The input should be robust to whether the user includes spaces or not but it is expected to be a string of addresses separated by commas with no spaces normally.

One nit change, initializing the addressUnbondings variable on ln33 to an empty array, before it was given a type but could have been nil if the address provided had no redemption records.

Noticed this keeper function never had a unit test before so added grpc_query_address_unbondings_test.go which tests:

  • Single address input with no redemption records found
  • Single address input with a single redemption record found
  • Single address input multiple redemption records across different epochs
  • Multiple addresses input which finds record for only one address but not the others
  • Multiple addresses input (even on different hostZones) which finds user records for each, more than one for some
  • Invalid query or empty address given is an expected error case

Copy link
Contributor

@shellvish shellvish left a comment

Choose a reason for hiding this comment

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

This looks great, thanks a lot Ethan! Verified locally that this works with mainnet state.

Pushed up a very small optimization (to stop the inner loop when we find a match), otherwise looks fantsatic.

@shellvish shellvish merged commit 910b667 into main Jan 15, 2024
10 checks passed
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.

2 participants