From 018b874c372ccc393cc1a2b26231516ba79a6dca Mon Sep 17 00:00:00 2001 From: mmsqe Date: Sun, 20 Aug 2023 20:39:29 +0800 Subject: [PATCH 1/2] add preblock dep --- .../app/runtime/v1alpha1/module.pulsar.go | 193 +++++++++++++++--- core/CHANGELOG.md | 2 + core/appmodule/module.go | 16 ++ .../cosmos/app/runtime/v1alpha1/module.proto | 5 + 4 files changed, 188 insertions(+), 28 deletions(-) diff --git a/api/cosmos/app/runtime/v1alpha1/module.pulsar.go b/api/cosmos/app/runtime/v1alpha1/module.pulsar.go index d29da340c17..14cb9784ab3 100644 --- a/api/cosmos/app/runtime/v1alpha1/module.pulsar.go +++ b/api/cosmos/app/runtime/v1alpha1/module.pulsar.go @@ -386,6 +386,52 @@ func (x *_Module_9_list) IsValid() bool { return x.list != nil } +var _ protoreflect.List = (*_Module_10_list)(nil) + +type _Module_10_list struct { + list *[]string +} + +func (x *_Module_10_list) Len() int { + if x.list == nil { + return 0 + } + return len(*x.list) +} + +func (x *_Module_10_list) Get(i int) protoreflect.Value { + return protoreflect.ValueOfString((*x.list)[i]) +} + +func (x *_Module_10_list) Set(i int, value protoreflect.Value) { + valueUnwrapped := value.String() + concreteValue := valueUnwrapped + (*x.list)[i] = concreteValue +} + +func (x *_Module_10_list) Append(value protoreflect.Value) { + valueUnwrapped := value.String() + concreteValue := valueUnwrapped + *x.list = append(*x.list, concreteValue) +} + +func (x *_Module_10_list) AppendMutable() protoreflect.Value { + panic(fmt.Errorf("AppendMutable can not be called on message Module at list field PreBlockers as it is not of Message kind")) +} + +func (x *_Module_10_list) Truncate(n int) { + *x.list = (*x.list)[:n] +} + +func (x *_Module_10_list) NewElement() protoreflect.Value { + v := "" + return protoreflect.ValueOfString(v) +} + +func (x *_Module_10_list) IsValid() bool { + return x.list != nil +} + var ( md_Module protoreflect.MessageDescriptor fd_Module_app_name protoreflect.FieldDescriptor @@ -397,6 +443,7 @@ var ( fd_Module_order_migrations protoreflect.FieldDescriptor fd_Module_precommiters protoreflect.FieldDescriptor fd_Module_prepare_check_staters protoreflect.FieldDescriptor + fd_Module_pre_blockers protoreflect.FieldDescriptor ) func init() { @@ -411,6 +458,7 @@ func init() { fd_Module_order_migrations = md_Module.Fields().ByName("order_migrations") fd_Module_precommiters = md_Module.Fields().ByName("precommiters") fd_Module_prepare_check_staters = md_Module.Fields().ByName("prepare_check_staters") + fd_Module_pre_blockers = md_Module.Fields().ByName("pre_blockers") } var _ protoreflect.Message = (*fastReflection_Module)(nil) @@ -532,6 +580,12 @@ func (x *fastReflection_Module) Range(f func(protoreflect.FieldDescriptor, proto return } } + if len(x.PreBlockers) != 0 { + value := protoreflect.ValueOfList(&_Module_10_list{list: &x.PreBlockers}) + if !f(fd_Module_pre_blockers, value) { + return + } + } } // Has reports whether a field is populated. @@ -565,6 +619,8 @@ func (x *fastReflection_Module) Has(fd protoreflect.FieldDescriptor) bool { return len(x.Precommiters) != 0 case "cosmos.app.runtime.v1alpha1.Module.prepare_check_staters": return len(x.PrepareCheckStaters) != 0 + case "cosmos.app.runtime.v1alpha1.Module.pre_blockers": + return len(x.PreBlockers) != 0 default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.app.runtime.v1alpha1.Module")) @@ -599,6 +655,8 @@ func (x *fastReflection_Module) Clear(fd protoreflect.FieldDescriptor) { x.Precommiters = nil case "cosmos.app.runtime.v1alpha1.Module.prepare_check_staters": x.PrepareCheckStaters = nil + case "cosmos.app.runtime.v1alpha1.Module.pre_blockers": + x.PreBlockers = nil default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.app.runtime.v1alpha1.Module")) @@ -666,6 +724,12 @@ func (x *fastReflection_Module) Get(descriptor protoreflect.FieldDescriptor) pro } listValue := &_Module_9_list{list: &x.PrepareCheckStaters} return protoreflect.ValueOfList(listValue) + case "cosmos.app.runtime.v1alpha1.Module.pre_blockers": + if len(x.PreBlockers) == 0 { + return protoreflect.ValueOfList(&_Module_10_list{}) + } + listValue := &_Module_10_list{list: &x.PreBlockers} + return protoreflect.ValueOfList(listValue) default: if descriptor.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.app.runtime.v1alpha1.Module")) @@ -720,6 +784,10 @@ func (x *fastReflection_Module) Set(fd protoreflect.FieldDescriptor, value proto lv := value.List() clv := lv.(*_Module_9_list) x.PrepareCheckStaters = *clv.list + case "cosmos.app.runtime.v1alpha1.Module.pre_blockers": + lv := value.List() + clv := lv.(*_Module_10_list) + x.PreBlockers = *clv.list default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.app.runtime.v1alpha1.Module")) @@ -788,6 +856,12 @@ func (x *fastReflection_Module) Mutable(fd protoreflect.FieldDescriptor) protore } value := &_Module_9_list{list: &x.PrepareCheckStaters} return protoreflect.ValueOfList(value) + case "cosmos.app.runtime.v1alpha1.Module.pre_blockers": + if x.PreBlockers == nil { + x.PreBlockers = []string{} + } + value := &_Module_10_list{list: &x.PreBlockers} + return protoreflect.ValueOfList(value) case "cosmos.app.runtime.v1alpha1.Module.app_name": panic(fmt.Errorf("field app_name of message cosmos.app.runtime.v1alpha1.Module is not mutable")) default: @@ -829,6 +903,9 @@ func (x *fastReflection_Module) NewField(fd protoreflect.FieldDescriptor) protor case "cosmos.app.runtime.v1alpha1.Module.prepare_check_staters": list := []string{} return protoreflect.ValueOfList(&_Module_9_list{list: &list}) + case "cosmos.app.runtime.v1alpha1.Module.pre_blockers": + list := []string{} + return protoreflect.ValueOfList(&_Module_10_list{list: &list}) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.app.runtime.v1alpha1.Module")) @@ -950,6 +1027,12 @@ func (x *fastReflection_Module) ProtoMethods() *protoiface.Methods { n += 1 + l + runtime.Sov(uint64(l)) } } + if len(x.PreBlockers) > 0 { + for _, s := range x.PreBlockers { + l = len(s) + n += 1 + l + runtime.Sov(uint64(l)) + } + } if x.unknownFields != nil { n += len(x.unknownFields) } @@ -979,6 +1062,15 @@ func (x *fastReflection_Module) ProtoMethods() *protoiface.Methods { i -= len(x.unknownFields) copy(dAtA[i:], x.unknownFields) } + if len(x.PreBlockers) > 0 { + for iNdEx := len(x.PreBlockers) - 1; iNdEx >= 0; iNdEx-- { + i -= len(x.PreBlockers[iNdEx]) + copy(dAtA[i:], x.PreBlockers[iNdEx]) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.PreBlockers[iNdEx]))) + i-- + dAtA[i] = 0x52 + } + } if len(x.PrepareCheckStaters) > 0 { for iNdEx := len(x.PrepareCheckStaters) - 1; iNdEx >= 0; iNdEx-- { i -= len(x.PrepareCheckStaters[iNdEx]) @@ -1404,6 +1496,38 @@ func (x *fastReflection_Module) ProtoMethods() *protoiface.Methods { } x.PrepareCheckStaters = append(x.PrepareCheckStaters, string(dAtA[iNdEx:postIndex])) iNdEx = postIndex + case 10: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field PreBlockers", 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.PreBlockers = append(x.PreBlockers, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := runtime.Skip(dAtA[iNdEx:]) @@ -1975,6 +2099,10 @@ type Module struct { // to call in the order in which they should be called. If this is left empty // no preparecheckstate function will be registered. PrepareCheckStaters []string `protobuf:"bytes,9,rep,name=prepare_check_staters,json=prepareCheckStaters,proto3" json:"prepare_check_staters,omitempty"` + // pre_blockers specifies the module names of pre blockers + // to call in the order in which they should be called. If this is left empty + // no pre blocker will be registered. + PreBlockers []string `protobuf:"bytes,10,rep,name=pre_blockers,json=preBlockers,proto3" json:"pre_blockers,omitempty"` } func (x *Module) Reset() { @@ -2060,6 +2188,13 @@ func (x *Module) GetPrepareCheckStaters() []string { return nil } +func (x *Module) GetPreBlockers() []string { + if x != nil { + return x.PreBlockers + } + return nil +} + // StoreKeyConfig may be supplied to override the default module store key, which // is the module name. type StoreKeyConfig struct { @@ -2116,7 +2251,7 @@ var file_cosmos_app_runtime_v1alpha1_module_proto_rawDesc = []byte{ 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x1a, 0x20, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2f, 0x6d, 0x6f, 0x64, - 0x75, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xdc, 0x03, 0x0a, 0x06, 0x4d, 0x6f, + 0x75, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xff, 0x03, 0x0a, 0x06, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x12, 0x19, 0x0a, 0x08, 0x61, 0x70, 0x70, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x61, 0x70, 0x70, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x25, 0x0a, 0x0e, 0x62, 0x65, 0x67, 0x69, 0x6e, 0x5f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x65, 0x72, @@ -2142,33 +2277,35 @@ var file_cosmos_app_runtime_v1alpha1_module_proto_rawDesc = []byte{ 0x32, 0x0a, 0x15, 0x70, 0x72, 0x65, 0x70, 0x61, 0x72, 0x65, 0x5f, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x5f, 0x73, 0x74, 0x61, 0x74, 0x65, 0x72, 0x73, 0x18, 0x09, 0x20, 0x03, 0x28, 0x09, 0x52, 0x13, 0x70, 0x72, 0x65, 0x70, 0x61, 0x72, 0x65, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x53, 0x74, 0x61, 0x74, - 0x65, 0x72, 0x73, 0x3a, 0x43, 0xba, 0xc0, 0x96, 0xda, 0x01, 0x3d, 0x0a, 0x24, 0x67, 0x69, 0x74, - 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, - 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, - 0x65, 0x12, 0x15, 0x0a, 0x13, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x70, 0x2e, - 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x22, 0x53, 0x0a, 0x0e, 0x53, 0x74, 0x6f, 0x72, - 0x65, 0x4b, 0x65, 0x79, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x1f, 0x0a, 0x0b, 0x6d, 0x6f, - 0x64, 0x75, 0x6c, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x0a, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x20, 0x0a, 0x0c, 0x6b, - 0x76, 0x5f, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x0a, 0x6b, 0x76, 0x53, 0x74, 0x6f, 0x72, 0x65, 0x4b, 0x65, 0x79, 0x42, 0xfb, 0x01, - 0x0a, 0x1f, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x70, - 0x2e, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, - 0x31, 0x42, 0x0b, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, - 0x5a, 0x3c, 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, 0x70, 0x70, 0x2f, 0x72, 0x75, - 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x3b, 0x72, - 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0xa2, 0x02, - 0x03, 0x43, 0x41, 0x52, 0xaa, 0x02, 0x1b, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x70, - 0x70, 0x2e, 0x52, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x2e, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, - 0x61, 0x31, 0xca, 0x02, 0x1b, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x41, 0x70, 0x70, 0x5c, - 0x52, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x5c, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, - 0xe2, 0x02, 0x27, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x41, 0x70, 0x70, 0x5c, 0x52, 0x75, - 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x5c, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x5c, 0x47, - 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x1e, 0x43, 0x6f, 0x73, - 0x6d, 0x6f, 0x73, 0x3a, 0x3a, 0x41, 0x70, 0x70, 0x3a, 0x3a, 0x52, 0x75, 0x6e, 0x74, 0x69, 0x6d, - 0x65, 0x3a, 0x3a, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x33, + 0x65, 0x72, 0x73, 0x12, 0x21, 0x0a, 0x0c, 0x70, 0x72, 0x65, 0x5f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, + 0x65, 0x72, 0x73, 0x18, 0x0a, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0b, 0x70, 0x72, 0x65, 0x42, 0x6c, + 0x6f, 0x63, 0x6b, 0x65, 0x72, 0x73, 0x3a, 0x43, 0xba, 0xc0, 0x96, 0xda, 0x01, 0x3d, 0x0a, 0x24, + 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, + 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x72, 0x75, 0x6e, + 0x74, 0x69, 0x6d, 0x65, 0x12, 0x15, 0x0a, 0x13, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x61, + 0x70, 0x70, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x22, 0x53, 0x0a, 0x0e, 0x53, + 0x74, 0x6f, 0x72, 0x65, 0x4b, 0x65, 0x79, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x1f, 0x0a, + 0x0b, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x0a, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x20, + 0x0a, 0x0c, 0x6b, 0x76, 0x5f, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x6b, 0x76, 0x53, 0x74, 0x6f, 0x72, 0x65, 0x4b, 0x65, 0x79, + 0x42, 0xfb, 0x01, 0x0a, 0x1f, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, + 0x61, 0x70, 0x70, 0x2e, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x2e, 0x76, 0x31, 0x61, 0x6c, + 0x70, 0x68, 0x61, 0x31, 0x42, 0x0b, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x50, 0x72, 0x6f, 0x74, + 0x6f, 0x50, 0x01, 0x5a, 0x3c, 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, 0x70, 0x70, + 0x2f, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, + 0x31, 0x3b, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, + 0x31, 0xa2, 0x02, 0x03, 0x43, 0x41, 0x52, 0xaa, 0x02, 0x1b, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, + 0x2e, 0x41, 0x70, 0x70, 0x2e, 0x52, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x2e, 0x56, 0x31, 0x61, + 0x6c, 0x70, 0x68, 0x61, 0x31, 0xca, 0x02, 0x1b, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x41, + 0x70, 0x70, 0x5c, 0x52, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x5c, 0x56, 0x31, 0x61, 0x6c, 0x70, + 0x68, 0x61, 0x31, 0xe2, 0x02, 0x27, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x41, 0x70, 0x70, + 0x5c, 0x52, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x5c, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, + 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x1e, + 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x3a, 0x3a, 0x41, 0x70, 0x70, 0x3a, 0x3a, 0x52, 0x75, 0x6e, + 0x74, 0x69, 0x6d, 0x65, 0x3a, 0x3a, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x62, 0x06, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/core/CHANGELOG.md b/core/CHANGELOG.md index 2673b35d495..7aa51692e60 100644 --- a/core/CHANGELOG.md +++ b/core/CHANGELOG.md @@ -36,6 +36,8 @@ Ref: https://keepachangelog.com/en/1.0.0/ ## [Unreleased] +* [#17421](https://github.com/cosmos/cosmos-sdk/pull/17421) Add `appmodule.HasPreBlocker` interface. + ## [v0.10.0](https://github.com/cosmos/cosmos-sdk/releases/tag/core%2Fv0.10.0) * [#17383](https://github.com/cosmos/cosmos-sdk/pull/17383) Add `appmoduke.UpgradeModule` interface. diff --git a/core/appmodule/module.go b/core/appmodule/module.go index 6f4c9b4e2af..61714b32bb1 100644 --- a/core/appmodule/module.go +++ b/core/appmodule/module.go @@ -52,6 +52,22 @@ type HasPrecommit interface { Precommit(context.Context) error } +// ResponsePreBlock represents the response from the PreBlock method. +// It can modify consensus parameters in storage and signal the caller through the return value. +// When it returns ConsensusParamsChanged=true, the caller must refresh the consensus parameter in the finalize context. +// The new context (ctx) must be passed to all the other lifecycle methods. +type ResponsePreBlock interface { + IsConsensusParamsChanged() bool +} + +// HasPreBlocker is the extension interface that modules should implement to run +// custom logic before BeginBlock. +type HasPreBlocker interface { + AppModule + // PreBlock is method that will be run before BeginBlock. + PreBlock(context.Context) (ResponsePreBlock, error) +} + // HasBeginBlocker is the extension interface that modules should implement to run // custom logic before transaction processing in a block. type HasBeginBlocker interface { diff --git a/proto/cosmos/app/runtime/v1alpha1/module.proto b/proto/cosmos/app/runtime/v1alpha1/module.proto index c0261217027..6ada4d8ca13 100644 --- a/proto/cosmos/app/runtime/v1alpha1/module.proto +++ b/proto/cosmos/app/runtime/v1alpha1/module.proto @@ -52,6 +52,11 @@ message Module { // to call in the order in which they should be called. If this is left empty // no preparecheckstate function will be registered. repeated string prepare_check_staters = 9; + + // pre_blockers specifies the module names of pre blockers + // to call in the order in which they should be called. If this is left empty + // no pre blocker will be registered. + repeated string pre_blockers = 10; } // StoreKeyConfig may be supplied to override the default module store key, which From 7032d2b229f78758dae5b5c1c1135e0d379d9465 Mon Sep 17 00:00:00 2001 From: mmsqe Date: Sun, 20 Aug 2023 21:36:58 +0800 Subject: [PATCH 2/2] Update core/CHANGELOG.md --- core/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/CHANGELOG.md b/core/CHANGELOG.md index 7aa51692e60..134d91bcbc9 100644 --- a/core/CHANGELOG.md +++ b/core/CHANGELOG.md @@ -36,7 +36,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ ## [Unreleased] -* [#17421](https://github.com/cosmos/cosmos-sdk/pull/17421) Add `appmodule.HasPreBlocker` interface. +* [#17468](https://github.com/cosmos/cosmos-sdk/pull/17468) Add `appmodule.HasPreBlocker` interface. ## [v0.10.0](https://github.com/cosmos/cosmos-sdk/releases/tag/core%2Fv0.10.0)