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

WIP: Add x/msg_authorization module #7370

Closed
wants to merge 89 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
89 commits
Select commit Hold shift + click to select a range
5a34c06
WIP: Msg authorization module added
atheeshp Sep 23, 2020
d30572c
Merge branch 'master' of github.com:cosmos/cosmos-sdk into msg_author…
atheeshp Sep 24, 2020
5087ad3
Merge branch 'master' of github.com:cosmos/cosmos-sdk into msg_auth_p…
atheeshp Sep 25, 2020
3eac303
fixing errors
atheeshp Sep 25, 2020
beb7cc2
Merge branch 'master' of github.com:cosmos/cosmos-sdk into msg_auth_p…
atheeshp Sep 25, 2020
39f1715
fixed errors
atheeshp Sep 25, 2020
0f71c06
fixed module.go
atheeshp Sep 29, 2020
ffd988e
Merge branch 'master' of github.com:cosmos/cosmos-sdk into msg_auth_p…
atheeshp Sep 29, 2020
14870e4
Add msg_tests
aleem1314 Sep 30, 2020
c2d6db2
fixes compile issues
atheeshp Sep 30, 2020
307cc99
Merge branch 'msg_auth_proto' of https://github.com/cosmos/cosmos-sdk…
aleem1314 Sep 30, 2020
5362872
fix test
atheeshp Sep 30, 2020
61834b6
Merge branch 'master' of github.com:cosmos/cosmos-sdk into msg_auth_p…
atheeshp Sep 30, 2020
7b80c0f
fix test
atheeshp Sep 30, 2020
ca9062e
Merge branch 'master' into msg_authorization
atheeshp Sep 30, 2020
f27b8f1
Merge branch 'msg_authorization' of github.com:cosmos/cosmos-sdk into…
atheeshp Sep 30, 2020
64224ea
Merge branch 'msg_auth_proto' of https://github.com/cosmos/cosmos-sdk…
aleem1314 Sep 30, 2020
5d9da55
Add msg types tests
aleem1314 Oct 1, 2020
e4b8dd5
Fix Getmsgs
aleem1314 Oct 3, 2020
4f2e40e
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk into al…
aleem1314 Oct 3, 2020
3b487ad
fixed codec issue
atheeshp Oct 3, 2020
c0ec30e
Fix syntax issues
aleem1314 Oct 3, 2020
df76719
Merge branch 'master' of github.com:cosmos/cosmos-sdk into msg_auth_p…
atheeshp Oct 3, 2020
8d480cd
Merge branch 'msg_auth_proto' of https://github.com/cosmos/cosmos-sdk…
aleem1314 Oct 3, 2020
3e985e7
Fix keeper
aleem1314 Oct 3, 2020
f6024d3
fixed proto issues
atheeshp Oct 3, 2020
6243445
Fix keeper tests
aleem1314 Oct 3, 2020
2490825
Merge branch 'msg_auth_proto' of https://github.com/cosmos/cosmos-sdk…
aleem1314 Oct 3, 2020
2f75c50
fixed router in keeper
atheeshp Oct 3, 2020
4cb8b77
Merge branch 'master' into msg_authorization
atheeshp Oct 5, 2020
9745393
Merge branch 'msg_authorization' of github.com:cosmos/cosmos-sdk into…
atheeshp Oct 5, 2020
24da343
Merge branch 'master' of github.com:cosmos/cosmos-sdk into msg_author…
atheeshp Oct 5, 2020
fbbcbac
Merge branch 'msg_authorization' of github.com:cosmos/cosmos-sdk into…
atheeshp Oct 5, 2020
d280dad
Merge branch 'msg_auth_proto' of github.com:cosmos/cosmos-sdk into ms…
atheeshp Oct 5, 2020
63acf05
Fix query proto
aleem1314 Oct 5, 2020
f22d8be
Merge branch 'aleem/msg_authorization' into msg_authorization
aleem1314 Oct 5, 2020
6d4f640
Merge branch 'master' of github.com:cosmos/cosmos-sdk into msg_author…
atheeshp Oct 5, 2020
cd4dba1
Merge branch 'msg_authorization' of github.com:cosmos/cosmos-sdk into…
atheeshp Oct 5, 2020
0f6266b
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk into ms…
aleem1314 Oct 6, 2020
38566b6
Fix cli txs
aleem1314 Oct 6, 2020
b118e4c
Add grpc query client implementation
aleem1314 Oct 6, 2020
01ad577
Add grpc-keeper test
aleem1314 Oct 6, 2020
246f3f4
Add grpc query tests
aleem1314 Oct 7, 2020
f4a5734
Fix linting issues
aleem1314 Oct 7, 2020
d442400
Fix cli query
aleem1314 Oct 7, 2020
2bae46c
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk into ms…
aleem1314 Oct 7, 2020
2b759a7
fix lint errors
aleem1314 Oct 7, 2020
6f6cf7e
Add Genesis state
aleem1314 Oct 8, 2020
35e107d
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk into ms…
aleem1314 Oct 8, 2020
edf46c8
Fix query authorization
aleem1314 Oct 9, 2020
4bd54a6
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk into ms…
aleem1314 Oct 9, 2020
9d1040d
Review changes
aleem1314 Oct 9, 2020
d8a2a18
Fix grant authorization handler
aleem1314 Oct 12, 2020
d100e49
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk into ms…
aleem1314 Oct 12, 2020
9ec3f39
Add cli tests
aleem1314 Oct 12, 2020
ab3f14a
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk into ms…
aleem1314 Oct 12, 2020
f1e434b
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk into ms…
aleem1314 Oct 13, 2020
5c37e32
Add cli tests
aleem1314 Oct 14, 2020
8be9599
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk into ms…
aleem1314 Oct 14, 2020
8b16c06
Fix genesis test
aleem1314 Oct 14, 2020
291ec19
Fix issues
aleem1314 Oct 14, 2020
d81ec6b
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk into ms…
aleem1314 Oct 14, 2020
1d6aa18
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk into ms…
aleem1314 Oct 15, 2020
cd72441
update module to use proto msg services
aleem1314 Oct 15, 2020
53462e6
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk into ms…
aleem1314 Oct 15, 2020
39f876b
Add simultion tests
aleem1314 Oct 15, 2020
8656392
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk into ms…
aleem1314 Oct 15, 2020
04f3c8a
Fix lint
aleem1314 Oct 16, 2020
cf097d4
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk into ms…
aleem1314 Oct 16, 2020
5f95ca8
fix lint
aleem1314 Oct 16, 2020
721aab3
Merge branch 'msg_authorization' of github.com:cosmos/cosmos-sdk into…
atheeshp Oct 16, 2020
fc60444
Merge branch 'master' into msg_authorization
atheeshp Oct 16, 2020
f417681
WIP simulations
aleem1314 Oct 16, 2020
eb782c5
Merge branch 'msg_authorization' of https://github.com/cosmos/cosmos-…
aleem1314 Oct 16, 2020
d78a517
Merge branch 'msg_authorization' of github.com:cosmos/cosmos-sdk into…
atheeshp Oct 16, 2020
8d28432
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk into ms…
aleem1314 Oct 19, 2020
1c166e0
WIP simulations
aleem1314 Oct 19, 2020
3d43482
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk into ms…
aleem1314 Oct 19, 2020
1ea7693
add msg tests
aleem1314 Oct 19, 2020
fc9438a
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk into ms…
aleem1314 Oct 20, 2020
39bb25d
Fix simulation
aleem1314 Oct 20, 2020
f728be7
Fix errors
aleem1314 Oct 20, 2020
be3c14d
Merge branch 'msg_authorization' of github.com:cosmos/cosmos-sdk into…
atheeshp Oct 20, 2020
5c5d126
fix genesis import export
atheeshp Oct 20, 2020
bbd3930
fix sim tests
atheeshp Oct 20, 2020
85dfb75
fix sim
atheeshp Oct 20, 2020
a4a81c7
fix test
atheeshp Oct 20, 2020
f5bfa38
Merge branch 'master' into msg_authorization
atheeshp Oct 20, 2020
b2b2106
Merge branch 'master' into msg_authorization
atheeshp Oct 21, 2020
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
12 changes: 12 additions & 0 deletions proto/cosmos/msg_authorization/v1beta1/genesis.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
syntax = "proto3";
package cosmos.msg_authorization.v1beta1;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
package cosmos.msg_authorization.v1beta1;
package cosmos.authz.v1beta1;


