feat(x/authz): add limits to grant pruning and enable message to aid manually (#18737)

This commit is contained in:
Julien Robert 2023-12-15 18:56:27 +01:00 committed by GitHub
parent a5f1217c9a
commit 0ba62db727
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 2154 additions and 122 deletions

View File

@ -1109,7 +1109,425 @@ func (x *fastReflection_EventRevoke) ProtoMethods() *protoiface.Methods {
}
}
// Since: cosmos-sdk 0.43
var (
md_EventPruneExpiredGrants protoreflect.MessageDescriptor
fd_EventPruneExpiredGrants_pruner protoreflect.FieldDescriptor
)
func init() {
file_cosmos_authz_v1beta1_event_proto_init()
md_EventPruneExpiredGrants = File_cosmos_authz_v1beta1_event_proto.Messages().ByName("EventPruneExpiredGrants")
fd_EventPruneExpiredGrants_pruner = md_EventPruneExpiredGrants.Fields().ByName("pruner")
}
var _ protoreflect.Message = (*fastReflection_EventPruneExpiredGrants)(nil)
type fastReflection_EventPruneExpiredGrants EventPruneExpiredGrants
func (x *EventPruneExpiredGrants) ProtoReflect() protoreflect.Message {
return (*fastReflection_EventPruneExpiredGrants)(x)
}
func (x *EventPruneExpiredGrants) slowProtoReflect() protoreflect.Message {
mi := &file_cosmos_authz_v1beta1_event_proto_msgTypes[2]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
var _fastReflection_EventPruneExpiredGrants_messageType fastReflection_EventPruneExpiredGrants_messageType
var _ protoreflect.MessageType = fastReflection_EventPruneExpiredGrants_messageType{}
type fastReflection_EventPruneExpiredGrants_messageType struct{}
func (x fastReflection_EventPruneExpiredGrants_messageType) Zero() protoreflect.Message {
return (*fastReflection_EventPruneExpiredGrants)(nil)
}
func (x fastReflection_EventPruneExpiredGrants_messageType) New() protoreflect.Message {
return new(fastReflection_EventPruneExpiredGrants)
}
func (x fastReflection_EventPruneExpiredGrants_messageType) Descriptor() protoreflect.MessageDescriptor {
return md_EventPruneExpiredGrants
}
// Descriptor returns message descriptor, which contains only the protobuf
// type information for the message.
func (x *fastReflection_EventPruneExpiredGrants) Descriptor() protoreflect.MessageDescriptor {
return md_EventPruneExpiredGrants
}
// Type returns the message type, which encapsulates both Go and protobuf
// type information. If the Go type information is not needed,
// it is recommended that the message descriptor be used instead.
func (x *fastReflection_EventPruneExpiredGrants) Type() protoreflect.MessageType {
return _fastReflection_EventPruneExpiredGrants_messageType
}
// New returns a newly allocated and mutable empty message.
func (x *fastReflection_EventPruneExpiredGrants) New() protoreflect.Message {
return new(fastReflection_EventPruneExpiredGrants)
}
// Interface unwraps the message reflection interface and
// returns the underlying ProtoMessage interface.
func (x *fastReflection_EventPruneExpiredGrants) Interface() protoreflect.ProtoMessage {
return (*EventPruneExpiredGrants)(x)
}
// Range iterates over every populated field in an undefined order,
// calling f for each field descriptor and value encountered.
// Range returns immediately if f returns false.
// While iterating, mutating operations may only be performed
// on the current field descriptor.
func (x *fastReflection_EventPruneExpiredGrants) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) {
if x.Pruner != "" {
value := protoreflect.ValueOfString(x.Pruner)
if !f(fd_EventPruneExpiredGrants_pruner, value) {
return
}
}
}
// Has reports whether a field is populated.
//
// Some fields have the property of nullability where it is possible to
// distinguish between the default value of a field and whether the field
// was explicitly populated with the default value. Singular message fields,
// member fields of a oneof, and proto2 scalar fields are nullable. Such
// fields are populated only if explicitly set.
//
// In other cases (aside from the nullable cases above),
// a proto3 scalar field is populated if it contains a non-zero value, and
// a repeated field is populated if it is non-empty.
func (x *fastReflection_EventPruneExpiredGrants) Has(fd protoreflect.FieldDescriptor) bool {
switch fd.FullName() {
case "cosmos.authz.v1beta1.EventPruneExpiredGrants.pruner":
return x.Pruner != ""
default:
if fd.IsExtension() {
panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.EventPruneExpiredGrants"))
}
panic(fmt.Errorf("message cosmos.authz.v1beta1.EventPruneExpiredGrants does not contain field %s", fd.FullName()))
}
}
// Clear clears the field such that a subsequent Has call reports false.
//
// Clearing an extension field clears both the extension type and value
// associated with the given field number.
//
// Clear is a mutating operation and unsafe for concurrent use.
func (x *fastReflection_EventPruneExpiredGrants) Clear(fd protoreflect.FieldDescriptor) {
switch fd.FullName() {
case "cosmos.authz.v1beta1.EventPruneExpiredGrants.pruner":
x.Pruner = ""
default:
if fd.IsExtension() {
panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.EventPruneExpiredGrants"))
}
panic(fmt.Errorf("message cosmos.authz.v1beta1.EventPruneExpiredGrants does not contain field %s", fd.FullName()))
}
}
// Get retrieves the value for a field.
//
// For unpopulated scalars, it returns the default value, where
// the default value of a bytes scalar is guaranteed to be a copy.
// For unpopulated composite types, it returns an empty, read-only view
// of the value; to obtain a mutable reference, use Mutable.
func (x *fastReflection_EventPruneExpiredGrants) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value {
switch descriptor.FullName() {
case "cosmos.authz.v1beta1.EventPruneExpiredGrants.pruner":
value := x.Pruner
return protoreflect.ValueOfString(value)
default:
if descriptor.IsExtension() {
panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.EventPruneExpiredGrants"))
}
panic(fmt.Errorf("message cosmos.authz.v1beta1.EventPruneExpiredGrants does not contain field %s", descriptor.FullName()))
}
}
// Set stores the value for a field.
//
// For a field belonging to a oneof, it implicitly clears any other field
// that may be currently set within the same oneof.
// For extension fields, it implicitly stores the provided ExtensionType.
// When setting a composite type, it is unspecified whether the stored value
// aliases the source's memory in any way. If the composite value is an
// empty, read-only value, then it panics.
//
// Set is a mutating operation and unsafe for concurrent use.
func (x *fastReflection_EventPruneExpiredGrants) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) {
switch fd.FullName() {
case "cosmos.authz.v1beta1.EventPruneExpiredGrants.pruner":
x.Pruner = value.Interface().(string)
default:
if fd.IsExtension() {
panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.EventPruneExpiredGrants"))
}
panic(fmt.Errorf("message cosmos.authz.v1beta1.EventPruneExpiredGrants does not contain field %s", fd.FullName()))
}
}
// Mutable returns a mutable reference to a composite type.
//
// If the field is unpopulated, it may allocate a composite value.
// For a field belonging to a oneof, it implicitly clears any other field
// that may be currently set within the same oneof.
// For extension fields, it implicitly stores the provided ExtensionType
// if not already stored.
// It panics if the field does not contain a composite type.
//
// Mutable is a mutating operation and unsafe for concurrent use.
func (x *fastReflection_EventPruneExpiredGrants) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value {
switch fd.FullName() {
case "cosmos.authz.v1beta1.EventPruneExpiredGrants.pruner":
panic(fmt.Errorf("field pruner of message cosmos.authz.v1beta1.EventPruneExpiredGrants is not mutable"))
default:
if fd.IsExtension() {
panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.EventPruneExpiredGrants"))
}
panic(fmt.Errorf("message cosmos.authz.v1beta1.EventPruneExpiredGrants does not contain field %s", fd.FullName()))
}
}
// NewField returns a new value that is assignable to the field
// for the given descriptor. For scalars, this returns the default value.
// For lists, maps, and messages, this returns a new, empty, mutable value.
func (x *fastReflection_EventPruneExpiredGrants) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value {
switch fd.FullName() {
case "cosmos.authz.v1beta1.EventPruneExpiredGrants.pruner":
return protoreflect.ValueOfString("")
default:
if fd.IsExtension() {
panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.EventPruneExpiredGrants"))
}
panic(fmt.Errorf("message cosmos.authz.v1beta1.EventPruneExpiredGrants does not contain field %s", fd.FullName()))
}
}
// WhichOneof reports which field within the oneof is populated,
// returning nil if none are populated.
// It panics if the oneof descriptor does not belong to this message.
func (x *fastReflection_EventPruneExpiredGrants) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor {
switch d.FullName() {
default:
panic(fmt.Errorf("%s is not a oneof field in cosmos.authz.v1beta1.EventPruneExpiredGrants", d.FullName()))
}
panic("unreachable")
}
// GetUnknown retrieves the entire list of unknown fields.
// The caller may only mutate the contents of the RawFields
// if the mutated bytes are stored back into the message with SetUnknown.
func (x *fastReflection_EventPruneExpiredGrants) GetUnknown() protoreflect.RawFields {
return x.unknownFields
}
// SetUnknown stores an entire list of unknown fields.
// The raw fields must be syntactically valid according to the wire format.
// An implementation may panic if this is not the case.
// Once stored, the caller must not mutate the content of the RawFields.
// An empty RawFields may be passed to clear the fields.
//
// SetUnknown is a mutating operation and unsafe for concurrent use.
func (x *fastReflection_EventPruneExpiredGrants) SetUnknown(fields protoreflect.RawFields) {
x.unknownFields = fields
}
// IsValid reports whether the message is valid.
//
// An invalid message is an empty, read-only value.
//
// An invalid message often corresponds to a nil pointer of the concrete
// message type, but the details are implementation dependent.
// Validity is not part of the protobuf data model, and may not
// be preserved in marshaling or other operations.
func (x *fastReflection_EventPruneExpiredGrants) IsValid() bool {
return x != nil
}
// ProtoMethods returns optional fastReflectionFeature-path implementations of various operations.
// This method may return nil.
//
// The returned methods type is identical to
// "google.golang.org/protobuf/runtime/protoiface".Methods.
// Consult the protoiface package documentation for details.
func (x *fastReflection_EventPruneExpiredGrants) ProtoMethods() *protoiface.Methods {
size := func(input protoiface.SizeInput) protoiface.SizeOutput {
x := input.Message.Interface().(*EventPruneExpiredGrants)
if x == nil {
return protoiface.SizeOutput{
NoUnkeyedLiterals: input.NoUnkeyedLiterals,
Size: 0,
}
}
options := runtime.SizeInputToOptions(input)
_ = options
var n int
var l int
_ = l
l = len(x.Pruner)
if l > 0 {
n += 1 + l + runtime.Sov(uint64(l))
}
if x.unknownFields != nil {
n += len(x.unknownFields)
}
return protoiface.SizeOutput{
NoUnkeyedLiterals: input.NoUnkeyedLiterals,
Size: n,
}
}
marshal := func(input protoiface.MarshalInput) (protoiface.MarshalOutput, error) {
x := input.Message.Interface().(*EventPruneExpiredGrants)
if x == nil {
return protoiface.MarshalOutput{
NoUnkeyedLiterals: input.NoUnkeyedLiterals,
Buf: input.Buf,
}, nil
}
options := runtime.MarshalInputToOptions(input)
_ = options
size := options.Size(x)
dAtA := make([]byte, size)
i := len(dAtA)
_ = i
var l int
_ = l
if x.unknownFields != nil {
i -= len(x.unknownFields)
copy(dAtA[i:], x.unknownFields)
}
if len(x.Pruner) > 0 {
i -= len(x.Pruner)
copy(dAtA[i:], x.Pruner)
i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Pruner)))
i--
dAtA[i] = 0x12
}
if input.Buf != nil {
input.Buf = append(input.Buf, dAtA...)
} else {
input.Buf = dAtA
}
return protoiface.MarshalOutput{
NoUnkeyedLiterals: input.NoUnkeyedLiterals,
Buf: input.Buf,
}, nil
}
unmarshal := func(input protoiface.UnmarshalInput) (protoiface.UnmarshalOutput, error) {
x := input.Message.Interface().(*EventPruneExpiredGrants)
if x == nil {
return protoiface.UnmarshalOutput{
NoUnkeyedLiterals: input.NoUnkeyedLiterals,
Flags: input.Flags,
}, nil
}
options := runtime.UnmarshalInputToOptions(input)
_ = options
dAtA := input.Buf
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
var wire uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow
}
if iNdEx >= l {
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, 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 protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: EventPruneExpiredGrants: wiretype end group for non-group")
}
if fieldNum <= 0 {
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: EventPruneExpiredGrants: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
case 2:
if wireType != 2 {
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Pruner", wireType)
}
var stringLen uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow
}
if iNdEx >= l {
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
stringLen |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
intStringLen := int(stringLen)
if intStringLen < 0 {
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength
}
postIndex := iNdEx + intStringLen
if postIndex < 0 {
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength
}
if postIndex > l {
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF
}
x.Pruner = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex
default:
iNdEx = preIndex
skippy, err := runtime.Skip(dAtA[iNdEx:])
if err != nil {
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err
}
if (skippy < 0) || (iNdEx+skippy) < 0 {
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength
}
if (iNdEx + skippy) > l {
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF
}
if !options.DiscardUnknown {
x.unknownFields = append(x.unknownFields, dAtA[iNdEx:iNdEx+skippy]...)
}
iNdEx += skippy
}
}
if iNdEx > l {
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF
}
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, nil
}
return &protoiface.Methods{
NoUnkeyedLiterals: struct{}{},
Flags: protoiface.SupportMarshalDeterministic | protoiface.SupportUnmarshalDiscardUnknown,
Size: size,
Marshal: marshal,
Unmarshal: unmarshal,
Merge: nil,
CheckInitialized: nil,
}
}
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
@ -1125,6 +1543,8 @@ const (
)
// EventGrant is emitted on Msg/Grant
//
// Since: cosmos-sdk 0.43
type EventGrant struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
@ -1180,6 +1600,8 @@ func (x *EventGrant) GetGrantee() string {
}
// EventRevoke is emitted on Msg/Revoke
//
// Since: cosmos-sdk 0.43
type EventRevoke struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
@ -1234,6 +1656,45 @@ func (x *EventRevoke) GetGrantee() string {
return ""
}
// EventPruneExpiredGrants is emitted on Msg/PruneExpiredGrants
//
// Since: x/authz 1.0.0
type EventPruneExpiredGrants struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
// Address of the pruner
Pruner string `protobuf:"bytes,2,opt,name=pruner,proto3" json:"pruner,omitempty"`
}
func (x *EventPruneExpiredGrants) Reset() {
*x = EventPruneExpiredGrants{}
if protoimpl.UnsafeEnabled {
mi := &file_cosmos_authz_v1beta1_event_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *EventPruneExpiredGrants) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*EventPruneExpiredGrants) ProtoMessage() {}
// Deprecated: Use EventPruneExpiredGrants.ProtoReflect.Descriptor instead.
func (*EventPruneExpiredGrants) Descriptor() ([]byte, []int) {
return file_cosmos_authz_v1beta1_event_proto_rawDescGZIP(), []int{2}
}
func (x *EventPruneExpiredGrants) GetPruner() string {
if x != nil {
return x.Pruner
}
return ""
}
var File_cosmos_authz_v1beta1_event_proto protoreflect.FileDescriptor
var file_cosmos_authz_v1beta1_event_proto_rawDesc = []byte{
@ -1261,20 +1722,25 @@ var file_cosmos_authz_v1beta1_event_proto_rawDesc = []byte{
0x65, 0x72, 0x12, 0x32, 0x0a, 0x07, 0x67, 0x72, 0x61, 0x6e, 0x74, 0x65, 0x65, 0x18, 0x04, 0x20,
0x01, 0x28, 0x09, 0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e,
0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x07, 0x67,
0x72, 0x61, 0x6e, 0x74, 0x65, 0x65, 0x42, 0xcc, 0x01, 0x0a, 0x18, 0x63, 0x6f, 0x6d, 0x2e, 0x63,
0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x75, 0x74, 0x68, 0x7a, 0x2e, 0x76, 0x31, 0x62, 0x65,
0x74, 0x61, 0x31, 0x42, 0x0a, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50,
0x01, 0x5a, 0x32, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f,
0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x61, 0x75, 0x74, 0x68, 0x7a,
0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x3b, 0x61, 0x75, 0x74, 0x68, 0x7a, 0x76, 0x31,
0x62, 0x65, 0x74, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x41, 0x58, 0xaa, 0x02, 0x14, 0x43, 0x6f,
0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x75, 0x74, 0x68, 0x7a, 0x2e, 0x56, 0x31, 0x62, 0x65, 0x74,
0x61, 0x31, 0xca, 0x02, 0x14, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x41, 0x75, 0x74, 0x68,
0x7a, 0x5c, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xe2, 0x02, 0x20, 0x43, 0x6f, 0x73, 0x6d,
0x6f, 0x73, 0x5c, 0x41, 0x75, 0x74, 0x68, 0x7a, 0x5c, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31,
0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x16, 0x43,
0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x3a, 0x3a, 0x41, 0x75, 0x74, 0x68, 0x7a, 0x3a, 0x3a, 0x56, 0x31,
0x62, 0x65, 0x74, 0x61, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
0x72, 0x61, 0x6e, 0x74, 0x65, 0x65, 0x22, 0x4b, 0x0a, 0x17, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x50,
0x72, 0x75, 0x6e, 0x65, 0x45, 0x78, 0x70, 0x69, 0x72, 0x65, 0x64, 0x47, 0x72, 0x61, 0x6e, 0x74,
0x73, 0x12, 0x30, 0x0a, 0x06, 0x70, 0x72, 0x75, 0x6e, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28,
0x09, 0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64,
0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x06, 0x70, 0x72, 0x75,
0x6e, 0x65, 0x72, 0x42, 0xcc, 0x01, 0x0a, 0x18, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d,
0x6f, 0x73, 0x2e, 0x61, 0x75, 0x74, 0x68, 0x7a, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31,
0x42, 0x0a, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x32,
0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69,
0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x61, 0x75, 0x74, 0x68, 0x7a, 0x2f, 0x76, 0x31,
0x62, 0x65, 0x74, 0x61, 0x31, 0x3b, 0x61, 0x75, 0x74, 0x68, 0x7a, 0x76, 0x31, 0x62, 0x65, 0x74,
0x61, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x41, 0x58, 0xaa, 0x02, 0x14, 0x43, 0x6f, 0x73, 0x6d, 0x6f,
0x73, 0x2e, 0x41, 0x75, 0x74, 0x68, 0x7a, 0x2e, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xca,
0x02, 0x14, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x41, 0x75, 0x74, 0x68, 0x7a, 0x5c, 0x56,
0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xe2, 0x02, 0x20, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c,
0x41, 0x75, 0x74, 0x68, 0x7a, 0x5c, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x5c, 0x47, 0x50,
0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x16, 0x43, 0x6f, 0x73, 0x6d,
0x6f, 0x73, 0x3a, 0x3a, 0x41, 0x75, 0x74, 0x68, 0x7a, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x65, 0x74,
0x61, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
@ -1289,10 +1755,11 @@ func file_cosmos_authz_v1beta1_event_proto_rawDescGZIP() []byte {
return file_cosmos_authz_v1beta1_event_proto_rawDescData
}
var file_cosmos_authz_v1beta1_event_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
var file_cosmos_authz_v1beta1_event_proto_msgTypes = make([]protoimpl.MessageInfo, 3)
var file_cosmos_authz_v1beta1_event_proto_goTypes = []interface{}{
(*EventGrant)(nil), // 0: cosmos.authz.v1beta1.EventGrant
(*EventRevoke)(nil), // 1: cosmos.authz.v1beta1.EventRevoke
(*EventGrant)(nil), // 0: cosmos.authz.v1beta1.EventGrant
(*EventRevoke)(nil), // 1: cosmos.authz.v1beta1.EventRevoke
(*EventPruneExpiredGrants)(nil), // 2: cosmos.authz.v1beta1.EventPruneExpiredGrants
}
var file_cosmos_authz_v1beta1_event_proto_depIdxs = []int32{
0, // [0:0] is the sub-list for method output_type
@ -1332,6 +1799,18 @@ func file_cosmos_authz_v1beta1_event_proto_init() {
return nil
}
}
file_cosmos_authz_v1beta1_event_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*EventPruneExpiredGrants); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
@ -1339,7 +1818,7 @@ func file_cosmos_authz_v1beta1_event_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_cosmos_authz_v1beta1_event_proto_rawDesc,
NumEnums: 0,
NumMessages: 2,
NumMessages: 3,
NumExtensions: 0,
NumServices: 0,
},

