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(authz)!: pruning expired authorizations #10714

Merged
merged 70 commits into from
Feb 16, 2022
Merged
Show file tree
Hide file tree
Changes from 61 commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
748822e
chore: remove `GetCleanAuthorization`
aleem1314 Nov 29, 2021
f9e6539
fix: fix keeper tests
aleem1314 Nov 29, 2021
1f5a61f
chore: fix test
aleem1314 Nov 29, 2021
cd07048
chore: add changelog
aleem1314 Nov 30, 2021
88d74e3
Merge branch 'master' into aleem/10611-authz-exec
aleem1314 Nov 30, 2021
c7fe1f8
chore: review changes
aleem1314 Dec 2, 2021
8b5b356
Merge branch 'master' into aleem/10611-authz-exec
aleem1314 Dec 2, 2021
873cf34
feat: add queue key
aleem1314 Dec 9, 2021
e222ff1
feat: add keeper functions
aleem1314 Dec 9, 2021
90fa276
feat: add endblocker
aleem1314 Dec 9, 2021
19c5ad4
chore: cleanup
aleem1314 Dec 10, 2021
c3c66b0
feat: add migration
aleem1314 Dec 10, 2021
6768159
chore: register migrations
aleem1314 Dec 10, 2021
8c626c3
chore: try fixing simulations
aleem1314 Dec 10, 2021
312fd88
Merge branch 'master' into aleem/8311-authz-pruning
aleem1314 Dec 10, 2021
158aba0
chore: simulations
aleem1314 Dec 12, 2021
f9c5e7d
Merge branch 'master' into aleem/8311-authz-pruning
aleem1314 Dec 12, 2021
fa3578c
chore: update delegations.go
aleem1314 Dec 13, 2021
a9e982d
chore: refactor
aleem1314 Dec 13, 2021
91ea07a
chore: add godoc
aleem1314 Dec 15, 2021
e23a4b6
feat: add migration tests
aleem1314 Dec 15, 2021
cd1ce4a
Merge branch 'aleem/authz-pruning-refactor' into aleem/8311-authz-pru…
aleem1314 Dec 15, 2021
bbde75f
fix failing tests
aleem1314 Dec 15, 2021
0f851b0
Merge branch 'master' into aleem/8311-authz-pruning
aleem1314 Dec 15, 2021
1060399
chore: fix simulations
aleem1314 Dec 15, 2021
dccff34
Merge branch 'master' into aleem/8311-authz-pruning
aleem1314 Dec 15, 2021
8f38282
chore: refactors
aleem1314 Dec 16, 2021
06cd3a6
Merge branch 'aleem/8311-authz-pruning' of https://github.com/cosmos/…
aleem1314 Dec 16, 2021
6dc61f9
chore: revert app.go
aleem1314 Dec 16, 2021
012f2e5
Merge branch 'master' into aleem/8311-authz-pruning
aleem1314 Dec 16, 2021
16efe18
Merge branch 'master' into aleem/10611-authz-exec
aleem1314 Dec 17, 2021
2bc1c51
chore: add more tests
aleem1314 Dec 22, 2021
aa1cade
Merge branch 'master' into aleem/8311-authz-pruning
aleem1314 Dec 22, 2021
67aca2e
chore: refactor
aleem1314 Dec 22, 2021
c5bde25
Merge branch 'aleem/8311-authz-pruning' of https://github.com/cosmos/…
aleem1314 Dec 22, 2021
8623dbe
Update simapp/app.go
aleem1314 Dec 23, 2021
2f27b00
Update x/authz/keeper/keeper.go
aleem1314 Dec 23, 2021
6cf3ba8
Update proto/cosmos/authz/v1beta1/authz.proto
aleem1314 Dec 23, 2021
8b2784a
Update x/authz/keeper/keeper_test.go
aleem1314 Dec 23, 2021
514da8f
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk into al…
aleem1314 Jan 3, 2022
e7fce47
Merge branch 'aleem/10611-authz-exec' into aleem/8311-authz-pruning
aleem1314 Jan 3, 2022
3402724
Merge branch 'master' into aleem/8311-authz-pruning
aleem1314 Jan 4, 2022
d359412
chore: refactor simulations
aleem1314 Jan 5, 2022
2491cc3
Merge branch 'master' into aleem/8311-authz-pruning
aleem1314 Jan 6, 2022
c5b79da
Merge branch 'master' into aleem/8311-authz-pruning
aleem1314 Jan 6, 2022
fcf1afb
chore: small refactors
aleem1314 Jan 6, 2022
b97d69f
chore: fix failing test
aleem1314 Jan 6, 2022
5934d6a
chore: review changes
aleem1314 Jan 11, 2022
b14a901
Merge branch 'master' into aleem/8311-authz-pruning
aleem1314 Jan 11, 2022
5de96d9
chore: move pruning to BeginBlocker
aleem1314 Jan 13, 2022
96b52a0
feat: refactor grant queue key
aleem1314 Jan 13, 2022
5b1c4f4
chore: fix grpc test
aleem1314 Jan 13, 2022
061a360
Merge branch 'master' into aleem/8311-authz-pruning
aleem1314 Jan 13, 2022
32b47c5
Merge branch 'master' into aleem/8311-authz-pruning
aleem1314 Jan 17, 2022
ae9f324
Merge branch 'master' into aleem/8311-authz-pruning
aleem1314 Feb 7, 2022
93f6ca3
cleanup
aleem1314 Feb 7, 2022
21642e5
Merge branch 'master' into aleem/8311-authz-pruning
aleem1314 Feb 7, 2022
d116a13
Merge branch 'master' into aleem/8311-authz-pruning
aleem1314 Feb 8, 2022
6790488
resolve conflicts
aleem1314 Feb 8, 2022
3ee7fb5
chore: fix failing tests
aleem1314 Feb 8, 2022
3b981dd
Merge branch 'master' into aleem/8311-authz-pruning
aleem1314 Feb 8, 2022
e67a94f
Update x/authz/keeper/grpc_query.go
aleem1314 Feb 8, 2022
063d31d
chore: review changes
aleem1314 Feb 8, 2022
caaacc4
fix grpc test
aleem1314 Feb 8, 2022
9e052ec
Merge branch 'master' into aleem/8311-authz-pruning
aleem1314 Feb 10, 2022
1e98db8
Merge branch 'master' into aleem/8311-authz-pruning
aleem1314 Feb 16, 2022
259b014
run: make proto-gen
aleem1314 Feb 16, 2022
653ca22
chore: fix errors
aleem1314 Feb 16, 2022
de0a641
Merge branch 'master' into aleem/8311-authz-pruning
aleem1314 Feb 16, 2022
432fa61
Merge branch 'master' into aleem/8311-authz-pruning
robert-zaremba Feb 16, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* [\#10947](https://github.com/cosmos/cosmos-sdk/pull/10947) Add `AllowancesByGranter` query to the feegrant module
* [\#10407](https://github.com/cosmos/cosmos-sdk/pull/10407) Add validation to `x/upgrade` module's `BeginBlock` to check accidental binary downgrades
* (gov) [\#11036](https://github.com/cosmos/cosmos-sdk/pull/11036) Add in-place migrations for 0.43->0.46. Add a `migrate v0.46` CLI command for v0.43->0.46 JSON genesis migration.
* (x/authz) [\#10714](https://github.com/cosmos/cosmos-sdk/pull/10714) Add support for pruning expired authorizations.

### API Breaking Changes
* [\#10950](https://github.com/cosmos/cosmos-sdk/pull/10950) Add `envPrefix` parameter to `cmd.Execute`.
Expand Down Expand Up @@ -187,6 +188,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* [\#10990](https://github.com/cosmos/cosmos-sdk/pull/10990) Fixes missing `iavl-cache-size` config parsing in `GetConfig` method.
* (crypto) [#11027] Remove dependency on Tendermint core for xsalsa20symmetric.
* (x/authz) [\#10447](https://github.com/cosmos/cosmos-sdk/pull/10447) Fix authz `NewGrant` expiration check.
* (x/authz) [\#10633](https://github.com/cosmos/cosmos-sdk/pull/10633) Fixed authorization not found error when executing message.

### State Machine Breaking

Expand Down
7 changes: 7 additions & 0 deletions proto/cosmos/authz/v1beta1/authz.proto
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,10 @@ message Grant {
google.protobuf.Any authorization = 1 [(cosmos_proto.accepts_interface) = "Authorization"];
google.protobuf.Timestamp expiration = 2 [(gogoproto.stdtime) = true, (gogoproto.nullable) = false];
}

// GrantQueueItem contains the list of TypeURL of a sdk.Msg.
message GrantQueueItem {
// msg_type_urls contains the list of TypeURL of a sdk.Msg.
repeated string msg_type_urls = 1;
}

2 changes: 1 addition & 1 deletion simapp/sim_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ func TestAppImportExport(t *testing.T) {
{app.keys[govtypes.StoreKey], newApp.keys[govtypes.StoreKey], [][]byte{}},
{app.keys[evidencetypes.StoreKey], newApp.keys[evidencetypes.StoreKey], [][]byte{}},
{app.keys[capabilitytypes.StoreKey], newApp.keys[capabilitytypes.StoreKey], [][]byte{}},
{app.keys[authzkeeper.StoreKey], newApp.keys[authzkeeper.StoreKey], [][]byte{}},
{app.keys[authzkeeper.StoreKey], newApp.keys[authzkeeper.StoreKey], [][]byte{authzkeeper.GrantKey, authzkeeper.GrantQueuePrefix}},
}

for _, skp := range storeKeysPrefixes {
Expand Down
8 changes: 4 additions & 4 deletions x/authz/authorization_grant.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ func (g Grant) UnpackInterfaces(unpacker cdctypes.AnyUnpacker) error {
}

// GetAuthorization returns the cached value from the Grant.Authorization if present.
func (g Grant) GetAuthorization() Authorization {
func (g Grant) GetAuthorization() (Authorization, error) {
if g.Authorization == nil {
return nil
return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidType, "authorization is nil")
}
a, ok := g.Authorization.GetCachedValue().(Authorization)
if !ok {
return nil
return nil, sdkerrors.ErrInvalidType.Wrapf("expected %T, got %T", (Authorization)(nil), g.Authorization.GetCachedValue())
}
return a
return a, nil
}

func (g Grant) ValidateBasic() error {
Expand Down
212 changes: 192 additions & 20 deletions x/authz/authz.pb.go

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

5 changes: 3 additions & 2 deletions x/authz/client/testutil/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func (s *IntegrationTestSuite) TestQueryGrantGRPC() {
"fail invalid msg-type",
fmt.Sprintf(grantsURL, val.Address.String(), grantee.String(), "invalidMsg"),
true,
"rpc error: code = NotFound desc = no authorization found for invalidMsg type: key not found",
"no authorization found for invalidMsg type",
},
{
"valid query",
Expand All @@ -72,7 +72,8 @@ func (s *IntegrationTestSuite) TestQueryGrantGRPC() {
require.NoError(err)
require.Len(g.Grants, 1)
g.Grants[0].UnpackInterfaces(val.ClientCtx.InterfaceRegistry)
auth := g.Grants[0].GetAuthorization()
auth, err := g.Grants[0].GetAuthorization()
require.NoError(err)
require.Equal(auth.MsgTypeURL(), banktypes.SendAuthorization{}.MsgTypeURL())
}
})
Expand Down
Loading