import "gogoproto/gogo.proto";
import "cosmos/msg_authorization/v1beta1/tx.proto";

option go_package = "github.com/cosmos/cosmos-sdk/x/msg_authorization/types";

// GenesisState defines the msg_authorization module's genesis state.
message GenesisState {
repeated MsgGrantAuthorization authorization = 1 [(gogoproto.nullable) = false];
}
44 changes: 44 additions & 0 deletions proto/cosmos/msg_authorization/v1beta1/msg_authorization.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
syntax = "proto3";
package cosmos.msg_authorization.v1beta1;

import "cosmos/base/v1beta1/coin.proto";
import "cosmos_proto/cosmos.proto";
import "gogoproto/gogo.proto";
import "google/protobuf/any.proto";

option go_package = "github.com/cosmos/cosmos-sdk/x/msg_authorization/types";

// SendAuthorization allows the grantee to spend up to spend_limit coins from
// the granter's account.
message SendAuthorization{
option (gogoproto.equal) = true;
option (gogoproto.goproto_getters) = false;
option (cosmos_proto.implements_interface) = "Authorization";

repeated cosmos.base.v1beta1.Coin spend_limit = 1 [
(gogoproto.nullable) = false,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins",
(gogoproto.moretags) = "yaml:\"spend_limit\""
];
}

