Skip to content

Commit

Permalink
feat(x/authz): add limits to grant pruning and enable message to aid …
Browse files Browse the repository at this point in the history
…manually (#18737)
  • Loading branch information
julienrbrt authored Dec 15, 2023
1 parent a5f1217 commit 0ba62db
Show file tree
Hide file tree
Showing 15 changed files with 2,154 additions and 122 deletions.
517 changes: 498 additions & 19 deletions api/cosmos/authz/v1beta1/event.pulsar.go

Large diffs are not rendered by default.

982 changes: 934 additions & 48 deletions api/cosmos/authz/v1beta1/tx.pulsar.go

Large diffs are not rendered by default.

49 changes: 46 additions & 3 deletions api/cosmos/authz/v1beta1/tx_grpc.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 12 additions & 1 deletion proto/cosmos/authz/v1beta1/event.proto
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// Since: cosmos-sdk 0.43
syntax = "proto3";
package cosmos.authz.v1beta1;

Expand All @@ -7,6 +6,8 @@ import "cosmos_proto/cosmos.proto";
option go_package = "cosmossdk.io/x/authz";

// EventGrant is emitted on Msg/Grant
//
// Since: cosmos-sdk 0.43
message EventGrant {
// Msg type URL for which an authorization is granted
string msg_type_url = 2;
Expand All @@ -17,6 +18,8 @@ message EventGrant {
}

// EventRevoke is emitted on Msg/Revoke
//
// Since: cosmos-sdk 0.43
message EventRevoke {
// Msg type URL for which an authorization is revoked
string msg_type_url = 2;
Expand All @@ -25,3 +28,11 @@ message EventRevoke {
// Grantee account address
string grantee = 4 [(cosmos_proto.scalar) = "cosmos.AddressString"];
}

// EventPruneExpiredGrants is emitted on Msg/PruneExpiredGrants
//
// Since: x/authz 1.0.0
message EventPruneExpiredGrants {
// Address of the pruner
string pruner = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
}
19 changes: 19 additions & 0 deletions proto/cosmos/authz/v1beta1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ service Msg {
// Revoke revokes any authorization corresponding to the provided method name on the
// granter's account that has been granted to the grantee.
rpc Revoke(MsgRevoke) returns (MsgRevokeResponse);

// PruneExpiredGrants prunes the expired grants. Currently up to 75 at a time.
//
// Since cosmos-sdk 0.51
rpc PruneExpiredGrants(MsgPruneExpiredGrants) returns (MsgPruneExpiredGrantsResponse);
}

// MsgGrant is a request type for Grant method. It declares authorization to the grantee
Expand Down Expand Up @@ -79,3 +84,17 @@ message MsgRevoke {

// MsgRevokeResponse defines the Msg/MsgRevokeResponse response type.
message MsgRevokeResponse {}

// MsgPruneExpiredGrants prunes the expired grants.
//
// Since x/authz v1.0.0
message MsgPruneExpiredGrants {
option (cosmos.msg.v1.signer) = "pruner";

string pruner = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
}

// MsgPruneExpiredGrantsResponse defines the Msg/MsgPruneExpiredGrantsResponse response type.
//
// Since x/authz v1.0.0
message MsgPruneExpiredGrantsResponse {}
4 changes: 4 additions & 0 deletions x/authz/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,12 @@ Ref: https://keepachangelog.com/en/1.0.0/

### Features

* [#18737](https://github.com/cosmos/cosmos-sdk/pull/18737) Added a limit of 200 grants pruned per `BeginBlock` and the `PruneExpiredGrants` message that prunes 75 expired grants on every run.

### Improvements

### API Breaking Changes

* [#18737](https://github.com/cosmos/cosmos-sdk/pull/18737) Update the keeper method `DequeueAndDeleteExpiredGrants` to take a limit argument for the number of grants to prune.

### Bug Fixes
5 changes: 5 additions & 0 deletions x/authz/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ granting arbitrary privileges from one account (the granter) to another account
* [MsgGrant](#msggrant)
* [MsgRevoke](#msgrevoke)
* [MsgExec](#msgexec)
* [MsgPruneExpiredGrants](#msgpruneexpiredgrants)
* [Events](#events)
* [Client](#client)
* [CLI](#cli)
Expand Down Expand Up @@ -181,6 +182,10 @@ The message handling should fail if:
* grantee doesn't have permission to run the transaction.
* if granted authorization is expired.

### MsgPruneExpiredGrants

Message that clean up 75 expired grants. A user has no benefit sending this transaction, it is only used by the chain to clean up expired grants.

## Events

The authz module emits proto events defined in [the Protobuf reference](https://buf.build/cosmos/cosmos-sdk/docs/main/cosmos.authz.v1beta1#cosmos.authz.v1beta1.EventGrant).
Expand Down
Loading

0 comments on commit 0ba62db

Please sign in to comment.