From f4fa606f79b24f7ec4698fbc7638b5d328f3a140 Mon Sep 17 00:00:00 2001 From: jsshenao <93172198+jsshenao@users.noreply.github.com> Date: Fri, 12 May 2023 15:04:31 +0800 Subject: [PATCH] notify rewards to provider --- proto/interchain_security/ccv/v1/ccv.proto | 7 + scripts/protocgen.sh | 0 x/ccv/consumer/keeper/distribution.go | 25 +- x/ccv/consumer/keeper/relay.go | 23 +- x/ccv/provider/ibc_module.go | 4 + x/ccv/types/ccv.go | 4 + x/ccv/types/ccv.pb.go | 350 +++++++++++++++++---- x/ccv/types/events.go | 1 + 8 files changed, 340 insertions(+), 74 deletions(-) mode change 100644 => 100755 scripts/protocgen.sh diff --git a/proto/interchain_security/ccv/v1/ccv.proto b/proto/interchain_security/ccv/v1/ccv.proto index 4af5785749..779369e5f7 100644 --- a/proto/interchain_security/ccv/v1/ccv.proto +++ b/proto/interchain_security/ccv/v1/ccv.proto @@ -53,6 +53,10 @@ message SlashPacketData { cosmos.staking.v1beta1.InfractionType infraction = 3; } +message NotifyRewardsPacketData { + int64 block_height = 1; +} + // MaturedUnbondingOps defines a list of ids corresponding to ids of matured unbonding operations. message MaturedUnbondingOps { repeated uint64 ids = 1; @@ -65,6 +69,7 @@ message ConsumerPacketData { oneof data { SlashPacketData slashPacketData = 2; VSCMaturedPacketData vscMaturedPacketData = 3; + NotifyRewardsPacketData notifyRewardsPacketData = 4; } } @@ -86,4 +91,6 @@ enum ConsumerPacketDataType { CONSUMER_PACKET_TYPE_SLASH = 1 [(gogoproto.enumvalue_customname) = "SlashPacket"]; // VSCMatured packet CONSUMER_PACKET_TYPE_VSCM = 2 [(gogoproto.enumvalue_customname) = "VscMaturedPacket"]; + // NotifyReward packet + CONSUMER_PACKET_TYPE_NOTIFY_REWARDS = 3 [(gogoproto.enumvalue_customname) = "NotifyRewardsPacket"]; } \ No newline at end of file diff --git a/scripts/protocgen.sh b/scripts/protocgen.sh old mode 100644 new mode 100755 diff --git a/x/ccv/consumer/keeper/distribution.go b/x/ccv/consumer/keeper/distribution.go index 140e135c12..733c7b3e93 100644 --- a/x/ccv/consumer/keeper/distribution.go +++ b/x/ccv/consumer/keeper/distribution.go @@ -19,26 +19,11 @@ import ( // Reward Distribution follows a simple model: send tokens to the fee pool // of the provider validator set func (k Keeper) EndBlockRD(ctx sdk.Context) { - // Split blocks rewards. - // It panics in case of marshalling / unmarshalling errors or - // if sending coins between module accounts fails. - k.DistributeRewardsInternally(ctx) - - if !k.shouldSendRewardsToProvider(ctx) { + if !k.shouldNotifyRewardsToProvider(ctx) { return } - // Try to send rewards to provider - cachedCtx, writeCache := ctx.CacheContext() - if err := k.SendRewardsToProvider(cachedCtx); err != nil { - k.Logger(ctx).Error("attempt to sent rewards to provider failed", "error", err) - } else { - // The cached context is created with a new EventManager so we merge the event - // into the original context - ctx.EventManager().EmitEvents(cachedCtx.EventManager().Events()) - // write cache - writeCache() - } + k.QueueNotifyRewardsPackets(ctx) // Update LastTransmissionBlockHeight newLtbh := types.LastTransmissionBlockHeight{ @@ -91,16 +76,16 @@ func (k Keeper) DistributeRewardsInternally(ctx sdk.Context) { } // Check whether it's time to send rewards to provider -func (k Keeper) shouldSendRewardsToProvider(ctx sdk.Context) bool { +func (k Keeper) shouldNotifyRewardsToProvider(ctx sdk.Context) bool { bpdt := k.GetBlocksPerDistributionTransmission(ctx) curHeight := ctx.BlockHeight() ltbh := k.GetLastTransmissionBlockHeight(ctx) return (curHeight - ltbh.Height) >= bpdt } -// SendRewardsToProvider attempts to send to the provider (via IBC) +// SendRewardsNotificationToProvider attempts to send to the provider (via IBC) // all the block rewards allocated for the provider -func (k Keeper) SendRewardsToProvider(ctx sdk.Context) error { +func (k Keeper) SendRewardsNotificationToProvider(ctx sdk.Context) error { // empty out the toSendToProviderTokens address ch := k.GetDistributionTransmissionChannel(ctx) transferChannel, found := k.channelKeeper.GetChannel(ctx, transfertypes.PortID, ch) diff --git a/x/ccv/consumer/keeper/relay.go b/x/ccv/consumer/keeper/relay.go index 072adf2438..64d2b213c8 100644 --- a/x/ccv/consumer/keeper/relay.go +++ b/x/ccv/consumer/keeper/relay.go @@ -10,9 +10,10 @@ import ( clienttypes "github.com/cosmos/ibc-go/v4/modules/core/02-client/types" channeltypes "github.com/cosmos/ibc-go/v4/modules/core/04-channel/types" "github.com/cosmos/ibc-go/v4/modules/core/exported" + abci "github.com/tendermint/tendermint/abci/types" + "github.com/cosmos/interchain-security/x/ccv/consumer/types" ccv "github.com/cosmos/interchain-security/x/ccv/types" - abci "github.com/tendermint/tendermint/abci/types" ) // OnRecvVSCPacket sets the pending validator set changes that will be flushed to ABCI on Endblock @@ -87,6 +88,26 @@ func (k Keeper) OnRecvVSCPacket(ctx sdk.Context, packet channeltypes.Packet, new return ack } +func (k *Keeper) QueueNotifyRewardsPackets(ctx sdk.Context) { + packet := ccv.NewNotifyRewardsPacketData(ctx.BlockHeight()) + k.AppendPendingPacket(ctx, ccv.ConsumerPacketData{ + Type: ccv.NotifyRewardsPacket, + Data: &ccv.ConsumerPacketData_NotifyRewardsPacketData{NotifyRewardsPacketData: packet}, + }) + + k.Logger(ctx).Info("NotifyRewardsPacket enqueued", "blockHeight", packet.BlockHeight) + + ctx.EventManager().EmitEvent( + sdk.NewEvent( + ccv.EventNotifyRewards, + sdk.NewAttribute(sdk.AttributeKeyModule, types.ModuleName), + sdk.NewAttribute(ccv.AttributeChainID, ctx.ChainID()), + sdk.NewAttribute(ccv.AttributeConsumerHeight, strconv.Itoa(int(ctx.BlockHeight()))), + sdk.NewAttribute(ccv.AttributeTimestamp, ctx.BlockTime().String()), + ), + ) +} + // QueueVSCMaturedPackets appends matured VSCs to an internal queue. // // Note: Per spec, a VSC reaching maturity on a consumer chain means that all the unbonding diff --git a/x/ccv/provider/ibc_module.go b/x/ccv/provider/ibc_module.go index 265310d283..b21c4eb9dc 100644 --- a/x/ccv/provider/ibc_module.go +++ b/x/ccv/provider/ibc_module.go @@ -10,6 +10,7 @@ import ( porttypes "github.com/cosmos/ibc-go/v4/modules/core/05-port/types" host "github.com/cosmos/ibc-go/v4/modules/core/24-host" ibcexported "github.com/cosmos/ibc-go/v4/modules/core/exported" + "github.com/cosmos/interchain-security/x/ccv/provider/keeper" providertypes "github.com/cosmos/interchain-security/x/ccv/provider/types" ccv "github.com/cosmos/interchain-security/x/ccv/types" @@ -190,6 +191,9 @@ func (am AppModule) OnRecvPacket( case ccv.SlashPacket: // handle SlashPacket ack = am.keeper.OnRecvSlashPacket(ctx, packet, *consumerPacket.GetSlashPacketData()) + case ccv.NotifyRewardsPacket: + // do nothing + ack = channeltypes.NewResultAcknowledgement([]byte{byte(1)}) default: errAck := channeltypes.NewErrorAcknowledgement(fmt.Errorf("invalid consumer packet type: %q", consumerPacket.Type)) ack = &errAck diff --git a/x/ccv/types/ccv.go b/x/ccv/types/ccv.go index a94a4dc549..36ad38846a 100644 --- a/x/ccv/types/ccv.go +++ b/x/ccv/types/ccv.go @@ -59,6 +59,10 @@ func NewSlashPacketData(validator abci.Validator, valUpdateId uint64, infraction } } +func NewNotifyRewardsPacketData(blockHeight int64) *NotifyRewardsPacketData { + return &NotifyRewardsPacketData{BlockHeight: blockHeight} +} + func (vdt SlashPacketData) ValidateBasic() error { if len(vdt.Validator.Address) == 0 || vdt.Validator.Power == 0 { return sdkerrors.Wrap(ErrInvalidPacketData, "validator fields cannot be empty") diff --git a/x/ccv/types/ccv.pb.go b/x/ccv/types/ccv.pb.go index 0c22465b8c..fd79d4c990 100644 --- a/x/ccv/types/ccv.pb.go +++ b/x/ccv/types/ccv.pb.go @@ -35,18 +35,22 @@ const ( SlashPacket ConsumerPacketDataType = 1 // VSCMatured packet VscMaturedPacket ConsumerPacketDataType = 2 + // NotifyReward packet + NotifyRewardsPacket ConsumerPacketDataType = 3 ) var ConsumerPacketDataType_name = map[int32]string{ 0: "CONSUMER_PACKET_TYPE_UNSPECIFIED", 1: "CONSUMER_PACKET_TYPE_SLASH", 2: "CONSUMER_PACKET_TYPE_VSCM", + 3: "CONSUMER_PACKET_TYPE_NOTIFY_REWARDS", } var ConsumerPacketDataType_value = map[string]int32{ - "CONSUMER_PACKET_TYPE_UNSPECIFIED": 0, - "CONSUMER_PACKET_TYPE_SLASH": 1, - "CONSUMER_PACKET_TYPE_VSCM": 2, + "CONSUMER_PACKET_TYPE_UNSPECIFIED": 0, + "CONSUMER_PACKET_TYPE_SLASH": 1, + "CONSUMER_PACKET_TYPE_VSCM": 2, + "CONSUMER_PACKET_TYPE_NOTIFY_REWARDS": 3, } func (x ConsumerPacketDataType) String() string { @@ -281,6 +285,50 @@ func (m *SlashPacketData) GetInfraction() types1.InfractionType { return types1.InfractionEmpty } +type NotifyRewardsPacketData struct { + BlockHeight int64 `protobuf:"varint,1,opt,name=block_height,json=blockHeight,proto3" json:"block_height,omitempty"` +} + +func (m *NotifyRewardsPacketData) Reset() { *m = NotifyRewardsPacketData{} } +func (m *NotifyRewardsPacketData) String() string { return proto.CompactTextString(m) } +func (*NotifyRewardsPacketData) ProtoMessage() {} +func (*NotifyRewardsPacketData) Descriptor() ([]byte, []int) { + return fileDescriptor_68bd5f3242e6f29c, []int{4} +} +func (m *NotifyRewardsPacketData) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *NotifyRewardsPacketData) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_NotifyRewardsPacketData.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 *NotifyRewardsPacketData) XXX_Merge(src proto.Message) { + xxx_messageInfo_NotifyRewardsPacketData.Merge(m, src) +} +func (m *NotifyRewardsPacketData) XXX_Size() int { + return m.Size() +} +func (m *NotifyRewardsPacketData) XXX_DiscardUnknown() { + xxx_messageInfo_NotifyRewardsPacketData.DiscardUnknown(m) +} + +var xxx_messageInfo_NotifyRewardsPacketData proto.InternalMessageInfo + +func (m *NotifyRewardsPacketData) GetBlockHeight() int64 { + if m != nil { + return m.BlockHeight + } + return 0 +} + // MaturedUnbondingOps defines a list of ids corresponding to ids of matured unbonding operations. type MaturedUnbondingOps struct { Ids []uint64 `protobuf:"varint,1,rep,packed,name=ids,proto3" json:"ids,omitempty"` @@ -290,7 +338,7 @@ func (m *MaturedUnbondingOps) Reset() { *m = MaturedUnbondingOps{} } func (m *MaturedUnbondingOps) String() string { return proto.CompactTextString(m) } func (*MaturedUnbondingOps) ProtoMessage() {} func (*MaturedUnbondingOps) Descriptor() ([]byte, []int) { - return fileDescriptor_68bd5f3242e6f29c, []int{4} + return fileDescriptor_68bd5f3242e6f29c, []int{5} } func (m *MaturedUnbondingOps) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -332,6 +380,7 @@ type ConsumerPacketData struct { // Types that are valid to be assigned to Data: // *ConsumerPacketData_SlashPacketData // *ConsumerPacketData_VscMaturedPacketData + // *ConsumerPacketData_NotifyRewardsPacketData Data isConsumerPacketData_Data `protobuf_oneof:"data"` } @@ -339,7 +388,7 @@ func (m *ConsumerPacketData) Reset() { *m = ConsumerPacketData{} } func (m *ConsumerPacketData) String() string { return proto.CompactTextString(m) } func (*ConsumerPacketData) ProtoMessage() {} func (*ConsumerPacketData) Descriptor() ([]byte, []int) { - return fileDescriptor_68bd5f3242e6f29c, []int{5} + return fileDescriptor_68bd5f3242e6f29c, []int{6} } func (m *ConsumerPacketData) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -380,9 +429,13 @@ type ConsumerPacketData_SlashPacketData struct { type ConsumerPacketData_VscMaturedPacketData struct { VscMaturedPacketData *VSCMaturedPacketData `protobuf:"bytes,3,opt,name=vscMaturedPacketData,proto3,oneof" json:"vscMaturedPacketData,omitempty"` } +type ConsumerPacketData_NotifyRewardsPacketData struct { + NotifyRewardsPacketData *NotifyRewardsPacketData `protobuf:"bytes,4,opt,name=notifyRewardsPacketData,proto3,oneof" json:"notifyRewardsPacketData,omitempty"` +} -func (*ConsumerPacketData_SlashPacketData) isConsumerPacketData_Data() {} -func (*ConsumerPacketData_VscMaturedPacketData) isConsumerPacketData_Data() {} +func (*ConsumerPacketData_SlashPacketData) isConsumerPacketData_Data() {} +func (*ConsumerPacketData_VscMaturedPacketData) isConsumerPacketData_Data() {} +func (*ConsumerPacketData_NotifyRewardsPacketData) isConsumerPacketData_Data() {} func (m *ConsumerPacketData) GetData() isConsumerPacketData_Data { if m != nil { @@ -412,11 +465,19 @@ func (m *ConsumerPacketData) GetVscMaturedPacketData() *VSCMaturedPacketData { return nil } +func (m *ConsumerPacketData) GetNotifyRewardsPacketData() *NotifyRewardsPacketData { + if x, ok := m.GetData().(*ConsumerPacketData_NotifyRewardsPacketData); ok { + return x.NotifyRewardsPacketData + } + return nil +} + // XXX_OneofWrappers is for the internal use of the proto package. func (*ConsumerPacketData) XXX_OneofWrappers() []interface{} { return []interface{}{ (*ConsumerPacketData_SlashPacketData)(nil), (*ConsumerPacketData_VscMaturedPacketData)(nil), + (*ConsumerPacketData_NotifyRewardsPacketData)(nil), } } @@ -429,7 +490,7 @@ func (m *ConsumerPacketDataList) Reset() { *m = ConsumerPacketDataList{} func (m *ConsumerPacketDataList) String() string { return proto.CompactTextString(m) } func (*ConsumerPacketDataList) ProtoMessage() {} func (*ConsumerPacketDataList) Descriptor() ([]byte, []int) { - return fileDescriptor_68bd5f3242e6f29c, []int{6} + return fileDescriptor_68bd5f3242e6f29c, []int{7} } func (m *ConsumerPacketDataList) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -471,6 +532,7 @@ func init() { proto.RegisterType((*ValidatorSetChangePackets)(nil), "interchain_security.ccv.v1.ValidatorSetChangePackets") proto.RegisterType((*VSCMaturedPacketData)(nil), "interchain_security.ccv.v1.VSCMaturedPacketData") proto.RegisterType((*SlashPacketData)(nil), "interchain_security.ccv.v1.SlashPacketData") + proto.RegisterType((*NotifyRewardsPacketData)(nil), "interchain_security.ccv.v1.NotifyRewardsPacketData") proto.RegisterType((*MaturedUnbondingOps)(nil), "interchain_security.ccv.v1.MaturedUnbondingOps") proto.RegisterType((*ConsumerPacketData)(nil), "interchain_security.ccv.v1.ConsumerPacketData") proto.RegisterType((*ConsumerPacketDataList)(nil), "interchain_security.ccv.v1.ConsumerPacketDataList") @@ -481,51 +543,56 @@ func init() { } var fileDescriptor_68bd5f3242e6f29c = []byte{ - // 696 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x94, 0xcf, 0x6e, 0xda, 0x4a, - 0x14, 0xc6, 0xed, 0x60, 0x45, 0xca, 0x20, 0x25, 0x8e, 0x2f, 0xf7, 0x8a, 0xf8, 0xde, 0xeb, 0x58, - 0x56, 0xd4, 0xa2, 0x56, 0xb5, 0x8b, 0xb3, 0xa9, 0xda, 0x4d, 0x03, 0x21, 0x02, 0xe5, 0x1f, 0xb2, - 0x43, 0xaa, 0x76, 0x63, 0x0d, 0xf6, 0x04, 0x46, 0x80, 0x8d, 0x3c, 0x83, 0x55, 0xde, 0xa0, 0xca, - 0xaa, 0x2f, 0x90, 0x55, 0xd5, 0x07, 0xe9, 0x2e, 0xcb, 0xec, 0x9a, 0x55, 0x54, 0x25, 0x6f, 0xd0, - 0x27, 0xa8, 0x3c, 0x18, 0x42, 0xc0, 0x41, 0xca, 0x8a, 0xe1, 0xcc, 0x39, 0x1f, 0x7c, 0xbf, 0xf9, - 0x74, 0xc0, 0x16, 0xf6, 0x29, 0x0a, 0xdd, 0x36, 0xc4, 0xbe, 0x43, 0x90, 0x3b, 0x08, 0x31, 0x1d, - 0x1a, 0xae, 0x1b, 0x19, 0x51, 0x31, 0xfe, 0xd0, 0xfb, 0x61, 0x40, 0x03, 0x49, 0x4e, 0xe9, 0xd2, - 0xe3, 0xeb, 0xa8, 0x28, 0x6f, 0xb9, 0x01, 0xe9, 0x05, 0xc4, 0x20, 0x14, 0x76, 0xb0, 0xdf, 0x32, - 0xa2, 0x62, 0x13, 0x51, 0x58, 0x1c, 0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of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x55, 0xcf, 0x8f, 0xda, 0x46, + 0x18, 0xb5, 0xd7, 0x56, 0xa4, 0x1d, 0xaa, 0x5d, 0xc7, 0xd9, 0x76, 0x89, 0xdb, 0x12, 0xd7, 0x8d, + 0x5a, 0xd4, 0xaa, 0x76, 0x61, 0x2f, 0x55, 0xdb, 0x43, 0x80, 0x05, 0x81, 0x92, 0xb0, 0x68, 0x0c, + 0x1b, 0xa5, 0x17, 0x6b, 0xb0, 0x07, 0x18, 0x01, 0x1e, 0xe4, 0x19, 0x68, 0x39, 0xf7, 0x52, 0x71, + 0xea, 0xa9, 0x37, 0x4e, 0xfd, 0x67, 0x72, 0xcc, 0xad, 0x39, 0x45, 0xd5, 0xee, 0x7f, 0xd0, 0xbf, + 0xa0, 0xf2, 0xf0, 0x63, 0x59, 0x30, 0x48, 0x39, 0x31, 0x7c, 0xf3, 0xbd, 0x37, 0x7a, 0xef, 0x7d, + 0xd6, 0x07, 0x9e, 0x92, 0x90, 0xe3, 0xc8, 0xef, 0x21, 0x12, 0x7a, 0x0c, 0xfb, 0xe3, 0x88, 0xf0, + 0xa9, 0xe3, 0xfb, 0x13, 0x67, 0x92, 0x8b, 0x7f, 0xec, 0x51, 0x44, 0x39, 0xd5, 0x8d, 0x84, 0x2e, + 0x3b, 0xbe, 0x9e, 0xe4, 0x8c, 0xa7, 0x3e, 0x65, 0x43, 0xca, 0x1c, 0xc6, 0x51, 0x9f, 0x84, 0x5d, + 0x67, 0x92, 0x6b, 0x63, 0x8e, 0x72, 0xab, 0xff, 0x0b, 0x06, 0xe3, 0xac, 0x4b, 0xbb, 0x54, 0x1c, + 0x9d, 0xf8, 0xb4, 0xac, 0x7e, 0xca, 0x71, 0x18, 0xe0, 0x68, 0x48, 0x42, 0xee, 0xa0, 0xb6, 0x4f, + 0x1c, 0x3e, 0x1d, 0x61, 0xb6,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0x37, 0x19, 0xf9, 0xcf, 0xdb, 0x8c, 0xf4, 0xf6, 0x36, 0x23, 0xbd, + 0xbb, 0xcd, 0x48, 0xbf, 0xe4, 0xba, 0x84, 0xf7, 0xc6, 0x6d, 0xdb, 0xa7, 0x43, 0x67, 0xb9, 0x4f, + 0xee, 0xcc, 0xfe, 0x6e, 0xbd, 0x98, 0x7e, 0x13, 0xab, 0x49, 0x2c, 0x89, 0xf6, 0x03, 0xb1, 0x25, + 0x2e, 0xfe, 0x0f, 0x00, 0x00, 0xff, 0xff, 0x94, 0x0e, 0xf0, 0x24, 0xc2, 0x06, 0x00, 0x00, } func (m *ValidatorSetChangePacketData) Marshal() (dAtA []byte, err error) { @@ -687,6 +754,34 @@ func (m *SlashPacketData) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *NotifyRewardsPacketData) 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 *NotifyRewardsPacketData) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *NotifyRewardsPacketData) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.BlockHeight != 0 { + i = encodeVarintCcv(dAtA, i, uint64(m.BlockHeight)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + func (m *MaturedUnbondingOps) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -807,6 +902,27 @@ func (m *ConsumerPacketData_VscMaturedPacketData) MarshalToSizedBuffer(dAtA []by } return len(dAtA) - i, nil } +func (m *ConsumerPacketData_NotifyRewardsPacketData) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ConsumerPacketData_NotifyRewardsPacketData) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + if m.NotifyRewardsPacketData != nil { + { + size, err := m.NotifyRewardsPacketData.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintCcv(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + return len(dAtA) - i, nil +} func (m *ConsumerPacketDataList) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -923,6 +1039,18 @@ func (m *SlashPacketData) Size() (n int) { return n } +func (m *NotifyRewardsPacketData) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.BlockHeight != 0 { + n += 1 + sovCcv(uint64(m.BlockHeight)) + } + return n +} + func (m *MaturedUnbondingOps) Size() (n int) { if m == nil { return 0 @@ -978,6 +1106,18 @@ func (m *ConsumerPacketData_VscMaturedPacketData) Size() (n int) { } return n } +func (m *ConsumerPacketData_NotifyRewardsPacketData) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.NotifyRewardsPacketData != nil { + l = m.NotifyRewardsPacketData.Size() + n += 1 + l + sovCcv(uint64(l)) + } + return n +} func (m *ConsumerPacketDataList) Size() (n int) { if m == nil { return 0 @@ -1408,6 +1548,75 @@ func (m *SlashPacketData) Unmarshal(dAtA []byte) error { } return nil } +func (m *NotifyRewardsPacketData) 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 ErrIntOverflowCcv + } + 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: NotifyRewardsPacketData: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: NotifyRewardsPacketData: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field BlockHeight", wireType) + } + m.BlockHeight = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCcv + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.BlockHeight |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipCcv(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthCcv + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *MaturedUnbondingOps) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -1652,6 +1861,41 @@ func (m *ConsumerPacketData) Unmarshal(dAtA []byte) error { } m.Data = &ConsumerPacketData_VscMaturedPacketData{v} iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field NotifyRewardsPacketData", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCcv + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthCcv + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthCcv + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + v := &NotifyRewardsPacketData{} + if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.Data = &ConsumerPacketData_NotifyRewardsPacketData{v} + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipCcv(dAtA[iNdEx:]) diff --git a/x/ccv/types/events.go b/x/ccv/types/events.go index 1cab3e8a15..728a37b571 100644 --- a/x/ccv/types/events.go +++ b/x/ccv/types/events.go @@ -13,6 +13,7 @@ const ( EventTypeFeeDistribution = "fee_distribution" EventTypeConsumerSlashRequest = "consumer_slash_request" EventTypeVSCMatured = "vsc_matured" + EventNotifyRewards = "notify_rewards" AttributeKeyAckSuccess = "success" AttributeKeyAck = "acknowledgement"