// GenericAuthorization gives the grantee unrestricted permissions to execute
// the provide method on behalf of the granter's account.
message GenericAuthorization{
option (gogoproto.equal) = true;
option (gogoproto.goproto_getters) = false;
option (cosmos_proto.implements_interface) = "Authorization";

string method_name = 1[
(gogoproto.customname)="MessageName"
];
}

// TODO
message AuthorizationGrant{
option (gogoproto.goproto_getters) = false;
google.protobuf.Any authorization = 1 [
(cosmos_proto.accepts_interface) = "Authorization"
];
int64 expiration = 2;
}
35 changes: 35 additions & 0 deletions proto/cosmos/msg_authorization/v1beta1/query.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
syntax = "proto3";
package cosmos.msg_authorization.v1beta1;

import "gogoproto/gogo.proto";
import "google/protobuf/any.proto";
import "google/api/annotations.proto";
import "cosmos_proto/cosmos.proto";

option go_package = "github.com/cosmos/cosmos-sdk/x/msg_authorization/types";

// Query defines the gRPC querier service.
service Query {
// Returns any `Authorization` (or `nil`), with the expiration time, granted to the grantee by the granter for the provided msg type.
rpc Authorization(QueryAuthorizationRequest) returns (QueryAuthorizationResponse) {
option (google.api.http).get = "/cosmos/msgauth/v1beta1/granters/{granter_addr}/grantees/{grantee_addr}/{msg_type}";
}

}

// QueryAuthorizationRequest is the request type for the Query/Authorization RPC method.
message QueryAuthorizationRequest {
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;

string granter_addr = 1;
string grantee_addr = 2;

string msg_type = 3;
}

// QueryAuthorizationResponse is the response type for the Query/Authorization RPC method.
message QueryAuthorizationResponse {
// account defines the account of the corresponding address.
google.protobuf.Any authorization = 1 [(cosmos_proto.accepts_interface) = "Authorization"];
}
83 changes: 83 additions & 0 deletions proto/cosmos/msg_authorization/v1beta1/tx.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
syntax = "proto3";
package cosmos.msg_authorization.v1beta1;

