-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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: add feegrant query to see allowances from a given granter #10947
Conversation
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.
lgtm, thanks @cmwaters !
@@ -239,7 +239,7 @@ func (s *IntegrationTestSuite) TestCmdGetFeeGrants() { | |||
tc := tc | |||
|
|||
s.Run(tc.name, func() { | |||
cmd := cli.GetCmdQueryFeeGrants() | |||
cmd := cli.GetCmdQueryFeeGrantsByGrantee() | |||
out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args) |
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.
Can you also add integration tests for GetCmdQueryFeeGrantsByGranter
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.
Done 👍
pageRes, err := query.Paginate(store, req.Pagination, func(key []byte, value []byte) error { | ||
var grant feegrant.Grant | ||
|
||
granter, _ := feegrant.ParseAddressesFromFeeAllowanceKey(key) | ||
if !granter.Equals(granterAddr) { | ||
return nil | ||
} | ||
|
||
if err := q.cdc.Unmarshal(value, &grant); err != nil { | ||
return err | ||
} | ||
|
||
grants = append(grants, &grant) | ||
return nil | ||
}) |
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.
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.
Yes the more efficient solution would be to have a secondary index and I think in the future we may want to have the feegrant
module use orm. For now I think this suffices due to the following reasons:
- The range scan is only parsing the keys and not the values to determine whether the allowance comes from the granter
- I can't imagine chains having a state size greater than a few hundred entries
- This is just a query endpoint (only affects individual nodes) and can be turned off from the public if need be.
- Most use cases will be for individuals checking grants on their own machines. Most "commercial" level products will be using something like a postgres indexer for serving
feegrant
information
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.
lgtm overall, can we add a changelog entry?
@@ -21,6 +21,11 @@ service Query { | |||
rpc Allowances(QueryAllowancesRequest) returns (QueryAllowancesResponse) { | |||
option (google.api.http).get = "/cosmos/feegrant/v1beta1/allowances/{grantee}"; | |||
} | |||
|
|||
// IssuedAllowances returns all the grants given by an address |
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.
Let's add a //Since
comment. Any plans to backport these?
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.
I don't mind backporting this. I'll defer the decision to others
|
||
// IssuedAllowances returns all the grants given by an address | ||
rpc IssuedAllowances(QueryIssuedAllowancesRequest) returns (QueryIssuedAllowancesResponse) { | ||
option (google.api.http).get = "/cosmos/feegrant/v1beta1/issued/{granter}"; |
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.
I'm not sure I like the IssuedAllowances
name. It's sounds confusing with Allowances
.
Maybe AllowancesByGranter
to be more explicit
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.
Would we want to change Allowances
to AllowancesByGrantee
or leave it as is?
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.
That would be proto-breaking, so no, though it would be the ideal choice.
I still prefer Allowances+AllowancesByGranter
over Allowances+IssuedAllowances
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.
Ok I will make the change
@Mergifyio backport release/v0.45.x |
❌ No backport have been created
|
We might need to do this one manually @julienrbrt. Maybe just checkout the commit and manually create a PR |
I have tried to cherry-pick the commit, but I wonder if the |
if it does not exist in 0.45, then yes, it can be ignored most likely. Double check with me if you're not sure though. |
Description
This PR adds a new query to the feegrant query server:
IssuedAllowances
which takes an address and returns all the allowances that the address has granted. This is a helpful query for UI tools so that users can more easily manage their feegrants (create, modify, delete).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...
!
to the type prefix if API or client breaking changeCHANGELOG.md
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...
!
in the type prefix if API or client breaking change