File diff suppressed because it is too large Load Diff

View File

@ -21,9 +21,10 @@ import (
const _ = grpc.SupportPackageIsVersion7
const (
Msg_Grant_FullMethodName = "/cosmos.authz.v1beta1.Msg/Grant"
Msg_Exec_FullMethodName = "/cosmos.authz.v1beta1.Msg/Exec"
Msg_Revoke_FullMethodName = "/cosmos.authz.v1beta1.Msg/Revoke"
Msg_Grant_FullMethodName = "/cosmos.authz.v1beta1.Msg/Grant"
Msg_Exec_FullMethodName = "/cosmos.authz.v1beta1.Msg/Exec"
Msg_Revoke_FullMethodName = "/cosmos.authz.v1beta1.Msg/Revoke"
Msg_PruneExpiredGrants_FullMethodName = "/cosmos.authz.v1beta1.Msg/PruneExpiredGrants"
)
// MsgClient is the client API for Msg service.
@ -42,6 +43,10 @@ type MsgClient interface {
// Revoke revokes any authorization corresponding to the provided method name on the
// granter's account that has been granted to the grantee.
Revoke(ctx context.Context, in *MsgRevoke, opts ...grpc.CallOption) (*MsgRevokeResponse, error)
// PruneExpiredGrants prunes the expired grants. Currently up to 75 at a time.
//
// Since cosmos-sdk 0.51
PruneExpiredGrants(ctx context.Context, in *MsgPruneExpiredGrants, opts ...grpc.CallOption) (*MsgPruneExpiredGrantsResponse, error)
}
type msgClient struct {
@ -79,6 +84,15 @@ func (c *msgClient) Revoke(ctx context.Context, in *MsgRevoke, opts ...grpc.Call
return out, nil
}
func (c *msgClient) PruneExpiredGrants(ctx context.Context, in *MsgPruneExpiredGrants, opts ...grpc.CallOption) (*MsgPruneExpiredGrantsResponse, error) {
out := new(MsgPruneExpiredGrantsResponse)
err := c.cc.Invoke(ctx, Msg_PruneExpiredGrants_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
@ -95,6 +109,10 @@ type MsgServer interface {
// Revoke revokes any authorization corresponding to the provided method name on the
// granter's account that has been granted to the grantee.
Revoke(context.Context, *MsgRevoke) (*MsgRevokeResponse, error)
// PruneExpiredGrants prunes the expired grants. Currently up to 75 at a time.
//
// Since cosmos-sdk 0.51
PruneExpiredGrants(context.Context, *MsgPruneExpiredGrants) (*MsgPruneExpiredGrantsResponse, error)
mustEmbedUnimplementedMsgServer()
}
@ -111,6 +129,9 @@ func (UnimplementedMsgServer) Exec(context.Context, *MsgExec) (*MsgExecResponse,
func (UnimplementedMsgServer) Revoke(context.Context, *MsgRevoke) (*MsgRevokeResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method Revoke not implemented")
}
func (UnimplementedMsgServer) PruneExpiredGrants(context.Context, *MsgPruneExpiredGrants) (*MsgPruneExpiredGrantsResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method PruneExpiredGrants not implemented")
}
func (UnimplementedMsgServer) mustEmbedUnimplementedMsgServer() {}
// UnsafeMsgServer may be embedded to opt out of forward compatibility for this service.
@ -178,6 +199,24 @@ func _Msg_Revoke_Handler(srv interface{}, ctx context.Context, dec func(interfac
return interceptor(ctx, in, info, handler)
}
func _Msg_PruneExpiredGrants_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(MsgPruneExpiredGrants)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(MsgServer).PruneExpiredGrants(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Msg_PruneExpiredGrants_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(MsgServer).PruneExpiredGrants(ctx, req.(*MsgPruneExpiredGrants))
}
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)
@ -197,6 +236,10 @@ var Msg_ServiceDesc = grpc.ServiceDesc{
MethodName: "Revoke",
Handler: _Msg_Revoke_Handler,
},
{
MethodName: "PruneExpiredGrants",
Handler: _Msg_PruneExpiredGrants_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "cosmos/authz/v1beta1/tx.proto",

View File

@ -1,4 +1,3 @@
// Since: cosmos-sdk 0.43
syntax = "proto3";
package cosmos.authz.v1beta1;
@ -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;
@ -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;
@ -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"];
}

View File

@ -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
@ -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 {}

View File

@ -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

View File

@ -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)
@ -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).

View File

@ -24,6 +24,8 @@ var _ = math.Inf
const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
// EventGrant is emitted on Msg/Grant
//
// Since: cosmos-sdk 0.43
type EventGrant struct {
// Msg type URL for which an authorization is granted
MsgTypeUrl string `protobuf:"bytes,2,opt,name=msg_type_url,json=msgTypeUrl,proto3" json:"msg_type_url,omitempty"`
@ -88,6 +90,8 @@ func (m *EventGrant) GetGrantee() string {
}
// EventRevoke is emitted on Msg/Revoke
//
// Since: cosmos-sdk 0.43
type EventRevoke struct {
// Msg type URL for which an authorization is revoked
MsgTypeUrl string `protobuf:"bytes,2,opt,name=msg_type_url,json=msgTypeUrl,proto3" json:"msg_type_url,omitempty"`
@ -151,15 +155,64 @@ func (m *EventRevoke) GetGrantee() string {
return ""
}
// EventPruneExpiredGrants is emitted on Msg/PruneExpiredGrants
//
// Since: x/authz 1.0.0
type EventPruneExpiredGrants struct {
// Address of the pruner
Pruner string `protobuf:"bytes,2,opt,name=pruner,proto3" json:"pruner,omitempty"`
}
func (m *EventPruneExpiredGrants) Reset() { *m = EventPruneExpiredGrants{} }
func (m *EventPruneExpiredGrants) String() string { return proto.CompactTextString(m) }
func (*EventPruneExpiredGrants) ProtoMessage() {}
func (*EventPruneExpiredGrants) Descriptor() ([]byte, []int) {
return fileDescriptor_1f88cbc71a8baf1f, []int{2}
}
func (m *EventPruneExpiredGrants) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *EventPruneExpiredGrants) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_EventPruneExpiredGrants.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 *EventPruneExpiredGrants) XXX_Merge(src proto.Message) {
xxx_messageInfo_EventPruneExpiredGrants.Merge(m, src)
}
func (m *EventPruneExpiredGrants) XXX_Size() int {
return m.Size()
}
func (m *EventPruneExpiredGrants) XXX_DiscardUnknown() {
xxx_messageInfo_EventPruneExpiredGrants.DiscardUnknown(m)
}
var xxx_messageInfo_EventPruneExpiredGrants proto.InternalMessageInfo
func (m *EventPruneExpiredGrants) GetPruner() string {
if m != nil {
return m.Pruner
}
return ""
}
func init() {
proto.RegisterType((*EventGrant)(nil), "cosmos.authz.v1beta1.EventGrant")
proto.RegisterType((*EventRevoke)(nil), "cosmos.authz.v1beta1.EventRevoke")
proto.RegisterType((*EventPruneExpiredGrants)(nil), "cosmos.authz.v1beta1.EventPruneExpiredGrants")
}
func init() { proto.RegisterFile("cosmos/authz/v1beta1/event.proto", fileDescriptor_1f88cbc71a8baf1f) }
var fileDescriptor_1f88cbc71a8baf1f = []byte{
// 234 bytes of a gzipped FileDescriptorProto
// 269 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, 0x2c, 0x2d, 0xc9, 0xa8, 0xd2, 0x2f, 0x33, 0x4c, 0x4a, 0x2d, 0x49, 0x34,
0xd4, 0x4f, 0x2d, 0x4b, 0xcd, 0x2b, 0xd1, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x81, 0xa8,
@ -170,11 +223,13 @@ var fileDescriptor_1f88cbc71a8baf1f = []byte{
0xe5, 0x08, 0x19, 0x71, 0xb1, 0xa7, 0x83, 0x94, 0xa6, 0x16, 0x49, 0x30, 0x83, 0x24, 0x9d, 0x24,
0x2e, 0x6d, 0xd1, 0x85, 0x59, 0xeb, 0x98, 0x92, 0x52, 0x94, 0x5a, 0x5c, 0x1c, 0x5c, 0x52, 0x94,
0x99, 0x97, 0x1e, 0x04, 0x53, 0x88, 0xd0, 0x93, 0x2a, 0xc1, 0x42, 0x9c, 0x9e, 0x54, 0xa5, 0xe9,
0x8c, 0x5c, 0xdc, 0x60, 0x87, 0x05, 0xa5, 0x96, 0xe5, 0x67, 0xa7, 0x0e, 0x1e, 0x97, 0x39, 0xe9,
0x9d, 0x78, 0x24, 0xc7, 0x78, 0xe1, 0x91, 0x1c, 0xe3, 0x83, 0x47, 0x72, 0x8c, 0x13, 0x1e, 0xcb,
0x31, 0x5c, 0x78, 0x2c, 0xc7, 0x70, 0xe3, 0xb1, 0x1c, 0x43, 0x14, 0x54, 0x63, 0x71, 0x4a, 0xb6,
0x5e, 0x66, 0xbe, 0x7e, 0x05, 0x24, 0x9e, 0x92, 0xd8, 0xc0, 0x21, 0x6d, 0x0c, 0x08, 0x00, 0x00,
0xff, 0xff, 0x8b, 0xe3, 0x4c, 0x04, 0xbe, 0x01, 0x00, 0x00,
0x8c, 0x5c, 0xdc, 0x60, 0x87, 0x05, 0xa5, 0x96, 0xe5, 0x67, 0xa7, 0x0e, 0x22, 0x97, 0x79, 0x73,
0x89, 0x83, 0x1d, 0x16, 0x50, 0x54, 0x9a, 0x97, 0xea, 0x5a, 0x51, 0x90, 0x59, 0x94, 0x9a, 0x02,
0x0e, 0xbd, 0x62, 0x21, 0x03, 0x2e, 0xb6, 0x02, 0x90, 0x68, 0x11, 0xc4, 0x79, 0x78, 0x4c, 0x83,
0xaa, 0x73, 0xd2, 0x3b, 0xf1, 0x48, 0x8e, 0xf1, 0xc2, 0x23, 0x39, 0xc6, 0x07, 0x8f, 0xe4, 0x18,
0x27, 0x3c, 0x96, 0x63, 0xb8, 0xf0, 0x58, 0x8e, 0xe1, 0xc6, 0x63, 0x39, 0x86, 0x28, 0xa8, 0xbe,
0xe2, 0x94, 0x6c, 0xbd, 0xcc, 0x7c, 0xfd, 0x0a, 0x48, 0xa4, 0x27, 0xb1, 0x81, 0xa3, 0xcd, 0x18,
0x10, 0x00, 0x00, 0xff, 0xff, 0xe8, 0x9f, 0xa5, 0x63, 0x0b, 0x02, 0x00, 0x00,
}
func (m *EventGrant) Marshal() (dAtA []byte, err error) {
@ -265,6 +320,36 @@ func (m *EventRevoke) MarshalToSizedBuffer(dAtA []byte) (int, error) {
return len(dAtA) - i, nil
}
func (m *EventPruneExpiredGrants) 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 *EventPruneExpiredGrants) MarshalTo(dAtA []byte) (int, error) {
size := m.Size()
return m.MarshalToSizedBuffer(dAtA[:size])
}
func (m *EventPruneExpiredGrants) 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 = encodeVarintEvent(dAtA, i, uint64(len(m.Pruner)))
i--
dAtA[i] = 0x12
}
return len(dAtA) - i, nil
}
func encodeVarintEvent(dAtA []byte, offset int, v uint64) int {
offset -= sovEvent(v)
base := offset
@ -318,6 +403,19 @@ func (m *EventRevoke) Size() (n int) {
return n
}
func (m *EventPruneExpiredGrants) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
l = len(m.Pruner)
if l > 0 {
n += 1 + l + sovEvent(uint64(l))
}
return n
}
func sovEvent(x uint64) (n int) {
return (math_bits.Len64(x|1) + 6) / 7
}
@ -616,6 +714,88 @@ func (m *EventRevoke) Unmarshal(dAtA []byte) error {
}
return nil
}
func (m *EventPruneExpiredGrants) 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 ErrIntOverflowEvent
}
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: EventPruneExpiredGrants: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: EventPruneExpiredGrants: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
case 2:
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 ErrIntOverflowEvent
}
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 ErrInvalidLengthEvent
}
postIndex := iNdEx + intStringLen
if postIndex < 0 {
return ErrInvalidLengthEvent
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.Pruner = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex
default:
iNdEx = preIndex
skippy, err := skipEvent(dAtA[iNdEx:])
if err != nil {
return err
}
if (skippy < 0) || (iNdEx+skippy) < 0 {
return ErrInvalidLengthEvent
}
if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF
}
iNdEx += skippy
}
}
if iNdEx > l {
return io.ErrUnexpectedEOF
}
return nil
}
func skipEvent(dAtA []byte) (n int, err error) {
l := len(dAtA)
iNdEx := 0

View File

@ -407,7 +407,7 @@ func (k Keeper) removeFromGrantQueue(ctx context.Context, grantKey []byte, grant
}
// DequeueAndDeleteExpiredGrants deletes expired grants from the state and grant queue.
func (k Keeper) DequeueAndDeleteExpiredGrants(ctx context.Context) error {
func (k Keeper) DequeueAndDeleteExpiredGrants(ctx context.Context, limit int) error {
store := k.storeService.OpenKVStore(ctx)
sdkCtx := sdk.UnwrapSDKContext(ctx)
@ -417,6 +417,7 @@ func (k Keeper) DequeueAndDeleteExpiredGrants(ctx context.Context) error {
}
defer iterator.Close()
count := 0
for ; iterator.Valid(); iterator.Next() {
var queueItem authz.GrantQueueItem
if err := k.cdc.Unmarshal(iterator.Value(), &queueItem); err != nil {
@ -428,8 +429,7 @@ func (k Keeper) DequeueAndDeleteExpiredGrants(ctx context.Context) error {
return err
}
err = store.Delete(iterator.Key())
if err != nil {
if err = store.Delete(iterator.Key()); err != nil {
return err
}
@ -439,6 +439,12 @@ func (k Keeper) DequeueAndDeleteExpiredGrants(ctx context.Context) error {
return err
}
}
// limit the amount of iterations to avoid taking too much time
count++
if count == limit {
return nil
}
}
return nil

View File

@ -381,7 +381,7 @@ func (s *TestSuite) TestDequeueAllGrantsQueue() {
require.NoError(err)
newCtx := s.ctx.WithHeaderInfo(header.Info{Time: exp.AddDate(1, 0, 0)})
err = s.authzKeeper.DequeueAndDeleteExpiredGrants(newCtx)
err = s.authzKeeper.DequeueAndDeleteExpiredGrants(newCtx, 200)
require.NoError(err)
s.T().Log("verify expired grants are pruned from the state")

View File

@ -118,6 +118,18 @@ func (k Keeper) Exec(ctx context.Context, msg *authz.MsgExec) (*authz.MsgExecRes
return &authz.MsgExecResponse{Results: results}, nil
}
func (k Keeper) PruneExpiredGrants(ctx context.Context, msg *authz.MsgPruneExpiredGrants) (*authz.MsgPruneExpiredGrantsResponse, error) {
// 75 is an arbitrary value, we can change it later if needed
if err := k.DequeueAndDeleteExpiredGrants(ctx, 75); err != nil {
return nil, err
}
sdkCtx := sdk.UnwrapSDKContext(ctx)
_ = sdkCtx.EventManager().EmitTypedEvent(&authz.EventPruneExpiredGrants{Pruner: msg.Pruner})
return &authz.MsgPruneExpiredGrantsResponse{}, nil
}
func validateMsgs(msgs []sdk.Msg) error {
for i, msg := range msgs {
m, ok := msg.(sdk.HasValidateBasic)

View File

@ -16,7 +16,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
)
func (suite *TestSuite) createAccounts(accs int) []sdk.AccAddress {
func (suite *TestSuite) createAccounts() []sdk.AccAddress {
addrs := simtestutil.CreateIncrementalAccounts(2)
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()
@ -25,7 +25,7 @@ func (suite *TestSuite) createAccounts(accs int) []sdk.AccAddress {
func (suite *TestSuite) TestGrant() {
ctx := suite.ctx.WithHeaderInfo(header.Info{Time: time.Now()})
addrs := suite.createAccounts(2)
addrs := suite.createAccounts()
curBlockTime := ctx.HeaderInfo().Time
suite.accountKeeper.EXPECT().AddressCodec().Return(address.NewBech32Codec("cosmos")).AnyTimes()
@ -208,7 +208,7 @@ func (suite *TestSuite) TestGrant() {
}
func (suite *TestSuite) TestRevoke() {
addrs := suite.createAccounts(2)
addrs := suite.createAccounts()
grantee, granter := addrs[0], addrs[1]
@ -306,7 +306,7 @@ func (suite *TestSuite) TestRevoke() {
}
func (suite *TestSuite) TestExec() {
addrs := suite.createAccounts(2)
addrs := suite.createAccounts()
grantee, granter := addrs[0], addrs[1]
coins := sdk.NewCoins(sdk.NewCoin("steak", sdkmath.NewInt(10)))
@ -369,3 +369,49 @@ func (suite *TestSuite) TestExec() {
})
}
}
func (suite *TestSuite) TestPruneExpiredGrants() {
addrs := suite.createAccounts()
timeNow := suite.ctx.BlockTime()
expiration := timeNow.Add(time.Hour)
coins := sdk.NewCoins(sdk.NewCoin("steak", sdkmath.NewInt(10)))
grant, err := authz.NewGrant(timeNow, banktypes.NewSendAuthorization(coins, nil), &expiration)
suite.Require().NoError(err)
_, err = suite.msgSrvr.Grant(suite.ctx, &authz.MsgGrant{
Granter: addrs[0].String(),
Grantee: addrs[1].String(),
Grant: grant,
})
suite.Require().NoError(err)
_, err = suite.msgSrvr.Grant(suite.ctx, &authz.MsgGrant{
Granter: addrs[1].String(),
Grantee: addrs[0].String(),
Grant: grant,
})
suite.Require().NoError(err)
totalGrants := 0
suite.authzKeeper.IterateGrants(suite.ctx, func(sdk.AccAddress, sdk.AccAddress, authz.Grant) bool {
totalGrants++
return false
})
suite.Require().Equal(len(addrs), totalGrants)
// prune expired grants
headerInfo := suite.ctx.HeaderInfo()
headerInfo.Time = headerInfo.Time.Add(2 * time.Hour)
suite.ctx = suite.ctx.WithHeaderInfo(headerInfo)
_, err = suite.authzKeeper.PruneExpiredGrants(suite.ctx, &authz.MsgPruneExpiredGrants{Pruner: addrs[0].String()})
suite.Require().NoError(err)
totalGrants = 0
suite.authzKeeper.IterateGrants(suite.ctx, func(sdk.AccAddress, sdk.AccAddress, authz.Grant) bool {
totalGrants++
return false
})
suite.Require().Equal(0, totalGrants)
}

View File

@ -9,5 +9,6 @@ import (
// BeginBlocker is called at the beginning of every block
func BeginBlocker(ctx context.Context, keeper keeper.Keeper) error {
// delete all the mature grants
return keeper.DequeueAndDeleteExpiredGrants(ctx)
// 200 is an arbitrary value, we can change it later if needed
return keeper.DequeueAndDeleteExpiredGrants(ctx, 200)
}

View File

@ -70,6 +70,13 @@ func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions {
{ProtoField: "msg_type_url"},
},
},
{
RpcMethod: "PruneExpiredGrants",
Use: "prune-grants --from [granter]",
Short: "Prune expired grants",
Long: "Prune up to 75 expired grants in order to reduce the size of the store when the number of expired grants is large.",
Example: fmt.Sprintf(`$ %s tx authz prune-grants --from [mykey]`, version.AppName),
},
},
},
}

View File

@ -270,6 +270,85 @@ func (m *MsgRevokeResponse) XXX_DiscardUnknown() {
var xxx_messageInfo_MsgRevokeResponse proto.InternalMessageInfo
// MsgPruneExpiredGrants prunes the expired grants.
//
// Since x/authz v1.0.0
type MsgPruneExpiredGrants struct {
Pruner string `protobuf:"bytes,1,opt,name=pruner,proto3" json:"pruner,omitempty"`
}
func (m *MsgPruneExpiredGrants) Reset() { *m = MsgPruneExpiredGrants{} }
func (m *MsgPruneExpiredGrants) String() string { return proto.CompactTextString(m) }
func (*MsgPruneExpiredGrants) ProtoMessage() {}
func (*MsgPruneExpiredGrants) Descriptor() ([]byte, []int) {
return fileDescriptor_3ceddab7d8589ad1, []int{6}
}
func (m *MsgPruneExpiredGrants) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *MsgPruneExpiredGrants) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_MsgPruneExpiredGrants.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 *MsgPruneExpiredGrants) XXX_Merge(src proto.Message) {
xxx_messageInfo_MsgPruneExpiredGrants.Merge(m, src)
}
func (m *MsgPruneExpiredGrants) XXX_Size() int {
return m.Size()
}
func (m *MsgPruneExpiredGrants) XXX_DiscardUnknown() {
xxx_messageInfo_MsgPruneExpiredGrants.DiscardUnknown(m)
}
var xxx_messageInfo_MsgPruneExpiredGrants proto.InternalMessageInfo
// MsgPruneExpiredGrantsResponse defines the Msg/MsgPruneExpiredGrantsResponse response type.
//
// Since x/authz v1.0.0
type MsgPruneExpiredGrantsResponse struct {
}
func (m *MsgPruneExpiredGrantsResponse) Reset() { *m = MsgPruneExpiredGrantsResponse{} }
func (m *MsgPruneExpiredGrantsResponse) String() string { return proto.CompactTextString(m) }
func (*MsgPruneExpiredGrantsResponse) ProtoMessage() {}
func (*MsgPruneExpiredGrantsResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_3ceddab7d8589ad1, []int{7}
}
func (m *MsgPruneExpiredGrantsResponse) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *MsgPruneExpiredGrantsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_MsgPruneExpiredGrantsResponse.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 *MsgPruneExpiredGrantsResponse) XXX_Merge(src proto.Message) {
xxx_messageInfo_MsgPruneExpiredGrantsResponse.Merge(m, src)
}
func (m *MsgPruneExpiredGrantsResponse) XXX_Size() int {
return m.Size()
}
func (m *MsgPruneExpiredGrantsResponse) XXX_DiscardUnknown() {
xxx_messageInfo_MsgPruneExpiredGrantsResponse.DiscardUnknown(m)
}
var xxx_messageInfo_MsgPruneExpiredGrantsResponse proto.InternalMessageInfo
func init() {
proto.RegisterType((*MsgGrant)(nil), "cosmos.authz.v1beta1.MsgGrant")
proto.RegisterType((*MsgGrantResponse)(nil), "cosmos.authz.v1beta1.MsgGrantResponse")
@ -277,47 +356,52 @@ func init() {
proto.RegisterType((*MsgExecResponse)(nil), "cosmos.authz.v1beta1.MsgExecResponse")
proto.RegisterType((*MsgRevoke)(nil), "cosmos.authz.v1beta1.MsgRevoke")
proto.RegisterType((*MsgRevokeResponse)(nil), "cosmos.authz.v1beta1.MsgRevokeResponse")
proto.RegisterType((*MsgPruneExpiredGrants)(nil), "cosmos.authz.v1beta1.MsgPruneExpiredGrants")
proto.RegisterType((*MsgPruneExpiredGrantsResponse)(nil), "cosmos.authz.v1beta1.MsgPruneExpiredGrantsResponse")
}
func init() { proto.RegisterFile("cosmos/authz/v1beta1/tx.proto", fileDescriptor_3ceddab7d8589ad1) }
var fileDescriptor_3ceddab7d8589ad1 = []byte{
// 547 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x54, 0x3f, 0x6f, 0xd3, 0x5e,
0x14, 0xcd, 0x6b, 0x9a, 0xe6, 0x97, 0xd7, 0x4a, 0x3f, 0xea, 0x46, 0xc2, 0x75, 0x55, 0xd7, 0x32,
0x14, 0xa2, 0xa0, 0xd8, 0x8a, 0xd9, 0x22, 0x96, 0x46, 0xaa, 0x58, 0x88, 0x90, 0x0c, 0x2c, 0x2c,
0x91, 0xd3, 0x3c, 0x1e, 0x51, 0x62, 0xbf, 0xc8, 0xd7, 0x89, 0x12, 0x26, 0xc4, 0xc8, 0xc4, 0xc7,
0x80, 0x2d, 0x43, 0x47, 0x3e, 0x40, 0xc4, 0x54, 0x31, 0x20, 0x26, 0x04, 0xc9, 0x90, 0x8f, 0x01,
0xf2, 0xfb, 0x13, 0x5a, 0x94, 0x96, 0x4e, 0x2c, 0xc9, 0x7d, 0xf7, 0x9c, 0xfb, 0xde, 0x3d, 0xf7,
0x5c, 0x19, 0xef, 0x9f, 0x30, 0x08, 0x19, 0xb8, 0xc1, 0x20, 0x79, 0xf9, 0xca, 0x1d, 0x56, 0x5b,
0x24, 0x09, 0xaa, 0x6e, 0x32, 0x72, 0xfa, 0x31, 0x4b, 0x98, 0x56, 0x14, 0xb0, 0xc3, 0x61, 0x47,
0xc2, 0xc6, 0xae, 0xc8, 0x36, 0x39, 0xc7, 0x95, 0x14, 0x7e, 0x30, 0x8a, 0x94, 0x51, 0x26, 0xf2,
0x69, 0x24, 0xb3, 0xbb, 0x94, 0x31, 0xda, 0x23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 0x47, 0x09, 0xed, 0xae, 0xd3, 0x61, 0xee, 0x48, 0x7c, 0x01,
0x5a, 0x1b, 0x7c, 0x19, 0xef, 0xff, 0x0a, 0x00, 0x00, 0xff, 0xff, 0x40, 0xb2, 0xed, 0x6b, 0xa7,
0x04, 0x00, 0x00,
// 604 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x54, 0x4f, 0x6f, 0x12, 0x41,
0x1c, 0x65, 0x4a, 0x0b, 0x32, 0x34, 0xd1, 0x6e, 0x31, 0x6e, 0xb7, 0x61, 0xd9, 0xac, 0x56, 0x09,
0x0d, 0xbb, 0x42, 0x6f, 0xc4, 0x4b, 0x49, 0x88, 0x17, 0x89, 0x66, 0xfd, 0x73, 0xf0, 0x42, 0x96,
0x32, 0x8e, 0x04, 0x76, 0x67, 0xb3, 0xb3, 0x10, 0xf0, 0x64, 0x3c, 0x7a, 0xf2, 0x63, 0xe8, 0x8d,
0x43, 0x8f, 0x7e, 0x00, 0xe2, 0xa9, 0xf1, 0x60, 0x3c, 0x19, 0x85, 0x03, 0x1f, 0xc1, 0xab, 0xd9,
0x99, 0xd9, 0xb5, 0x55, 0x68, 0xeb, 0xc5, 0x0b, 0xfc, 0xfe, 0xbc, 0xdf, 0xcc, 0x7b, 0xf3, 0x66,
0x16, 0xe6, 0x8f, 0x08, 0x75, 0x08, 0x35, 0xed, 0x41, 0xf0, 0xf2, 0x95, 0x39, 0xac, 0xb4, 0x51,
0x60, 0x57, 0xcc, 0x60, 0x64, 0x78, 0x3e, 0x09, 0x88, 0x94, 0xe3, 0x6d, 0x83, 0xb5, 0x0d, 0xd1,
0x56, 0x76, 0x78, 0xb5, 0xc5, 0x30, 0xa6, 0x80, 0xb0, 0x44, 0xc9, 0x61, 0x82, 0x09, 0xaf, 0x87,
0x91, 0xa8, 0xee, 0x60, 0x42, 0x70, 0x1f, 0x99, 0x2c, 0x6b, 0x0f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0x00, 0x88, 0xd7, 0x1c, 0x42,
0x69, 0xc9, 0x81, 0xef, 0xaf, 0x1c, 0xff, 0x1b, 0xac, 0x1c, 0xfc, 0x03, 0x38, 0xda, 0x57, 0xd9,
0x78, 0x1d, 0x3e, 0xf0, 0x7a, 0x75, 0xfa, 0x43, 0x4d, 0x4c, 0x67, 0x2a, 0x38, 0x99, 0xa9, 0xe0,
0xfb, 0x4c, 0x05, 0xef, 0xe6, 0x6a, 0xe2, 0x64, 0xae, 0x26, 0xbe, 0xce, 0xd5, 0xc4, 0x73, 0xe1,
0x31, 0xed, 0xf4, 0x8c, 0x2e, 0x31, 0x47, 0xfc, 0x93, 0xd7, 0x4e, 0xb1, 0xd7, 0x77, 0xf0, 0x2b,
0x00, 0x00, 0xff, 0xff, 0x06, 0x4f, 0xd8, 0xf8, 0x98, 0x05, 0x00, 0x00,
}
// Reference imports to suppress errors if they are not otherwise used.
@ -344,6 +428,10 @@ type MsgClient interface {
// Revoke revokes any authorization corresponding to the provided method name on the
// granter's account that has been granted to the grantee.
Revoke(ctx context.Context, in *MsgRevoke, opts ...grpc.CallOption) (*MsgRevokeResponse, error)
// PruneExpiredGrants prunes the expired grants. Currently up to 75 at a time.
//
// Since cosmos-sdk 0.51
PruneExpiredGrants(ctx context.Context, in *MsgPruneExpiredGrants, opts ...grpc.CallOption) (*MsgPruneExpiredGrantsResponse, error)
}
type msgClient struct {
@ -381,6 +469,15 @@ func (c *msgClient) Revoke(ctx context.Context, in *MsgRevoke, opts ...grpc.Call
return out, nil
}
func (c *msgClient) PruneExpiredGrants(ctx context.Context, in *MsgPruneExpiredGrants, opts ...grpc.CallOption) (*MsgPruneExpiredGrantsResponse, error) {
out := new(MsgPruneExpiredGrantsResponse)
err := c.cc.Invoke(ctx, "/cosmos.authz.v1beta1.Msg/PruneExpiredGrants", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// MsgServer is the server API for Msg service.
type MsgServer interface {
// Grant grants the provided authorization to the grantee on the granter's
@ -395,6 +492,10 @@ type MsgServer interface {
// Revoke revokes any authorization corresponding to the provided method name on the
// granter's account that has been granted to the grantee.
Revoke(context.Context, *MsgRevoke) (*MsgRevokeResponse, error)
// PruneExpiredGrants prunes the expired grants. Currently up to 75 at a time.
//
// Since cosmos-sdk 0.51
PruneExpiredGrants(context.Context, *MsgPruneExpiredGrants) (*MsgPruneExpiredGrantsResponse, error)
}
// UnimplementedMsgServer can be embedded to have forward compatible implementations.
@ -410,6 +511,9 @@ func (*UnimplementedMsgServer) Exec(ctx context.Context, req *MsgExec) (*MsgExec
func (*UnimplementedMsgServer) Revoke(ctx context.Context, req *MsgRevoke) (*MsgRevokeResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method Revoke not implemented")
}
func (*UnimplementedMsgServer) PruneExpiredGrants(ctx context.Context, req *MsgPruneExpiredGrants) (*MsgPruneExpiredGrantsResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method PruneExpiredGrants not implemented")
}
func RegisterMsgServer(s grpc1.Server, srv MsgServer) {
s.RegisterService(&_Msg_serviceDesc, srv)
@ -469,6 +573,24 @@ func _Msg_Revoke_Handler(srv interface{}, ctx context.Context, dec func(interfac
return interceptor(ctx, in, info, handler)
}
func _Msg_PruneExpiredGrants_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(MsgPruneExpiredGrants)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(MsgServer).PruneExpiredGrants(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/cosmos.authz.v1beta1.Msg/PruneExpiredGrants",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(MsgServer).PruneExpiredGrants(ctx, req.(*MsgPruneExpiredGrants))
}
return interceptor(ctx, in, info, handler)
}
var _Msg_serviceDesc = grpc.ServiceDesc{
ServiceName: "cosmos.authz.v1beta1.Msg",
HandlerType: (*MsgServer)(nil),
@ -485,6 +607,10 @@ var _Msg_serviceDesc = grpc.ServiceDesc{
MethodName: "Revoke",
Handler: _Msg_Revoke_Handler,
},
{
MethodName: "PruneExpiredGrants",
Handler: _Msg_PruneExpiredGrants_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "cosmos/authz/v1beta1/tx.proto",
@ -703,6 +829,59 @@ func (m *MsgRevokeResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
return len(dAtA) - i, nil
}
func (m *MsgPruneExpiredGrants) 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 *MsgPruneExpiredGrants) MarshalTo(dAtA []byte) (int, error) {
size := m.Size()
return m.MarshalToSizedBuffer(dAtA[:size])
}
func (m *MsgPruneExpiredGrants) 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 *MsgPruneExpiredGrantsResponse) 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 *MsgPruneExpiredGrantsResponse) MarshalTo(dAtA []byte) (int, error) {
size := m.Size()
return m.MarshalToSizedBuffer(dAtA[:size])
}
func (m *MsgPruneExpiredGrantsResponse) 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
@ -806,6 +985,28 @@ func (m *MsgRevokeResponse) Size() (n int) {
return n
}
func (m *MsgPruneExpiredGrants) 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 *MsgPruneExpiredGrantsResponse) 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
}
@ -1403,6 +1604,138 @@ func (m *MsgRevokeResponse) Unmarshal(dAtA []byte) error {
}
return nil
}
func (m *MsgPruneExpiredGrants) 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: MsgPruneExpiredGrants: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: MsgPruneExpiredGrants: 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 *MsgPruneExpiredGrantsResponse) 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: MsgPruneExpiredGrantsResponse: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: MsgPruneExpiredGrantsResponse: 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