import "cosmos_proto/cosmos.proto";
import "gogoproto/gogo.proto";
import "google/protobuf/timestamp.proto";
import "google/protobuf/any.proto";
import "cosmos/base/abci/v1beta1/abci.proto";
option go_package = "github.com/cosmos/cosmos-sdk/x/msg_authorization/types";
option (gogoproto.equal_all) = true;


// Msg defines the msg_authorization Msg service.
service Msg {
// GrantAuthorization grants the provided authorization to the grantee on the granter's
// account with the provided expiration time.
rpc GrantAuthorization(MsgGrantAuthorization) returns (MsgGrantAuthorizationResponse);
// ExecAuthorized attempts to execute the provided messages using
// authorizations granted to the grantee. Each message should have only
// one signer corresponding to the granter of the authorization.
rpc ExecAuthorized(MsgExecAuthorized) returns (MsgExecAuthorizedResponse);
// RevokeAuthorization revokes any authorization corresponding to the provided method name on the
// granter's account that has been granted to the grantee.
rpc RevokeAuthorization(MsgRevokeAuthorization) returns (MsgRevokeAuthorizationResponse);
}

// MsgGrantAuthorization grants the provided authorization to the grantee on the granter's
// account with the provided expiration time.
message MsgGrantAuthorization{
option (gogoproto.equal) = true;
option (gogoproto.goproto_getters) = false;
option (gogoproto.goproto_stringer) = false;

string granter = 1;
string grantee = 2;

google.protobuf.Any authorization = 3 [
(cosmos_proto.accepts_interface) = "Authorization"
];
google.protobuf.Timestamp expiration = 4 [
(gogoproto.nullable) = false,
(gogoproto.stdtime) = true
];
}


// MsgExecAuthorizedResponse defines the Msg/MsgExecAuthorizedResponse response type.
message MsgExecAuthorizedResponse {
option (gogoproto.equal) = false;

cosmos.base.abci.v1beta1.Result result = 1;
}

// MsgExecAuthorized attempts to execute the provided messages using
// authorizations granted to the grantee. Each message should have only
// one signer corresponding to the granter of the authorization.
message MsgExecAuthorized {
option (gogoproto.goproto_getters) = false;
option (gogoproto.goproto_stringer) = false;

string grantee = 1;
repeated google.protobuf.Any msgs = 2 [
(cosmos_proto.accepts_interface) = "github.com/cosmos/cosmos-sdk/types.Msg",
(gogoproto.moretags) = "yaml:\"msgs\""
];
}

// MsgGrantAuthorizationResponse defines the Msg/MsgGrantAuthorization response type.
message MsgGrantAuthorizationResponse { }

// MsgRevokeAuthorization revokes any authorization with the provided sdk.Msg type on the
// granter's account with that has been granted to the grantee.
message MsgRevokeAuthorization{
option (gogoproto.goproto_getters) = false;
option (gogoproto.goproto_stringer) = false;

string granter = 1;
string grantee = 2;
string authorization_msg_type = 3 [(gogoproto.moretags) = "yaml:\"authorization_msg_type\""];
}

