diff --git a/proto/babylon/btcstaking/v1/query.proto b/proto/babylon/btcstaking/v1/query.proto index 8bca2917b..4c05f7c5c 100644 --- a/proto/babylon/btcstaking/v1/query.proto +++ b/proto/babylon/btcstaking/v1/query.proto @@ -41,6 +41,11 @@ service Query { option (google.api.http).get = "/babylon/btcstaking/v1/btc_validators/{val_btc_pk_hex}/power/{height}"; } + // BTCValidatorCurrentPower queries the voting power of a BTC validator at the current height + rpc BTCValidatorCurrentPower(QueryBTCValidatorCurrentPowerRequest) returns (QueryBTCValidatorCurrentPowerResponse) { + option (google.api.http).get = "/babylon/btcstaking/v1/btc_validators/{val_btc_pk_hex}/power"; + } + // ActivatedHeight queries the height when BTC staking protocol is activated, i.e., the first height when // there exists 1 BTC validator with voting power rpc ActivatedHeight(QueryActivatedHeightRequest) returns (QueryActivatedHeightResponse) { @@ -122,6 +127,24 @@ message QueryBTCValidatorPowerAtHeightResponse { uint64 voting_power = 1; } +// QueryBTCValidatorCurrentPowerRequest is the request type for the +// Query/BTCValidatorCurrentPower RPC method. +message QueryBTCValidatorCurrentPowerRequest { + // val_btc_pk_hex is the hex str of Bitcoin secp256k1 PK of the BTC validator that + // this BTC delegation delegates to + // the PK follows encoding in BIP-340 spec + string val_btc_pk_hex = 1; +} + +// QueryBTCValidatorCurrentPowerResponse is the response type for the +// Query/BTCValidatorCurrentPower RPC method. +message QueryBTCValidatorCurrentPowerResponse { + // height is the current height + uint64 height = 1; + // voting_power is the voting power of the BTC validator + uint64 voting_power = 2; +} + // QueryActiveBTCValidatorsAtHeightRequest is the request type for the // Query/ActiveBTCValidatorsAtHeight RPC method. message QueryActiveBTCValidatorsAtHeightRequest { diff --git a/x/btcstaking/keeper/grpc_query.go b/x/btcstaking/keeper/grpc_query.go index 9e1c2c1a8..9fdad6d41 100644 --- a/x/btcstaking/keeper/grpc_query.go +++ b/x/btcstaking/keeper/grpc_query.go @@ -135,6 +135,36 @@ func (k Keeper) BTCValidatorPowerAtHeight(ctx context.Context, req *types.QueryB return &types.QueryBTCValidatorPowerAtHeightResponse{VotingPower: power}, nil } +// BTCValidatorCurrentPower returns the voting power of the specified validator +// at the current height +func (k Keeper) BTCValidatorCurrentPower(ctx context.Context, req *types.QueryBTCValidatorCurrentPowerRequest) (*types.QueryBTCValidatorCurrentPowerResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "empty request") + } + + valBTCPK, err := bbn.NewBIP340PubKeyFromHex(req.ValBtcPkHex) + if err != nil { + return nil, status.Errorf(codes.InvalidArgument, "failed to unmarshal validator BTC PK hex: %v", err) + } + + sdkCtx := sdk.UnwrapSDKContext(ctx) + power := uint64(0) + curHeight := uint64(sdkCtx.BlockHeight()) + + // if voting power table is recorded at the current height, use this voting power + if k.HasVotingPowerTable(sdkCtx, curHeight) { + power = k.GetVotingPower(sdkCtx, valBTCPK.MustMarshal(), curHeight) + } else { + // NOTE: it's possible that the voting power is not recorded at the current height, + // e.g., `EndBlock` is not reached yet + // in this case, we use the last height + curHeight -= 1 + power = k.GetVotingPower(sdkCtx, valBTCPK.MustMarshal(), curHeight) + } + + return &types.QueryBTCValidatorCurrentPowerResponse{Height: curHeight, VotingPower: power}, nil +} + // ActiveBTCValidatorsAtHeight returns the active BTC validators at the provided height func (k Keeper) ActiveBTCValidatorsAtHeight(ctx context.Context, req *types.QueryActiveBTCValidatorsAtHeightRequest) (*types.QueryActiveBTCValidatorsAtHeightResponse, error) { if req == nil { diff --git a/x/btcstaking/keeper/grpc_query_test.go b/x/btcstaking/keeper/grpc_query_test.go index 149d2677f..9ebf82df1 100644 --- a/x/btcstaking/keeper/grpc_query_test.go +++ b/x/btcstaking/keeper/grpc_query_test.go @@ -253,6 +253,51 @@ func FuzzBTCValidatorVotingPowerAtHeight(f *testing.F) { }) } +func FuzzBTCValidatorCurrentVotingPower(f *testing.F) { + datagen.AddRandomSeedsToFuzzer(f, 10) + f.Fuzz(func(t *testing.T, seed int64) { + r := rand.New(rand.NewSource(seed)) + + // Setup keeper and context + keeper, ctx := testkeeper.BTCStakingKeeper(t, nil, nil) + + // random BTC validator + btcVal, err := datagen.GenRandomBTCValidator(r) + require.NoError(t, err) + // add this BTC validator + keeper.SetBTCValidator(ctx, btcVal) + // set random voting power at random height + randomHeight := datagen.RandomInt(r, 100) + 1 + ctx = ctx.WithBlockHeight(int64(randomHeight)) + randomPower := datagen.RandomInt(r, 100) + 1 + keeper.SetVotingPower(ctx, btcVal.BtcPk.MustMarshal(), randomHeight, randomPower) + + // assert voting power at current height + req := &types.QueryBTCValidatorCurrentPowerRequest{ + ValBtcPkHex: btcVal.BtcPk.MarshalHex(), + } + resp, err := keeper.BTCValidatorCurrentPower(ctx, req) + require.NoError(t, err) + require.Equal(t, randomHeight, resp.Height) + require.Equal(t, randomPower, resp.VotingPower) + + // if height increments but voting power hasn't recorded yet, then + // we need to return the height and voting power at the last height + ctx = ctx.WithBlockHeight(int64(randomHeight + 1)) + resp, err = keeper.BTCValidatorCurrentPower(ctx, req) + require.NoError(t, err) + require.Equal(t, randomHeight, resp.Height) + require.Equal(t, randomPower, resp.VotingPower) + + // but no more + ctx = ctx.WithBlockHeight(int64(randomHeight + 2)) + resp, err = keeper.BTCValidatorCurrentPower(ctx, req) + require.NoError(t, err) + require.Equal(t, randomHeight+1, resp.Height) + require.Equal(t, uint64(0), resp.VotingPower) + }) +} + func FuzzActiveBTCValidatorsAtHeight(f *testing.F) { datagen.AddRandomSeedsToFuzzer(f, 10) f.Fuzz(func(t *testing.T, seed int64) { diff --git a/x/btcstaking/keeper/voting_power_table.go b/x/btcstaking/keeper/voting_power_table.go index 1544513d6..631cdf187 100644 --- a/x/btcstaking/keeper/voting_power_table.go +++ b/x/btcstaking/keeper/voting_power_table.go @@ -79,6 +79,14 @@ func (k Keeper) GetVotingPower(ctx sdk.Context, valBTCPK []byte, height uint64) return sdk.BigEndianToUint64(powerBytes) } +// HasVotingPowerTable checks if the voting power table exists at a given height +func (k Keeper) HasVotingPowerTable(ctx sdk.Context, height uint64) bool { + store := k.votingPowerStore(ctx, height) + iter := store.Iterator(nil, nil) + defer iter.Close() + return iter.Valid() +} + // GetVotingPowerTable gets the voting power table, i.e., validator set at a given height func (k Keeper) GetVotingPowerTable(ctx sdk.Context, height uint64) map[string]uint64 { store := k.votingPowerStore(ctx, height) diff --git a/x/btcstaking/types/query.pb.go b/x/btcstaking/types/query.pb.go index 3cf44878d..ae21dda38 100644 --- a/x/btcstaking/types/query.pb.go +++ b/x/btcstaking/types/query.pb.go @@ -500,6 +500,111 @@ func (m *QueryBTCValidatorPowerAtHeightResponse) GetVotingPower() uint64 { return 0 } +// QueryBTCValidatorCurrentPowerRequest is the request type for the +// Query/BTCValidatorCurrentPower RPC method. +type QueryBTCValidatorCurrentPowerRequest struct { + // val_btc_pk_hex is the hex str of Bitcoin secp256k1 PK of the BTC validator that + // this BTC delegation delegates to + // the PK follows encoding in BIP-340 spec + ValBtcPkHex string `protobuf:"bytes,1,opt,name=val_btc_pk_hex,json=valBtcPkHex,proto3" json:"val_btc_pk_hex,omitempty"` +} + +func (m *QueryBTCValidatorCurrentPowerRequest) Reset() { *m = QueryBTCValidatorCurrentPowerRequest{} } +func (m *QueryBTCValidatorCurrentPowerRequest) String() string { return proto.CompactTextString(m) } +func (*QueryBTCValidatorCurrentPowerRequest) ProtoMessage() {} +func (*QueryBTCValidatorCurrentPowerRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_74d49d26f7429697, []int{10} +} +func (m *QueryBTCValidatorCurrentPowerRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryBTCValidatorCurrentPowerRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryBTCValidatorCurrentPowerRequest.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 *QueryBTCValidatorCurrentPowerRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryBTCValidatorCurrentPowerRequest.Merge(m, src) +} +func (m *QueryBTCValidatorCurrentPowerRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryBTCValidatorCurrentPowerRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryBTCValidatorCurrentPowerRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryBTCValidatorCurrentPowerRequest proto.InternalMessageInfo + +func (m *QueryBTCValidatorCurrentPowerRequest) GetValBtcPkHex() string { + if m != nil { + return m.ValBtcPkHex + } + return "" +} + +// QueryBTCValidatorCurrentPowerResponse is the response type for the +// Query/BTCValidatorCurrentPower RPC method. +type QueryBTCValidatorCurrentPowerResponse struct { + // height is the current height + Height uint64 `protobuf:"varint,1,opt,name=height,proto3" json:"height,omitempty"` + // voting_power is the voting power of the BTC validator + VotingPower uint64 `protobuf:"varint,2,opt,name=voting_power,json=votingPower,proto3" json:"voting_power,omitempty"` +} + +func (m *QueryBTCValidatorCurrentPowerResponse) Reset() { *m = QueryBTCValidatorCurrentPowerResponse{} } +func (m *QueryBTCValidatorCurrentPowerResponse) String() string { return proto.CompactTextString(m) } +func (*QueryBTCValidatorCurrentPowerResponse) ProtoMessage() {} +func (*QueryBTCValidatorCurrentPowerResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_74d49d26f7429697, []int{11} +} +func (m *QueryBTCValidatorCurrentPowerResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryBTCValidatorCurrentPowerResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryBTCValidatorCurrentPowerResponse.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 *QueryBTCValidatorCurrentPowerResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryBTCValidatorCurrentPowerResponse.Merge(m, src) +} +func (m *QueryBTCValidatorCurrentPowerResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryBTCValidatorCurrentPowerResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryBTCValidatorCurrentPowerResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryBTCValidatorCurrentPowerResponse proto.InternalMessageInfo + +func (m *QueryBTCValidatorCurrentPowerResponse) GetHeight() uint64 { + if m != nil { + return m.Height + } + return 0 +} + +func (m *QueryBTCValidatorCurrentPowerResponse) GetVotingPower() uint64 { + if m != nil { + return m.VotingPower + } + return 0 +} + // QueryActiveBTCValidatorsAtHeightRequest is the request type for the // Query/ActiveBTCValidatorsAtHeight RPC method. type QueryActiveBTCValidatorsAtHeightRequest struct { @@ -515,7 +620,7 @@ func (m *QueryActiveBTCValidatorsAtHeightRequest) Reset() { func (m *QueryActiveBTCValidatorsAtHeightRequest) String() string { return proto.CompactTextString(m) } func (*QueryActiveBTCValidatorsAtHeightRequest) ProtoMessage() {} func (*QueryActiveBTCValidatorsAtHeightRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_74d49d26f7429697, []int{10} + return fileDescriptor_74d49d26f7429697, []int{12} } func (m *QueryActiveBTCValidatorsAtHeightRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -573,7 +678,7 @@ func (m *QueryActiveBTCValidatorsAtHeightResponse) Reset() { func (m *QueryActiveBTCValidatorsAtHeightResponse) String() string { return proto.CompactTextString(m) } func (*QueryActiveBTCValidatorsAtHeightResponse) ProtoMessage() {} func (*QueryActiveBTCValidatorsAtHeightResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_74d49d26f7429697, []int{11} + return fileDescriptor_74d49d26f7429697, []int{13} } func (m *QueryActiveBTCValidatorsAtHeightResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -624,7 +729,7 @@ func (m *QueryActivatedHeightRequest) Reset() { *m = QueryActivatedHeigh func (m *QueryActivatedHeightRequest) String() string { return proto.CompactTextString(m) } func (*QueryActivatedHeightRequest) ProtoMessage() {} func (*QueryActivatedHeightRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_74d49d26f7429697, []int{12} + return fileDescriptor_74d49d26f7429697, []int{14} } func (m *QueryActivatedHeightRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -662,7 +767,7 @@ func (m *QueryActivatedHeightResponse) Reset() { *m = QueryActivatedHeig func (m *QueryActivatedHeightResponse) String() string { return proto.CompactTextString(m) } func (*QueryActivatedHeightResponse) ProtoMessage() {} func (*QueryActivatedHeightResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_74d49d26f7429697, []int{13} + return fileDescriptor_74d49d26f7429697, []int{15} } func (m *QueryActivatedHeightResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -713,7 +818,7 @@ func (m *QueryBTCValidatorDelegationsRequest) Reset() { *m = QueryBTCVal func (m *QueryBTCValidatorDelegationsRequest) String() string { return proto.CompactTextString(m) } func (*QueryBTCValidatorDelegationsRequest) ProtoMessage() {} func (*QueryBTCValidatorDelegationsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_74d49d26f7429697, []int{14} + return fileDescriptor_74d49d26f7429697, []int{16} } func (m *QueryBTCValidatorDelegationsRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -769,7 +874,7 @@ func (m *QueryBTCValidatorDelegationsResponse) Reset() { *m = QueryBTCVa func (m *QueryBTCValidatorDelegationsResponse) String() string { return proto.CompactTextString(m) } func (*QueryBTCValidatorDelegationsResponse) ProtoMessage() {} func (*QueryBTCValidatorDelegationsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_74d49d26f7429697, []int{15} + return fileDescriptor_74d49d26f7429697, []int{17} } func (m *QueryBTCValidatorDelegationsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -823,6 +928,8 @@ func init() { proto.RegisterType((*QueryPendingBTCDelegationsResponse)(nil), "babylon.btcstaking.v1.QueryPendingBTCDelegationsResponse") proto.RegisterType((*QueryBTCValidatorPowerAtHeightRequest)(nil), "babylon.btcstaking.v1.QueryBTCValidatorPowerAtHeightRequest") proto.RegisterType((*QueryBTCValidatorPowerAtHeightResponse)(nil), "babylon.btcstaking.v1.QueryBTCValidatorPowerAtHeightResponse") + proto.RegisterType((*QueryBTCValidatorCurrentPowerRequest)(nil), "babylon.btcstaking.v1.QueryBTCValidatorCurrentPowerRequest") + proto.RegisterType((*QueryBTCValidatorCurrentPowerResponse)(nil), "babylon.btcstaking.v1.QueryBTCValidatorCurrentPowerResponse") proto.RegisterType((*QueryActiveBTCValidatorsAtHeightRequest)(nil), "babylon.btcstaking.v1.QueryActiveBTCValidatorsAtHeightRequest") proto.RegisterType((*QueryActiveBTCValidatorsAtHeightResponse)(nil), "babylon.btcstaking.v1.QueryActiveBTCValidatorsAtHeightResponse") proto.RegisterType((*QueryActivatedHeightRequest)(nil), "babylon.btcstaking.v1.QueryActivatedHeightRequest") @@ -834,66 +941,70 @@ func init() { func init() { proto.RegisterFile("babylon/btcstaking/v1/query.proto", fileDescriptor_74d49d26f7429697) } var fileDescriptor_74d49d26f7429697 = []byte{ - // 939 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x57, 0xdf, 0x6f, 0xdb, 0x54, - 0x14, 0xee, 0x2d, 0xa5, 0x12, 0x27, 0xe9, 0x26, 0x5d, 0x36, 0xd6, 0x7a, 0x6b, 0xb6, 0x3a, 0x6b, - 0xd3, 0x0d, 0x61, 0x37, 0x99, 0x34, 0x01, 0x03, 0xc6, 0xb2, 0xc1, 0xa2, 0x41, 0xa5, 0x60, 0x4d, - 0x20, 0xf1, 0x12, 0x5d, 0x3b, 0x57, 0x8e, 0x69, 0xea, 0xeb, 0xc5, 0xb7, 0xa6, 0x15, 0xda, 0x0b, - 0x0f, 0x48, 0x3c, 0x20, 0x21, 0xf8, 0x13, 0x78, 0xe4, 0x89, 0x67, 0x5e, 0x91, 0xd8, 0xe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, 0xe9, 0xcf, 0x08, 0xce, 0x4e, 0xf8, 0x04, - 0x6e, 0xcc, 0x6c, 0xfb, 0x94, 0xe7, 0x28, 0x37, 0x4e, 0x85, 0x91, 0x5a, 0x74, 0xa1, 0xe5, 0x1a, - 0xae, 0x65, 0x68, 0x21, 0x23, 0x5c, 0x47, 0xfe, 0x29, 0xf0, 0x0c, 0xc1, 0x85, 0x0c, 0x1f, 0xc0, - 0x6f, 0x17, 0xed, 0x6b, 0xca, 0xed, 0xdc, 0x9a, 0x0b, 0x2b, 0x55, 0x3c, 0x10, 0x2a, 0xee, 0xe1, - 0xe6, 0x9c, 0x13, 0x89, 0x5d, 0x54, 0xf3, 0xe3, 0x27, 0xc7, 0x15, 0xf4, 0xf4, 0xb8, 0x82, 0xfe, - 0x39, 0xae, 0xa0, 0xef, 0x4f, 0x2a, 0x0b, 0x4f, 0x4f, 0x2a, 0x0b, 0x7f, 0x9d, 0x54, 0x16, 0x3e, - 0x6f, 0xd8, 0x0e, 0xef, 0x1d, 0x98, 0x9a, 0xc5, 0xf6, 0x47, 0x75, 0xac, 0x1e, 0x71, 0xdc, 0x71, - 0xd1, 0xc3, 0x78, 0x59, 0x7e, 0xe4, 0x51, 0xdf, 0x5c, 0x16, 0xff, 0xfc, 0xdc, 0xf8, 0x3f, 0x00, - 0x00, 0xff, 0xff, 0x36, 0x6b, 0x31, 0xed, 0xe4, 0x0d, 0x00, 0x00, + // 998 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x57, 0xcf, 0x6f, 0xdc, 0x44, + 0x14, 0xce, 0x84, 0x10, 0x89, 0x97, 0xa4, 0x95, 0x86, 0x96, 0x26, 0x6e, 0xb3, 0x6d, 0x9c, 0xe6, + 0x47, 0x8b, 0xb0, 0xb3, 0x5b, 0xa9, 0x02, 0x12, 0x5a, 0xba, 0x09, 0x6d, 0xd4, 0x12, 0x29, 0x58, + 0x15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x21, 0x9c, 0x36, 0x13, 0x89, 0xd4, 0x6f, 0xc3, 0x15, 0xf5, 0x71, 0xfe, 0x7d, 0xea, 0xdf, 0x23, + 0x98, 0x4f, 0x55, 0x44, 0xba, 0x5b, 0x8b, 0xf5, 0xc3, 0x59, 0xdd, 0xda, 0x0b, 0xa4, 0xa8, 0x79, + 0xd5, 0x74, 0xf8, 0x02, 0x66, 0x62, 0xd3, 0x81, 0x75, 0x15, 0x73, 0xc2, 0x18, 0x3a, 0x27, 0x92, + 0xae, 0x2f, 0x45, 0x13, 0x23, 0x71, 0x70, 0x66, 0x37, 0x59, 0xfb, 0x77, 0x0a, 0x5e, 0x17, 0xea, + 0xf0, 0x37, 0x08, 0xc6, 0xc3, 0x0d, 0x88, 0x6f, 0x64, 0xd0, 0x4c, 0xaf, 0x5c, 0xed, 0x66, 0x11, + 0xd3, 0x30, 0xae, 0xbe, 0xf0, 0xf5, 0xef, 0x7f, 0xff, 0x30, 0x7a, 0x15, 0xcf, 0x9a, 0x79, 0x2f, + 0x01, 0xfc, 0x23, 0x82, 0xa9, 0x44, 0x6f, 0xe0, 0x95, 0xbc, 0x20, 0xaa, 0xc5, 0xac, 0x55, 0x4f, + 0x81, 0x90, 0xec, 0xde, 0x11, 0xec, 0x96, 0xf0, 0x82, 0x99, 0xf9, 0x06, 0x89, 0x75, 0x23, 0xfe, + 0x05, 0xc1, 0x64, 0xdc, 0x11, 0x36, 0x8b, 0x86, 0x1c, 0x70, 0x5c, 0x29, 0x0e, 0x90, 0x14, 0x37, + 0x05, 0xc5, 0x3a, 0xfe, 0xb0, 0x10, 0x45, 0xf3, 0xab, 0x64, 0x93, 0x3c, 0x35, 0x8f, 0xcf, 0xf0, + 0xaf, 0x08, 0x2e, 0x2a, 0x77, 0x1d, 0x7e, 0x37, 0xf7, 0x42, 0x73, 0x76, 0xa8, 0xf6, 0x5e, 0x09, + 0xa4, 0x14, 0x76, 0x5b, 0x08, 0x5b, 0xc1, 0x46, 0x56, 0x65, 0x84, 0xe8, 0xc6, 0x89, 0xed, 0x8b, + 0xff, 0x40, 0x70, 0x39, 0x67, 0x98, 0xe2, 0x3b, 0x79, 0x94, 0x86, 0x6f, 0x04, 0xed, 0x6e, 0x69, + 0x7c, 0x41, 0x61, 0x27, 0x6f, 0x2c, 0x1c, 0x84, 0x4f, 0xf1, 0x3f, 0x08, 0x66, 0x32, 0x17, 0x36, + 0x5e, 0x2b, 0x5a, 0x39, 0xaa, 0xd7, 0x84, 0xf6, 0x41, 0x49, 0xb4, 0x94, 0xb4, 0x25, 0x24, 0x3d, + 0xc0, 0x1f, 0x95, 0x2c, 0x42, 0xb1, 0xaa, 0x23, 0xa5, 0x2f, 0x10, 0x4c, 0x67, 0x3d, 0x00, 0xf0, + 0x6a, 0x51, 0xaa, 0x8a, 0x37, 0x88, 0xb6, 0x56, 0x0e, 0x2c, 0x65, 0x6e, 0x08, 0x99, 0x77, 0xf0, + 0xda, 0xff, 0x91, 0x89, 0x7f, 0x42, 0x70, 0xfe, 0xc4, 0x16, 0xc4, 0xb5, 0xa1, 0x45, 0x95, 0xda, + 0xa8, 0xda, 0xad, 0x53, 0x61, 0xa4, 0x04, 0x53, 0x48, 0xb8, 0x81, 0x97, 0x32, 0x24, 0x90, 0x01, + 0xae, 0x21, 0x1f, 0x3a, 0x2f, 0x11, 0x5c, 0xca, 0xd8, 0x72, 0xf8, 0xfd, 0xa2, 0xd9, 0x54, 0x4c, + 0x86, 0xd5, 0x52, 0x58, 0xa9, 0xe2, 0xa1, 0x50, 0xb1, 0x81, 0xeb, 0x25, 0x2f, 0x22, 0x36, 0x2f, + 0xea, 0x1f, 0x3f, 0x3b, 0xac, 0xa0, 0xe7, 0x87, 0x15, 0xf4, 0xd7, 0x61, 0x05, 0x7d, 0x77, 0x54, + 0x19, 0x79, 0x7e, 0x54, 0x19, 0xf9, 0xf3, 0xa8, 0x32, 0xf2, 0x79, 0xcd, 0xf5, 0x78, 0x6b, 0xcf, + 0x36, 0x1c, 0xb6, 0x3b, 0x88, 0xe3, 0xb4, 0x88, 0xe7, 0x1f, 0x07, 0xdd, 0x8f, 0x87, 0xe5, 0x07, + 0x1d, 0x1a, 0xd8, 0xe3, 0xe2, 0xb7, 0xe8, 0xad, 0xff, 0x02, 0x00, 0x00, 0xff, 0xff, 0x03, 0xab, + 0x0b, 0x81, 0x73, 0x0f, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -920,6 +1031,8 @@ type QueryClient interface { ActiveBTCValidatorsAtHeight(ctx context.Context, in *QueryActiveBTCValidatorsAtHeightRequest, opts ...grpc.CallOption) (*QueryActiveBTCValidatorsAtHeightResponse, error) // BTCValidatorPowerAtHeight queries the voting power of a BTC validator at a given height BTCValidatorPowerAtHeight(ctx context.Context, in *QueryBTCValidatorPowerAtHeightRequest, opts ...grpc.CallOption) (*QueryBTCValidatorPowerAtHeightResponse, error) + // BTCValidatorCurrentPower queries the voting power of a BTC validator at the current height + BTCValidatorCurrentPower(ctx context.Context, in *QueryBTCValidatorCurrentPowerRequest, opts ...grpc.CallOption) (*QueryBTCValidatorCurrentPowerResponse, error) // ActivatedHeight queries the height when BTC staking protocol is activated, i.e., the first height when // there exists 1 BTC validator with voting power ActivatedHeight(ctx context.Context, in *QueryActivatedHeightRequest, opts ...grpc.CallOption) (*QueryActivatedHeightResponse, error) @@ -989,6 +1102,15 @@ func (c *queryClient) BTCValidatorPowerAtHeight(ctx context.Context, in *QueryBT return out, nil } +func (c *queryClient) BTCValidatorCurrentPower(ctx context.Context, in *QueryBTCValidatorCurrentPowerRequest, opts ...grpc.CallOption) (*QueryBTCValidatorCurrentPowerResponse, error) { + out := new(QueryBTCValidatorCurrentPowerResponse) + err := c.cc.Invoke(ctx, "/babylon.btcstaking.v1.Query/BTCValidatorCurrentPower", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *queryClient) ActivatedHeight(ctx context.Context, in *QueryActivatedHeightRequest, opts ...grpc.CallOption) (*QueryActivatedHeightResponse, error) { out := new(QueryActivatedHeightResponse) err := c.cc.Invoke(ctx, "/babylon.btcstaking.v1.Query/ActivatedHeight", in, out, opts...) @@ -1021,6 +1143,8 @@ type QueryServer interface { ActiveBTCValidatorsAtHeight(context.Context, *QueryActiveBTCValidatorsAtHeightRequest) (*QueryActiveBTCValidatorsAtHeightResponse, error) // BTCValidatorPowerAtHeight queries the voting power of a BTC validator at a given height BTCValidatorPowerAtHeight(context.Context, *QueryBTCValidatorPowerAtHeightRequest) (*QueryBTCValidatorPowerAtHeightResponse, error) + // BTCValidatorCurrentPower queries the voting power of a BTC validator at the current height + BTCValidatorCurrentPower(context.Context, *QueryBTCValidatorCurrentPowerRequest) (*QueryBTCValidatorCurrentPowerResponse, error) // ActivatedHeight queries the height when BTC staking protocol is activated, i.e., the first height when // there exists 1 BTC validator with voting power ActivatedHeight(context.Context, *QueryActivatedHeightRequest) (*QueryActivatedHeightResponse, error) @@ -1050,6 +1174,9 @@ func (*UnimplementedQueryServer) ActiveBTCValidatorsAtHeight(ctx context.Context func (*UnimplementedQueryServer) BTCValidatorPowerAtHeight(ctx context.Context, req *QueryBTCValidatorPowerAtHeightRequest) (*QueryBTCValidatorPowerAtHeightResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method BTCValidatorPowerAtHeight not implemented") } +func (*UnimplementedQueryServer) BTCValidatorCurrentPower(ctx context.Context, req *QueryBTCValidatorCurrentPowerRequest) (*QueryBTCValidatorCurrentPowerResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method BTCValidatorCurrentPower not implemented") +} func (*UnimplementedQueryServer) ActivatedHeight(ctx context.Context, req *QueryActivatedHeightRequest) (*QueryActivatedHeightResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method ActivatedHeight not implemented") } @@ -1169,6 +1296,24 @@ func _Query_BTCValidatorPowerAtHeight_Handler(srv interface{}, ctx context.Conte return interceptor(ctx, in, info, handler) } +func _Query_BTCValidatorCurrentPower_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryBTCValidatorCurrentPowerRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).BTCValidatorCurrentPower(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/babylon.btcstaking.v1.Query/BTCValidatorCurrentPower", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).BTCValidatorCurrentPower(ctx, req.(*QueryBTCValidatorCurrentPowerRequest)) + } + return interceptor(ctx, in, info, handler) +} + func _Query_ActivatedHeight_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(QueryActivatedHeightRequest) if err := dec(in); err != nil { @@ -1233,6 +1378,10 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "BTCValidatorPowerAtHeight", Handler: _Query_BTCValidatorPowerAtHeight_Handler, }, + { + MethodName: "BTCValidatorCurrentPower", + Handler: _Query_BTCValidatorCurrentPower_Handler, + }, { MethodName: "ActivatedHeight", Handler: _Query_ActivatedHeight_Handler, @@ -1574,6 +1723,69 @@ func (m *QueryBTCValidatorPowerAtHeightResponse) MarshalToSizedBuffer(dAtA []byt return len(dAtA) - i, nil } +func (m *QueryBTCValidatorCurrentPowerRequest) 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 *QueryBTCValidatorCurrentPowerRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryBTCValidatorCurrentPowerRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.ValBtcPkHex) > 0 { + i -= len(m.ValBtcPkHex) + copy(dAtA[i:], m.ValBtcPkHex) + i = encodeVarintQuery(dAtA, i, uint64(len(m.ValBtcPkHex))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryBTCValidatorCurrentPowerResponse) 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 *QueryBTCValidatorCurrentPowerResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryBTCValidatorCurrentPowerResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.VotingPower != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.VotingPower)) + i-- + dAtA[i] = 0x10 + } + if m.Height != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.Height)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + func (m *QueryActiveBTCValidatorsAtHeightRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -1946,6 +2158,34 @@ func (m *QueryBTCValidatorPowerAtHeightResponse) Size() (n int) { return n } +func (m *QueryBTCValidatorCurrentPowerRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ValBtcPkHex) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryBTCValidatorCurrentPowerResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Height != 0 { + n += 1 + sovQuery(uint64(m.Height)) + } + if m.VotingPower != 0 { + n += 1 + sovQuery(uint64(m.VotingPower)) + } + return n +} + func (m *QueryActiveBTCValidatorsAtHeightRequest) Size() (n int) { if m == nil { return 0 @@ -2855,6 +3095,176 @@ func (m *QueryBTCValidatorPowerAtHeightResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *QueryBTCValidatorCurrentPowerRequest) 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 ErrIntOverflowQuery + } + 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: QueryBTCValidatorCurrentPowerRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryBTCValidatorCurrentPowerRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ValBtcPkHex", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + 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 ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ValBtcPkHex = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryBTCValidatorCurrentPowerResponse) 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 ErrIntOverflowQuery + } + 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: QueryBTCValidatorCurrentPowerResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryBTCValidatorCurrentPowerResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Height", wireType) + } + m.Height = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Height |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field VotingPower", wireType) + } + m.VotingPower = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.VotingPower |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *QueryActiveBTCValidatorsAtHeightRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/x/btcstaking/types/query.pb.gw.go b/x/btcstaking/types/query.pb.gw.go index 93af02ba0..03f33ca38 100644 --- a/x/btcstaking/types/query.pb.gw.go +++ b/x/btcstaking/types/query.pb.gw.go @@ -307,6 +307,60 @@ func local_request_Query_BTCValidatorPowerAtHeight_0(ctx context.Context, marsha } +func request_Query_BTCValidatorCurrentPower_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryBTCValidatorCurrentPowerRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["val_btc_pk_hex"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "val_btc_pk_hex") + } + + protoReq.ValBtcPkHex, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "val_btc_pk_hex", err) + } + + msg, err := client.BTCValidatorCurrentPower(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_BTCValidatorCurrentPower_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryBTCValidatorCurrentPowerRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["val_btc_pk_hex"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "val_btc_pk_hex") + } + + protoReq.ValBtcPkHex, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "val_btc_pk_hex", err) + } + + msg, err := server.BTCValidatorCurrentPower(ctx, &protoReq) + return msg, metadata, err + +} + func request_Query_ActivatedHeight_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryActivatedHeightRequest var metadata runtime.ServerMetadata @@ -541,6 +595,29 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_BTCValidatorCurrentPower_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_BTCValidatorCurrentPower_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_BTCValidatorCurrentPower_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + mux.Handle("GET", pattern_Query_ActivatedHeight_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -748,6 +825,26 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_BTCValidatorCurrentPower_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_BTCValidatorCurrentPower_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_BTCValidatorCurrentPower_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + mux.Handle("GET", pattern_Query_ActivatedHeight_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -804,6 +901,8 @@ var ( pattern_Query_BTCValidatorPowerAtHeight_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 2, 5, 1, 0, 4, 1, 5, 6}, []string{"babylon", "btcstaking", "v1", "btc_validators", "val_btc_pk_hex", "power", "height"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_BTCValidatorCurrentPower_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 2, 5}, []string{"babylon", "btcstaking", "v1", "btc_validators", "val_btc_pk_hex", "power"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_ActivatedHeight_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"babylon", "btcstaking", "v1", "activated_height"}, "", runtime.AssumeColonVerbOpt(false))) pattern_Query_BTCValidatorDelegations_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 2, 5}, []string{"babylon", "btcstaking", "v1", "btc_validators", "val_btc_pk_hex", "delegations"}, "", runtime.AssumeColonVerbOpt(false))) @@ -822,6 +921,8 @@ var ( forward_Query_BTCValidatorPowerAtHeight_0 = runtime.ForwardResponseMessage + forward_Query_BTCValidatorCurrentPower_0 = runtime.ForwardResponseMessage + forward_Query_ActivatedHeight_0 = runtime.ForwardResponseMessage forward_Query_BTCValidatorDelegations_0 = runtime.ForwardResponseMessage