feat(x/feegrant): Add limits to grant pruning and enable message to aid manually (#18047)

This commit is contained in:
Facundo Medica 2023-10-16 19:28:06 +03:00 committed by GitHub
parent 13afd9389b
commit 4caecf13bb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
40 changed files with 1486 additions and 122 deletions

File diff suppressed because it is too large Load Diff

View File

@ -23,6 +23,7 @@ const _ = grpc.SupportPackageIsVersion7
const (
Msg_GrantAllowance_FullMethodName = "/cosmos.feegrant.v1beta1.Msg/GrantAllowance"
Msg_RevokeAllowance_FullMethodName = "/cosmos.feegrant.v1beta1.Msg/RevokeAllowance"
Msg_PruneAllowances_FullMethodName = "/cosmos.feegrant.v1beta1.Msg/PruneAllowances"
)
// MsgClient is the client API for Msg service.
@ -35,6 +36,8 @@ type MsgClient interface {
// RevokeAllowance revokes any fee allowance of granter's account that
// has been granted to the grantee.
RevokeAllowance(ctx context.Context, in *MsgRevokeAllowance, opts ...grpc.CallOption) (*MsgRevokeAllowanceResponse, error)
// PruneAllowances prunes expired fee allowances.
PruneAllowances(ctx context.Context, in *MsgPruneAllowances, opts ...grpc.CallOption) (*MsgPruneAllowancesResponse, error)
}
type msgClient struct {
@ -63,6 +66,15 @@ func (c *msgClient) RevokeAllowance(ctx context.Context, in *MsgRevokeAllowance,
return out, nil
}
func (c *msgClient) PruneAllowances(ctx context.Context, in *MsgPruneAllowances, opts ...grpc.CallOption) (*MsgPruneAllowancesResponse, error) {
out := new(MsgPruneAllowancesResponse)
err := c.cc.Invoke(ctx, Msg_PruneAllowances_FullMethodName, in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// MsgServer is the server API for Msg service.
// All implementations must embed UnimplementedMsgServer
// for forward compatibility
@ -73,6 +85,8 @@ type MsgServer interface {
// RevokeAllowance revokes any fee allowance of granter's account that
// has been granted to the grantee.
RevokeAllowance(context.Context, *MsgRevokeAllowance) (*MsgRevokeAllowanceResponse, error)
// PruneAllowances prunes expired fee allowances.
PruneAllowances(context.Context, *MsgPruneAllowances) (*MsgPruneAllowancesResponse, error)
mustEmbedUnimplementedMsgServer()
}
@ -86,6 +100,9 @@ func (UnimplementedMsgServer) GrantAllowance(context.Context, *MsgGrantAllowance
func (UnimplementedMsgServer) RevokeAllowance(context.Context, *MsgRevokeAllowance) (*MsgRevokeAllowanceResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method RevokeAllowance not implemented")
}
func (UnimplementedMsgServer) PruneAllowances(context.Context, *MsgPruneAllowances) (*MsgPruneAllowancesResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method PruneAllowances not implemented")
}
func (UnimplementedMsgServer) mustEmbedUnimplementedMsgServer() {}
// UnsafeMsgServer may be embedded to opt out of forward compatibility for this service.
@ -135,6 +152,24 @@ func _Msg_RevokeAllowance_Handler(srv interface{}, ctx context.Context, dec func
return interceptor(ctx, in, info, handler)
}
func _Msg_PruneAllowances_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(MsgPruneAllowances)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(MsgServer).PruneAllowances(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Msg_PruneAllowances_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(MsgServer).PruneAllowances(ctx, req.(*MsgPruneAllowances))
}
return interceptor(ctx, in, info, handler)
}
// Msg_ServiceDesc is the grpc.ServiceDesc for Msg service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
@ -150,6 +185,10 @@ var Msg_ServiceDesc = grpc.ServiceDesc{
MethodName: "RevokeAllowance",
Handler: _Msg_RevokeAllowance_Handler,
},
{
MethodName: "PruneAllowances",
Handler: _Msg_PruneAllowances_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "cosmos/feegrant/v1beta1/tx.proto",

View File

@ -3,7 +3,7 @@ module cosmossdk.io/client/v2
go 1.21
require (
cosmossdk.io/api v0.7.2-0.20230927090904-9dd34510e273
cosmossdk.io/api v0.7.2-0.20231016084709-1314de734f17
cosmossdk.io/core v0.12.0
cosmossdk.io/depinject v1.0.0-alpha.4
cosmossdk.io/x/tx v0.10.0

View File

@ -35,8 +35,8 @@ cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohl
cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs=
cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0=
cloud.google.com/go/storage v1.14.0/go.mod h1:GrKmX003DSIwi9o29oFT7YDnHYwZoctc3fOKtUw0Xmo=
cosmossdk.io/api v0.7.2-0.20230927090904-9dd34510e273 h1:rNTYK/OQQ5B8jNY0wGSOv+64Fwm7DG8Yke5eRmdTPqk=
cosmossdk.io/api v0.7.2-0.20230927090904-9dd34510e273/go.mod h1:RgzIuGUBiX4E4imKHFyxl+uSKU+qs2v0W2ymVoGoyQQ=
cosmossdk.io/api v0.7.2-0.20231016084709-1314de734f17 h1:bCxnZ6XHFedjB1bT1twYfaLxY/uMkIxgFGOFtQ9xnt4=
cosmossdk.io/api v0.7.2-0.20231016084709-1314de734f17/go.mod h1:RgzIuGUBiX4E4imKHFyxl+uSKU+qs2v0W2ymVoGoyQQ=
cosmossdk.io/collections v0.4.0 h1:PFmwj2W8szgpD5nOd8GWH6AbYNi1f2J6akWXJ7P5t9s=
cosmossdk.io/collections v0.4.0/go.mod h1:oa5lUING2dP+gdDquow+QjlF45eL1t4TJDypgGd+tv0=
cosmossdk.io/core v0.12.0 h1:aFuvkG6eDv0IQC+UDjx86wxNWVAxdCFk7OABJ1Vh4RU=

2
go.mod
View File

@ -5,7 +5,7 @@ toolchain go1.21.0
module github.com/cosmos/cosmos-sdk
require (
cosmossdk.io/api v0.7.2-0.20230927090904-9dd34510e273
cosmossdk.io/api v0.7.2-0.20231016084709-1314de734f17
cosmossdk.io/collections v0.4.0
cosmossdk.io/core v0.12.0
cosmossdk.io/depinject v1.0.0-alpha.4

4
go.sum
View File

@ -35,8 +35,8 @@ cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohl
cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs=
cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0=
cloud.google.com/go/storage v1.14.0/go.mod h1:GrKmX003DSIwi9o29oFT7YDnHYwZoctc3fOKtUw0Xmo=
cosmossdk.io/api v0.7.2-0.20230927090904-9dd34510e273 h1:rNTYK/OQQ5B8jNY0wGSOv+64Fwm7DG8Yke5eRmdTPqk=
cosmossdk.io/api v0.7.2-0.20230927090904-9dd34510e273/go.mod h1:RgzIuGUBiX4E4imKHFyxl+uSKU+qs2v0W2ymVoGoyQQ=
cosmossdk.io/api v0.7.2-0.20231016084709-1314de734f17 h1:bCxnZ6XHFedjB1bT1twYfaLxY/uMkIxgFGOFtQ9xnt4=
cosmossdk.io/api v0.7.2-0.20231016084709-1314de734f17/go.mod h1:RgzIuGUBiX4E4imKHFyxl+uSKU+qs2v0W2ymVoGoyQQ=
cosmossdk.io/collections v0.4.0 h1:PFmwj2W8szgpD5nOd8GWH6AbYNi1f2J6akWXJ7P5t9s=
cosmossdk.io/collections v0.4.0/go.mod h1:oa5lUING2dP+gdDquow+QjlF45eL1t4TJDypgGd+tv0=
cosmossdk.io/core v0.12.0 h1:aFuvkG6eDv0IQC+UDjx86wxNWVAxdCFk7OABJ1Vh4RU=

View File

@ -20,6 +20,11 @@ service Msg {
// RevokeAllowance revokes any fee allowance of granter's account that
// has been granted to the grantee.
rpc RevokeAllowance(MsgRevokeAllowance) returns (MsgRevokeAllowanceResponse);
// PruneAllowances prunes expired fee allowances, currently up to 75 at a time.
//
// Since cosmos-sdk 0.50
rpc PruneAllowances(MsgPruneAllowances) returns (MsgPruneAllowancesResponse);
}
// MsgGrantAllowance adds permission for Grantee to spend up to Allowance
@ -55,3 +60,18 @@ message MsgRevokeAllowance {
// MsgRevokeAllowanceResponse defines the Msg/RevokeAllowanceResponse response type.
message MsgRevokeAllowanceResponse {}
// MsgPruneAllowances prunes expired fee allowances.
//
// Since cosmos-sdk 0.50
message MsgPruneAllowances {
option (cosmos.msg.v1.signer) = "pruner";
// pruner is the address of the user pruning expired allowances.
string pruner = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
}
// MsgPruneAllowancesResponse defines the Msg/PruneAllowancesResponse response type.
//
// Since cosmos-sdk 0.50
message MsgPruneAllowancesResponse {}

View File

@ -3,7 +3,7 @@ module cosmossdk.io/simapp
go 1.21
require (
cosmossdk.io/api v0.7.2-0.20230927090904-9dd34510e273
cosmossdk.io/api v0.7.2-0.20231016084709-1314de734f17
cosmossdk.io/client/v2 v2.0.0-20230630094428-02b760776860
cosmossdk.io/collections v0.4.0
cosmossdk.io/core v0.12.0

View File

@ -187,8 +187,8 @@ cloud.google.com/go/webrisk v1.4.0/go.mod h1:Hn8X6Zr+ziE2aNd8SliSDWpEnSS1u4R9+xX
cloud.google.com/go/webrisk v1.5.0/go.mod h1:iPG6fr52Tv7sGk0H6qUFzmL3HHZev1htXuWDEEsqMTg=
cloud.google.com/go/workflows v1.6.0/go.mod h1:6t9F5h/unJz41YqfBmqSASJSXccBLtD1Vwf+KmJENM0=
cloud.google.com/go/workflows v1.7.0/go.mod h1:JhSrZuVZWuiDfKEFxU0/F1PQjmpnpcoISEXH2bcHC3M=
cosmossdk.io/api v0.7.2-0.20230927090904-9dd34510e273 h1:rNTYK/OQQ5B8jNY0wGSOv+64Fwm7DG8Yke5eRmdTPqk=
cosmossdk.io/api v0.7.2-0.20230927090904-9dd34510e273/go.mod h1:RgzIuGUBiX4E4imKHFyxl+uSKU+qs2v0W2ymVoGoyQQ=
cosmossdk.io/api v0.7.2-0.20231016084709-1314de734f17 h1:bCxnZ6XHFedjB1bT1twYfaLxY/uMkIxgFGOFtQ9xnt4=
cosmossdk.io/api v0.7.2-0.20231016084709-1314de734f17/go.mod h1:RgzIuGUBiX4E4imKHFyxl+uSKU+qs2v0W2ymVoGoyQQ=
cosmossdk.io/collections v0.4.0 h1:PFmwj2W8szgpD5nOd8GWH6AbYNi1f2J6akWXJ7P5t9s=
cosmossdk.io/collections v0.4.0/go.mod h1:oa5lUING2dP+gdDquow+QjlF45eL1t4TJDypgGd+tv0=
cosmossdk.io/core v0.12.0 h1:aFuvkG6eDv0IQC+UDjx86wxNWVAxdCFk7OABJ1Vh4RU=

View File

@ -17,8 +17,8 @@ schema = 3
version = "v1.33.0"
hash = "sha256-oW2OubL84ZHjw7/XD6Pjl6pdUPkAqtFS2bXQKVUec6A="
[mod."cosmossdk.io/api"]
version = "v0.7.2-0.20230927090904-9dd34510e273"
hash = "sha256-KRosrgOUbZeHDkLcSRLq4e4DHugXynj5vSHNrzGKEqs="
version = "v0.7.2-0.20231016084709-1314de734f17"
hash = "sha256-AByjhMjt6dmx4mGr+ljAoFnBBeaDYnj71mgpnGbogys="
[mod."cosmossdk.io/collections"]
version = "v0.4.0"
hash = "sha256-minFyzgO/D+Oda4E3B1qvOAN5qd65SjS6nmjca4cp/8="

View File

@ -3,7 +3,7 @@ module github.com/cosmos/cosmos-sdk/tests
go 1.21
require (
cosmossdk.io/api v0.7.2-0.20230927090904-9dd34510e273
cosmossdk.io/api v0.7.2-0.20231016084709-1314de734f17
cosmossdk.io/collections v0.4.0
cosmossdk.io/core v0.12.0
cosmossdk.io/depinject v1.0.0-alpha.4

View File

@ -187,8 +187,8 @@ cloud.google.com/go/webrisk v1.4.0/go.mod h1:Hn8X6Zr+ziE2aNd8SliSDWpEnSS1u4R9+xX
cloud.google.com/go/webrisk v1.5.0/go.mod h1:iPG6fr52Tv7sGk0H6qUFzmL3HHZev1htXuWDEEsqMTg=
cloud.google.com/go/workflows v1.6.0/go.mod h1:6t9F5h/unJz41YqfBmqSASJSXccBLtD1Vwf+KmJENM0=
cloud.google.com/go/workflows v1.7.0/go.mod h1:JhSrZuVZWuiDfKEFxU0/F1PQjmpnpcoISEXH2bcHC3M=
cosmossdk.io/api v0.7.2-0.20230927090904-9dd34510e273 h1:rNTYK/OQQ5B8jNY0wGSOv+64Fwm7DG8Yke5eRmdTPqk=
cosmossdk.io/api v0.7.2-0.20230927090904-9dd34510e273/go.mod h1:RgzIuGUBiX4E4imKHFyxl+uSKU+qs2v0W2ymVoGoyQQ=
cosmossdk.io/api v0.7.2-0.20231016084709-1314de734f17 h1:bCxnZ6XHFedjB1bT1twYfaLxY/uMkIxgFGOFtQ9xnt4=
cosmossdk.io/api v0.7.2-0.20231016084709-1314de734f17/go.mod h1:RgzIuGUBiX4E4imKHFyxl+uSKU+qs2v0W2ymVoGoyQQ=
cosmossdk.io/collections v0.4.0 h1:PFmwj2W8szgpD5nOd8GWH6AbYNi1f2J6akWXJ7P5t9s=
cosmossdk.io/collections v0.4.0/go.mod h1:oa5lUING2dP+gdDquow+QjlF45eL1t4TJDypgGd+tv0=
cosmossdk.io/core v0.12.0 h1:aFuvkG6eDv0IQC+UDjx86wxNWVAxdCFk7OABJ1Vh4RU=

View File

@ -39,7 +39,7 @@ require (
cloud.google.com/go/compute/metadata v0.2.3 // indirect
cloud.google.com/go/iam v1.1.3 // indirect
cloud.google.com/go/storage v1.33.0 // indirect
cosmossdk.io/api v0.7.2-0.20230927090904-9dd34510e273 // indirect
cosmossdk.io/api v0.7.2-0.20231016084709-1314de734f17 // indirect
cosmossdk.io/client/v2 v2.0.0-20230630094428-02b760776860 // indirect
cosmossdk.io/collections v0.4.0 // indirect
cosmossdk.io/core v0.12.0 // indirect

View File

@ -187,8 +187,8 @@ cloud.google.com/go/webrisk v1.4.0/go.mod h1:Hn8X6Zr+ziE2aNd8SliSDWpEnSS1u4R9+xX
cloud.google.com/go/webrisk v1.5.0/go.mod h1:iPG6fr52Tv7sGk0H6qUFzmL3HHZev1htXuWDEEsqMTg=
cloud.google.com/go/workflows v1.6.0/go.mod h1:6t9F5h/unJz41YqfBmqSASJSXccBLtD1Vwf+KmJENM0=
cloud.google.com/go/workflows v1.7.0/go.mod h1:JhSrZuVZWuiDfKEFxU0/F1PQjmpnpcoISEXH2bcHC3M=
cosmossdk.io/api v0.7.2-0.20230927090904-9dd34510e273 h1:rNTYK/OQQ5B8jNY0wGSOv+64Fwm7DG8Yke5eRmdTPqk=
cosmossdk.io/api v0.7.2-0.20230927090904-9dd34510e273/go.mod h1:RgzIuGUBiX4E4imKHFyxl+uSKU+qs2v0W2ymVoGoyQQ=
cosmossdk.io/api v0.7.2-0.20231016084709-1314de734f17 h1:bCxnZ6XHFedjB1bT1twYfaLxY/uMkIxgFGOFtQ9xnt4=
cosmossdk.io/api v0.7.2-0.20231016084709-1314de734f17/go.mod h1:RgzIuGUBiX4E4imKHFyxl+uSKU+qs2v0W2ymVoGoyQQ=
cosmossdk.io/collections v0.4.0 h1:PFmwj2W8szgpD5nOd8GWH6AbYNi1f2J6akWXJ7P5t9s=
cosmossdk.io/collections v0.4.0/go.mod h1:oa5lUING2dP+gdDquow+QjlF45eL1t4TJDypgGd+tv0=
cosmossdk.io/core v0.12.0 h1:aFuvkG6eDv0IQC+UDjx86wxNWVAxdCFk7OABJ1Vh4RU=

View File

@ -3,7 +3,7 @@ module cosmossdk.io/x/circuit
go 1.21
require (
cosmossdk.io/api v0.7.2-0.20230927090904-9dd34510e273
cosmossdk.io/api v0.7.2-0.20231016084709-1314de734f17
cosmossdk.io/collections v0.4.0
cosmossdk.io/core v0.12.0
cosmossdk.io/depinject v1.0.0-alpha.4

View File

@ -35,8 +35,8 @@ cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohl
cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs=
cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0=
cloud.google.com/go/storage v1.14.0/go.mod h1:GrKmX003DSIwi9o29oFT7YDnHYwZoctc3fOKtUw0Xmo=
cosmossdk.io/api v0.7.2-0.20230927090904-9dd34510e273 h1:rNTYK/OQQ5B8jNY0wGSOv+64Fwm7DG8Yke5eRmdTPqk=
cosmossdk.io/api v0.7.2-0.20230927090904-9dd34510e273/go.mod h1:RgzIuGUBiX4E4imKHFyxl+uSKU+qs2v0W2ymVoGoyQQ=
cosmossdk.io/api v0.7.2-0.20231016084709-1314de734f17 h1:bCxnZ6XHFedjB1bT1twYfaLxY/uMkIxgFGOFtQ9xnt4=
cosmossdk.io/api v0.7.2-0.20231016084709-1314de734f17/go.mod h1:RgzIuGUBiX4E4imKHFyxl+uSKU+qs2v0W2ymVoGoyQQ=
cosmossdk.io/collections v0.4.0 h1:PFmwj2W8szgpD5nOd8GWH6AbYNi1f2J6akWXJ7P5t9s=
cosmossdk.io/collections v0.4.0/go.mod h1:oa5lUING2dP+gdDquow+QjlF45eL1t4TJDypgGd+tv0=
cosmossdk.io/core v0.12.0 h1:aFuvkG6eDv0IQC+UDjx86wxNWVAxdCFk7OABJ1Vh4RU=

View File

@ -3,7 +3,7 @@ module cosmossdk.io/x/evidence
go 1.21
require (
cosmossdk.io/api v0.7.2-0.20230927090904-9dd34510e273
cosmossdk.io/api v0.7.2-0.20231016084709-1314de734f17
cosmossdk.io/collections v0.4.0
cosmossdk.io/core v0.12.0
cosmossdk.io/depinject v1.0.0-alpha.4

View File

@ -35,8 +35,8 @@ cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohl
cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs=
cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0=
cloud.google.com/go/storage v1.14.0/go.mod h1:GrKmX003DSIwi9o29oFT7YDnHYwZoctc3fOKtUw0Xmo=
cosmossdk.io/api v0.7.2-0.20230927090904-9dd34510e273 h1:rNTYK/OQQ5B8jNY0wGSOv+64Fwm7DG8Yke5eRmdTPqk=
cosmossdk.io/api v0.7.2-0.20230927090904-9dd34510e273/go.mod h1:RgzIuGUBiX4E4imKHFyxl+uSKU+qs2v0W2ymVoGoyQQ=
cosmossdk.io/api v0.7.2-0.20231016084709-1314de734f17 h1:bCxnZ6XHFedjB1bT1twYfaLxY/uMkIxgFGOFtQ9xnt4=
cosmossdk.io/api v0.7.2-0.20231016084709-1314de734f17/go.mod h1:RgzIuGUBiX4E4imKHFyxl+uSKU+qs2v0W2ymVoGoyQQ=
cosmossdk.io/collections v0.4.0 h1:PFmwj2W8szgpD5nOd8GWH6AbYNi1f2J6akWXJ7P5t9s=
cosmossdk.io/collections v0.4.0/go.mod h1:oa5lUING2dP+gdDquow+QjlF45eL1t4TJDypgGd+tv0=
cosmossdk.io/core v0.12.0 h1:aFuvkG6eDv0IQC+UDjx86wxNWVAxdCFk7OABJ1Vh4RU=

View File

@ -27,6 +27,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
### Features
* [#18047](https://github.com/cosmos/cosmos-sdk/pull/18047) Added a limit of 200 grants pruned per EndBlock and the method PruneAllowances that prunes 75 expired grants on every run.
* [#14649](https://github.com/cosmos/cosmos-sdk/pull/14649) The `x/feegrant` module is extracted to have a separate go.mod file which allows it to be a standalone module.
### API Breaking Changes

View File

@ -206,6 +206,14 @@ The feegrant module emits the following events:
| message | granter | {granterAddress} |
| message | grantee | {granteeAddress} |
### Prune fee allowances
| Type | Attribute Key | Attribute Value |
| ------- | ------------- | ---------------- |
| message | action | prune_feegrant |
| message | pruner | {prunerAddress} |
## Client
### CLI

View File

@ -6,7 +6,9 @@ const (
EventTypeRevokeFeeGrant = "revoke_feegrant"
EventTypeSetFeeGrant = "set_feegrant"
EventTypeUpdateFeeGrant = "update_feegrant"
EventTypePruneFeeGrant = "prune_feegrant"
AttributeKeyGranter = "granter"
AttributeKeyGrantee = "grantee"
AttributeKeyPruner = "pruner"
)

View File

@ -3,7 +3,7 @@ module cosmossdk.io/x/feegrant
go 1.21
require (
cosmossdk.io/api v0.7.2-0.20230927090904-9dd34510e273
cosmossdk.io/api v0.7.2-0.20231016084709-1314de734f17
cosmossdk.io/collections v0.4.0
cosmossdk.io/core v0.12.0
cosmossdk.io/depinject v1.0.0-alpha.4

View File

@ -35,8 +35,8 @@ cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohl
cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs=
cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0=
cloud.google.com/go/storage v1.14.0/go.mod h1:GrKmX003DSIwi9o29oFT7YDnHYwZoctc3fOKtUw0Xmo=
cosmossdk.io/api v0.7.2-0.20230927090904-9dd34510e273 h1:rNTYK/OQQ5B8jNY0wGSOv+64Fwm7DG8Yke5eRmdTPqk=
cosmossdk.io/api v0.7.2-0.20230927090904-9dd34510e273/go.mod h1:RgzIuGUBiX4E4imKHFyxl+uSKU+qs2v0W2ymVoGoyQQ=
cosmossdk.io/api v0.7.2-0.20231016084709-1314de734f17 h1:bCxnZ6XHFedjB1bT1twYfaLxY/uMkIxgFGOFtQ9xnt4=
cosmossdk.io/api v0.7.2-0.20231016084709-1314de734f17/go.mod h1:RgzIuGUBiX4E4imKHFyxl+uSKU+qs2v0W2ymVoGoyQQ=
cosmossdk.io/collections v0.4.0 h1:PFmwj2W8szgpD5nOd8GWH6AbYNi1f2J6akWXJ7P5t9s=
cosmossdk.io/collections v0.4.0/go.mod h1:oa5lUING2dP+gdDquow+QjlF45eL1t4TJDypgGd+tv0=
cosmossdk.io/core v0.12.0 h1:aFuvkG6eDv0IQC+UDjx86wxNWVAxdCFk7OABJ1Vh4RU=

View File

@ -128,7 +128,7 @@ func (k Keeper) GrantAllowance(ctx context.Context, granter, grantee sdk.AccAddr
// UpdateAllowance updates the existing grant.
func (k Keeper) UpdateAllowance(ctx context.Context, granter, grantee sdk.AccAddress, feeAllowance feegrant.FeeAllowanceI) error {
_, err := k.getGrant(ctx, granter, grantee)
_, err := k.GetAllowance(ctx, granter, grantee)
if err != nil {
return err
}
@ -215,16 +215,6 @@ func (k Keeper) GetAllowance(ctx context.Context, granter, grantee sdk.AccAddres
return grant.GetGrant()
}
// getGrant returns entire grant between both accounts
func (k Keeper) getGrant(ctx context.Context, granter, grantee sdk.AccAddress) (*feegrant.Grant, error) {
feegrant, err := k.FeeAllowance.Get(ctx, collections.Join(grantee, granter))
if err != nil {
return nil, err
}
return &feegrant, nil
}
// IterateAllFeeAllowances iterates over all the grants in the store.
// Callback to get all data, returns true to stop, false to keep reading
// Calling this without pagination is very expensive and only designed for export genesis
@ -245,12 +235,7 @@ func (k Keeper) IterateAllFeeAllowances(ctx context.Context, cb func(grant feegr
// UseGrantedFees will try to pay the given fee from the granter's account as requested by the grantee
func (k Keeper) UseGrantedFees(ctx context.Context, granter, grantee sdk.AccAddress, fee sdk.Coins, msgs []sdk.Msg) error {
f, err := k.getGrant(ctx, granter, grantee)
if err != nil {
return err
}
grant, err := f.GetGrant()
grant, err := k.GetAllowance(ctx, granter, grantee)
if err != nil {
return err
}
@ -334,9 +319,10 @@ func (k Keeper) ExportGenesis(ctx context.Context) (*feegrant.GenesisState, erro
}
// RemoveExpiredAllowances iterates grantsByExpiryQueue and deletes the expired grants.
func (k Keeper) RemoveExpiredAllowances(ctx context.Context) error {
func (k Keeper) RemoveExpiredAllowances(ctx context.Context, limit int) error {
exp := sdk.UnwrapSDKContext(ctx).HeaderInfo().Time
rng := collections.NewPrefixUntilTripleRange[time.Time, sdk.AccAddress, sdk.AccAddress](exp)
count := 0
err := k.FeeAllowanceQueue.Walk(ctx, rng, func(key collections.Triple[time.Time, sdk.AccAddress, sdk.AccAddress], value bool) (stop bool, err error) {
grantee, granter := key.K2(), key.K3()
@ -349,6 +335,12 @@ func (k Keeper) RemoveExpiredAllowances(ctx context.Context) error {
return true, err
}
// limit the amount of iterations to avoid taking too much time
count++
if count == limit {
return true, nil
}
return false, nil
})
if err != nil {

View File

@ -40,7 +40,7 @@ func TestKeeperTestSuite(t *testing.T) {
}
func (suite *KeeperTestSuite) SetupTest() {
suite.addrs = simtestutil.CreateIncrementalAccounts(4)
suite.addrs = simtestutil.CreateIncrementalAccounts(20)
key := storetypes.NewKVStoreKey(feegrant.StoreKey)
testCtx := testutil.DefaultContextWithDB(suite.T(), key, storetypes.NewTransientStoreKey("transient_test"))
encCfg := moduletestutil.MakeTestEncodingConfig(module.AppModuleBasic{})
@ -48,10 +48,9 @@ func (suite *KeeperTestSuite) SetupTest() {
// setup gomock and initialize some globally expected executions
ctrl := gomock.NewController(suite.T())
suite.accountKeeper = feegranttestutil.NewMockAccountKeeper(ctrl)
suite.accountKeeper.EXPECT().GetAccount(gomock.Any(), suite.addrs[0]).Return(authtypes.NewBaseAccountWithAddress(suite.addrs[0])).AnyTimes()
suite.accountKeeper.EXPECT().GetAccount(gomock.Any(), suite.addrs[1]).Return(authtypes.NewBaseAccountWithAddress(suite.addrs[1])).AnyTimes()
suite.accountKeeper.EXPECT().GetAccount(gomock.Any(), suite.addrs[2]).Return(authtypes.NewBaseAccountWithAddress(suite.addrs[2])).AnyTimes()
suite.accountKeeper.EXPECT().GetAccount(gomock.Any(), suite.addrs[3]).Return(authtypes.NewBaseAccountWithAddress(suite.addrs[3])).AnyTimes()
for i := 0; i < len(suite.addrs); i++ {
suite.accountKeeper.EXPECT().GetAccount(gomock.Any(), suite.addrs[i]).Return(authtypes.NewBaseAccountWithAddress(suite.addrs[i])).AnyTimes()
}
ac := codecaddress.NewBech32Codec("cosmos")
suite.accountKeeper.EXPECT().AddressCodec().Return(ac).AnyTimes()
@ -416,7 +415,7 @@ func (suite *KeeperTestSuite) TestPruneGrants() {
}
err := suite.feegrantKeeper.GrantAllowance(suite.ctx, tc.granter, tc.grantee, tc.allowance)
suite.NoError(err)
err = suite.feegrantKeeper.RemoveExpiredAllowances(tc.ctx)
err = suite.feegrantKeeper.RemoveExpiredAllowances(tc.ctx, 5)
suite.NoError(err)
grant, err := suite.feegrantKeeper.GetAllowance(tc.ctx, tc.granter, tc.grantee)

View File

@ -7,6 +7,7 @@ import (
errorsmod "cosmossdk.io/errors"
"cosmossdk.io/x/feegrant"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
)
@ -84,3 +85,22 @@ func (k msgServer) RevokeAllowance(ctx context.Context, msg *feegrant.MsgRevokeA
return &feegrant.MsgRevokeAllowanceResponse{}, nil
}
// PruneAllowances removes expired allowances from the store.
func (k msgServer) PruneAllowances(ctx context.Context, req *feegrant.MsgPruneAllowances) (*feegrant.MsgPruneAllowancesResponse, error) {
// 75 is an arbitrary value, we can change it later if needed
err := k.RemoveExpiredAllowances(ctx, 75)
if err != nil {
return nil, err
}
sdkCtx := sdk.UnwrapSDKContext(ctx)
sdkCtx.EventManager().EmitEvent(
sdk.NewEvent(
feegrant.EventTypePruneFeeGrant,
sdk.NewAttribute(feegrant.AttributeKeyPruner, req.Pruner),
),
)
return &feegrant.MsgPruneAllowancesResponse{}, nil
}

View File

@ -5,11 +5,13 @@ import (
"github.com/golang/mock/gomock"
"cosmossdk.io/collections"
"cosmossdk.io/core/header"
"cosmossdk.io/x/feegrant"
codecaddress "github.com/cosmos/cosmos-sdk/codec/address"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/types"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
)
@ -286,3 +288,67 @@ func (suite *KeeperTestSuite) TestRevokeAllowance() {
})
}
}
func (suite *KeeperTestSuite) TestPruneAllowances() {
ctx := suite.ctx.WithHeaderInfo(header.Info{Time: time.Now()})
oneYear := ctx.HeaderInfo().Time.AddDate(1, 0, 0)
// We create 76 allowances, all expiring in one year
count := 0
for i := 0; i < len(suite.encodedAddrs); i++ {
for j := 0; j < len(suite.encodedAddrs); j++ {
if count == 76 {
break
}
if suite.encodedAddrs[i] == suite.encodedAddrs[j] {
continue
}
any, err := codectypes.NewAnyWithValue(&feegrant.BasicAllowance{
SpendLimit: suite.atom,
Expiration: &oneYear,
})
suite.Require().NoError(err)
req := &feegrant.MsgGrantAllowance{
Granter: suite.encodedAddrs[i],
Grantee: suite.encodedAddrs[j],
Allowance: any,
}
_, err = suite.msgSrvr.GrantAllowance(ctx, req)
if err != nil {
// do not fail, just try with another pair
continue
}
count++
}
}
// we have 76 allowances
count = 0
err := suite.feegrantKeeper.FeeAllowance.Walk(ctx, nil, func(key collections.Pair[types.AccAddress, types.AccAddress], value feegrant.Grant) (stop bool, err error) {
count++
return false, nil
})
suite.Require().NoError(err)
suite.Require().Equal(76, count)
// after a year and one day passes, they are all expired
oneYearAndADay := ctx.HeaderInfo().Time.AddDate(1, 0, 1)
ctx = suite.ctx.WithHeaderInfo(header.Info{Time: oneYearAndADay})
// we prune them, but currently only 75 will be pruned
_, err = suite.msgSrvr.PruneAllowances(ctx, &feegrant.MsgPruneAllowances{})
suite.Require().NoError(err)
// we have 1 allowance left
count = 0
err = suite.feegrantKeeper.FeeAllowance.Walk(ctx, nil, func(key collections.Pair[types.AccAddress, types.AccAddress], value feegrant.Grant) (stop bool, err error) {
count++
return false, nil
})
suite.Require().NoError(err)
suite.Require().Equal(1, count)
}

View File

@ -1,14 +1,12 @@
package module
import (
"cosmossdk.io/x/feegrant/keeper"
"context"
sdk "github.com/cosmos/cosmos-sdk/types"
"cosmossdk.io/x/feegrant/keeper"
)
func EndBlocker(ctx sdk.Context, k keeper.Keeper) {
err := k.RemoveExpiredAllowances(ctx)
if err != nil {
panic(err)
}
func EndBlocker(ctx context.Context, k keeper.Keeper) error {
// 200 is an arbitrary value, we can change it later if needed
return k.RemoveExpiredAllowances(ctx, 200)
}

View File

@ -83,7 +83,7 @@ func TestFeegrantPruning(t *testing.T) {
feegrant.RegisterQueryServer(queryHelper, feegrantKeeper)
queryClient := feegrant.NewQueryClient(queryHelper)
module.EndBlocker(testCtx.Ctx, feegrantKeeper)
require.NoError(t, module.EndBlocker(testCtx.Ctx, feegrantKeeper))
granteeStr, err := ac.BytesToString(grantee)
require.NoError(t, err)
@ -95,7 +95,7 @@ func TestFeegrantPruning(t *testing.T) {
require.Len(t, res.Allowances, 2)
testCtx.Ctx = testCtx.Ctx.WithHeaderInfo(header.Info{Time: now.AddDate(0, 0, 2)})
module.EndBlocker(testCtx.Ctx, feegrantKeeper)
require.NoError(t, module.EndBlocker(testCtx.Ctx, feegrantKeeper))
res, err = queryClient.Allowances(testCtx.Ctx.Context(), &feegrant.QueryAllowancesRequest{
Grantee: granteeStr,

View File

@ -63,6 +63,13 @@ You can find the fee-grant of a granter and grantee.`),
{ProtoField: "grantee"},
},
},
{
RpcMethod: "PruneAllowances",
Use: "prune",
Short: "Prune expired allowances",
Long: "Prune up to 75 expired allowances in order to reduce the size of the store when the number of expired allowances is large.",
Example: fmt.Sprintf(`$ %s tx feegrant prune --from [mykey]`, version.AppName),
},
},
EnhanceCustomCommand: true,
},

View File

@ -21,7 +21,6 @@ import (
sdkclient "github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec"
cdctypes "github.com/cosmos/cosmos-sdk/codec/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
)
@ -160,9 +159,7 @@ func (AppModule) ConsensusVersion() uint64 { return 2 }
// EndBlock returns the end blocker for the feegrant module. It returns no validator
// updates.
func (am AppModule) EndBlock(ctx context.Context) error {
c := sdk.UnwrapSDKContext(ctx)
EndBlocker(c, am.keeper)
return nil
return EndBlocker(ctx, am.keeper)
}
func init() {

View File

@ -225,17 +225,102 @@ func (m *MsgRevokeAllowanceResponse) XXX_DiscardUnknown() {
var xxx_messageInfo_MsgRevokeAllowanceResponse proto.InternalMessageInfo
// MsgPruneAllowances prunes expired fee allowances.
type MsgPruneAllowances struct {
// pruner is the address of the user pruning expired allowances.
Pruner string `protobuf:"bytes,1,opt,name=pruner,proto3" json:"pruner,omitempty"`
}
func (m *MsgPruneAllowances) Reset() { *m = MsgPruneAllowances{} }
func (m *MsgPruneAllowances) String() string { return proto.CompactTextString(m) }
func (*MsgPruneAllowances) ProtoMessage() {}
func (*MsgPruneAllowances) Descriptor() ([]byte, []int) {
return fileDescriptor_dd44ad7946dad783, []int{4}
}
func (m *MsgPruneAllowances) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *MsgPruneAllowances) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_MsgPruneAllowances.Marshal(b, m, deterministic)
} else {
b = b[:cap(b)]
n, err := m.MarshalToSizedBuffer(b)
if err != nil {
return nil, err
}
return b[:n], nil
}
}
func (m *MsgPruneAllowances) XXX_Merge(src proto.Message) {
xxx_messageInfo_MsgPruneAllowances.Merge(m, src)
}
func (m *MsgPruneAllowances) XXX_Size() int {
return m.Size()
}
func (m *MsgPruneAllowances) XXX_DiscardUnknown() {
xxx_messageInfo_MsgPruneAllowances.DiscardUnknown(m)
}
var xxx_messageInfo_MsgPruneAllowances proto.InternalMessageInfo
func (m *MsgPruneAllowances) GetPruner() string {
if m != nil {
return m.Pruner
}
return ""
}
// MsgPruneAllowancesResponse defines the Msg/PruneAllowancesResponse response type.
type MsgPruneAllowancesResponse struct {
}
func (m *MsgPruneAllowancesResponse) Reset() { *m = MsgPruneAllowancesResponse{} }
func (m *MsgPruneAllowancesResponse) String() string { return proto.CompactTextString(m) }
func (*MsgPruneAllowancesResponse) ProtoMessage() {}
func (*MsgPruneAllowancesResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_dd44ad7946dad783, []int{5}
}
func (m *MsgPruneAllowancesResponse) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *MsgPruneAllowancesResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_MsgPruneAllowancesResponse.Marshal(b, m, deterministic)
} else {
b = b[:cap(b)]
n, err := m.MarshalToSizedBuffer(b)
if err != nil {
return nil, err
}
return b[:n], nil
}
}
func (m *MsgPruneAllowancesResponse) XXX_Merge(src proto.Message) {
xxx_messageInfo_MsgPruneAllowancesResponse.Merge(m, src)
}
func (m *MsgPruneAllowancesResponse) XXX_Size() int {
return m.Size()
}
func (m *MsgPruneAllowancesResponse) XXX_DiscardUnknown() {
xxx_messageInfo_MsgPruneAllowancesResponse.DiscardUnknown(m)
}
var xxx_messageInfo_MsgPruneAllowancesResponse proto.InternalMessageInfo
func init() {
proto.RegisterType((*MsgGrantAllowance)(nil), "cosmos.feegrant.v1beta1.MsgGrantAllowance")
proto.RegisterType((*MsgGrantAllowanceResponse)(nil), "cosmos.feegrant.v1beta1.MsgGrantAllowanceResponse")
proto.RegisterType((*MsgRevokeAllowance)(nil), "cosmos.feegrant.v1beta1.MsgRevokeAllowance")
proto.RegisterType((*MsgRevokeAllowanceResponse)(nil), "cosmos.feegrant.v1beta1.MsgRevokeAllowanceResponse")
proto.RegisterType((*MsgPruneAllowances)(nil), "cosmos.feegrant.v1beta1.MsgPruneAllowances")
proto.RegisterType((*MsgPruneAllowancesResponse)(nil), "cosmos.feegrant.v1beta1.MsgPruneAllowancesResponse")
}
func init() { proto.RegisterFile("cosmos/feegrant/v1beta1/tx.proto", fileDescriptor_dd44ad7946dad783) }
var fileDescriptor_dd44ad7946dad783 = []byte{
// 409 bytes of a gzipped FileDescriptorProto
// 455 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x48, 0xce, 0x2f, 0xce,
0xcd, 0x2f, 0xd6, 0x4f, 0x4b, 0x4d, 0x4d, 0x2f, 0x4a, 0xcc, 0x2b, 0xd1, 0x2f, 0x33, 0x4c, 0x4a,
0x2d, 0x49, 0x34, 0xd4, 0x2f, 0xa9, 0xd0, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x87, 0xa8,
@ -254,14 +339,17 @@ var fileDescriptor_dd44ad7946dad783 = []byte{
0xb2, 0xf5, 0x31, 0x7c, 0xad, 0x24, 0xcd, 0x25, 0x89, 0x21, 0x18, 0x94, 0x5a, 0x5c, 0x90, 0x9f,
0x57, 0x9c, 0xaa, 0xb4, 0x86, 0x91, 0x4b, 0xc8, 0xb7, 0x38, 0x3d, 0x28, 0xb5, 0x2c, 0x3f, 0x3b,
0x95, 0xee, 0x21, 0x65, 0xa5, 0x87, 0xee, 0x15, 0x59, 0x54, 0xaf, 0xa0, 0xb9, 0x4b, 0x49, 0x86,
0x4b, 0x0a, 0x53, 0x14, 0xe6, 0x19, 0xa3, 0xcf, 0x8c, 0x5c, 0xcc, 0xbe, 0xc5, 0xe9, 0x42, 0x05,
0x5c, 0x7c, 0x68, 0x31, 0xaf, 0xa5, 0x87, 0x2b, 0x94, 0x31, 0x82, 0x46, 0xca, 0x88, 0x78, 0xb5,
0x30, 0x9b, 0x85, 0x8a, 0xb9, 0xf8, 0xd1, 0x83, 0x50, 0x1b, 0x9f, 0x31, 0x68, 0x8a, 0xa5, 0x8c,
0x49, 0x50, 0x0c, 0xb3, 0x54, 0x8a, 0xb5, 0xe1, 0xf9, 0x06, 0x2d, 0x46, 0x27, 0xc3, 0x13, 0x8f,
0xe4, 0x18, 0x2f, 0x3c, 0x92, 0x63, 0x7c, 0xf0, 0x48, 0x8e, 0x71, 0xc2, 0x63, 0x39, 0x86, 0x0b,
0x8f, 0xe5, 0x18, 0x6e, 0x3c, 0x96, 0x63, 0x88, 0x82, 0xe6, 0x98, 0xe2, 0x94, 0x6c, 0xbd, 0xcc,
0x7c, 0xfd, 0x0a, 0x78, 0x56, 0x4d, 0x62, 0x03, 0xa7, 0x42, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff,
0xff, 0x3f, 0x13, 0x6c, 0x2e, 0xc4, 0x03, 0x00, 0x00,
0x4b, 0x0a, 0x53, 0x14, 0xee, 0x99, 0x60, 0xb0, 0x5f, 0x02, 0x8a, 0x4a, 0xf3, 0x10, 0x92, 0xc5,
0x42, 0x06, 0x5c, 0x6c, 0x05, 0x20, 0x21, 0xc2, 0x5e, 0x81, 0xaa, 0xb3, 0xe2, 0x06, 0xb9, 0x0a,
0xca, 0x81, 0x5a, 0x89, 0x66, 0x28, 0xcc, 0x4a, 0xa3, 0x17, 0x4c, 0x5c, 0xcc, 0xbe, 0xc5, 0xe9,
0x42, 0x05, 0x5c, 0x7c, 0x68, 0x89, 0x4d, 0x4b, 0x0f, 0x57, 0xc4, 0x62, 0xc4, 0x86, 0x94, 0x11,
0xf1, 0x6a, 0x61, 0x36, 0x0b, 0x15, 0x73, 0xf1, 0xa3, 0xc7, 0x9a, 0x36, 0x3e, 0x63, 0xd0, 0x14,
0x4b, 0x19, 0x93, 0xa0, 0x18, 0xd9, 0x52, 0xf4, 0xe0, 0xc5, 0x6b, 0x29, 0x9a, 0x62, 0xfc, 0x96,
0xe2, 0x08, 0x63, 0x29, 0xd6, 0x86, 0xe7, 0x1b, 0xb4, 0x18, 0x9d, 0x0c, 0x4f, 0x3c, 0x92, 0x63,
0xbc, 0xf0, 0x48, 0x8e, 0xf1, 0xc1, 0x23, 0x39, 0xc6, 0x09, 0x8f, 0xe5, 0x18, 0x2e, 0x3c, 0x96,
0x63, 0xb8, 0xf1, 0x58, 0x8e, 0x21, 0x0a, 0x5a, 0x32, 0x14, 0xa7, 0x64, 0xeb, 0x65, 0xe6, 0xeb,
0x57, 0xc0, 0x8b, 0xa4, 0x24, 0x36, 0x70, 0x6e, 0x33, 0x06, 0x04, 0x00, 0x00, 0xff, 0xff, 0x8d,
0x04, 0xdd, 0xf4, 0xac, 0x04, 0x00, 0x00,
}
// Reference imports to suppress errors if they are not otherwise used.
@ -282,6 +370,8 @@ type MsgClient interface {
// RevokeAllowance revokes any fee allowance of granter's account that
// has been granted to the grantee.
RevokeAllowance(ctx context.Context, in *MsgRevokeAllowance, opts ...grpc.CallOption) (*MsgRevokeAllowanceResponse, error)
// PruneAllowances prunes expired fee allowances.
PruneAllowances(ctx context.Context, in *MsgPruneAllowances, opts ...grpc.CallOption) (*MsgPruneAllowancesResponse, error)
}
type msgClient struct {
@ -310,6 +400,15 @@ func (c *msgClient) RevokeAllowance(ctx context.Context, in *MsgRevokeAllowance,
return out, nil
}
func (c *msgClient) PruneAllowances(ctx context.Context, in *MsgPruneAllowances, opts ...grpc.CallOption) (*MsgPruneAllowancesResponse, error) {
out := new(MsgPruneAllowancesResponse)
err := c.cc.Invoke(ctx, "/cosmos.feegrant.v1beta1.Msg/PruneAllowances", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// MsgServer is the server API for Msg service.
type MsgServer interface {
// GrantAllowance grants fee allowance to the grantee on the granter's
@ -318,6 +417,8 @@ type MsgServer interface {
// RevokeAllowance revokes any fee allowance of granter's account that
// has been granted to the grantee.
RevokeAllowance(context.Context, *MsgRevokeAllowance) (*MsgRevokeAllowanceResponse, error)
// PruneAllowances prunes expired fee allowances.
PruneAllowances(context.Context, *MsgPruneAllowances) (*MsgPruneAllowancesResponse, error)
}
// UnimplementedMsgServer can be embedded to have forward compatible implementations.
@ -330,6 +431,9 @@ func (*UnimplementedMsgServer) GrantAllowance(ctx context.Context, req *MsgGrant
func (*UnimplementedMsgServer) RevokeAllowance(ctx context.Context, req *MsgRevokeAllowance) (*MsgRevokeAllowanceResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method RevokeAllowance not implemented")
}
func (*UnimplementedMsgServer) PruneAllowances(ctx context.Context, req *MsgPruneAllowances) (*MsgPruneAllowancesResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method PruneAllowances not implemented")
}
func RegisterMsgServer(s grpc1.Server, srv MsgServer) {
s.RegisterService(&_Msg_serviceDesc, srv)
@ -371,6 +475,24 @@ func _Msg_RevokeAllowance_Handler(srv interface{}, ctx context.Context, dec func
return interceptor(ctx, in, info, handler)
}
func _Msg_PruneAllowances_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(MsgPruneAllowances)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(MsgServer).PruneAllowances(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/cosmos.feegrant.v1beta1.Msg/PruneAllowances",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(MsgServer).PruneAllowances(ctx, req.(*MsgPruneAllowances))
}
return interceptor(ctx, in, info, handler)
}
var _Msg_serviceDesc = grpc.ServiceDesc{
ServiceName: "cosmos.feegrant.v1beta1.Msg",
HandlerType: (*MsgServer)(nil),
@ -383,6 +505,10 @@ var _Msg_serviceDesc = grpc.ServiceDesc{
MethodName: "RevokeAllowance",
Handler: _Msg_RevokeAllowance_Handler,
},
{
MethodName: "PruneAllowances",
Handler: _Msg_PruneAllowances_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "cosmos/feegrant/v1beta1/tx.proto",
@ -520,6 +646,59 @@ func (m *MsgRevokeAllowanceResponse) MarshalToSizedBuffer(dAtA []byte) (int, err
return len(dAtA) - i, nil
}
func (m *MsgPruneAllowances) Marshal() (dAtA []byte, err error) {
size := m.Size()
dAtA = make([]byte, size)
n, err := m.MarshalToSizedBuffer(dAtA[:size])
if err != nil {
return nil, err
}
return dAtA[:n], nil
}
func (m *MsgPruneAllowances) MarshalTo(dAtA []byte) (int, error) {
size := m.Size()
return m.MarshalToSizedBuffer(dAtA[:size])
}
func (m *MsgPruneAllowances) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i := len(dAtA)
_ = i
var l int
_ = l
if len(m.Pruner) > 0 {
i -= len(m.Pruner)
copy(dAtA[i:], m.Pruner)
i = encodeVarintTx(dAtA, i, uint64(len(m.Pruner)))
i--
dAtA[i] = 0xa
}
return len(dAtA) - i, nil
}
func (m *MsgPruneAllowancesResponse) Marshal() (dAtA []byte, err error) {
size := m.Size()
dAtA = make([]byte, size)
n, err := m.MarshalToSizedBuffer(dAtA[:size])
if err != nil {
return nil, err
}
return dAtA[:n], nil
}
func (m *MsgPruneAllowancesResponse) MarshalTo(dAtA []byte) (int, error) {
size := m.Size()
return m.MarshalToSizedBuffer(dAtA[:size])
}
func (m *MsgPruneAllowancesResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i := len(dAtA)
_ = i
var l int
_ = l
return len(dAtA) - i, nil
}
func encodeVarintTx(dAtA []byte, offset int, v uint64) int {
offset -= sovTx(v)
base := offset
@ -587,6 +766,28 @@ func (m *MsgRevokeAllowanceResponse) Size() (n int) {
return n
}
func (m *MsgPruneAllowances) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
l = len(m.Pruner)
if l > 0 {
n += 1 + l + sovTx(uint64(l))
}
return n
}
func (m *MsgPruneAllowancesResponse) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
return n
}
func sovTx(x uint64) (n int) {
return (math_bits.Len64(x|1) + 6) / 7
}
@ -957,6 +1158,138 @@ func (m *MsgRevokeAllowanceResponse) Unmarshal(dAtA []byte) error {
}
return nil
}
func (m *MsgPruneAllowances) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
var wire uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowTx
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
wire |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
fieldNum := int32(wire >> 3)
wireType := int(wire & 0x7)
if wireType == 4 {
return fmt.Errorf("proto: MsgPruneAllowances: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: MsgPruneAllowances: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
case 1:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Pruner", wireType)
}
var stringLen uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowTx
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
stringLen |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
intStringLen := int(stringLen)
if intStringLen < 0 {
return ErrInvalidLengthTx
}
postIndex := iNdEx + intStringLen
if postIndex < 0 {
return ErrInvalidLengthTx
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.Pruner = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex
default:
iNdEx = preIndex
skippy, err := skipTx(dAtA[iNdEx:])
if err != nil {
return err
}
if (skippy < 0) || (iNdEx+skippy) < 0 {
return ErrInvalidLengthTx
}
if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF
}
iNdEx += skippy
}
}
if iNdEx > l {
return io.ErrUnexpectedEOF
}
return nil
}
func (m *MsgPruneAllowancesResponse) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
var wire uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowTx
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
wire |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
fieldNum := int32(wire >> 3)
wireType := int(wire & 0x7)
if wireType == 4 {
return fmt.Errorf("proto: MsgPruneAllowancesResponse: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: MsgPruneAllowancesResponse: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
default:
iNdEx = preIndex
skippy, err := skipTx(dAtA[iNdEx:])
if err != nil {
return err
}
if (skippy < 0) || (iNdEx+skippy) < 0 {
return ErrInvalidLengthTx
}
if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF
}
iNdEx += skippy
}
}
if iNdEx > l {
return io.ErrUnexpectedEOF
}
return nil
}
func skipTx(dAtA []byte) (n int, err error) {
l := len(dAtA)
iNdEx := 0

View File

@ -3,7 +3,7 @@ module cosmossdk.io/x/nft
go 1.21
require (
cosmossdk.io/api v0.7.2-0.20230927090904-9dd34510e273
cosmossdk.io/api v0.7.2-0.20231016084709-1314de734f17
cosmossdk.io/core v0.12.0
cosmossdk.io/depinject v1.0.0-alpha.4
cosmossdk.io/errors v1.0.0

View File

@ -35,8 +35,8 @@ cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohl
cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs=
cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0=
cloud.google.com/go/storage v1.14.0/go.mod h1:GrKmX003DSIwi9o29oFT7YDnHYwZoctc3fOKtUw0Xmo=
cosmossdk.io/api v0.7.2-0.20230927090904-9dd34510e273 h1:rNTYK/OQQ5B8jNY0wGSOv+64Fwm7DG8Yke5eRmdTPqk=
cosmossdk.io/api v0.7.2-0.20230927090904-9dd34510e273/go.mod h1:RgzIuGUBiX4E4imKHFyxl+uSKU+qs2v0W2ymVoGoyQQ=
cosmossdk.io/api v0.7.2-0.20231016084709-1314de734f17 h1:bCxnZ6XHFedjB1bT1twYfaLxY/uMkIxgFGOFtQ9xnt4=
cosmossdk.io/api v0.7.2-0.20231016084709-1314de734f17/go.mod h1:RgzIuGUBiX4E4imKHFyxl+uSKU+qs2v0W2ymVoGoyQQ=
cosmossdk.io/collections v0.4.0 h1:PFmwj2W8szgpD5nOd8GWH6AbYNi1f2J6akWXJ7P5t9s=
cosmossdk.io/collections v0.4.0/go.mod h1:oa5lUING2dP+gdDquow+QjlF45eL1t4TJDypgGd+tv0=
cosmossdk.io/core v0.12.0 h1:aFuvkG6eDv0IQC+UDjx86wxNWVAxdCFk7OABJ1Vh4RU=

View File

@ -3,7 +3,7 @@ module cosmossdk.io/x/params
go 1.21
require (
cosmossdk.io/api v0.7.2-0.20230927090904-9dd34510e273
cosmossdk.io/api v0.7.2-0.20231016084709-1314de734f17
cosmossdk.io/core v0.12.0
cosmossdk.io/depinject v1.0.0-alpha.4
cosmossdk.io/errors v1.0.0

View File

@ -35,8 +35,8 @@ cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohl
cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs=
cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0=
cloud.google.com/go/storage v1.14.0/go.mod h1:GrKmX003DSIwi9o29oFT7YDnHYwZoctc3fOKtUw0Xmo=
cosmossdk.io/api v0.7.2-0.20230927090904-9dd34510e273 h1:rNTYK/OQQ5B8jNY0wGSOv+64Fwm7DG8Yke5eRmdTPqk=
cosmossdk.io/api v0.7.2-0.20230927090904-9dd34510e273/go.mod h1:RgzIuGUBiX4E4imKHFyxl+uSKU+qs2v0W2ymVoGoyQQ=
cosmossdk.io/api v0.7.2-0.20231016084709-1314de734f17 h1:bCxnZ6XHFedjB1bT1twYfaLxY/uMkIxgFGOFtQ9xnt4=
cosmossdk.io/api v0.7.2-0.20231016084709-1314de734f17/go.mod h1:RgzIuGUBiX4E4imKHFyxl+uSKU+qs2v0W2ymVoGoyQQ=
cosmossdk.io/collections v0.4.0 h1:PFmwj2W8szgpD5nOd8GWH6AbYNi1f2J6akWXJ7P5t9s=
cosmossdk.io/collections v0.4.0/go.mod h1:oa5lUING2dP+gdDquow+QjlF45eL1t4TJDypgGd+tv0=
cosmossdk.io/core v0.12.0 h1:aFuvkG6eDv0IQC+UDjx86wxNWVAxdCFk7OABJ1Vh4RU=

View File

@ -3,7 +3,7 @@ module cosmossdk.io/x/protocolpool
go 1.21
require (
cosmossdk.io/api v0.7.2-0.20230927090904-9dd34510e273
cosmossdk.io/api v0.7.2-0.20231016084709-1314de734f17
cosmossdk.io/core v0.12.0
cosmossdk.io/depinject v1.0.0-alpha.4
cosmossdk.io/errors v1.0.0

View File

@ -35,8 +35,8 @@ cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohl
cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs=
cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0=
cloud.google.com/go/storage v1.14.0/go.mod h1:GrKmX003DSIwi9o29oFT7YDnHYwZoctc3fOKtUw0Xmo=
cosmossdk.io/api v0.7.2-0.20230927090904-9dd34510e273 h1:rNTYK/OQQ5B8jNY0wGSOv+64Fwm7DG8Yke5eRmdTPqk=
cosmossdk.io/api v0.7.2-0.20230927090904-9dd34510e273/go.mod h1:RgzIuGUBiX4E4imKHFyxl+uSKU+qs2v0W2ymVoGoyQQ=
cosmossdk.io/api v0.7.2-0.20231016084709-1314de734f17 h1:bCxnZ6XHFedjB1bT1twYfaLxY/uMkIxgFGOFtQ9xnt4=
cosmossdk.io/api v0.7.2-0.20231016084709-1314de734f17/go.mod h1:RgzIuGUBiX4E4imKHFyxl+uSKU+qs2v0W2ymVoGoyQQ=
cosmossdk.io/collections v0.4.0 h1:PFmwj2W8szgpD5nOd8GWH6AbYNi1f2J6akWXJ7P5t9s=
cosmossdk.io/collections v0.4.0/go.mod h1:oa5lUING2dP+gdDquow+QjlF45eL1t4TJDypgGd+tv0=
cosmossdk.io/core v0.12.0 h1:aFuvkG6eDv0IQC+UDjx86wxNWVAxdCFk7OABJ1Vh4RU=

View File

@ -3,7 +3,7 @@ module cosmossdk.io/x/upgrade
go 1.21
require (
cosmossdk.io/api v0.7.2-0.20230927090904-9dd34510e273
cosmossdk.io/api v0.7.2-0.20231016084709-1314de734f17
cosmossdk.io/core v0.12.0
cosmossdk.io/depinject v1.0.0-alpha.4
cosmossdk.io/errors v1.0.0

View File

@ -187,8 +187,8 @@ cloud.google.com/go/webrisk v1.4.0/go.mod h1:Hn8X6Zr+ziE2aNd8SliSDWpEnSS1u4R9+xX
cloud.google.com/go/webrisk v1.5.0/go.mod h1:iPG6fr52Tv7sGk0H6qUFzmL3HHZev1htXuWDEEsqMTg=
cloud.google.com/go/workflows v1.6.0/go.mod h1:6t9F5h/unJz41YqfBmqSASJSXccBLtD1Vwf+KmJENM0=
cloud.google.com/go/workflows v1.7.0/go.mod h1:JhSrZuVZWuiDfKEFxU0/F1PQjmpnpcoISEXH2bcHC3M=
cosmossdk.io/api v0.7.2-0.20230927090904-9dd34510e273 h1:rNTYK/OQQ5B8jNY0wGSOv+64Fwm7DG8Yke5eRmdTPqk=
cosmossdk.io/api v0.7.2-0.20230927090904-9dd34510e273/go.mod h1:RgzIuGUBiX4E4imKHFyxl+uSKU+qs2v0W2ymVoGoyQQ=
cosmossdk.io/api v0.7.2-0.20231016084709-1314de734f17 h1:bCxnZ6XHFedjB1bT1twYfaLxY/uMkIxgFGOFtQ9xnt4=
cosmossdk.io/api v0.7.2-0.20231016084709-1314de734f17/go.mod h1:RgzIuGUBiX4E4imKHFyxl+uSKU+qs2v0W2ymVoGoyQQ=
cosmossdk.io/collections v0.4.0 h1:PFmwj2W8szgpD5nOd8GWH6AbYNi1f2J6akWXJ7P5t9s=
cosmossdk.io/collections v0.4.0/go.mod h1:oa5lUING2dP+gdDquow+QjlF45eL1t4TJDypgGd+tv0=
cosmossdk.io/core v0.12.0 h1:aFuvkG6eDv0IQC+UDjx86wxNWVAxdCFk7OABJ1Vh4RU=