// MsgRevokeAuthorizationResponse defines the Msg/MsgRevokeAuthorizationResponse response type.
message MsgRevokeAuthorizationResponse { }
18 changes: 17 additions & 1 deletion simapp/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import (
"github.com/cosmos/cosmos-sdk/x/capability"
capabilitykeeper "github.com/cosmos/cosmos-sdk/x/capability/keeper"
capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types"

"github.com/cosmos/cosmos-sdk/x/crisis"
crisiskeeper "github.com/cosmos/cosmos-sdk/x/crisis/keeper"
crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types"
Expand Down Expand Up @@ -83,6 +84,10 @@ import (
upgradekeeper "github.com/cosmos/cosmos-sdk/x/upgrade/keeper"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"

msgauth "github.com/cosmos/cosmos-sdk/x/msg_authorization"
msgauthkeeper "github.com/cosmos/cosmos-sdk/x/msg_authorization/keeper"
msgauthtypes "github.com/cosmos/cosmos-sdk/x/msg_authorization/types"

// unnamed import of statik for swagger UI support
_ "github.com/cosmos/cosmos-sdk/client/docs/statik"
)
Expand Down Expand Up @@ -114,6 +119,7 @@ var (
upgrade.AppModuleBasic{},
evidence.AppModuleBasic{},
transfer.AppModuleBasic{},
msgauth.AppModuleBasic{},
vesting.AppModuleBasic{},
)

Expand Down Expand Up @@ -164,6 +170,7 @@ type SimApp struct {
CrisisKeeper crisiskeeper.Keeper
UpgradeKeeper upgradekeeper.Keeper
ParamsKeeper paramskeeper.Keeper
MsgAuthKeeper msgauthkeeper.Keeper
IBCKeeper *ibckeeper.Keeper // IBC Keeper must be a pointer in the app, so we can SetRouter on it correctly
EvidenceKeeper evidencekeeper.Keeper
TransferKeeper ibctransferkeeper.Keeper
Expand Down Expand Up @@ -211,6 +218,7 @@ func NewSimApp(
minttypes.StoreKey, distrtypes.StoreKey, slashingtypes.StoreKey,
govtypes.StoreKey, paramstypes.StoreKey, ibchost.StoreKey, upgradetypes.StoreKey,
evidencetypes.StoreKey, ibctransfertypes.StoreKey, capabilitytypes.StoreKey,
msgauthtypes.StoreKey,
)
tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey)
memKeys := sdk.NewMemoryStoreKeys(capabilitytypes.MemStoreKey)
Expand Down Expand Up @@ -276,6 +284,12 @@ func NewSimApp(
appCodec, keys[ibchost.StoreKey], app.StakingKeeper, scopedIBCKeeper,
)

// TODO: Add rest of the modules' routes(at the moment only bank routers added).
msgAuthRouter := msgauthtypes.NewRouter()
msgAuthRouter.AddRoute(banktypes.RouterKey, bank.NewHandler(app.BankKeeper))

app.MsgAuthKeeper = msgauthkeeper.NewKeeper(keys[msgauthtypes.StoreKey], appCodec, msgAuthRouter)

// register the proposal types
govRouter := govtypes.NewRouter()
govRouter.AddRoute(govtypes.RouterKey, govtypes.ProposalHandler).
Expand Down Expand Up @@ -334,6 +348,7 @@ func NewSimApp(
evidence.NewAppModule(app.EvidenceKeeper),
ibc.NewAppModule(app.IBCKeeper),
params.NewAppModule(app.ParamsKeeper),
msgauth.NewAppModule(appCodec, app.MsgAuthKeeper, app.AccountKeeper, app.BankKeeper),
transferModule,
)

Expand All @@ -355,7 +370,7 @@ func NewSimApp(
app.mm.SetOrderInitGenesis(
capabilitytypes.ModuleName, authtypes.ModuleName, banktypes.ModuleName, distrtypes.ModuleName, stakingtypes.ModuleName,
slashingtypes.ModuleName, govtypes.ModuleName, minttypes.ModuleName, crisistypes.ModuleName,
ibchost.ModuleName, genutiltypes.ModuleName, evidencetypes.ModuleName, ibctransfertypes.ModuleName,
ibchost.ModuleName, genutiltypes.ModuleName, evidencetypes.ModuleName, msgauthtypes.ModuleName, ibctransfertypes.ModuleName,
)

app.mm.RegisterInvariants(&app.CrisisKeeper)
Expand All @@ -380,6 +395,7 @@ func NewSimApp(
slashing.NewAppModule(appCodec, app.SlashingKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper),
params.NewAppModule(app.ParamsKeeper),
evidence.NewAppModule(app.EvidenceKeeper),
msgauth.NewAppModule(appCodec, app.MsgAuthKeeper, app.AccountKeeper, app.BankKeeper),
ibc.NewAppModule(app.IBCKeeper),
transferModule,
)
Expand Down
Loading