diff --git a/proto/lumera/supernode/v1/supernode_state.proto b/proto/lumera/supernode/v1/supernode_state.proto index ac40787..a1a3081 100644 --- a/proto/lumera/supernode/v1/supernode_state.proto +++ b/proto/lumera/supernode/v1/supernode_state.proto @@ -17,7 +17,10 @@ enum SuperNodeState { SUPERNODE_STATE_POSTPONED = 5 [(gogoproto.enumvalue_customname) = "SuperNodeStatePostponed"]; } -message SuperNodeStateRecord { - SuperNodeState state = 1 [(gogoproto.moretags) = "yaml:\"state\""]; - int64 height = 2; -} +message SuperNodeStateRecord { + SuperNodeState state = 1 [(gogoproto.moretags) = "yaml:\"state\""]; + int64 height = 2; + // reason is an optional string describing why the state transition occurred. + // It is currently set only for transitions into POSTPONED. + string reason = 3 [(gogoproto.moretags) = "yaml:\"reason\""]; +} diff --git a/x/supernode/v1/keeper/metrics_state.go b/x/supernode/v1/keeper/metrics_state.go index 8b84e92..42cf6fb 100644 --- a/x/supernode/v1/keeper/metrics_state.go +++ b/x/supernode/v1/keeper/metrics_state.go @@ -18,7 +18,7 @@ func markPostponed(ctx sdk.Context, keeper types.SupernodeKeeper, sn *types.Supe if last.State == types.SuperNodeStatePostponed { return nil } - sn.States = append(sn.States, &types.SuperNodeStateRecord{State: types.SuperNodeStatePostponed, Height: ctx.BlockHeight()}) + sn.States = append(sn.States, &types.SuperNodeStateRecord{State: types.SuperNodeStatePostponed, Height: ctx.BlockHeight(), Reason: reason}) if err := keeper.SetSuperNode(ctx, *sn); err != nil { return err } diff --git a/x/supernode/v1/types/supernode_state.pb.go b/x/supernode/v1/types/supernode_state.pb.go index 1b75422..d660281 100644 --- a/x/supernode/v1/types/supernode_state.pb.go +++ b/x/supernode/v1/types/supernode_state.pb.go @@ -63,6 +63,9 @@ func (SuperNodeState) EnumDescriptor() ([]byte, []int) { type SuperNodeStateRecord struct { State SuperNodeState `protobuf:"varint,1,opt,name=state,proto3,enum=lumera.supernode.v1.SuperNodeState" json:"state,omitempty" yaml:"state"` Height int64 `protobuf:"varint,2,opt,name=height,proto3" json:"height,omitempty"` + // reason is an optional string describing why the state transition occurred. + // It is currently set only for transitions into POSTPONED. + Reason string `protobuf:"bytes,3,opt,name=reason,proto3" json:"reason,omitempty" yaml:"reason"` } func (m *SuperNodeStateRecord) Reset() { *m = SuperNodeStateRecord{} } @@ -112,6 +115,13 @@ func (m *SuperNodeStateRecord) GetHeight() int64 { return 0 } +func (m *SuperNodeStateRecord) GetReason() string { + if m != nil { + return m.Reason + } + return "" +} + func init() { proto.RegisterEnum("lumera.supernode.v1.SuperNodeState", SuperNodeState_name, SuperNodeState_value) proto.RegisterType((*SuperNodeStateRecord)(nil), "lumera.supernode.v1.SuperNodeStateRecord") @@ -122,34 +132,35 @@ func init() { } var fileDescriptor_bb8b41f035e29780 = []byte{ - // 418 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xd2, 0xcc, 0x29, 0xcd, 0x4d, - 0x2d, 0x4a, 0xd4, 0x2f, 0x2e, 0x2d, 0x48, 0x2d, 0xca, 0xcb, 0x4f, 0x49, 0xd5, 0x2f, 0x33, 0x44, - 0x70, 0xe2, 0x8b, 0x4b, 0x12, 0x4b, 0x52, 0xf5, 0x0a, 0x8a, 0xf2, 0x4b, 0xf2, 0x85, 0x84, 0x21, - 0x4a, 0xf5, 0xe0, 0xb2, 0x7a, 0x65, 0x86, 0x52, 0x22, 0xe9, 0xf9, 0xe9, 0xf9, 0x60, 0x79, 0x7d, - 0x10, 0x0b, 0xa2, 0x54, 0xa9, 0x9a, 0x4b, 0x24, 0x18, 0xa4, 0xca, 0x2f, 0x3f, 0x25, 0x35, 0x18, - 0x64, 0x44, 0x50, 0x6a, 0x72, 0x7e, 0x51, 0x8a, 0x90, 0x37, 0x17, 0x2b, 0xd8, 0x44, 0x09, 0x46, - 0x05, 0x46, 0x0d, 0x3e, 0x23, 0x65, 0x3d, 0x2c, 0x46, 0xea, 0xa1, 0xea, 0x74, 0x12, 0xf8, 0x74, - 0x4f, 0x9e, 0xa7, 0x32, 0x31, 0x37, 0xc7, 0x4a, 0x09, 0xac, 0x57, 0x29, 0x08, 0x62, 0x86, 0x90, - 0x18, 0x17, 0x5b, 0x46, 0x6a, 0x66, 0x7a, 0x46, 0x89, 0x04, 0x93, 0x02, 0xa3, 0x06, 0x73, 0x10, - 0x94, 0xa7, 0xf5, 0x8b, 0x89, 0x8b, 0x0f, 0xd5, 0x0c, 0x21, 0x3b, 0x2e, 0xe9, 0xe0, 0xd0, 0x00, - 0xd7, 0x20, 0x3f, 0x7f, 0x17, 0xd7, 0xf8, 0xe0, 0x10, 0xc7, 0x10, 0xd7, 0xf8, 0x50, 0xbf, 0xe0, - 0x00, 0x57, 0x67, 0x4f, 0x37, 0x4f, 0x57, 0x17, 0x01, 0x06, 0x29, 0xd9, 0xae, 0xb9, 0x0a, 0x92, - 0xa8, 0x9a, 0x42, 0xf3, 0x8a, 0x0b, 0x52, 0x93, 0x33, 0xd3, 0x32, 0x53, 0x53, 0x84, 0x4c, 0xb8, - 0xc4, 0xd0, 0xf5, 0x3b, 0x3a, 0x87, 0x78, 0x86, 0xb9, 0x0a, 0x30, 0x4a, 0x49, 0x74, 0xcd, 0x55, - 0x40, 0xf3, 0xad, 0x63, 0x72, 0x49, 0x66, 0x59, 0xaa, 0x90, 0x05, 0x97, 0x04, 0xba, 0x2e, 0x17, - 0xcf, 0x60, 0x47, 0x27, 0x1f, 0x57, 0x17, 0x01, 0x26, 0x29, 0xa9, 0xae, 0xb9, 0x0a, 0x62, 0xa8, - 0xfa, 0x5c, 0x32, 0x8b, 0x13, 0x93, 0x72, 0x52, 0x53, 0x84, 0xcc, 0xb8, 0xc4, 0xd1, 0x75, 0x06, - 0x87, 0xf8, 0x07, 0x04, 0xb8, 0xba, 0x08, 0x30, 0x4b, 0x49, 0x76, 0xcd, 0x55, 0x10, 0x45, 0xd5, - 0x18, 0x5c, 0x92, 0x5f, 0x50, 0x90, 0x9a, 0x22, 0x64, 0xc5, 0x25, 0x89, 0xae, 0x2f, 0xc0, 0xd5, - 0xcf, 0xd1, 0xc7, 0x33, 0xca, 0xd5, 0x45, 0x80, 0x45, 0x4a, 0xba, 0x6b, 0xae, 0x82, 0x38, 0xaa, - 0xce, 0x80, 0xd4, 0xbc, 0xc4, 0x9c, 0xcc, 0x2a, 0x1c, 0x7a, 0xfd, 0x83, 0x43, 0x02, 0xfc, 0xfd, - 0x5c, 0x5d, 0x04, 0x58, 0xb1, 0xea, 0xcd, 0x2f, 0x2e, 0x29, 0xc8, 0xcf, 0x4b, 0x4d, 0x91, 0xe2, - 0xe8, 0x58, 0x2c, 0xc7, 0xb0, 0x62, 0x89, 0x1c, 0xa3, 0x93, 0xde, 0x89, 0x47, 0x72, 0x8c, 0x17, - 0x1e, 0xc9, 0x31, 0x3e, 0x78, 0x24, 0xc7, 0x38, 0xe1, 0xb1, 0x1c, 0xc3, 0x85, 0xc7, 0x72, 0x0c, - 0x37, 0x1e, 0xcb, 0x31, 0x44, 0x89, 0x54, 0xa0, 0x26, 0xb2, 0x92, 0xca, 0x82, 0xd4, 0xe2, 0x24, - 0x36, 0x70, 0x82, 0x31, 0x06, 0x04, 0x00, 0x00, 0xff, 0xff, 0x09, 0xfa, 0xab, 0x3f, 0x88, 0x02, - 0x00, 0x00, + // 447 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0xd2, 0x41, 0x6b, 0xd3, 0x60, + 0x18, 0x07, 0xf0, 0xbc, 0xad, 0x2b, 0xfa, 0xa2, 0x23, 0xbe, 0xd6, 0x2e, 0xcd, 0x30, 0x0b, 0xf5, + 0xd2, 0x79, 0x48, 0x99, 0x8a, 0xc8, 0x0e, 0x42, 0xba, 0xbc, 0x42, 0x70, 0xa4, 0x21, 0x6f, 0xea, + 0x61, 0x97, 0x92, 0x35, 0x8f, 0x5d, 0xa0, 0xcb, 0x1b, 0x92, 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x6a, 0x7f, 0xac, 0x1e, 0x64, 0x7a, 0x1e, 0x41, 0x72, 0xdc, 0x2a, 0x8e, 0xeb, + 0xc5, 0xdf, 0x00, 0x00, 0x00, 0xff, 0xff, 0x4a, 0xfd, 0x91, 0xc1, 0xb4, 0x02, 0x00, 0x00, } func (m *SuperNodeStateRecord) Marshal() (dAtA []byte, err error) { @@ -172,6 +183,13 @@ func (m *SuperNodeStateRecord) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.Reason) > 0 { + i -= len(m.Reason) + copy(dAtA[i:], m.Reason) + i = encodeVarintSupernodeState(dAtA, i, uint64(len(m.Reason))) + i-- + dAtA[i] = 0x1a + } if m.Height != 0 { i = encodeVarintSupernodeState(dAtA, i, uint64(m.Height)) i-- @@ -208,6 +226,10 @@ func (m *SuperNodeStateRecord) Size() (n int) { if m.Height != 0 { n += 1 + sovSupernodeState(uint64(m.Height)) } + l = len(m.Reason) + if l > 0 { + n += 1 + l + sovSupernodeState(uint64(l)) + } return n } @@ -284,6 +306,38 @@ func (m *SuperNodeStateRecord) Unmarshal(dAtA []byte) error { break } } + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Reason", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSupernodeState + } + 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 ErrInvalidLengthSupernodeState + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthSupernodeState + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Reason = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipSupernodeState(dAtA[iNdEx:])